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