# Adding histograms changes number of entries in ways I don't understand, please help

**URL:** <https://root-forum.cern.ch/t/adding-histograms-changes-number-of-entries-in-ways-i-dont-understand-please-help/35487>\
**Category:** ROOT\
**Created:** [August 3, 2019, 9:14pm UTC](https://root-forum.cern.ch/t/adding-histograms-changes-number-of-entries-in-ways-i-dont-understand-please-help/35487 "2019-08-03T21:14:32Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [August 4, 2019, 6:40am UTC](https://root-forum.cern.ch/t/adding-histograms-changes-number-of-entries-in-ways-i-dont-understand-please-help/35487/2 "2019-08-04T06:40:51Z")

</div>

> [@Subtracting multiple histogram with same TH2F](https://root-forum.cern.ch/t/subtracting-multiple-histogram-with-same-th2f/31114/2):
>
> I guess you could be interested in the [TH1:Integral](https://root.cern.ch/root/html534/TH1.html#TH1:Integral@1) / [TH2::Integral](https://root.cern.ch/root/html534/TH2.html#TH2:Integral@1) / [TH3::Integral](https://root.cern.ch/root/html534/TH3.html#TH3:Integral@1) and / or the [TH1::IntegralAndError](https://root.cern.ch/root/html534/TH1.html#TH1:IntegralAndError) / [TH2::IntegralAndError](https://root.cern.ch/root/html534/TH2.html#TH2:IntegralAndError) / [TH3::IntegralAndError](https://root.cern.ch/root/html534/TH3.html#TH3:IntegralAndError) methods. When you “subtract” histograms, the “number of entries” is recalculated in a different way than when you “add” them so, you may get “unexpected” / “weird” values. { TH1F \*h1 = new TH1F("h1", "h1", 100, -5., 5.); h1-\>Sumw2(kTRUE); #if 0 /\* 0 or 1 \*/ h1-\>FillRandom("gaus"); #else /\* 0 or 1 \*/ for (Int\_t i = 0; i \< …

> [@Subtracting histograms does not yield difference in entries](https://root-forum.cern.ch/t/subtracting-histograms-does-not-yield-difference-in-entries/31133):
>
> When I subtract two histograms, the number of entries in the subtracted histogram is not equal to the difference in the number of entries between the two histograms. It seems that the resulting histogram does not contain the contents of the underflow and overflow bins. This is not, however, the case for addition, which seems to preserve the sums just fine. Is this behavior expected? It is very unintuitive. Step-by-step demonstration: Get TFile and TTree and draw a branch into histograms (wit…

---

_[View the full topic](https://root-forum.cern.ch/t/adding-histograms-changes-number-of-entries-in-ways-i-dont-understand-please-help/35487)._
