roorarfit tutorial fergus wilson ral/stfc based on original tutorial by author lei zhang 1st...

45
RooRarFit Tutorial Fergus Wilson RAL/STFC Based on original tutorial by author Lei Zhang 1st February 2011 Fergus Wilson, RAL/STFC 1

Upload: rodney-hodges

Post on 02-Jan-2016

217 views

Category:

Documents


0 download

TRANSCRIPT

RooRarFit TutorialFergus Wilson

RAL/STFCBased 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 M

j

N

( )

1

s:

To maximize likelihood minim

!

(iz )e

jjN N

ii

eL L

N

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 RooRarFitand

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:> rarFitrarFit [-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.configrarFit 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 workdirmkdir Ntuples$ROOTSYS/bin/root –l –q –b ../RooRarFit/doc/tutorial/make_data.Ccp ../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 plotsrarFit –A PdfAct tutorial.config

// fit the whole model and extract the yields -> no plots createdrarFit –A MLAct tutorial.config

// Do a “pure” toy study on ensemble of events created by the fitted PDFs -> creates ntuplesrarFit –A ToyAct tutorial.config

// Do an “embedded” toy study on ensemble of events created from the datasetsrarFit –A eToyAct tutorial.config

// generate projection plots -> creates plotsrarFit –A ProjAct tutorial.config // generate sPlots -> creates plotsrarFit –A SPlotAct tutorial.config

// scan the NLL about fitted yield ML minimum -> creates plotsrarFit –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 PDFsrarFit –A PdfAct –C “bfFitter Config” tutorial.config

// fit the whole model and extract the branching fractionrarFit –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 datasetsrarFit –A eToyAct –C “bfFitter Config” tutorial.config

// projection and sPlots are meaningless for branching fraction fits

// scan the NLL about fitted branching fraction ML minimumrarFit –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 PDFsrarFit –A PdfAct tutorial.config

// fit the whole model and extract the Charged AsymmetriesrarFit –A MLAct tutorial.config

// scan the NLL about fitted Charge Asymmetry ML minimumrarFit –A AScan tutorial.config

4) Time Dependent Asymmetries Example

1st February 2011 Fergus Wilson, RAL/STFC 13

// fit the individual PDFsrarFit –A PdfAct tutorial_v3.config

// fit the whole model and extract the asymmetries C and S and yieldrarFit –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 documentationcd RooRarFit/docgmake 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”– Fit the individual PDFs and create plots of fits - pdfFit

– Fit the maximum likelihood model and output results - mlFit

– Perform multiple toy fits to extract pulls and biases – toyStudy

– Create plots of log-likelihood about the minimum – scanPlot

– Create projection plots of the fitted yields – projPlot

– Create contour plots of two variables – contourPlot

– Create sPlot plots of the hypothesis yields – sPlot

– 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 fisherrunNum = RooRealVar “runNum” 0 1e10mes = 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

unitrange Plot binsType 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 fisherrunNum = RooRealVar “runNum” 0 1e10mes = 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 = runBlockrunBlock = 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 totMConData = root “on peak data” “mydats/on.root” “ntout”sigMC = ascii “sig MC” “mydats/sigMC.txt” QbbMC = ascii “peaking BB MC” “mydats/bbMC.txt” QgsbData = 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 cutsinputType 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 datasetuseNumCPU = 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 herethe_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 namesOptional title

[myModel Config]configStr = MLPdf “ml yield model”Comps = Sig Chls Bkg // component PDFs for this modelCoeffs = nSig nChls nBkg // component yields for this modelnSig = 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 componentsfitData = sigMC // Use sigMC to get pdf params

[Chls Config]configStr = ProdPdf “Charmless B bkg”Comps = deChls mesChls fisChlsfitData = bbMC // Use bbMC to get pdf params

[Bkg Config]configStr = ProdPdf “Continuum Bkg”Comps = deBkg mesBkg fisBkgfitData = 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 = demeanC = 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 = TwoGaussx = mesmeanC = 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 = BGGaussx = fishermean = -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, RRVname will be prefixed with PDF name,for example, fisSig_mean, fisSig_rms,and fisSig_asym.In RooRarFit, params belong to RooRarFitPDF objects, so full names are needed todistinguish same param names from differentPDFs.

1st February 2011 Fergus Wilson, RAL/STFC

• Charmless B background PDF config sections

[mesChlsA Config]configStr = ArgusBGx = mesmax = 5.29 Cc = -30 L(-80 - -.1)

[fisChls Config]configStr = BGGaussx = fishermean = -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 = TwoGaussx = demeanC = 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 = AddPdfComps = mesChlsG mesChlsACoeffs = fracGfracG = T “f_{G}” 0.08 L(0-1)

