Home | News | Documentation | Download

Asymmetric Error bars

Hi forum,
I am making an efficiency turn-on plot, and I want to see the error bars. I am using the following code

  TH1F *h1= new TH1F ("h1", "h1", 125, 0, 250);
  TH1F *h2= new TH1F ("h2", "h2", 125, 0, 250);
  h1->Sumw2();
  h2->Sumw2();

  Tree->Draw("met.metcorr>>h1", trigger&&offline);
  Tree->Draw("met.metcorr>>h2", offline);

  gr = new TGraphAsymmErrors();
  gr->BayesDivide(h1,h2,"w");
  gr->SetMarkerColor(4);
  gr->SetMarkerStyle(7);
  gr->Fit(fcurve,"R");

The problem is that even for points where the ratio of the two is 1, the error bars go above 1.0. What would the procedure be to get the errors right (the efficiency cannot be more than 1.0)? I add an example *ps file to show what I mean.
Thank you!
l1-turnon.ps (1.66 MB)

Could you send a small ROOT file containing your two histograms?

Rene

Hi Rene,
EDIT:
Sorry I first attached the tree file. Now I attached the histos…
So, h1 would be the numerator, and h2 the denominator…

Thanks a lot!

Artur
histos.root (5.69 KB)

In the CVS head, I have modified TGraphAsymmErrors such that the high error + efficiency is always <=1.

Rene

Thanks Rene,
This doesn’t simply suppress errors above 1.0, but rather calculates them correctly, right?

Artur.

For a discussion about the way the errors are computed in TGraphAsymmErrors::BayesDivide, see the publications/papers indicated
in the documentation of this function.

and in the code, see the special cases:

//If either of the errors are 0, set them to 1/10 of the other error //so that the fitters don't get confused. if (low==0.0) low=high/10.; if (high==0.0) high=low/10.; if (high+mode > 1) high = 1-mode;

Rene

Ok, thanks a lot!!!

Artur.

Hi,
I would like to revive this discussion as when studying the behaviour of TGraphAsymmErrors:BayesDivide I found something I cannot understand by looking at the corresponding code (http://root.cern.ch/root/htmldoc/src/TGraphAsymmErrors.cxx.html#W.xs7B).

hnum and hden are the histos I used to evaluate the efficiency as:

heff->Divide(hnum, hden, 1., 1., "b");
hasym->BayesDivide(hnum, hden);

I printed out the following info for each bin:

cout << i << "  " << hnum->GetBinContent(i) <<  " " << hden->GetBinContent(i) << "  " << heff->GetBinContent(i) << " " << heff->GetBinError(i) << "  " << hasym->GetErrorY(i) << "  " << hasym->GetErrorYlow(i) << " " << hasym->GetErrorYhigh(i) << endl;

obtaining:

I can imagine that if hnum[i] = 0 and hden[i] > 0 the corresponding high error will decrease when increasing hden[i] (6-9 bins), but why does the error go up from 0.00431203 to 00432134 when moving from hden[i] = 4733 to hden[i] = 7117 events (9-10 bins)?

Why does the high error change even if hnum[i] = hden[i] = 0 (0-5 bins)? Why is it stable for 44-45 and 46-48 bins, but with a different value between the two ranges?

Why do I get an ErrorY = ErrorYlow = ErrorYhigh = -1 (8.5267e-312) even if the hnum[i] = 0 and any hden[i] value as in the first bins (49-60 bins)?

simone

Hi,
I agree this doesn’t seem to make sense. Perhaps something is funny with your histograms. Could you post a root file containing them?
Cheers, Andy.
PS - sorry for the delay… I was waiting for my roottalk account and everyone was busy at CHEP, I think. :slight_smile:

Hi,
as about 1 month has passed and these where example histos, I am not sure I can exactly reproduce them. At least not immediately.
But because of the output I add in the previous post (2nd and 3rd entries of the cout)

cout << i << "  " << hnum->GetBinContent(i) <<  " " << hden->GetBinContent(i) << "  " << heff->GetBinContent(i) << " " << heff->GetBinError(i) << "  " << hasym->GetErrorY(i) << "  " << hasym->GetErrorYlow(i) << " " << hasym->GetErrorYhigh(i) << endl;

you can built the histos yourself. Did you try?

s.