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 <list>
20#include <vector>
21#include <string>
22#include <algorithm>
23#include "RooAbsDataStore.h"
24#include "TString.h"
25#include "RooAbsCategory.h"
26#include "RooAbsReal.h"
27#include "RooChangeTracker.h"
28
29#define VECTOR_BUFFER_SIZE 1024
30
31class RooAbsArg ;
32class RooArgList ;
33class TTree ;
34class RooFormulaVar ;
35class RooArgSet ;
36
38public:
39
41
42 // Empty ctor
43 RooVectorDataStore(const char* name, const char* title, const RooArgSet& vars, const char* wgtVarName=0) ;
44 virtual RooAbsDataStore* clone(const char* newname=0) const override { return new RooVectorDataStore(*this,newname) ; }
45 virtual RooAbsDataStore* clone(const RooArgSet& vars, const char* newname=0) const override { return new RooVectorDataStore(*this,vars,newname) ; }
46
47 RooVectorDataStore(const RooVectorDataStore& other, const char* newname=0) ;
48 RooVectorDataStore(const RooTreeDataStore& other, const RooArgSet& vars, const char* newname=0) ;
49 RooVectorDataStore(const RooVectorDataStore& other, const RooArgSet& vars, const char* newname=0) ;
50
51
52 RooVectorDataStore(const char *name, const char *title, RooAbsDataStore& tds,
53 const RooArgSet& vars, const RooFormulaVar* cutVar, const char* cutRange,
54 std::size_t nStart, std::size_t nStop, Bool_t /*copyCache*/, const char* wgtVarName=0) ;
55
56 virtual ~RooVectorDataStore() ;
57
58private:
59 RooArgSet varsNoWeight(const RooArgSet& allVars, const char* wgtName);
60 RooRealVar* weightVar(const RooArgSet& allVars, const char* wgtName);
61
62 // reserve storage for nEvt entries
63 void reserve(Int_t nEvt);
64
65public:
66 // Write current row
67 virtual Int_t fill() override;
68
69 // Retrieve a row
71 virtual const RooArgSet* get(Int_t index) const override;
72
73 virtual const RooArgSet* getNative(Int_t index) const;
74
75 virtual Double_t weight() const override;
77 virtual void weightError(Double_t& lo, Double_t& hi, RooAbsData::ErrorType etype=RooAbsData::Poisson) const override;
78 virtual Double_t weight(Int_t index) const override;
79 virtual Bool_t isWeighted() const override { return (_wgtVar!=0||_extWgtArray!=0) ; }
80
81 virtual std::vector<RooSpan<const double>> getBatch(std::size_t first, std::size_t last) const override;
82 virtual RooSpan<const double> getWeightBatch(std::size_t first, std::size_t len) const override;
83
84 // Change observable name
85 virtual Bool_t changeObservableName(const char* from, const char* to) override;
86
87 // Add one or more columns
88 virtual RooAbsArg* addColumn(RooAbsArg& var, Bool_t adjustRange=kTRUE) override;
89 virtual RooArgSet* addColumns(const RooArgList& varList) override;
90
91 // Merge column-wise
92 RooAbsDataStore* merge(const RooArgSet& allvars, std::list<RooAbsDataStore*> dstoreList) override;
93
94 // Add rows
95 virtual void append(RooAbsDataStore& other) override;
96
97 // General & bookkeeping methods
98 virtual Bool_t valid() const override;
99 virtual Int_t numEntries() const override { return static_cast<int>(size()); }
100 virtual Double_t sumEntries() const override { return _sumWeight ; }
101 /// Get size of stored dataset.
102 std::size_t size() const {
103 if (!_realStoreList.empty()) {
104 return _realStoreList.front()->size();
105 } else if (!_realfStoreList.empty()) {
106 return _realfStoreList.front()->size();
107 } else if (!_catStoreList.empty()) {
108 return _catStoreList.front()->size();
109 }
110
111 return 0;
112 }
113 virtual void reset() override;
114
115 // Buffer redirection routines used in inside RooAbsOptTestStatistics
116 virtual void attachBuffers(const RooArgSet& extObs) override;
117 virtual void resetBuffers() override;
118
119
120 // Constant term optimizer interface
121 virtual const RooAbsArg* cacheOwner() override { return _cacheOwner ; }
122 virtual void cacheArgs(const RooAbsArg* owner, RooArgSet& varSet, const RooArgSet* nset=0, Bool_t skipZeroWeights=kTRUE) override;
123 virtual void attachCache(const RooAbsArg* newOwner, const RooArgSet& cachedVars) override;
124 virtual void resetCache() override;
125 virtual void recalculateCache(const RooArgSet* /*proj*/, Int_t firstEvent, Int_t lastEvent, Int_t stepSize, Bool_t skipZeroWeights) override;
126
127 virtual void setArgStatus(const RooArgSet& set, Bool_t active) override;
128
129 const RooVectorDataStore* cache() const { return _cache ; }
130
131 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;
132
133 void dump() override;
134
135 void setExternalWeightArray(const Double_t* arrayWgt, const Double_t* arrayWgtErrLo,
136 const Double_t* arrayWgtErrHi, const Double_t* arraySumW2) override {
137 _extWgtArray = arrayWgt ;
138 _extWgtErrLoArray = arrayWgtErrLo ;
139 _extWgtErrHiArray = arrayWgtErrHi ;
140 _extSumW2Array = arraySumW2 ;
141 }
142
143 virtual void setDirtyProp(Bool_t flag) override {
144 _doDirtyProp = flag ;
145 if (_cache) {
146 _cache->setDirtyProp(flag) ;
147 }
148 }
149
150 const RooArgSet& row() { return _varsww ; }
151
153 public:
154
155 RealVector(UInt_t initialCapacity=(VECTOR_BUFFER_SIZE / sizeof(Double_t))) :
156 _nativeReal(0), _real(0), _buf(0), _nativeBuf(0), _tracker(0), _nset(0) {
157 _vec.reserve(initialCapacity);
158 }
159
160 RealVector(RooAbsReal* arg, UInt_t initialCapacity=(VECTOR_BUFFER_SIZE / sizeof(Double_t))) :
161 _nativeReal(arg), _real(0), _buf(0), _nativeBuf(0), _tracker(0), _nset(0) {
162 _vec.reserve(initialCapacity);
163 }
164
165 virtual ~RealVector() {
166 delete _tracker;
167 if (_nset) delete _nset ;
168 }
169
170 RealVector(const RealVector& other, RooAbsReal* real=0) :
171 _vec(other._vec), _nativeReal(real?real:other._nativeReal), _real(real?real:other._real), _buf(other._buf), _nativeBuf(other._nativeBuf), _nset(0) {
172 if (other._tracker) {
173 _tracker = new RooChangeTracker(Form("track_%s",_nativeReal->GetName()),"tracker",other._tracker->parameters()) ;
174 } else {
175 _tracker = 0 ;
176 }
177 if (other._nset) {
178 _nset = new RooArgSet(*other._nset) ;
179 }
180 }
181
183 if (&other==this) return *this;
184 _nativeReal = other._nativeReal;
185 _real = other._real;
186 _buf = other._buf;
187 _nativeBuf = other._nativeBuf;
188 if (other._vec.size() <= _vec.capacity() / 2 && _vec.capacity() > (VECTOR_BUFFER_SIZE / sizeof(Double_t))) {
189 std::vector<Double_t> tmp;
190 tmp.reserve(std::max(other._vec.size(), VECTOR_BUFFER_SIZE / sizeof(Double_t)));
191 tmp.assign(other._vec.begin(), other._vec.end());
192 _vec.swap(tmp);
193 } else {
194 _vec = other._vec;
195 }
196
197 return *this;
198 }
199
200 void setNset(RooArgSet* newNset) { _nset = newNset ? new RooArgSet(*newNset) : 0 ; }
201
202 RooArgSet* nset() const { return _nset ; }
203
204 void setBufArg(RooAbsReal* arg) { _nativeReal = arg ; }
205 const RooAbsReal* bufArg() const { return _nativeReal ; }
206
207 void setBuffer(RooAbsReal* real, Double_t* newBuf) {
208 _real = real ;
209 _buf = newBuf ;
210 if (_nativeBuf==0) {
211 _nativeBuf=newBuf ;
212 }
213 }
214
215 void setNativeBuffer(Double_t* newBuf=0) {
216 _nativeBuf = newBuf ? newBuf : _buf ;
217 }
218
219 void setDependents(const RooArgSet& deps) {
220 if (_tracker) {
221 delete _tracker ;
222 }
223 _tracker = new RooChangeTracker(Form("track_%s",_nativeReal->GetName()),"tracker",deps) ;
224 }
225
227 if (!_tracker) return kFALSE ;
228 return _tracker->hasChanged(kTRUE) ;
229 }
230
231 void fill() {
232 _vec.push_back(*_buf);
233 }
234
235 void write(Int_t i) {
236 assert(static_cast<std::size_t>(i) < _vec.size());
237 _vec[i] = *_buf ;
238 }
239
240 void reset() {
241 _vec.clear();
242 }
243
244 inline void load(std::size_t idx) const {
245 assert(idx < _vec.size());
246 *_buf = *(_vec.begin() + idx) ;
247 }
248
249 RooSpan<const double> getRange(std::size_t first, std::size_t last) const {
250 auto beg = std::min(_vec.cbegin() + first, _vec.cend());
251 auto end = std::min(_vec.cbegin() + last, _vec.cend());
252
253 return RooSpan<const double>(beg, end);
254 }
255
256 inline void loadToNative(std::size_t idx) const {
257 *_nativeBuf = *(_vec.begin() + idx) ;
258 }
259
260 std::size_t size() const { return _vec.size() ; }
261
262 void resize(Int_t siz) {
263 if (siz < Int_t(_vec.capacity()) / 2 && _vec.capacity() > (VECTOR_BUFFER_SIZE / sizeof(Double_t))) {
264 // do an expensive copy, if we save at least a factor 2 in size
265 std::vector<Double_t> tmp;
266 tmp.reserve(std::max(siz, Int_t(VECTOR_BUFFER_SIZE / sizeof(Double_t))));
267 if (!_vec.empty())
268 tmp.assign(_vec.begin(), std::min(_vec.end(), _vec.begin() + siz));
269 if (Int_t(tmp.size()) != siz)
270 tmp.resize(siz);
271 _vec.swap(tmp);
272 } else {
273 _vec.resize(siz);
274 }
275 }
276
277 void reserve(Int_t siz) {
278 _vec.reserve(siz);
279 }
280
281 const std::vector<double>& data() const {
282 return _vec;
283 }
284
285 protected:
286 std::vector<double> _vec;
287
288 private:
289 friend class RooVectorDataStore ;
296 ClassDef(RealVector,1) // STL-vector-based Data Storage class
297 } ;
298
299
300 class RealFullVector : public RealVector {
301 public:
302 RealFullVector(UInt_t initialCapacity=(VECTOR_BUFFER_SIZE / sizeof(Double_t))) : RealVector(initialCapacity),
303 _bufE(0), _bufEL(0), _bufEH(0),
305 _vecE(0), _vecEL(0), _vecEH(0) {
306 }
307
308 RealFullVector(RooAbsReal* arg, UInt_t initialCapacity=(VECTOR_BUFFER_SIZE / sizeof(Double_t))) :
309 RealVector(arg,initialCapacity),
310 _bufE(0), _bufEL(0), _bufEH(0),
312 _vecE(0), _vecEL(0), _vecEH(0) {
313 }
314
315 virtual ~RealFullVector() {
316 if (_vecE) delete _vecE ;
317 if (_vecEL) delete _vecEL ;
318 if (_vecEH) delete _vecEH ;
319 }
320
321 RealFullVector(const RealFullVector& other, RooAbsReal* real=0) : RealVector(other,real),
322 _bufE(other._bufE), _bufEL(other._bufEL), _bufEH(other._bufEH),
324 _vecE = (other._vecE) ? new std::vector<Double_t>(*other._vecE) : 0 ;
325 _vecEL = (other._vecEL) ? new std::vector<Double_t>(*other._vecEL) : 0 ;
326 _vecEH = (other._vecEH) ? new std::vector<Double_t>(*other._vecEH) : 0 ;
327 }
328
329 RealFullVector(const RealVector& other, RooAbsReal* real=0) : RealVector(other,real),
330 _bufE(0), _bufEL(0), _bufEH(0),
332 _vecE = 0 ;
333 _vecEL = 0 ;
334 _vecEH = 0 ;
335 }
336
338 if (&other==this) return *this;
340 _bufE = other._bufE;
341 _bufEL = other._bufEL;
342 _bufEH = other._bufEH;
343 _nativeBufE = other._nativeBufE;
346 std::vector<Double_t>* src[3] = { other._vecE, other._vecEL, other._vecEH };
347 std::vector<Double_t>* dst[3] = { _vecE, _vecEL, _vecEH };
348 for (unsigned i = 0; i < 3; ++i) {
349 if (src[i]) {
350 if (dst[i]) {
351 if (dst[i]->size() <= src[i]->capacity() / 2 &&
352 src[i]->capacity() > (VECTOR_BUFFER_SIZE / sizeof(Double_t))) {
353 std::vector<Double_t> tmp;
354 tmp.reserve(std::max(src[i]->size(), VECTOR_BUFFER_SIZE / sizeof(Double_t)));
355 tmp.assign(src[i]->begin(), src[i]->end());
356 dst[i]->swap(tmp);
357 } else {
358 *dst[i] = *src[i];
359 }
360 } else {
361 dst[i] = new std::vector<Double_t>(*src[i]);
362 }
363 } else {
364 delete dst[i];
365 dst[i] = 0;
366 }
367 }
368 return *this;
369 }
370
371 void setErrorBuffer(Double_t* newBuf) {
372 /* std::cout << "setErrorBuffer(" << _nativeReal->GetName() << ") newBuf = " << newBuf << std::endl ; */
373 _bufE = newBuf ;
374 if (!_vecE) _vecE = new std::vector<Double_t> ;
375 _vecE->reserve(_vec.capacity()) ;
377 }
378 void setAsymErrorBuffer(Double_t* newBufL, Double_t* newBufH) {
379 _bufEL = newBufL ; _bufEH = newBufH ;
380 if (!_vecEL) {
381 _vecEL = new std::vector<Double_t> ;
382 _vecEH = new std::vector<Double_t> ;
383 _vecEL->reserve(_vec.capacity()) ;
384 _vecEH->reserve(_vec.capacity()) ;
385 }
386 if (!_nativeBufEL) {
389 }
390 }
391
392 inline void loadToNative(Int_t idx) const {
394 if (_vecE) {
395 *_nativeBufE = (*_vecE)[idx] ;
396 }
397 if (_vecEL) {
398 *_nativeBufEL = (*_vecEL)[idx] ;
399 *_nativeBufEH = (*_vecEH)[idx] ;
400 }
401 }
402
403 void fill() {
405 if (_vecE) _vecE->push_back(*_bufE) ;
406 if (_vecEL) _vecEL->push_back(*_bufEL) ;
407 if (_vecEH) _vecEH->push_back(*_bufEH) ;
408 } ;
409
410 void write(Int_t i) {
412 if (_vecE) (*_vecE)[i] = *_bufE ;
413 if (_vecEL) (*_vecEL)[i] = *_bufEL ;
414 if (_vecEH) (*_vecEH)[i] = *_bufEH ;
415 }
416
417 void reset() {
419 if (_vecE) {
420 std::vector<Double_t> tmp;
421 _vecE->swap(tmp);
422 }
423 if (_vecEL) {
424 std::vector<Double_t> tmp;
425 _vecEL->swap(tmp);
426 }
427 if (_vecEH) {
428 std::vector<Double_t> tmp;
429 _vecEH->swap(tmp);
430 }
431 }
432
433 inline void get(Int_t idx) const {
434 RealVector::load(idx) ;
435 if (_vecE) *_bufE = (*_vecE)[idx];
436 if (_vecEL) *_bufEL = (*_vecEL)[idx] ;
437 if (_vecEH) *_bufEH = (*_vecEH)[idx] ;
438 }
439
440 void resize(Int_t siz) {
442 std::vector<Double_t>* vlist[3] = { _vecE, _vecEL, _vecEH };
443 for (unsigned i = 0; i < 3; ++i) {
444 if (!vlist[i]) continue;
445 if (vlist[i]) {
446 if (siz < Int_t(vlist[i]->capacity()) / 2 && vlist[i]->capacity() > (VECTOR_BUFFER_SIZE / sizeof(Double_t))) {
447 // if we gain a factor of 2 in memory, we copy and swap
448 std::vector<Double_t> tmp;
449 tmp.reserve(std::max(siz, Int_t(VECTOR_BUFFER_SIZE / sizeof(Double_t))));
450 if (!vlist[i]->empty())
451 tmp.assign(vlist[i]->begin(),
452 std::min(_vec.end(), _vec.begin() + siz));
453 if (Int_t(tmp.size()) != siz)
454 tmp.resize(siz);
455 vlist[i]->swap(tmp);
456 } else {
457 vlist[i]->resize(siz);
458 }
459 }
460 }
461 }
462
463 void reserve(Int_t siz) {
465 if (_vecE) _vecE->reserve(siz);
466 if (_vecEL) _vecEL->reserve(siz);
467 if (_vecEH) _vecEH->reserve(siz);
468 }
469
470 private:
471 friend class RooVectorDataStore ;
478 std::vector<double> *_vecE, *_vecEL, *_vecEH ;
479 ClassDef(RealFullVector,1) // STL-vector-based Data Storage class
480 } ;
481
482
483 class CatVector {
484 public:
486 _cat(nullptr), _buf(nullptr), _nativeBuf(nullptr)
487 {
488 _vec.reserve(initialCapacity);
489 }
490
492 _cat(cat), _buf(nullptr), _nativeBuf(nullptr)
493 {
494 _vec.reserve(initialCapacity);
495 }
496
497 virtual ~CatVector() {
498 }
499
500 CatVector(const CatVector& other, RooAbsCategory* cat = nullptr) :
501 _cat(cat?cat:other._cat), _buf(other._buf), _nativeBuf(other._nativeBuf), _vec(other._vec)
502 {
503
504 }
505
507 if (&other==this) return *this;
508 _cat = other._cat;
509 _buf = other._buf;
510 _nativeBuf = other._nativeBuf;
511 if (other._vec.size() <= _vec.capacity() / 2 && _vec.capacity() > VECTOR_BUFFER_SIZE) {
512 std::vector<RooAbsCategory::value_type> tmp;
513 tmp.reserve(std::max(other._vec.size(), std::size_t(VECTOR_BUFFER_SIZE)));
514 tmp.assign(other._vec.begin(), other._vec.end());
515 _vec.swap(tmp);
516 } else {
517 _vec = other._vec;
518 }
519
520 return *this;
521 }
522
524 _buf = newBuf ;
525 if (!_nativeBuf) _nativeBuf = newBuf;
526 }
527
529 _nativeBuf = newBuf ? newBuf : _buf;
530 }
531
532 void fill() {
533 _vec.push_back(*_buf) ;
534 }
535
536 void write(std::size_t i) {
537 _vec[i] = *_buf;
538 }
539
540 void reset() {
541 // make sure the vector releases the underlying memory
542 std::vector<RooAbsCategory::value_type> tmp;
543 _vec.swap(tmp);
544 }
545
546 inline void load(std::size_t idx) const {
547 *_buf = _vec[idx];
548 }
549
550 inline void loadToNative(std::size_t idx) const {
551 *_nativeBuf = _vec[idx];
552 }
553
554 std::size_t size() const { return _vec.size() ; }
555
556 void resize(Int_t siz) {
557 if (siz < Int_t(_vec.capacity()) / 2 && _vec.capacity() > VECTOR_BUFFER_SIZE) {
558 // do an expensive copy, if we save at least a factor 2 in size
559 std::vector<RooAbsCategory::value_type> tmp;
560 tmp.reserve(std::max(siz, VECTOR_BUFFER_SIZE));
561 if (!_vec.empty())
562 tmp.assign(_vec.begin(), std::min(_vec.end(), _vec.begin() + siz));
563 if (Int_t(tmp.size()) != siz)
564 tmp.resize(siz);
565 _vec.swap(tmp);
566 } else {
567 _vec.resize(siz);
568 }
569 }
570
571 void reserve(Int_t siz) {
572 _vec.reserve(siz);
573 }
574
575 void setBufArg(RooAbsCategory* arg) { _cat = arg; }
576 const RooAbsCategory* bufArg() const { return _cat; }
577
578 private:
579 friend class RooVectorDataStore ;
583 std::vector<RooAbsCategory::value_type> _vec;
584 ClassDef(CatVector,2) // STL-vector-based Data Storage class
585 } ;
586
587
588 protected:
589
590 friend class RooAbsReal ;
591 friend class RooAbsCategory ;
592 friend class RooRealVar ;
593 std::vector<RealVector*>& realStoreList() { return _realStoreList ; }
594 std::vector<RealFullVector*>& realfStoreList() { return _realfStoreList ; }
595 std::vector<CatVector*>& catStoreList() { return _catStoreList ; }
596
597 CatVector* addCategory(RooAbsCategory* cat);
598
599 RealVector* addReal(RooAbsReal* real);
600
602
604
606
607 RealFullVector* addRealFull(RooAbsReal* real);
608
609 virtual Bool_t hasFilledCache() const override { return _cache ? kTRUE : kFALSE ; }
610
611 void forceCacheUpdate() override;
612
613 private:
615 RooRealVar* _wgtVar ; // Pointer to weight variable (if set)
616
617 std::vector<RealVector*> _realStoreList ;
618 std::vector<RealFullVector*> _realfStoreList ;
619 std::vector<CatVector*> _catStoreList ;
620 std::vector<double> _weights;
621
622 void setAllBuffersNative() ;
623
626
627 const Double_t* _extWgtArray ; //! External weight array
628 const Double_t* _extWgtErrLoArray ; //! External weight array - low error
629 const Double_t* _extWgtErrHiArray ; //! External weight array - high error
630 const Double_t* _extSumW2Array ; //! External sum of weights array
631
632 mutable Double_t _curWgt ; // Weight of current event
633 mutable Double_t _curWgtErrLo ; // Weight of current event
634 mutable Double_t _curWgtErrHi ; // Weight of current event
635 mutable Double_t _curWgtErr ; // Weight of current event
636
637 RooVectorDataStore* _cache ; //! Optimization cache
638 RooAbsArg* _cacheOwner ; //! Cache owner
639
640 Bool_t _forcedUpdate ; //! Request for forced cache update
641
642 ClassDefOverride(RooVectorDataStore,4) // STL-vector-based Data Storage class
643};
644
645
646#endif
#define VECTOR_BUFFER_SIZE
int Int_t
Definition: RtypesCore.h:43
unsigned int UInt_t
Definition: RtypesCore.h:44
const Bool_t kFALSE
Definition: RtypesCore.h:90
bool Bool_t
Definition: RtypesCore.h:61
double Double_t
Definition: RtypesCore.h:57
const Bool_t kTRUE
Definition: RtypesCore.h:89
#define ClassDef(name, id)
Definition: Rtypes.h:322
#define ClassDefOverride(name, id)
Definition: Rtypes.h:326
char name[80]
Definition: TGX11.cxx:109
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 (of arbitrary type) an...
Definition: RooAbsArg.h:73
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 const RooArgSet * get() const
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:60
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:21
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
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:29
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:35
A simple container to hold a batch of data values.
Definition: RooSpan.h:32
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 is the abstract base class for data collection that use a TTree as internal storag...
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
virtual std::vector< RooSpan< const double > > getBatch(std::size_t first, std::size_t last) const override
Return a batch of the data columns for all events in [firstEvent, lastEvent[.
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 Bool_t valid() const override
Return true if currently loaded coordinate is considered valid within the current range definitions o...
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 ...
virtual Double_t weight() const override
Return the weight of the n-th data point (n='index') in memory.
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
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()
Double_t _curWgt
External sum of weights array.
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
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:78
Definition: first.py:1