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 "RooFormulaVar.h"
00020 #include "RooProdPdf.h"
00021 #include "RooEfficiency.h"
00022 #include "RooPolynomial.h"
00023 #include "RooCategory.h"
00024 #include "TCanvas.h"
00025 #include "RooPlot.h"
00026 using namespace RooFit ;
00027
00028
00029
00030 class TestBasic701 : public RooFitTestUnit
00031 {
00032 public:
00033 TestBasic701(TFile* refFile, Bool_t writeRef, Int_t verbose) : RooFitTestUnit("Efficiency operator p.d.f. 1D",refFile,writeRef,verbose) {} ;
00034 Bool_t testCode() {
00035
00036
00037
00038
00039
00040 RooRealVar x("x","x",-10,10) ;
00041
00042
00043 RooRealVar a("a","a",0.4,0,1) ;
00044 RooRealVar b("b","b",5) ;
00045 RooRealVar c("c","c",-1,-10,10) ;
00046 RooFormulaVar effFunc("effFunc","(1-a)+a*cos((x-c)/b)",RooArgList(a,b,c,x)) ;
00047
00048
00049
00050
00051
00052
00053
00054 RooCategory cut("cut","cutr") ;
00055 cut.defineType("accept",1) ;
00056 cut.defineType("reject",0) ;
00057
00058
00059 RooEfficiency effPdf("effPdf","effPdf",effFunc,cut,"accept") ;
00060
00061
00062
00063
00064
00065
00066
00067
00068 RooPolynomial shapePdf("shapePdf","shapePdf",x,RooConst(-0.095)) ;
00069 RooProdPdf model("model","model",shapePdf,Conditional(effPdf,cut)) ;
00070
00071
00072 RooDataSet* data = model.generate(RooArgSet(x,cut),10000) ;
00073
00074
00075
00076
00077
00078
00079
00080 effPdf.fitTo(*data,ConditionalObservables(x)) ;
00081
00082
00083
00084
00085
00086
00087
00088 RooPlot* frame1 = x.frame(Bins(20),Title("Data (all, accepted)")) ;
00089 data->plotOn(frame1) ;
00090 data->plotOn(frame1,Cut("cut==cut::accept"),MarkerColor(kRed),LineColor(kRed)) ;
00091
00092
00093 RooPlot* frame2 = x.frame(Bins(20),Title("Fitted efficiency")) ;
00094 data->plotOn(frame2,Efficiency(cut)) ;
00095 effFunc.plotOn(frame2,LineColor(kRed)) ;
00096
00097
00098 regPlot(frame1,"rf701_plot1") ;
00099 regPlot(frame2,"rf701_plot2") ;
00100
00101
00102 delete data ;
00103
00104 return kTRUE ;
00105 }
00106 } ;