Mismatch in root file addition

I have three root file each has identical branches information. In each file there are two branches named Edep and Edep1 . Now in one method I added three root file by reading this way :
for(Int_t i = 1; i<=3; ++i)
{ string InputFile = “1E6_solid_20_”+to_string(i)+“.root”;
here the spectrum I got

Since these three file has similar info , I tried another method . Taking any one of the file then filling the histogram three times like this way :
for(Int_t i=1;i<=3;i++){
for(Int_t iEntry=0;iEntry<Edep_Branch->GetEntries();iEntry++)
{
Edep_Branch->GetEntry(iEntry);
if(Edep_info!=0)
Edep_his_4pi->Fill(Edep_info);
}
here the spectrum I got


.
Why this mismatch is coming ? Note the no of entries also very much different . Here I added branch named ‘Edep1’ .

But with branch ‘Edep’ this method worked well . No of entries matches also.

I also find problem in overlap this spectrum. First one needed log scale for visualization but second one does not.

To merge into one root file, use hadd; to just concatenate on-the-fly (not writing, unless you explicitly save), use a TChain. See this and the TChain docs (or search this forum for examples of both hadd and TChain).

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