Logo ROOT  
Reference Guide
No Matches
rf511_wsfactory_basic.C File Reference

Detailed Description

View in nbviewer Open in SWAN Organization and simultaneous fits: basic use of the 'object factory' associated with a workspace to rapidly build pdfs functions and their parameter components

␛[1mRooFit v3.60 -- Developed by Wouter Verkerke and David Kirkby␛[0m
Copyright (C) 2000-2013 NIKHEF, University of California & Stanford University
All rights reserved, please read http://roofit.sourceforge.net/license.txt
[#0] WARNING:Eval -- Evaluating RooAddPdf without a defined normalization set. This can lead to ambiguos coefficients definition and incorrect results. Use RooAddPdf::fixCoefNormalization(nset) to provide a normalization set for defining uniquely RooAddPdf coefficients!
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing dataset modelData
[#1] INFO:ObjectHandling -- RooWorkSpace::import(w) changing name of dataset from modelData to data
RooWorkspace(w) w contents
RooChebychev::bkg[ x=x coefList=(a0,a1) ] = 0.8
RooKeysPdf::k[ x=x ] = 0.0210129
RooAddPdf::model[ bkgfrac * bkg + [%] * sig ] = 0.4
RooAddPdf::sig[ sig1frac * sig1 + [%] * sig2 ] = 7.45331e-07
RooGaussian::sig1[ x=x mean=mean sigma=0.5 ] = 1.92875e-22
RooGaussian::sig2[ x=x mean=mean sigma=1 ] = 3.72665e-06
#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooGaussian.h"
#include "RooConstVar.h"
#include "RooChebychev.h"
#include "RooAddPdf.h"
#include "RooWorkspace.h"
#include "RooPlot.h"
#include "TCanvas.h"
#include "TAxis.h"
using namespace RooFit;
RooWorkspace *w = new RooWorkspace("w");
// C r e a t i n g a n d a d d i n g b a s i c p . d . f . s
// ----------------------------------------------------------------
// Remake example pdf of tutorial rs502_wspacewrite.C:
// Basic pdf construction: ClassName::ObjectName(constructor arguments)
// Variable construction : VarName[x,xlo,xhi], VarName[xlo,xhi], VarName[x]
// P.d.f. addition : SUM::ObjectName(coef1*pdf1,...coefM*pdfM,pdfN)
if (!compact) {
// Use object factory to build pdf of tutorial rs502_wspacewrite
} else {
// Use object factory to build pdf of tutorial rs502_wspacewrite but
// - Contracted to a single line recursive expression,
// - Omitting explicit names for components that are not referred to explicitly later
"SUM(sig1frac[0.8,0.,1.]*Gaussian(x,mean[5,0,10],0.5), Gaussian(x,mean,1)))");
// A d v a n c e d p . d . f . c o n s t r u c t o r a r g u m e n t s
// ----------------------------------------------------------------
// P.d.f. constructor arguments may by any type of RooAbsArg, but also
// Double_t --> converted to RooConst(...)
// {a,b,c} --> converted to RooArgSet() or RooArgList() depending on required ctor arg
// dataset name --> converted to RooAbsData reference for any dataset residing in the workspace
// enum --> Any enum label that belongs to an enum defined in the (base) class
// Make a dummy dataset pdf 'model' and import it in the workspace
RooDataSet *data = w->pdf("model")->generate(*w->var("x"), 1000);
w->import(*data, Rename("data"));
// Construct a KEYS pdf passing a dataset name and an enum type defining the
// mirroring strategy
// Print workspace contents
const Bool_t kFALSE
Definition RtypesCore.h:92
bool Bool_t
Definition RtypesCore.h:63
RooDataSet * generate(const RooArgSet &whatVars, Int_t nEvents, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none())
See RooAbsPdf::generate(const RooArgSet&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,...
Definition RooAbsPdf.h:58
RooDataSet is a container class to hold unbinned data.
Definition RooDataSet.h:33
The RooWorkspace is a persistable container for RooFit projects.
void Print(Option_t *opts=0) const
Print contents of the workspace.
RooRealVar * var(const char *name) const
Retrieve real-valued variable (RooRealVar) with given name. A null pointer is returned if not found.
Bool_t import(const RooAbsArg &arg, const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg())
Import a RooAbsArg object, e.g.
RooFactoryWSTool & factory()
Return instance to factory tool.
RooAbsPdf * pdf(const char *name) const
Retrieve p.d.f (RooAbsPdf) with given name. A null pointer is returned if not found.
RooCmdArg Rename(const char *suffix)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
July 2009
Wouter Verkerke

Definition in file rf511_wsfactory_basic.C.