How to set 'error in SetBinError'

Hello everyone.
I am trying to use SetBinError, but little bit confused about the error analysis formula. I have three histograms h1, h2, h3. They have same binning.

TH1D* hr
double nbins = h1->GetNbinsX();
for( int i = 0; i< nbins; i++)
   double get_h1 = h1->GetBinContent(i+1);
   double get_h2 = h2->GetBinContent(i+1);
   double get_h3 = h3->GetBinContent(i+1);
   double get_setcontent = (h1 - (h2*h3));
   hr -> SetBinContent(i+1, get_setcontent);

   double geterror_h1 = h1->GetBinError(i+1);
   double geterror_h1 = h1->GetBinError(i+1);
   double geterror_h1 = h1->GetBinError(i+1);
   double error1 = (geterror_h1 - (geterror_h2*geterror_h3));
   double error2 = ( geterror_h1 - (geterror_h2*get_h3) - (get_h2*geterror_h3) );
   hr -> SetBinError(i+1, error1 or error2 ); ????????????????????????????????????

What should be the correct SetbinError? error1 or error2 or something else?

Thank you

@couet can you please take a look?

Thank you in advance,

I guess it is up to you to decide what the errors should be.

Hi Sayan,

what does the following do exactly?

Are you trying to manipulate histograms in a loop over bins? Or are these bin contents of three different histograms?

Also, why nbins is a double and not an int here:


Hi yus,

Thanks. These are the typing mistake! These are the bin contents of these three histograms!
It should be " double get_setcontent = (get_h1 - (get_h2*get_h3));"
And you are right, nbins is integer variable.

Can you please suggest the proper error formula for the above equation?

For this line.


I’m not sure this is correct, but I’d do something like this:

const double overallRelativeUncertainty = TMath::Sqrt(TMath::Sq(geterror_h1/get_h1) + TMath::Sq(geterror_h2/get_h2) + TMath::Sq(geterror_h3/get_h3));
hr->SetBinError(i+1, overallRelativeUncertainty * get_setcontent);

Thanks yus,

I’d definitely check with this :slightly_smiling_face:


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