I’m trying to create a macro to open each histogram and fit it, but when I plot the histograms they’re blank.
My code is currently:
TFile * file = new TFile(OutputFileRoot.root);
TList * list = (TList *) file->GetDirectory(MyList)->GetListOfKeys();
TH1D* histo = (TH1D*)list->FindObject("Hist1");
histo->Draw();
All that appears is a blank canvas. I’ve checked that the histogram exists by doing ‘if(!histo) std::cout<<“no histo”<<std::endl;’, and nothing is printed, but if I change the name to something that I know doesn’t exist then the statement is printed. So an object with this name exists and is cast to a TH1D*.
Where am I going wrong? Thanks in advance for any help.
I was too minimal in my suggestions. [It is not important but puzzling that the previous code was returning a value (then mis-used) but the new code did not]. What you really should be using in order to be able to find the newest key for a name is: