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