Normalising histogram

I am trying to plot Delta N/Delta M from the histogram in this hmass_copy then normalize but getting error with GetBinContent.- Function GetBinContent(ibins) is not defined in current scope

Int_t ibins;
void mass_fit(const char fname = “h_mass.root”)
// Get file and get histogram
TFile *file = TFile::Open(“h_mass.root”);
TH1F hmass_copy = (TH1F)file ->Get(“h_mass”)->Clone(“hmass_copy”);
TFile *myfile = new TFile(“hnorm.root”,“RECREATE”);
hmass_copy-> norm/GetBinContent(ibins));
//cout<<“Initial check:”<<endl;

This is incorrect. It should be hmass_copy->GetBinContent(ibins); GetBinContent() is a method of the TH1F class

Thank you, only with this that I will get the new normalized plot?

No, you can either use TH1F::Scale (Double_t c1=1, Option_t *option="")
or TH1F::DrawNormalized (Option_t *option="", Double_t norm=1) if you simply want to draw it normalized. See the TH1F class documentation

You probably want something like this:


I am sorry, no understand.

I read the DrawNormalized, I no understand what to put in macro so I can store it to use fit function.

I told you how to normalize your histogram:


Now, if it’s not what you’re asking for, could you explain what you’re trying to achieve exactly?


First plot of number vs mass. Then want the plot (derivative number)/(derivative mass), This I use to find the number of particles.(Already completed). was looking for 1.0/(hmass_copy->GetBinWidth(1));

Thank you for your help.