# Manual histogram bin distribution

**URL:** <https://root-forum.cern.ch/t/manual-histogram-bin-distribution/63200>\
**Category:** Newbie\
**Created:** [March 24, 2025, 3:30pm UTC](https://root-forum.cern.ch/t/manual-histogram-bin-distribution/63200 "2025-03-24T15:30:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![phylmath](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/phylmath/32/38400_2.png) [@phylmath](https://root-forum.cern.ch/u/phylmath)\
**Post date:** [March 24, 2025, 3:30pm UTC](https://root-forum.cern.ch/t/manual-histogram-bin-distribution/63200/1 "2025-03-24T15:30:23Z")

</div>

_ROOT Version:_ 6.32.04  
_Platform:_ WSL2 Ubuntu

Hello! From what I understand, the following command:

`TH1D *hist = new TH1D("hist", " ", 50, 0, 0.4);`

… defines a histogram of 50 equally-spaced bins between 0 and 0.4 on the x-axis. However, is it possible to manually set a bin distribution? I need the bins to be defined as follows:

```auto
5.00E-3
1.50E-2
2.50E-2
3.50E-2
4.50E-2
6.00E-2
8.00E-2
1.05E-1
1.35E-1
1.85E-1
2.60E-1
3.50E-1

```

Thanks in advance! Cheers.

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [March 24, 2025, 3:43pm UTC](https://root-forum.cern.ch/t/manual-histogram-bin-distribution/63200/2 "2025-03-24T15:43:10Z")

</div>

Use this constructor:  
[https://root.cern/doc/master/classTH1D.html#a0a805a27aba096fe3cdba020701da9df](https://root.cern/doc/master/classTH1D.html#a0a805a27aba096fe3cdba020701da9df)

where you pass the number of bins and an array with the lower edges of the bins (see [ROOT: TH1 Class Reference](https://root.cern/doc/master/classTH1.html#a3ba472a2a1e853307c8368ddba833637))

---

<div class="post-metadata">

**Author:** ![phylmath](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/phylmath/32/38400_2.png) [@phylmath](https://root-forum.cern.ch/u/phylmath)\
**Post date:** [March 24, 2025, 3:54pm UTC](https://root-forum.cern.ch/t/manual-histogram-bin-distribution/63200/3 "2025-03-24T15:54:43Z")

</div>

Thanks for responding. Following your link, I took each value in the previous table I shared and subtracted half a bin width from it. Then I defined the histogram as follows.

```auto
float xbin[] = { 0.00E+00, 1.00E-02, 2.00E-02, 3.00E-02, 4.00E-02, 5.00E-02, 7.00E-02, 9.00E-02, 1.20E-01, 1.50E-01, 2.20E-01, 3.00E-01 }; 
TH1D *hist_ThrustP = new TH1D("hist_ThrustP", "Thrust distributions", (sizeof(xbin)/sizeof(xbin[0])-1), xbin);

```

Is this logic correct?
