RooPlot with Asymetry

Hi,
I’m having this plot :

m_tag = some RooCategory with 2 states (+/-1) RooPlot*m_t_frame_asym = m_t->frame(0.,15.); RooDataSet* m_data = some data where m_tag is filled properly; m_data->plotOn(m_t_frame_asym,RooFit::Asymmetry(*m_tag) ,RooFit::Name("totdata")); RooAbsPdf m_total_pdf = somepdf; m_total_pdf->plotOn(m_t_frame_asym, RooFit::Asymmetry(*m_tag) ,RooFit::Name("totpdf"));
This is plotted very nicely.

Now I want to get the chi2, so I use

double chi2 = m_t_frame_asym->chiSquare("totpdf", "totdata");
But at this point, the code fails to find “totpdf”, as the Name property is not passed to plotAsymOn. I guess this is a bug somehow.

But anyway, I used the final plot and got the curve’s name by right click,

double chi2 = m_t_frame_asym->chiSquare("curve_Total pdfAsymmetry[tag]", "totdata");
But there, chi2 = nan
Where did I make a mistake ?

Thanks.

Cheers.

S Poss.

Hi Stephane,

What version of ROOT/RooFit are you using (this code handling this was recently changed)? Also. can attach a ROOT file with your RooPlot? Then I can have a look
at the NaN issue.

Wouter

I found something in the RooCurve::chiSquare.
In case of an asymmetry plot, it is very convenient to use a RooBinning, to have variable bin sizes. In the method above, which is called by RooPlot::chiSquare, the bin size is not taken into account. The bin width is taken as follows :

I would say this is not the best in case of variable bin size…
I’d rather use something like

[code]Double_t exl,exh;
for (i=0 ; i<np ; i++) {

// Retrieve histogram contents
((RooHist&)hist).GetPoint(i,x,y) ;

// Check if point is in range of curve
if (x<xstart || x>xstop) continue ;

nbin++ ;
eyl = hist.GetEYlow()[i] ;
eyh = hist.GetEYhigh()[i] ;
exl = hist.GetEXlow()[i] ;
exh = hist.GetEXhigh()[i] ;

// Integrate function over this bin
Double_t avg = average(x-exl,x+exh) ;
// Add pull^2 to chisq
if (y!=0) {
  Double_t pull = (y>avg) ? ((y-avg)/eyl) : ((y-avg)/eyh) ;
  chisq += pull*pull ;
}

}
[/code]

The problem seems to come from the fact that some bins have eyh = nan and/or eyl = nan. So pull = nan. Is there a way to check that ?

Cheers.

[quote=“Wouter Verkerke”]Hi Stephane,

What version of ROOT/RooFit are you using (this code handling this was recently changed)? Also. can attach a ROOT file with your RooPlot? Then I can have a look
at the NaN issue.

Wouter[/quote]

Hi Wouter,
I’m using root 5.18.

The root file is attached.
rooplot.root (12.6 KB)

Hi,

That’s a definitely a bug! I’ll fix this tomorrow in SVN.

Cam you still send me a RooPlot with a histogram that have
eyl or eyh of NaN because that’s weird (and easy to investigate
with a plot in hand)

Wouter

Hi Wouter,
The attached file contains a RooPlot. There is a RooHist in the RooPlot called totdata.
This RooHist’s last bin as eyl and eyh = nan.

Thanks.

Cheers.

P.S : in July, you told us that the “new” manual would be ready by September. Is there a date ?

Hi Stephane,

Thanks.

Concerning the manual, a release is foreseen at the end of next week.
(It’s becoming a rather big project, I’m over 100 pages already…)

Wouter

Hi Wouter,
This is great news, thanks !