Uploaded image for project: 'ROOT'
  1. ROOT
  2. ROOT-5509

TH1::Merge() has problems when the histograms have no entries set.



    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: 5.34/00
    • Fix Version/s: None
    • Component/s: Math Libraries
    • Labels:
    • Environment:



      As TH1::Merge() skips histograms which do not have the entries set and by that has problems with merging these kind of histograms as it detects them at the moment as labeled histograms with non zero bin content (if only bin content is set but no entries).
      In addition when the first histogram has no entries set and is skipped the merge function has problems calculating the correct axis ranges if both histograms do not have the exact same axis limits.
      As a fix we could not skip the first histogram. We can look for the variable "initialLimitsFound" and check for this one before skipping this empty histogram.

      So the old source

      5211: do {
      5212: // skip empty histograms
      5213: if (h->fTsumw == 0 && h->GetEntries() == 0) continue;

      would then become

      5211: do {
      5212: // skip empty histograms
      5213: if (h->fTsumw == 0 && h->GetEntries() == 0 && initialLimitsFound) continue;

      Anyhow there would be the question if skipping empty histograms is desired? What is the reason for skipping them? Especially if the histograms have different axis limits one might want to append also empty histograms. At the moment this is not possible so maybe it is worth a thought.


        1. 0001-Fixes-bugs-in-TH1-Merge-TH2-Merge-and-TH3-Merge.patch
          13 kB
          Andreas Bachlechner
        2. 0002-Fix-merging-of-histograms-with-non-equidistant-binni.patch
          13 kB
          Bastian Beischer
        3. th1MergeTest.cc
          1.0 kB
          Andreas Bachlechner
        4. th2MergeTest.cc
          1 kB
          Andreas Bachlechner
        5. th3MergeTest.cc
          1 kB
          Andreas Bachlechner



            • Assignee:
              moneta Lorenzo Moneta
              abachlec Andreas Bachlechner
            • Votes:
              7 Vote for this issue
              5 Start watching this issue


              • Created:
                Actual End: