Hadd is not working properly

Dear experts,
I added 2 root files: file 1 (1) and file 2 (2), into a 3rd file (3). If you open (2) and (3) you see that the histogram “AFP/SIT/hit/expert/numberOfHitVersusPileup_station0_layer0” pic respectively at 55 and 35. But when I add them with “hadd 3.root 1.root 2.root”, you can see in 3) that the same hist “AFP/SIT/hit/expert/numberOfHitVersusPileup_station0_layer0” has only 1 pic at 55 instead of having 2 at 55 and 35. During the merging I did not get any error message. Do you see what is wrong?
Regards

(1)
http://calpas.web.cern.ch/calpas/user.calpas.13131369.EXT1._000001.xAOD.340368.physics_Main.HIST.root

(2)
http://calpas.web.cern.ch/calpas/user.calpas.13131369.EXT1._000471.xAOD.340368.physics_Main.HIST.root

(3)
http://calpas.web.cern.ch/calpas/test.root

(3)

Dear experts,
any ideas?
Regards

Hi,
first of, I believe that

If you open (2) and (3) you see that...

from your first post should be

If you open (1) and (2) you see that...

Second, I downloaded your (1) and (2) and merged them myself in 5.30.06. The output follows:

Error in <TH1D::Merge>: Cannot merge ! Label histogram FirstClone contains a bin 354 which has not a label and has non-zero content
Error in <TFileMerger::MergeRecursive>: calling Merge() on 'numberOfHitVersusPileup_station0_layer0' with the corresponding object in '2.root'
Error in <TH1D::Merge>: Cannot merge ! Label histogram FirstClone contains a bin 354 which has not a label and has non-zero content
Error in <TFileMerger::MergeRecursive>: calling Merge() on 'numberOfHitVersusPileup_station0_layer1' with the corresponding object in '2.root'
Error in <TH1D::Merge>: Cannot merge ! Label histogram FirstClone contains a bin 354 which has not a label and has non-zero content
Error in <TFileMerger::MergeRecursive>: calling Merge() on 'numberOfHitVersusPileup_station1_layer0' with the corresponding object in '2.root'
Error in <TH1D::Merge>: Cannot merge ! Label histogram FirstClone contains a bin 354 which has not a label and has non-zero content
Error in <TFileMerger::MergeRecursive>: calling Merge() on 'numberOfHitVersusPileup_station1_layer1' with the corresponding object in '2.root'
Error in <TH1D::Merge>: Cannot merge ! Label histogram FirstClone contains a bin 354 which has not a label and has non-zero content
Error in <TFileMerger::MergeRecursive>: calling Merge() on 'numberOfHitVersusPileup_station1_layer2' with the corresponding object in '2.root'
Error in <TH1D::Merge>: Cannot merge ! Label histogram FirstClone contains a bin 354 which has not a label and has non-zero content
Error in <TFileMerger::MergeRecursive>: calling Merge() on 'numberOfHitVersusPileup_station1_layer3' with the corresponding object in '2.root'
Error in <TH1D::Merge>: Cannot merge ! Label histogram FirstClone contains a bin 355 which has not a label and has non-zero content
Error in <TFileMerger::MergeRecursive>: calling Merge() on 'numberOfHitVersusPileup_station2_layer0' with the corresponding object in '2.root'
Error in <TH1D::Merge>: Cannot merge ! Label histogram FirstClone contains a bin 355 which has not a label and has non-zero content
Error in <TFileMerger::MergeRecursive>: calling Merge() on 'numberOfHitVersusPileup_station2_layer1' with the corresponding object in '2.root'
Error in <TH1D::Merge>: Cannot merge ! Label histogram FirstClone contains a bin 355 which has not a label and has non-zero content
Error in <TFileMerger::MergeRecursive>: calling Merge() on 'numberOfHitVersusPileup_station2_layer2' with the corresponding object in '2.root'
Error in <TH1D::Merge>: Cannot merge ! Label histogram FirstClone contains a bin 355 which has not a label and has non-zero content
Error in <TFileMerger::MergeRecursive>: calling Merge() on 'numberOfHitVersusPileup_station2_layer3' with the corresponding object in '2.root'
Error in <TH1D::Merge>: Cannot merge ! Label histogram FirstClone contains a bin 355 which has not a label and has non-zero content
Error in <TFileMerger::MergeRecursive>: calling Merge() on 'numberOfHitVersusPileup_station3_layer0' with the corresponding object in '2.root'
Error in <TH1D::Merge>: Cannot merge ! Label histogram FirstClone contains a bin 355 which has not a label and has non-zero content
Error in <TFileMerger::MergeRecursive>: calling Merge() on 'numberOfHitVersusPileup_station3_layer1' with the corresponding object in '2.root'
Error in <TH1D::Merge>: Cannot merge ! Label histogram FirstClone contains a bin 355 which has not a label and has non-zero content
Error in <TFileMerger::MergeRecursive>: calling Merge() on 'numberOfHitVersusPileup_station3_layer2' with the corresponding object in '2.root'
Error in <TH1D::Merge>: Cannot merge ! Label histogram FirstClone contains a bin 355 which has not a label and has non-zero content
Error in <TFileMerger::MergeRecursive>: calling Merge() on 'numberOfHitVersusPileup_station3_layer3' with the corresponding object in '2.root'

Indeed, doing the same in ROOT 6.10.04 results in a histogram with the only peak at 56. I guess you should try to fix your histograms according to what ROOT5 tells.

Dear Yus,

  • thank you for your investigation.
  • why I do not have this message in root6?
  • I’m not using “Label”, so I do not see where this can come from.
    I’m doing:

h_numberOfHitVersusPileup[station][layer]=new TH1D(name.c_str(), name.c_str(), 500, 0, 80);
double avg_mu = 0.;
int nhitPerEvt[4][4]{0};

int avg_mu_bin = h_numberOfHitVersusPileup[station][layer]->FindBin(avg_mu);
h_numberOfHitVersusPileup[station][layer]->AddBinContent(avg_mu_bin, nhitPerEvt[station][layer]);

  • here is the entire code (1), do you see something wrong?

Regards

(1)
http://calpas.web.cern.ch/calpas/AFPSiTMonitor.cxx

You are welcome!

No idea, I guess hadd has changed between ROOT5 and ROOT6.

This might help: Problem with Merge and bin labels

Dear Yus,
I saw the documentation, but may I ask what is the main difference btw Fill(x) and AddBinContent(x)?
Regards

Check this regarding the difference. It’s all about updating (or not updating) the number of entries and, thus, the bin errors.

Dear Yus,
ok, thank you for your answer.
Regards

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