ROOT logo

From $ROOTSYS/tutorials/roofit/rf513_wsfactory_tools.C

/////////////////////////////////////////////////////////////////////////
//
// 'ORGANIZATION AND SIMULTANEOUS FITS' RooFit tutorial macro #513
// 
//  Illustration use of RooCustomizer and RooSimWSTool interface
//  in factory workspace tool in a complex standalone B physics example
//
// 04/2009 - Wouter Verkerke 
//
/////////////////////////////////////////////////////////////////////////

#ifndef __CINT__
#include "RooGlobalFunc.h"
#endif
#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooGaussian.h"
#include "RooConstVar.h"
#include "RooChebychev.h"
#include "RooAddPdf.h"
#include "RooWorkspace.h"
#include "RooPlot.h"
#include "TCanvas.h"
#include "TAxis.h"
using namespace RooFit ;


void rf513_wsfactory_tools()
{
  RooWorkspace* w = new RooWorkspace("w") ;


  // B u i l d   a   c o m p l e x   e x a m p l e   p . d . f . 
  // -----------------------------------------------------------

  // Make signal model for CPV: A bmixing decay function in t (convoluted with a triple Gaussian resolution model)
  //                            times a Gaussian function the reconstructed mass
  w->factory("PROD::sig(  BMixDecay::sig_t( dt[-20,20], mixState[mixed=1,unmix=-1], tagFlav[B0=1,B0bar=-1], "
                                             "tau[1.54], dm[0.472], w[0.05], dw[0],"
                                             "AddModel::gm({GaussModel(dt,biasC[-10,10],sigmaC[0.1,3],dterr[0.01,0.2]),"
                                                     	   "GaussModel(dt,0,sigmaT[3,10]),"
                                                           "GaussModel(dt,0,20)},{fracC[0,1],fracT[0,1]}),"
                                             "DoubleSided ),"
                           "Gaussian::sig_m( mes[5.20,5.30], mB0[5.20,5.30], sigmB0[0.01,0.05] ))") ;
  
  // Make background component: A plain decay function in t times an Argus function in the reconstructed mass
  w->factory("PROD::bkg(  Decay::bkg_t( dt, tau, gm, DoubleSided),"
                         "ArgusBG::bkg_m( mes, 5.291, k[-100,-10]))") ;

  // Make composite model from the signal and background component
  w->factory("SUM::model( Nsig[5000,0,10000]*sig, NBkg[500,0,10000]*bkg )") ;


  // 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 
  // ------------------------------------------------------------------

  // Introduce a flavour tagging category tagCat as observable with 4 states corresponding
  // to 4 flavour tagging techniques with different performance that require different
  // parameterizations of the fit model
  //
  // RooSimWSTool operation: 
  //     - Make 4 clones of model (for each tagCat) state, that will gain an individual 
  //       copy of parameters w,dw and biasC. The other parameters remain common
  //     - Make a simultaneous p.d.f. of the 4 clones assigning each to the appropriate
  //       state of the tagCat index category

  // RooSimWSTool is interfaced as meta-type SIMCLONE in the factory. The $SplitParam() 
  // argument maps to the SplitParam() named argument in the RooSimWSTool constructor
  w->factory("SIMCLONE::model_sim( model, $SplitParam({w,dw,biasC},tagCat[Lep,Kao,NT1,NT2]))") ;


  // 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 
  // -------------------------------------------------------------------
  //
  // Class RooCustomizer makes clones of existing p.d.f.s with certain prescribed
  // modifications (branch of leaf node replacements)
  //
  // Here we take our model (the original before RooSimWSTool modifications)
  // and request that the parameter w (the mistag rate) is replaced with
  // an expression-based function that calculates w in terms of the Dilution
  // parameter D that is defined as D = 1-2*w

  // Make a clone model_D of original 'model' replacing 'w' with 'expr('0.5-D/2',D[0,1])'
  w->factory("EDIT::model_D(model, w=expr('0.5-D/2',D[0,1]) )") ;


  // Print workspace contents
  w->Print() ;

  // Make workspace visible on command line
  gDirectory->Add(w) ;
}


 rf513_wsfactory_tools.C:1
 rf513_wsfactory_tools.C:2
 rf513_wsfactory_tools.C:3
 rf513_wsfactory_tools.C:4
 rf513_wsfactory_tools.C:5
 rf513_wsfactory_tools.C:6
 rf513_wsfactory_tools.C:7
 rf513_wsfactory_tools.C:8
 rf513_wsfactory_tools.C:9
 rf513_wsfactory_tools.C:10
 rf513_wsfactory_tools.C:11
 rf513_wsfactory_tools.C:12
 rf513_wsfactory_tools.C:13
 rf513_wsfactory_tools.C:14
 rf513_wsfactory_tools.C:15
 rf513_wsfactory_tools.C:16
 rf513_wsfactory_tools.C:17
 rf513_wsfactory_tools.C:18
 rf513_wsfactory_tools.C:19
 rf513_wsfactory_tools.C:20
 rf513_wsfactory_tools.C:21
 rf513_wsfactory_tools.C:22
 rf513_wsfactory_tools.C:23
 rf513_wsfactory_tools.C:24
 rf513_wsfactory_tools.C:25
 rf513_wsfactory_tools.C:26
 rf513_wsfactory_tools.C:27
 rf513_wsfactory_tools.C:28
 rf513_wsfactory_tools.C:29
 rf513_wsfactory_tools.C:30
 rf513_wsfactory_tools.C:31
 rf513_wsfactory_tools.C:32
 rf513_wsfactory_tools.C:33
 rf513_wsfactory_tools.C:34
 rf513_wsfactory_tools.C:35
 rf513_wsfactory_tools.C:36
 rf513_wsfactory_tools.C:37
 rf513_wsfactory_tools.C:38
 rf513_wsfactory_tools.C:39
 rf513_wsfactory_tools.C:40
 rf513_wsfactory_tools.C:41
 rf513_wsfactory_tools.C:42
 rf513_wsfactory_tools.C:43
 rf513_wsfactory_tools.C:44
 rf513_wsfactory_tools.C:45
 rf513_wsfactory_tools.C:46
 rf513_wsfactory_tools.C:47
 rf513_wsfactory_tools.C:48
 rf513_wsfactory_tools.C:49
 rf513_wsfactory_tools.C:50
 rf513_wsfactory_tools.C:51
 rf513_wsfactory_tools.C:52
 rf513_wsfactory_tools.C:53
 rf513_wsfactory_tools.C:54
 rf513_wsfactory_tools.C:55
 rf513_wsfactory_tools.C:56
 rf513_wsfactory_tools.C:57
 rf513_wsfactory_tools.C:58
 rf513_wsfactory_tools.C:59
 rf513_wsfactory_tools.C:60
 rf513_wsfactory_tools.C:61
 rf513_wsfactory_tools.C:62
 rf513_wsfactory_tools.C:63
 rf513_wsfactory_tools.C:64
 rf513_wsfactory_tools.C:65
 rf513_wsfactory_tools.C:66
 rf513_wsfactory_tools.C:67
 rf513_wsfactory_tools.C:68
 rf513_wsfactory_tools.C:69
 rf513_wsfactory_tools.C:70
 rf513_wsfactory_tools.C:71
 rf513_wsfactory_tools.C:72
 rf513_wsfactory_tools.C:73
 rf513_wsfactory_tools.C:74
 rf513_wsfactory_tools.C:75
 rf513_wsfactory_tools.C:76
 rf513_wsfactory_tools.C:77
 rf513_wsfactory_tools.C:78
 rf513_wsfactory_tools.C:79
 rf513_wsfactory_tools.C:80
 rf513_wsfactory_tools.C:81
 rf513_wsfactory_tools.C:82
 rf513_wsfactory_tools.C:83
 rf513_wsfactory_tools.C:84
 rf513_wsfactory_tools.C:85
 rf513_wsfactory_tools.C:86
 rf513_wsfactory_tools.C:87
 rf513_wsfactory_tools.C:88
 rf513_wsfactory_tools.C:89
 rf513_wsfactory_tools.C:90
 rf513_wsfactory_tools.C:91
 rf513_wsfactory_tools.C:92
 rf513_wsfactory_tools.C:93
 rf513_wsfactory_tools.C:94
 rf513_wsfactory_tools.C:95