sjaved
April 9, 2018, 8:51am
1
Hi Rooters . Hope so you are all doing well .
I have seven histograms from seven different root files now i want to normalize them to unit area .
what i am doing is
TFile *f1 = new TFile("ww.root");
TFile *f2 = new TFile("TT.root");
TFile *f3 = new TFile("TTZT.root");
TH1F *h1 = (TH1F*)f1->Get("W_Tran_mass");
TH1F *h2 = (TH1F*)f2->Get("W_Tran_mass");
TH1F *h3 = (TH1F*)f3->Get("W_Tran_mass");
Double_t scale = 1/(h1->GetEntries());
h1->Scale(scale);
Double_t scale = 1/(h2->GetEntries());
h2->Scale(scale);
Double_t scale = 1/(h3->GetEntries());
h3->Scale(scale);
h1->Draw();
h2->Draw("same");
h3->Draw("same")
}
getting nothing .try diiferent root tutorials but getting no idea how i do it .
Kindly Help me.
Best Regards
couet
April 9, 2018, 9:05am
2
Somehow I have your root files already. If I do:
{
TFile *f1 = new TFile("WW.root");
TFile *f2 = new TFile("TT.root");
TFile *f3 = new TFile("TTZT.root");
TH1F *h1 = (TH1F*)f1->Get("W_Tran_mass");
TH1F *h2 = (TH1F*)f2->Get("W_Tran_mass");
TH1F *h3 = (TH1F*)f3->Get("W_Tran_mass");
Double_t scale = 1./(h1->GetEntries());
h1->Scale(scale);
scale = 1./(h2->GetEntries());
h2->Scale(scale);
scale = 1./(h3->GetEntries());
h3->Scale(scale);
h1->Draw("hist");
h2->SetLineColor(kRed); h2->Draw("hist same");
h2->SetLineColor(kGreen);h3->Draw("hist same");
}
I get:
Note that in the version of your files I have h2 and h3 are exactly the same that’s why we do not see any red histogram as it is exactly covered by the green one
sjaved
April 9, 2018, 10:13am
3
yup i do it and get a little bit different from yours .
Thank you so much for your quick reply:smiley:
Best Regards