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#include "Rtypes.h"
27
28#include <list>
29#include <vector>
30#include <algorithm>
31
32class RooAbsArg ;
33class RooArgList ;
34class TTree ;
35class RooFormulaVar ;
36class RooArgSet ;
37
38#define VECTOR_BUFFER_SIZE 1024
39
41public:
42
44
45 // Empty ctor
46 RooVectorDataStore(RooStringView name, RooStringView title, const RooArgSet& vars, const char* wgtVarName=0) ;
47
48 RooAbsDataStore* clone(const char* newname=0) const override { return new RooVectorDataStore(*this,newname) ; }
49 RooAbsDataStore* clone(const RooArgSet& vars, const char* newname=0) const override { return new RooVectorDataStore(*this,vars,newname) ; }
50
52 const RooArgSet& vars, const RooFormulaVar* cutVar, const char* cutRange,
53 std::size_t nStart, std::size_t nStop) override;
54
55 RooVectorDataStore(const RooVectorDataStore& other, const char* newname=0) ;
56 RooVectorDataStore(const RooTreeDataStore& other, const RooArgSet& vars, const char* newname=0) ;
57 RooVectorDataStore(const RooVectorDataStore& other, const RooArgSet& vars, const char* newname=0) ;
58
59
61 const RooArgSet& vars, const RooFormulaVar* cutVar, const char* cutRange,
62 std::size_t nStart, std::size_t nStop, const char* wgtVarName=0) ;
63
64 ~RooVectorDataStore() override ;
65
66 /// \class ArraysStruct
67 /// Output struct for the RooVectorDataStore::getArrays() helper function.
68 /// Meant to be used for RooFit internal use and might change without warning.
69 struct ArraysStruct {
70
71 template<class T>
72 struct ArrayInfo {
73 ArrayInfo(RooStringView n, T const* d) : name{n}, data{d} {}
74 std::string name;
75 T const* data;
76 };
77
78 std::vector<ArrayInfo<double>> reals;
79 std::vector<ArrayInfo<RooAbsCategory::value_type>> cats;
80
81 std::size_t size;
82 };
83
84 /// \name Internal RooFit interface.
85 /// The classes and functions in the internal RooFit interface are
86 /// implementation details and not part of the public user interface.
87 /// Everything in this group might change without warning.
88 /// @{
89 ArraysStruct getArrays() const;
90 void recomputeSumWeight();
91 /// @}
92
93private:
94 RooArgSet varsNoWeight(const RooArgSet& allVars, const char* wgtName);
95 RooRealVar* weightVar(const RooArgSet& allVars, const char* wgtName);
96
97 // reserve storage for nEvt entries
98 void reserve(Int_t nEvt);
99
100public:
101 // Write current row
102 Int_t fill() override;
103
104 // Retrieve a row
106 const RooArgSet* get(Int_t index) const override;
107
108 virtual const RooArgSet* getNative(Int_t index) const;
109
111 /// Return the weight of the last-retrieved data point.
112 double weight() const override
113 {
114 if (_extWgtArray)
116 if (_wgtVar)
117 return _wgtVar->getVal();
118
119 return 1.0;
120 }
121 double weightError(RooAbsData::ErrorType etype=RooAbsData::Poisson) const override;
122 void weightError(double& lo, double& hi, RooAbsData::ErrorType etype=RooAbsData::Poisson) const override;
123 bool isWeighted() const override { return _wgtVar || _extWgtArray; }
124
125 RooAbsData::RealSpans getBatches(std::size_t first, std::size_t len) const override;
126 RooAbsData::CategorySpans getCategoryBatches(std::size_t /*first*/, std::size_t len) const override;
127 RooSpan<const double> getWeightBatch(std::size_t first, std::size_t len) const override;
128
129 // Change observable name
130 bool changeObservableName(const char* from, const char* to) override;
131
132 // Add one column
133 RooAbsArg* addColumn(RooAbsArg& var, bool adjustRange=true) override;
134
135 // Merge column-wise
136 RooAbsDataStore* merge(const RooArgSet& allvars, std::list<RooAbsDataStore*> dstoreList) override;
137
138 // Add rows
139 void append(RooAbsDataStore& other) override;
140
141 // General & bookkeeping methods
142 Int_t numEntries() const override { return static_cast<int>(size()); }
143 double sumEntries() const override { return _sumWeight ; }
144 /// Get size of stored dataset.
145 std::size_t size() const {
146 if (!_realStoreList.empty()) {
147 return _realStoreList.front()->size();
148 } else if (!_realfStoreList.empty()) {
149 return _realfStoreList.front()->size();
150 } else if (!_catStoreList.empty()) {
151 return _catStoreList.front()->size();
152 }
153
154 return 0;
155 }
156 void reset() override;
157
158 // Buffer redirection routines used in inside RooAbsOptTestStatistics
159 void attachBuffers(const RooArgSet& extObs) override;
160 void resetBuffers() override;
161
162
163 // Constant term optimizer interface
164 const RooAbsArg* cacheOwner() override { return _cacheOwner ; }
165 void cacheArgs(const RooAbsArg* owner, RooArgSet& varSet, const RooArgSet* nset=0, bool skipZeroWeights=true) override;
166 void attachCache(const RooAbsArg* newOwner, const RooArgSet& cachedVars) override;
167 void resetCache() override;
168 void recalculateCache(const RooArgSet* /*proj*/, Int_t firstEvent, Int_t lastEvent, Int_t stepSize, bool skipZeroWeights) override;
169
170 void setArgStatus(const RooArgSet& set, bool active) override;
171
172 const RooVectorDataStore* cache() const { return _cache ; }
173
174 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;
175
176 void dump() override;
177
178 void setExternalWeightArray(const double* arrayWgt, const double* arrayWgtErrLo,
179 const double* arrayWgtErrHi, const double* arraySumW2) override {
180 _extWgtArray = arrayWgt ;
181 _extWgtErrLoArray = arrayWgtErrLo ;
182 _extWgtErrHiArray = arrayWgtErrHi ;
183 _extSumW2Array = arraySumW2 ;
184 }
185
186 void setDirtyProp(bool flag) override {
187 _doDirtyProp = flag ;
188 if (_cache) {
189 _cache->setDirtyProp(flag) ;
190 }
191 }
192
193 const RooArgSet& row() { return _varsww ; }
194
196 public:
197
198 RealVector(UInt_t initialCapacity=(VECTOR_BUFFER_SIZE / sizeof(double))) :
199 _nativeReal(0), _real(0), _buf(0), _nativeBuf(0), _tracker(0), _nset(0) {
200 _vec.reserve(initialCapacity);
201 }
202
203 RealVector(RooAbsReal* arg, UInt_t initialCapacity=(VECTOR_BUFFER_SIZE / sizeof(double))) :
204 _nativeReal(arg), _real(0), _buf(0), _nativeBuf(0), _tracker(0), _nset(0) {
205 _vec.reserve(initialCapacity);
206 }
207
208 virtual ~RealVector() {
209 delete _tracker;
210 if (_nset) delete _nset ;
211 }
212
213 RealVector(const RealVector& other, RooAbsReal* real=0) :
214 _vec(other._vec), _nativeReal(real?real:other._nativeReal), _real(real?real:other._real), _buf(other._buf), _nativeBuf(other._nativeBuf), _nset(0) {
215 if (other._tracker) {
216 _tracker = new RooChangeTracker(Form("track_%s",_nativeReal->GetName()),"tracker",other._tracker->parameters()) ;
217 } else {
218 _tracker = 0 ;
219 }
220 if (other._nset) {
221 _nset = new RooArgSet(*other._nset) ;
222 }
223 }
224
226 if (&other==this) return *this;
227 _nativeReal = other._nativeReal;
228 _real = other._real;
229 _buf = other._buf;
230 _nativeBuf = other._nativeBuf;
231 if (other._vec.size() <= _vec.capacity() / 2 && _vec.capacity() > (VECTOR_BUFFER_SIZE / sizeof(double))) {
232 std::vector<double> tmp;
233 tmp.reserve(std::max(other._vec.size(), VECTOR_BUFFER_SIZE / sizeof(double)));
234 tmp.assign(other._vec.begin(), other._vec.end());
235 _vec.swap(tmp);
236 } else {
237 _vec = other._vec;
238 }
239
240 return *this;
241 }
242
243 void setNset(RooArgSet* newNset) { _nset = newNset ? new RooArgSet(*newNset) : 0 ; }
244
245 RooArgSet* nset() const { return _nset ; }
246
247 void setBufArg(RooAbsReal* arg) { _nativeReal = arg ; }
248 const RooAbsReal* bufArg() const { return _nativeReal ; }
249
250 void setBuffer(RooAbsReal* real, double* newBuf) {
251 _real = real ;
252 _buf = newBuf ;
253 if (_nativeBuf==0) {
254 _nativeBuf=newBuf ;
255 }
256 }
257
258 void setNativeBuffer(double* newBuf=0) {
259 _nativeBuf = newBuf ? newBuf : _buf ;
260 }
261
262 void setDependents(const RooArgSet& deps) {
263 if (_tracker) {
264 delete _tracker ;
265 }
266 _tracker = new RooChangeTracker(Form("track_%s",_nativeReal->GetName()),"tracker",deps) ;
267 }
268
269 bool needRecalc() {
270 if (!_tracker) return false ;
271 return _tracker->hasChanged(true) ;
272 }
273
274 void fill() {
275 _vec.push_back(*_buf);
276 }
277
278 void write(Int_t i) {
279 assert(static_cast<std::size_t>(i) < _vec.size());
280 _vec[i] = *_buf ;
281 }
282
283 void reset() {
284 _vec.clear();
285 }
286
287 inline void load(std::size_t idx) const {
288 assert(idx < _vec.size());
289 *_buf = *(_vec.begin() + idx) ;
290 }
291
292 RooSpan<const double> getRange(std::size_t first, std::size_t last) const {
293 auto beg = std::min(_vec.cbegin() + first, _vec.cend());
294 auto end = std::min(_vec.cbegin() + last, _vec.cend());
295
296 return RooSpan<const double>(beg, end);
297 }
298
299 inline void loadToNative(std::size_t idx) const {
300 *_nativeBuf = *(_vec.begin() + idx) ;
301 }
302
303 std::size_t size() const { return _vec.size() ; }
304
305 void resize(Int_t siz) {
306 if (siz < Int_t(_vec.capacity()) / 2 && _vec.capacity() > (VECTOR_BUFFER_SIZE / sizeof(double))) {
307 // do an expensive copy, if we save at least a factor 2 in size
308 std::vector<double> tmp;
309 tmp.reserve(std::max(siz, Int_t(VECTOR_BUFFER_SIZE / sizeof(double))));
310 if (!_vec.empty())
311 tmp.assign(_vec.begin(), std::min(_vec.end(), _vec.begin() + siz));
312 if (Int_t(tmp.size()) != siz)
313 tmp.resize(siz);
314 _vec.swap(tmp);
315 } else {
316 _vec.resize(siz);
317 }
318 }
319
320 void reserve(Int_t siz) {
321 _vec.reserve(siz);
322 }
323
324 const std::vector<double>& data() const {
325 return _vec;
326 }
327
328 std::vector<double>& data() { return _vec; }
329
330 protected:
331 std::vector<double> _vec;
332
333 private:
334 friend class RooVectorDataStore ;
335 RooAbsReal* _nativeReal ; ///< Instance which our data belongs to. This is the variable in the dataset.
336 RooAbsReal* _real ; ///< Instance where we should write data into when load() is called.
337 double* _buf ; ///<!
338 double* _nativeBuf ; ///<!
341 ClassDef(RealVector,1) // STL-vector-based Data Storage class
342 } ;
343
344
345 class RealFullVector : public RealVector {
346 public:
347 RealFullVector(UInt_t initialCapacity=(VECTOR_BUFFER_SIZE / sizeof(double))) : RealVector(initialCapacity),
348 _bufE(0), _bufEL(0), _bufEH(0),
350 _vecE(0), _vecEL(0), _vecEH(0) {
351 }
352
353 RealFullVector(RooAbsReal* arg, UInt_t initialCapacity=(VECTOR_BUFFER_SIZE / sizeof(double))) :
354 RealVector(arg,initialCapacity),
355 _bufE(0), _bufEL(0), _bufEH(0),
357 _vecE(0), _vecEL(0), _vecEH(0) {
358 }
359
360 ~RealFullVector() override {
361 if (_vecE) delete _vecE ;
362 if (_vecEL) delete _vecEL ;
363 if (_vecEH) delete _vecEH ;
364 }
365
366 RealFullVector(const RealFullVector& other, RooAbsReal* real=0) : RealVector(other,real),
367 _bufE(other._bufE), _bufEL(other._bufEL), _bufEH(other._bufEH),
369 _vecE = (other._vecE) ? new std::vector<double>(*other._vecE) : 0 ;
370 _vecEL = (other._vecEL) ? new std::vector<double>(*other._vecEL) : 0 ;
371 _vecEH = (other._vecEH) ? new std::vector<double>(*other._vecEH) : 0 ;
372 }
373
374 RealFullVector(const RealVector& other, RooAbsReal* real=0) : RealVector(other,real),
375 _bufE(0), _bufEL(0), _bufEH(0),
377 _vecE = 0 ;
378 _vecEL = 0 ;
379 _vecEH = 0 ;
380 }
381
383 if (&other==this) return *this;
385 _bufE = other._bufE;
386 _bufEL = other._bufEL;
387 _bufEH = other._bufEH;
388 _nativeBufE = other._nativeBufE;
391 std::vector<double>* src[3] = { other._vecE, other._vecEL, other._vecEH };
392 std::vector<double>* dst[3] = { _vecE, _vecEL, _vecEH };
393 for (unsigned i = 0; i < 3; ++i) {
394 if (src[i]) {
395 if (dst[i]) {
396 if (dst[i]->size() <= src[i]->capacity() / 2 &&
397 src[i]->capacity() > (VECTOR_BUFFER_SIZE / sizeof(double))) {
398 std::vector<double> tmp;
399 tmp.reserve(std::max(src[i]->size(), VECTOR_BUFFER_SIZE / sizeof(double)));
400 tmp.assign(src[i]->begin(), src[i]->end());
401 dst[i]->swap(tmp);
402 } else {
403 *dst[i] = *src[i];
404 }
405 } else {
406 dst[i] = new std::vector<double>(*src[i]);
407 }
408 } else {
409 delete dst[i];
410 dst[i] = 0;
411 }
412 }
413 return *this;
414 }
415
416 void setErrorBuffer(double* newBuf) {
417 /* std::cout << "setErrorBuffer(" << _nativeReal->GetName() << ") newBuf = " << newBuf << std::endl ; */
418 _bufE = newBuf ;
419 if (!_vecE) _vecE = new std::vector<double> ;
420 _vecE->reserve(_vec.capacity()) ;
422 }
423 void setAsymErrorBuffer(double* newBufL, double* newBufH) {
424 _bufEL = newBufL ; _bufEH = newBufH ;
425 if (!_vecEL) {
426 _vecEL = new std::vector<double> ;
427 _vecEH = new std::vector<double> ;
428 _vecEL->reserve(_vec.capacity()) ;
429 _vecEH->reserve(_vec.capacity()) ;
430 }
431 if (!_nativeBufEL) {
434 }
435 }
436
437 inline void loadToNative(Int_t idx) const {
439 if (_vecE) {
440 *_nativeBufE = (*_vecE)[idx] ;
441 }
442 if (_vecEL) {
443 *_nativeBufEL = (*_vecEL)[idx] ;
444 *_nativeBufEH = (*_vecEH)[idx] ;
445 }
446 }
447
448 void fill() {
450 if (_vecE) _vecE->push_back(*_bufE) ;
451 if (_vecEL) _vecEL->push_back(*_bufEL) ;
452 if (_vecEH) _vecEH->push_back(*_bufEH) ;
453 } ;
454
455 void write(Int_t i) {
457 if (_vecE) (*_vecE)[i] = *_bufE ;
458 if (_vecEL) (*_vecEL)[i] = *_bufEL ;
459 if (_vecEH) (*_vecEH)[i] = *_bufEH ;
460 }
461
462 void reset() {
464 if (_vecE) {
465 std::vector<double> tmp;
466 _vecE->swap(tmp);
467 }
468 if (_vecEL) {
469 std::vector<double> tmp;
470 _vecEL->swap(tmp);
471 }
472 if (_vecEH) {
473 std::vector<double> tmp;
474 _vecEH->swap(tmp);
475 }
476 }
477
478 inline void get(Int_t idx) const {
479 RealVector::load(idx) ;
480 if (_vecE) *_bufE = (*_vecE)[idx];
481 if (_vecEL) *_bufEL = (*_vecEL)[idx] ;
482 if (_vecEH) *_bufEH = (*_vecEH)[idx] ;
483 }
484
485 void resize(Int_t siz) {
487 std::vector<double>* vlist[3] = { _vecE, _vecEL, _vecEH };
488 for (unsigned i = 0; i < 3; ++i) {
489 if (!vlist[i]) continue;
490 if (vlist[i]) {
491 if (siz < Int_t(vlist[i]->capacity()) / 2 && vlist[i]->capacity() > (VECTOR_BUFFER_SIZE / sizeof(double))) {
492 // if we gain a factor of 2 in memory, we copy and swap
493 std::vector<double> tmp;
494 tmp.reserve(std::max(siz, Int_t(VECTOR_BUFFER_SIZE / sizeof(double))));
495 if (!vlist[i]->empty())
496 tmp.assign(vlist[i]->begin(),
497 std::min(_vec.end(), _vec.begin() + siz));
498 if (Int_t(tmp.size()) != siz)
499 tmp.resize(siz);
500 vlist[i]->swap(tmp);
501 } else {
502 vlist[i]->resize(siz);
503 }
504 }
505 }
506 }
507
508 void reserve(Int_t siz) {
510 if (_vecE) _vecE->reserve(siz);
511 if (_vecEL) _vecEL->reserve(siz);
512 if (_vecEH) _vecEH->reserve(siz);
513 }
514
515 std::vector<double>* dataE() { return _vecE; }
516 std::vector<double>* dataEL() { return _vecEL; }
517 std::vector<double>* dataEH() { return _vecEH; }
518
519 private:
520 friend class RooVectorDataStore ;
521 double *_bufE ; ///<!
522 double *_bufEL ; ///<!
523 double *_bufEH ; ///<!
524 double *_nativeBufE ; ///<!
525 double *_nativeBufEL ; ///<!
526 double *_nativeBufEH ; ///<!
527 std::vector<double> *_vecE, *_vecEL, *_vecEH ;
528 ClassDefOverride(RealFullVector,1) // STL-vector-based Data Storage class
529 } ;
530
531
532 class CatVector {
533 public:
535 _cat(nullptr), _buf(nullptr), _nativeBuf(nullptr)
536 {
537 _vec.reserve(initialCapacity);
538 }
539
541 _cat(cat), _buf(nullptr), _nativeBuf(nullptr)
542 {
543 _vec.reserve(initialCapacity);
544 }
545
546 virtual ~CatVector() {
547 }
548
549 CatVector(const CatVector& other, RooAbsCategory* cat = nullptr) :
550 _cat(cat?cat:other._cat), _buf(other._buf), _nativeBuf(other._nativeBuf), _vec(other._vec)
551 {
552
553 }
554
556 if (&other==this) return *this;
557 _cat = other._cat;
558 _buf = other._buf;
559 _nativeBuf = other._nativeBuf;
560 if (other._vec.size() <= _vec.capacity() / 2 && _vec.capacity() > VECTOR_BUFFER_SIZE) {
561 std::vector<RooAbsCategory::value_type> tmp;
562 tmp.reserve(std::max(other._vec.size(), std::size_t(VECTOR_BUFFER_SIZE)));
563 tmp.assign(other._vec.begin(), other._vec.end());
564 _vec.swap(tmp);
565 } else {
566 _vec = other._vec;
567 }
568
569 return *this;
570 }
571
573 _buf = newBuf ;
574 if (!_nativeBuf) _nativeBuf = newBuf;
575 }
576
578 _nativeBuf = newBuf ? newBuf : _buf;
579 }
580
581 void fill() {
582 _vec.push_back(*_buf) ;
583 }
584
585 void write(std::size_t i) {
586 _vec[i] = *_buf;
587 }
588
589 void reset() {
590 // make sure the vector releases the underlying memory
591 std::vector<RooAbsCategory::value_type> tmp;
592 _vec.swap(tmp);
593 }
594
595 inline void load(std::size_t idx) const {
596 *_buf = _vec[idx];
597 }
598
599 RooSpan<const RooAbsCategory::value_type> getRange(std::size_t first, std::size_t last) const {
600 auto beg = std::min(_vec.cbegin() + first, _vec.cend());
601 auto end = std::min(_vec.cbegin() + last, _vec.cend());
602
604 }
605
606
607 inline void loadToNative(std::size_t idx) const {
608 *_nativeBuf = _vec[idx];
609 }
610
611 std::size_t size() const { return _vec.size() ; }
612
613 void resize(Int_t siz) {
614 if (siz < Int_t(_vec.capacity()) / 2 && _vec.capacity() > VECTOR_BUFFER_SIZE) {
615 // do an expensive copy, if we save at least a factor 2 in size
616 std::vector<RooAbsCategory::value_type> tmp;
617 tmp.reserve(std::max(siz, VECTOR_BUFFER_SIZE));
618 if (!_vec.empty())
619 tmp.assign(_vec.begin(), std::min(_vec.end(), _vec.begin() + siz));
620 if (Int_t(tmp.size()) != siz)
621 tmp.resize(siz);
622 _vec.swap(tmp);
623 } else {
624 _vec.resize(siz);
625 }
626 }
627
628 void reserve(Int_t siz) {
629 _vec.reserve(siz);
630 }
631
632 void setBufArg(RooAbsCategory* arg) { _cat = arg; }
633 const RooAbsCategory* bufArg() const { return _cat; }
634
635 std::vector<RooAbsCategory::value_type>& data() { return _vec; }
636
637 private:
638 friend class RooVectorDataStore ;
642 std::vector<RooAbsCategory::value_type> _vec;
643 ClassDef(CatVector,2) // STL-vector-based Data Storage class
644 } ;
645
646 std::vector<RealVector*>& realStoreList() { return _realStoreList ; }
647 std::vector<RealFullVector*>& realfStoreList() { return _realfStoreList ; }
648 std::vector<CatVector*>& catStoreList() { return _catStoreList ; }
649
650 protected:
651
652 friend class RooAbsReal ;
653 friend class RooAbsCategory ;
654 friend class RooRealVar ;
655
657
659
660 bool isFullReal(RooAbsReal* real);
661
662 bool hasError(RooAbsReal* real);
663
664 bool hasAsymError(RooAbsReal* real);
665
667
668 bool hasFilledCache() const override { return _cache ? true : false ; }
669
670 void forceCacheUpdate() override;
671
672 private:
674 RooRealVar* _wgtVar = nullptr; ///< Pointer to weight variable (if set)
675
676 std::vector<RealVector*> _realStoreList ;
677 std::vector<RealFullVector*> _realfStoreList ;
678 std::vector<CatVector*> _catStoreList ;
679
680 void setAllBuffersNative() ;
681
682 double _sumWeight = 0.0;
683 double _sumWeightCarry = 0.0;
684
685 const double* _extWgtArray = nullptr; ///<! External weight array
686 const double* _extWgtErrLoArray = nullptr; ///<! External weight array - low error
687 const double* _extWgtErrHiArray = nullptr; ///<! External weight array - high error
688 const double* _extSumW2Array = nullptr; ///<! External sum of weights array
689
691
692 RooVectorDataStore* _cache = nullptr; ///<! Optimization cache
693 RooAbsArg* _cacheOwner = nullptr; ///<! Cache owner
694
695 bool _forcedUpdate = false; ///<! Request for forced cache update
696
697 ClassDefOverride(RooVectorDataStore, 7) // STL-vector-based Data Storage class
698};
699
700
701#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:335
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
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
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t src
char name[80]
Definition: TGX11.cxx:110
#define hi
Definition: THbookFile.cxx:128
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition: TString.cxx:2447
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:72
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, RooSpan< const double > > RealSpans
Definition: RooAbsData.h:136
std::map< RooFit::Detail::DataKey, RooSpan< const RooAbsCategory::value_type > > CategorySpans
Definition: RooAbsData.h:137
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:64
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition: RooAbsReal.h:94
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:57
RooChangeTracker is a meta object that tracks value changes in a given set of RooAbsArgs by registeri...
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...
Definition: RooFormulaVar.h:30
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
RooTreeDataStore is a TTree-backed data storage.
void setBufArg(RooAbsCategory *arg)
void setBuffer(RooAbsCategory::value_type *newBuf)
RooSpan< const RooAbsCategory::value_type > getRange(std::size_t first, std::size_t last) const
CatVector(UInt_t initialCapacity=1024)
RooAbsCategory::value_type * _buf
!
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
CatVector(RooAbsCategory *cat, UInt_t initialCapacity=1024)
const RooAbsCategory * bufArg() const
std::vector< RooAbsCategory::value_type > & data()
CatVector(const CatVector &other, RooAbsCategory *cat=nullptr)
std::vector< double > * dataEL()
RealFullVector(RooAbsReal *arg, UInt_t initialCapacity=(1024/sizeof(double)))
RealFullVector(const RealFullVector &other, RooAbsReal *real=0)
std::vector< double > * dataEH()
RealFullVector(const RealVector &other, RooAbsReal *real=0)
RealFullVector(UInt_t initialCapacity=(1024/sizeof(double)))
RealFullVector & operator=(const RealFullVector &other)
void setAsymErrorBuffer(double *newBufL, double *newBufH)
RealVector & operator=(const RealVector &other)
const RooAbsReal * bufArg() const
void setNset(RooArgSet *newNset)
std::vector< double > & data()
void loadToNative(std::size_t idx) const
RooSpan< const double > getRange(std::size_t first, std::size_t last) const
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)))
void setNativeBuffer(double *newBuf=0)
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
RealVector(const RealVector &other, RooAbsReal *real=0)
const std::vector< double > & data() const
RooVectorDataStore uses std::vectors to store data columns.
const RooArgSet & row()
RooAbsDataStore * reduce(RooStringView name, RooStringView title, const RooArgSet &vars, const RooFormulaVar *cutVar, const char *cutRange, std::size_t nStart, std::size_t nStop) override
void resetCache() override
void recalculateCache(const RooArgSet *, Int_t firstEvent, Int_t lastEvent, Int_t stepSize, bool skipZeroWeights) 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
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
~RooVectorDataStore() override
Destructor.
void resetBuffers() override
RooRealVar * weightVar(const RooArgSet &allVars, const char *wgtName)
Utility function for constructors Return pointer to weight variable if it is defined.
RooRealVar * _wgtVar
Pointer to weight variable (if set)
std::vector< RealVector * > _realStoreList
CatVector * addCategory(RooAbsCategory *cat)
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
RealFullVector * addRealFull(RooAbsReal *real)
double weight() const override
Return the weight of the last-retrieved data point.
RooAbsDataStore * clone(const RooArgSet &vars, const char *newname=0) const override
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)
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 ...
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
void cacheArgs(const RooAbsArg *owner, RooArgSet &varSet, const RooArgSet *nset=0, bool skipZeroWeights=true) override
Cache given RooAbsArgs: The tree is given direct write access of the args internal cache the args val...
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.
RooAbsDataStore * clone(const char *newname=0) const override
void reserve(Int_t nEvt)
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
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
double T(double x)
Definition: ChebyshevPol.h:34
Definition: first.py:1
Output struct for the RooVectorDataStore::getArrays() helper function.
std::vector< ArrayInfo< double > > reals
std::vector< ArrayInfo< RooAbsCategory::value_type > > cats