Hello everybody.
I have to solve an issue. I have a root file containing a number of histograms (please see the attachment).
Each histogram has already been fitted with a gaussian function. I need to extract the mean value of the gaussian function in order to plot this number as a function of time.
How can I perform this task?
Thank you in advance,
Marco.
test.root (43.7 KB)
TFile *f = new TFile(“test.root”, “READ”);
f->ls();
TH1F *h;
f->GetObject(“ZNChg-tow0”, h);
if (h) h->GetListOfFunctions()->Print();
if (h && (h->GetFunction(“gaus”))) h->GetFunction(“gaus”)->Print();
if (h && (h->GetFunction(“gaus”))) std::cout << h->GetFunction(“gaus”)->GetParameter(1) << std::endl;
f->GetObject(“ZPChg-tow0”, h);
if (h && (h->GetFunction(“gaus”))) std::cout << h->GetFunction(“gaus”)->GetParameter(1) << std::endl;
// …
f->GetObject(“hPMRefAlg”, h);
if (h && (h->GetFunction(“gaus”))) std::cout << h->GetFunction(“gaus”)->GetParameter(1) << std::endl;
[code]TFile *f = new TFile(“test.root”, “READ”);
TListIter next(f->GetListOfKeys());
TObject *o;
while (o = next()) o->Print();
next.Reset();
TH1F *h;
while (o = next()) {
f->GetObject(o->GetName(), h);
if (h && (h->GetFunction(“gaus”)))
std::cout << o->GetName() << " : "
<< h->GetFunction(“gaus”)->GetParameter(1)
<< std::endl;
}[/code]