# Stat box for TH2

**URL:** <https://root-forum.cern.ch/t/stat-box-for-th2/31714>\
**Category:** ROOT\
**Created:** [November 22, 2018, 4:58am UTC](https://root-forum.cern.ch/t/stat-box-for-th2/31714 "2018-11-22T04:58:00Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrea91](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/2acd7d/32.png) [@Andrea91](https://root-forum.cern.ch/u/Andrea91)\
**Post date:** [November 22, 2018, 4:58am UTC](https://root-forum.cern.ch/t/stat-box-for-th2/31714/1 "2018-11-22T04:58:00Z")

</div>

What does the overflow grid for TH2 exactly say?

E.g. my first example, the field in the middle shows the number of entries, but in my second example, it is a negative number (that hist goes from -150 to 150 on both axes). How should this be interpreted?

Thanks,

Andrea

![53](https://root-forum.cern.ch/uploads/default/original/3X/f/b/fb5c1ec67cc45858a2e58518ad57294d33e2420c.png)

 ![45](https://root-forum.cern.ch/uploads/default/original/3X/4/4/4414a809f5feab25d7504ecbc7f6becea9aa0799.png)

* * *

_ROOT Version:_ Not Provided  
_Platform:_ Not Provided  
_Compiler:_ Not Provided

* * *

---

<div class="post-metadata">

**Author:** ![OSchaile](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/o/e495f1/32.png) [@OSchaile](https://root-forum.cern.ch/u/OSchaile)\
**Post date:** [November 22, 2018, 6:02am UTC](https://root-forum.cern.ch/t/stat-box-for-th2/31714/2 "2018-11-22T06:02:54Z")

</div>

Hi Andrea,  
could you specify the type of your TH2:  
TH2C, TH2I, TH2F or TH2D  
You obviously have huge numbers.  
Otto

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [November 22, 2018, 7:35am UTC](https://root-forum.cern.ch/t/stat-box-for-th2/31714/3 "2018-11-22T07:35:56Z")

</div>

Negative number for the number of entries is weird. Do you have a reproducer ?

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [November 22, 2018, 9:48am UTC](https://root-forum.cern.ch/t/stat-box-for-th2/31714/4 "2018-11-22T09:48:16Z")

</div>

Actually, negative numbers in the “underflows and overflows table” are possible if, for example, one uses negative “weights” when filling the histogram (but then I would also expect a negative “Integral”).  
But this number is quite suspicious … 2147483648LL = 0x80000000 = -1L and so -2147483648LL = 0xffffffff80000000

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [November 22, 2018, 9:58am UTC](https://root-forum.cern.ch/t/stat-box-for-th2/31714/5 "2018-11-22T09:58:28Z")

</div>

> [@Wile\_E\_Coyote](#):
>
> Actually, negative numbers of entries are possible if, for example, one uses negative “weights”

Well it depends. see for instance the following lines:

```auto
root [0] TH1D *h = new TH1D("h","h",100,-1.,1)
root [1] h->Fill(0.,1.)
root [2] h->GetEntries()
(double) 1.0000000
root [3] h->Fill(0.,-1.)
root [4] h->GetEntries()
(double) 2.0000000

```

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [November 22, 2018, 10:01am UTC](https://root-forum.cern.ch/t/stat-box-for-th2/31714/6 "2018-11-22T10:01:47Z")

</div>

We are talking about the “number of overflows and underflows” table.

---

<div class="post-metadata">

**Author:** ![Andrea91](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/2acd7d/32.png) [@Andrea91](https://root-forum.cern.ch/u/Andrea91)\
**Post date:** [November 22, 2018, 1:14pm UTC](https://root-forum.cern.ch/t/stat-box-for-th2/31714/8 "2018-11-22T13:14:36Z")

</div>

The histogram is TH2F. The weights are positive. I attached a file with the histogram.

> [@Wile\_E\_Coyote](#):
>
> 2147483648LL = 0x80000000 = -1L and so -2147483648LL = 0xffffffff80000000

Can you explain what does this mean?

[histogram.root](https://root-forum.cern.ch/uploads/default/original/3X/e/1/e17825b88b9d1c90c4bca3b2d6cc76122917d486.root) (18.9 KB)

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [November 22, 2018, 2:03pm UTC](https://root-forum.cern.ch/t/stat-box-for-th2/31714/9 "2018-11-22T14:03:53Z")

</div>

> [@Andrea91](#):
>
> Can you explain what does this mean?

[Numerology](https://en.wikipedia.org/wiki/Numerology)

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [November 22, 2018, 2:14pm UTC](https://root-forum.cern.ch/t/stat-box-for-th2/31714/10 "2018-11-22T14:14:53Z")

</div>

Your histogram has 9670702 entries and it then triggers a bug in the [THistPainter::PaintStat2](https://root.cern.ch/root/html534/src/THistPainter.cxx.html#cbx6.) method:

```auto
      if (h2->GetEntries() < 1e7)
         snprintf(t, 100," %7d|%7d|%7d\n", (Int_t)unov[3], (Int_t)unov[4], (Int_t)unov[5]);
      else
         snprintf(t, 100," %7d|%14.7g|%7d\n", (Int_t)unov[3], (Float_t)unov[4], (Int_t)unov[5]);

```

@couet The simplest fix would be to use:

```auto
      if (TMath::Abs(unov[4]) < 1.e7)

```

This bug is present in ROOT 5 and 6.

Note that this bug will also appear for another fields, as soon as they exceed the maximum value 2147483647 possible for an “(Int\_t)”.

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [November 22, 2018, 3:19pm UTC](https://root-forum.cern.ch/t/stat-box-for-th2/31714/11 "2018-11-22T15:19:17Z")

</div>

@Wile_E_Coyote yes I was looking at that too.

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [November 22, 2018, 4:21pm UTC](https://root-forum.cern.ch/t/stat-box-for-th2/31714/12 "2018-11-22T16:21:06Z")

</div>

@Wile_E_Coyote the fix you suggested is correct. I just pushed it in master.  
Thanks !

---

<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:** [December 6, 2018, 4:21pm UTC](https://root-forum.cern.ch/t/stat-box-for-th2/31714/13 "2018-12-06T16:21:12Z")

</div>

Closed on December 6, 2018, 4:21pm UTC

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