Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
rf712_lagrangianmorphfit.C File Reference

Detailed Description

View in nbviewer Open in SWAN
Performing a simple fit with RooLagrangianMorphFunc.

a morphing function is setup as a function of three variables and a fit is performed on a pseudo-dataset.

#include <RooDataHist.h>
#include <RooFitResult.h>
#include <RooPlot.h>
#include <RooRealVar.h>
#include <TAxis.h>
#include <TCanvas.h>
#include <TH2.h>
#include <TStyle.h>
using namespace RooFit;
{
// C r e a t e v a r i a b l e s f o r
// m o r p h i n g f u n c t i o n
// ---------------------------------------------
std::string observablename = "pTV";
RooRealVar obsvar(observablename.c_str(), "observable of pTV", 10, 600);
RooRealVar kSM("kSM", "sm modifier", 1.0);
RooRealVar cHq3("cHq3", "EFT modifier", -10.0, 10.0);
cHq3.setAttribute("NewPhysics", true);
RooRealVar cHl3("cHl3", "EFT modifier", -10.0, 10.0);
cHl3.setAttribute("NewPhysics", true);
RooRealVar cHDD("cHDD", "EFT modifier", -10.0, 10.0);
cHDD.setAttribute("NewPhysics", true);
// I n p u t s n e e d e d f o r c o n f i g
// ---------------------------------------------
std::string infilename = std::string(gROOT->GetTutorialDir()) + "/roofit/input_histos_rf_lagrangianmorph.root";
std::vector<std::string> samplelist = {"SM_NPsq0", "cHq3_NPsq1", "cHq3_NPsq2", "cHl3_NPsq1",
"cHl3_NPsq2", "cHDD_NPsq1", "cHDD_NPsq2", "cHl3_cHDD_NPsq2",
"cHq3_cHDD_NPsq2", "cHl3_cHq3_NPsq2"};
// S e t u p C o n f i g
// ---------------------------------------------
config.fileName = infilename;
config.observableName = observablename;
config.folderNames = samplelist;
config.couplings.add(cHq3);
config.couplings.add(cHl3);
config.couplings.add(cHDD);
config.couplings.add(kSM);
// C r e a t e m o r p h i n g f u n c t i o n
// ---------------------------------------------
RooLagrangianMorphFunc morphfunc("morphfunc", "morphed dist. of pTV", config);
// C r e a t e p s e u d o d a t a h i s t o g r a m
// f o r f i t
// ---------------------------------------------
morphfunc.setParameter("cHq3", 0.01);
morphfunc.setParameter("cHl3", 1.0);
morphfunc.setParameter("cHDD", 0.2);
auto pseudo_hist = morphfunc.createTH1("pseudo_hist");
auto pseudo_dh = new RooDataHist("pseudo_dh", "pseudo_dh", RooArgList(obsvar), pseudo_hist);
// reset parameters to zeros before fit
morphfunc.setParameter("cHq3", 0.0);
morphfunc.setParameter("cHl3", 0.0);
morphfunc.setParameter("cHDD", 0.0);
// error set used as initial step size
cHq3.setError(0.1);
cHl3.setError(0.1);
cHDD.setError(0.1);
// W r a p p d f o n m o r p h f u n c a n d
// f i t t o d a t a h i s t o g r a m
// ---------------------------------------------
// wrapper pdf to normalise morphing function to a morphing pdf
RooWrapperPdf model("wrap_pdf", "wrap_pdf", morphfunc);
auto fitres = model.fitTo(*pseudo_dh, SumW2Error(true), Optimize(false), Save(), PrintLevel(-1));
auto hcorr = fitres->correlationHist();
// E x t r a c t p o s t f i t d i s t r i b u t i o n
// a n d p l o t w i t h i n i t i a l
// h i s t o g r a m
// ---------------------------------------------
auto postfit_hist = morphfunc.createTH1("morphing_postfit_hist");
RooDataHist postfit_dh("morphing_postfit_dh", "morphing_postfit_dh", RooArgList(obsvar), postfit_hist);
auto frame0 = obsvar.frame(Title("Fitted histogram of p_{T}^{V}"));
postfit_dh.plotOn(frame0, Name("postfit_dist"), DrawOption("C"), LineColor(kBlue), DataError(RooAbsData::None),
XErrorSize(0));
pseudo_dh->plotOn(frame0, Name("input"));
// D r a w p l o t s o n c a n v a s
// ---------------------------------------------
TCanvas *c1 = new TCanvas("fig3", "fig3", 800, 400);
c1->Divide(2, 1);
c1->cd(1);
gPad->SetLeftMargin(0.15);
gPad->SetRightMargin(0.05);
model.paramOn(frame0, Layout(0.50, 0.75, 0.9), Parameters(config.couplings));
frame0->GetXaxis()->SetTitle("p_{T}^{V}");
frame0->Draw();
c1->cd(2);
gPad->SetLeftMargin(0.15);
gPad->SetRightMargin(0.15);
hcorr->SetMarkerSize(3.);
hcorr->SetTitle("correlation matrix");
hcorr->GetYaxis()->SetTitleOffset(1.4);
hcorr->GetYaxis()->SetLabelSize(0.1);
hcorr->GetXaxis()->SetLabelSize(0.1);
hcorr->GetYaxis()->SetBinLabel(1, "c_{HDD}");
hcorr->GetYaxis()->SetBinLabel(2, "c_{Hl^{(3)}}");
hcorr->GetYaxis()->SetBinLabel(3, "c_{Hq^{(3)}}");
hcorr->GetXaxis()->SetBinLabel(3, "c_{HDD}");
hcorr->GetXaxis()->SetBinLabel(2, "c_{Hl^{(3)}}");
hcorr->GetXaxis()->SetBinLabel(1, "c_{Hq^{(3)}}");
hcorr->Draw("colz text");
c1->SaveAs("rf712_lagrangianmorphfit.png");
}
@ kBlue
Definition Rtypes.h:66
#define gROOT
Definition TROOT.h:407
R__EXTERN TStyle * gStyle
Definition TStyle.h:433
#define gPad
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
The RooDataHist is a container class to hold N-dimensional binned data.
Definition RooDataHist.h:39
Class RooLagrangianMorphing is a implementation of the method of Effective Lagrangian Morphing,...
RooRealVar represents a variable that can be changed from the outside.
Definition RooRealVar.h:37
The RooWrapperPdf is a class that can be used to convert a function into a PDF.
The Canvas class.
Definition TCanvas.h:23
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
Definition TStyle.cxx:1636
void SetPaintTextFormat(const char *format="g")
Definition TStyle.h:383
return c1
Definition legend1.C:41
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition JSONIO.h:26
std::vector< std::string > folderNames
[#0] PROGRESS:InputArguments -- initializing physics inputs from file /home/sftnight/build/workspace/root-makedoc-v630/rootspi/rdoc/src/v6-30-00-patches.build/tutorials/roofit/input_histos_rf_lagrangianmorph.root with object name(s) 'pTV'
[#0] PROGRESS:Caching -- creating cache from getCache function for 0x7fff8300f908
[#0] PROGRESS:Caching -- current storage has size 10
[#0] PROGRESS:ObjectHandling -- observable: pTV
[#0] PROGRESS:ObjectHandling -- binWidth: binWidth_pTV
[#1] INFO:DataHandling -- RooDataHist::adjustBinning(pseudo_dh): fit range of variable pTV expanded to nearest bin boundaries: [10,600] --> [0,600]
[#0] PROGRESS:Caching -- creating cache from getCache function for 0x558510827ad0
[#0] PROGRESS:Caching -- current storage has size 10
[#0] PROGRESS:ObjectHandling -- observable: pTV
[#0] PROGRESS:ObjectHandling -- binWidth: binWidth_pTV
RooAbsMinimizerFcn: Minimized function has error status.
Returning maximum FCN so far (39620.3) to force MIGRAD to back out of this region. Error log follows.
Parameter values: cHDD=0.22238 cHl3=2.00088 cHq3=0.00780325
RooNLLVar::nll_wrap_pdf_pseudo_dh[ parameters=(binWidth_pTV,cHDD,cHl3,cHq3,kSM,nNP0,nNP1,nNP2,nNP3,nNP4) ]
function value is NAN @ parameters=(binWidth_pTV = 0.05,cHDD = 0.22238 +/- 0.1,cHl3 = 2.00088 +/- 0.1,cHq3 = 0.00780325 +/- 0.1,kSM = 1,nNP0 = 1,nNP1 = 1,nNP2 = 1,nNP3 = 1,nNP4 = 1)
RooWrapperPdf::wrap_pdf[ inputFunction=morphfunc ]
p.d.f value is less than zero (-0.040406), trying to recover @ inputFunction=morphfunc=-0.0404061
getLogVal() top-level p.d.f evaluates to NaN @ inputFunction=morphfunc=-0.0404061
p.d.f value is less than zero (-0.040462), trying to recover @ inputFunction=morphfunc=-0.0404616
getLogVal() top-level p.d.f evaluates to NaN @ inputFunction=morphfunc=-0.0404616
RooAbsMinimizerFcn: Minimized function has error status.
Returning maximum FCN so far (39620.3) to force MIGRAD to back out of this region. Error log follows.
Parameter values: cHDD=1.16153 cHl3=8.6965 cHq3=0.0408466
RooNLLVar::nll_wrap_pdf_pseudo_dh[ parameters=(binWidth_pTV,cHDD,cHl3,cHq3,kSM,nNP0,nNP1,nNP2,nNP3,nNP4) ]
function value is NAN @ parameters=(binWidth_pTV = 0.05,cHDD = 1.16153 +/- 0.1,cHl3 = 8.6965 +/- 0.1,cHq3 = 0.0408466 +/- 0.1,kSM = 1,nNP0 = 1,nNP1 = 1,nNP2 = 1,nNP3 = 1,nNP4 = 1)
RooWrapperPdf::wrap_pdf[ inputFunction=morphfunc ]
p.d.f value is less than zero (-0.423644), trying to recover @ inputFunction=morphfunc=-0.423644
getLogVal() top-level p.d.f evaluates to NaN @ inputFunction=morphfunc=-0.423644
p.d.f value is less than zero (-2.779762), trying to recover @ inputFunction=morphfunc=-2.77976
getLogVal() top-level p.d.f evaluates to NaN @ inputFunction=morphfunc=-2.77976
p.d.f value is less than zero (-0.022566), trying to recover @ inputFunction=morphfunc=-0.0225659
getLogVal() top-level p.d.f evaluates to NaN @ inputFunction=morphfunc=-0.0225659
p.d.f value is less than zero (-0.205861), trying to recover @ inputFunction=morphfunc=-0.205861
getLogVal() top-level p.d.f evaluates to NaN @ inputFunction=morphfunc=-0.205861
p.d.f value is less than zero (-1.337222), trying to recover @ inputFunction=morphfunc=-1.33722
getLogVal() top-level p.d.f evaluates to NaN @ inputFunction=morphfunc=-1.33722
p.d.f value is less than zero (-0.477718), trying to recover @ inputFunction=morphfunc=-0.477718
getLogVal() top-level p.d.f evaluates to NaN @ inputFunction=morphfunc=-0.477718
... (remaining 4 messages suppressed)
RooAbsMinimizerFcn: Minimized function has error status.
Returning maximum FCN so far (39620.3) to force MIGRAD to back out of this region. Error log follows.
Parameter values: cHDD=0.607791 cHl3=5.23432 cHq3=0.0213386
RooNLLVar::nll_wrap_pdf_pseudo_dh[ parameters=(binWidth_pTV,cHDD,cHl3,cHq3,kSM,nNP0,nNP1,nNP2,nNP3,nNP4) ]
function value is NAN @ parameters=(binWidth_pTV = 0.05,cHDD = 0.607791 +/- 0.1,cHl3 = 5.23432 +/- 0.1,cHq3 = 0.0213386 +/- 0.1,kSM = 1,nNP0 = 1,nNP1 = 1,nNP2 = 1,nNP3 = 1,nNP4 = 1)
RooWrapperPdf::wrap_pdf[ inputFunction=morphfunc ]
p.d.f value is less than zero (-0.067384), trying to recover @ inputFunction=morphfunc=-0.0673836
getLogVal() top-level p.d.f evaluates to NaN @ inputFunction=morphfunc=-0.0673836
p.d.f value is less than zero (-0.313216), trying to recover @ inputFunction=morphfunc=-0.313216
getLogVal() top-level p.d.f evaluates to NaN @ inputFunction=morphfunc=-0.313216
p.d.f value is less than zero (-1.542083), trying to recover @ inputFunction=morphfunc=-1.54208
getLogVal() top-level p.d.f evaluates to NaN @ inputFunction=morphfunc=-1.54208
p.d.f value is less than zero (-1.460439), trying to recover @ inputFunction=morphfunc=-1.46044
getLogVal() top-level p.d.f evaluates to NaN @ inputFunction=morphfunc=-1.46044
p.d.f value is less than zero (-1.443873), trying to recover @ inputFunction=morphfunc=-1.44387
getLogVal() top-level p.d.f evaluates to NaN @ inputFunction=morphfunc=-1.44387
p.d.f value is less than zero (-1.909523), trying to recover @ inputFunction=morphfunc=-1.90952
getLogVal() top-level p.d.f evaluates to NaN @ inputFunction=morphfunc=-1.90952
... (remaining 16 messages suppressed)
RooAbsMinimizerFcn: Minimized function has error status.
Returning maximum FCN so far (39620.3) to force MIGRAD to back out of this region. Error log follows.
Parameter values: cHDD=0.330108 cHl3=2.94627 cHq3=0.0115846
RooNLLVar::nll_wrap_pdf_pseudo_dh[ parameters=(binWidth_pTV,cHDD,cHl3,cHq3,kSM,nNP0,nNP1,nNP2,nNP3,nNP4) ]
function value is NAN @ parameters=(binWidth_pTV = 0.05,cHDD = 0.330108 +/- 0.1,cHl3 = 2.94627 +/- 0.1,cHq3 = 0.0115846 +/- 0.1,kSM = 1,nNP0 = 1,nNP1 = 1,nNP2 = 1,nNP3 = 1,nNP4 = 1)
RooWrapperPdf::wrap_pdf[ inputFunction=morphfunc ]
p.d.f value is less than zero (-0.072286), trying to recover @ inputFunction=morphfunc=-0.0722861
getLogVal() top-level p.d.f evaluates to NaN @ inputFunction=morphfunc=-0.0722861
p.d.f value is less than zero (-0.082234), trying to recover @ inputFunction=morphfunc=-0.0822337
getLogVal() top-level p.d.f evaluates to NaN @ inputFunction=morphfunc=-0.0822337
p.d.f value is less than zero (-0.149372), trying to recover @ inputFunction=morphfunc=-0.149372
getLogVal() top-level p.d.f evaluates to NaN @ inputFunction=morphfunc=-0.149372
RooAbsMinimizerFcn: Minimized function has error status.
Returning maximum FCN so far (39620.3) to force MIGRAD to back out of this region. Error log follows.
Parameter values: cHDD=0.191157 cHl3=1.72296 cHq3=0.00670752
RooNLLVar::nll_wrap_pdf_pseudo_dh[ parameters=(binWidth_pTV,cHDD,cHl3,cHq3,kSM,nNP0,nNP1,nNP2,nNP3,nNP4) ]
function value is NAN @ parameters=(binWidth_pTV = 0.05,cHDD = 0.191157 +/- 0.1,cHl3 = 1.72296 +/- 0.1,cHq3 = 0.00670752 +/- 0.1,kSM = 1,nNP0 = 1,nNP1 = 1,nNP2 = 1,nNP3 = 1,nNP4 = 1)
RooWrapperPdf::wrap_pdf[ inputFunction=morphfunc ]
p.d.f value is less than zero (-0.027317), trying to recover @ inputFunction=morphfunc=-0.0273169
getLogVal() top-level p.d.f evaluates to NaN @ inputFunction=morphfunc=-0.0273169
p.d.f value is less than zero (-0.007139), trying to recover @ inputFunction=morphfunc=-0.00713888
getLogVal() top-level p.d.f evaluates to NaN @ inputFunction=morphfunc=-0.00713888
RooAbsMinimizerFcn: Minimized function has error status.
Returning maximum FCN so far (39620.3) to force MIGRAD to back out of this region. Error log follows.
Parameter values: cHDD=0.138238 cHl3=1.24892 cHq3=0.00485049
RooNLLVar::nll_wrap_pdf_pseudo_dh[ parameters=(binWidth_pTV,cHDD,cHl3,cHq3,kSM,nNP0,nNP1,nNP2,nNP3,nNP4) ]
function value is NAN @ parameters=(binWidth_pTV = 0.05,cHDD = 0.138238 +/- 0.1,cHl3 = 1.24892 +/- 0.1,cHq3 = 0.00485049 +/- 0.1,kSM = 1,nNP0 = 1,nNP1 = 1,nNP2 = 1,nNP3 = 1,nNP4 = 1)
RooWrapperPdf::wrap_pdf[ inputFunction=morphfunc ]
p.d.f value is less than zero (-0.001109), trying to recover @ inputFunction=morphfunc=-0.00110901
getLogVal() top-level p.d.f evaluates to NaN @ inputFunction=morphfunc=-0.00110901
RooAbsMinimizerFcn: Minimized function has error status.
Returning maximum FCN so far (39620.3) to force MIGRAD to back out of this region. Error log follows.
Parameter values: cHDD=0.121667 cHl3=1.24299 cHq3=0.004269
RooNLLVar::nll_wrap_pdf_pseudo_dh[ parameters=(binWidth_pTV,cHDD,cHl3,cHq3,kSM,nNP0,nNP1,nNP2,nNP3,nNP4) ]
function value is NAN @ parameters=(binWidth_pTV = 0.05,cHDD = 0.121667 +/- 0.1,cHl3 = 1.24299 +/- 0.1,cHq3 = 0.004269 +/- 0.1,kSM = 1,nNP0 = 1,nNP1 = 1,nNP2 = 1,nNP3 = 1,nNP4 = 1)
RooWrapperPdf::wrap_pdf[ inputFunction=morphfunc ]
p.d.f value is less than zero (-0.001164), trying to recover @ inputFunction=morphfunc=-0.00116395
getLogVal() top-level p.d.f evaluates to NaN @ inputFunction=morphfunc=-0.00116395
[#1] INFO:Fitting -- RooAbsPdf::fitTo(wrap_pdf) Calculating sum-of-weights-squared correction matrix for covariance matrix
[#1] INFO:InputArguments -- RooAbsData::plotOn(pseudo_dh) INFO: dataset has non-integer weights, auto-selecting SumW2 errors instead of Poisson errors
[#1] INFO:Plotting -- RooPlot::updateFitRangeNorm: New event count of 7389.24 will supersede previous event count of 7388.38 for normalization of PDF projections
Date
January 2022
Author
Rahul Balasubramanian

Definition in file rf712_lagrangianmorphfit.C.