Hello,

I see that when I add two histograms with TH1::Add() after calling TH1::Sumw2() the entries are set to the sum of the entries, whereas when I subtract them the entries are far fewer. I have already read the same question in this post:

however I still don’t understand why the two cases are treated differently.

I have read the code of TH1::Add() and wonder why statistics are reset if the coefficient of the second histogram is negative (why is there a risk of getting negative variances?), and why the resulting histogram is considered as weighted, thus using effective entries instead of “normal” entries in the stats box, which also affects mean error and standard deviation error. I see that a double called nEntries is calculated, but SetEntries(nEntries) is called only if the histograms are added, not if they are subtracted:

```
1083 // - Add statistics
1084 Double_t nEntries = TMath::Abs( c1* h1->GetEntries() + c2* h2->GetEntries() );
//[...]
1087 // statistics can be preserved only in case of positive coefficients
1088 // otherwise with negative c1 (histogram subtraction) one risks to get negative variances
1089 // also in case of scaling with the width we cannot preserve the statistics.
//[...]
1095 Bool_t resetStats = (c1*c2 < 0) || normWidth;
if (resetStats) {
1185 // statistics need to be reset in case coefficient are negative
1186 ResetStats();
1187 }
1188 else {
//[...]
1191 SetEntries(nEntries);
1192 }
```

My histograms are unweighted but I used Sumw2() to add bin errors in quadrature, so that after fitting the resulting histogram the reduced chi-square is close to 1.

I can use hdiff->SetEntries(h1->GetEntries()-h2->GetEntries()); however, when mean error and rms error are calculated, effective entries are still used instead of entries and I see no SetEffectiveEntries() method.

Thank you in advance for your help.

*ROOT Version:* 6.18/04

*Platform:* Ubuntu 19.04 x86_64

*Compiler:* g++9