Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooVectorDataStore.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * @(#)root/roofitcore:$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
17/**
18\file RooVectorDataStore.cxx
19\class RooVectorDataStore
20\ingroup Roofitcore
21
22Uses `std::vector` to store data columns. Each of these vectors
23is associated to an instance of a RooAbsReal, whose values it represents. Those
24RooAbsReal are the observables of the dataset.
25In addition to the observables, a data column can be bound to a different instance
26of a RooAbsReal (e.g., the column "x" can be bound to the observable "x" of a computation
27graph using attachBuffers()). In this case, a get() operation writes the value of
28the requested column into the bound real.
29
30As a faster alternative to loading values one-by-one, one can use the function getBatches(),
31which returns spans pointing directly to the data.
32**/
33
34#include "RooVectorDataStore.h"
35
36#include "RooMsgService.h"
37#include "RooTreeDataStore.h"
38#include "RooFormulaVar.h"
39#include "RooRealVar.h"
40#include "RooCategory.h"
41#include "RooHistError.h"
42#include "RooFitImplHelpers.h"
43
44#include "Math/Util.h"
45#include "ROOT/StringUtils.hxx"
46#include "TBuffer.h"
47
48#include <iomanip>
49using std::string, std::vector, std::list;
50
51
52
53////////////////////////////////////////////////////////////////////////////////
54
58
59
60
61////////////////////////////////////////////////////////////////////////////////
62
64 RooAbsDataStore(name,title,varsNoWeight(vars,wgtVarName)),
65 _varsww(vars),
66 _wgtVar(weightVar(vars,wgtVarName))
67{
68 for (auto arg : _varsww) {
69 arg->attachToVStore(*this) ;
70 }
71
73}
74
75
76
77////////////////////////////////////////////////////////////////////////////////
78
80{
81 for (auto realVec : _realStoreList) {
82 realVec->setNativeBuffer();
83 }
84
85 for (auto fullVec : _realfStoreList) {
86 fullVec->setNativeBuffer();
87 }
88
89 for (auto catVec : _catStoreList) {
90 catVec->setNativeBuffer();
91 }
92}
93
94
95
96
97////////////////////////////////////////////////////////////////////////////////
98/// Utility function for constructors
99/// Return RooArgSet that is copy of allVars minus variable matching wgtName if specified
100
102{
103 RooArgSet ret(allVars) ;
104 if(wgtName) {
105 RooAbsArg* wgt = allVars.find(wgtName) ;
106 if (wgt) {
107 ret.remove(*wgt,true,true) ;
108 }
109 }
110 return ret ;
111}
112
113
114
115////////////////////////////////////////////////////////////////////////////////
116/// Utility function for constructors
117/// Return pointer to weight variable if it is defined
118
120{
121 if(wgtName) {
122 RooRealVar* wgt = dynamic_cast<RooRealVar*>(allVars.find(wgtName)) ;
123 return wgt ;
124 }
125 return nullptr ;
126}
127
128
129
130
131////////////////////////////////////////////////////////////////////////////////
132/// Regular copy constructor.
133
136 _varsww(other._varsww),
137 _wgtVar(other._wgtVar),
138 _sumWeight(other._sumWeight),
139 _sumWeightCarry(other._sumWeightCarry),
140 _extWgtArray(other._extWgtArray),
141 _extWgtErrLoArray(other._extWgtErrLoArray),
142 _extWgtErrHiArray(other._extWgtErrHiArray),
143 _extSumW2Array(other._extSumW2Array),
144 _currentWeightIndex(other._currentWeightIndex)
145{
146 for (const auto realVec : other._realStoreList) {
147 _realStoreList.push_back(new RealVector(*realVec, static_cast<RooAbsReal*>(_varsww.find(realVec->_nativeReal->GetName())))) ;
148 }
149
150 for (const auto realFullVec : other._realfStoreList) {
151 _realfStoreList.push_back(new RealFullVector(*realFullVec, static_cast<RooAbsReal*>(_varsww.find(realFullVec->_nativeReal->GetName())))) ;
152 }
153
154 for (const auto catVec : other._catStoreList) {
155 _catStoreList.push_back(new CatVector(*catVec, static_cast<RooAbsCategory*>(_varsww.find(catVec->_cat->GetName())))) ;
156 }
157
159
160}
161
162
163////////////////////////////////////////////////////////////////////////////////
164
166 RooAbsDataStore(other,varsNoWeight(vars,other._wgtVar?other._wgtVar->GetName():nullptr),newname),
167 _varsww(vars),
168 _wgtVar(weightVar(vars,other._wgtVar?other._wgtVar->GetName():nullptr))
169{
170 for (const auto arg : _varsww) {
171 arg->attachToVStore(*this) ;
172 }
173
175
176 // now copy contents of tree storage here
177 reserve(other.numEntries());
178 for (Int_t i=0 ; i<other.numEntries() ; i++) {
179 other.get(i) ;
180 _varsww.assign(other._varsww) ;
181 fill() ;
182 }
183
184}
185
186
187////////////////////////////////////////////////////////////////////////////////
188/// Clone constructor, must connect internal storage to given new external set of variables.
189
191 RooAbsDataStore(other,varsNoWeight(vars,other._wgtVar?other._wgtVar->GetName():nullptr),newname),
192 _varsww(vars),
193 _wgtVar(other._wgtVar?weightVar(vars,other._wgtVar->GetName()):nullptr),
194 _sumWeight(other._sumWeight),
195 _sumWeightCarry(other._sumWeightCarry),
196 _extWgtArray(other._extWgtArray),
197 _extWgtErrLoArray(other._extWgtErrLoArray),
198 _extWgtErrHiArray(other._extWgtErrHiArray),
199 _extSumW2Array(other._extSumW2Array),
200 _currentWeightIndex(other._currentWeightIndex)
201{
202 for (const auto realVec : other._realStoreList) {
203 auto real = static_cast<RooAbsReal*>(vars.find(realVec->bufArg()->GetName()));
204 if (real) {
205 // Clone vector
206 _realStoreList.push_back(new RealVector(*realVec, real)) ;
207 // Adjust buffer pointer
208 real->attachToVStore(*this) ;
209 }
210 }
211
212 auto forwardIter = other._realfStoreList.begin() ;
213 for (; forwardIter!=other._realfStoreList.end() ; ++forwardIter) {
214 RooAbsReal* real = static_cast<RooAbsReal*>(vars.find((*forwardIter)->bufArg()->GetName())) ;
215 if (real) {
216 // Clone vector
218 // Adjust buffer pointer
219 real->attachToVStore(*this) ;
220 }
221 }
222
223 vector<CatVector*>::const_iterator citer = other._catStoreList.begin() ;
224 for (; citer!=other._catStoreList.end() ; ++citer) {
225 RooAbsCategory* cat = static_cast<RooAbsCategory*>(vars.find((*citer)->bufArg()->GetName())) ;
226 if (cat) {
227 // Clone vector
228 _catStoreList.push_back(new CatVector(**citer,cat)) ;
229 // Adjust buffer pointer
230 cat->attachToVStore(*this) ;
231 }
232 }
233
235
236}
237
238
239std::unique_ptr<RooAbsDataStore> RooVectorDataStore::reduce(RooStringView name, RooStringView title,
240 const RooArgSet& vars, const RooFormulaVar* cutVar, const char* cutRange,
241 std::size_t nStart, std::size_t nStop) {
242 RooArgSet tmp(vars) ;
243 if(_wgtVar && !tmp.contains(*_wgtVar)) {
244 tmp.add(*_wgtVar) ;
245 }
246 const char* wgtVarName = _wgtVar ? _wgtVar->GetName() : nullptr;
247 return std::make_unique<RooVectorDataStore>(name, title, *this, tmp, cutVar, cutRange, nStart, nStop, wgtVarName);
248}
249
250
251
252////////////////////////////////////////////////////////////////////////////////
253
255 const RooArgSet& vars, const RooFormulaVar* cutVar, const char* cutRange,
256 std::size_t nStart, std::size_t nStop, const char* wgtVarName) :
257
258 RooAbsDataStore(name,title,varsNoWeight(vars,wgtVarName)),
259 _varsww(vars),
260 _wgtVar(weightVar(vars,wgtVarName))
261{
262 for (const auto arg : _varsww) {
263 arg->attachToVStore(*this) ;
264 }
265
267
268 // Deep clone cutVar and attach clone to this dataset
269 std::unique_ptr<RooFormulaVar> cloneVar;
270 if (cutVar) {
271 cloneVar.reset(static_cast<RooFormulaVar*>(cutVar->cloneTree()));
272 cloneVar->attachDataStore(tds) ;
273 }
274
275 RooVectorDataStore* vds = dynamic_cast<RooVectorDataStore*>(&tds) ;
276 if (vds && vds->_cache) {
277 _cache = new RooVectorDataStore(*vds->_cache) ;
278 }
279
280 loadValues(&tds,cloneVar.get(),cutRange,nStart,nStop);
281
282}
283
284
285
286
287
288
289////////////////////////////////////////////////////////////////////////////////
290/// Destructor
291
293{
294 for (auto elm : _realStoreList) {
295 delete elm;
296 }
297
298 for (auto elm : _realfStoreList) {
299 delete elm;
300 }
301
302 for (auto elm : _catStoreList) {
303 delete elm;
304 }
305
306 delete _cache ;
307}
308
309
310////////////////////////////////////////////////////////////////////////////////
311/// Interface function to TTree::Fill
312
314{
315 for (auto realVec : _realStoreList) {
316 realVec->fill() ;
317 }
318
319 for (auto fullVec : _realfStoreList) {
320 fullVec->fill() ;
321 }
322
323 for (auto catVec : _catStoreList) {
324 catVec->fill() ;
325 }
326 // use Kahan's algorithm to sum up weights to avoid loss of precision
327 double y = (_wgtVar ? _wgtVar->getVal() : 1.) - _sumWeightCarry;
328 double t = _sumWeight + y;
329 _sumWeightCarry = (t - _sumWeight) - y;
330 _sumWeight = t;
331
332 return 0 ;
333}
334
335
336
337////////////////////////////////////////////////////////////////////////////////
338/// Load the n-th data point (n='index') into the variables of this dataset,
339/// and return a pointer to the RooArgSet that holds them.
341{
342 if (index < 0 || static_cast<std::size_t>(index) >= size()) return nullptr;
343
344 for (const auto realV : _realStoreList) {
345 realV->load(index);
346 }
347
348 for (const auto fullRealP : _realfStoreList) {
349 fullRealP->load(index);
350 }
351
352 for (const auto catP : _catStoreList) {
353 catP->load(index);
354 }
355
356 if (_doDirtyProp) {
357 // Raise all dirty flags
358 for (auto var : _vars) {
359 var->setValueDirty(); // This triggers recalculation of all clients
360 }
361 }
362
363 // Update current weight cache
365
366 if (_cache) {
367 _cache->get(index) ;
368 }
369
370 return &_vars;
371}
372
373
374////////////////////////////////////////////////////////////////////////////////
375/// Return the error of the current weight.
376/// @param[in] etype Switch between simple Poisson or sum-of-weights statistics
377
379{
380 if (_extWgtArray) {
381
382 // We have a weight array, use that info
383
384 // Return symmetric error on current bin calculated either from Poisson statistics or from SumOfWeights
385 double lo = 0;
386 double hi = 0;
387 weightError(lo,hi,etype) ;
388 return (lo+hi)/2 ;
389
390 } else if (_wgtVar) {
391
392 // We have a weight variable, use that info
393 if (_wgtVar->hasAsymError()) {
394 return ( _wgtVar->getAsymErrorHi() - _wgtVar->getAsymErrorLo() ) / 2 ;
395 } else if (_wgtVar->hasError(false)) {
396 return _wgtVar->getError();
397 } else {
398 return 0 ;
399 }
400
401 } else {
402
403 // We have no weights
404 return 0 ;
405
406 }
407}
408
409
410
411////////////////////////////////////////////////////////////////////////////////
412
413void RooVectorDataStore::weightError(double& lo, double& hi, RooAbsData::ErrorType etype) const
414{
415 if (_extWgtArray) {
416 double wgt;
417
418 // We have a weight array, use that info
419 switch (etype) {
420
421 case RooAbsData::Auto:
422 throw string(Form("RooDataHist::weightError(%s) error type Auto not allowed here",GetName())) ;
423 break ;
424
426 throw string(Form("RooDataHist::weightError(%s) error type Expected not allowed here",GetName())) ;
427 break ;
428
430 // Weight may be preset or precalculated
434 return ;
435 }
436
437 // Otherwise Calculate poisson errors
438 wgt = weight();
439 double ym;
440 double yp;
441 RooHistError::instance().getPoissonInterval(Int_t(wgt+0.5),ym,yp,1);
442 lo = wgt-ym;
443 hi = yp-wgt;
444 return ;
445
448 hi = lo;
449 return ;
450
451 case RooAbsData::None:
452 lo = 0 ;
453 hi = 0 ;
454 return ;
455 }
456
457 } else if (_wgtVar) {
458
459 // We have a weight variable, use that info
460 if (_wgtVar->hasAsymError()) {
462 lo = _wgtVar->getAsymErrorLo() ;
463 } else {
464 hi = _wgtVar->getError() ;
465 lo = _wgtVar->getError() ;
466 }
467
468 } else {
469
470 // We are unweighted
471 lo=0 ;
472 hi=0 ;
473
474 }
475}
476
477
478
479////////////////////////////////////////////////////////////////////////////////
480///
481
482void RooVectorDataStore::loadValues(const RooAbsDataStore *ads, const RooFormulaVar* select, const char* rangeName, std::size_t nStart, std::size_t nStop)
483{
484 // Load values from dataset 't' into this data collection, optionally
485 // selecting events using 'select' RooFormulaVar
486 //
487
488 // Redirect formula servers to source data row
489 std::unique_ptr<RooFormulaVar> selectClone;
490 if (select) {
491 selectClone.reset( static_cast<RooFormulaVar*>(select->cloneTree()) );
492 selectClone->recursiveRedirectServers(*ads->get()) ;
493 selectClone->setOperMode(RooAbsArg::ADirty,true) ;
494 }
495
496 // Force DS internal initialization
497 ads->get(0) ;
498
499 // Loop over events in source tree
500 const auto numEntr = static_cast<std::size_t>(ads->numEntries());
501 const std::size_t nevent = nStop < numEntr ? nStop : numEntr;
502
503 auto treeDS = dynamic_cast<const RooTreeDataStore*>(ads);
504 auto vectorDS = dynamic_cast<const RooVectorDataStore*>(ads);
505
506 // Check if weight is being renamed - if so set flag to enable special handling in copy loop
507 bool weightRename(false) ;
508 const bool newWeightVar = _wgtVar ? _wgtVar->getAttribute("NewWeight") : false ;
509
510 if (_wgtVar && vectorDS && vectorDS->_wgtVar) {
511 if (std::string(_wgtVar->GetName()) != vectorDS->_wgtVar->GetName() && !newWeightVar) {
513 }
514 }
515 if (_wgtVar && treeDS && treeDS->_wgtVar) {
516 if (std::string(_wgtVar->GetName()) != treeDS->_wgtVar->GetName() && !newWeightVar) {
518 }
519 }
520
521 std::vector<std::string> ranges;
522 if (rangeName) {
523 ranges = ROOT::Split(rangeName, ",");
524 }
525
526 reserve(numEntries() + (nevent - nStart));
527 for(auto i=nStart; i < nevent ; ++i) {
528 ads->get(i);
529
530 // Does this event pass the cuts?
531 if (selectClone && selectClone->getVal()==0) {
532 continue ;
533 }
534
535 RooArgSet const* otherVarsww = nullptr;
536
537 if (treeDS) {
538 otherVarsww = &treeDS->_varsww;
539 if (weightRename) {
540 _wgtVar->setVal(treeDS->_wgtVar->getVal()) ;
541 }
542 } else if (vectorDS) {
543 otherVarsww = &vectorDS->_varsww;
544 if (weightRename) {
545 _wgtVar->setVal(vectorDS->_wgtVar->getVal()) ;
546 }
547 } else {
548 otherVarsww = ads->get();
549 }
550
551 // Check that all copied values are valid and in range
552 bool allValid = true;
553 for (const auto arg : *otherVarsww) {
554 allValid &= arg->isValid();
555 if (allValid && !ranges.empty()) {
556 // If we have one or multiple ranges to be selected, the value
557 // must be in one of them to be valid
558 allValid &= std::any_of(ranges.begin(), ranges.end(), [arg](const std::string& range){
559 return arg->inRange(range.c_str());});
560 }
561 if (!allValid)
562 break ;
563 }
564
565 if (!allValid) {
566 continue ;
567 }
568
570
571 fill() ;
572 }
573
574 SetTitle(ads->GetTitle());
575}
576
577
578
579
580
581////////////////////////////////////////////////////////////////////////////////
582
583bool RooVectorDataStore::changeObservableName(const char* /*from*/, const char* /*to*/)
584{
585 return false ;
586}
587
588
589
590////////////////////////////////////////////////////////////////////////////////
591/// Add a new column to the data set which holds the pre-calculated values
592/// of 'newVar'. This operation is only meaningful if 'newVar' is a derived
593/// value.
594///
595/// The return value points to the added element holding 'newVar's value
596/// in the data collection. The element is always the corresponding fundamental
597/// type of 'newVar' (e.g. a RooRealVar if 'newVar' is a RooFormulaVar)
598///
599/// Note: This function is explicitly NOT intended as a speed optimization
600/// opportunity for the user. Components of complex PDFs that can be
601/// precalculated with the dataset are automatically identified as such
602/// and will be precalculated when fitting to a dataset
603///
604/// By forcibly precalculating functions with non-trivial Jacobians,
605/// or functions of multiple variables occurring in the data set,
606/// using addColumn(), you may alter the outcome of the fit.
607///
608/// Only in cases where such a modification of fit behaviour is intentional,
609/// this function should be used.
610
612{
613 // Create a fundamental object of the right type to hold newVar values
614 auto valHolder = std::unique_ptr<RooAbsArg>{newVar.createFundamental()}.release();
615 // Sanity check that the holder really is fundamental
616 if(!valHolder->isFundamental()) {
617 coutE(InputArguments) << GetName() << "::addColumn: holder argument is not fundamental: \""
618 << valHolder->GetName() << "\"" << std::endl;
619 return nullptr;
620 }
621
622 // Attention: need to do this now, as adding an empty column might give 0 as size
623 const std::size_t numEvt = size();
624
625 // Clone variable and attach to cloned tree
626 std::unique_ptr<RooAbsArg> newVarClone{newVar.cloneTree()};
627 newVarClone->recursiveRedirectServers(_vars,false) ;
628
629 // Attach value place holder to this tree
630 valHolder->attachToVStore(*this) ;
633
634 // Fill values of placeholder
635 RealVector* rv(nullptr) ;
636 CatVector* cv(nullptr) ;
637 assert(numEvt != 0);
638 if (dynamic_cast<RooAbsReal*>(valHolder)) {
639 rv = addReal(static_cast<RooAbsReal*>(valHolder));
640 rv->resize(numEvt) ;
641 } else if (dynamic_cast<RooAbsCategory*>(static_cast<RooAbsCategory*>(valHolder))) {
642 cv = addCategory(static_cast<RooAbsCategory*>(valHolder)) ;
643 cv->resize(numEvt) ;
644 }
645
646 for (std::size_t i=0; i < numEvt; i++) {
647 get(i) ;
648
649 newVarClone->syncCache(&_vars) ;
650 valHolder->copyCache(newVarClone.get()) ;
651
652 if (rv) rv->write(i) ;
653 if (cv) cv->write(i) ;
654 }
655
656 return valHolder ;
657}
658
659
660
661////////////////////////////////////////////////////////////////////////////////
662/// Merge columns of supplied data set(s) with this data set. All
663/// data sets must have equal number of entries. In case of
664/// duplicate columns the column of the last dataset in the list
665/// prevails
666
668{
669 RooVectorDataStore* mergedStore = new RooVectorDataStore("merged","merged",allVars) ;
670
671 const auto nevt = dstoreList.front()->numEntries();
672 mergedStore->reserve(nevt);
673 for (int i=0 ; i<nevt ; i++) {
674
675 // Copy data from self
676 mergedStore->_vars.assign(*get(i)) ;
677
678 // Copy variables from merge sets
679 for (list<RooAbsDataStore*>::iterator iter = dstoreList.begin() ; iter!=dstoreList.end() ; ++iter) {
680 const RooArgSet* partSet = (*iter)->get(i) ;
681 mergedStore->_vars.assign(*partSet) ;
682 }
683
684 mergedStore->fill() ;
685 }
686 return mergedStore ;
687}
688
689
690
692{
693 for (auto elm : _realStoreList) {
694 elm->reserve(nEvts);
695 }
696
697 for (auto elm : _realfStoreList) {
698 elm->reserve(nEvts);
699 }
700
701 for (auto elm : _catStoreList) {
702 elm->reserve(nEvts);
703 }
704}
705
706////////////////////////////////////////////////////////////////////////////////
707
709{
710 Int_t nevt = other.numEntries() ;
711 reserve(nevt + numEntries());
712 for (int i=0 ; i<nevt ; i++) {
713 _vars.assign(*other.get(i)) ;
714 if (_wgtVar) {
715 _wgtVar->setVal(other.weight()) ;
716 }
717
718 fill() ;
719 }
720}
721
722
723
724////////////////////////////////////////////////////////////////////////////////
725
727{
729
730 for (auto elm : _realStoreList) {
731 elm->reset() ;
732 }
733
734 for (auto elm : _realfStoreList) {
735 elm->reset() ;
736 }
737
738 for (auto elm : _catStoreList) {
739 elm->reset() ;
740 }
741
742}
743
744////////////////////////////////////////////////////////////////////////////////
745/// Cache given RooAbsArgs: The tree is
746/// given direct write access of the args internal cache
747/// the args values is pre-calculated for all data points
748/// in this data collection. Upon a get() call, the
749/// internal cache of 'newVar' will be loaded with the
750/// precalculated value and it's dirty flag will be cleared.
751
753{
754 // Delete previous cache, if any
755 delete _cache ;
756 _cache = nullptr ;
757
758 // Reorder cached elements. First constant nodes, then tracked nodes in order of dependence
759
760 // Step 1 - split in constant and tracked
764 for (const auto arg : newVarSetCopy) {
765 if (arg->getAttribute("ConstantExpression") && !arg->getAttribute("NOCacheAndTrack")) {
766 orderedArgs.add(*arg) ;
767 } else {
768
769 // Explicitly check that arg depends on any of the observables, if this
770 // is not the case, skip it, as inclusion would result in repeated
771 // calculation of a function that has the same value for every event
772 // in the likelihood
773 if (arg->dependsOn(_vars) && !arg->getAttribute("NOCacheAndTrack")) {
774 trackArgs.push_back(arg) ;
775 } else {
776 newVarSet.remove(*arg) ;
777 }
778 }
779 }
780
781 // Step 2 - reorder tracked nodes
782 std::sort(trackArgs.begin(), trackArgs.end(), [](RooAbsArg* left, RooAbsArg* right){
783 //LM: exclude same comparison. This avoids an issue when using sort in MacOS versions
784 if (left == right) return false;
785 return right->dependsOn(*left);
786 });
787
788 // Step 3 - put back together
789 for (const auto trackedArg : trackArgs) {
791 }
792
793 // WVE need to prune tracking entries _below_ constant nodes as the're not needed
794
795 checkInit() ;
796
797 std::vector<std::unique_ptr<RooArgSet>> vlist;
799
800 for (const auto var : orderedArgs) {
801
802 // Clone variable and attach to cloned tree
803 auto newVarCloneList = std::make_unique<RooArgSet>();
805 RooAbsArg* newVarClone = newVarCloneList->find(var->GetName()) ;
806 newVarClone->recursiveRedirectServers(_vars,false) ;
807
808 vlist.emplace_back(std::move(newVarCloneList));
809 cloneSet.add(*newVarClone) ;
810 }
811
812 _cacheOwner = const_cast<RooAbsArg *>(owner);
814
815
817
818 std::vector<RooArgSet*> nsetList ;
819 std::vector<std::unique_ptr<RooArgSet>> argObsList ;
820 std::vector<std::unique_ptr<RooArgSet>> ownedNsets;
821
822 // Now need to attach branch buffers of clones
823 for (const auto arg : cloneSet) {
824 arg->attachToVStore(*newCache) ;
825
826 if(nset) argObsList.emplace_back(arg->getObservables(*nset));
827 else argObsList.emplace_back(arg->getVariables());
828 RooArgSet* argObs = argObsList.back().get();
829
830 RooArgSet* normSet(nullptr) ;
831 const char* catNset = arg->getStringAttribute("CATNormSet") ;
832 if (catNset) {
834 ownedNsets.emplace_back(anset.selectCommon(*argObs));
835 normSet = ownedNsets.back().get();
836 }
837 const char* catCset = arg->getStringAttribute("CATCondSet") ;
838 if (catCset) {
840 argObs->remove(acset,true,true) ;
841 normSet = argObs ;
842 }
843
844 // now construct normalization set for component from cset/nset spec
845 nsetList.push_back(normSet) ;
846 }
847
848
849 // Fill values of placeholder
850 const std::size_t numEvt = size();
851 newCache->reserve(numEvt);
852 for (std::size_t i=0; i < numEvt; i++) {
853 get(i) ;
854 if (weight()!=0 || !skipZeroWeights) {
855 for (unsigned int j = 0; j < cloneSet.size(); ++j) {
856 auto& cloneArg = cloneSet[j];
857 auto argNSet = nsetList[j];
858 // WVE need to intervene here for condobs from ProdPdf
859 cloneArg.syncCache(argNSet ? argNSet : nset) ;
860 }
861 }
862 newCache->fill() ;
863 }
864
866
867
868 // Now need to attach branch buffers of original function objects
869 for (const auto arg : orderedArgs) {
870 arg->attachToVStore(*newCache) ;
871
872 // Activate change tracking mode, if requested
873 if (!arg->getAttribute("ConstantExpression") && dynamic_cast<RooAbsReal*>(arg)) {
874 RealVector* rv = newCache->addReal(static_cast<RooAbsReal*>(arg)) ;
875 RooArgSet deps;
876 arg->getParameters(&_vars, deps);
877 rv->setDependents(deps) ;
878
879 // WV lookup normalization set and associate with RealVector
880 // find ordinal number of arg in original list
881 Int_t idx = cloneSet.index(arg->GetName()) ;
882
883 coutI(Optimization) << "RooVectorDataStore::cacheArg() element " << arg->GetName() << " has change tracking enabled on parameters " << deps << std::endl ;
884 rv->setNset(nsetList[idx]) ;
885 }
886
887 }
888
889 _cache = newCache ;
891}
892
893
898
899
900
901////////////////////////////////////////////////////////////////////////////////
902
904{
905 if (!_cache) return ;
906
907 std::vector<RooVectorDataStore::RealVector *> tv;
908 tv.reserve(static_cast<std::size_t>(_cache->_realStoreList.size() * 0.7)); // Typically, 30..60% need to be recalculated
909
910 // Check which items need recalculation
911 for (const auto realVec : _cache->_realStoreList) {
912 if (_forcedUpdate || realVec->needRecalc()) {
913 tv.push_back(realVec);
914 realVec->_nativeReal->setOperMode(RooAbsArg::ADirty);
915 realVec->_nativeReal->_operMode = RooAbsArg::Auto;
916 }
917 }
919
920 // If no recalculations are needed stop here
921 if (tv.empty()) {
922 return;
923 }
924
925
926 // Refill caches of elements that require recalculation
927 std::unique_ptr<RooArgSet> ownedNset;
928 RooArgSet* usedNset = nullptr;
929 if (projectedArgs && !projectedArgs->empty()) {
930 ownedNset = std::make_unique<RooArgSet>();
931 _vars.snapshot(*ownedNset, false) ;
932 ownedNset->remove(*projectedArgs,false,true);
933 usedNset = ownedNset.get();
934 } else {
935 usedNset = &_vars ;
936 }
937
938
939 for (int i=firstEvent ; i<lastEvent ; i+=stepSize) {
940 get(i) ;
941 bool zeroWeight = (weight()==0) ;
942 if (!zeroWeight || !skipZeroWeights) {
943 for (auto realVector : tv) {
944 realVector->_nativeReal->_valueDirty = true;
945 realVector->_nativeReal->getValV(realVector->_nset ? realVector->_nset : usedNset);
946 realVector->write(i);
947 }
948 }
949 }
950
951 for (auto realVector : tv) {
952 realVector->_nativeReal->setOperMode(RooAbsArg::AClean);
953 }
954}
955
956
957////////////////////////////////////////////////////////////////////////////////
958/// Initialize cache of dataset: attach variables of cache ArgSet
959/// to the corresponding TTree branches
960
962{
963 // Only applicable if a cache exists
964 if (!_cache) return ;
965
966 // Clone constructor, must connect internal storage to given new external set of variables
967 std::vector<RealVector*> cacheElements(_cache->realStoreList());
969
970 for (const auto elm : cacheElements) {
971 auto real = static_cast<RooAbsReal*>(cachedVarsIn.find(elm->bufArg()->GetName()));
972 if (real) {
973 // Adjust buffer pointer
974 real->attachToVStore(*_cache) ;
975 }
976 }
977
978 for (const auto catVec : _cache->_catStoreList) {
979 auto cat = static_cast<RooAbsCategory*>(cachedVarsIn.find(catVec->bufArg()->GetName()));
980 if (cat) {
981 // Adjust buffer pointer
982 cat->attachToVStore(*_cache) ;
983 }
984 }
985
986 _cacheOwner = const_cast<RooAbsArg*>(newOwner);
987}
988
989
990
991
992////////////////////////////////////////////////////////////////////////////////
993
995{
996 delete _cache;
997 _cache = nullptr;
998 _cacheOwner = nullptr;
999 return ;
1000}
1001
1002
1003
1004
1005
1006////////////////////////////////////////////////////////////////////////////////
1007/// Disabling of branches is (intentionally) not implemented in vector
1008/// data stores (as the doesn't result in a net saving of time)
1009
1010void RooVectorDataStore::setArgStatus(const RooArgSet& /*set*/, bool /*active*/)
1011{
1012 return ;
1013}
1014
1015
1016
1017
1018////////////////////////////////////////////////////////////////////////////////
1019
1021{
1022 for (auto arg : _varsww) {
1023 RooAbsArg* extArg = extObs.find(arg->GetName()) ;
1024 if (extArg) {
1025 extArg->attachToVStore(*this) ;
1026 }
1027 }
1028}
1029
1030
1031
1032////////////////////////////////////////////////////////////////////////////////
1033
1035{
1036 for (auto arg : _varsww) {
1037 arg->attachToVStore(*this);
1038 }
1039}
1040
1041
1042
1043////////////////////////////////////////////////////////////////////////////////
1044
1046{
1047 std::cout << "RooVectorDataStor::dump()" << std::endl ;
1048
1049 std::cout << "_varsww = " << std::endl ; _varsww.Print("v") ;
1050 std::cout << "realVector list is" << std::endl ;
1051
1052 for (const auto elm : _realStoreList) {
1053 std::cout << "RealVector " << elm << " _nativeReal = " << elm->_nativeReal << " = " << elm->_nativeReal->GetName() << " bufptr = " << elm->_buf << std::endl ;
1054 std::cout << " values : " ;
1055 Int_t imax = elm->_vec.size()>10 ? 10 : elm->_vec.size() ;
1056 for (Int_t i=0 ; i<imax ; i++) {
1057 std::cout << elm->_vec[i] << " " ;
1058 }
1059 std::cout << std::endl ;
1060 }
1061
1062 for (const auto elm : _realfStoreList) {
1063 std::cout << "RealFullVector " << elm << " _nativeReal = " << elm->_nativeReal << " = " << elm->_nativeReal->GetName()
1064 << " bufptr = " << elm->_buf << " errbufptr = " << elm->bufE() << std::endl ;
1065
1066 std::cout << " values : " ;
1067 Int_t imax = elm->_vec.size()>10 ? 10 : elm->_vec.size() ;
1068 for (Int_t i=0 ; i<imax ; i++) {
1069 std::cout << elm->_vec[i] << " " ;
1070 }
1071 std::cout << std::endl ;
1072 if (elm->bufE()) {
1073 std::cout << " errors : " ;
1074 for (Int_t i=0 ; i<imax ; i++) {
1075 std::cout << elm->dataE()[i] << " " ;
1076 }
1077 std::cout << std::endl ;
1078
1079 }
1080 }
1081}
1082
1083
1084////////////////////////////////////////////////////////////////////////////////
1085/// Stream an object of class RooVectorDataStore.
1086
1088{
1089 if (R__b.IsReading()) {
1090 R__b.ReadClassBuffer(RooVectorDataStore::Class(),this);
1091
1092 for (auto elm : _realStoreList) {
1093 RooAbsArg* arg = _varsww.find(elm->_nativeReal->GetName()) ;
1094 arg->attachToVStore(*this) ;
1095 }
1096 for (auto elm : _realfStoreList) {
1097 RooAbsArg* arg = _varsww.find(elm->_nativeReal->GetName()) ;
1098 arg->attachToVStore(*this) ;
1099 }
1100 for (auto elm : _catStoreList) {
1101 RooAbsArg* arg = _varsww.find(elm->_cat->GetName()) ;
1102 arg->attachToVStore(*this) ;
1103 }
1104
1105 } else {
1106 R__b.WriteClassBuffer(RooVectorDataStore::Class(),this);
1107 }
1108}
1109
1110
1111////////////////////////////////////////////////////////////////////////////////
1112/// Return batches of the data columns for the requested events.
1113/// \param[in] first First event in the batches.
1114/// \param[in] len Number of events in batches.
1115/// \return Spans with the associated data.
1116RooAbsData::RealSpans RooVectorDataStore::getBatches(std::size_t first, std::size_t len) const {
1118
1119 auto emplace = [this,&evalData,first,len](const RealVector* realVec) {
1120 auto span = realVec->getRange(first, first + len);
1121 auto result = evalData.emplace(realVec->_nativeReal, span);
1122 if (result.second == false || result.first->second.size() != len) {
1123 const auto size = result.second ? result.first->second.size() : 0;
1124 coutE(DataHandling) << "A batch of data for '" << realVec->_nativeReal->GetName()
1125 << "' was requested from " << first << " to " << first+len
1126 << ", but only the events [" << first << ", " << first + size << ") are available." << std::endl;
1127 }
1128 if (realVec->_real) {
1129 // If a buffer is attached, i.e. we are ready to load into a RooAbsReal outside of our dataset,
1130 // we can directly map our spans to this real.
1131 evalData.emplace(realVec->_real, span);
1132 }
1133 };
1134
1135 for (const auto realVec : _realStoreList) {
1136 emplace(realVec);
1137 }
1138 for (const auto realVec : _realfStoreList) {
1139 emplace(realVec);
1140 }
1141
1142 if (_cache) {
1143 for (const auto realVec : _cache->_realStoreList) {
1144 emplace(realVec);
1145 }
1146 for (const auto realVec : _cache->_realfStoreList) {
1147 emplace(realVec);
1148 }
1149 }
1150
1151 return evalData;
1152}
1153
1154
1157
1158 auto emplace = [this,&evalData,first,len](const CatVector* catVec) {
1159 auto span = catVec->getRange(first, first + len);
1160 auto result = evalData.emplace(catVec->_cat, span);
1161 if (result.second == false || result.first->second.size() != len) {
1162 const auto size = result.second ? result.first->second.size() : 0;
1163 coutE(DataHandling) << "A batch of data for '" << catVec->_cat->GetName()
1164 << "' was requested from " << first << " to " << first+len
1165 << ", but only the events [" << first << ", " << first + size << ") are available." << std::endl;
1166 }
1167 };
1168
1169 for (const auto& catVec : _catStoreList) {
1170 emplace(catVec);
1171 }
1172
1173 return evalData;
1174}
1175
1176
1177////////////////////////////////////////////////////////////////////////////////
1178/// Return the weights of all events in the range [first, first+len).
1179/// If an array with weights is stored, a batch with these weights will be returned. If
1180/// no weights are stored, an empty batch is returned. Use weight() to check if there's
1181/// a constant weight.
1182std::span<const double> RooVectorDataStore::getWeightBatch(std::size_t first, std::size_t len) const
1183{
1184 if (_extWgtArray) {
1185 return std::span<const double>(_extWgtArray + first, _extWgtArray + first + len);
1186 }
1187
1188 if (_wgtVar) {
1189 auto findWeightVar = [this](const RealVector* realVec) {
1190 return realVec->_nativeReal == _wgtVar || realVec->_nativeReal->GetName() == _wgtVar->GetName();
1191 };
1192
1193 auto storageIter = std::find_if(_realStoreList.begin(), _realStoreList.end(), findWeightVar);
1195 return (*storageIter)->getRange(first, first + len);
1196
1197 auto fstorageIter = std::find_if(_realfStoreList.begin(), _realfStoreList.end(), findWeightVar);
1199 return (*fstorageIter)->getRange(first, first + len);
1200
1201 throw std::logic_error("RooVectorDataStore::getWeightBatch(): Could not retrieve data for _wgtVar.");
1202 }
1203 return {};
1204}
1205
1206
1208
1209 // First try a match by name
1210 for (auto catVec : _catStoreList) {
1211 if (std::string(catVec->bufArg()->GetName())==cat->GetName()) {
1212 return catVec;
1213 }
1214 }
1215
1216 // If nothing found this will make an entry
1217 _catStoreList.push_back(new CatVector(cat)) ;
1218
1219 return _catStoreList.back() ;
1220}
1221
1222
1224
1225 // First try a match by name
1226 for (auto realVec : _realStoreList) {
1227 if (realVec->bufArg()->namePtr()==real->namePtr()) {
1228 return realVec;
1229 }
1230 }
1231
1232 // Then check if an entry already exists for a full real
1233 for (auto fullVec : _realfStoreList) {
1234 if (fullVec->bufArg()->namePtr()==real->namePtr()) {
1235 // Return full vector as RealVector base class here
1236 return fullVec;
1237 }
1238 }
1239
1240 // If nothing found this will make an entry
1241 _realStoreList.push_back(new RealVector(real)) ;
1242
1243 return _realStoreList.back() ;
1244}
1245
1246
1248
1249 // First try a match by name
1250 for (auto fullVec : _realfStoreList) {
1251 if (std::string(fullVec->bufArg()->GetName())==real->GetName()) {
1252 return true ;
1253 }
1254 }
1255 return false ;
1256}
1257
1258
1260
1261 // First try a match by name
1262 for (auto fullVec : _realfStoreList) {
1263 if (std::string(fullVec->bufArg()->GetName())==real->GetName()) {
1264 return fullVec->bufE();
1265 }
1266 }
1267 return false ;
1268}
1269
1270
1272
1273 // First try a match by name
1274 for (auto fullVec : _realfStoreList) {
1275 if (std::string(fullVec->bufArg()->GetName())==real->GetName()) {
1276 return fullVec->bufEL();
1277 }
1278 }
1279 return false ;
1280}
1281
1282
1284
1285 // First try a match by name
1286 for (auto fullVec : _realfStoreList) {
1287 if (std::string(fullVec->bufArg()->GetName())==real->GetName()) {
1288 return fullVec;
1289 }
1290 }
1291
1292 // Then check if an entry already exists for a bare real
1293 for (auto realVec : _realStoreList) {
1294 if (std::string(realVec->bufArg()->GetName())==real->GetName()) {
1295
1296 // Convert element to full and add to full list
1297 _realfStoreList.push_back(new RealFullVector(*realVec,real)) ;
1298
1299 // Delete bare element
1300 _realStoreList.erase(std::find(_realStoreList.begin(), _realStoreList.end(), realVec));
1301 delete realVec;
1302
1303 return _realfStoreList.back() ;
1304 }
1305 }
1306
1307 // If nothing found this will make an entry
1308 _realfStoreList.push_back(new RealFullVector(real)) ;
1309
1310 return _realfStoreList.back() ;
1311}
1312
1313
1314/// Trigger a recomputation of the cached weight sums. Meant for use by RooFit
1315/// dataset converter functions such as the NumPy converter functions
1316/// implemented as pythonizations.
1318 double const* arr = nullptr;
1319 if (_extWgtArray) {
1320 arr = _extWgtArray;
1321 }
1322 if (_wgtVar) {
1323 const std::string wgtName = _wgtVar->GetName();
1324 for(auto const* real : _realStoreList) {
1325 if(wgtName == real->_nativeReal->GetName())
1326 arr = real->_vec.data();
1327 }
1328 for(auto const* real : _realfStoreList) {
1329 if(wgtName == real->_nativeReal->GetName())
1330 arr = real->_vec.data();
1331 }
1332 }
1333 if(arr == nullptr) {
1334 _sumWeight = size();
1335 return;
1336 }
1338 _sumWeight = result.Sum();
1339 _sumWeightCarry = result.Carry();
1340}
1341
1342
1343/// Exports all arrays in this RooVectorDataStore into a simple datastructure
1344/// to be used by RooFit internal export functions.
1346 ArraysStruct out;
1347 out.size = size();
1348
1349 for(auto const* real : _realStoreList) {
1350 out.reals.emplace_back(real->_nativeReal->GetName(), real->_vec.data());
1351 }
1352 for(auto const* realf : _realfStoreList) {
1353 std::string name = realf->_nativeReal->GetName();
1354 out.reals.emplace_back(name, realf->_vec.data());
1355 if(realf->bufE()) out.reals.emplace_back(name + "Err", realf->dataE().data());
1356 if(realf->bufEL()) out.reals.emplace_back(name + "ErrLo", realf->dataEL().data());
1357 if(realf->bufEH()) out.reals.emplace_back(name + "ErrHi", realf->dataEH().data());
1358 }
1359 for(auto const* cat : _catStoreList) {
1360 out.cats.emplace_back(cat->_cat->GetName(), cat->_vec.data());
1361 }
1362
1363 if(_extWgtArray) out.reals.emplace_back("weight", _extWgtArray);
1364 if(_extWgtErrLoArray) out.reals.emplace_back("wgtErrLo", _extWgtErrLoArray);
1365 if(_extWgtErrHiArray) out.reals.emplace_back("wgtErrHi", _extWgtErrHiArray);
1366 if(_extSumW2Array) out.reals.emplace_back("sumW2",_extSumW2Array);
1367
1368 return out;
1369}
#define coutI(a)
#define coutE(a)
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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 result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
char name[80]
Definition TGX11.cxx:148
#define hi
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2570
static KahanSum< T, N > Accumulate(Iterator begin, Iterator end, T initialValue=T{})
Iterate over a range and return an instance of a KahanSum.
Definition Util.h:230
const_iterator begin() const
const_iterator end() const
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:76
static void setDirtyInhibit(bool flag)
Control global dirty inhibit mode.
bool getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
virtual void attachToVStore(RooVectorDataStore &vstore)=0
A space to attach TBranches.
void attachToVStore(RooVectorDataStore &vstore) override
Attach the category index and label to as branches to the given vector store.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
void assign(const RooAbsCollection &other) const
Sets the value, cache and constant attribute of any argument in our set that also appears in the othe...
RooAbsArg * find(const char *name) const
Find object with given name in list.
void Print(Option_t *options=nullptr) const override
This method must be overridden when a class wants to print itself.
Abstract base class for a data collection.
virtual void checkInit() const
bool _doDirtyProp
Switch do (de)activate dirty state propagation when loading a data point.
std::map< RooFit::Detail::DataKey, std::span< const double > > RealSpans
Definition RooAbsData.h:132
std::map< RooFit::Detail::DataKey, std::span< const RooAbsCategory::value_type > > CategorySpans
Definition RooAbsData.h:133
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:63
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition RooAbsReal.h:107
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:24
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
Definition RooArgSet.h:159
A RooFormulaVar is a generic implementation of a real-valued object, which takes a RooArgList of serv...
static const RooHistError & instance()
Return a reference to a singleton object that is created the first time this method is called.
Variable that can be changed from the outside.
Definition RooRealVar.h:37
void setVal(double value) override
Set value of variable to 'value'.
double getError() const
Definition RooRealVar.h:59
bool hasError(bool allowZero=true) const
Definition RooRealVar.h:60
bool hasAsymError(bool allowZero=true) const
Definition RooRealVar.h:65
double getAsymErrorHi() const
Definition RooRealVar.h:64
double getAsymErrorLo() const
Definition RooRealVar.h:63
The RooStringView is a wrapper around a C-style string that can also be constructed from a std::strin...
TTree-backed data storage.
Uses std::vector to store data columns.
void recalculateCache(const RooArgSet *, Int_t firstEvent, Int_t lastEvent, Int_t stepSize, bool skipZeroWeights) override
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
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'.
RooVectorDataStore * _cache
! Optimization cache
const double * _extWgtErrHiArray
! External weight array - high error
std::span< const double > getWeightBatch(std::size_t first, std::size_t len) const override
Return the weights of all events in the range [first, first+len).
~RooVectorDataStore() override
Destructor.
static TClass * Class()
RooRealVar * weightVar(const RooArgSet &allVars, const char *wgtName)
Utility function for constructors Return pointer to weight variable if it is defined.
void cacheArgs(const RooAbsArg *owner, RooArgSet &varSet, const RooArgSet *nset=nullptr, bool skipZeroWeights=true) override
Cache given RooAbsArgs: The tree is given direct write access of the args internal cache the args val...
RooRealVar * _wgtVar
Pointer to weight variable (if set)
std::vector< RealVector * > _realStoreList
CatVector * addCategory(RooAbsCategory *cat)
void loadValues(const RooAbsDataStore *tds, const RooFormulaVar *select=nullptr, const char *rangeName=nullptr, std::size_t nStart=0, std::size_t nStop=std::numeric_limits< std::size_t >::max()) override
const RooArgSet * get(Int_t index) const override
Load the n-th data point (n='index') into the variables of this dataset, and return a pointer to the ...
RealFullVector * addRealFull(RooAbsReal *real)
double weight() const override
Return the weight of the last-retrieved data point.
RooAbsData::RealSpans getBatches(std::size_t first, std::size_t len) const override
Return batches of the data columns for the requested events.
bool isFullReal(RooAbsReal *real)
Int_t fill() override
Interface function to TTree::Fill.
const double * _extWgtErrLoArray
! External weight array - low error
bool _forcedUpdate
! Request for forced cache update
void append(RooAbsDataStore &other) override
bool hasError(RooAbsReal *real)
std::vector< CatVector * > _catStoreList
void setArgStatus(const RooArgSet &set, bool active) override
Disabling of branches is (intentionally) not implemented in vector data stores (as the doesn't result...
double weightError(RooAbsData::ErrorType etype=RooAbsData::Poisson) const override
Return the error of the current weight.
void attachBuffers(const RooArgSet &extObs) override
ArraysStruct getArrays() const
Exports all arrays in this RooVectorDataStore into a simple datastructure to be used by RooFit intern...
RooAbsData::CategorySpans getCategoryBatches(std::size_t, std::size_t len) const override
RooAbsDataStore * merge(const RooArgSet &allvars, std::list< RooAbsDataStore * > dstoreList) override
Merge columns of supplied data set(s) with this data set.
void setDirtyProp(bool flag) override
RealVector * addReal(RooAbsReal *real)
bool hasAsymError(RooAbsReal *real)
bool changeObservableName(const char *from, const char *to) override
void forceCacheUpdate() override
const double * _extSumW2Array
! External sum of weights array
void recomputeSumWeight()
Trigger a recomputation of the cached weight sums.
std::vector< RealVector * > & realStoreList()
std::size_t size() const
Get size of stored dataset.
std::unique_ptr< RooAbsDataStore > reduce(RooStringView name, RooStringView title, const RooArgSet &vars, const RooFormulaVar *cutVar, const char *cutRange, std::size_t nStart, std::size_t nStop) override
virtual const RooArgSet * get() const
const double * _extWgtArray
! External weight array
void Streamer(TBuffer &) override
Stream an object of class RooVectorDataStore.
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
Buffer base class used for serializing objects.
Definition TBuffer.h:43
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:173
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
Double_t y[n]
Definition legend1.C:17
std::vector< std::string > Split(std::string_view str, std::string_view delims, bool skipEmpty=false)
Splits a string at each character in delims.
RooArgSet selectFromArgSet(RooArgSet const &, std::string const &names)
Output struct for the RooVectorDataStore::getArrays() helper function.
std::vector< ArrayInfo< double > > reals
std::vector< ArrayInfo< RooAbsCategory::value_type > > cats