Re: [ROOT] error propagation

From: Dr. John Krane (jkrane@fnal.gov)
Date: Wed Jul 30 2003 - 22:17:46 MEST


Hi Justin,

Create your own functions to laboriously get the BinContent and BinError 
of each histo and manipulate them.  Put them one by one into a new 
histogram.  It is the best way to perform histogram mathematics.

I personally don't trust ROOT (and didn't trust PAW) to handle my errors 
right ever.  I have a small library of functions to add, subtract, 
multiply, divide, c=(a-b)/b, and on and on and on.  In some cases I pay 
attention only to the errors of one histogram, in others I watch both 
histograms.  I include below an example from my library.

    - John

//   a kind of scaled subtraction  a=(b-c+d)/d, with errors preserved
//   The extra +d puts the result back near 1.0 instead of near 0.0
TH1F * hbd::sshist(TH1F *a, TH1F *b, TH1F *c, TH1F *d){
  Double_t bc,cc,be,dc;
  for (Int_t i=1; i< b->GetNbinsX(); i++){
    bc=b->GetBinContent(i);
    cc=c->GetBinContent(i);
    dc=d->GetBinContent(i);
    be=b->GetBinError(i);
    if (dc && cc && bc) a->SetBinContent(i,(bc-cc+dc)/dc);
    a->SetBinError(i,0.0);
  }
  return a;
}


Justin Findlay wrote:

>Hi,
>
>I have a function composed of some constants and some random variables
>(ntuple columns) like this:
>
>f(w, x, y, z) = 20.0 *(x - y)-(w + 1000.0 /(z - y))
>
>How can I use this function as an axis of an histogram with the combined
>errors of each random variable correctly computed and displayed in the
>histogram?  Thanks,
>
>
>Justin
>
>  
>



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:14 MET