00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef __CINT__
00012 #include "RooGlobalFunc.h"
00013 #endif
00014 #include "RooRealVar.h"
00015 #include "RooDataSet.h"
00016 #include "RooGaussian.h"
00017 #include "RooChebychev.h"
00018 #include "RooAddPdf.h"
00019 #include "RooMCStudy.h"
00020 #include "RooPlot.h"
00021 #include "TCanvas.h"
00022 #include "TH2.h"
00023 #include "RooFitResult.h"
00024 #include "TStyle.h"
00025 #include "TDirectory.h"
00026
00027 using namespace RooFit ;
00028
00029
00030
00031 class TestBasic801 : public RooFitTestUnit
00032 {
00033 public:
00034 TestBasic801(TFile* refFile, Bool_t writeRef, Int_t verbose) : RooFitTestUnit("Automated MC studies",refFile,writeRef,verbose) {} ;
00035 Bool_t testCode() {
00036
00037
00038
00039
00040
00041 RooRealVar x("x","x",0,10) ;
00042 x.setBins(40) ;
00043
00044
00045 RooRealVar mean("mean","mean of gaussians",5,0,10) ;
00046 RooRealVar sigma1("sigma1","width of gaussians",0.5) ;
00047 RooRealVar sigma2("sigma2","width of gaussians",1) ;
00048
00049 RooGaussian sig1("sig1","Signal component 1",x,mean,sigma1) ;
00050 RooGaussian sig2("sig2","Signal component 2",x,mean,sigma2) ;
00051
00052
00053 RooRealVar a0("a0","a0",0.5,0.,1.) ;
00054 RooRealVar a1("a1","a1",-0.2,-1,1.) ;
00055 RooChebychev bkg("bkg","Background",x,RooArgSet(a0,a1)) ;
00056
00057
00058 RooRealVar sig1frac("sig1frac","fraction of component 1 in signal",0.8,0.,1.) ;
00059 RooAddPdf sig("sig","Signal",RooArgList(sig1,sig2),sig1frac) ;
00060
00061
00062 RooRealVar nbkg("nbkg","number of background events,",150,0,1000) ;
00063 RooRealVar nsig("nsig","number of signal events",150,0,1000) ;
00064 RooAddPdf model("model","g1+g2+a",RooArgList(bkg,sig),RooArgList(nbkg,nsig)) ;
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 RooMCStudy* mcstudy = new RooMCStudy(model,x,Binned(kTRUE),Silence(),Extended(),
00087 FitOptions(Save(kTRUE),PrintEvalErrors(0))) ;
00088
00089
00090
00091
00092
00093
00094 mcstudy->generateAndFit(100) ;
00095
00096
00097
00098
00099
00100
00101
00102 RooPlot* frame1 = mcstudy->plotParam(mean,Bins(40)) ;
00103 RooPlot* frame2 = mcstudy->plotError(mean,Bins(40)) ;
00104 RooPlot* frame3 = mcstudy->plotPull(mean,Bins(40),FitGauss(kTRUE)) ;
00105
00106
00107 RooPlot* frame4 = mcstudy->plotNLL(Bins(40)) ;
00108
00109 regPlot(frame1,"rf801_plot1") ;
00110 regPlot(frame2,"rf801_plot2") ;
00111 regPlot(frame3,"rf801_plot3") ;
00112 regPlot(frame4,"rf801_plot4") ;
00113
00114 delete mcstudy ;
00115
00116 return kTRUE ;
00117 }
00118 } ;