I think my file(ss.root) don’t load I only use “TFile f(ss.root)” to use my file and for reading histogram i use f->Get(“histogram name”) I think it is no enough. my file(ss.root) is containing of histogram not ntuple.
I don’t know about TApplication and Run(), please explain me about them
thank you
Your file contains many different kind of objects. Some of them are THD2.
Some kind of “naming conventions” appear for some of them.
The following macro reads one of the “collection of histograms” named Det1dE, Det2dE, …, Det9dE.
{
auto ss = new TFile("ss.root");
TH2D *h;
for (int i=1; i<=9; i++) {
h = (TH2D*)ss->Get(TString::Format("Det%dE",i));
if (h) printf("Histogram named \"%s\" has the title \"%s\" and %g entries\n",
h->GetName(),h->GetTitle(), h->GetEntries());
}
}
When I run this macro I get the following result:
root [0] .x ss.C
Histogram named "Det1E" has the title "SecondCalib E1 vs E10" and 0 entries
Histogram named "Det2E" has the title "SecondCalib E2 vs E9" and 0 entries
Histogram named "Det3E" has the title "SecondCalib E3 vs E8" and 0 entries
Histogram named "Det4E" has the title "SecondCalib E4 vs E7" and 0 entries
Histogram named "Det5E" has the title "SecondCalib E5 vs E6" and 0 entries
Histogram named "Det6E" has the title "SecondCalib E6 vs E5" and 0 entries
Histogram named "Det7E" has the title "SecondCalib E7 vs E4" and 0 entries
Histogram named "Det8E" has the title "SecondCalib E8 vs E3" and 0 entries
Histogram named "Det9E" has the title "SecondCalib E9 vs E2" and 0 entries
root [1]
Thank you sooooo much
I can write it as an array of histogram
for (int i=1; i<=9; i++) {
h[i] = (TH2D*)ss->Get(TString::Format("Det%dE",i));
if (h[i]) printf("Histogram name %s with title %s has %g entries\n",
h[i]->GetName(),h[i]->GetTitle(), h[i]->GetEntries());
ps->NewPage();
c->cd();
h[i]->Draw("colz");
c->Update();
}