TH1::SetBins Missing Candidates

Hi,

It appears that a few use cases for TH1::SetBins are missing (current valid candidates: https://root.cern.ch/doc/master/classTH1.html#aec7b0a0dfcecb6ed6d24d58428d0a8a9). I ran into this problem looking for the following:

TH1::SetBins(Int_t nx, const Double_t *xBins, Int_t ny, Double_t ymin, Double_t ymax);

In addition, the following is missing as well:

TH1::SetBins(Int_t nx, Double_t xmin, Double_t xmax, Int_t ny, const Double_t *yBins);

Finally, the combinations for three dimensional histograms are missing as well.

Thanks

@moneta should be able to help.

Hi,

Yes it is correct these functions are missing. I am not sure however if it is really important to have them, since there exists the class constructor for doing this.
What is your reason to use TH1::SetBins instead of re-create a new histogram ?

Lorenzo

If I recreate the histogram than I loose the particular address that the user has for a histogram. In more detail, I have a class (lets call it AnalysisClass) that provides some histograms which are updated from a data source. The user simply asks for the pointer and can plot and do as they please with it, if the source data changes then the histogram is updated. The AnalysisClass has an option to update the binning of an axis and the the histogram is reset and refilled from the data source.

At the moment I am using the array signature and simply creating two vectors of bins, one is simply a linear binning, while the other has custom bin edges.

In addition, to the use case above, I think it is strange to provide different signatures for the constructor and TH1::SetBins. Although, I’ve been using ROOT for many years now and this is the first time I’ve run into the issue.

Thanks

Hi,

I understand your use case now. Yes the method can be added then to be consistent with the constructor.
I would prefer to have them in TH2 and not TH1 since these are valid only for 2d histograms. I hope this is not a problem for you

Lorenzo

1 Like

I agree with you, about adding them to TH2. I just listed them in TH1 as that is where they all live now. As I understand it, most of the histogram methods for any dimension live in TH1. Thanks for adding the additional methods.

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