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 "RooProdPdf.h"
00019 #include "RooAddPdf.h"
00020 #include "RooMinuit.h"
00021 #include "RooNLLVar.h"
00022 #include "RooFitResult.h"
00023 #include "RooPlot.h"
00024 #include "TCanvas.h"
00025 #include "TH1.h"
00026 using namespace RooFit ;
00027
00028
00029 class TestBasic601 : public RooFitTestUnit
00030 {
00031 public:
00032 TestBasic601(TFile* refFile, Bool_t writeRef, Int_t verbose) : RooFitTestUnit("Interactive Minuit",refFile,writeRef,verbose) {} ;
00033 Bool_t testCode() {
00034
00035
00036
00037
00038
00039 RooRealVar x("x","x",-20,20) ;
00040
00041
00042 RooRealVar mean("mean","mean of g1 and g2",0) ;
00043 RooRealVar sigma_g1("sigma_g1","width of g1",3) ;
00044 RooGaussian g1("g1","g1",x,mean,sigma_g1) ;
00045
00046 RooRealVar sigma_g2("sigma_g2","width of g2",4,3.0,6.0) ;
00047 RooGaussian g2("g2","g2",x,mean,sigma_g2) ;
00048
00049 RooRealVar frac("frac","frac",0.5,0.0,1.0) ;
00050 RooAddPdf model("model","model",RooArgList(g1,g2),frac) ;
00051
00052
00053 RooDataSet* data = model.generate(x,1000) ;
00054
00055
00056 RooNLLVar nll("nll","nll",model,*data) ;
00057
00058
00059
00060
00061
00062
00063 RooMinuit m(nll) ;
00064
00065
00066 m.migrad() ;
00067
00068
00069 m.hesse() ;
00070
00071
00072 m.minos(sigma_g2) ;
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 RooFitResult* r = m.save() ;
00084
00085
00086
00087
00088
00089
00090
00091 mean = 0.3 ;
00092
00093
00094 m.migrad() ;
00095 m.hesse() ;
00096
00097
00098 sigma_g2.setConstant(kTRUE) ;
00099
00100
00101 m.migrad() ;
00102 m.hesse() ;
00103
00104 RooFitResult* r2 = m.save() ;
00105
00106 regResult(r,"rf601_r") ;
00107 regResult(r2,"rf601_r2") ;
00108
00109 delete data ;
00110
00111 return kTRUE ;
00112 }
00113 } ;