Normalizing a Histogram

Hi everyone

I’m new to using root and I’ve been trying to normalize a histogram created from a tree file but for some reason the normalization does not work. I have tried all the different methods of normalization but they don’t work
I have attached the histograms for the normalized and unnormalized histograms
hnorm.pdf (13.8 KB)
h.pdf (14.1 KB)

Hi,

try to give a look at


and let us know if you still encounter issues.

Yes I did try all the method but they produce the same result.
Is there a problem with the way I defined my loop?
{for (Long64_t ientry=0; ientry<nentries;ientry++) {
GetEntry(ientry);
for (Int_t i = 0; i < pt->size(); i++) {
h->Fill(pt->at(i),mc_event_weight);
Double_t norm = 1;
h->Scale(norm/h2->Integral(“width”));
h->Draw();}

{ for (Long64_t ientry=0; ientry<nentries;ientry++) { GetEntry(ientry); for (Int_t i = 0; i < pt->size(); i++) h->Fill(pt->at(i),mc_event_weight); } Double_t norm = 1; h->Scale(norm/h->Integral("width")); h->Draw(); }

Thank you, I see where my problems was.