I have a root file called “mass_T1.root” and I want to redraw it in macro “lognormal_fit.C” and fit it.
My fit function is ready, but I don’t know how to call the histograms root file.
any ideas? lognormal_fit.C (1.2 KB)
You have 50 TH1F histograms (each of them with the name “h1” and the title “Mass”) in 50 pads in 1 TCanvas.
{
TFile *f = TFile::Open("mass_T4.root");
// f->ls();
TCanvas *c; f->GetObject("Topology1 4", c);
// c->ls();
delete f; // no longer needed
c->Draw(); // must be drawn first
for (Int_t i = 1; i <= 50; i++) { // 50 pads
c->cd(i);
TH1F *h = ((TH1F*)(gPad->FindObject("h1"))); // histogram in "current" pad
if (h) {
h->SetName(h->GetName() + TString("_") + i); // set unique name
h->SetDirectory(gROOT); // connect to "ROOT Memory"
h->Print();
// ... do here whatever you want with this histogram ...
}
}
c->cd(0);
}