Trouble with histogram integration

Hello All,
My problem:

  • Opening two different root files
  • both files have a TTree called “eng”
  • I draw two histograms from the two files.
  • Integral of the histograms from the two files gives the same result even though the files are different

Can anyone comment on how I solve this? Thanks.

Code and output attached:

[code] // Open first file
cylfile = TFile::Open(CFile);
TH1F CEngHist = new TH1F(“CEngHist”,“CEngHist”,NoOfBins,EnergyLow,EnergyHigh);
singlesTree = (TTree
)gDirectory->Get(“Events1”);
singles = singlesTree->GetEntries();
singlesTree->SetBranchAddress(“energy”,&energy);
for (singleno=0;singleno<singles;singleno++) {
singlesTree->GetEntry(singleno);
CEngHist->Fill(energy*1000.0); //Fill in keV.
TotalEnergyDeposited += energy;
}
printf("%g\n",CEngHist->Integral());

// Open Point Source________________________________________________________________________________ 

ptfile = TFile::Open(PFile);
TH1F *PEngHist=new TH1F("PEngHist","PEngHist",NoOfBins,EnergyLow,EnergyHigh);
singlesTree2     = (TTree*)gDirectory->Get("Events1");
singles    	= singlesTree2->GetEntries();
singlesTree2->SetBranchAddress("energy",&energy);
for (singleno=0;singleno<singles;singleno++) {
	singlesTree2->GetEntry(singleno);
	PEngHist->Fill(energy*1000.0);
}
printf("%g\n",PEngHist->Integral());[/code]

The answer from both the printf files are the same. And I know that they should be different from actually printing the “singles” variables.

Thanks.
Karthik

Check:
CEngHist->Integral(0, (NoOfBins + 1)); // should be equal to "singlesTree->GetEntries()"
PEngHist->Integral(0, (NoOfBins + 1)); // should be equal to "singlesTree2->GetEntries()"
I believe you maybe want to get the “sumwx” from http://root.cern.ch/root/html/TH1.html#TH1:GetStats