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 "RooAddPdf.h"
00020 #include "RooChebychev.h"
00021 #include "RooFitResult.h"
00022 #include "TCanvas.h"
00023 #include "RooPlot.h"
00024 #include "TFile.h"
00025 #include "TStyle.h"
00026 #include "TH2.h"
00027
00028 using namespace RooFit ;
00029
00030
00031 class TestBasic607 : public RooFitTestUnit
00032 {
00033 public:
00034 TestBasic607(TFile* refFile, Bool_t writeRef, Int_t verbose) : RooFitTestUnit("Fit Result functionality",refFile,writeRef,verbose) {} ;
00035 Bool_t testCode() {
00036
00037
00038
00039
00040
00041 RooRealVar x("x","x",0,10) ;
00042
00043
00044 RooRealVar mean("mean","mean of gaussians",5,-10,10) ;
00045 RooRealVar sigma1("sigma1","width of gaussians",0.5,0.1,10) ;
00046 RooRealVar sigma2("sigma2","width of gaussians",1,0.1,10) ;
00047
00048 RooGaussian sig1("sig1","Signal component 1",x,mean,sigma1) ;
00049 RooGaussian sig2("sig2","Signal component 2",x,mean,sigma2) ;
00050
00051
00052 RooRealVar a0("a0","a0",0.5,0.,1.) ;
00053 RooRealVar a1("a1","a1",-0.2) ;
00054 RooChebychev bkg("bkg","Background",x,RooArgSet(a0,a1)) ;
00055
00056
00057 RooRealVar sig1frac("sig1frac","fraction of component 1 in signal",0.8,0.,1.) ;
00058 RooAddPdf sig("sig","Signal",RooArgList(sig1,sig2),sig1frac) ;
00059
00060
00061 RooRealVar bkgfrac("bkgfrac","fraction of background",0.5,0.,1.) ;
00062 RooAddPdf model("model","g1+g2+a",RooArgList(bkg,sig),bkgfrac) ;
00063
00064
00065 RooDataSet* data = model.generate(x,1000) ;
00066
00067
00068
00069
00070
00071
00072
00073 RooFitResult* r = model.fitTo(*data,Save()) ;
00074
00075
00076
00077
00078
00079
00080 gStyle->SetOptStat(0) ;
00081 gStyle->SetPalette(1) ;
00082 TH2* hcorr = r->correlationHist() ;
00083
00084
00085
00086
00087 RooDataSet randPars("randPars","randPars",r->floatParsFinal()) ;
00088 for (Int_t i=0 ; i<10000 ; i++) {
00089 randPars.add(r->randomizePars()) ;
00090 }
00091
00092
00093 TH1* hhrand = randPars.createHistogram("hhrand",sigma1,Binning(35,0.25,0.65),YVar(sig1frac,Binning(35,0.3,1.1))) ;
00094
00095 regTH(hcorr,"rf607_hcorr") ;
00096 regTH(hhrand,"rf607_hhand") ;
00097
00098 delete data ;
00099 delete r ;
00100
00101 return kTRUE ;
00102
00103 }
00104 } ;