Logo ROOT  
Reference Guide
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
27#include <list>
28#include <vector>
29#include <algorithm>
30
31class RooAbsArg ;
32class RooArgList ;
33class TTree ;
34class RooFormulaVar ;
35class RooArgSet ;
36
37#define VECTOR_BUFFER_SIZE 1024
38
40public:
41
43
44 // Empty ctor
45 RooVectorDataStore(std::string_view name, std::string_view title, const RooArgSet& vars, const char* wgtVarName=0) ;
46
48
49 virtual RooAbsDataStore* clone(const char* newname=0) const override { return new RooVectorDataStore(*this,newname) ; }
50 virtual RooAbsDataStore* clone(const RooArgSet& vars, const char* newname=0) const override { return new RooVectorDataStore(*this,vars,newname) ; }
51
52 RooVectorDataStore(const RooVectorDataStore& other, const char* newname=0) ;
53 RooVectorDataStore(const RooTreeDataStore& other, const RooArgSet& vars, const char* newname=0) ;
54 RooVectorDataStore(const RooVectorDataStore& other, const RooArgSet& vars, const char* newname=0) ;
55
56
58 const RooArgSet& vars, const RooFormulaVar* cutVar, const char* cutRange,
59 std::size_t nStart, std::size_t nStop, Bool_t /*copyCache*/, const char* wgtVarName=0) ;
60
61 virtual ~RooVectorDataStore() ;
62
63private:
64 RooArgSet varsNoWeight(const RooArgSet& allVars, const char* wgtName);
65 RooRealVar* weightVar(const RooArgSet& allVars, const char* wgtName);
66
67 // reserve storage for nEvt entries
68 void reserve(Int_t nEvt);
69
70public:
71 // Write current row
72 virtual Int_t fill() override;
73
74 // Retrieve a row
76 virtual const RooArgSet* get(Int_t index) const override;
77
78 virtual const RooArgSet* getNative(Int_t index) const;
79
81 /// Return the weight of the last-retrieved data point.
82 Double_t weight() const override
83 {
84 if (_extWgtArray)
86 if (_wgtVar)
87 return _wgtVar->getVal();
88
89 return 1.0;
90 }
92 virtual void weightError(Double_t& lo, Double_t& hi, RooAbsData::ErrorType etype=RooAbsData::Poisson) const override;
93 virtual Bool_t isWeighted() const override { return _wgtVar || _extWgtArray; }
94
95 RooBatchCompute::RunContext getBatches(std::size_t first, std::size_t len) const override;
96 virtual RooSpan<const double> getWeightBatch(std::size_t first, std::size_t len) const override;
97
98 // Change observable name
99 virtual Bool_t changeObservableName(const char* from, const char* to) override;
100
101 // Add one or more columns
102 virtual RooAbsArg* addColumn(RooAbsArg& var, Bool_t adjustRange=kTRUE) override;
103 virtual RooArgSet* addColumns(const RooArgList& varList) override;
104
105 // Merge column-wise
106 RooAbsDataStore* merge(const RooArgSet& allvars, std::list<RooAbsDataStore*> dstoreList) override;
107
108 // Add rows
109 virtual void append(RooAbsDataStore& other) override;
110
111 // General & bookkeeping methods
112 virtual Int_t numEntries() const override { return static_cast<int>(size()); }
113 virtual Double_t sumEntries() const override { return _sumWeight ; }
114 /// Get size of stored dataset.
115 std::size_t size() const {
116 if (!_realStoreList.empty()) {
117 return _realStoreList.front()->size();
118 } else if (!_realfStoreList.empty()) {
119 return _realfStoreList.front()->size();
120 } else if (!_catStoreList.empty()) {
121 return _catStoreList.front()->size();
122 }
123
124 return 0;
125 }
126 virtual void reset() override;
127
128 // Buffer redirection routines used in inside RooAbsOptTestStatistics
129 virtual void attachBuffers(const RooArgSet& extObs) override;
130 virtual void resetBuffers() override;
131
132
133 // Constant term optimizer interface
134 virtual const RooAbsArg* cacheOwner() override { return _cacheOwner ; }
135 virtual void cacheArgs(const RooAbsArg* owner, RooArgSet& varSet, const RooArgSet* nset=0, Bool_t skipZeroWeights=kTRUE) override;
136 virtual void attachCache(const RooAbsArg* newOwner, const RooArgSet& cachedVars) override;
137 virtual void resetCache() override;
138 virtual void recalculateCache(const RooArgSet* /*proj*/, Int_t firstEvent, Int_t lastEvent, Int_t stepSize, Bool_t skipZeroWeights) override;
139
140 virtual void setArgStatus(const RooArgSet& set, Bool_t active) override;
141
142 const RooVectorDataStore* cache() const { return _cache ; }
143
144 void loadValues(const RooAbsDataStore *tds, const RooFormulaVar* select=0, const char* rangeName=0, std::size_t nStart=0, std::size_t nStop = std::numeric_limits<std::size_t>::max()) override;
145
146 void dump() override;
147
148 void setExternalWeightArray(const Double_t* arrayWgt, const Double_t* arrayWgtErrLo,
149 const Double_t* arrayWgtErrHi, const Double_t* arraySumW2) override {
150 _extWgtArray = arrayWgt ;
151 _extWgtErrLoArray = arrayWgtErrLo ;
152 _extWgtErrHiArray = arrayWgtErrHi ;
153 _extSumW2Array = arraySumW2 ;
154 }
155
156 virtual void setDirtyProp(Bool_t flag) override {
157 _doDirtyProp = flag ;
158 if (_cache) {
159 _cache->setDirtyProp(flag) ;
160 }
161 }
162
163 const RooArgSet& row() { return _varsww ; }
164
166 public:
167
168 RealVector(UInt_t initialCapacity=(VECTOR_BUFFER_SIZE / sizeof(Double_t))) :
169 _nativeReal(0), _real(0), _buf(0), _nativeBuf(0), _tracker(0), _nset(0) {
170 _vec.reserve(initialCapacity);
171 }
172
173 RealVector(RooAbsReal* arg, UInt_t initialCapacity=(VECTOR_BUFFER_SIZE / sizeof(Double_t))) :
174 _nativeReal(arg), _real(0), _buf(0), _nativeBuf(0), _tracker(0), _nset(0) {
175 _vec.reserve(initialCapacity);
176 }
177
178 virtual ~RealVector() {
179 delete _tracker;
180 if (_nset) delete _nset ;
181 }
182
183 RealVector(const RealVector& other, RooAbsReal* real=0) :
184 _vec(other._vec), _nativeReal(real?real:other._nativeReal), _real(real?real:other._real), _buf(other._buf), _nativeBuf(other._nativeBuf), _nset(0) {
185 if (other._tracker) {
186 _tracker = new RooChangeTracker(Form("track_%s",_nativeReal->GetName()),"tracker",other._tracker->parameters()) ;
187 } else {
188 _tracker = 0 ;
189 }
190 if (other._nset) {
191 _nset = new RooArgSet(*other._nset) ;
192 }
193 }
194
196 if (&other==this) return *this;
197 _nativeReal = other._nativeReal;
198 _real = other._real;
199 _buf = other._buf;
200 _nativeBuf = other._nativeBuf;
201 if (other._vec.size() <= _vec.capacity() / 2 && _vec.capacity() > (VECTOR_BUFFER_SIZE / sizeof(Double_t))) {
202 std::vector<Double_t> tmp;
203 tmp.reserve(std::max(other._vec.size(), VECTOR_BUFFER_SIZE / sizeof(Double_t)));
204 tmp.assign(other._vec.begin(), other._vec.end());
205 _vec.swap(tmp);
206 } else {
207 _vec = other._vec;
208 }
209
210 return *this;
211 }
212
213 void setNset(RooArgSet* newNset) { _nset = newNset ? new RooArgSet(*newNset) : 0 ; }
214
215 RooArgSet* nset() const { return _nset ; }
216
217 void setBufArg(RooAbsReal* arg) { _nativeReal = arg ; }
218 const RooAbsReal* bufArg() const { return _nativeReal ; }
219
220 void setBuffer(RooAbsReal* real, Double_t* newBuf) {
221 _real = real ;
222 _buf = newBuf ;
223 if (_nativeBuf==0) {
224 _nativeBuf=newBuf ;
225 }
226 }
227
228 void setNativeBuffer(Double_t* newBuf=0) {
229 _nativeBuf = newBuf ? newBuf : _buf ;
230 }
231
232 void setDependents(const RooArgSet& deps) {
233 if (_tracker) {
234 delete _tracker ;
235 }
236 _tracker = new RooChangeTracker(Form("track_%s",_nativeReal->GetName()),"tracker",deps) ;
237 }
238
240 if (!_tracker) return kFALSE ;
241 return _tracker->hasChanged(kTRUE) ;
242 }
243
244 void fill() {
245 _vec.push_back(*_buf);
246 }
247
248 void write(Int_t i) {
249 assert(static_cast<std::size_t>(i) < _vec.size());
250 _vec[i] = *_buf ;
251 }
252
253 void reset() {
254 _vec.clear();
255 }
256
257 inline void load(std::size_t idx) const {
258 assert(idx < _vec.size());
259 *_buf = *(_vec.begin() + idx) ;
260 }
261
262 RooSpan<const double> getRange(std::size_t first, std::size_t last) const {
263 auto beg = std::min(_vec.cbegin() + first, _vec.cend());
264 auto end = std::min(_vec.cbegin() + last, _vec.cend());
265
266 return RooSpan<const double>(beg, end);
267 }
268
269 inline void loadToNative(std::size_t idx) const {
270 *_nativeBuf = *(_vec.begin() + idx) ;
271 }
272
273 std::size_t size() const { return _vec.size() ; }
274
275 void resize(Int_t siz) {
276 if (siz < Int_t(_vec.capacity()) / 2 && _vec.capacity() > (VECTOR_BUFFER_SIZE / sizeof(Double_t))) {
277 // do an expensive copy, if we save at least a factor 2 in size
278 std::vector<Double_t> tmp;
279 tmp.reserve(std::max(siz, Int_t(VECTOR_BUFFER_SIZE / sizeof(Double_t))));
280 if (!_vec.empty())
281 tmp.assign(_vec.begin(), std::min(_vec.end(), _vec.begin() + siz));
282 if (Int_t(tmp.size()) != siz)
283 tmp.resize(siz);
284 _vec.swap(tmp);
285 } else {
286 _vec.resize(siz);
287 }
288 }
289
290 void reserve(Int_t siz) {
291 _vec.reserve(siz);
292 }
293
294 const std::vector<double>& data() const {
295 return _vec;
296 }
297
298 protected:
299 std::vector<double> _vec;
300
301 private:
302 friend class RooVectorDataStore ;
303 RooAbsReal* _nativeReal ; // Instance which our data belongs to. This is the variable in the dataset.
304 RooAbsReal* _real ; // Instance where we should write data into when load() is called.
309 ClassDef(RealVector,1) // STL-vector-based Data Storage class
310 } ;
311
312
313 class RealFullVector : public RealVector {
314 public:
315 RealFullVector(UInt_t initialCapacity=(VECTOR_BUFFER_SIZE / sizeof(Double_t))) : RealVector(initialCapacity),
316 _bufE(0), _bufEL(0), _bufEH(0),
318 _vecE(0), _vecEL(0), _vecEH(0) {
319 }
320
321 RealFullVector(RooAbsReal* arg, UInt_t initialCapacity=(VECTOR_BUFFER_SIZE / sizeof(Double_t))) :
322 RealVector(arg,initialCapacity),
323 _bufE(0), _bufEL(0), _bufEH(0),
325 _vecE(0), _vecEL(0), _vecEH(0) {
326 }
327
328 virtual ~RealFullVector() {
329 if (_vecE) delete _vecE ;
330 if (_vecEL) delete _vecEL ;
331 if (_vecEH) delete _vecEH ;
332 }
333
334 RealFullVector(const RealFullVector& other, RooAbsReal* real=0) : RealVector(other,real),
335 _bufE(other._bufE), _bufEL(other._bufEL), _bufEH(other._bufEH),
337 _vecE = (other._vecE) ? new std::vector<Double_t>(*other._vecE) : 0 ;
338 _vecEL = (other._vecEL) ? new std::vector<Double_t>(*other._vecEL) : 0 ;
339 _vecEH = (other._vecEH) ? new std::vector<Double_t>(*other._vecEH) : 0 ;
340 }
341
342 RealFullVector(const RealVector& other, RooAbsReal* real=0) : RealVector(other,real),
343 _bufE(0), _bufEL(0), _bufEH(0),
345 _vecE = 0 ;
346 _vecEL = 0 ;
347 _vecEH = 0 ;
348 }
349
351 if (&other==this) return *this;
353 _bufE = other._bufE;
354 _bufEL = other._bufEL;
355 _bufEH = other._bufEH;
356 _nativeBufE = other._nativeBufE;
359 std::vector<Double_t>* src[3] = { other._vecE, other._vecEL, other._vecEH };
360 std::vector<Double_t>* dst[3] = { _vecE, _vecEL, _vecEH };
361 for (unsigned i = 0; i < 3; ++i) {
362 if (src[i]) {
363 if (dst[i]) {
364 if (dst[i]->size() <= src[i]->capacity() / 2 &&
365 src[i]->capacity() > (VECTOR_BUFFER_SIZE / sizeof(Double_t))) {
366 std::vector<Double_t> tmp;
367 tmp.reserve(std::max(src[i]->size(), VECTOR_BUFFER_SIZE / sizeof(Double_t)));
368 tmp.assign(src[i]->begin(), src[i]->end());
369 dst[i]->swap(tmp);
370 } else {
371 *dst[i] = *src[i];
372 }
373 } else {
374 dst[i] = new std::vector<Double_t>(*src[i]);
375 }
376 } else {
377 delete dst[i];
378 dst[i] = 0;
379 }
380 }
381 return *this;
382 }
383
384 void setErrorBuffer(Double_t* newBuf) {
385 /* std::cout << "setErrorBuffer(" << _nativeReal->GetName() << ") newBuf = " << newBuf << std::endl ; */
386 _bufE = newBuf ;
387 if (!_vecE) _vecE = new std::vector<Double_t> ;
388 _vecE->reserve(_vec.capacity()) ;
390 }
391 void setAsymErrorBuffer(Double_t* newBufL, Double_t* newBufH) {
392 _bufEL = newBufL ; _bufEH = newBufH ;
393 if (!_vecEL) {
394 _vecEL = new std::vector<Double_t> ;
395 _vecEH = new std::vector<Double_t> ;
396 _vecEL->reserve(_vec.capacity()) ;
397 _vecEH->reserve(_vec.capacity()) ;
398 }
399 if (!_nativeBufEL) {
402 }
403 }
404
405 inline void loadToNative(Int_t idx) const {
407 if (_vecE) {
408 *_nativeBufE = (*_vecE)[idx] ;
409 }
410 if (_vecEL) {
411 *_nativeBufEL = (*_vecEL)[idx] ;
412 *_nativeBufEH = (*_vecEH)[idx] ;
413 }
414 }
415
416 void fill() {
418 if (_vecE) _vecE->push_back(*_bufE) ;
419 if (_vecEL) _vecEL->push_back(*_bufEL) ;
420 if (_vecEH) _vecEH->push_back(*_bufEH) ;
421 } ;
422
423 void write(Int_t i) {
425 if (_vecE) (*_vecE)[i] = *_bufE ;
426 if (_vecEL) (*_vecEL)[i] = *_bufEL ;
427 if (_vecEH) (*_vecEH)[i] = *_bufEH ;
428 }
429
430 void reset() {
432 if (_vecE) {
433 std::vector<Double_t> tmp;
434 _vecE->swap(tmp);
435 }
436 if (_vecEL) {
437 std::vector<Double_t> tmp;
438 _vecEL->swap(tmp);
439 }
440 if (_vecEH) {
441 std::vector<Double_t> tmp;
442 _vecEH->swap(tmp);
443 }
444 }
445
446 inline void get(Int_t idx) const {
447 RealVector::load(idx) ;
448 if (_vecE) *_bufE = (*_vecE)[idx];
449 if (_vecEL) *_bufEL = (*_vecEL)[idx] ;
450 if (_vecEH) *_bufEH = (*_vecEH)[idx] ;
451 }
452
453 void resize(Int_t siz) {
455 std::vector<Double_t>* vlist[3] = { _vecE, _vecEL, _vecEH };
456 for (unsigned i = 0; i < 3; ++i) {
457 if (!vlist[i]) continue;
458 if (vlist[i]) {
459 if (siz < Int_t(vlist[i]->capacity()) / 2 && vlist[i]->capacity() > (VECTOR_BUFFER_SIZE / sizeof(Double_t))) {
460 // if we gain a factor of 2 in memory, we copy and swap
461 std::vector<Double_t> tmp;
462 tmp.reserve(std::max(siz, Int_t(VECTOR_BUFFER_SIZE / sizeof(Double_t))));
463 if (!vlist[i]->empty())
464 tmp.assign(vlist[i]->begin(),
465 std::min(_vec.end(), _vec.begin() + siz));
466 if (Int_t(tmp.size()) != siz)
467 tmp.resize(siz);
468 vlist[i]->swap(tmp);
469 } else {
470 vlist[i]->resize(siz);
471 }
472 }
473 }
474 }
475
476 void reserve(Int_t siz) {
478 if (_vecE) _vecE->reserve(siz);
479 if (_vecEL) _vecEL->reserve(siz);
480 if (_vecEH) _vecEH->reserve(siz);
481 }
482
483 private:
484 friend class RooVectorDataStore ;
491 std::vector<double> *_vecE, *_vecEL, *_vecEH ;
492 ClassDef(RealFullVector,1) // STL-vector-based Data Storage class
493 } ;
494
495
496 class CatVector {
497 public:
499 _cat(nullptr), _buf(nullptr), _nativeBuf(nullptr)
500 {
501 _vec.reserve(initialCapacity);
502 }
503
505 _cat(cat), _buf(nullptr), _nativeBuf(nullptr)
506 {
507 _vec.reserve(initialCapacity);
508 }
509
510 virtual ~CatVector() {
511 }
512
513 CatVector(const CatVector& other, RooAbsCategory* cat = nullptr) :
514 _cat(cat?cat:other._cat), _buf(other._buf), _nativeBuf(other._nativeBuf), _vec(other._vec)
515 {
516
517 }
518
520 if (&other==this) return *this;
521 _cat = other._cat;
522 _buf = other._buf;
523 _nativeBuf = other._nativeBuf;
524 if (other._vec.size() <= _vec.capacity() / 2 && _vec.capacity() > VECTOR_BUFFER_SIZE) {
525 std::vector<RooAbsCategory::value_type> tmp;
526 tmp.reserve(std::max(other._vec.size(), std::size_t(VECTOR_BUFFER_SIZE)));
527 tmp.assign(other._vec.begin(), other._vec.end());
528 _vec.swap(tmp);
529 } else {
530 _vec = other._vec;
531 }
532
533 return *this;
534 }
535
537 _buf = newBuf ;
538 if (!_nativeBuf) _nativeBuf = newBuf;
539 }
540
542 _nativeBuf = newBuf ? newBuf : _buf;
543 }
544
545 void fill() {
546 _vec.push_back(*_buf) ;
547 }
548
549 void write(std::size_t i) {
550 _vec[i] = *_buf;
551 }
552
553 void reset() {
554 // make sure the vector releases the underlying memory
555 std::vector<RooAbsCategory::value_type> tmp;
556 _vec.swap(tmp);
557 }
558
559 inline void load(std::size_t idx) const {
560 *_buf = _vec[idx];
561 }
562
563 inline void loadToNative(std::size_t idx) const {
564 *_nativeBuf = _vec[idx];
565 }
566
567 std::size_t size() const { return _vec.size() ; }
568
569 void resize(Int_t siz) {
570 if (siz < Int_t(_vec.capacity()) / 2 && _vec.capacity() > VECTOR_BUFFER_SIZE) {
571 // do an expensive copy, if we save at least a factor 2 in size
572 std::vector<RooAbsCategory::value_type> tmp;
573 tmp.reserve(std::max(siz, VECTOR_BUFFER_SIZE));
574 if (!_vec.empty())
575 tmp.assign(_vec.begin(), std::min(_vec.end(), _vec.begin() + siz));
576 if (Int_t(tmp.size()) != siz)
577 tmp.resize(siz);
578 _vec.swap(tmp);
579 } else {
580 _vec.resize(siz);
581 }
582 }
583
584 void reserve(Int_t siz) {
585 _vec.reserve(siz);
586 }
587
588 void setBufArg(RooAbsCategory* arg) { _cat = arg; }
589 const RooAbsCategory* bufArg() const { return _cat; }
590
591 private:
592 friend class RooVectorDataStore ;
596 std::vector<RooAbsCategory::value_type> _vec;
597 ClassDef(CatVector,2) // STL-vector-based Data Storage class
598 } ;
599
600
601 protected:
602
603 friend class RooAbsReal ;
604 friend class RooAbsCategory ;
605 friend class RooRealVar ;
606 std::vector<RealVector*>& realStoreList() { return _realStoreList ; }
607 std::vector<RealFullVector*>& realfStoreList() { return _realfStoreList ; }
608 std::vector<CatVector*>& catStoreList() { return _catStoreList ; }
609
610 CatVector* addCategory(RooAbsCategory* cat);
611
612 RealVector* addReal(RooAbsReal* real);
613
615
617
619
620 RealFullVector* addRealFull(RooAbsReal* real);
621
622 virtual Bool_t hasFilledCache() const override { return _cache ? kTRUE : kFALSE ; }
623
624 void forceCacheUpdate() override;
625
626 private:
628 RooRealVar* _wgtVar ; // Pointer to weight variable (if set)
629
630 std::vector<RealVector*> _realStoreList ;
631 std::vector<RealFullVector*> _realfStoreList ;
632 std::vector<CatVector*> _catStoreList ;
633 std::vector<double> _weights;
634
635 void setAllBuffersNative() ;
636
639
640 const Double_t* _extWgtArray ; //! External weight array
641 const Double_t* _extWgtErrLoArray ; //! External weight array - low error
642 const Double_t* _extWgtErrHiArray ; //! External weight array - high error
643 const Double_t* _extSumW2Array ; //! External sum of weights array
644
645 mutable std::size_t _currentWeightIndex{0}; //
646
647 RooVectorDataStore* _cache ; //! Optimization cache
648 RooAbsArg* _cacheOwner ; //! Cache owner
649
650 Bool_t _forcedUpdate ; //! Request for forced cache update
651
652 ClassDefOverride(RooVectorDataStore, 5) // STL-vector-based Data Storage class
653};
654
655
656#endif
#define WRITE_TSTRING_COMPATIBLE_CONSTRUCTOR(Class_t)
Definition: RooAbsData.h:66
#define VECTOR_BUFFER_SIZE
int Int_t
Definition: RtypesCore.h:45
unsigned int UInt_t
Definition: RtypesCore.h:46
const Bool_t kFALSE
Definition: RtypesCore.h:101
bool Bool_t
Definition: RtypesCore.h:63
double Double_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:100
#define ClassDef(name, id)
Definition: Rtypes.h:325
#define ClassDefOverride(name, id)
Definition: Rtypes.h:329
char name[80]
Definition: TGX11.cxx:110
float type_of_call hi(const int &, const int &)
char * Form(const char *fmt,...)
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:72
RooAbsCategory is the base class for objects that represent a discrete value with a finite number of ...
int value_type
The type used to denote a specific category state.
RooAbsDataStore is the abstract base class for data collection that use a TTree as internal storage m...
const RooArgSet & cachedVars() const
virtual Double_t weight() const =0
virtual const RooArgSet * get() const
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:61
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition: RooAbsReal.h:91
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:35
RooChangeTracker is a meta object that tracks value changes in a given set of RooAbsArgs by registeri...
Bool_t hasChanged(Bool_t clearState)
Returns true if state has changed since last call with clearState=kTRUE.
RooArgSet parameters() const
A RooFormulaVar is a generic implementation of a real-valued object, which takes a RooArgList of serv...
Definition: RooFormulaVar.h:30
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:39
A simple container to hold a batch of data values.
Definition: RooSpan.h:34
RooTreeDataStore is a TTree-backed data storage.
void setBufArg(RooAbsCategory *arg)
void setBuffer(RooAbsCategory::value_type *newBuf)
CatVector(UInt_t initialCapacity=VECTOR_BUFFER_SIZE)
RooAbsCategory::value_type * _buf
CatVector(RooAbsCategory *cat, UInt_t initialCapacity=VECTOR_BUFFER_SIZE)
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)
void loadToNative(std::size_t idx) const
const RooAbsCategory * bufArg() const
CatVector(const CatVector &other, RooAbsCategory *cat=nullptr)
void setAsymErrorBuffer(Double_t *newBufL, Double_t *newBufH)
RealFullVector(const RealFullVector &other, RooAbsReal *real=0)
RealFullVector(RooAbsReal *arg, UInt_t initialCapacity=(VECTOR_BUFFER_SIZE/sizeof(Double_t)))
RealFullVector(const RealVector &other, RooAbsReal *real=0)
RealFullVector & operator=(const RealFullVector &other)
RealFullVector(UInt_t initialCapacity=(VECTOR_BUFFER_SIZE/sizeof(Double_t)))
RealVector(RooAbsReal *arg, UInt_t initialCapacity=(VECTOR_BUFFER_SIZE/sizeof(Double_t)))
RealVector & operator=(const RealVector &other)
void setBuffer(RooAbsReal *real, Double_t *newBuf)
const RooAbsReal * bufArg() const
void setNset(RooArgSet *newNset)
void setNativeBuffer(Double_t *newBuf=0)
void loadToNative(std::size_t idx) const
RooSpan< const double > getRange(std::size_t first, std::size_t last) const
void setDependents(const RooArgSet &deps)
RealVector(UInt_t initialCapacity=(VECTOR_BUFFER_SIZE/sizeof(Double_t)))
void load(std::size_t idx) const
RealVector(const RealVector &other, RooAbsReal *real=0)
const std::vector< double > & data() const
RooVectorDataStore uses std::vectors to store data columns.
const RooArgSet & row()
const Double_t * _extWgtErrHiArray
External weight array - low error.
Bool_t hasAsymError(RooAbsReal *real)
virtual void resetCache() override
std::vector< CatVector * > & catStoreList()
virtual Int_t numEntries() const override
virtual 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
const RooVectorDataStore * cache() const
Bool_t isFullReal(RooAbsReal *real)
RooVectorDataStore * _cache
virtual void resetBuffers() override
RooRealVar * weightVar(const RooArgSet &allVars, const char *wgtName)
Utility function for constructors Return pointer to weight variable if it is defined.
std::vector< RealVector * > _realStoreList
std::vector< double > _weights
CatVector * addCategory(RooAbsCategory *cat)
virtual RooArgSet * addColumns(const RooArgList &varList) override
Utility function to add multiple columns in one call See addColumn() for details.
void loadValues(const RooAbsDataStore *tds, const RooFormulaVar *select=0, const char *rangeName=0, std::size_t nStart=0, std::size_t nStop=std::numeric_limits< std::size_t >::max()) override
virtual Bool_t hasFilledCache() const override
virtual RooAbsDataStore * clone(const RooArgSet &vars, const char *newname=0) const override
virtual Bool_t changeObservableName(const char *from, const char *to) override
RealFullVector * addRealFull(RooAbsReal *real)
const Double_t * _extWgtErrLoArray
External weight array.
virtual const RooArgSet * getNative(Int_t index) const
Load the n-th data point (n='index') into the variables of this dataset, and return a pointer to the ...
Double_t weight() const override
Return the weight of the last-retrieved data point.
virtual Int_t fill() override
Interface function to TTree::Fill.
std::vector< RealFullVector * > & realfStoreList()
virtual void append(RooAbsDataStore &other) override
void setExternalWeightArray(const Double_t *arrayWgt, const Double_t *arrayWgtErrLo, const Double_t *arrayWgtErrHi, const Double_t *arraySumW2) override
std::vector< CatVector * > _catStoreList
Bool_t _forcedUpdate
Cache owner.
const Double_t * _extSumW2Array
External weight array - high error.
virtual void reset() override
RooBatchCompute::RunContext getBatches(std::size_t first, std::size_t len) const override
Return batches of the data columns for the requested events.
virtual Bool_t isWeighted() const override
virtual void attachBuffers(const RooArgSet &extObs) override
virtual void setDirtyProp(Bool_t flag) override
RooAbsDataStore * merge(const RooArgSet &allvars, std::list< RooAbsDataStore * > dstoreList) override
Merge columns of supplied data set(s) with this data set.
virtual void cacheArgs(const RooAbsArg *owner, RooArgSet &varSet, const RooArgSet *nset=0, Bool_t skipZeroWeights=kTRUE) override
Cache given RooAbsArgs: The tree is given direct write access of the args internal cache the args val...
virtual RooAbsDataStore * clone(const char *newname=0) const override
RealVector * addReal(RooAbsReal *real)
virtual Double_t weightError(RooAbsData::ErrorType etype=RooAbsData::Poisson) const override
Return the error of the current weight.
void forceCacheUpdate() override
std::vector< RealVector * > & realStoreList()
virtual void recalculateCache(const RooArgSet *, Int_t firstEvent, Int_t lastEvent, Int_t stepSize, Bool_t skipZeroWeights) override
std::size_t size() const
Get size of stored dataset.
Bool_t hasError(RooAbsReal *real)
void reserve(Int_t nEvt)
virtual RooSpan< 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).
virtual const RooArgSet * get() const
virtual ~RooVectorDataStore()
Destructor.
virtual Double_t sumEntries() const override
RooArgSet varsNoWeight(const RooArgSet &allVars, const char *wgtName)
Utility function for constructors Return RooArgSet that is copy of allVars minus variable matching wg...
const Double_t * _extWgtArray
std::size_t _currentWeightIndex
External sum of weights array.
virtual RooAbsArg * addColumn(RooAbsArg &var, Bool_t adjustRange=kTRUE) override
Add a new column to the data set which holds the pre-calculated values of 'newVar'.
virtual const RooAbsArg * cacheOwner() override
virtual void setArgStatus(const RooArgSet &set, Bool_t active) override
Disabling of branches is (intentionally) not implemented in vector data stores (as the doesn't result...
RooAbsArg * _cacheOwner
Optimization cache.
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
A TTree represents a columnar dataset.
Definition: TTree.h:79
basic_string_view< char > string_view
Definition: first.py:1
This struct enables passing computation data around between elements of a computation graph.
Definition: RunContext.h:31