How to normalise a histogram to area unity?

Dear Experts,
I want to normalize a histogram to area unity. But I am not getting proper plot. Could you please check the code that I am using.

void pi0mom()
{
  TChain *t1 = new TChain();
  t1->Add("/home/souvik/belle/kek/useroot/evtgen_exp_07_d0kspi0pi0-*.root/h1");
   Float_t mult_ds, flag, deltam, pi0mass1, pi0mass2, mom, d0mass, mass, dz, dr, kid, pi0mom1, pi0mom2 ;

t1->SetBranchAddress("pi0mom1",&pi0mom1);
  t1->SetBranchAddress("pi0mom2",&pi0mom2);

TH1F *hist1 = new TH1F("","D0 MASS",50, 0,10);
  for (Int_t i=0; i < t1->GetEntries(); ++i)
    {
     t1->GetEntry(i);
    {
        //hist1->SetMaximum(1);
        hist1->Fill(pi0mom1);
    }

}
TCanvas* c1 = new TCanvas();
c1->cd();
//Double_t scale = hist1->GetXaxis()->GetBinWidth(1)/(hist1->GetIntegral());
//hist1->Scale(scale);
hist1->GetXaxis()->SetTitle("D_{0} Mass");
hist1->SetLineColor(4);
hist1->Scale(norm/hist1->Integral(“width”));
hist1->Draw();
}

Thanks in Advance


ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.