rf803_mcstudy_addons2.C

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////
00002 //
00003 // 'VALIDATION AND MC STUDIES' RooFit tutorial macro #803
00004 // 
00005 // RooMCStudy: Using the randomizer and profile likelihood add-on models
00006 //
00007 // 
00008 // 07/2008 - Wouter Verkerke 
00009 //
00010 /////////////////////////////////////////////////////////////////////////
00011 
00012 #ifndef __CINT__
00013 #include "RooGlobalFunc.h"
00014 #endif
00015 #include "RooRealVar.h"
00016 #include "RooDataSet.h"
00017 #include "RooGaussian.h"
00018 #include "RooConstVar.h"
00019 #include "RooChebychev.h"
00020 #include "RooAddPdf.h"
00021 #include "RooMCStudy.h"
00022 #include "RooRandomizeParamMCSModule.h"
00023 #include "RooDLLSignificanceMCSModule.h"
00024 #include "RooPlot.h"
00025 #include "TCanvas.h"
00026 #include "TAxis.h"
00027 #include "TH1.h"
00028 #include "TDirectory.h"
00029 
00030 using namespace RooFit ;
00031 
00032 
00033 void rf803_mcstudy_addons2()
00034 {
00035   // C r e a t e   m o d e l 
00036   // -----------------------
00037 
00038   // Simulation of signal and background of top quark decaying into
00039   // 3 jets with background
00040 
00041   // Observable
00042   RooRealVar mjjj("mjjj","m(3jet) (GeV)",100,85.,350.) ;
00043 
00044   // Signal component (Gaussian)
00045   RooRealVar mtop("mtop","m(top)",162) ;
00046   RooRealVar wtop("wtop","m(top) resolution",15.2) ;
00047   RooGaussian sig("sig","top signal",mjjj,mtop,wtop) ;
00048 
00049   // Background component (Chebychev)
00050   RooRealVar c0("c0","Chebychev coefficient 0",-0.846,-1.,1.) ;
00051   RooRealVar c1("c1","Chebychev coefficient 1", 0.112,-1.,1.) ;
00052   RooRealVar c2("c2","Chebychev coefficient 2", 0.076,-1.,1.) ;
00053   RooChebychev bkg("bkg","combinatorial background",mjjj,RooArgList(c0,c1,c2)) ;
00054 
00055   // Composite model
00056   RooRealVar nsig("nsig","number of signal events",53,0,1e3) ;
00057   RooRealVar nbkg("nbkg","number of background events",103,0,5e3) ;
00058   RooAddPdf model("model","model",RooArgList(sig,bkg),RooArgList(nsig,nbkg)) ;
00059 
00060 
00061 
00062   // C r e a t e   m a n a g e r
00063   // ---------------------------
00064 
00065   // Configure manager to perform binned extended likelihood fits (Binned(),Extended()) on data generated
00066   // with a Poisson fluctuation on Nobs (Extended())
00067   RooMCStudy* mcs = new RooMCStudy(model,mjjj,Binned(),Silence(),Extended(kTRUE),
00068                                    FitOptions(Extended(kTRUE),PrintEvalErrors(-1))) ;
00069 
00070 
00071 
00072   // C u s t o m i z e   m a n a g e r
00073   // ---------------------------------
00074 
00075   // Add module that randomizes the summed value of nsig+nbkg 
00076   // sampling from a uniform distribution between 0 and 1000
00077   //
00078   // In general one can randomize a single parameter, or a 
00079   // sum of N parameters, using either a uniform or a Gaussian
00080   // distribution. Multiple randomization can be executed
00081   // by a single randomizer module
00082   
00083   RooRandomizeParamMCSModule randModule ;
00084   randModule.sampleSumUniform(RooArgSet(nsig,nbkg),50,500) ;
00085   mcs->addModule(randModule) ;  
00086 
00087 
00088   // Add profile likelihood calculation of significance. Redo each
00089   // fit while keeping parameter nsig fixed to zero. For each toy,
00090   // the difference in -log(L) of both fits is stored, as well
00091   // a simple significance interpretation of the delta(-logL)
00092   // using Dnll = 0.5 sigma^2
00093 
00094   RooDLLSignificanceMCSModule sigModule(nsig,0) ;
00095   mcs->addModule(sigModule) ;
00096 
00097 
00098 
00099   // R u n   m a n a g e r ,   m a k e   p l o t s
00100   // ---------------------------------------------
00101 
00102   // Run 1000 experiments. This configuration will generate a fair number
00103   // of (harmless) MINUIT warnings due to the instability of the Chebychev polynomial fit
00104   // at low statistics.
00105   mcs->generateAndFit(500) ;
00106 
00107   // Make some plots
00108   TH1* dll_vs_ngen = mcs->fitParDataSet().createHistogram("ngen,dll_nullhypo_nsig",-40,-40) ;
00109   TH1* z_vs_ngen = mcs->fitParDataSet().createHistogram("ngen,significance_nullhypo_nsig",-40,-40) ;
00110   TH1* errnsig_vs_ngen = mcs->fitParDataSet().createHistogram("ngen,nsigerr",-40,-40) ;
00111   TH1* errnsig_vs_nsig = mcs->fitParDataSet().createHistogram("nsig,nsigerr",-40,-40) ;
00112 
00113 
00114   // Draw plots on canvas
00115   TCanvas* c = new TCanvas("rf803_mcstudy_addons2","rf802_mcstudy_addons2",800,800) ;
00116   c->Divide(2,2) ;
00117   c->cd(1) ; gPad->SetLeftMargin(0.15) ; dll_vs_ngen->GetYaxis()->SetTitleOffset(1.6) ; dll_vs_ngen->Draw("box") ;
00118   c->cd(2) ; gPad->SetLeftMargin(0.15) ; z_vs_ngen->GetYaxis()->SetTitleOffset(1.6) ; z_vs_ngen->Draw("box") ;
00119   c->cd(3) ; gPad->SetLeftMargin(0.15) ; errnsig_vs_ngen->GetYaxis()->SetTitleOffset(1.6) ; errnsig_vs_ngen->Draw("box") ;
00120   c->cd(4) ; gPad->SetLeftMargin(0.15) ; errnsig_vs_nsig->GetYaxis()->SetTitleOffset(1.6) ; errnsig_vs_nsig->Draw("box") ;
00121 
00122  
00123   // Make RooMCStudy object available on command line after
00124   // macro finishes
00125   gDirectory->Add(mcs) ;
00126 
00127 }
00128 
00129 
00130 
00131 

Generated on Tue Jul 5 15:45:09 2011 for ROOT_528-00b_version by  doxygen 1.5.1