////////////////////////////////////////////////////////////////////////// // // 'SPECIAL PDFS' RooFit tutorial macro #705 // // Linear interpolation between p.d.f shapes using the 'Alex Read' algorithm // // // // 07/2008 - Wouter Verkerke // ///////////////////////////////////////////////////////////////////////// #ifndef __CINT__ #include "RooGlobalFunc.h" #endif #include "RooRealVar.h" #include "RooDataSet.h" #include "RooGaussian.h" #include "RooConstVar.h" #include "RooPolynomial.h" #include "RooIntegralMorph.h" #include "RooNLLVar.h" #include "TCanvas.h" #include "TAxis.h" #include "RooPlot.h" #include "TH1.h" using namespace RooFit ; void rf705_linearmorph() { // C r e a t e e n d p o i n t p d f s h a p e s // ------------------------------------------------------ // Observable Int_t range = 150000; RooRealVar x("x","x",-1*range,range) ; // Lower end point shape: a Gaussian //RooRealVar g1mean("g1mean","g1mean",-10) ; RooGaussian g1("g1","g1",x,RooConst(0),RooConst(100)) ; RooGaussian g2("g2","g2",x,RooConst(0),RooConst(10)) ; // C r e a t e i n t e r p o l a t i n g p d f // ----------------------------------------------- // Create interpolation variable RooRealVar alpha("alpha","alpha",0,1.0) ; // Specify sampling density on observable and interpolation variable x.setBins(range,"cache") ; alpha.setBins(50,"cache") ; // Construct interpolating pdf in (x,a) represent g1(x) at a=a_min // and g2(x) at a=a_max RooIntegralMorph lmorph("lmorph","lmorph",g1,g2,x,alpha) ; // P l o t i n t e r p o l a t i n g p d f a t v a r i o u s a l p h a // ----------------------------------------------------------------------------- // Show end points as blue curves RooPlot* frame1 = x.frame(-200,200) ; g1.plotOn(frame1) ; g2.plotOn(frame1) ; // Show interpolated shapes in red alpha.setVal(0.125) ; lmorph.plotOn(frame1,LineColor(kRed)) ; alpha.setVal(0.25) ; lmorph.plotOn(frame1,LineColor(kRed)) ; alpha.setVal(0.375) ; lmorph.plotOn(frame1,LineColor(kRed)) ; alpha.setVal(0.50) ; lmorph.plotOn(frame1,LineColor(kRed)) ; alpha.setVal(0.625) ; lmorph.plotOn(frame1,LineColor(kRed)) ; alpha.setVal(0.75) ; lmorph.plotOn(frame1,LineColor(kRed)) ; alpha.setVal(0.875) ; lmorph.plotOn(frame1,LineColor(kRed)) ; alpha.setVal(0.95) ; lmorph.plotOn(frame1,LineColor(kRed)) ; TCanvas* c = new TCanvas("rf705_linearmorph","rf705_linearmorph",800,800) ; c->cd() ; gPad->SetLeftMargin(0.15) ; frame1->GetYaxis()->SetTitleOffset(1.6) ; frame1->Draw() ; return ; }