ROOT   Reference Guide
rf513_wsfactory_tools.py
Go to the documentation of this file.
1## \file
2## \ingroup tutorial_roofit
3## \notebook -nodraw
4## Organization and simultaneous fits: illustration use of ROOT.RooCustomizer and
5## ROOT.RooSimWSTool interface in factory workspace tool in a complex standalone B physics example
6##
7## \macro_code
8##
9## \date February 2018
10## \authors Clemens Lange, Wouter Verkerke (C++ version)
11
12import ROOT
13
14
15w = ROOT.RooWorkspace("w")
16
17# Build a complex example pdf
18# -----------------------------------------------------------
19
20# Make signal model for CPV: A bmixing decay function in t (convoluted with a triple Gaussian resolution model)
21# times a Gaussian function the reconstructed mass
22w.factory(
23 "PROD::sig( BMixDecay::sig_t( dt[-20,20], mixState[mixed=1,unmix=-1], tagFlav[B0=1,B0bar=-1], "
24 "tau[1.54], dm[0.472], w[0.05], dw[0], "
26 "GaussModel(dt,0,sigmaT[3,10]), "
27 "GaussModel(dt,0,20)},{fracC[0,1],fracT[0,1]}), "
28 "DoubleSided ), "
29 "Gaussian::sig_m( mes[5.20,5.30], mB0[5.20,5.30], sigmB0[0.01,0.05] ))"
30)
31
32# Make background component: A plain decay function in t times an Argus
33# function in the reconstructed mass
34w.factory("PROD::bkg( Decay::bkg_t( dt, tau, gm, DoubleSided), " "ArgusBG::bkg_m( mes, 5.291, k[-100,-10]))")
35
36# Make composite model from the signal and background component
37w.factory("SUM::model( Nsig[5000,0,10000]*sig, NBkg[500,0,10000]*bkg )")
38
39# Example of RooSimWSTool interface
40# ------------------------------------------------------------------
41
42# Introduce a flavour tagging category tagCat as observable with 4 states corresponding
43# to 4 flavour tagging techniques with different performance that require different
44# parameterizations of the fit model
45#
46# ROOT.RooSimWSTool operation:
47# - Make 4 clones of model (for each tagCat) state, will gain an individual
48# copy of parameters w, and biasC. The other parameters remain common
49# - Make a simultaneous pdf of the 4 clones assigning each to the appropriate
50# state of the tagCat index category
51
52# ROOT.RooSimWSTool is interfaced as meta-type SIMCLONE in the factory. The $SplitParam() 53# argument maps to the SplitParam() named argument in the 54# ROOT.RooSimWSTool constructor 55w.factory("SIMCLONE::model_sim( model,$SplitParam({w,dw,biasC},tagCat[Lep,Kao,NT1,NT2]))")
56
57# Example of RooCustomizer interface
58# -------------------------------------------------------------------
59#
60# Class ROOT.RooCustomizer makes clones of existing pdfs with certain prescribed
61# modifications (branch of leaf node replacements)
62#
63# Here we take our model (the original before ROOT.RooSimWSTool modifications)
64# and request that the parameter w (the mistag rate) is replaced with
65# an expression-based function that calculates w in terms of the Dilution
66# parameter D that is defined D = 1-2*w
67
68# Make a clone model_D of original 'model' replacing 'w' with
69# 'expr('0.5-D/2',D[0,1])'
70w.factory("EDIT::model_D(model, w=expr('0.5-D/2',D[0,1]) )")
71
72# Print workspace contents
73w.Print()
74
75# Make workspace visible on command line