00001
00002
00003
00004
00005
00006
00007
00008
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 "RooPolynomial.h"
00019 #include "RooAddPdf.h"
00020 #include "RooProdPdf.h"
00021 #include "RooMCStudy.h"
00022 #include "RooPlot.h"
00023 #include "TCanvas.h"
00024 #include "TH1.h"
00025 using namespace RooFit ;
00026
00027
00028 class TestBasic804 : public RooFitTestUnit
00029 {
00030 public:
00031 TestBasic804(TFile* refFile, Bool_t writeRef, Int_t verbose) : RooFitTestUnit("MC Studies with aux. obs. constraints",refFile,writeRef,verbose) {} ;
00032
00033 Double_t htol() { return 0.1 ; }
00034
00035 Bool_t testCode() {
00036
00037
00038
00039
00040
00041 RooRealVar x("x","x",-10,10) ;
00042
00043
00044 RooRealVar m("m","m",0,-10,10) ;
00045 RooRealVar s("s","s",2,0.1,10) ;
00046 RooGaussian g("g","g",x,m,s) ;
00047
00048
00049 RooPolynomial p("p","p",x) ;
00050
00051
00052 RooRealVar f("f","f",0.4,0.,1.) ;
00053 RooAddPdf sum("sum","sum",RooArgSet(g,p),f) ;
00054
00055
00056 RooGaussian fconstraint("fconstraint","fconstraint",f,RooConst(0.7),RooConst(0.1)) ;
00057
00058
00059 RooProdPdf sumc("sumc","sum with constraint",RooArgSet(sum,fconstraint)) ;
00060
00061
00062
00063
00064
00065
00066
00067 RooMCStudy mcs(sumc,x,Constrain(f),Silence(),Binned(),FitOptions(PrintLevel(-1))) ;
00068
00069
00070
00071
00072 mcs.generateAndFit(50,2000) ;
00073
00074
00075 RooRealVar* f_gen = (RooRealVar*) mcs.fitParDataSet().get()->find("f_gen") ;
00076 TH1* h_f_gen = new TH1F("h_f_gen","",40,0,1) ;
00077 mcs.fitParDataSet().fillHistogram(h_f_gen,*f_gen) ;
00078
00079
00080 RooPlot* frame1 = mcs.plotParam(f,Bins(40),Range(0.4,1)) ;
00081 frame1->SetTitle("Distribution of fitted f values") ;
00082
00083
00084 RooPlot* frame2 = mcs.plotPull(f,Bins(40),Range(-3,3)) ;
00085 frame1->SetTitle("Distribution of f pull values") ;
00086
00087 regTH(h_f_gen,"rf804_h_f_gen") ;
00088 regPlot(frame1,"rf804_plot1") ;
00089 regPlot(frame2,"rf804_plot2") ;
00090
00091 return kTRUE ;
00092 }
00093 } ;
00094