roorarfit tutorial - sourceforgerarfit.sourceforge.net/tutorial/roorarfit-ffw.pdf · own fitters...
TRANSCRIPT
RooRarFit Tutorial Fergus Wilson
RAL/STFC Based on original tutorial by author Lei Zhang
1st February 2011 Fergus Wilson, RAL/STFC 1
Contents
• Maximum Likelihood Reminder
• Why RooRarFit
• How to setup RooRarFit
• How to write a RooRarFit configuration file
• How to run a RooRarFit action (with examples.)
• Tutorial files
1st February 2011 Fergus Wilson, RAL/STFC 2
Maximum Likelihood Reminder
1st February 2011 Fergus Wilson, RAL/STFC 3
1
The likelihood (L ) for event is defined as
The product of the PDFs for hypothesis is written as
For events, the extended
1 ( ; )
( ) ( ) ( )
likelihood functi
(
o
)
n i
k
i j j i jj
j i j ESi j i
i
j i
L N P xN
P x
i
P m P E P Mj
N
α=
=
= × Δ × ×
∑
L
( )
1
s:
To maximize likelihood minim!
(iz )e
jjN N
ii
eL LN
log L
−
=
⇒
∑=
−
∏
Observables
Parameters
4
What is RooRarFit?
• A general ML fitter based on ROOT/RooFit written by lei Zhang
Why use RooRarFit? • A question asked by many people: Why do so many people write their
own fitters with ROOT/RooFit? What’s wrong?
• ROOT/RooFit are toolkits, engines, so one needs to build a fitter, an application, to make use of them.
• RooRarFit is one of such fitters, applications, but as a general fitter, it can be used by many different analyses, with benefits:
• Access to the full power of RooFit
• Coding free to final users (no C++ experience needed)
• Driven by readable text configuration files
• Flexible design, ‘programmable’ configuration files
• Lots of fitting, plotting functions implemented
• Fully documented, lots of working examples from many analyses already
• Automatically creates the plots you need
1st February 2011 Fergus Wilson, RAL/STFC
5
RooRarFit implementation
• Wrappers of RooRealVar, RooDataSet, RooPDFs, etc. implemented, so can be defined through ascii configs – Dataset classes
– PDF classes
• Fitting actions implemented as functions driven by ascii configuration filess
• Auxiliary classes, main program, scripts – String parser class
– NLL class to deal with NLL curve
– Minuit class derived from RooMinuit for contour plot
– Version control header file
– Main program (rarFit)
– submitToy (toy study batch processor for slac, cu-boulder, ed, ral)
• Assume users have experience with ROOT/RooFit, so no ROOT/RooFit details in this tutorial
1st February 2011 Fergus Wilson, RAL/STFC
RooRarFit status and the future
• RooRarFit and BaBar – At the moment, RooRarFit only runs in the BaBar analysis
framework.
– You need to check out a BaBar analysis and then add RooRarFit package.
– This is because BaBar uses its own, older versions of RooFitCore and RooFitModels that are incompatible with the versions that come with Root/RooFit.
– Do not check out RooFitCore and RooFitModels packages or you will get conflicts.
– This tutorial based on the BaBar RooRarFit version.
• RooRarFit in the future – There is a project to free RooRarFit from the BaBar framework. – New version will run on any machine (linux, solaris, mac) with
Root installed (even if BaBar code is not available).
– Should become available early in 2011. – Will have same functionality as old version plus improvements.
1st February 2011 Fergus Wilson, RAL/STFC 6
Setting up RooRarFit and
Running tutorial.config
1st February 2011 Fergus Wilson, RAL/STFC 7
8
Get and Run RooRarFit
• With BaBar SRT release version >= 24.5.6 addpkg RooRarFit V00-01-86
gmake RooRarFit.all
cd workdir
• In workdir, run the application (rarFit) without any args to get short help page: > rarFit rarFit [-options] <RooRarFit_Config_file> -h this help page -D <data input section> (default "Dataset Input") -C <mlFitter config section> (default "mlFitter Config") -A <fitter action section> (default "Fitter Action") -t <toy job id> (default 0) -n <toyNexp> (default 0, use config) -d <toy dir> (default .toyData) e.g. To run rarFit from config file demo.config rarFit demo.config and with mlfitter config from section [myMLFitter] rarFit -C myMLFitter demo.config and with mlfitter action from section [my Fit Action] rarFit -C myMLFitter -A "my Fit Action" demo.config
1st February 2011 Fergus Wilson, RAL/STFC
Running the tutorial.config – getting ready
• Checkout RooRarFit package (page 8)
• Create the input datasets (both ascii and root). The dataset can be used to represent both a charge asymmetry (B+→) and a time-dependent CP Violation (B0→) analysis dataset with 3 hypotheses (signal, uds bkg, peaking bkg) and 10 observables.
• Creates 3 datasets for signal, uds and peaking bkg.
• Merges together to form “real data” = signal (100 #evts), uds (4000) and peaking (500).
• The expected results are:
1st February 2011 Fergus Wilson, RAL/STFC 9
cd workdir mkdir Ntuples $ROOTSYS/bin/root –l –q –b ../RooRarFit/doc/tutorial/make_data.C cp ../RooRarFit/doc/tutorial/tutorial.config . cp ../RooRarFit/doc/tutorial/tutorial_v3.config .
Variable Input Fitted
Yield (events) 100 105 ± 18
BF (x 10-6) 5.22 5.47 ± 1.0
Charge asymmetry -0.05 -0.19 ± 0.16
S 0.7 0.6 ± 0.22
C 0.0 0.003 ± 0.15
1) Signal Yield Examples
1st February 2011 Fergus Wilson, RAL/STFC 10
// The signal yield model is defined in “[mlFitter config]” (default if not specified on cmd line) // fit the individual PDFs -> creates plots rarFit –A PdfAct tutorial.config
// fit the whole model and extract the yields -> no plots created rarFit –A MLAct tutorial.config // Do a “pure” toy study on ensemble of events created by the fitted PDFs -> creates ntuples rarFit –A ToyAct tutorial.config // Do an “embedded” toy study on ensemble of events created from the datasets rarFit –A eToyAct tutorial.config // generate projection plots -> creates plots rarFit –A ProjAct tutorial.config // generate sPlots -> creates plots rarFit –A SPlotAct tutorial.config
// scan the NLL about fitted yield ML minimum -> creates plots rarFit –A YieldScan tutorial.config
2) Branching Fraction Examples
1st February 2011 Fergus Wilson, RAL/STFC 11
//use the BF model in “[bfFitter Config]” section // fit the individual PDFs rarFit –A PdfAct –C “bfFitter Config” tutorial.config
// fit the whole model and extract the branching fraction rarFit –A MLAct –C “bfFitter Config” tutorial.config // Do a “pure” toy study on an ensemble of events created // by the fitted PDFs >rarFit –A ToyAct –C “bfFitter Config” tutorial.config // Do an “embedded” toy study on an ensemble of events created // from the datasets rarFit –A eToyAct –C “bfFitter Config” tutorial.config
// projection and sPlots are meaningless for branching fraction fits // scan the NLL about fitted branching fraction ML minimum rarFit –A BRScan –C “bfFitter Config” tutorial.config
3) Charge Asymmetry Example
1st February 2011 Fergus Wilson, RAL/STFC 12
// Edit tutorial.config and change “simultaneousFit = no” to “simultaneousFit = yes” // in section “[mlFitter Config]” // fit the individual PDFs rarFit –A PdfAct tutorial.config
// fit the whole model and extract the Charged Asymmetries rarFit –A MLAct tutorial.config // scan the NLL about fitted Charge Asymmetry ML minimum rarFit –A AScan tutorial.config
4) Time Dependent Asymmetries Example
1st February 2011 Fergus Wilson, RAL/STFC 13
// fit the individual PDFs rarFit –A PdfAct tutorial_v3.config
// fit the whole model and extract the asymmetries C and S and yield rarFit –A MLAct tutorial_v3.config
14
Documentation
• You can make your own documentation
• Slightly out of date HTML/pdf/ps is on the web as well – http://rarfit.sourceforge.net/
• Lots of working examples from many analyses – RooRarFit/doc/Sample_configs/
• Sample scripts to deal with RooRarFit ROOT output – RooRarFit/doc/Sample_scripts/
• Tutorial configuration file and examples – RooRarFit/doc/tutorial/
• Source code documented using doxygen (but out of date) – http://www.slac.stanford.edu/~zhanglei/RooRarFit/html
1st February 2011 Fergus Wilson, RAL/STFC
// create pdf, ps and html documentation cd RooRarFit/doc gmake RooRarFitMakeInfo
Dataset Definition & Input Define the structure of dataset entry
&
Read in datasets
1st February 2011 Fergus Wilson, RAL/STFC
16
RooRarFit configuration file
• There are 3 main “Configuration sections” – Dataset definition section - define the variables to be read
– Dataset input section – define and read in datasets
– PDF configuration section – define the PDFs for each hypothesis and observable e.g. “signal mass”, “background MES”, …
• PDFs are created from top to bottom with PDF config sections.
• Composite PDFs can be created from simpler PDFs
• There can be zero or more “Action sections” 1. Fit the individual PDFs and create plots of fits - pdfFit
2. Fit the maximum likelihood model and output results - mlFit
3. Perform multiple toy fits to extract pulls and biases – toyStudy
4. Create plots of log-likelihood about the minimum – scanPlot
5. Create projection plots of the fitted yields – projPlot
6. Create contour plots of two variables – contourPlot
7. Create sPlot plots of the hypothesis yields – sPlot
8. Combine Log-likelihood distributions - combinePlot
1st February 2011 Fergus Wilson, RAL/STFC
• Define dataset entry structure with dataset section – Default name is “[Dataset Definition]”
– “Fields” declares observables/variables that will be used.
– Then define each observable (name, type, title, range, etc..)
– Observable definition syntax • <Name> = <cType> “<title>” <specifications>
– Possible types: RooRealVar, RooCategory, RooStringVar, RooConstVar, RooUnblindPrecision, RooMappedCategory, RooThresholdCategory, RooFormulaVar
17
[Dataset Definition] Fields = runNum mes de fisher runNum = RooRealVar “runNum” 0 1e10 mes = RooRealVar “M_{es}” 5.19 5.29 B(50) “GeV/c^2” de = RooRealVar “#Delta E” -.2 .2 B(45) “GeV” fisher = RooRealVar “Fisher” -4 5 B(45)
Dataset definition section
Latex in RooFit
unit range Plot bins Type Title
1st February 2011 Fergus Wilson, RAL/STFC
[…text…] starts a section
– “AddOns” declares derived columns
– Define all declared ‘add-on’ columns in this section as well
– columnType can be:
RooMappedCategory, RooThresholdCategory, RooFormulaVar
18
[Dataset Definition] Fields = runNum mes de fisher runNum = RooRealVar “runNum” 0 1e10 mes = RooRealVar “M_{es}” 5.19 5.29 B(50) “GeV/c^2” de = RooRealVar “#Delta E” -.2 .2 B(45) “GeV” fisher = RooRealVar “Fisher” -4 5 B(45) AddOns = runBlock runBlock = RooMappedCategory "Run Block" noIdx runRange \\ “Run1” "*Run1" "Run1" "*Run2" "Run2" \\ "*Run3" "Run3" "*Run4" "Run4" runRange = RooThresholdCategory "Run Range" noIdx runNum \\ "mcRun2" 18000 "daRun1" 30000 "daRun2" \\ 40000 "daRun3" 200000 "daRun4" \\ 770000 "mcRun1"
Dataset definition section (Cont.)
1st February 2011 Fergus Wilson, RAL/STFC
• Input datasets with dataset input section – Default name is “[Dataset Input]”
– “Datasets” declares all datasets to be used as input
– Then define all declared datasets (in the order they were defined in “Datasets”).
– Dataset definition syntax • <Name> = <inputType> “<title>” <specifications>
– Dataset input types: ascii, root, reduce, add
[Dataset Input] Datasets = onData sigMC bbMC gsbData desbData totMC onData = root “on peak data” “mydats/on.root” “ntout” sigMC = ascii “sig MC” “mydats/sigMC.txt” Q bbMC = ascii “peaking BB MC” “mydats/bbMC.txt” Q gsbData = reduce “gsb Data” onData “mes<5.27” desbData = reduce “de sb Data” onData “(de<-.1)||(de>.1)” totMC = add “signal+bckg MC” sigMC 100 bbMC 5000
19
Dataset file name
source dataset reduce cuts inputType title
Dataset input section
Q for quiet mode
1st February 2011 Fergus Wilson, RAL/STFC
20
Dataset input section (Cont.)
• Other (optional) configs for “[Dataset Input]” section – dsdSec = <dataset definition section name>
Default: Dataset Definition
– setWeightVar = <obs used as weightVar>
Default: no weightVar for datasets
Warning: may become obsolete in new versions.
– tabulateDatasets = yes
Tabulate datasets for each RooCategory observable.
Default: no tabulation
– computeCorrelations = <yes|no|dataSetName1 ...>
Compute correlation matrices for (given) datasets.
Default: yes
1st February 2011 Fergus Wilson, RAL/STFC
PDF Configuration Sections
Define PDFs from top to bottom
with configuration sections
1st February 2011 Fergus Wilson, RAL/STFC
• Master fitter configuration section – Starting point for all PDFs, also include:
– Global configurations
– Simultaneous fit configuration for RooFit
– All section headers have keyword “Config”
[mlFitter Config] Comps = myModel // can have multiple ML models for simFit fitData = simData // Default dataset, also used as prototype dataset useNumCPU = 4 // number of cpu cores to use simultaneousFit = no // Build and use simPdf if set to yes physModels = the_myModel // models for simPdf splitCats = runBlock // List all splitting categories here the_myModel = runBlock : mesSig_shift
22
PDF configuration sections – Master fitter
RooSimPdfBuilder Configs
Configured in its own section, see next slide
1st February 2011 Fergus Wilson, RAL/STFC
23
Declared as full names Optional title
[myModel Config] configStr = MLPdf “ml yield model” Comps = Sig Chls Bkg // component PDFs for this model Coeffs = nSig nChls nBkg // component yields for this model nSig = nSig 100 L(-100 – 1000) nChls = nChls 100 L(-100 – 1000) nBkg = nBkg 2000 L(-100 – 10000) postPdfFloat = nSig nChls nBkg
PDF configuration sections – ML model
• Maximum Likelihood model config section – Each model declared in ML fitter section has its own configuration section
– configStr set to `MLPdf’ for ML models
– Declare as many hypotheses as wanted with config `Comps’
– Each hypothesis has its own configuration section (see next slide)
– Corresponding yields listed with config `Coeffs’
– Declared yields defined within the section
Float yields
RRV stream output
1st February 2011 Fergus Wilson, RAL/STFC
24
PDF config sections – hypothesis configuration
• Hypothesis configuration sections – Each hypothesis in ML model has its own configuration section
– configStr can be set to any valid PDF type in RooRarFit,
but usually `ProdPdf’ for composite PDF as product of PDFs for observables included in the model
[Sig Config] configStr = ProdPdf “Signal Pdf” Comps = deSig mesSig fisSig // Product components fitData = sigMC // Use sigMC to get pdf params [Chls Config] configStr = ProdPdf “Charmless B bkg” Comps = deChls mesChls fisChls fitData = bbMC // Use bbMC to get pdf params [Bkg Config] configStr = ProdPdf “Continuum Bkg” Comps = deBkg mesBkg fisBkg fitData = gsbData // Use gsbData to get pdf params
Signal config section
Chmls B Bkg config section
Continuum config section
Defined in their own sections
1st February 2011 Fergus Wilson, RAL/STFC
25
PDF config sections – (1) Signal PDFs examples
• Signal PDF config sections
[deSig Config] configStr = TwoGauss “Signal” x = de meanC = 0. L(-.1 - .1) meanT = -0.04 L(-.1 - .1) sigmaC = 0.025 L(0.0 - .15) sigmaT = 0.09 L(0.0 – 0.3) fracC = 0.75 L(0.5 – 1.0) [mesSig Config] configStr = TwoGauss x = mes meanC = 5.28 L(5.25 – 5.29) meanT = 5.27 L(5.25 – 5.29) sigmaC = 0.0028 L(0.0 – 0.01) sigmaT = 0.008 L(0.0 – 0.10) fracC = 0.95 L(0.5 – 1.0) shift = 0.0 C L(-.1 - 0.1)
[fisSig Config] configStr = BGGauss x = fisher mean = -0.5 L(-2 - 2) rms = 0.6 L(0.0 – 1) asym = 0.1 L(-.5 – 0.5)
If full name is not specified for params, RRV name will be prefixed with PDF name, for example, fisSig_mean, fisSig_rms, and fisSig_asym. In RooRarFit, params belong to RooRarFit PDF objects, so full names are needed to distinguish same param names from different PDFs.
1st February 2011 Fergus Wilson, RAL/STFC
• Charmless B background PDF config sections
[mesChlsA Config] configStr = ArgusBG x = mes max = 5.29 C c = -30 L(-80 - -.1) [fisChls Config] configStr = BGGauss x = fisher mean = -0.4 L(-2 - 2) rms = 0.6 L(0.0 – 1) asym = 0.1 L(-.5 – 0.5)
26
PDF config sections – (2) Chls PDFs examples
[deChls Config] configStr = TwoGauss x = de meanC = 0.13 L(-.2 - .2) meanT = -0.20 L(-.3 - .2) sigmaC = 0.06 L(0.0 - .3) sigmaT = 0.14 L(0.0 – 0.3) fracC = 0.35 L(0.0 – 1.0) [mesChls Config] configStr = AddPdf Comps = mesChlsG mesChlsA Coeffs = fracG fracG = T “f_{G}” 0.08 L(0-1) [mesChlsG Config] configStr = Gaussian x = mes mean = 5.28 L(5.25 – 5.29) sigma = 0.004 L(0.0 – 0.1)
1st February 2011 Fergus Wilson, RAL/STFC
AddPdf means: mesChls = fracG * mesChlsG + (1-fracG) * mesChlsA
27
[fisBkg Config] configStr = AddPdf Comps = fisBkgC fisBkgT Coeffs = fracC fracC = T “f_{C}” 0.97 L(0 -1) [fisBkgC Config] configStr = BGGauss x = fisher mean = T “#mu_{C}” -0.4 L(-2 - 2) rms = T “#sigma_{C}” 0.6 L(0 – 1) asym = T “A_{C}” 0.1 L(-.5 – 0.5) [fisBkgT Config] configStr = Gaussian x = fisher mean = T “#mu_{T}” 0.8 L(-1 – 2) sigma = T “#sigma_{T}” 2.0 L(0 – 5)
PDF config sections – (3) Bkg PDFs examples
• Continuum background PDF config sections
[deBkg Config] configStr = Polynomial x = de nOrder = 2 P01 = -1.5 L(-100 - 100) P02 = 2.0 L(-100 - 100) postPdfFloat = P01 [mesBkg Config] fitData = desbData configStr = ArgusBG x = mes max = 5.29 C c = -15 L(-80 - -.1) postPdfFloat = c
1st February 2011 Fergus Wilson, RAL/STFC
This parameter will be floated after the PDF fit
• We can reuse a fitted PDF in another PDF e.g. we wish to fit the continuum background but we know that it has a signal-like component – First fit signal PDF
– Then use fitted signal PDF in background
Reusing a PDF
1st February 2011 Fergus Wilson, RAL/STFC 28
[massSig] configStr = RelBreitWigner “Signal” x = mass mean = 0.80 L(0.8 – 1.0) width = 0.05 L(0.01 – 0.1) [massBkg Config] configStr = AddPdf “Continuum” Comps = massSig massPolyBkg prePdfFix = massSig Coeffs = fracS fracS = T “f_{S}” 0.75 L(0.5 – 1.0)
Reuse the PDF fitted in the “massSig” section
29
PDF config sections
– ArgusBG
– Ballack
– BifurGauss
– Binned
– Decay, BDecay, BCPGenDecay
– CBShape (Crystal Ball)
– Cruijff
– Exponential
– Gaussian
– BreitWigner, Relativistic BW
– Landau
– Voigtian
– Novosibirsk
– GaussModel
– Generic Pdf
– Keys, 2DKeys
– Polynomial, Chebychev
– Parametric Step Function
– Triple Gaussian, Triple Guassian Model, Gexp
– Double Gaussian (w/ scale and shift)
– Histograms
• RooFit composite PDFs implemented:
• ProdPdf, AddPdf, AddModel, SimPdfBuild
• RooFit base PDFs implemented:
1st February 2011 Fergus Wilson, RAL/STFC
Fit Action Sections 1. Fit the individual PDFs and create plots of fits - pdfFit
2. Fit the maximum likelihood model - mlFit
3. Perform multiple toy fits to extract pulls and biases – toyStudy
4. Create plots of log-likelihood about the minimum – scanPlot
5. Create projection plots of the fitted yields – projPlot
6. Create contour plots of two variables – contourPlot
7. Create sPlot plots of the hypothesis yields – sPlot
8. Combine Log-likelihood distributions - combinePlot
1st February 2011 Fergus Wilson, RAL/STFC
31
Fit action (1) - pdfFit
• Get PDF parameters from fits of individual PDFs to datasets – Input: initial values in PDF configuration sections
– Output: fitted parameters in intermediate file; PDF plots in ROOT file
// Action section name, command line option –A PdfAct [PdfAct] // pdfFit options pdfFit = yes // enable pdfFit action postPdfMakePlot = yes // To output PDF plots into root file postPdfWriteParams = yes // To output params to text file
Other configs for pdfFit action
– pdfToFit = <pdf1> …
Only those listed PDFs will be fitted if this config exists.
– postPdfReadSecParams = <no|yes|secName>
Override params from PDF fits with values listed in action section (and section if specified here).
1st February 2011 Fergus Wilson, RAL/STFC
Fit action (1) – pdfFit output example
1st February 2011 Fergus Wilson, RAL/STFC 32
heplnx111> rarFit –A PdfAct tutorial.config heplnx111> $ROOTSYS/bin/root -l results/tutorial.mlFitter.Config.pdfFit.PdfAct.root ...using style 'Plain' ...found RELEASE directory ...found PARENT directory ...running in release 24.5.6 For approved plots use: gROOT->SetStyle("BABAR"); To add a BABAR label use: BABARLabel(); To add a better-scaling BABAR label use: BABARSmartLabel(); Type "BABARSmartLabel(-2);" for options root [0] Attaching file results/tutorial.mlFitterConfig.pdfFit.PdfAct.root as _file0... RooFit v3.12 -- Developed by Wouter Verkerke and David Kirkby Copyright (C) 2000-2009 NIKHEF, University of California & Stanford University All rights reserved, please read http://roofit.sourceforge.net/license.txt root [1] _file0->ls() TFile** results/tutorial.mlFitter_Config.pdfFit.PdfAct.root TFile* results/tutorial.mlFitter_Config.pdfFit.PdfAct.root KEY: RooPlot mes_the_mesSig;1 M_{ES} CBShape signal KEY: RooPlot deltae_the_deSig;1 #DeltaE TwoGauss signal KEY: RooPlot nn_the_nnSig;1 Fisher Gaussian signal KEY: RooPlot mass_the_massSig;1 Mass BreitWigner signal KEY: RooPlot mes_the_mesBkg;1 M_{ES} AddPdf bkg KEY: RooPlot deltae_the_deBkg;1 #DeltaE Chebychev bkg KEY: RooPlot nn_the_nnBkg;1 Fisher Gaussian bkg KEY: RooPlot mass_the_massBkg;1 Mass Chebychev bkg KEY: RooPlot mes_the_mesUds;1 M_{ES} ArgusBG bkg KEY: RooPlot deltae_the_deUds;1 #DeltaE Chebychev uds KEY: RooPlot nn_the_nnUds;1 Fisher Gaussian uds KEY: RooPlot mass_the_massUds;1 Mass Chebychev uds Root [2] mes_the_mesBkg->Draw()
• Fit full ML model on dataset to get yields, etc. – Input: parameters values from pdfFit action
– Output: final parameters in intermediate file, mlFit results, including: • Yields, floating parameters
• Significance of any floating parameters wrt any particular value
• Systematic errors of floating parameters due to the uncertainty of fixed parameters
33
// Action section name, command line option –A MLAct [MLAct] // mlFit options mlFit = yes // enable mlFit action mlFitData = onData postMLSignf = nSig // signal yield signf. (wrt 0 by default) postMLSysVars = nSig // calculate syst. error for nSig by varying fixed params postMLSysParams = deSig_meanC deSig_meanT \\ deSig_sigmaC deSig_sigmaT \\ deSig_fracC
List all fixed params to vary for syst. errors
Fit action (2)- mlFit
1st February 2011 Fergus Wilson, RAL/STFC
• toyStudy action is to validate the fitter – Input: param values from pdfFit action
– Output: toyStudy results (pulls, etc) in ROOT file
34
// Action section name, command line option –A ToyAct [ToyAct] // toyStudy options toyStudy = yes // enable toyStudy action preToyReadParams = yes preToyReadSecParams = yes nSig = 93 +/- 10 L(-10 – 3000) nChls = 200 +/- 50 L(-10 – 3000) protDatasets = onData toyNexp = 100 toyNevt = 0 floated // 0: nEvt from protDataset; and fluctuation. toySrc_nSig = sigMC “@0 nSig” toySrc_nChls = bbMC “@0 nChls” toySrc_nBkg = gsbData 1 pdf “@0-1 nBkg”
Fit action (3) - toyStudy
Override params from pdfFit or init values
If not specified, `pure toy’. a variety of `embd toys’ if specified
1st February 2011 Fergus Wilson, RAL/STFC
35
[ToyAct] toyStudy = yes // enable toyStudy action nSig = 93 +/- 10 L(-10 – 3000) protDatasets = onData toyNexp = 100 preToyRandParams = nSig “@0+@1 nSig nSigGen” \\ nBkg “@0-@1 nBkg nSigGen” preToyRandGenerators = nSigGenPdf // PDF config section for param randomizer [nSigGenPdf Config] configStr = Generic formula = "1" nSigGen nSigGen = nSigGen 0 L(-43 - 57) // nSig scan range (50, 150)
Fit action (3) - toyStudy advanced features
• Parameter scanning Validate the fitter on all possible values for some parameters
For example, scan signal yields from 50 to 150 events:
1st February 2011 Fergus Wilson, RAL/STFC
Fit action (3) - toyStudy output example
1st February 2011 Fergus Wilson, RAL/STFC 36
heplnx111> rarFit –A ToyAct tutorial.config heplnx111> bbrroot –l results/tutorial.mlFitter_Config.toyPlot.ToyAct.root root [0] Attaching file all.root as _file0... root [1] _file0->ls() TFile** all.root chain files TFile* all.root chain files KEY: TTree toyResults;1 toyResults root [2] toyResults->Draw(“nSig”) ; toyResults->Draw(“nSigerr”) root [3] toyResults->Draw(“nSigpull”) ; htemp->Fit(“gaus”)
Number of signal events fitted
Error on number of signal events fitted
Pull on number of signal events
37
Fit action (4)- scanPlot
• Scan –Log(L) [NLL] within interested parameter spaces – Input: parameters from mlFit action
– Output: NLL points within parameter spaces, NLL plot (for 1D scanning), in ROOT file
// Action section name, command line option –A ScanAct [ScanAct] // scanPlot options scanPlot = yes // enable scanPlot action scanPlotData = onData nScanPoints = 100 // Number of NLL values scanVars = nSig 0 100 scanUnCorrErr = 5.1 // nll plot with uncorrelated error included scanCorrErr = 2.2 // nll plot with correlated error (and uncorrelated // if any) included
1st February 2011 Fergus Wilson, RAL/STFC
Fit action (4)- scanPlot output example
1st February 2011 Fergus Wilson, RAL/STFC 38
heplnx111> rarFit –A YieldScan tutorial.config heplnx111> $ROOTSYS/bin/root -l results/tutorial.mlFitter_Config.scanPlot.YieldScan.root root [0] Attaching file results/tutorial.mlFitter_Config.scanPlot.YieldScan.root as _file0... root [1] _file0->ls() TFile** results/tutorial.mlFitter_Config.scanPlot.YieldScan.root TFile* results/tutorial.mlFitter_Config.scanPlot.YieldScan.root KEY: RooPlot NLLScanPlot_nSig;1 NLLScanPlot_nSig KEY: TTree scanDS;1 scanDS Root [2] NLLScanPlot_nSig->Draw()
39
Fit action (5) - projPlot
• Get projection plots for given hypothesis (signal etc…) – Input: parameters from mlFit action
– Output: projection plots, LLR histograms, asym plots, in ROOT file
// Action section name, command line option –A ProjAct [ProjAct] // projPlot options projPlot = yes // enable projPlot action projPlotData = onData projComps = Sig // signal PDF to be projected projLLRPlots = yes // create LLR histograms projVars = mes de fisher // obs to get projection plots projLRatioCut = .810 projLRatioCut_mes = .835 projLRatioCut_de = .920 projLRatioCut_fisher = .890 projFindOptimCut = yes projOptimRange_mes = "abs(mes-5.28)<0.006" projOptimRange_de = "abs(de)<0.07" projOptimRange_fisher = "fisher<0.0" projPlotCat = runBlock // get projection plot for each cat type
Likelihood ratio cuts
Find optimal cuts
1st February 2011 Fergus Wilson, RAL/STFC
Fit action (5) – projPlot output example
1st February 2011 Fergus Wilson, RAL/STFC 40
heplnx111> rarFit –A ProjAct tutorial.config heplnx111> $ROOTSYS/bin/root -l results/tutorial.mlFitter_Config.projPlot.ProjAct.root root [0] Attaching file results/tutorial.mlFitter_Config.projPlot.ProjAct.root as _file0... root [1] _file0->ls() TFile** results/tutorial.mlFitter_Config.projPlot.ProjAct.root TFile* results/tutorial.mlFitter_Config.projPlot.ProjAct.root KEY: RooPlot proj_mes;1 projection of M_{ES} with lRatioFunc_mes>.90 KEY: RooPlot proj_deltae;1 projection of #DeltaE with lRatioFunc_deltae>.90 KEY: RooPlot proj_mass;1 projection of Mass with lRatioFunc_mass>.90 KEY: RooPlot proj_nn;1 projection of Fisher with lRatioFunc_nn>.90 KEY: TH1F LLR_simData;1 LLR ds KEY: TH1F LLR_mlFitter;1 LLR hist KEY: TH1F LLR_sigPdf;1 LLR hist KEY: TH1F LLR_bkgPdf;1 LLR hist KEY: TH1F LLR_udsPdf;1 LLR hist Root [2] proj_mes->Draw() Root [3] LLR_simData->draw(“PE”);LLR_sigPdf->Draw(“same”)
41
Fit action (6) - contourPlot
• Get contour plots for two floating params – Input: parameters from mlFit action
– Output: contour plots in ROOT file
// Action section name, command line option –A ContourAct [ContourAct] // contourPlot options contourPlot = yes // enable contourPlot action contourPlotData = onData nContours = 3 // Number of contours contourVars = nSig 0 100 fL .3 1.4
1st February 2011 Fergus Wilson, RAL/STFC
42
Fit action (7)- sPlot
• Get sPlots – Input: parameters from mlFit action
– Output: sPlots in ROOT file
// Action section name, command line option –A SPlotAct [ProjAct] // sPlot options sPlot = yes // enable sPlot action sPlotData = onData sPlotComps = all // sPlots for all hypotheses sPlotVars = mes de fisher // observables to get sPlots sPlotPdfOverlay = direct // direct PDF used for PDF overlay sPlotIgnoredVars_heli = resMass sPlotNormIgnoredObs = tagFlav dtErr
removed from PDF normalization due to PDF inconsistency across species
correlated obs should be removed
1st February 2011 Fergus Wilson, RAL/STFC
Fit action (7)- sPlot output example
1st February 2011 Fergus Wilson, RAL/STFC 43
heplnx111>heplnx111> rarFit –A SPlotAct tutorial.config $ROOTSYS/bin/root -l results/tutorial.mlFitter_Config.sPlot.SPlotAct.root root [0] Attaching file results/tutorial.mlFitter_Config.sPlot.SPlotAct.root as _file0... root [1] _file0->ls() TFile** results/tutorial.mlFitter_Config.sPlot.SPlotAct.root TFile* results/tutorial.mlFitter_Config.sPlot.SPlotAct.root KEY: RooPlot sPlot_mes_nSig;1 sPlot_mes_nSig KEY: RooPlot sPlot_mes_nBkg;1 sPlot_mes_nBkg KEY: RooPlot sPlot_mes_nUds;1 sPlot_mes_nUds KEY: RooPlot sPlot_deltae_nSig;1 sPlot_deltae_nSig KEY: RooPlot sPlot_deltae_nBkg;1 sPlot_deltae_nBkg KEY: RooPlot sPlot_deltae_nUds;1 sPlot_deltae_nUds KEY: RooPlot sPlot_mass_nSig;1 sPlot_mass_nSig KEY: RooPlot sPlot_mass_nBkg;1 sPlot_mass_nBkg KEY: RooPlot sPlot_mass_nUds;1 sPlot_mass_nUds KEY: RooPlot sPlot_nn_nSig;1 sPlot_nn_nSig KEY: RooPlot sPlot_nn_nBkg;1 sPlot_nn_nBkg KEY: RooPlot sPlot_nn_nUds;1 sPlot_nn_nUds Root [2] sPlot_mes_nSig->Draw() ; sPlot_mes_nUds->Draw()
Fit action (8) - combinePlot
• Can combine NLL from different model fits e.g. combine Branching Fraction for B→ρK*+ where K*+ has been fitted separately as K*+ →π+K0s and K*+ →π0K+.
– Input: scan curves in files created by scanPlot action
– Output: combined scan curve with optional systematic errors
1st February 2011 Fergus Wilson, RAL/STFC 44
// Action section name, command line option –A combineAct [combineAct] // combinePlot options combinePlot = yes // enable scanPlot action combineNcurves = 2 combineFilenames = “results/f1.mlFitter_Config.scanplot.scan.root” \\ “results/f2.mlFitter_Config.scanplot.scan.root” combinePlotnames = “NLLScanPlot_measBR_Sig” \\ “NLLScanPlot_measBR_Sig” combineAdditive = 0.5 0.4 // additive systematic errors combineMultiplicativeUncorrelated = 0.01 0.01 // systematic errors combineMultiplicativeCorrelated = 0.2 0.2 // systematic errors combineUpperLimit = yes 90 // calculate 90% CL upper limit CombineXaxisTitle = “Combined Branching Fraction”
Fit action (8) – combinePlot output example
1st February 2011 Fergus Wilson, RAL/STFC 45
heplnx111> rarFit –A CombineAct tutorial.config heplnx111> $ROOTSYS/bin/root -l results/tutorial.mlFitter_Config.combinePlot.CombineAct.root root [0] Attaching file results/tutorial.mlFitter_Config.combinePlot.CombineAct.root as _file0... root [1] _file0->ls() TFile** results/tutorial.mlFitter_Config.combinePlot.CombineAct.root TFile* results/tutorial.mlFitter_Config.combinePlot.CombineAct.root KEY: RooPlot combinePlot_Mode0;1 NLL with syst+stat and stat. errs only KEY: RooPlot combinePlot_Mode1;1 NLL with syst+stat and stat. errs only KEY: RooPlot combinePlot;1 Combined curves root [2] combinePlot_Mode0->Draw() ; combinePlot_Mode1->Draw() ; combinePlot->Draw()
Statistical only
Statistical + Systematic
1st mode
2nd mode 1st mode
2nd mode
Combined
Statistical + Systematic
This example won’t work for you as you do not have the input files. Edit “CombineAct” section to pick up files from ~fwilson/BAS/