Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooVectorDataStore.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_VECTOR_DATA_STORE
17#define ROO_VECTOR_DATA_STORE
18
19#include "RooAbsDataStore.h"
20#include "RooAbsCategory.h"
21#include "RooAbsReal.h"
22#include "RooChangeTracker.h"
23#include "RooRealVar.h"
24
25#include "ROOT/RStringView.hxx"
26#include "Rtypes.h"
27
28#include <list>
29#include <vector>
30#include <algorithm>
31
32class RooAbsArg ;
33class RooArgList ;
34class TTree ;
35class RooFormulaVar ;
36class RooArgSet ;
37class RooTreeDataStore ;
38
39#define VECTOR_BUFFER_SIZE 1024
40
42public:
43
45
46 // Empty ctor
47 RooVectorDataStore(RooStringView name, RooStringView title, const RooArgSet& vars, const char* wgtVarName=nullptr) ;
48
49 RooAbsDataStore* clone(const char* newname=nullptr) const override { return new RooVectorDataStore(*this,newname) ; }
50 RooAbsDataStore* clone(const RooArgSet& vars, const char* newname=nullptr) const override { return new RooVectorDataStore(*this,vars,newname) ; }
51
52 std::unique_ptr<RooAbsDataStore> reduce(RooStringView name, RooStringView title,
53 const RooArgSet& vars, const RooFormulaVar* cutVar, const char* cutRange,
54 std::size_t nStart, std::size_t nStop) override;
55
56 RooVectorDataStore(const RooVectorDataStore& other, const char* newname=nullptr) ;
57 RooVectorDataStore(const RooTreeDataStore& other, const RooArgSet& vars, const char* newname=nullptr) ;
58 RooVectorDataStore(const RooVectorDataStore& other, const RooArgSet& vars, const char* newname=nullptr) ;
59
60
62 const RooArgSet& vars, const RooFormulaVar* cutVar, const char* cutRange,
63 std::size_t nStart, std::size_t nStop, const char* wgtVarName=nullptr) ;
64
65 ~RooVectorDataStore() override ;
66
67 /// \class ArraysStruct
68 /// Output struct for the RooVectorDataStore::getArrays() helper function.
69 /// Meant to be used for RooFit internal use and might change without warning.
70 struct ArraysStruct {
71
72 template<class T>
73 struct ArrayInfo {
74 ArrayInfo(RooStringView n, T const* d) : name{n}, data{d} {}
75 std::string name;
76 T const* data;
77 };
78
79 std::vector<ArrayInfo<double>> reals;
80 std::vector<ArrayInfo<RooAbsCategory::value_type>> cats;
81
82 std::size_t size;
83 };
84
85 /// \name Internal RooFit interface.
86 /// The classes and functions in the internal RooFit interface are
87 /// implementation details and not part of the public user interface.
88 /// Everything in this group might change without warning.
89 /// @{
90 ArraysStruct getArrays() const;
91 void recomputeSumWeight();
92 /// @}
93
94private:
95 RooArgSet varsNoWeight(const RooArgSet& allVars, const char* wgtName);
96 RooRealVar* weightVar(const RooArgSet& allVars, const char* wgtName);
97
98 // reserve storage for nEvt entries
99 void reserve(Int_t nEvt);
100
101public:
102 // Write current row
103 Int_t fill() override;
104
105 // Retrieve a row
107 const RooArgSet* get(Int_t index) const override;
108
110 /// Return the weight of the last-retrieved data point.
111 double weight() const override
112 {
113 if (_extWgtArray)
115 if (_wgtVar)
116 return _wgtVar->getVal();
117
118 return 1.0;
119 }
120 double weightError(RooAbsData::ErrorType etype=RooAbsData::Poisson) const override;
121 void weightError(double& lo, double& hi, RooAbsData::ErrorType etype=RooAbsData::Poisson) const override;
122 bool isWeighted() const override { return _wgtVar || _extWgtArray; }
123
124 RooAbsData::RealSpans getBatches(std::size_t first, std::size_t len) const override;
125 RooAbsData::CategorySpans getCategoryBatches(std::size_t /*first*/, std::size_t len) const override;
126 std::span<const double> getWeightBatch(std::size_t first, std::size_t len) const override;
127
128 // Change observable name
129 bool changeObservableName(const char* from, const char* to) override;
130
131 // Add one column
132 RooAbsArg* addColumn(RooAbsArg& var, bool adjustRange=true) override;
133
134 // Merge column-wise
135 RooAbsDataStore* merge(const RooArgSet& allvars, std::list<RooAbsDataStore*> dstoreList) override;
136
137 // Add rows
138 void append(RooAbsDataStore& other) override;
139
140 // General & bookkeeping methods
141 Int_t numEntries() const override { return static_cast<int>(size()); }
142 double sumEntries() const override { return _sumWeight ; }
143 /// Get size of stored dataset.
144 std::size_t size() const {
145 if (!_realStoreList.empty()) {
146 return _realStoreList.front()->size();
147 } else if (!_realfStoreList.empty()) {
148 return _realfStoreList.front()->size();
149 } else if (!_catStoreList.empty()) {
150 return _catStoreList.front()->size();
151 }
152
153 return 0;
154 }
155 void reset() override;
156
157 // Buffer redirection routines used in inside RooAbsOptTestStatistics
158 void attachBuffers(const RooArgSet& extObs) override;
159 void resetBuffers() override;
160
161
162 // Constant term optimizer interface
163 const RooAbsArg* cacheOwner() override { return _cacheOwner ; }
164 void cacheArgs(const RooAbsArg* owner, RooArgSet& varSet, const RooArgSet* nset=nullptr, bool skipZeroWeights=true) override;
165 void attachCache(const RooAbsArg* newOwner, const RooArgSet& cachedVars) override;
166 void resetCache() override;
167 void recalculateCache(const RooArgSet* /*proj*/, Int_t firstEvent, Int_t lastEvent, Int_t stepSize, bool skipZeroWeights) override;
168
169 void setArgStatus(const RooArgSet& set, bool active) override;
170
171 const RooVectorDataStore* cache() const { return _cache ; }
172
173 void loadValues(const RooAbsDataStore *tds, const RooFormulaVar* select=nullptr, const char* rangeName=nullptr, std::size_t nStart=0, std::size_t nStop = std::numeric_limits<std::size_t>::max()) override;
174
175 void dump() override;
176
177 void setExternalWeightArray(const double* arrayWgt, const double* arrayWgtErrLo,
178 const double* arrayWgtErrHi, const double* arraySumW2) override {
179 _extWgtArray = arrayWgt ;
180 _extWgtErrLoArray = arrayWgtErrLo ;
181 _extWgtErrHiArray = arrayWgtErrHi ;
182 _extSumW2Array = arraySumW2 ;
183 }
184
185 void setDirtyProp(bool flag) override {
186 _doDirtyProp = flag ;
187 if (_cache) {
188 _cache->setDirtyProp(flag) ;
189 }
190 }
191
192 const RooArgSet& row() { return _varsww ; }
193
195 public:
196
197 RealVector(UInt_t initialCapacity=(VECTOR_BUFFER_SIZE / sizeof(double))) {
198 _vec.reserve(initialCapacity);
199 }
200
201 RealVector(RooAbsReal* arg, UInt_t initialCapacity=(VECTOR_BUFFER_SIZE / sizeof(double))) :
202 _nativeReal(arg) {
203 _vec.reserve(initialCapacity);
204 }
205
206 virtual ~RealVector() {
207 delete _tracker;
208 if (_nset) delete _nset ;
209 }
210
211 RealVector(const RealVector& other, RooAbsReal* real=nullptr) :
212 _vec(other._vec), _nativeReal(real?real:other._nativeReal), _real(real?real:other._real), _buf(other._buf), _nativeBuf(other._nativeBuf) {
213 if (other._tracker) {
214 _tracker = new RooChangeTracker(Form("track_%s",_nativeReal->GetName()),"tracker",other._tracker->parameters()) ;
215 } else {
216 _tracker = nullptr ;
217 }
218 if (other._nset) {
219 _nset = new RooArgSet(*other._nset) ;
220 }
221 }
222
224 if (&other==this) return *this;
225 _nativeReal = other._nativeReal;
226 _real = other._real;
227 _buf = other._buf;
228 _nativeBuf = other._nativeBuf;
229 if (other._vec.size() <= _vec.capacity() / 2 && _vec.capacity() > (VECTOR_BUFFER_SIZE / sizeof(double))) {
230 std::vector<double> tmp;
231 tmp.reserve(std::max(other._vec.size(), VECTOR_BUFFER_SIZE / sizeof(double)));
232 tmp.assign(other._vec.begin(), other._vec.end());
233 _vec.swap(tmp);
234 } else {
235 _vec = other._vec;
236 }
237
238 return *this;
239 }
240
241 void setNset(RooArgSet* newNset) { _nset = newNset ? new RooArgSet(*newNset) : nullptr ; }
242
243 RooArgSet* nset() const { return _nset ; }
244
245 void setBufArg(RooAbsReal* arg) { _nativeReal = arg ; }
246 const RooAbsReal* bufArg() const { return _nativeReal ; }
247
248 void setBuffer(RooAbsReal* real, double* newBuf) {
249 _real = real ;
250 _buf = newBuf ;
251 if (_nativeBuf==nullptr) {
252 _nativeBuf=newBuf ;
253 }
254 }
255
256 void setNativeBuffer(double* newBuf=nullptr) {
257 _nativeBuf = newBuf ? newBuf : _buf ;
258 }
259
260 void setDependents(const RooArgSet& deps) {
261 if (_tracker) {
262 delete _tracker ;
263 }
264 _tracker = new RooChangeTracker(Form("track_%s",_nativeReal->GetName()),"tracker",deps) ;
265 }
266
267 bool needRecalc() {
268 if (!_tracker) return false ;
269 return _tracker->hasChanged(true) ;
270 }
271
272 void fill() {
273 _vec.push_back(*_buf);
274 }
275
276 void write(Int_t i) {
277 assert(static_cast<std::size_t>(i) < _vec.size());
278 _vec[i] = *_buf ;
279 }
280
281 void reset() {
282 _vec.clear();
283 }
284
285 inline void load(std::size_t idx) const {
286 assert(idx < _vec.size());
287 *_buf = *(_vec.begin() + idx) ;
288 *_nativeBuf = *_buf ;
289 }
290
291 std::span<const double> getRange(std::size_t first, std::size_t last) const {
292 auto beg = std::min(_vec.cbegin() + first, _vec.cend());
293 auto end = std::min(_vec.cbegin() + last, _vec.cend());
294
295 return std::span<const double>(&*beg, std::distance(beg, end));
296 }
297
298 std::size_t size() const { return _vec.size() ; }
299
300 void resize(Int_t newSize) {
301 if (newSize < Int_t(_vec.capacity()) / 2 && _vec.capacity() > (VECTOR_BUFFER_SIZE / sizeof(double))) {
302 // do an expensive copy, if we save at least a factor 2 in size
303 std::vector<double> tmp;
304 tmp.reserve(std::max(newSize, Int_t(VECTOR_BUFFER_SIZE / sizeof(double))));
305 if (!_vec.empty())
306 tmp.assign(_vec.begin(), std::min(_vec.end(), _vec.begin() + newSize));
307 if (Int_t(tmp.size()) != newSize)
308 tmp.resize(newSize);
309 _vec.swap(tmp);
310 } else {
311 _vec.resize(newSize);
312 }
313 }
314
315 void reserve(Int_t newSize) {
316 _vec.reserve(newSize);
317 }
318
319 const std::vector<double>& data() const {
320 return _vec;
321 }
322
323 std::vector<double>& data() { return _vec; }
324
325 protected:
326 std::vector<double> _vec;
327
328 private:
329 friend class RooVectorDataStore ;
330 RooAbsReal* _nativeReal = nullptr; ///< Instance which our data belongs to. This is the variable in the dataset.
331 RooAbsReal* _real = nullptr; ///< Instance where we should write data into when load() is called.
332 double* _buf = nullptr; ///<!
333 double* _nativeBuf = nullptr; ///<!
335 RooArgSet* _nset = nullptr; ///<!
336 ClassDef(RealVector,1) // STL-vector-based Data Storage class
337 } ;
338
339
340 class RealFullVector : public RealVector {
341 public:
342 RealFullVector(UInt_t initialCapacity=(VECTOR_BUFFER_SIZE / sizeof(double))) : RealVector(initialCapacity) {}
343
344 RealFullVector(RooAbsReal* arg, UInt_t initialCapacity=(VECTOR_BUFFER_SIZE / sizeof(double))) :
345 RealVector(arg,initialCapacity) {}
346
347 RealFullVector(const RealFullVector& other, RooAbsReal* real=nullptr) : RealVector(other,real),
348 _bufE(other._bufE), _bufEL(other._bufEL), _bufEH(other._bufEH),
349 _vecE{other._vecE}, _vecEL{other._vecEL}, _vecEH{other._vecEH}
350 {
351 }
352
353 RealFullVector(const RealVector& other, RooAbsReal* real=nullptr) : RealVector(other,real) {}
354
355 RealFullVector& operator=(RealFullVector const& other) = delete;
356
357 void setErrorBuffer(double* newBuf) {
358 _bufE = newBuf ;
359 _vecE.reserve(_vec.capacity()) ;
360 }
361 void setAsymErrorBuffer(double* newBufL, double* newBufH) {
362 _bufEL = newBufL;
363 _bufEH = newBufH;
364 _vecEL.reserve(_vec.capacity()) ;
365 _vecEH.reserve(_vec.capacity()) ;
366 }
367
368 void fill() {
370 if (_bufE) _vecE.push_back(*_bufE) ;
371 if (_bufEL) _vecEL.push_back(*_bufEL) ;
372 if (_bufEH) _vecEH.push_back(*_bufEH) ;
373 } ;
374
375 void write(Int_t i) {
377 if (_bufE) _vecE[i] = *_bufE ;
378 if (_bufEL) _vecEL[i] = *_bufEL ;
379 if (_bufEH) _vecEH[i] = *_bufEH ;
380 }
381
382 void reset() {
384 _vecE.clear();
385 _vecEL.clear();
386 _vecEH.clear();
387 }
388
389 inline void load(Int_t idx) const {
390 RealVector::load(idx) ;
391 if (_bufE) *_bufE = _vecE[idx];
392 if (_bufEL) *_bufEL = _vecEL[idx];
393 if (_bufEH) *_bufEH = _vecEH[idx];
394 }
395
396 void resize(Int_t newSize) {
397 RealVector::resize(newSize);
398 if(_bufE) _vecE.resize(newSize);
399 if(_bufEL) _vecEL.resize(newSize);
400 if(_bufEH) _vecEH.resize(newSize);
401 }
402
403 void reserve(Int_t newSize) {
404 RealVector::reserve(newSize);
405 if(_bufE) _vecE.reserve(newSize);
406 if(_bufEL) _vecEL.reserve(newSize);
407 if(_bufEH) _vecEH.reserve(newSize);
408 }
409
410 double* bufE() const { return _bufE; }
411 double* bufEL() const { return _bufEL; }
412 double* bufEH() const { return _bufEH; }
413
414 std::vector<double> const& dataE() const { return _vecE; }
415 std::vector<double> const& dataEL() const { return _vecEL; }
416 std::vector<double> const& dataEH() const { return _vecEH; }
417
418 private:
419
420 double *_bufE = nullptr; ///<!
421 double *_bufEL = nullptr; ///<!
422 double *_bufEH = nullptr; ///<!
423 std::vector<double> _vecE;
424 std::vector<double> _vecEL;
425 std::vector<double> _vecEH;
426 ClassDefOverride(RealFullVector,2); // STL-vector-based Data Storage class
427 };
428
429
430 class CatVector {
431 public:
433 {
434 _vec.reserve(initialCapacity);
435 }
436
438 _cat(cat)
439 {
440 _vec.reserve(initialCapacity);
441 }
442
443 virtual ~CatVector() {
444 }
445
446 CatVector(const CatVector& other, RooAbsCategory* cat = nullptr) :
447 _cat(cat?cat:other._cat), _buf(other._buf), _nativeBuf(other._nativeBuf), _vec(other._vec)
448 {
449
450 }
451
453 if (&other==this) return *this;
454 _cat = other._cat;
455 _buf = other._buf;
456 _nativeBuf = other._nativeBuf;
457 if (other._vec.size() <= _vec.capacity() / 2 && _vec.capacity() > VECTOR_BUFFER_SIZE) {
458 std::vector<RooAbsCategory::value_type> tmp;
459 tmp.reserve(std::max(other._vec.size(), std::size_t(VECTOR_BUFFER_SIZE)));
460 tmp.assign(other._vec.begin(), other._vec.end());
461 _vec.swap(tmp);
462 } else {
463 _vec = other._vec;
464 }
465
466 return *this;
467 }
468
470 _buf = newBuf ;
471 if (!_nativeBuf) _nativeBuf = newBuf;
472 }
473
475 _nativeBuf = newBuf ? newBuf : _buf;
476 }
477
478 void fill() {
479 _vec.push_back(*_buf) ;
480 }
481
482 void write(std::size_t i) {
483 _vec[i] = *_buf;
484 }
485
486 void reset() {
487 // make sure the vector releases the underlying memory
488 std::vector<RooAbsCategory::value_type> tmp;
489 _vec.swap(tmp);
490 }
491
492 inline void load(std::size_t idx) const {
493 *_buf = _vec[idx];
494 *_nativeBuf = *_buf;
495 }
496
497 std::span<const RooAbsCategory::value_type> getRange(std::size_t first, std::size_t last) const {
498 auto beg = std::min(_vec.cbegin() + first, _vec.cend());
499 auto end = std::min(_vec.cbegin() + last, _vec.cend());
500
501 return std::span<const RooAbsCategory::value_type>(&*beg, std::distance(beg, end));
502 }
503
504
505 std::size_t size() const { return _vec.size() ; }
506
507 void resize(Int_t newSize) {
508 if (newSize < Int_t(_vec.capacity()) / 2 && _vec.capacity() > VECTOR_BUFFER_SIZE) {
509 // do an expensive copy, if we save at least a factor 2 in size
510 std::vector<RooAbsCategory::value_type> tmp;
511 tmp.reserve(std::max(newSize, VECTOR_BUFFER_SIZE));
512 if (!_vec.empty())
513 tmp.assign(_vec.begin(), std::min(_vec.end(), _vec.begin() + newSize));
514 if (Int_t(tmp.size()) != newSize)
515 tmp.resize(newSize);
516 _vec.swap(tmp);
517 } else {
518 _vec.resize(newSize);
519 }
520 }
521
522 void reserve(Int_t newSize) {
523 _vec.reserve(newSize);
524 }
525
526 void setBufArg(RooAbsCategory* arg) { _cat = arg; }
527 const RooAbsCategory* bufArg() const { return _cat; }
528
529 std::vector<RooAbsCategory::value_type>& data() { return _vec; }
530
531 private:
532 friend class RooVectorDataStore ;
536 std::vector<RooAbsCategory::value_type> _vec;
537 ClassDef(CatVector,2) // STL-vector-based Data Storage class
538 } ;
539
540 std::vector<RealVector*>& realStoreList() { return _realStoreList ; }
541 std::vector<RealFullVector*>& realfStoreList() { return _realfStoreList ; }
542 std::vector<CatVector*>& catStoreList() { return _catStoreList ; }
543
544 protected:
545
546 friend class RooAbsReal ;
547 friend class RooAbsCategory ;
548 friend class RooRealVar ;
549
551
553
554 bool isFullReal(RooAbsReal* real);
555
556 bool hasError(RooAbsReal* real);
557
558 bool hasAsymError(RooAbsReal* real);
559
561
562 bool hasFilledCache() const override { return _cache ? true : false ; }
563
564 void forceCacheUpdate() override;
565
566 private:
568 RooRealVar* _wgtVar = nullptr; ///< Pointer to weight variable (if set)
569
570 std::vector<RealVector*> _realStoreList ;
571 std::vector<RealFullVector*> _realfStoreList ;
572 std::vector<CatVector*> _catStoreList ;
573
574 void setAllBuffersNative() ;
575
576 double _sumWeight = 0.0;
577 double _sumWeightCarry = 0.0;
578
579 const double* _extWgtArray = nullptr; ///<! External weight array
580 const double* _extWgtErrLoArray = nullptr; ///<! External weight array - low error
581 const double* _extWgtErrHiArray = nullptr; ///<! External weight array - high error
582 const double* _extSumW2Array = nullptr; ///<! External sum of weights array
583
585
586 RooVectorDataStore* _cache = nullptr; ///<! Optimization cache
587 RooAbsArg* _cacheOwner = nullptr; ///<! Cache owner
588
589 bool _forcedUpdate = false; ///<! Request for forced cache update
590
591 ClassDefOverride(RooVectorDataStore, 7) // STL-vector-based Data Storage class
592};
593
594
595#endif
#define d(i)
Definition RSha256.hxx:102
#define VECTOR_BUFFER_SIZE
int Int_t
Definition RtypesCore.h:45
unsigned long long ULong64_t
Definition RtypesCore.h:81
#define ClassDef(name, id)
Definition Rtypes.h:337
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
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
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
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2467
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:79
A space to attach TBranches.
RooAbsDataStore is the abstract base class for data collection that use a TTree as internal storage m...
const RooArgSet & cachedVars() const
bool _doDirtyProp
Switch do (de)activate dirty state propagation when loading a data point.
virtual double weight() const =0
virtual const RooArgSet * get() const
std::map< RooFit::Detail::DataKey, std::span< const double > > RealSpans
Definition RooAbsData.h:131
std::map< RooFit::Detail::DataKey, std::span< const RooAbsCategory::value_type > > CategorySpans
Definition RooAbsData.h:132
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition RooAbsReal.h:103
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
Meta object that tracks value changes in a given set of RooAbsArgs by registering itself as value cli...
bool hasChanged(bool clearState)
Returns true if state has changed since last call with clearState=true.
RooArgSet parameters() const
A RooFormulaVar is a generic implementation of a real-valued object, which takes a RooArgList of serv...
RooRealVar represents a variable that can be changed from the outside.
Definition RooRealVar.h:37
The RooStringView is a wrapper around a C-style string that can also be constructed from a std::strin...
RooTreeDataStore is a TTree-backed data storage.
void setBufArg(RooAbsCategory *arg)
void setBuffer(RooAbsCategory::value_type *newBuf)
CatVector(UInt_t initialCapacity=1024)
RooAbsCategory::value_type * _buf
!
std::span< const RooAbsCategory::value_type > getRange(std::size_t first, std::size_t last) const
RooAbsCategory::value_type * _nativeBuf
!
CatVector & operator=(const CatVector &other)
void load(std::size_t idx) const
std::vector< RooAbsCategory::value_type > _vec
void setNativeBuffer(RooAbsCategory::value_type *newBuf=nullptr)
CatVector(RooAbsCategory *cat, UInt_t initialCapacity=1024)
const RooAbsCategory * bufArg() const
std::vector< RooAbsCategory::value_type > & data()
CatVector(const CatVector &other, RooAbsCategory *cat=nullptr)
RealFullVector(RooAbsReal *arg, UInt_t initialCapacity=(1024/sizeof(double)))
RealFullVector(const RealFullVector &other, RooAbsReal *real=nullptr)
std::vector< double > const & dataE() const
RealFullVector & operator=(RealFullVector const &other)=delete
std::vector< double > const & dataEL() const
RealFullVector(UInt_t initialCapacity=(1024/sizeof(double)))
RealFullVector(const RealVector &other, RooAbsReal *real=nullptr)
std::vector< double > const & dataEH() const
void setAsymErrorBuffer(double *newBufL, double *newBufH)
std::span< const double > getRange(std::size_t first, std::size_t last) const
RealVector & operator=(const RealVector &other)
RealVector(const RealVector &other, RooAbsReal *real=nullptr)
const RooAbsReal * bufArg() const
void setNset(RooArgSet *newNset)
std::vector< double > & data()
RooAbsReal * _nativeReal
Instance which our data belongs to. This is the variable in the dataset.
void setDependents(const RooArgSet &deps)
RealVector(UInt_t initialCapacity=(1024/sizeof(double)))
RooAbsReal * _real
Instance where we should write data into when load() is called.
void setBuffer(RooAbsReal *real, double *newBuf)
RealVector(RooAbsReal *arg, UInt_t initialCapacity=(1024/sizeof(double)))
void load(std::size_t idx) const
void setNativeBuffer(double *newBuf=nullptr)
const std::vector< double > & data() const
RooVectorDataStore uses std::vectors to store data columns.
const RooArgSet & row()
void recalculateCache(const RooArgSet *, Int_t firstEvent, Int_t lastEvent, Int_t stepSize, bool skipZeroWeights) override
RooAbsDataStore * clone(const RooArgSet &vars, const char *newname=nullptr) const override
std::vector< CatVector * > & catStoreList()
void attachCache(const RooAbsArg *newOwner, const RooArgSet &cachedVars) override
Initialize cache of dataset: attach variables of cache ArgSet to the corresponding TTree branches.
std::vector< RealFullVector * > _realfStoreList
void setExternalWeightArray(const double *arrayWgt, const double *arrayWgtErrLo, const double *arrayWgtErrHi, const double *arraySumW2) override
Int_t numEntries() const override
RooAbsDataStore * clone(const char *newname=nullptr) const override
RooAbsArg * addColumn(RooAbsArg &var, bool adjustRange=true) override
Add a new column to the data set which holds the pre-calculated values of 'newVar'.
const RooVectorDataStore * cache() const
RooVectorDataStore * _cache
! Optimization cache
const double * _extWgtErrHiArray
! External weight array - high error
std::span< const double > getWeightBatch(std::size_t first, std::size_t len) const override
Return the weights of all events in the range [first, first+len).
~RooVectorDataStore() override
Destructor.
RooRealVar * weightVar(const RooArgSet &allVars, const char *wgtName)
Utility function for constructors Return pointer to weight variable if it is defined.
void cacheArgs(const RooAbsArg *owner, RooArgSet &varSet, const RooArgSet *nset=nullptr, bool skipZeroWeights=true) override
Cache given RooAbsArgs: The tree is given direct write access of the args internal cache the args val...
RooRealVar * _wgtVar
Pointer to weight variable (if set)
std::vector< RealVector * > _realStoreList
CatVector * addCategory(RooAbsCategory *cat)
void loadValues(const RooAbsDataStore *tds, const RooFormulaVar *select=nullptr, const char *rangeName=nullptr, std::size_t nStart=0, std::size_t nStop=std::numeric_limits< std::size_t >::max()) override
RealFullVector * addRealFull(RooAbsReal *real)
double weight() const override
Return the weight of the last-retrieved data point.
RooAbsData::RealSpans getBatches(std::size_t first, std::size_t len) const override
Return batches of the data columns for the requested events.
bool isFullReal(RooAbsReal *real)
bool isWeighted() const override
double sumEntries() const override
Int_t fill() override
Interface function to TTree::Fill.
std::vector< RealFullVector * > & realfStoreList()
const double * _extWgtErrLoArray
! External weight array - low error
bool _forcedUpdate
! Request for forced cache update
void append(RooAbsDataStore &other) override
bool hasError(RooAbsReal *real)
std::vector< CatVector * > _catStoreList
void setArgStatus(const RooArgSet &set, bool active) override
Disabling of branches is (intentionally) not implemented in vector data stores (as the doesn't result...
double weightError(RooAbsData::ErrorType etype=RooAbsData::Poisson) const override
Return the error of the current weight.
void attachBuffers(const RooArgSet &extObs) override
ArraysStruct getArrays() const
Exports all arrays in this RooVectorDataStore into a simple datastructure to be used by RooFit intern...
RooAbsData::CategorySpans getCategoryBatches(std::size_t, std::size_t len) const override
RooAbsDataStore * merge(const RooArgSet &allvars, std::list< RooAbsDataStore * > dstoreList) override
Merge columns of supplied data set(s) with this data set.
void setDirtyProp(bool flag) override
RealVector * addReal(RooAbsReal *real)
bool hasAsymError(RooAbsReal *real)
bool changeObservableName(const char *from, const char *to) override
void forceCacheUpdate() override
const RooAbsArg * cacheOwner() override
const double * _extSumW2Array
! External sum of weights array
void recomputeSumWeight()
Trigger a recomputation of the cached weight sums.
std::vector< RealVector * > & realStoreList()
std::size_t size() const
Get size of stored dataset.
std::unique_ptr< RooAbsDataStore > reduce(RooStringView name, RooStringView title, const RooArgSet &vars, const RooFormulaVar *cutVar, const char *cutRange, std::size_t nStart, std::size_t nStop) override
virtual const RooArgSet * get() const
const double * _extWgtArray
! External weight array
RooArgSet varsNoWeight(const RooArgSet &allVars, const char *wgtName)
Utility function for constructors Return RooArgSet that is copy of allVars minus variable matching wg...
RooAbsArg * _cacheOwner
! Cache owner
bool hasFilledCache() const override
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
A TTree represents a columnar dataset.
Definition TTree.h:79
const Int_t n
Definition legend1.C:16
Definition first.py:1
Output struct for the RooVectorDataStore::getArrays() helper function.
std::vector< ArrayInfo< double > > reals
std::vector< ArrayInfo< RooAbsCategory::value_type > > cats