Problem with Pull Histogram

Hi everyone,
something weird is happening on my pull distribution and I can’t figure out why.
I want to plot the pull distribution of a fit, but the result on my pull canvas is the fit itself. Here is a snippet of my code:

TFile *file = new TFile("BDT_Xibm_sel_C.root");
   TTree *tree = (TTree*)file->Get("mytree");
   TH1F *hist  = new TH1F ("hist","hist",125,5600,5930);
   tree->Project("hist","lab0_M", "BDT_response>0.5");
   
   RooRealVar x ("lab0_M","lab0_M",5600.,5930);
   RooDataHist data("data","data",x,hist);

...

model.fitTo(data,Extended());
RooPlot* xframe = x.frame() ;

...

xframe->Draw();

...

RooHist* hpull = xframe->pullHist() ;
RooPlot* frame2 = x.frame(Title("Pull Distribution")) ;
frame2->addPlotable(hpull,"P") ;
TCanvas *can2 = new TCanvas ("c2","c2",500,150);
frame2->Draw();

Here are the plots I get for the fit distribution and the pull distribution:
FIT.pdf (29.4 KB)
PULL.pdf (22.6 KB)

Can anyone help?
Thanks,
Andrea

Hi,
I think you are using wrong curve to make the pull histogram. You should pass histogram name and pdf name in xframe->pullHist(). See https://root.cern/doc/master/classRooPlot.html#a7d216156856479ed6b7952823d987532

You can get the names by calling xframe->Print()

Lorenzo

1 Like

Hi @moneta,
Thanks. You perfectly solved my problem.
Cheers
Andrea

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.