I have a very simple query about setting error using SetBinError() method.
I have a histogram filled like h->Fill(x,w); where "w" is the weight for each entry. After filling "h" I decide to apply different scales to each bin and set new content as (scale_i * x) for each bin "i". In this case how I should get and set the correct error (using SetBinError() method) for each bin in the new histogram?
Thanks in advance,
In the ref guide, there is some info concerning the errors of a scaled histogram …
Have you seen it ?
root.cern.ch/doc/master/classTH … ae0860bfbd
Thanks for your prompt reply. Yes I have seen this earlier but not sure I fully understand. I am aware that h->Fill() will take care error properly if declared h->Sumw2(), but here i am making a new histogram by ->SetBinContent() method.
I am applying a different scale to each bin to my “h” histogram to get a new histogram like this:
h->Fill(x, w); // then stored in a root file
// later I do this
h_new->SetBinContent(i, h->GetBinContent(i) * scale[i]); // i is for each bin scale is different for each i
My query is what ?? should be in this case.
If you are scaling yourself the histogram content using TH1::SetBinContent you should also scale the error using
so is this the correct way?
h_new->SetBinError(i, (h->GetBinError(i) * scale[i]) );
( because I understand h->GetBinError(i) is sum of square of weights used while filling h)
okay, I got the answer and it is the correct way. Thanks you all for your reply.