00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include <fstream>
00014 #include "TString.h"
00015 #include "TROOT.h"
00016 #include "RooGlobalFunc.h"
00017 #include "RooWorkspace.h"
00018 #include "RooRealVar.h"
00019 #include "RooAbsPdf.h"
00020 #include "RooDataSet.h"
00021 #include "RooPlot.h"
00022 #include "RooStats/HLFactory.h"
00023
00024
00025
00026 using namespace RooFit ;
00027 using namespace RooStats ;
00028 using namespace std;
00029
00030 void rs601_HLFactoryexample() {
00031
00032
00033
00034 TString card_name("HLFavtoryexample.rs");
00035 ofstream ofile(card_name);
00036 ofile << "// The simplest card\n\n"
00037 << "gauss = Gaussian(mes[5.20,5.30],mean[5.28,5.2,5.3],width[0.0027,0.001,1]);\n"
00038 << "argus = ArgusBG(mes,5.291,argpar[-20,-100,-1]);\n"
00039 << "sum = SUM(nsig[200,0,10000]*gauss,nbkg[800,0,10000]*argus);\n\n";
00040
00041 ofile.close();
00042
00043 HLFactory hlf("HLFavtoryexample",
00044 card_name,
00045 false);
00046
00047
00048
00049 RooWorkspace* w = hlf.GetWs();
00050
00051 RooRealVar* mes = dynamic_cast<RooRealVar*>(w->arg("mes"));
00052 RooAbsPdf* sum = dynamic_cast<RooAbsPdf*>(w->pdf("sum"));
00053 RooAbsPdf* argus = dynamic_cast<RooAbsPdf*>(w->pdf("argus"));
00054
00055
00056
00057
00058 RooDataSet *data = sum->generate(*mes,2000) ;
00059
00060
00061 sum->fitTo(*data) ;
00062
00063
00064 RooPlot* mesframe = mes->frame() ;
00065 data->plotOn(mesframe) ;
00066 sum->plotOn(mesframe) ;
00067 sum->plotOn(mesframe,Components(*argus),LineStyle(kDashed)) ;
00068
00069 gROOT->SetStyle("Plain");
00070 mesframe->Draw() ;
00071 }