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