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



    • Bug
    • Status: Closed (View Workflow)
    • High
    • Resolution: Fixed
    • 5.34/00, 6.00.00
    • None
    • None
    • None
    • All environments


      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.


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


      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.




            moneta Lorenzo Moneta
            ofreyerm Oliver Freyermuth
            0 Vote for this issue
            2 Start watching this issue


              Actual End: