[ROOT-5611] Calling TProfile[xD]::Rebuild() after modifying the binning of an axis breaks the size of inner fBinEntries array Created: 22/Oct/13  Updated: 15/May/19  Resolved: 04/Dec/13

Status: Closed
Project: ROOT
Component/s: None
Affects Version/s: 5.34/00, 6.00.00
Fix Version/s: None

Type: Bug Priority: High
Reporter: Oliver Freyermuth Assignee: Lorenzo Moneta
Resolution: Fixed Votes: 0
Labels: None

All environments

Actual End:


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.

Comment by Lorenzo Moneta [ 04/Dec/13 ]


This has been fixed by re-implemnting for the TProfile classes the method SetBinsLength


Generated at Mon Feb 17 08:08:21 CET 2020 using Jira 8.3.4#803005-sha1:1f96e09b3c60279a408a2ae47be3c745f571388b.