Docs | All | Real | Category | PDF | DataSet | Plot | Container | Misc | Aux | User

RooFit Toolkit for Data Modeling

Adding more dimensions, multiplying PDFs

// Adding more dimensions, multiplying PDFs
intro3()
{
  // Build two Gaussian PDFs
  RooRealVar x("x","x",-5,5) ;
  RooRealVar y("y","y",-5,5) ;
  RooRealVar meanx("mean1","mean of gaussian x",2) ;
  RooRealVar meany("mean2","mean of gaussian y",-2) ;
  RooRealVar sigmax("sigmax","width of gaussian x",1) ;
  RooRealVar sigmay("sigmay","width of gaussian y",5) ;
  RooGaussian gaussx("gaussx","gaussian PDF",x,meanx,sigmax) ;  
  RooGaussian gaussy("gaussy","gaussian PDF",y,meany,sigmay) ;  

  // Multiply the components
  RooProdPdf  prod("gaussxy","gaussx*gaussy",RooArgList(gaussx,gaussy)) ;

  // Generate a toyMC sample
  RooDataSet *data = prod.generate(RooArgSet(x,y),10000) ;
  
  // Plot data and PDF overlaid
  TCanvas *c = new TCanvas("c","c",800, 600);
  c->Divide(2,1);
  
  c->cd(1) ;
  RooPlot* xframe = x.frame() ;
  data->plotOn(xframe) ;
  prod->plotOn(xframe) ; // plots f(x) = Int(dy) pdf(x,y)
  xframe->Draw() ;

  c->cd(2) ;
  RooPlot* yframe = y.frame() ;
  data->plotOn(yframe) ;
  prod->plotOn(yframe) ; // plots f(y) = Int(dx) pdf(x,y)
  yframe->Draw() ;
}



Last CVS Update: Top
Copyright © 2000-2005 University of California, Stanford University

Page maintained by Wouter Verkerke and David Kirkby

SourceForge.net Logo