Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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## \macro_output
9##
10## \date February 2018
11## \authors Clemens Lange, Wouter Verkerke (C++ version)
12
13import ROOT
14
15
16w = ROOT.RooWorkspace("w")
17
18# Build a complex example pdf
19# -----------------------------------------------------------
20
21# Make signal model for CPV: A bmixing decay function in t (convoluted with a triple Gaussian resolution model)
22# times a Gaussian function the reconstructed mass
23w.factory(
24 "PROD::sig( BMixDecay::sig_t( dt[-20,20], mixState[mixed=1,unmix=-1], tagFlav[B0=1,B0bar=-1], "
25 "tau[1.54], dm[0.472], w[0.05], dw[0], "
26 "AddModel::gm({GaussModel(dt,biasC[-10,10],sigmaC[0.1,3],dterr[0.01,0.2]), "
27 "GaussModel(dt,0,sigmaT[3,10]), "
28 "GaussModel(dt,0,20)},{fracC[0,1],fracT[0,1]}), "
29 "DoubleSided ), "
30 "Gaussian::sig_m( mes[5.20,5.30], mB0[5.20,5.30], sigmB0[0.01,0.05] ))"
31)
32
33# Make background component: A plain decay function in t times an Argus
34# function in the reconstructed mass
35w.factory("PROD::bkg( Decay::bkg_t( dt, tau, gm, DoubleSided), " "ArgusBG::bkg_m( mes, 5.291, k[-100,-10]))")
36
37# Make composite model from the signal and background component
38w.factory("SUM::model( Nsig[5000,0,10000]*sig, NBkg[500,0,10000]*bkg )")
39
40# Example of RooSimWSTool interface
41# ------------------------------------------------------------------
42
43# Introduce a flavour tagging category tagCat as observable with 4 states corresponding
44# to 4 flavour tagging techniques with different performance that require different
45# parameterizations of the fit model
46#
47# ROOT.RooSimWSTool operation:
48# - Make 4 clones of model (for each tagCat) state, will gain an individual
49# copy of parameters w, and biasC. The other parameters remain common
50# - Make a simultaneous pdf of the 4 clones assigning each to the appropriate
51# state of the tagCat index category
52
53# ROOT.RooSimWSTool is interfaced as meta-type SIMCLONE in the factory. The $SplitParam()
54# argument maps to the SplitParam() named argument in the
55# ROOT.RooSimWSTool constructor
56w.factory("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 pdfs 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)