00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef __CINT__
00014 #include "RooGlobalFunc.h"
00015 #endif
00016 #include "RooRealVar.h"
00017 #include "RooDataSet.h"
00018 #include "RooGaussian.h"
00019 #include "RooChebychev.h"
00020 #include "RooAddPdf.h"
00021 #include "RooExtendPdf.h"
00022 #include "TCanvas.h"
00023 #include "RooPlot.h"
00024 using namespace RooFit ;
00025
00026
00027 class TestBasic202 : public RooFitTestUnit
00028 {
00029 public:
00030 TestBasic202(TFile* refFile, Bool_t writeRef, Int_t verbose) : RooFitTestUnit("Extended ML fits to addition operator p.d.f.s",refFile,writeRef,verbose) {} ;
00031 Bool_t testCode() {
00032
00033
00034
00035
00036
00037 RooRealVar x("x","x",0,10) ;
00038
00039
00040 RooRealVar mean("mean","mean of gaussians",5) ;
00041 RooRealVar sigma1("sigma1","width of gaussians",0.5) ;
00042 RooRealVar sigma2("sigma2","width of gaussians",1) ;
00043
00044 RooGaussian sig1("sig1","Signal component 1",x,mean,sigma1) ;
00045 RooGaussian sig2("sig2","Signal component 2",x,mean,sigma2) ;
00046
00047
00048 RooRealVar a0("a0","a0",0.5,0.,1.) ;
00049 RooRealVar a1("a1","a1",-0.2,0.,1.) ;
00050 RooChebychev bkg("bkg","Background",x,RooArgSet(a0,a1)) ;
00051
00052
00053 RooRealVar sig1frac("sig1frac","fraction of component 1 in signal",0.8,0.,1.) ;
00054 RooAddPdf sig("sig","Signal",RooArgList(sig1,sig2),sig1frac) ;
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 RooRealVar nsig("nsig","number of signal events",500,0.,10000) ;
00066 RooRealVar nbkg("nbkg","number of background events",500,0,10000) ;
00067 RooAddPdf model("model","(g1+g2)+a",RooArgList(bkg,sig),RooArgList(nbkg,nsig)) ;
00068
00069
00070
00071
00072
00073
00074
00075
00076 RooDataSet *data = model.generate(x) ;
00077
00078
00079 model.fitTo(*data) ;
00080
00081
00082
00083 RooPlot* xframe = x.frame(Title("extended ML fit example")) ;
00084 data->plotOn(xframe) ;
00085 model.plotOn(xframe,Normalization(1.0,RooAbsReal::RelativeExpected)) ;
00086
00087
00088 model.plotOn(xframe,Components(bkg),LineStyle(kDashed),Normalization(1.0,RooAbsReal::RelativeExpected)) ;
00089
00090
00091 model.plotOn(xframe,Components(RooArgSet(bkg,sig2)),LineStyle(kDotted),Normalization(1.0,RooAbsReal::RelativeExpected)) ;
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 RooExtendPdf esig("esig","extended signal p.d.f",sig,nsig) ;
00103 RooExtendPdf ebkg("ebkg","extended background p.d.f",bkg,nbkg) ;
00104
00105
00106
00107
00108
00109
00110 RooAddPdf model2("model2","(g1+g2)+a",RooArgList(ebkg,esig)) ;
00111
00112
00113 regPlot(xframe,"rf202_plot1") ;
00114
00115 delete data ;
00116 return kTRUE ;
00117
00118 }
00119
00120 } ;