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 "RooChi2Var.h"
00022 #include "RooMinuit.h"
00023 #include "TCanvas.h"
00024 #include "RooPlot.h"
00025 using namespace RooFit ;
00026
00027
00028 class TestBasic602 : public RooFitTestUnit
00029 {
00030 public:
00031 TestBasic602(TFile* refFile, Bool_t writeRef, Int_t verbose) : RooFitTestUnit("Chi2 minimization",refFile,writeRef,verbose) {} ;
00032 Bool_t testCode() {
00033
00034
00035
00036
00037
00038 RooRealVar x("x","x",0,10) ;
00039
00040
00041 RooRealVar mean("mean","mean of gaussians",5) ;
00042 RooRealVar sigma1("sigma1","width of gaussians",0.5) ;
00043 RooRealVar sigma2("sigma2","width of gaussians",1) ;
00044
00045 RooGaussian sig1("sig1","Signal component 1",x,mean,sigma1) ;
00046 RooGaussian sig2("sig2","Signal component 2",x,mean,sigma2) ;
00047
00048
00049 RooRealVar a0("a0","a0",0.5,0.,1.) ;
00050 RooRealVar a1("a1","a1",-0.2,0.,1.) ;
00051 RooChebychev bkg("bkg","Background",x,RooArgSet(a0,a1)) ;
00052
00053
00054 RooRealVar sig1frac("sig1frac","fraction of component 1 in signal",0.8,0.,1.) ;
00055 RooAddPdf sig("sig","Signal",RooArgList(sig1,sig2),sig1frac) ;
00056
00057
00058 RooRealVar bkgfrac("bkgfrac","fraction of background",0.5,0.,1.) ;
00059 RooAddPdf model("model","g1+g2+a",RooArgList(bkg,sig),bkgfrac) ;
00060
00061
00062
00063
00064
00065 RooDataSet* d = model.generate(x,10000) ;
00066 RooDataHist* dh = d->binnedClone() ;
00067
00068
00069
00070
00071
00072 RooChi2Var chi2("chi2","chi2",model,*dh) ;
00073
00074
00075 RooMinuit m(chi2) ;
00076 m.migrad() ;
00077 m.hesse() ;
00078
00079 RooFitResult* r = m.save() ;
00080
00081 regResult(r,"rf602_r") ;
00082
00083 delete d ;
00084 delete dh ;
00085
00086 return kTRUE ;
00087 }
00088 } ;