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

Calling TProfile[xD]::Rebuild() after modifying the binning of an axis breaks the size of inner fBinEntries array

    XMLWordPrintable

    Details

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

      All environments

      Description

      Dear ROOTers,

      while finding a general way to modify axises of histograms after the initial booking, I found a problem with any TProfile. Consider the following example:

      TProfile foo("foo", "foo", 10, 0, 10);

      At this point (as a Dump() shows), fBinEntries.fN is 12, as expected, and fXaxis.fNbins is 10.
      Now:

      foo.GetXaxis()->Set(100,0,10);

      This of course only modified fXaxis.fNbins. Now a call to Rebuild should fix the situation:

      foo.Rebuild();

      Another Dump() shows that fNcells was correctly fixed, but fBinEntries.fN is still 12, and filling into the TProfile (of any dimension) will cause invalid writes or segmentation faults.

      The way to go is:

      foo.TH1::Sumw2(kFALSE); // To suppress warning that Sumw2 is already created, interestingly statement has no effect in interpreter, appears to works fine in compiled code...
      foo.BuildOptions(0,0," ");

      It appears fBinEntries is only modified in TProfile::BuildOptions and TProfile::SetBins but not in Rebuild() (naturally not as this is inherited from TH1 without any override).

      Why not call SetBins instead?

      SetBins is not the way to go if only some of the axises should have a variable binning (and is of course not a method of the common baseclass, as the number of parameters has to differ for each dimensionality, which makes it much less convenient if you don't want to care about the actual histogram class which is in use).

      Of course the outlined way to use TProfile::BuildOptions works perfectly well for me, but I think that TProfile::Rebuild should either be implemented for each TProfile to set the correct size for the fBinEntries array or be forbidden in all TProfile-classes.

        Attachments

          Activity

            People

            • Assignee:
              moneta Lorenzo Moneta
              Reporter:
              ofreyerm Oliver Freyermuth
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Actual End: