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