I’m reading a rootfile that has several histograms and I was working with root 5.34 and this was working perfectly but recently I started to work with root 6.06 and suddenly when I open my file to obtain the graph of a histogram like this:
I obtain an error from root 6 that is:
error: use of undeclared identifier ‘histo_tst1’
I wiil be very happy if you help me with this error,
Thank you very much.
I cannot reproduce this. Could you provide us with a script (that we can run, i.e. with the necessary data files) that shows this behavior?
Hi Axel, this forum doesn’t allow me attach archives yet, because I’m a new user, but this is the macro that I was working with:
TFile *file1 = TFile::Open("fig_histograms_my_input0.root");
TFile *file2 = TFile::Open("root5_rho_1_my_input0.root");
TFile *file3 = TFile::Open("root6_rho_1_my_input0.root");
TFile *file4 = TFile::Open("root6_rho_2_my_input0.root");
cout<<" -->Running: myEfficiency"<<endl;
myTitle = ".pdf";
myTitle2 = "graphs/";
n=0; g[n] = new TCanvas(Form("all%d",n),"Compare number of tracks"), g[n]->Divide(2,3);
tst20->SetTitle("ntracks for root5_larsoft_v05_14_01");
The thing is that this macro run with root 5 perfectly, but with root 6 don’t.
Thank you very much .
In ROOT 6, you must create histogram pointers and then retrieve your histograms manually. So, for each histogram, you should have something like:
TH1F *h; SomeRootFile->GetObject("SomeHistoName", h);
Note also that, you should not use the “same” drawing option, if nothing has been drawn yet (in the current pad).
Note that if the current canvas in empty the option “same” will be ignored. But in principle you are right.
I’ll give some background in case anyone cares / reads this We went back and forth with this in ROOT 6; what you observe is likely the long lasting result:
It’s easy to misspell variables. I do it all the time. To make sure that we know what we’re talking about, we decided to stop doing magic variables in named macros (anything that has a function inside). We had cases - also in ROOT tutorials - where broken code was hidden because of these magic variables, giving wrong results.
We also like the fact that code that looks like code is now much closer to what the compiler would accept (except for
#includes) making it less confusing for novices why “sometimes” something is okay and sometimes it’s not.
Note that these magic variables continue to work on the prompt: opening a ROOT file with a histogram called
histo will still allow you to simply issue a
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.