# IntegralAndError Calculation

**URL:** <https://root-forum.cern.ch/t/integralanderror-calculation/45866>\
**Category:** Newbie\
**Tags:** hist, root\
**Created:** [July 15, 2021, 5:52pm UTC](https://root-forum.cern.ch/t/integralanderror-calculation/45866 "2021-07-15T17:52:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dil](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dil/32/26887_2.png) [@Dil](https://root-forum.cern.ch/u/Dil)\
**Post date:** [July 15, 2021, 5:52pm UTC](https://root-forum.cern.ch/t/integralanderror-calculation/45866/1 "2021-07-15T17:52:30Z")

</div>

Hello Rooters,

I used IntegralAndError option to look at the integration error of the histogram.(range of integration)  
But when I subtract two histogram integration, can root handle the error propagation?

Here is the snippet

```cpp
    Double_t error1,error2,error3,error4,error5;
    TAxis *axis1 = h3fold->GetXaxis();
    int bmin1 = axis1->FindBin(0.3); //xmin=0.3
    int bmax1 = axis1->FindBin(0.5);
    double norm3tot = h3fold->IntegralAndError(bmin1,bmax1,error1,"");
    TAxis *axis2 = h3->GetXaxis();
    int bmin2 = axis2->FindBin(0.3);
    int bmax2 = axis2->FindBin(0.5);
    double norm3bck = h3->IntegralAndError(bmin2,bmax2,error2,"");
    TH1F h3norm= (norm3tot/norm3bck)*(*h3);

    TAxis *axis3 = h3fold->GetXaxis();
    int bmin3 = axis3->FindBin(-0.01);
    int bmax3 = axis3->FindBin(0.05);
    double Signal = h3fold->IntegralAndError(bmin3,bmax3,error3,"");
    TAxis *axis4 = h3norm.GetXaxis();
    int bmin4 = axis4->FindBin(-0.01);
    int bmax4 = axis4->FindBin(0.05);
    double Bgnd = h3norm.IntegralAndError(bmin4,bmax4,error4,"");
    double Trues = Signal-Bgnd;

```

Just to know that is that error calculating for the Trues? Look like it doesn’t.  
I used sumW() for h3,h3fold histograms.  
Any help would be greatly appreciated.

---

<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:** [July 15, 2021, 6:16pm UTC](https://root-forum.cern.ch/t/integralanderror-calculation/45866/2 "2021-07-15T18:16:18Z")

</div>

You may want:  
`double Error = TMath::Sqrt(error3 * error3 + error4 * error4);`

---

<div class="post-metadata">

**Author:** ![Dil](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dil/32/26887_2.png) [@Dil](https://root-forum.cern.ch/u/Dil)\
**Post date:** [July 15, 2021, 6:23pm UTC](https://root-forum.cern.ch/t/integralanderror-calculation/45866/3 "2021-07-15T18:23:34Z")

</div>

Thank you, Wile.  
So If I am taking division of Coinc/Trues, What should be the error?

double Trues = Signal-Bgnd;  
TAxis \*axis5 = h2-\>GetXaxis();  
int bmin5 = axis5-\>FindBin(-0.01);  
int bmax5 = axis5-\>FindBin(0.05);  
double Coinc = h2-\>IntegralAndError(bmin5,bmax5,error5,"");  
double Efficiency = Coinc/Trues;

Error of Efficiency???

---

<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:** [July 15, 2021, 6:35pm UTC](https://root-forum.cern.ch/t/integralanderror-calculation/45866/4 "2021-07-15T18:35:04Z")

</div>

[Wikipedia → Propagation of uncertainty](https://en.wikipedia.org/wiki/Propagation_of_uncertainty#Example_formulae)

[ErrorsBase → Easy Propagation Of Error](https://errorsbase.com/e-errors/easy-propagation-of-error.html)

[ErrorsBase → Error Propagation Rules Power](https://errorsbase.com/e-errors/error-propagation-rules-power.html)

---

<div class="post-metadata">

**Author:** ![Dil](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dil/32/26887_2.png) [@Dil](https://root-forum.cern.ch/u/Dil)\
**Post date:** [July 15, 2021, 6:45pm UTC](https://root-forum.cern.ch/t/integralanderror-calculation/45866/5 "2021-07-15T18:45:55Z")

</div>

Thank you.These are really helpful.
