Logo ROOT  
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: illustration use of ROOT.RooCustomizer and ROOT.RooSimWSTool interface in factory workspace tool in a complex standalone B physics example
6##
7## \macro_code
8##
9## \date February 2018
10## \author 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], "
25 "AddModel::gm({GaussModel(dt,biasC[-10,10],sigmaC[0.1,3],dterr[0.01,0.2]), "
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# Make background component: A plain decay function in t times an Argus
32# function in the reconstructed mass
33w.factory("PROD::bkg( Decay::bkg_t( dt, tau, gm, DoubleSided), "
34 "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 p.d.f. 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(
56 "SIMCLONE::model_sim( model, $SplitParam({w,dw,biasC},tagCat[Lep,Kao,NT1,NT2]))")
57
58# Example of RooCustomizer interface
59# -------------------------------------------------------------------
60#
61# Class ROOT.RooCustomizer makes clones of existing p.d.f.s with certain prescribed
62# modifications (branch of leaf node replacements)
63#
64# Here we take our model (the original before ROOT.RooSimWSTool modifications)
65# and request that the parameter w (the mistag rate) is replaced with
66# an expression-based function that calculates w in terms of the Dilution
67# parameter D that is defined D = 1-2*w
68
69# Make a clone model_D of original 'model' replacing 'w' with
70# 'expr('0.5-D/2',D[0,1])'
71w.factory("EDIT::model_D(model, w=expr('0.5-D/2',D[0,1]) )")
72
73# Print workspace contents
74w.Print()
75
76# Make workspace visible on command line
77ROOT.gDirectory.Add(w)