# Error Propagation of TH1->Integral() values

Hello all,

I am trying to make sure that I am correctly propagating the statistical errors associated with some histograms that I am taking the integral value of.
Here as a snippet example of the code that I am using:
TH1D h_l = (TH1D)f_mc->Get(identifier_l.c_str());
TH1D h_c = (TH1D)f_mc->Get(identifier_c.c_str());
TH1D h_b = (TH1D)f_mc->Get(identifier_b.c_str());
h_l->Sumw2();
h_c->Sumw2();
h_b->Sumw2();
double N_l_mc = h_l->Integral();
double N_c_mc = h_c->Integral();
double N_b_mc = h_b->Integral();
double N_inc_mc = N_l_mc + N_c_mc + N_b_mc;
h_fracl_mc->SetBinContent(i,j,N_l_mc/N_inc_mc);
h_fracc_mc->SetBinContent(i,j,N_c_mc/N_inc_mc);
h_fracb_mc->SetBinContent(i,j,N_b_mc/N_inc_mc);

I was raised with the question whether or not the error appearing in my final 2D histograms (h_frac*) are being propagated correctly. I use the Sumw2 method to calculated the weighted sum square error on each of the individual histograms, but then I move the integral value to a double, do some math, and then fill that value to a histogram bin. I thought it might be useful to use the IntegralAndError method of TH1, but I’m not sure how to use that, or even if it’s necessary in this case. In the end I have a more involved calculation to carry out, but if I can figure out how to propagate through these few steps, I think I would understand for the rest.

To summarize briefly of what I want to do:
Get histogram, calculate Sumw2;
Get Integral of this histogram and store the error;
Do some math on this integral with other similar integral results, propagating the error through;
Fill this value to a new histogram with the error included.

Many thanks for the help!

Regards,
NGrieser

Hi,

Yes if you have a weighted histogram, you can use IntegralAndError to compute at the same time both the integral and its error. Then you can propagate as you wish, keeping in mind however that error propagation is an approximated method

Best Regards

Lorenzo

Moneta,

Thanks for the response. So currently I store the output of my integral as a value type double. Will I do the same thing IntegralAndError? Is the error then stored within the double object, or do I need to assign the error specifically to a new object, and then carry that all the way through? Sorry for the naive questions, but I can’t find too much use of this method on the web Regards,
Ngrieser

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