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

RooFit Toolkit for Data Modeling

Observables vs parameters

//  dependents vs parameters
intro9()
{
  // This example demonstrates RFCs dynamic concept of dependents vs parameters
  //
  // Definition:
  //   'dependent' = a variable of a function that is loaded from a dataset
  //   'parameter' = any variable that is not a dependent
  //
  // For probability density functions this distinction is non-trivial because,
  // by construction, they must be normalized over all dependent variables:
  //      
  //     Int(dDep) Pdf(Dep,Par) == 1    (Dep = set of dependent variables , 
  //                                     Par = set parameter variables)
  //
  // In RooFit, the dep/par status of each variable of a RooAbsPdf object is
  // explicitly dynamic: each variable can be a parameter or a dependent
  // at any time. This only depends on the context in which the PDF is used, i.e.
  // the status of each variables is only explicit when a PDF is associated
  // with a dataset, which determines the set of dependents. 
  //
  // A consequence of this dynamic concept is that a complete set
  // of values for all PDF variables does not yield a unique return value:
  // the dep/par status of each variables must be specified in addition.
  //
  // To achieve this dynamic property, the normalization of a PDF is decoupled 
  // from the calculation of its raw unnormalized value.
  // 

  // A simple gaussian PDF has 3 variables: x,mean,sigma
  RooRealVar x("x","x",-10,10) ;
  RooRealVar mean("mean","mean of gaussian",-1,-10,10) ;
  RooRealVar sigma("sigma","width of gaussian",3,1,20) ;
  RooGaussian gauss("gauss","gaussian PDF",x,mean,sigma) ;  

  // For getVal() without any arguments all variables are interpreted as parameters,
  // and no normalization is enforced
  x = 0 ;  
  Double_t rawVal = gauss.getVal() ; // = exp(-[(x-mean)/sigma]^2)
  cout << "gauss(x=0,mean=-1,width=3)_raw = " << rawVal << endl ;

  // If we supply getVal() with the subset of its variables that should be interpreted as dependents, 
  // it will apply the correct normalization for that set of dependents
  Double_t xnormVal = gauss.getVal(x) ; // NB: RooAbsArg& implicitly converts to RooArgSet(RooAbsArg&) 
  cout << "gauss(x=0,mean=-1,width=3)_normalized_x[-10,10] = " << xnormVal << endl ;

  //*** gauss.getVal(x) = gauss.getVal() / Int(-10,10) gauss() dx

  // If we adjust the limits on x, the normalization will change accordingly
  x.setFitRange(-1,1) ;
  Double_t xnorm2Val = gauss.getVal(x) ;
  cout << "gauss(x=0,mean=-1,width=3)_normalized_x[-1,1] = " << xnorm2Val << endl ;

  //*** gauss.getVal(x) = gauss.getVal() / Int(-1,1) gauss() dx

  // We can also add sigma as dependent
  Double_t xsnormVal = gauss.getVal(RooArgSet(x,sigma)) ;
  cout << "gauss(x=0,mean=-1,width=3)_normalized_x[-1,1]_width[1,20] = " << xsnormVal << endl ;

  //*** gauss.getVal(RooArgSet(x,sigma)) = gauss.getVal() / Int(-1,1)(1,20) gauss() dx dsigma

  // (!) The set of arguments passed in RooAbsPdf::getVal() determines _only_ which
  //     the variables are interpreted as dependents/parameters. No values are passed,
  //     these are _always_ taken from the arguments supplied in the constructor
  //
  //     Objects passed in RooAbsPdf::getVal() that are not variables of the PDF are
  //     silently ignored
}

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

Page maintained by Wouter Verkerke and David Kirkby

SourceForge.net Logo