TGraphAsymmErrors::Divide with weights

hi all

i’m trying to use TGraphAsymmErrors::Divide to compute an efficiency of weighted histograms and i get a puzzling behaviour.

i compile and run the following C++ program:

///////////////////////// BEGIN

#include
#include “TGraphAsymmErrors.h”
#include “TFile.h”
#include “TH1D.h”
#include “TCanvas.h”

int main() {

TFile* file = TFile::Open(“prova.root”);

TH1D* h1_denom = (TH1D*)file->Get(“denom”);
TH1D* h1_num = (TH1D*)file->Get(“num”);

for( unsigned ibin=1; ibin<h1_num->GetNbinsX(); ++ibin )
std::cout << ibin << " pass/total: " << h1_num->GetBinContent(ibin) << “/” << h1_denom->GetBinContent(ibin) << std::endl;

TGraphAsymmErrors* gr = new TGraphAsymmErrors();
gr->Divide( h1_num, h1_denom );

TCanvas* c1 = new TCanvas(“c1”, “”, 600, 600);
c1->cd();
gr->Draw(“APE”);
c1->SaveAs(“test.eps”);

return 0;

}

////////////////////////////////////// END

where the file “prova.root” can be found in /afs/cern.ch/user/p/pandolf/public

as you can see by running it yourself, i get the following output:

1 pass/total: 76.564/78.4033
2 pass/total: 157.693/163.85
3 pass/total: 3817.17/4081.08
4 pass/total: 3918.11/4204.31
5 pass/total: 161.009/167.809
Error in ROOT::Math::Cephes::incbi: Wrong domain for parameter a (must be > 0)
Info in TCanvas::Print: eps file test.eps has been created

i don’t understand the printed error (Cephes?) and i dont understand why the resulting plot (prova.eps) has some crazy efficiency values. i was expecting that at least the value of the Y coordinates of the points should correspond to the ratio of the bin contents, but it doesnt seem so.

i must be doing something wrong, can someone help out?

f

sorry, forgot to mention using ROOT version 5.27/06b

f

I’m curious, have you found a solution to this problem? I’m running into something similar, and all I’ve been able to determine is that it seems to be related to the way the histograms passed to the TGraphAsymmError constructor are filled. It works if they are filled with the function Fill(x), but I had a similar error when filling them with Fill(x,w). For example:

root [1] Huno = new TH1I("Hu","Hu",2,0,2);
root [2] Hdos = new TH1I("Hd","Hd",2,0,2);
root [3] Htre = new TH1I("Ht","Ht",2,0,2);
root [4] Hcuq = new TH1I("Hc","Hc",2,0,2);
root [5] Huno->Fill(0);
root [6] Huno->Fill(1);
root [7] Hdos->Fill(1);
root [8] Hdos->Fill(1);
root [9] Hdos->Fill(0);
root [10] Hdos->Fill(0);
root [11] Htre->Fill(0,1);
root [12] Htre->Fill(1,2);
root [13] Hcua->Fill(1,4);
Error: Symbol Hcua is not defined in current scope  (tmpfile):1:
Error: Failed to evaluate Hcua->Fill(1,4)
*** Interpreter error recovered ***
root [14] Hcuq->Fill(1,4);
root [15] Hcuq->Fill(0,2);
root [16] grA1 = new TGraphAsymmErrors(Huno,Hdos);
root [17] grA2 = new TGraphAsymmErrors(Htre,Hcuq);
Error in <TArrayD::At>: index 0 out of bounds (size: 0, this: 0xa6d4600)
Error in <TArrayD::At>: index 0 out of bounds (size: 0, this: 0xa6d43b0)
Error in <ROOT::Math::Cephes::incbi>: Wrong domain for parameter a (must be > 0)
Error in <TArrayD::At>: index 1 out of bounds (size: 0, this: 0xa6d4600)
Error in <TArrayD::At>: index 1 out of bounds (size: 0, this: 0xa6d43b0)
Error in <ROOT::Math::Cephes::incbi>: Wrong domain for parameter a (must be > 0)

I have no clue why this is so!
AE

{ Huno = new TH1I("Hu","Hu",2,0,2); Hdos = new TH1I("Hd","Hd",2,0,2); Htre = new TH1I("Ht","Ht",2,0,2); Htre->Sumw2(); // histogram with weights Hcuq = new TH1I("Hc","Hc",2,0,2); Hcuq->Sumw2(); // histogram with weights Huno->Fill(0); Huno->Fill(1); Hdos->Fill(1); Hdos->Fill(1); Hdos->Fill(0); Hdos->Fill(0); Htre->Fill(0,1); Htre->Fill(1,2); Hcuq->Fill(1,4); Hcuq->Fill(0,2); // // http://root.cern.ch/root/html/TGraphAsymmErrors.html#TGraphAsymmErrors:Divide // grA1 = new TGraphAsymmErrors(Huno, Hdos, "cp"); // // Histograms have weights: only Normal or // Bayesian error calculation is supported // grA2 = new TGraphAsymmErrors(Htre, Hcuq, "n"); // Normal grA3 = new TGraphAsymmErrors(Htre, Hcuq, "cl=0.683 b(1,1) mode"); // Bayesian }