Logo ROOT  
Reference Guide
ParamHistFunc.h
Go to the documentation of this file.
1 // @(#)root/roostats:$Id: cranmer $
2 // Author: George Lewis, Kyle Cranmer
3 /*************************************************************************
4  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
5  * All rights reserved. *
6  * *
7  * For the licensing terms see $ROOTSYS/LICENSE. *
8  * For the list of contributors see $ROOTSYS/README/CREDITS. *
9  *************************************************************************/
10 
11 
12 #ifndef ROO_PARAMHISTFUNC
13 #define ROO_PARAMHISTFUNC
14 
15 #include "RooAbsReal.h"
16 #include "RooListProxy.h"
17 #include "RooObjCacheManager.h"
18 #include "RooDataHist.h"
19 
20 // Forward Declarations
21 class RooRealVar;
22 class RooWorkspace;
23 
24 class ParamHistFunc : public RooAbsReal {
25 public:
26 
27  ParamHistFunc() ;
28  ParamHistFunc(const char *name, const char *title, const RooArgList& vars, const RooArgList& paramSet );
29  ParamHistFunc(const char *name, const char *title, const RooArgList& vars, const RooArgList& paramSet, const TH1* hist );
30  virtual ~ParamHistFunc() ;
31 
32  ParamHistFunc(const ParamHistFunc& other, const char* name = 0);
33  virtual TObject* clone(const char* newname) const override { return new ParamHistFunc(*this, newname); }
34 
35  const RooArgList& paramList() const { return _paramSet ; }
36 
37  Int_t numBins() const { return _dataSet.numEntries(); } // Number of bins (called numEntries in RooDataHist)
38 
40  void setConstant(bool constant);
41 
42  void setShape(TH1* shape);
43 
44  RooRealVar& getParameter() const ;
45  RooRealVar& getParameter( Int_t masterIdx ) const ;
46 
47  const RooArgSet* get(Int_t masterIdx) const { return _dataSet.get( masterIdx ) ; }
48  const RooArgSet* get(const RooArgSet& coord) const { return _dataSet.get( coord ) ; }
49 
50  double binVolume() const { return _dataSet.binVolume(); }
51 
52  virtual Bool_t forceAnalyticalInt(const RooAbsArg&) const override { return kTRUE ; }
53 
54  Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& analVars, const RooArgSet* normSet,const char* rangeName=0) const override;
55  Double_t analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=0) const override;
56 
57  static RooArgList createParamSet(RooWorkspace& w, const std::string&, const RooArgList& Vars);
58  static RooArgList createParamSet(RooWorkspace& w, const std::string&, const RooArgList& Vars, Double_t, Double_t);
59  static RooArgList createParamSet(const std::string&, Int_t, Double_t, Double_t);
60 
61  virtual std::list<Double_t>* binBoundaries(RooAbsRealLValue& /*obs*/, Double_t /*xlo*/, Double_t /*xhi*/) const override;
62  virtual std::list<Double_t>* plotSamplingHint(RooAbsRealLValue& obs, Double_t xlo, Double_t xhi) const override;
63  virtual Bool_t isBinnedDistribution(const RooArgSet& /*obs*/) const override { return true; }
64 
65 
66 protected:
67 
68  class CacheElem : public RooAbsCacheElement {
69  public:
70  CacheElem() {} ;
71  virtual ~CacheElem() {} ;
73  RooArgList ret(_funcIntList) ;
74  ret.add(_lowIntList);
75  ret.add(_highIntList);
76  return ret ;
77  }
81  // will want std::vector<RooRealVar*> for low and high also
82  } ;
83  mutable RooObjCacheManager _normIntMgr ; // The integration cache manager
84 
85  RooListProxy _dataVars; // The RooRealVars
86  RooListProxy _paramSet ; // interpolation parameters
87 
89  struct NumBins {
90  NumBins() {}
91  NumBins(int nx, int ny, int nz) : x{nx}, y{ny}, z{nz}, xy{x*y}, xz{x*z}, yz{y*z}, xyz{xy*z} {}
92  int x = 0;
93  int y = 0;
94  int z = 0;
95  int xy = 0;
96  int xz = 0;
97  int yz = 0;
98  int xyz = 0;
99  };
100  mutable NumBins _numBinsPerDim; //!
102 
103  Int_t getCurrentBin() const;
104  Int_t addVarSet( const RooArgList& vars );
105  Int_t addParamSet( const RooArgList& params );
106  static Int_t GetNumBins( const RooArgSet& vars );
107  double evaluate() const override;
108  RooSpan<double> evaluateSpan(RooBatchCompute::RunContext& evalData, const RooArgSet* normSet) const override;
109 
110 private:
111  static NumBins getNumBinsPerDim(RooArgSet const& vars);
112 
114 };
115 
116 #endif
ParamHistFunc::CacheElem::~CacheElem
virtual ~CacheElem()
Definition: ParamHistFunc.h:71
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
RooAbsReal.h
ParamHistFunc::NumBins::x
int x
Definition: ParamHistFunc.h:92
ParamHistFunc::getAnalyticalIntegralWN
Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *normSet, const char *rangeName=0) const override
Advertise that all integrals can be handled internally.
Definition: ParamHistFunc.cxx:630
ParamHistFunc::CacheElem::containedArgs
virtual RooArgList containedArgs(Action)
Definition: ParamHistFunc.h:72
ParamHistFunc::CacheElem
Definition: ParamHistFunc.h:68
ParamHistFunc::addVarSet
Int_t addVarSet(const RooArgList &vars)
return 0 for success return 1 for failure Check that the elements are actually RooRealVar's If so,...
Definition: ParamHistFunc.cxx:520
RooArgList
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:21
ParamHistFunc::ParamHistFunc
ParamHistFunc()
Definition: ParamHistFunc.cxx:61
ParamHistFunc::NumBins::yz
int yz
Definition: ParamHistFunc.h:97
ParamHistFunc::getParameter
RooRealVar & getParameter() const
Definition: ParamHistFunc.cxx:218
ParamHistFunc::get
const RooArgSet * get(Int_t masterIdx) const
Definition: ParamHistFunc.h:47
ParamHistFunc::NumBins::y
int y
Definition: ParamHistFunc.h:93
ParamHistFunc::forceAnalyticalInt
virtual Bool_t forceAnalyticalInt(const RooAbsArg &) const override
Definition: ParamHistFunc.h:52
RooAbsReal
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:61
ParamHistFunc::evaluateSpan
RooSpan< double > evaluateSpan(RooBatchCompute::RunContext &evalData, const RooArgSet *normSet) const override
Find all bins corresponding to the values of the observables in evalData, and evaluate the associated...
Definition: ParamHistFunc.cxx:590
ParamHistFunc::NumBins::xyz
int xyz
Definition: ParamHistFunc.h:98
ParamHistFunc::CacheElem::CacheElem
CacheElem()
Definition: ParamHistFunc.h:70
RooAbsCacheElement
RooAbsCacheElement is the abstract base class for objects to be stored in RooAbsCache cache manager o...
Definition: RooAbsCacheElement.h:26
ParamHistFunc::_paramSet
RooListProxy _paramSet
Definition: ParamHistFunc.h:86
ClassDefOverride
#define ClassDefOverride(name, id)
Definition: Rtypes.h:329
ParamHistFunc::_numBins
Int_t _numBins
Definition: ParamHistFunc.h:88
ParamHistFunc::NumBins::NumBins
NumBins(int nx, int ny, int nz)
Definition: ParamHistFunc.h:91
bool
ParamHistFunc::setConstant
void setConstant(bool constant)
Definition: ParamHistFunc.cxx:230
ParamHistFunc::get
const RooArgSet * get(const RooArgSet &coord) const
Definition: ParamHistFunc.h:48
ParamHistFunc::getCurrentBin
Int_t getCurrentBin() const
Get the index of the gamma parameter associated with the current bin.
Definition: ParamHistFunc.cxx:507
RooDataHist
The RooDataHist is a container class to hold N-dimensional binned data.
Definition: RooDataHist.h:37
ParamHistFunc::evaluate
double evaluate() const override
Find the bin corresponding to the current value of the observable, and evaluate the associated parame...
Definition: ParamHistFunc.cxx:579
RooDataHist::get
const RooArgSet * get() const override
Get bin centre of current bin.
Definition: RooDataHist.h:74
ParamHistFunc::_dataSet
RooDataHist _dataSet
Definition: ParamHistFunc.h:101
ParamHistFunc::binBoundaries
virtual std::list< Double_t > * binBoundaries(RooAbsRealLValue &, Double_t, Double_t) const override
Return sampling hint for making curves of (projections) of this function as the recursive division st...
Definition: ParamHistFunc.cxx:731
RooDataHist.h
ParamHistFunc::getNumBinsPerDim
static NumBins getNumBinsPerDim(RooArgSet const &vars)
Definition: ParamHistFunc.cxx:488
ParamHistFunc::NumBins::z
int z
Definition: ParamHistFunc.h:94
ParamHistFunc::~ParamHistFunc
virtual ~ParamHistFunc()
Definition: ParamHistFunc.cxx:187
RooAbsCollection::add
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
Definition: RooAbsCollection.cxx:455
ParamHistFunc::GetNumBins
static Int_t GetNumBins(const RooArgSet &vars)
Definition: ParamHistFunc.cxx:144
ParamHistFunc::analyticalIntegralWN
Double_t analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=0) const override
Implement analytical integrations by doing appropriate weighting from component integrals functions t...
Definition: ParamHistFunc.cxx:664
RooListProxy
RooListProxy is the concrete proxy for RooArgList objects.
Definition: RooListProxy.h:24
ParamHistFunc::CacheElem::_lowIntList
RooArgList _lowIntList
Definition: ParamHistFunc.h:79
RooDataHist::binVolume
double binVolume(std::size_t i) const
Return bin volume of i-th bin.
Definition: RooDataHist.h:108
RooObjCacheManager.h
ParamHistFunc::_normIntMgr
RooObjCacheManager _normIntMgr
Definition: ParamHistFunc.h:83
ParamHistFunc::_dataVars
RooListProxy _dataVars
Definition: ParamHistFunc.h:85
ParamHistFunc::numBins
Int_t numBins() const
Definition: ParamHistFunc.h:37
ParamHistFunc::setShape
void setShape(TH1 *shape)
Definition: ParamHistFunc.cxx:239
RooListProxy.h
RooWorkspace
The RooWorkspace is a persistable container for RooFit projects.
Definition: RooWorkspace.h:43
RooDataHist::numEntries
Int_t numEntries() const override
Return the number of bins.
Definition: RooDataHist.cxx:1799
Double_t
double Double_t
Definition: RtypesCore.h:59
ParamHistFunc::binVolume
double binVolume() const
Definition: ParamHistFunc.h:50
ParamHistFunc::paramList
const RooArgList & paramList() const
Definition: ParamHistFunc.h:35
ParamHistFunc::NumBins::xy
int xy
Definition: ParamHistFunc.h:95
RooObjCacheManager
Class RooObjCacheManager is an implementation of class RooCacheManager<RooAbsCacheElement> and specia...
Definition: RooObjCacheManager.h:30
RooAbsCacheElement::Action
Action
Definition: RooAbsCacheElement.h:39
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ParamHistFunc::NumBins::xz
int xz
Definition: ParamHistFunc.h:96
ParamHistFunc::NumBins
Definition: ParamHistFunc.h:89
ParamHistFunc::CacheElem::_highIntList
RooArgList _highIntList
Definition: ParamHistFunc.h:80
TH1
TH1 is the base class of all histogram classes in ROOT.
Definition: TH1.h:58
name
char name[80]
Definition: TGX11.cxx:110
ParamHistFunc::isBinnedDistribution
virtual Bool_t isBinnedDistribution(const RooArgSet &) const override
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
Definition: ParamHistFunc.h:63
ParamHistFunc
A class which maps the current values of a RooRealVar (or a set of RooRealVars) to one of a number of...
Definition: ParamHistFunc.h:24
ParamHistFunc::CacheElem::_funcIntList
RooArgList _funcIntList
Definition: ParamHistFunc.h:78
RooAbsArg
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:72
ParamHistFunc::clone
virtual TObject * clone(const char *newname) const override
Definition: ParamHistFunc.h:33
ParamHistFunc::_numBinsPerDim
NumBins _numBinsPerDim
Definition: ParamHistFunc.h:100
ParamHistFunc::NumBins::NumBins
NumBins()
Definition: ParamHistFunc.h:90
RooRealVar
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:39
RooAbsRealLValue
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
Definition: RooAbsRealLValue.h:31
ParamHistFunc::createParamSet
static RooArgList createParamSet(RooWorkspace &w, const std::string &, const RooArgList &Vars)
Create the list of RooRealVar parameters which represent the height of the histogram bins.
Definition: ParamHistFunc.cxx:278
RooBatchCompute::RunContext
This struct enables passing computation data around between elements of a computation graph.
Definition: RunContext.h:31
RooSpan
A simple container to hold a batch of data values.
Definition: RooSpan.h:34
ParamHistFunc::plotSamplingHint
virtual std::list< Double_t > * plotSamplingHint(RooAbsRealLValue &obs, Double_t xlo, Double_t xhi) const override
Return sampling hint for making curves of (projections) of this function as the recursive division st...
Definition: ParamHistFunc.cxx:696
RooArgSet
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:33
ParamHistFunc::addParamSet
Int_t addParamSet(const RooArgList &params)
Definition: ParamHistFunc.cxx:536
int
ParamHistFunc::setParamConst
void setParamConst(Int_t, Bool_t=kTRUE)
Definition: ParamHistFunc.cxx:224