Hello everybody,
I have hopefully a very simple problem.
I’ve a simple .root file with only one Histo (inside a Canvas) inside.
If I try to fit the Histo I always get the error:
“illegal pointer to class object his 0x0 1397”
Here is my simple code:
TFile miofile(filename,“read”);
TCanvas can = (TCanvas)miofile.Get(“c1”);
TH1D his;
his = (TH1D)can->GetPrimitive(“MCA”);
his->Draw();
his->Fit(“gaus”,"","",xmin,xmax);
If I am writing
can->Draw();
his->Fit(“gaus”,"","",xmin,xmax);
the compiler complains as well about “his”.
If I am writing only
can->Draw();
without his->fit() everything is fine.
How can I get access to the histo?
Try:
can->GetListOfPrimitives()->ls()
can->GetListOfPrimitives()->Print()
and see if your “c1” canvas really contains a histogram (TH1) with the name “MCA”.
(Note: if it exists, make sure it’s a TH1D, and not a TH1F, for example.)