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 ;
37
38#define VECTOR_BUFFER_SIZE 1024
39
41public:
42
44
45 // Empty ctor
46 RooVectorDataStore(std::string_view name, std::string_view title, const RooArgSet& vars, const char* wgtVarName=0) ;
47
49
50 virtual RooAbsDataStore* clone(const char* newname=0) const override { return new RooVectorDataStore(*this,newname) ; }
51 virtual RooAbsDataStore* clone(const RooArgSet& vars, const char* newname=0) const override { return new RooVectorDataStore(*this,vars,newname) ; }
52
53 RooVectorDataStore(const RooVectorDataStore& other, const char* newname=0) ;
54 RooVectorDataStore(const RooTreeDataStore& other, const RooArgSet& vars, const char* newname=0) ;
55 RooVectorDataStore(const RooVectorDataStore& other, const RooArgSet& vars, const char* newname=0) ;
56
57
58 RooVectorDataStore(std::string_view name, std::string_view title, RooAbsDataStore& tds,
59 const RooArgSet& vars, const RooFormulaVar* cutVar, const char* cutRange,
60 std::size_t nStart, std::size_t nStop, Bool_t /*copyCache*/, const char* wgtVarName=0) ;
61
62 virtual ~RooVectorDataStore() ;
63
64 /// \class ArraysStruct
65 /// Output struct for the RooVectorDataStore::getArrays() helper function.
66 /// Meant to be used for RooFit internal use and might change without warning.
67 struct ArraysStruct {
68
69 template<class T>
70 struct ArrayInfo {
71 ArrayInfo(std::string_view n, T const* d) : name{n}, data{d} {}
72 std::string name;
73 T const* data;
74 };
75
76 std::vector<ArrayInfo<double>> reals;
77 std::vector<ArrayInfo<RooAbsCategory::value_type>> cats;
78
79 std::size_t size;
80 };
81
82 /// \name Internal RooFit interface.
83 /// The classes and functions in the internal RooFit interface are
84 /// implementaion details and not part of the public user interface.
85 /// Everything in this group might change without warning.
86 /// @{
87 ArraysStruct getArrays() const;
88 void recomputeSumWeight();
89 /// @}
90
91private:
92 RooArgSet varsNoWeight(const RooArgSet& allVars, const char* wgtName);
93 RooRealVar* weightVar(const RooArgSet& allVars, const char* wgtName);
94
95 // reserve storage for nEvt entries
96 void reserve(Int_t nEvt);
97
98public:
99 // Write current row
100 virtual Int_t fill() override;
101
102 // Retrieve a row
104 virtual const RooArgSet* get(Int_t index) const override;
105
106 virtual const RooArgSet* getNative(Int_t index) const;
107
109 /// Return the weight of the last-retrieved data point.
110 Double_t weight() const override
111 {
112 if (_extWgtArray)
114 if (_wgtVar)
115 return _wgtVar->getVal();
116
117 return 1.0;
118 }
120 virtual void weightError(Double_t& lo, Double_t& hi, RooAbsData::ErrorType etype=RooAbsData::Poisson) const override;
121 virtual Bool_t isWeighted() const override { return _wgtVar || _extWgtArray; }
122
123 RooAbsData::RealSpans getBatches(std::size_t first, std::size_t len) const override;
124 RooAbsData::CategorySpans getCategoryBatches(std::size_t /*first*/, std::size_t len) const override;
125 RooSpan<const double> getWeightBatch(std::size_t first, std::size_t len) const override;
126
127 // Change observable name
128 virtual Bool_t changeObservableName(const char* from, const char* to) override;
129
130 // Add one or more columns
131 virtual RooAbsArg* addColumn(RooAbsArg& var, Bool_t adjustRange=kTRUE) override;
132 virtual RooArgSet* addColumns(const RooArgList& varList) override;
133
134 // Merge column-wise
135 RooAbsDataStore* merge(const RooArgSet& allvars, std::list<RooAbsDataStore*> dstoreList) override;
136
137 // Add rows
138 virtual void append(RooAbsDataStore& other) override;
139
140 // General & bookkeeping methods
141 virtual Int_t numEntries() const override { return static_cast<int>(size()); }
142 virtual Double_t 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 virtual void reset() override;
156
157 // Buffer redirection routines used in inside RooAbsOptTestStatistics
158 virtual void attachBuffers(const RooArgSet& extObs) override;
159 virtual void resetBuffers() override;
160
161
162 // Constant term optimizer interface
163 virtual const RooAbsArg* cacheOwner() override { return _cacheOwner ; }
164 virtual void cacheArgs(const RooAbsArg* owner, RooArgSet& varSet, const RooArgSet* nset=0, Bool_t skipZeroWeights=kTRUE) override;
165 virtual void attachCache(const RooAbsArg* newOwner, const RooArgSet& cachedVars) override;
166 virtual void resetCache() override;
167 virtual void recalculateCache(const RooArgSet* /*proj*/, Int_t firstEvent, Int_t lastEvent, Int_t stepSize, Bool_t skipZeroWeights) override;
168
169 virtual void setArgStatus(const RooArgSet& set, Bool_t active) override;
170
171 const RooVectorDataStore* cache() const { return _cache ; }
172
173 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;
174
175 void dump() override;
176
177 void setExternalWeightArray(const Double_t* arrayWgt, const Double_t* arrayWgtErrLo,
178 const Double_t* arrayWgtErrHi, const Double_t* arraySumW2) override {
179 _extWgtArray = arrayWgt ;
180 _extWgtErrLoArray = arrayWgtErrLo ;
181 _extWgtErrHiArray = arrayWgtErrHi ;
182 _extSumW2Array = arraySumW2 ;
183 }
184
185 virtual void setDirtyProp(Bool_t 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_t))) :
198 _nativeReal(0), _real(0), _buf(0), _nativeBuf(0), _tracker(0), _nset(0) {
199 _vec.reserve(initialCapacity);
200 }
201
202 RealVector(RooAbsReal* arg, UInt_t initialCapacity=(VECTOR_BUFFER_SIZE / sizeof(Double_t))) :
203 _nativeReal(arg), _real(0), _buf(0), _nativeBuf(0), _tracker(0), _nset(0) {
204 _vec.reserve(initialCapacity);
205 }
206
207 virtual ~RealVector() {
208 delete _tracker;
209 if (_nset) delete _nset ;
210 }
211
212 RealVector(const RealVector& other, RooAbsReal* real=0) :
213 _vec(other._vec), _nativeReal(real?real:other._nativeReal), _real(real?real:other._real), _buf(other._buf), _nativeBuf(other._nativeBuf), _nset(0) {
214 if (other._tracker) {
215 _tracker = new RooChangeTracker(Form("track_%s",_nativeReal->GetName()),"tracker",other._tracker->parameters()) ;
216 } else {
217 _tracker = 0 ;
218 }
219 if (other._nset) {
220 _nset = new RooArgSet(*other._nset) ;
221 }
222 }
223
225 if (&other==this) return *this;
226 _nativeReal = other._nativeReal;
227 _real = other._real;
228 _buf = other._buf;
229 _nativeBuf = other._nativeBuf;
230 if (other._vec.size() <= _vec.capacity() / 2 && _vec.capacity() > (VECTOR_BUFFER_SIZE / sizeof(Double_t))) {
231 std::vector<Double_t> tmp;
232 tmp.reserve(std::max(other._vec.size(), VECTOR_BUFFER_SIZE / sizeof(Double_t)));
233 tmp.assign(other._vec.begin(), other._vec.end());
234 _vec.swap(tmp);
235 } else {
236 _vec = other._vec;
237 }
238
239 return *this;
240 }
241
242 void setNset(RooArgSet* newNset) { _nset = newNset ? new RooArgSet(*newNset) : 0 ; }
243
244 RooArgSet* nset() const { return _nset ; }
245
246 void setBufArg(RooAbsReal* arg) { _nativeReal = arg ; }
247 const RooAbsReal* bufArg() const { return _nativeReal ; }
248
249 void setBuffer(RooAbsReal* real, Double_t* newBuf) {
250 _real = real ;
251 _buf = newBuf ;
252 if (_nativeBuf==0) {
253 _nativeBuf=newBuf ;
254 }
255 }
256
257 void setNativeBuffer(Double_t* newBuf=0) {
258 _nativeBuf = newBuf ? newBuf : _buf ;
259 }
260
261 void setDependents(const RooArgSet& deps) {
262 if (_tracker) {
263 delete _tracker ;
264 }
265 _tracker = new RooChangeTracker(Form("track_%s",_nativeReal->GetName()),"tracker",deps) ;
266 }
267
269 if (!_tracker) return kFALSE ;
270 return _tracker->hasChanged(kTRUE) ;
271 }
272
273 void fill() {
274 _vec.push_back(*_buf);
275 }
276
277 void write(Int_t i) {
278 assert(static_cast<std::size_t>(i) < _vec.size());
279 _vec[i] = *_buf ;
280 }
281
282 void reset() {
283 _vec.clear();
284 }
285
286 inline void load(std::size_t idx) const {
287 assert(idx < _vec.size());
288 *_buf = *(_vec.begin() + idx) ;
289 }
290
291 RooSpan<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 RooSpan<const double>(beg, end);
296 }
297
298 inline void loadToNative(std::size_t idx) const {
299 *_nativeBuf = *(_vec.begin() + idx) ;
300 }
301
302 std::size_t size() const { return _vec.size() ; }
303
304 void resize(Int_t siz) {
305 if (siz < Int_t(_vec.capacity()) / 2 && _vec.capacity() > (VECTOR_BUFFER_SIZE / sizeof(Double_t))) {
306 // do an expensive copy, if we save at least a factor 2 in size
307 std::vector<Double_t> tmp;
308 tmp.reserve(std::max(siz, Int_t(VECTOR_BUFFER_SIZE / sizeof(Double_t))));
309 if (!_vec.empty())
310 tmp.assign(_vec.begin(), std::min(_vec.end(), _vec.begin() + siz));
311 if (Int_t(tmp.size()) != siz)
312 tmp.resize(siz);
313 _vec.swap(tmp);
314 } else {
315 _vec.resize(siz);
316 }
317 }
318
319 void reserve(Int_t siz) {
320 _vec.reserve(siz);
321 }
322
323 const std::vector<double>& data() const {
324 return _vec;
325 }
326
327 std::vector<double>& data() { return _vec; }
328
329 protected:
330 std::vector<double> _vec;
331
332 private:
333 friend class RooVectorDataStore ;
334 RooAbsReal* _nativeReal ; // Instance which our data belongs to. This is the variable in the dataset.
335 RooAbsReal* _real ; // Instance where we should write data into when load() is called.
340 ClassDef(RealVector,1) // STL-vector-based Data Storage class
341 } ;
342
343
344 class RealFullVector : public RealVector {
345 public:
346 RealFullVector(UInt_t initialCapacity=(VECTOR_BUFFER_SIZE / sizeof(Double_t))) : RealVector(initialCapacity),
347 _bufE(0), _bufEL(0), _bufEH(0),
349 _vecE(0), _vecEL(0), _vecEH(0) {
350 }
351
352 RealFullVector(RooAbsReal* arg, UInt_t initialCapacity=(VECTOR_BUFFER_SIZE / sizeof(Double_t))) :
353 RealVector(arg,initialCapacity),
354 _bufE(0), _bufEL(0), _bufEH(0),
356 _vecE(0), _vecEL(0), _vecEH(0) {
357 }
358
359 virtual ~RealFullVector() {
360 if (_vecE) delete _vecE ;
361 if (_vecEL) delete _vecEL ;
362 if (_vecEH) delete _vecEH ;
363 }
364
365 RealFullVector(const RealFullVector& other, RooAbsReal* real=0) : RealVector(other,real),
366 _bufE(other._bufE), _bufEL(other._bufEL), _bufEH(other._bufEH),
368 _vecE = (other._vecE) ? new std::vector<Double_t>(*other._vecE) : 0 ;
369 _vecEL = (other._vecEL) ? new std::vector<Double_t>(*other._vecEL) : 0 ;
370 _vecEH = (other._vecEH) ? new std::vector<Double_t>(*other._vecEH) : 0 ;
371 }
372
373 RealFullVector(const RealVector& other, RooAbsReal* real=0) : RealVector(other,real),
374 _bufE(0), _bufEL(0), _bufEH(0),
376 _vecE = 0 ;
377 _vecEL = 0 ;
378 _vecEH = 0 ;
379 }
380
382 if (&other==this) return *this;
384 _bufE = other._bufE;
385 _bufEL = other._bufEL;
386 _bufEH = other._bufEH;
387 _nativeBufE = other._nativeBufE;
390 std::vector<Double_t>* src[3] = { other._vecE, other._vecEL, other._vecEH };
391 std::vector<Double_t>* dst[3] = { _vecE, _vecEL, _vecEH };
392 for (unsigned i = 0; i < 3; ++i) {
393 if (src[i]) {
394 if (dst[i]) {
395 if (dst[i]->size() <= src[i]->capacity() / 2 &&
396 src[i]->capacity() > (VECTOR_BUFFER_SIZE / sizeof(Double_t))) {
397 std::vector<Double_t> tmp;
398 tmp.reserve(std::max(src[i]->size(), VECTOR_BUFFER_SIZE / sizeof(Double_t)));
399 tmp.assign(src[i]->begin(), src[i]->end());
400 dst[i]->swap(tmp);
401 } else {
402 *dst[i] = *src[i];
403 }
404 } else {
405 dst[i] = new std::vector<Double_t>(*src[i]);
406 }
407 } else {
408 delete dst[i];
409 dst[i] = 0;
410 }
411 }
412 return *this;
413 }
414
415 void setErrorBuffer(Double_t* newBuf) {
416 /* std::cout << "setErrorBuffer(" << _nativeReal->GetName() << ") newBuf = " << newBuf << std::endl ; */
417 _bufE = newBuf ;
418 if (!_vecE) _vecE = new std::vector<Double_t> ;
419 _vecE->reserve(_vec.capacity()) ;
421 }
422 void setAsymErrorBuffer(Double_t* newBufL, Double_t* newBufH) {
423 _bufEL = newBufL ; _bufEH = newBufH ;
424 if (!_vecEL) {
425 _vecEL = new std::vector<Double_t> ;
426 _vecEH = new std::vector<Double_t> ;
427 _vecEL->reserve(_vec.capacity()) ;
428 _vecEH->reserve(_vec.capacity()) ;
429 }
430 if (!_nativeBufEL) {
433 }
434 }
435
436 inline void loadToNative(Int_t idx) const {
438 if (_vecE) {
439 *_nativeBufE = (*_vecE)[idx] ;
440 }
441 if (_vecEL) {
442 *_nativeBufEL = (*_vecEL)[idx] ;
443 *_nativeBufEH = (*_vecEH)[idx] ;
444 }
445 }
446
447 void fill() {
449 if (_vecE) _vecE->push_back(*_bufE) ;
450 if (_vecEL) _vecEL->push_back(*_bufEL) ;
451 if (_vecEH) _vecEH->push_back(*_bufEH) ;
452 } ;
453
454 void write(Int_t i) {
456 if (_vecE) (*_vecE)[i] = *_bufE ;
457 if (_vecEL) (*_vecEL)[i] = *_bufEL ;
458 if (_vecEH) (*_vecEH)[i] = *_bufEH ;
459 }
460
461 void reset() {
463 if (_vecE) {
464 std::vector<Double_t> tmp;
465 _vecE->swap(tmp);
466 }
467 if (_vecEL) {
468 std::vector<Double_t> tmp;
469 _vecEL->swap(tmp);
470 }
471 if (_vecEH) {
472 std::vector<Double_t> tmp;
473 _vecEH->swap(tmp);
474 }
475 }
476
477 inline void get(Int_t idx) const {
478 RealVector::load(idx) ;
479 if (_vecE) *_bufE = (*_vecE)[idx];
480 if (_vecEL) *_bufEL = (*_vecEL)[idx] ;
481 if (_vecEH) *_bufEH = (*_vecEH)[idx] ;
482 }
483
484 void resize(Int_t siz) {
486 std::vector<Double_t>* vlist[3] = { _vecE, _vecEL, _vecEH };
487 for (unsigned i = 0; i < 3; ++i) {
488 if (!vlist[i]) continue;
489 if (vlist[i]) {
490 if (siz < Int_t(vlist[i]->capacity()) / 2 && vlist[i]->capacity() > (VECTOR_BUFFER_SIZE / sizeof(Double_t))) {
491 // if we gain a factor of 2 in memory, we copy and swap
492 std::vector<Double_t> tmp;
493 tmp.reserve(std::max(siz, Int_t(VECTOR_BUFFER_SIZE / sizeof(Double_t))));
494 if (!vlist[i]->empty())
495 tmp.assign(vlist[i]->begin(),
496 std::min(_vec.end(), _vec.begin() + siz));
497 if (Int_t(tmp.size()) != siz)
498 tmp.resize(siz);
499 vlist[i]->swap(tmp);
500 } else {
501 vlist[i]->resize(siz);
502 }
503 }
504 }
505 }
506
507 void reserve(Int_t siz) {
509 if (_vecE) _vecE->reserve(siz);
510 if (_vecEL) _vecEL->reserve(siz);
511 if (_vecEH) _vecEH->reserve(siz);
512 }
513
514 std::vector<double>* dataE() { return _vecE; }
515 std::vector<double>* dataEL() { return _vecEL; }
516 std::vector<double>* dataEH() { return _vecEH; }
517
518 private:
519 friend class RooVectorDataStore ;
526 std::vector<double> *_vecE, *_vecEL, *_vecEH ;
527 ClassDef(RealFullVector,1) // STL-vector-based Data Storage class
528 } ;
529
530
531 class CatVector {
532 public:
534 _cat(nullptr), _buf(nullptr), _nativeBuf(nullptr)
535 {
536 _vec.reserve(initialCapacity);
537 }
538
540 _cat(cat), _buf(nullptr), _nativeBuf(nullptr)
541 {
542 _vec.reserve(initialCapacity);
543 }
544
545 virtual ~CatVector() {
546 }
547
548 CatVector(const CatVector& other, RooAbsCategory* cat = nullptr) :
549 _cat(cat?cat:other._cat), _buf(other._buf), _nativeBuf(other._nativeBuf), _vec(other._vec)
550 {
551
552 }
553
555 if (&other==this) return *this;
556 _cat = other._cat;
557 _buf = other._buf;
558 _nativeBuf = other._nativeBuf;
559 if (other._vec.size() <= _vec.capacity() / 2 && _vec.capacity() > VECTOR_BUFFER_SIZE) {
560 std::vector<RooAbsCategory::value_type> tmp;
561 tmp.reserve(std::max(other._vec.size(), std::size_t(VECTOR_BUFFER_SIZE)));
562 tmp.assign(other._vec.begin(), other._vec.end());
563 _vec.swap(tmp);
564 } else {
565 _vec = other._vec;
566 }
567
568 return *this;
569 }
570
572 _buf = newBuf ;
573 if (!_nativeBuf) _nativeBuf = newBuf;
574 }
575
577 _nativeBuf = newBuf ? newBuf : _buf;
578 }
579
580 void fill() {
581 _vec.push_back(*_buf) ;
582 }
583
584 void write(std::size_t i) {
585 _vec[i] = *_buf;
586 }
587
588 void reset() {
589 // make sure the vector releases the underlying memory
590 std::vector<RooAbsCategory::value_type> tmp;
591 _vec.swap(tmp);
592 }
593
594 inline void load(std::size_t idx) const {
595 *_buf = _vec[idx];
596 }
597
598 RooSpan<const RooAbsCategory::value_type> getRange(std::size_t first, std::size_t last) const {
599 auto beg = std::min(_vec.cbegin() + first, _vec.cend());
600 auto end = std::min(_vec.cbegin() + last, _vec.cend());
601
603 }
604
605
606 inline void loadToNative(std::size_t idx) const {
607 *_nativeBuf = _vec[idx];
608 }
609
610 std::size_t size() const { return _vec.size() ; }
611
612 void resize(Int_t siz) {
613 if (siz < Int_t(_vec.capacity()) / 2 && _vec.capacity() > VECTOR_BUFFER_SIZE) {
614 // do an expensive copy, if we save at least a factor 2 in size
615 std::vector<RooAbsCategory::value_type> tmp;
616 tmp.reserve(std::max(siz, VECTOR_BUFFER_SIZE));
617 if (!_vec.empty())
618 tmp.assign(_vec.begin(), std::min(_vec.end(), _vec.begin() + siz));
619 if (Int_t(tmp.size()) != siz)
620 tmp.resize(siz);
621 _vec.swap(tmp);
622 } else {
623 _vec.resize(siz);
624 }
625 }
626
627 void reserve(Int_t siz) {
628 _vec.reserve(siz);
629 }
630
631 void setBufArg(RooAbsCategory* arg) { _cat = arg; }
632 const RooAbsCategory* bufArg() const { return _cat; }
633
634 std::vector<RooAbsCategory::value_type>& data() { return _vec; }
635
636 private:
637 friend class RooVectorDataStore ;
641 std::vector<RooAbsCategory::value_type> _vec;
642 ClassDef(CatVector,2) // STL-vector-based Data Storage class
643 } ;
644
645 std::vector<RealVector*>& realStoreList() { return _realStoreList ; }
646 std::vector<RealFullVector*>& realfStoreList() { return _realfStoreList ; }
647 std::vector<CatVector*>& catStoreList() { return _catStoreList ; }
648
649 protected:
650
651 friend class RooAbsReal ;
652 friend class RooAbsCategory ;
653 friend class RooRealVar ;
654
656
658
660
662
664
666
667 virtual Bool_t hasFilledCache() const override { return _cache ? kTRUE : kFALSE ; }
668
669 void forceCacheUpdate() override;
670
671 private:
673 RooRealVar* _wgtVar ; // Pointer to weight variable (if set)
674
675 std::vector<RealVector*> _realStoreList ;
676 std::vector<RealFullVector*> _realfStoreList ;
677 std::vector<CatVector*> _catStoreList ;
678
679 void setAllBuffersNative() ;
680
683
684 const Double_t* _extWgtArray ; //! External weight array
685 const Double_t* _extWgtErrLoArray ; //! External weight array - low error
686 const Double_t* _extWgtErrHiArray ; //! External weight array - high error
687 const Double_t* _extSumW2Array ; //! External sum of weights array
688
690
691 RooVectorDataStore* _cache ; //! Optimization cache
692 RooAbsArg* _cacheOwner ; //! Cache owner
693
694 Bool_t _forcedUpdate ; //! Request for forced cache update
695
696 ClassDefOverride(RooVectorDataStore, 7) // STL-vector-based Data Storage class
697};
698
699
700#endif
#define d(i)
Definition RSha256.hxx:102
#define WRITE_TSTRING_COMPATIBLE_CONSTRUCTOR(Class_t)
Definition RooAbsData.h:69
#define VECTOR_BUFFER_SIZE
int Int_t
Definition RtypesCore.h:45
const Bool_t kFALSE
Definition RtypesCore.h:101
double Double_t
Definition RtypesCore.h:59
unsigned long long ULong64_t
Definition RtypesCore.h:81
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
#define hi
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:69
RooAbsCategory is the base class for objects that represent a discrete value with a finite number of ...
void reserve(Storage_t::size_type count)
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
std::map< RooFit::Detail::DataKey, RooSpan< const double > > RealSpans
Definition RooAbsData.h:159
std::map< RooFit::Detail::DataKey, RooSpan< const RooAbsCategory::value_type > > CategorySpans
Definition RooAbsData.h:160
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition RooAbsReal.h:64
Double_t 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: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...
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)
RooSpan< const RooAbsCategory::value_type > getRange(std::size_t first, std::size_t last) const
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
std::vector< RooAbsCategory::value_type > & data()
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)
std::vector< double > & data()
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
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.
RooAbsData::RealSpans getBatches(std::size_t first, std::size_t len) const override
Return batches of the data columns for the requested events.
ULong64_t _currentWeightIndex
External sum of weights 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
virtual Bool_t isWeighted() const override
virtual 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...
virtual void setDirtyProp(Bool_t flag) override
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.
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
void recomputeSumWeight()
Trigger a recomputation of the cached weight sums.
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)
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:79
const Int_t n
Definition legend1.C:16
Definition first.py:1
ArrayInfo(std::string_view n, T const *d)
Output struct for the RooVectorDataStore::getArrays() helper function.
std::vector< ArrayInfo< double > > reals
std::vector< ArrayInfo< RooAbsCategory::value_type > > cats