00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef __CINT__
00016 #include "RooGlobalFunc.h"
00017 #endif
00018 #include "RooRealVar.h"
00019 #include "RooDataHist.h"
00020 #include "RooGaussian.h"
00021 #include "RooGenericPdf.h"
00022 #include "RooFormulaVar.h"
00023 #include "RooFFTConvPdf.h"
00024 #include "RooPlot.h"
00025 #include "TCanvas.h"
00026 #include "TAxis.h"
00027 #include "TH2.h"
00028 using namespace RooFit ;
00029
00030
00031 void rf211_paramconv()
00032 {
00033
00034
00035
00036
00037 RooRealVar x("x","x",-10,10) ;
00038 RooRealVar mean("mean","mean",-3,3) ;
00039 RooRealVar sigma("sigma","sigma",0.5,0.1,10) ;
00040 RooGaussian modelx("gx","gx",x,mean,sigma) ;
00041
00042
00043 RooRealVar a("a","a",2,1,10) ;
00044 RooGenericPdf model_mean("model_mean","abs(mean)<a",RooArgList(mean,a)) ;
00045
00046
00047 x.setBins(1000,"cache") ;
00048 mean.setBins(50,"cache") ;
00049 RooFFTConvPdf model("model","model",mean,modelx,model_mean) ;
00050
00051
00052
00053
00054 model.setCacheObservables(x) ;
00055 model.setBufferFraction(1.0) ;
00056
00057
00058 RooAbsPdf* projModel = model.createProjection(mean) ;
00059
00060
00061 RooDataHist* d = projModel->generateBinned(x,1000) ;
00062
00063
00064 projModel->fitTo(*d,Verbose()) ;
00065
00066
00067 RooPlot* frame = x.frame(Bins(25)) ;
00068 d->plotOn(frame) ;
00069 projModel->plotOn(frame) ;
00070
00071
00072 TH1* hh = model.createHistogram("hh",x,Binning(50),YVar(mean,Binning(50)),ConditionalObservables(mean)) ;
00073 hh->SetTitle("histogram of model(x|mean)") ;
00074 hh->SetLineColor(kBlue) ;
00075
00076
00077 TCanvas* c = new TCanvas("rf211_paramconv","rf211_paramconv",800,400) ;
00078 c->Divide(2) ;
00079 c->cd(1) ; gPad->SetLeftMargin(0.15) ; frame->GetYaxis()->SetTitleOffset(1.4) ; frame->Draw() ;
00080 c->cd(2) ; gPad->SetLeftMargin(0.20) ; hh->GetZaxis()->SetTitleOffset(2.5) ; hh->Draw("surf") ;
00081
00082 }