Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooHistFunc.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * File: $Id$
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_HIST_FUNC
17#define ROO_HIST_FUNC
18
19#include "RooAbsReal.h"
20#include "RooRealProxy.h"
21#include "RooSetProxy.h"
22#include "RooAICRegistry.h"
23#include "RooTrace.h"
24#include "RooDataHist.h"
25
26#include <list>
27
28class RooRealVar;
29class RooAbsReal;
30
31class RooHistFunc : public RooAbsReal {
32public:
34 RooHistFunc(const char *name, const char *title, const RooArgSet& vars, const RooDataHist& dhist, Int_t intOrder=0);
35 RooHistFunc(const char *name, const char *title, const RooArgList& funcObs, const RooArgList& histObs, const RooDataHist& dhist, Int_t intOrder=0);
36 RooHistFunc(const char *name, const char *title, const RooArgSet& vars,
37 std::unique_ptr<RooDataHist> dhist, int intOrder=0);
38 RooHistFunc(const char *name, const char *title, const RooArgList& pdfObs, const RooArgList& histObs,
39 std::unique_ptr<RooDataHist> dhist, int intOrder=0);
40 RooHistFunc(const RooHistFunc& other, const char* name=nullptr);
41 TObject* clone(const char* newname) const override { return new RooHistFunc(*this,newname); }
42 ~RooHistFunc() override ;
43
44 /// Return RooDataHist that is represented.
46 return *_dataHist ;
47 }
48
49 /// Return RooDataHist that is represented.
50 const RooDataHist& dataHist() const {
51 return *_dataHist ;
52 }
53
54 /// Replaces underlying RooDataHist with a clone, which is now owned, and returns the clone.
55 /// If the underlying RooDataHist is already owned, then that is returned instead of being cloned.
56 RooDataHist* cloneAndOwnDataHist(const char* newname="");
57
58 /// Get total bin volume spanned by this hist function.
59 /// In 1-d, this is e.g. the range spanned on the x-axis.
60 double totVolume() const;
61
62 /// Set histogram interpolation order.
64
65 _intOrder = order ;
66 }
67
68 /// Return histogram interpolation order.
70
71 return _intOrder ;
72 }
73
74 Int_t getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* rangeName=nullptr) const override ;
75 double analyticalIntegral(Int_t code, const char* rangeName=nullptr) const override ;
76
77 bool forceAnalyticalInt(const RooAbsArg& dep) const override;
78
79 /// Set use of special boundary conditions for c.d.f.s
80 void setCdfBoundaries(bool flag) {
81 _cdfBoundaries = flag ;
82 }
83
84 /// If true, special boundary conditions for c.d.f.s are used
85 bool getCdfBoundaries() const {
86
87 return _cdfBoundaries ;
88 }
89
90 Int_t getMaxVal(const RooArgSet& vars) const override;
91 double maxVal(Int_t code) const override;
92
93 std::list<double>* binBoundaries(RooAbsRealLValue& /*obs*/, double /*xlo*/, double /*xhi*/) const override ;
94 std::list<double>* plotSamplingHint(RooAbsRealLValue& obs, double xlo, double xhi) const override ;
95 bool isBinnedDistribution(const RooArgSet&) const override { return _intOrder==0 ; }
96 RooArgSet const& getHistObsList() const { return _histObsList; }
97
98
99 Int_t getBin() const;
100 std::vector<Int_t> getBins(RooFit::Detail::DataMap const& dataMap) const;
101
102 void translate(RooFit::Detail::CodeSquashContext &ctx) const override;
103 std::string
104 buildCallToAnalyticIntegral(int code, const char *rangeName, RooFit::Detail::CodeSquashContext &ctx) const override;
105protected:
106
107 bool importWorkspaceHook(RooWorkspace& ws) override ;
108 bool areIdentical(const RooDataHist& dh1, const RooDataHist& dh2) ;
109
110 double evaluate() const override;
111 void computeBatch(double* output, size_t size, RooFit::Detail::DataMap const&) const override;
112 friend class RooAbsCachedReal ;
113
114 void ioStreamerPass2() override ;
115
116 RooArgSet _histObsList; ///< List of observables defining dimensions of histogram
117 RooSetProxy _depList; ///< List of observables mapped onto histogram observables
118 RooDataHist* _dataHist = nullptr; ///< Unowned pointer to underlying histogram
119 std::unique_ptr<RooDataHist> _ownedDataHist; ///<! Owned pointer to underlying histogram
120 mutable RooAICRegistry _codeReg; ///<! Auxiliary class keeping tracking of analytical integration code
121 Int_t _intOrder = 0; ///< Interpolation order
122 bool _cdfBoundaries = false; ///< Use boundary conditions for CDFs.
123 mutable double _totVolume = 0.0; ///<! Total volume of space (product of ranges of observables)
124 bool _unitNorm = false; ///<! Assume contents is unit normalized (for use as pdf cache)
125
126 ClassDefOverride(RooHistFunc,2) // Histogram based function
127};
128
129#endif
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
char name[80]
Definition TGX11.cxx:110
RooAICRegistry is a utility class for operator p.d.f classes that keeps track of analytical integrati...
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:79
Abstract base class for functions that need or want to cache their evaluate() output in a RooHistFunc...
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
The RooDataHist is a container class to hold N-dimensional binned data.
Definition RooDataHist.h:39
A class to maintain the context for squashing of RooFit models into code.
RooHistFunc implements a real-valued function sampled from a multidimensional histogram.
Definition RooHistFunc.h:31
Int_t getInterpolationOrder() const
Return histogram interpolation order.
Definition RooHistFunc.h:69
bool _cdfBoundaries
Use boundary conditions for CDFs.
RooDataHist * _dataHist
Unowned pointer to underlying histogram.
double _totVolume
! Total volume of space (product of ranges of observables)
void setCdfBoundaries(bool flag)
Set use of special boundary conditions for c.d.f.s.
Definition RooHistFunc.h:80
void setInterpolationOrder(Int_t order)
Set histogram interpolation order.
Definition RooHistFunc.h:63
std::vector< Int_t > getBins(RooFit::Detail::DataMap const &dataMap) const
Compute bin numbers corresponding to all coordinates in evalData.
bool forceAnalyticalInt(const RooAbsArg &dep) const override
double analyticalIntegral(Int_t code, const char *rangeName=nullptr) const override
Return integral identified by 'code'.
~RooHistFunc() override
RooAICRegistry _codeReg
! Auxiliary class keeping tracking of analytical integration code
bool _unitNorm
! Assume contents is unit normalized (for use as pdf cache)
std::list< double > * binBoundaries(RooAbsRealLValue &, double, double) const override
Return sampling hint for making curves of (projections) of this function as the recursive division st...
std::unique_ptr< RooDataHist > _ownedDataHist
! Owned pointer to underlying histogram
void ioStreamerPass2() override
Schema evolution: if histObsList wasn't filled from persistence (v1) then fill it here.
double evaluate() const override
Return the current value: The value of the bin enclosing the current coordinates of the dependents,...
std::list< double > * plotSamplingHint(RooAbsRealLValue &obs, double xlo, double xhi) const override
Return sampling hint for making curves of (projections) of this function as the recursive division st...
bool getCdfBoundaries() const
If true, special boundary conditions for c.d.f.s are used.
Definition RooHistFunc.h:85
Int_t getMaxVal(const RooArgSet &vars) const override
Only handle case of maximum in all variables.
double totVolume() const
Get total bin volume spanned by this hist function.
Int_t getBin() const
Compute bin number corresponding to current coordinates.
bool areIdentical(const RooDataHist &dh1, const RooDataHist &dh2)
std::string buildCallToAnalyticIntegral(int code, const char *rangeName, RooFit::Detail::CodeSquashContext &ctx) const override
This function defines the analytical integral translation for the class.
double maxVal(Int_t code) const override
Return maximum value for set of observables identified by code assigned in getMaxVal.
void translate(RooFit::Detail::CodeSquashContext &ctx) const override
This function defines a translation for each RooAbsReal based object that can be used to express the ...
const RooDataHist & dataHist() const
Return RooDataHist that is represented.
Definition RooHistFunc.h:50
bool importWorkspaceHook(RooWorkspace &ws) override
Check if our datahist is already in the workspace.
RooArgSet const & getHistObsList() const
Definition RooHistFunc.h:96
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=nullptr) const override
Determine integration scenario.
RooDataHist * cloneAndOwnDataHist(const char *newname="")
Replaces underlying RooDataHist with a clone, which is now owned, and returns the clone.
bool isBinnedDistribution(const RooArgSet &) const override
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
Definition RooHistFunc.h:95
RooDataHist & dataHist()
Return RooDataHist that is represented.
Definition RooHistFunc.h:45
Int_t _intOrder
Interpolation order.
void computeBatch(double *output, size_t size, RooFit::Detail::DataMap const &) const override
Base function for computing multiple values of a RooAbsReal.
RooSetProxy _depList
List of observables mapped onto histogram observables.
RooArgSet _histObsList
List of observables defining dimensions of histogram.
TObject * clone(const char *newname) const override
Definition RooHistFunc.h:41
RooRealVar represents a variable that can be changed from the outside.
Definition RooRealVar.h:37
Persistable container for RooFit projects.
Mother of all ROOT objects.
Definition TObject.h:41
static void output()