Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooGenericPdf.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * File: $Id: RooGenericPdf.h,v 1.20 2007/05/11 09:11:30 verkerke Exp $
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2000-2005, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16#ifndef ROO_GENERIC_PDF
17#define ROO_GENERIC_PDF
18
19#include "RooAbsPdf.h"
20#include "RooListProxy.h"
21#include "RooAbsBinning.h"
22
23#include <map>
24#include <memory>
25#include <string>
26
27class RooArgList ;
28class RooFormula ;
30
31class RooGenericPdf : public RooAbsPdf {
32public:
33 // Constructors, assignment etc
35 ~RooGenericPdf() override;
36 RooGenericPdf(const char *name, const char *title, const char* formula, const RooArgList& dependents);
37 RooGenericPdf(const char *name, const char *title, const RooArgList& dependents);
38 RooGenericPdf(const RooGenericPdf& other, const char* name=nullptr);
39 TObject* clone(const char* newname=nullptr) const override { return new RooGenericPdf(*this,newname); }
40
41 // I/O streaming interface (machine readable)
42 bool readFromStream(std::istream& is, bool compact, bool verbose=false) override ;
43 void writeToStream(std::ostream& os, bool compact) const override ;
44
45 /// Return pointer to parameter with given name.
46 inline RooAbsArg* getParameter(const char* name) const {
47 return _actualVars.find(name) ;
48 }
49 /// Return pointer to parameter at given index.
51 return _actualVars.at(index) ;
52 }
53 /// Return the number of parameters.
54 inline size_t nParameters() const {
55 return _actualVars.size();
56 }
57
58 // Printing interface (human readable)
59 void printMultiline(std::ostream& os, Int_t content, bool verbose=false, TString indent="") const override ;
60 void printMetaArgs(std::ostream& os) const override ;
61
62 // Debugging
63 void dumpFormula();
64
65 const char* expression() const { return _formExpr.Data(); }
66 const RooArgList& dependents() const { return _actualVars; }
67
68 std::string getUniqueFuncName() const;
69
70 void setBinning(const RooAbsRealLValue &obs, const RooAbsBinning &binning, bool checkFlatness = true);
71 bool removeBinning(const RooAbsRealLValue &obs);
72
73 bool isBinnedDistribution(const RooArgSet &obs) const override;
74 std::list<double> *binBoundaries(RooAbsRealLValue &obs, double xlo, double xhi) const override;
75 std::list<double> *plotSamplingHint(RooAbsRealLValue &obs, double xlo, double xhi) const override;
76
77protected:
78 RooFormula& formula() const ;
79
80 // Function evaluation
82 double evaluate() const override ;
83 void doEval(RooFit::EvalContext &) const override;
84
85 // Post-processing of server redirection
87
88 bool isValidReal(double /*value*/, bool /*printError*/) const override { return true; }
89
90 mutable RooFormula * _formula = nullptr; ///<! Formula engine
91 TString _formExpr ; ///< Formula expression string
92
93 std::map<int, std::unique_ptr<RooAbsBinning>> _binnings; ///< User-defined binnings, keyed by the observable's index
94 ///< in _actualVars, for a piecewise-flat distribution
95
96 ClassDefOverride(RooGenericPdf, 2) // Generic PDF defined by string expression and list of variables
97};
98
99#endif
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
static void indent(ostringstream &buf, int indent_level)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
char name[80]
Definition TGX11.cxx:145
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:76
Abstract base class for RooRealVar binning definitions.
Abstract container object that can hold multiple RooAbsArg objects.
Storage_t::size_type size() const
RooAbsArg * find(const char *name) const
Find object with given name in list.
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:32
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
Definition RooArgList.h:110
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
Implementation of a probability density function that takes a RooArgList of servers and a C++ express...
double evaluate() const override
Calculate current value of this object.
~RooGenericPdf() override
const char * expression() const
RooAbsArg * getParameter(Int_t index) const
Return pointer to parameter at given index.
bool readFromStream(std::istream &is, bool compact, bool verbose=false) override
Read object contents from given stream.
const RooArgList & dependents() const
TObject * clone(const char *newname=nullptr) const override
void printMetaArgs(std::ostream &os) const override
Add formula expression as meta argument in printing interface.
bool isBinnedDistribution(const RooArgSet &obs) const override
Return true if a binning was set with setBinning() for every observable in the integration set obs.
std::string getUniqueFuncName() const
RooListProxy _actualVars
bool isValidReal(double, bool) const override
Interface function to check if given value is a valid value for this object. Returns true unless over...
void writeToStream(std::ostream &os, bool compact) const override
Write object contents to given stream.
std::map< int, std::unique_ptr< RooAbsBinning > > _binnings
User-defined binnings, keyed by the observable's index in _actualVars, for a piecewise-flat distribut...
RooAbsArg * getParameter(const char *name) const
Return pointer to parameter with given name.
std::list< double > * plotSamplingHint(RooAbsRealLValue &obs, double xlo, double xhi) const override
Return sampling hints that draw the piecewise-flat shape exactly (a pair of points just left and righ...
std::list< double > * binBoundaries(RooAbsRealLValue &obs, double xlo, double xhi) const override
Return the boundaries of the binning set with setBinning() that fall within [xlo, xhi],...
RooFormula * _formula
! Formula engine
bool removeBinning(const RooAbsRealLValue &obs)
Remove a binning previously declared with setBinning() for observable obs, reverting to the generic n...
size_t nParameters() const
Return the number of parameters.
RooFormula & formula() const
TString _formExpr
Formula expression string.
void doEval(RooFit::EvalContext &) const override
Base function for computing multiple values of a RooAbsReal.
void printMultiline(std::ostream &os, Int_t content, bool verbose=false, TString indent="") const override
Print info about this object to the specified stream.
void setBinning(const RooAbsRealLValue &obs, const RooAbsBinning &binning, bool checkFlatness=true)
Declare that this pdf is piecewise constant (flat) within the bins of the given binning of the observ...
bool redirectServersHook(const RooAbsCollection &newServerList, bool mustReplaceAll, bool nameChange, bool isRecursive) override
Propagate server changes to embedded formula object.
Mother of all ROOT objects.
Definition TObject.h:42
Basic string class.
Definition TString.h:138
const char * Data() const
Definition TString.h:384