I am trying to calculate my own test statistics using a recipe from one of the earlier roottalk entries.
But, my program fails with “cannot find object tmodel_hist”
I also tried RooPlot “getCurve” and “getHist” methods to no avail ;8-(
My histogram and pdf are cleary and correctly drawn on the tmodel_frame.
So, why is this not working (the full code attached):
// Construct and plot frame in t
RooPlot* tmodel_frame = t.frame(Title("p2e+Michel+accidentals+DIF+Prompt decay time p.d.f.")) ;
tmodel_hist->plotOn(tmodel_frame) ; }
tmodel.plotOn(tmodel_frame,LineColor(kBlack)) ;
tmodel.plotOn(tmodel_frame,Components(t_acc),LineStyle(kDashed),LineColor(kRed)) ;
tmodel.plotOn(tmodel_frame,Components(t_mich),LineStyle(kDashed),LineColor(kGreen)) ;
tmodel.plotOn(tmodel_frame,Components(t_mu),LineStyle(kDashed),LineColor(kBlue)) ;
tmodel.plotOn(tmodel_frame,Components(t_prom),LineStyle(kDashed),LineColor(6)) ;
tmodel.plotOn(tmodel_frame,Components(t_p2e),LineStyle(kDashed),LineColor(28)) ;
tmodel_frame->Draw() ;
Double_t chi2_fit=0 ;
RooHist* histo = (RooHist*) tmodel_frame->findObject("tmodel_hist") ;
RooCurve* func = (RooCurve*) tmodel_frame->findObject("tmodel") ;
for (Int_t i=0 ; i<histo->GetN() ; i++) {
Double_t xdata,ydata ;
histo->GetPoint(i,xdata,ydata) ;
Double_t yfunc = curve->interpolate(xdata) ;
if (ydata>0) chi2_fit=chi2_fit + (ydata-yfunc)*(ydata-yfunc)/ydata ;}
printf("\n\n CHI2 VALUE: %.2f\n\n",chi2_fit) ;
…
[#0] ERROR:InputArguments – RooPlot::findObject(frame_t_0a7e64b0) cannot find object tmodel_hist
[#0] ERROR:InputArguments – RooPlot::findObject(frame_t_0a7e64b0) cannot find object tmodel
simplePEN.C (33.7 KB)