# TH1::SetBins Missing Candidates

**URL:** <https://root-forum.cern.ch/t/th1-setbins-missing-candidates/24318>\
**Category:** ROOT\
**Tags:** hist\
**Created:** [April 4, 2017, 10:15pm UTC](https://root-forum.cern.ch/t/th1-setbins-missing-candidates/24318 "2017-04-04T22:15:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [April 4, 2017, 10:15pm UTC](https://root-forum.cern.ch/t/th1-setbins-missing-candidates/24318/1 "2017-04-04T22:15:24Z")

</div>

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](https://root.cern.ch/doc/master/classTH1.html#aec7b0a0dfcecb6ed6d24d58428d0a8a9)). I ran into this problem looking for the following:

```auto
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:

```auto
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

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [April 10, 2017, 8:17am UTC](https://root-forum.cern.ch/t/th1-setbins-missing-candidates/24318/2 "2017-04-10T08:17:32Z")

</div>

@moneta should be able to help.

---

<div class="post-metadata">

**Author:** ![moneta2](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@moneta2](https://root-forum.cern.ch/u/moneta2)\
**Post date:** [April 10, 2017, 10:43am UTC](https://root-forum.cern.ch/t/th1-setbins-missing-candidates/24318/3 "2017-04-10T10:43:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [April 10, 2017, 1:48pm UTC](https://root-forum.cern.ch/t/th1-setbins-missing-candidates/24318/4 "2017-04-10T13:48:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![moneta2](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@moneta2](https://root-forum.cern.ch/u/moneta2)\
**Post date:** [April 10, 2017, 2:06pm UTC](https://root-forum.cern.ch/t/th1-setbins-missing-candidates/24318/5 "2017-04-10T14:06:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [April 10, 2017, 2:08pm UTC](https://root-forum.cern.ch/t/th1-setbins-missing-candidates/24318/6 "2017-04-10T14:08:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [April 24, 2017, 2:08pm UTC](https://root-forum.cern.ch/t/th1-setbins-missing-candidates/24318/7 "2017-04-24T14:08:41Z")

</div>

Closed on April 24, 2017, 2:08pm UTC

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