00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef __CINT__
00013 #include "RooGlobalFunc.h"
00014 #else
00015
00016
00017 class Roo2DKeysPdf;
00018 #endif
00019 #include "RooRealVar.h"
00020 #include "RooDataSet.h"
00021 #include "RooGaussian.h"
00022 #include "TCanvas.h"
00023 #include "TAxis.h"
00024 #include "RooPlot.h"
00025 #include "TMath.h"
00026 #include "TF1.h"
00027 #include "Math/DistFunc.h"
00028 #ifndef __CINT__
00029 #include "RooCFunction1Binding.h"
00030 #include "RooCFunction3Binding.h"
00031 #endif
00032 #include "RooTFnBinding.h"
00033
00034 using namespace RooFit;
00035
00036
00037 void rf105_funcbinding()
00038 {
00039
00040
00041
00042
00043
00044 RooRealVar x("x","x",-3,3) ;
00045 RooAbsReal* erf = bindFunction("erf",TMath::Erf,x) ;
00046
00047
00048 erf->Print() ;
00049
00050
00051 RooPlot* frame1 = x.frame(Title("TMath::Erf bound as RooFit function")) ;
00052 erf->plotOn(frame1) ;
00053
00054
00055
00056
00057
00058
00059 RooRealVar x2("x2","x2",0,0.999) ;
00060 RooRealVar a("a","a",5,0,10) ;
00061 RooRealVar b("b","b",2,0,10) ;
00062 RooAbsPdf* beta = bindPdf("beta",ROOT::Math::beta_pdf,x2,a,b) ;
00063
00064
00065 beta->Print() ;
00066
00067
00068 RooDataSet* data = beta->generate(x2,10000) ;
00069 beta->fitTo(*data) ;
00070
00071
00072 RooPlot* frame2 = x2.frame(Title("ROOT::Math::Beta bound as RooFit pdf")) ;
00073 data->plotOn(frame2) ;
00074 beta->plotOn(frame2) ;
00075
00076
00077
00078
00079
00080
00081
00082 TF1 *fa1 = new TF1("fa1","sin(x)/x",0,10);
00083
00084
00085 RooRealVar x3("x3","x3",0.01,20) ;
00086
00087
00088 RooAbsReal* rfa1 = bindFunction(fa1,x3) ;
00089
00090
00091 rfa1->Print() ;
00092
00093
00094 RooPlot* frame3 = x3.frame(Title("TF1 bound as RooFit function")) ;
00095 rfa1->plotOn(frame3) ;
00096
00097
00098
00099 TCanvas* c = new TCanvas("rf105_funcbinding","rf105_funcbinding",1200,400) ;
00100 c->Divide(3) ;
00101 c->cd(1) ; gPad->SetLeftMargin(0.15) ; frame1->GetYaxis()->SetTitleOffset(1.6) ; frame1->Draw() ;
00102 c->cd(2) ; gPad->SetLeftMargin(0.15) ; frame2->GetYaxis()->SetTitleOffset(1.6) ; frame2->Draw() ;
00103 c->cd(3) ; gPad->SetLeftMargin(0.15) ; frame3->GetYaxis()->SetTitleOffset(1.6) ; frame3->Draw() ;
00104
00105 }