[mesChlsG Config]configStr = Gaussianx = mesmean = 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 = AddPdfComps = fisBkgC fisBkgTCoeffs = fracCfracC = T “f_{C}” 0.97 L(0 -1)

[fisBkgC Config]configStr = BGGaussx = fishermean = 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 = Gaussianx = fishermean = 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 = Polynomialx = denOrder = 2P01 = -1.5 L(-100 - 100)P02 = 2.0 L(-100 - 100)postPdfFloat = P01

[mesBkg Config]fitData = desbDataconfigStr = ArgusBGx = mesmax = 5.29 Cc = -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 = massmean = 0.80 L(0.8 – 1.0)width = 0.05 L(0.01 – 0.1)

[massBkg Config]configStr = AddPdf “Continuum”Comps = massSig massPolyBkgprePdfFix = massSigCoeffs = fracSfracS = 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 optionspdfFit = yes // enable pdfFit actionpostPdfMakePlot = yes // To output PDF plots into root filepostPdfWriteParams = 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.configheplnx111> $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 udsRoot [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 optionsmlFit = yes // enable mlFit actionmlFitData = onDatapostMLSignf = nSig // signal yield signf. (wrt 0 by default)postMLSysVars = nSig // calculate syst. error for nSig by varying fixed paramspostMLSysParams = 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 optionstoyStudy = yes // enable toyStudy actionpreToyReadParams = yespreToyReadSecParams = yesnSig = 93 +/- 10 L(-10 – 3000)nChls = 200 +/- 50 L(-10 – 3000)protDatasets = onDatatoyNexp = 100toyNevt = 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 actionnSig = 93 +/- 10 L(-10 – 3000)protDatasets = onDatatoyNexp = 100preToyRandParams = nSig “@0+@1 nSig nSigGen” \\ nBkg “@0-@1 nBkg nSigGen”preToyRandGenerators = nSigGenPdf

// PDF config section for param randomizer[nSigGenPdf Config]configStr = Genericformula = "1" nSigGennSigGen = 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.configheplnx111> bbrroot –l results/tutorial.mlFitter_Config.toyPlot.ToyAct.rootroot [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 toyResultsroot [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 optionsscanPlot = yes // enable scanPlot actionscanPlotData = onDatanScanPoints = 100 // Number of NLL valuesscanVars = nSig 0 100scanUnCorrErr = 5.1 // nll plot with uncorrelated error includedscanCorrErr = 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.configheplnx111> $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 scanDSRoot [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 optionsprojPlot = yes // enable projPlot actionprojPlotData = onDataprojComps = Sig // signal PDF to be projectedprojLLRPlots = yes // create LLR histogramsprojVars = mes de fisher // obs to get projection plotsprojLRatioCut = .810projLRatioCut_mes = .835projLRatioCut_de = .920 projLRatioCut_fisher = .890projFindOptimCut = yesprojOptimRange_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.configheplnx111> $ROOTSYS/bin/root -l results/tutorial.mlFitter_Config.projPlot.ProjAct.rootroot [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 histRoot [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 optionscontourPlot = yes // enable contourPlot actioncontourPlotData = onDatanContours = 3 // Number of contourscontourVars = 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 optionssPlot = yes // enable sPlot actionsPlotData = onDatasPlotComps = all // sPlots for all hypothesessPlotVars = mes de fisher // observables to get sPlotssPlotPdfOverlay = direct // direct PDF used for PDF overlaysPlotIgnoredVars_heli = resMasssPlotNormIgnoredObs = tagFlav dtErr

removed from PDF normalization due toPDF 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.rootroot [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_nUdsRoot [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 optionscombinePlot = yes // enable scanPlot actioncombineNcurves = 2combineFilenames = “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 errorscombineMultiplicativeUncorrelated = 0.01 0.01 // systematic errorscombineMultiplicativeCorrelated = 0.2 0.2 // systematic errorscombineUpperLimit = yes 90 // calculate 90% CL upper limitCombineXaxisTitle = “Combined Branching Fraction”

Fit action (8) – combinePlot output example

1st February 2011 Fergus Wilson, RAL/STFC 45

heplnx111> rarFit –A CombineAct tutorial.configheplnx111> $ROOTSYS/bin/root -l results/tutorial.mlFitter_Config.combinePlot.CombineAct.rootroot [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 curvesroot [2] combinePlot_Mode0->Draw() ; combinePlot_Mode1->Draw() ; combinePlot->Draw()

Statistical only

Statistical + Systematic

1st mode

2nd mode1st 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/