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