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

RooFit Toolkit for Data Modeling

Elementary operations on a gaussian PDF

// Elementary operations on a gaussian PDF
intro1()
{
  // Build Gaussian PDF
  RooRealVar x("x","x",-10,10) ;
  RooRealVar mean("mean","mean of gaussian",-1) ;
  RooRealVar sigma("sigma","width of gaussian",3) ;
  RooGaussian gauss("gauss","gaussian PDF",x,mean,sigma) ;  
  
  
  // Generate a toy MC set
  RooDataSet* data = gauss.generate(x,10000) ;  
  
  // Fit pdf to toy
  mean.setConstant(kFALSE) ;
  sigma.setConstant(kFALSE) ;

  gauss.fitTo(*data,Range(-5,5)) ;
  
  // Plot PDF and toy data overlaid
  RooPlot* xframe2 = x.frame() ;
  data->plotOn(xframe2) ;
  gauss.plotOn(xframe2) ;
  xframe2->Draw() ;


  // Print final value of parameters
  mean.Print() ;
  sigma.Print() ;
}
Last CVS Update: Top
Copyright © 2000-2005 University of California, Stanford University

Page maintained by Wouter Verkerke and David Kirkby

SourceForge.net Logo