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