Finding number of events

In the attached histogram I want find the number of evnet before 50 GeV. Here is the macro which takes histogram from the input root file:
void pt()
{


TFile *myfile_1=TFile::Open("/storage/submitDir/CxAOD.root",“READ”);
TH1F myhist_1= new TH1F(“myhist”,“h1”,100,0.0,250.);
myhist_1=(TH1F
)myfile_1->Get(“muon_Pt”);
TCanvas *c1 = new TCanvas();
c1->cd();
gStyle->SetOptStat(kFALSE);
myhist_1->Integral(myhist_1->FindFixBin(0.), myhist_1->FindFixBin(50.) - 1);
myhist_1->SetLineWidth(3);
myhist_1->SetTitle("");
myhist_1->GetXaxis()->SetTitle(" Electron Pt [GeV]");
myhist_1->GetYaxis()->SetTitle(“Events”);
myhist_1->Rebin(2);
myhist_1->Draw(“l”);
}

Try:

std::cout << myhist_1->Integral(myhist_1->FindFixBin(0.), myhist_1->FindFixBin(50.) - 1) << std::endl;
1 Like

I modified as per your suggestion and after compiling the code I don’t see any number of events just only can the same histogram.

You do not print it anywhere.

1 Like

I have one another question. I would like to change the histogram style as attached. This could be done by the macro which produced this histogram or by the code?

signal_electron_pt.pdf (13.9 KB)

myhist_1->Draw("HIST");
1 Like

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