Logo ROOT  
Reference Guide
RooDataHist.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * File: $Id: RooDataHist.h,v 1.37 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_DATA_HIST
17#define ROO_DATA_HIST
18
19#include "RooAbsData.h"
20#include "RooDirItem.h"
21#include "RooArgSet.h"
22
23#include "ROOT/RStringView.hxx"
24#include "Rtypes.h"
25
26#include <map>
27#include <vector>
28#include <string>
29#include <functional>
30#include <memory>
31#include <unordered_map>
32
33class TAxis ;
34class TObject ;
35class RooAbsArg;
36class RooCategory ;
37class RooPlot;
38class RooAbsLValue ;
39namespace RooFit {
40namespace TestStatistics {
41class RooAbsL;
42}
43}
44
45class RooDataHist : public RooAbsData, public RooDirItem {
46public:
47
48 // Constructors, factory methods etc.
49 RooDataHist() ;
50 RooDataHist(RooStringView name, RooStringView title, const RooArgSet& vars, const char* binningName=nullptr) ;
51 RooDataHist(RooStringView name, RooStringView title, const RooArgSet& vars, const RooAbsData& data, double initWgt=1.0) ;
52 RooDataHist(RooStringView name, RooStringView title, const RooArgList& vars, const TH1* hist, double initWgt=1.0) ;
53 RooDataHist(RooStringView name, RooStringView title, const RooArgList& vars, RooCategory& indexCat, std::map<std::string,TH1*> histMap, double initWgt=1.0) ;
54 RooDataHist(RooStringView name, RooStringView title, const RooArgList& vars, RooCategory& indexCat, std::map<std::string,RooDataHist*> dhistMap, double wgt=1.0) ;
55 //RooDataHist(const char *name, const char *title, const RooArgList& vars, double initWgt=1.0) ;
56 RooDataHist(RooStringView name, RooStringView title, const RooArgList& vars, const RooCmdArg& arg1, const RooCmdArg& arg2=RooCmdArg(), const RooCmdArg& arg3=RooCmdArg(),
57 const RooCmdArg& arg4=RooCmdArg(),const RooCmdArg& arg5=RooCmdArg(),const RooCmdArg& arg6=RooCmdArg(),const RooCmdArg& arg7=RooCmdArg(),const RooCmdArg& arg8=RooCmdArg()) ;
59
60 RooDataHist(const RooDataHist& other, const char* newname = nullptr) ;
61 TObject* Clone(const char* newname="") const override {
62 return new RooDataHist(*this, newname && newname[0] != '\0' ? newname : GetName());
63 }
64 ~RooDataHist() override ;
65
66 /// Return empty clone of this RooDataHist.
67 RooAbsData* emptyClone(const char* newName=nullptr, const char* newTitle=nullptr, const RooArgSet*vars=nullptr, const char* /*wgtVarName*/=nullptr) const override {
68 return new RooDataHist(newName?newName:GetName(),newTitle?newTitle:GetTitle(),vars?*vars:*get()) ;
69 }
70
71 /// Add `wgt` to the bin content enclosed by the coordinates passed in `row`.
72 virtual void add(const RooArgSet& row, double wgt=1.0) { add(row,wgt,-1.); }
73 void add(const RooArgSet& row, double weight, double sumw2) override ;
74 void set(std::size_t binNumber, double weight, double wgtErr);
75 void set(const RooArgSet& row, double weight, double wgtErr=-1.) ;
76 void set(const RooArgSet& row, double weight, double wgtErrLo, double wgtErrHi) ;
77
78 void add(const RooAbsData& dset, const RooFormulaVar* cutVar=nullptr, double weight=1.0 ) ;
79 void add(const RooAbsData& dset, const char* cut, double weight=1.0 ) ;
80
81 /// Get bin centre of current bin.
82 const RooArgSet* get() const override { return &_vars; }
83 const RooArgSet* get(Int_t binNumber) const override;
84 virtual const RooArgSet* get(const RooArgSet& coord) const;
85 Int_t numEntries() const override;
86 double sumEntries() const override;
87 double sumEntries(const char* cutSpec, const char* cutRange=nullptr) const override;
88
89 /// Always returns true as all histograms use event weights.
90 bool isWeighted() const override { return true; }
91 bool isNonPoissonWeighted() const override ;
92
93 RooSpan<const double> getWeightBatch(std::size_t first, std::size_t len, bool sumW2=false) const override;
94
95 /// Retrieve all bin volumes. Bins are indexed according to getIndex().
96 RooSpan<const double> binVolumes(std::size_t first, std::size_t len) const {
97 return {_binv + first, len};
98 }
99
100 double sum(bool correctForBinSize, bool inverseCorr=false) const ;
101 double sum(const RooArgSet& sumSet, const RooArgSet& sliceSet, bool correctForBinSize, bool inverseCorr=false) ;
102 double sum(const RooArgSet& sumSet,
103 const RooArgSet& sliceSet,
104 bool correctForBinSize,
105 bool inverseCorr,
106 const std::map<const RooAbsArg*, std::pair<double, double> >& ranges,
107 std::function<double(int)> getBinScale = [](int){ return 1.0; } );
108
109 void weights(double* output, RooSpan<double const> xVals, int intOrder, bool correctForBinSize, bool cdfBoundaries);
110 /// Return weight of i-th bin. \see getIndex()
111 double weight(std::size_t i) const { return _wgt[i]; }
112 double weightFast(const RooArgSet& bin, int intOrder, bool correctForBinSize, bool cdfBoundaries);
113 double weight(const RooArgSet& bin, Int_t intOrder=1, bool correctForBinSize=false, bool cdfBoundaries=false, bool oneSafe=false);
114 /// Return squared weight sum of i-th bin. \see getIndex()
115 double weightSquared(std::size_t i) const { return get_sumw2(i); }
116 /// Return bin volume of i-th bin. \see getIndex()
117 double binVolume(std::size_t i) const { return _binv[i]; }
118 double binVolume(const RooArgSet& bin) const;
119
120 TIterator* sliceIterator(RooAbsArg& sliceArg, const RooArgSet& otherArgs) ;
121
122 void weightError(double& lo, double& hi, ErrorType etype=Poisson) const override;
123 /// \copydoc RooAbsData::weightError(RooAbsData::ErrorType) const
124 double weightError(ErrorType etype=Poisson) const override {
125 // Return symmetric error on current bin calculated either from Poisson statistics or from SumOfWeights
126 double lo,hi ;
127 weightError(lo,hi,etype) ;
128 return (lo+hi)/2 ;
129 }
130
131 using RooAbsData::plotOn ;
132 RooPlot *plotOn(RooPlot *frame, PlotOpt o) const override;
133
134 void reset() override;
135
136 void printMultiline(std::ostream& os, Int_t content, bool verbose=false, TString indent="") const override;
137 void printArgs(std::ostream& os) const override;
138 void printValue(std::ostream& os) const override;
139 void printDataHistogram(std::ostream& os, RooRealVar* obs) const;
140
141 void SetName(const char *name) override;
142 void SetNameTitle(const char *name, const char* title) override;
143
144 Int_t getIndex(const RooAbsCollection& coord, bool fast = false) const;
145 /// \copydoc getIndex(const RooAbsCollection&,bool) const
146 ///
147 /// \note This overload only exists because there is an implicit conversion from RooAbsArg
148 /// to RooArgSet, and this needs to remain supported. This enables code like
149 /// ```
150 /// RooRealVar x(...);
151 /// dataHist.getIndex(x);
152 /// ```
153 /// It is, however, recommended to use
154 /// ```
155 /// dataHist.getIndex(RooArgSet(x));
156 /// ```
157 /// in this case.
158 Int_t getIndex(const RooArgSet& coord, bool fast = false) const {
159 return getIndex(static_cast<const RooAbsCollection&>(coord), fast);
160 }
161
163
164
165 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
166 /// @name Deprecated functions
167 /// These functions rely on the fact that an event has been loaded before they are called. It is advised
168 /// to switch to their counterparts that take bin numbers as arguments. In this way, code like,
169 /// ```
170 /// const RooArgSet* coordinates = dataHist.get(i); // Need this to achieve side effect on next call of weight() - bad.
171 /// const double weight = dataHist.weight();
172 /// processEvent(coordinates, weight);
173 /// ```
174 /// becomes
175 /// ```
176 /// processEvent(dataHist.get(i), dataHist.weight(i));
177 /// ```
178 /// The index of a set of coordinates can be computed using getIndex().
179 /// @{
180
181 /// Return weight of last bin that was requested with get().
182 /// \deprecated Use the safer weight(std::size_t) const.
183 double weight() const override
184 R__SUGGEST_ALTERNATIVE("Use the safer weight(std::size_t) const.")
185 { return get_curWeight(); }
186 /// Return squared weight of last bin that was requested with get().
187 /// \deprecated Use the safer weightSquared(std::size_t) const.
188 double weightSquared() const override
189 R__SUGGEST_ALTERNATIVE("Use the safer weightSquared(std::size_t) const.")
190 { return get_curSumW2(); }
191 /// Return volume of current bin. \deprecated Use binVolume(std::size_t) const.
192 double binVolume() const
193 R__SUGGEST_ALTERNATIVE("Use binVolume(std::size_t) const.")
194 { return _binv[_curIndex]; }
195 /// Write `weight` into current bin. \deprecated Use set(std::size_t,double,double)
196 void set(double wgt, double wgtErr=-1)
197 R__SUGGEST_ALTERNATIVE("Use set(std::size_t,double,double).");
198
199 void dump2();
200
201 ///@}
202 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
203
204 /// Structure to cache information on the histogram variable that is
205 /// frequently used for histogram weights retrieval.
206 struct VarInfo {
207 size_t nRealVars = 0;
208 size_t realVarIdx1 = 0;
209 size_t realVarIdx2 = 0;
210 bool initialized = false;
211 };
212
213 std::vector<std::unique_ptr<const RooAbsBinning>> const& getBinnings() const { return _lvbins; }
214
215 double const* weightArray() const { return _wgt; }
216 double const* wgtErrLoArray() const { return _errLo; }
217 double const* wgtErrHiArray() const { return _errHi; }
218 double const* sumW2Array() const { return _sumw2; }
219
220protected:
221
222 friend class RooAbsCachedPdf ;
223 friend class RooAbsCachedReal ;
224 friend class RooDataHistSliceIter ;
225 // for access into copied dataset:
227
228 std::size_t calcTreeIndex(const RooAbsCollection& coords, bool fast) const;
229 /// Legacy overload to calculate the tree index from the current value of `_vars`.
230 /// \deprecated Use calcTreeIndex(const RooArgSet&,bool) const.
231 Int_t calcTreeIndex() const { return static_cast<Int_t>(calcTreeIndex(_vars, true)); }
232
233 void setAllWeights(double value) ;
234
235 void initialize(const char* binningName=nullptr,bool fillTree=true) ;
237 const RooFormulaVar* cutVar, const char* cutRange, Int_t nStart, Int_t nStop) ;
238 RooAbsData* reduceEng(const RooArgSet& varSubset, const RooFormulaVar* cutVar, const char* cutRange=nullptr,
239 std::size_t nStart=0, std::size_t nStop=std::numeric_limits<std::size_t>::max()) override;
240 double interpolateDim(int iDim, double xval, size_t centralIdx, int intOrder, bool correctForBinSize, bool cdfBoundaries) ;
241 const std::vector<double>& calculatePartialBinVolume(const RooArgSet& dimSet) const ;
242 void checkBinBounds() const;
243
244 void adjustBinning(const RooArgList& vars, const TH1& href, Int_t* offset=nullptr) ;
245 void importTH1(const RooArgList& vars, const TH1& histo, double initWgt, bool doDensityCorrection) ;
246 void importTH1Set(const RooArgList& vars, RooCategory& indexCat, std::map<std::string,TH1*> hmap, double initWgt, bool doDensityCorrection) ;
247 void importDHistSet(const RooArgList& vars, RooCategory& indexCat, std::map<std::string,RooDataHist*> dmap, double initWgt) ;
248
249 double get_wgt(std::size_t idx) const { return _wgt[idx]; }
250 double get_errLo(std::size_t idx) const { return _errLo ? _errLo[idx] : -1.; }
251 double get_errHi(std::size_t idx) const { return _errHi ? _errHi[idx] : -1.; }
252 // If sumw2 is not being tracked, assume that all previous fill operations had a weight of 1, i.e., return the bare weight of the bin.
253 double get_sumw2(std::size_t idx) const { return _sumw2 ? _sumw2[idx] : _wgt[idx]; }
254
255 double get_curWeight() const { return get_wgt(_curIndex); }
256 double get_curWgtErrLo() const { return get_errLo(_curIndex); }
257 double get_curWgtErrHi() const { return get_errHi(_curIndex); }
258 double get_curSumW2() const { return get_sumw2(_curIndex); }
259
260 Int_t get_curIndex() const { return _curIndex; }
261
262 Int_t _arrSize{0}; // Size of member arrays.
263 std::vector<Int_t> _idxMult ; // Multiplier jump table for index calculation
264
265 double* _wgt {nullptr}; ///<[_arrSize] Weight array
266 mutable double* _errLo{nullptr}; ///<[_arrSize] Low-side error on weight array
267 mutable double* _errHi{nullptr}; ///<[_arrSize] High-side error on weight array
268 mutable double* _sumw2{nullptr}; ///<[_arrSize] Sum of weights^2
269 double* _binv {nullptr}; ///<[_arrSize] Bin volume array
270
271 mutable ULong64_t _curIndex{std::numeric_limits<ULong64_t>::max()}; ///< Current index
272
273 mutable std::unordered_map<int,std::vector<double>> _pbinvCache ; ///<! Cache for arrays of partial bin volumes
274 std::vector<RooAbsLValue*> _lvvars ; ///<! List of observables casted as RooAbsLValue
275 std::vector<std::unique_ptr<const RooAbsBinning>> _lvbins ; ///<! List of used binnings associated with lvalues
276 mutable std::vector<std::vector<double> > _binbounds; ///<! list of bin bounds per dimension
277
279 mutable Int_t _cache_sum_valid{kInvalid}; ///<! Is cache sum valid? Needs to be Int_t instead of CacheSumState_t for subclasses.
280 mutable double _cache_sum{0.}; ///<! Cache for sum of entries ;
281
282private:
283
284 void interpolateQuadratic(double* output, RooSpan<const double> xVals, bool correctForBinSize, bool cdfBoundaries);
285 void interpolateLinear(double* output, RooSpan<const double> xVals, bool correctForBinSize, bool cdfBoundaries);
286 double weightInterpolated(const RooArgSet& bin, int intOrder, bool correctForBinSize, bool cdfBoundaries);
287
288 void _adjustBinning(RooRealVar &theirVar, const TAxis &axis, RooRealVar *ourVar, Int_t *offset);
290 VarInfo const& getVarInfo();
291
292 static std::unique_ptr<RooAbsDataStore> makeDefaultDataStore(const char* name, const char* title, RooArgSet const& vars);
293
295 std::vector<double> _interpolationBuffer; ///<! Buffer to contain values used for weight interpolation
296
297 ClassDefOverride(RooDataHist, 8) // Binned data set
298};
299
300#endif
301
#define R__SUGGEST_ALTERNATIVE(ALTERNATIVE)
Definition: RConfig.hxx:521
#define h(i)
Definition: RSha256.hxx:106
unsigned long long ULong64_t
Definition: RtypesCore.h:81
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
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 data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
char name[80]
Definition: TGX11.cxx:110
#define hi
Definition: THbookFile.cxx:128
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:71
RooAbsCachedPdf is the abstract base class for p.d.f.s that need or want to cache their evaluate() ou...
RooAbsCachedReal is the abstract base class for functions that need or want to cache their evaluate()...
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects.
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:62
RooArgSet _vars
Dimensions of this data set.
Definition: RooAbsData.h:362
virtual RooPlot * plotOn(RooPlot *frame, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
Definition: RooAbsData.cxx:602
Abstract base class for objects that are lvalues, i.e.
Definition: RooAbsLValue.h:26
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:56
RooCategory is an object to represent discrete states.
Definition: RooCategory.h:28
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Definition: RooCmdArg.h:26
RooDataHistSliceIter iterates over all bins in a RooDataHist that occur in a slice defined by the bin...
The RooDataHist is a container class to hold N-dimensional binned data.
Definition: RooDataHist.h:45
double sum(bool correctForBinSize, bool inverseCorr=false) const
Return the sum of the weights of all bins in the histogram.
void dump2()
Debug stuff, should go...
double get_curWgtErrLo() const
Definition: RooDataHist.h:256
virtual void add(const RooArgSet &row, double wgt=1.0)
Add wgt to the bin content enclosed by the coordinates passed in row.
Definition: RooDataHist.h:72
double get_errLo(std::size_t idx) const
Definition: RooDataHist.h:250
RooAbsData * reduceEng(const RooArgSet &varSubset, const RooFormulaVar *cutVar, const char *cutRange=nullptr, std::size_t nStart=0, std::size_t nStop=std::numeric_limits< std::size_t >::max()) override
Implementation of RooAbsData virtual method that drives the RooAbsData::reduce() methods.
void setAllWeights(double value)
Set all the event weight of all bins to the specified value.
static std::unique_ptr< RooAbsDataStore > makeDefaultDataStore(const char *name, const char *title, RooArgSet const &vars)
Definition: RooDataHist.cxx:91
Int_t _cache_sum_valid
! Is cache sum valid? Needs to be Int_t instead of CacheSumState_t for subclasses.
Definition: RooDataHist.h:279
double interpolateDim(int iDim, double xval, size_t centralIdx, int intOrder, bool correctForBinSize, bool cdfBoundaries)
Perform boundary safe 'intOrder'-th interpolation of weights in dimension 'dim' at current value 'xva...
double weightSquared() const override
Return squared weight of last bin that was requested with get().
Definition: RooDataHist.h:188
std::vector< std::unique_ptr< const RooAbsBinning > > const & getBinnings() const
Definition: RooDataHist.h:213
void importTH1(const RooArgList &vars, const TH1 &histo, double initWgt, bool doDensityCorrection)
Import data from given TH1/2/3 into this RooDataHist.
void printDataHistogram(std::ostream &os, RooRealVar *obs) const
void SetNameTitle(const char *name, const char *title) override
Change the title of this RooDataHist.
TObject * Clone(const char *newname="") const override
Make a clone of an object using the Streamer facility.
Definition: RooDataHist.h:61
double _cache_sum
! Cache for sum of entries ;
Definition: RooDataHist.h:280
double const * sumW2Array() const
Definition: RooDataHist.h:218
double const * weightArray() const
Definition: RooDataHist.h:215
void initialize(const char *binningName=nullptr, bool fillTree=true)
Initialization procedure: allocate weights array, calculate multipliers needed for N-space to 1-dim a...
VarInfo _varInfo
!
Definition: RooDataHist.h:294
Int_t getIndex(const RooAbsCollection &coord, bool fast=false) const
Calculate bin number of the given coordinates.
const std::vector< double > & calculatePartialBinVolume(const RooArgSet &dimSet) const
Fill the transient cache with partial bin volumes with up-to-date values for the partial volume speci...
void weights(double *output, RooSpan< double const > xVals, int intOrder, bool correctForBinSize, bool cdfBoundaries)
A vectorized version of RooDataHist::weight() for one dimensional histograms with up to one dimension...
double weightInterpolated(const RooArgSet &bin, int intOrder, bool correctForBinSize, bool cdfBoundaries)
Return the weight at given coordinates with interpolation.
RooSpan< const double > getWeightBatch(std::size_t first, std::size_t len, bool sumW2=false) const override
Return event weights of all events in range [first, first+len).
std::unordered_map< int, std::vector< double > > _pbinvCache
! Cache for arrays of partial bin volumes
Definition: RooDataHist.h:273
void checkBinBounds() const
double weight(std::size_t i) const
Return weight of i-th bin.
Definition: RooDataHist.h:111
RooAbsData * emptyClone(const char *newName=nullptr, const char *newTitle=nullptr, const RooArgSet *vars=nullptr, const char *=nullptr) const override
Return empty clone of this RooDataHist.
Definition: RooDataHist.h:67
void set(std::size_t binNumber, double weight, double wgtErr)
Set bin content of bin that was last loaded with get(std::size_t).
double get_curWeight() const
Definition: RooDataHist.h:255
double get_curWgtErrHi() const
Definition: RooDataHist.h:257
double get_errHi(std::size_t idx) const
Definition: RooDataHist.h:251
RooSpan< const double > binVolumes(std::size_t first, std::size_t len) const
Retrieve all bin volumes. Bins are indexed according to getIndex().
Definition: RooDataHist.h:96
void weightError(double &lo, double &hi, ErrorType etype=Poisson) const override
Return the asymmetric errors on the current weight.
double * _errHi
[_arrSize] High-side error on weight array
Definition: RooDataHist.h:267
void importTH1Set(const RooArgList &vars, RooCategory &indexCat, std::map< std::string, TH1 * > hmap, double initWgt, bool doDensityCorrection)
Import data from given set of TH1/2/3 into this RooDataHist.
void adjustBinning(const RooArgList &vars, const TH1 &href, Int_t *offset=nullptr)
Adjust binning specification on first and optionally second and third observable to binning in given ...
double * _binv
[_arrSize] Bin volume array
Definition: RooDataHist.h:269
RooDataHist()
Default constructor.
Definition: RooDataHist.cxx:85
bool isWeighted() const override
Always returns true as all histograms use event weights.
Definition: RooDataHist.h:90
void removeSelfFromDir()
Definition: RooDataHist.h:162
double weightSquared(std::size_t i) const
Return squared weight sum of i-th bin.
Definition: RooDataHist.h:115
double get_sumw2(std::size_t idx) const
Definition: RooDataHist.h:253
double const * wgtErrHiArray() const
Definition: RooDataHist.h:217
ULong64_t _curIndex
Current index.
Definition: RooDataHist.h:271
double weightFast(const RooArgSet &bin, int intOrder, bool correctForBinSize, bool cdfBoundaries)
A faster version of RooDataHist::weight that assumes the passed arguments are aligned with the histog...
RooPlot * plotOn(RooPlot *frame, PlotOpt o) const override
Back end function to plotting functionality.
double weight() const override
Return weight of last bin that was requested with get().
Definition: RooDataHist.h:183
std::vector< std::vector< double > > _binbounds
! list of bin bounds per dimension
Definition: RooDataHist.h:276
void printArgs(std::ostream &os) const override
Print argument of dataset, i.e. the observable names.
void importDHistSet(const RooArgList &vars, RooCategory &indexCat, std::map< std::string, RooDataHist * > dmap, double initWgt)
Import data from given set of TH1/2/3 into this RooDataHist.
void _adjustBinning(RooRealVar &theirVar, const TAxis &axis, RooRealVar *ourVar, Int_t *offset)
Helper doing the actual work of adjustBinning().
void printMultiline(std::ostream &os, Int_t content, bool verbose=false, TString indent="") const override
Print the details on the dataset contents.
double * _sumw2
[_arrSize] Sum of weights^2
Definition: RooDataHist.h:268
TIterator * sliceIterator(RooAbsArg &sliceArg, const RooArgSet &otherArgs)
Create an iterator over all bins in a slice defined by the subset of observables listed in sliceArg.
void interpolateQuadratic(double *output, RooSpan< const double > xVals, bool correctForBinSize, bool cdfBoundaries)
A vectorized version of interpolateDim for boundary safe quadratic interpolation of one dimensional h...
Int_t calcTreeIndex() const
Legacy overload to calculate the tree index from the current value of _vars.
Definition: RooDataHist.h:231
~RooDataHist() override
Destructor.
bool isNonPoissonWeighted() const override
Returns true if dataset contains entries with a non-integer weight.
RooDataHist & operator=(const RooDataHist &)=delete
double get_wgt(std::size_t idx) const
Definition: RooDataHist.h:249
Int_t getIndex(const RooArgSet &coord, bool fast=false) const
Calculate bin number of the given coordinates.
Definition: RooDataHist.h:158
Int_t _arrSize
Definition: RooDataHist.h:262
double binVolume(std::size_t i) const
Return bin volume of i-th bin.
Definition: RooDataHist.h:117
std::vector< RooAbsLValue * > _lvvars
! List of observables casted as RooAbsLValue
Definition: RooDataHist.h:274
double weightError(ErrorType etype=Poisson) const override
Return the symmetric error on the current weight.
Definition: RooDataHist.h:124
double const * wgtErrLoArray() const
Definition: RooDataHist.h:216
Int_t numEntries() const override
Return the number of bins.
void SetName(const char *name) override
Change the name of the RooDataHist.
std::vector< std::unique_ptr< const RooAbsBinning > > _lvbins
! List of used binnings associated with lvalues
Definition: RooDataHist.h:275
Int_t get_curIndex() const
Definition: RooDataHist.h:260
std::vector< double > _interpolationBuffer
! Buffer to contain values used for weight interpolation
Definition: RooDataHist.h:295
std::vector< Int_t > _idxMult
Definition: RooDataHist.h:263
void registerWeightArraysToDataStore() const
Hand over pointers to our weight arrays to the data store implementation.
void reset() override
Reset all bin weights to zero.
double * _errLo
[_arrSize] Low-side error on weight array
Definition: RooDataHist.h:266
double * _wgt
[_arrSize] Weight array
Definition: RooDataHist.h:265
@ kCorrectForBinSize
Definition: RooDataHist.h:278
void printValue(std::ostream &os) const override
Print value of the dataset, i.e. the sum of weights contained in the dataset.
VarInfo const & getVarInfo()
Return reference to VarInfo struct with cached histogram variable information that is frequently used...
const RooArgSet * get() const override
Get bin centre of current bin.
Definition: RooDataHist.h:82
double binVolume() const
Return volume of current bin.
Definition: RooDataHist.h:192
double get_curSumW2() const
Definition: RooDataHist.h:258
void interpolateLinear(double *output, RooSpan< const double > xVals, bool correctForBinSize, bool cdfBoundaries)
A vectorized version of interpolateDim for boundary safe linear interpolation of one dimensional hist...
double sumEntries() const override
Sum the weights of all bins.
RooDirItem is a utility base class for RooFit objects that are to be attached to ROOT directories.
Definition: RooDirItem.h:22
void removeFromDir(TObject *obj)
Remove object from directory it was added to.
Definition: RooDirItem.cxx:39
A RooFormulaVar is a generic implementation of a real-valued object, which takes a RooArgList of serv...
Definition: RooFormulaVar.h:30
A RooPlot is a plot frame and a container for graphics objects within that frame.
Definition: RooPlot.h:43
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:40
A simple container to hold a batch of data values.
Definition: RooSpan.h:34
The RooStringView is a wrapper around a C-syle string that can also be constructed from a std::string...
Definition: RooStringView.h:27
Class to manage histogram axis.
Definition: TAxis.h:30
TH1 is the base class of all histogram classes in ROOT.
Definition: TH1.h:58
Iterator abstract base class.
Definition: TIterator.h:30
const char * GetName() const override
Returns name of object.
Definition: TNamed.h:47
const char * GetTitle() const override
Returns title of object.
Definition: TNamed.h:48
Mother of all ROOT objects.
Definition: TObject.h:41
Basic string class.
Definition: TString.h:136
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
Definition: RExports.h:167
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition: Common.h:18
Definition: first.py:1
Structure to cache information on the histogram variable that is frequently used for histogram weight...
Definition: RooDataHist.h:206
static void output()