Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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// std::cout << "Number of Cache-and-Tracked args are " << trackArgs.size() << std::endl ;
804// std::cout << "Compound ordered cache parameters = " << std::endl ;
805// orderedArgs.Print("v") ;
806
807 checkInit() ;
808
809 std::vector<std::unique_ptr<RooArgSet>> vlist;
811
812 for (const auto var : orderedArgs) {
813
814 // Clone variable and attach to cloned tree
815 auto newVarCloneList = std::make_unique<RooArgSet>();
817 RooAbsArg* newVarClone = newVarCloneList->find(var->GetName()) ;
818 newVarClone->recursiveRedirectServers(_vars,false) ;
819
820 vlist.emplace_back(std::move(newVarCloneList));
821 cloneSet.add(*newVarClone) ;
822 }
823
824 _cacheOwner = const_cast<RooAbsArg *>(owner);
826
827
829
830 std::vector<RooArgSet*> nsetList ;
831 std::vector<std::unique_ptr<RooArgSet>> argObsList ;
832
833 // Now need to attach branch buffers of clones
834 for (const auto arg : cloneSet) {
835 arg->attachToVStore(*newCache) ;
836
837 if(nset) argObsList.emplace_back(arg->getObservables(*nset));
838 else argObsList.emplace_back(arg->getVariables());
839 RooArgSet* argObs = argObsList.back().get();
840
841 RooArgSet* normSet(nullptr) ;
842 const char* catNset = arg->getStringAttribute("CATNormSet") ;
843 if (catNset) {
844// std::cout << "RooVectorDataStore::cacheArgs() cached node " << arg->GetName() << " has a normalization set specification CATNormSet = " << catNset << std::endl ;
845
847 normSet = anset.selectCommon(*argObs);
848
849 }
850 const char* catCset = arg->getStringAttribute("CATCondSet") ;
851 if (catCset) {
852// std::cout << "RooVectorDataStore::cacheArgs() cached node " << arg->GetName() << " has a conditional observable set specification CATCondSet = " << catCset << std::endl ;
853
855 argObs->remove(acset,true,true) ;
856 normSet = argObs ;
857 }
858
859 // now construct normalization set for component from cset/nset spec
860// if (normSet) {
861// std::cout << "RooVectorDaraStore::cacheArgs() component " << arg->GetName() << " has custom normalization set " << *normSet << std::endl ;
862// }
863 nsetList.push_back(normSet) ;
864 }
865
866
867 // Fill values of placeholder
868 const std::size_t numEvt = size();
869 newCache->reserve(numEvt);
870 for (std::size_t i=0; i < numEvt; i++) {
871 get(i) ;
872 if (weight()!=0 || !skipZeroWeights) {
873 for (unsigned int j = 0; j < cloneSet.size(); ++j) {
874 auto& cloneArg = cloneSet[j];
875 auto argNSet = nsetList[j];
876 // WVE need to intervene here for condobs from ProdPdf
877 cloneArg.syncCache(argNSet ? argNSet : nset) ;
878 }
879 }
880 newCache->fill() ;
881 }
882
884
885
886 // Now need to attach branch buffers of original function objects
887 for (const auto arg : orderedArgs) {
888 arg->attachToVStore(*newCache) ;
889
890 // Activate change tracking mode, if requested
891 if (!arg->getAttribute("ConstantExpression") && dynamic_cast<RooAbsReal*>(arg)) {
892 RealVector* rv = newCache->addReal(static_cast<RooAbsReal*>(arg)) ;
893 RooArgSet deps;
894 arg->getParameters(&_vars, deps);
895 rv->setDependents(deps) ;
896
897 // WV lookup normalization set and associate with RealVector
898 // find ordinal number of arg in original list
899 Int_t idx = cloneSet.index(arg->GetName()) ;
900
901 coutI(Optimization) << "RooVectorDataStore::cacheArg() element " << arg->GetName() << " has change tracking enabled on parameters " << deps << std::endl ;
902 rv->setNset(nsetList[idx]) ;
903 }
904
905 }
906
907 _cache = newCache ;
909}
910
911
916
917
918
919////////////////////////////////////////////////////////////////////////////////
920
922{
923 if (!_cache) return ;
924
925 std::vector<RooVectorDataStore::RealVector *> tv;
926 tv.reserve(static_cast<std::size_t>(_cache->_realStoreList.size() * 0.7)); // Typically, 30..60% need to be recalculated
927
928 // Check which items need recalculation
929 for (const auto realVec : _cache->_realStoreList) {
930 if (_forcedUpdate || realVec->needRecalc()) {
931 tv.push_back(realVec);
932 realVec->_nativeReal->setOperMode(RooAbsArg::ADirty);
933 realVec->_nativeReal->_operMode = RooAbsArg::Auto;
934 }
935 }
937
938 // If no recalculations are needed stop here
939 if (tv.empty()) {
940 return;
941 }
942
943
944 // Refill caches of elements that require recalculation
945 std::unique_ptr<RooArgSet> ownedNset;
946 RooArgSet* usedNset = nullptr;
947 if (projectedArgs && !projectedArgs->empty()) {
948 ownedNset = std::make_unique<RooArgSet>();
949 _vars.snapshot(*ownedNset, false) ;
950 ownedNset->remove(*projectedArgs,false,true);
951 usedNset = ownedNset.get();
952 } else {
953 usedNset = &_vars ;
954 }
955
956
957 for (int i=firstEvent ; i<lastEvent ; i+=stepSize) {
958 get(i) ;
959 bool zeroWeight = (weight()==0) ;
960 if (!zeroWeight || !skipZeroWeights) {
961 for (auto realVector : tv) {
962 realVector->_nativeReal->_valueDirty = true;
963 realVector->_nativeReal->getValV(realVector->_nset ? realVector->_nset : usedNset);
964 realVector->write(i);
965 }
966 }
967 }
968
969 for (auto realVector : tv) {
970 realVector->_nativeReal->setOperMode(RooAbsArg::AClean);
971 }
972}
973
974
975////////////////////////////////////////////////////////////////////////////////
976/// Initialize cache of dataset: attach variables of cache ArgSet
977/// to the corresponding TTree branches
978
980{
981 // Only applicable if a cache exists
982 if (!_cache) return ;
983
984 // Clone constructor, must connect internal storage to given new external set of variables
985 std::vector<RealVector*> cacheElements(_cache->realStoreList());
987
988 for (const auto elm : cacheElements) {
989 auto real = static_cast<RooAbsReal*>(cachedVarsIn.find(elm->bufArg()->GetName()));
990 if (real) {
991 // Adjust buffer pointer
992 real->attachToVStore(*_cache) ;
993 }
994 }
995
996 for (const auto catVec : _cache->_catStoreList) {
997 auto cat = static_cast<RooAbsCategory*>(cachedVarsIn.find(catVec->bufArg()->GetName()));
998 if (cat) {
999 // Adjust buffer pointer
1000 cat->attachToVStore(*_cache) ;
1001 }
1002 }
1003
1004 _cacheOwner = const_cast<RooAbsArg*>(newOwner);
1005}
1006
1007
1008
1009
1010////////////////////////////////////////////////////////////////////////////////
1011
1013{
1014 delete _cache;
1015 _cache = nullptr;
1016 _cacheOwner = nullptr;
1017 return ;
1018}
1019
1020
1021
1022
1023
1024////////////////////////////////////////////////////////////////////////////////
1025/// Disabling of branches is (intentionally) not implemented in vector
1026/// data stores (as the doesn't result in a net saving of time)
1027
1028void RooVectorDataStore::setArgStatus(const RooArgSet& /*set*/, bool /*active*/)
1029{
1030 return ;
1031}
1032
1033
1034
1035
1036////////////////////////////////////////////////////////////////////////////////
1037
1039{
1040 for (auto arg : _varsww) {
1041 RooAbsArg* extArg = extObs.find(arg->GetName()) ;
1042 if (extArg) {
1043 extArg->attachToVStore(*this) ;
1044 }
1045 }
1046}
1047
1048
1049
1050////////////////////////////////////////////////////////////////////////////////
1051
1053{
1054 for (auto arg : _varsww) {
1055 arg->attachToVStore(*this);
1056 }
1057}
1058
1059
1060
1061////////////////////////////////////////////////////////////////////////////////
1062
1064{
1065 std::cout << "RooVectorDataStor::dump()" << std::endl ;
1066
1067 std::cout << "_varsww = " << std::endl ; _varsww.Print("v") ;
1068 std::cout << "realVector list is" << std::endl ;
1069
1070 for (const auto elm : _realStoreList) {
1071 std::cout << "RealVector " << elm << " _nativeReal = " << elm->_nativeReal << " = " << elm->_nativeReal->GetName() << " bufptr = " << elm->_buf << std::endl ;
1072 std::cout << " values : " ;
1073 Int_t imax = elm->_vec.size()>10 ? 10 : elm->_vec.size() ;
1074 for (Int_t i=0 ; i<imax ; i++) {
1075 std::cout << elm->_vec[i] << " " ;
1076 }
1077 std::cout << std::endl ;
1078 }
1079
1080 for (const auto elm : _realfStoreList) {
1081 std::cout << "RealFullVector " << elm << " _nativeReal = " << elm->_nativeReal << " = " << elm->_nativeReal->GetName()
1082 << " bufptr = " << elm->_buf << " errbufptr = " << elm->bufE() << std::endl ;
1083
1084 std::cout << " values : " ;
1085 Int_t imax = elm->_vec.size()>10 ? 10 : elm->_vec.size() ;
1086 for (Int_t i=0 ; i<imax ; i++) {
1087 std::cout << elm->_vec[i] << " " ;
1088 }
1089 std::cout << std::endl ;
1090 if (elm->bufE()) {
1091 std::cout << " errors : " ;
1092 for (Int_t i=0 ; i<imax ; i++) {
1093 std::cout << elm->dataE()[i] << " " ;
1094 }
1095 std::cout << std::endl ;
1096
1097 }
1098 }
1099}
1100
1101
1102////////////////////////////////////////////////////////////////////////////////
1103/// Stream an object of class RooVectorDataStore.
1104
1106{
1107 if (R__b.IsReading()) {
1108 R__b.ReadClassBuffer(RooVectorDataStore::Class(),this);
1109
1110 for (auto elm : _realStoreList) {
1111 RooAbsArg* arg = _varsww.find(elm->_nativeReal->GetName()) ;
1112 arg->attachToVStore(*this) ;
1113 }
1114 for (auto elm : _realfStoreList) {
1115 RooAbsArg* arg = _varsww.find(elm->_nativeReal->GetName()) ;
1116 arg->attachToVStore(*this) ;
1117 }
1118 for (auto elm : _catStoreList) {
1119 RooAbsArg* arg = _varsww.find(elm->_cat->GetName()) ;
1120 arg->attachToVStore(*this) ;
1121 }
1122
1123 } else {
1124 R__b.WriteClassBuffer(RooVectorDataStore::Class(),this);
1125 }
1126}
1127
1128
1129////////////////////////////////////////////////////////////////////////////////
1130/// Return batches of the data columns for the requested events.
1131/// \param[in] first First event in the batches.
1132/// \param[in] len Number of events in batches.
1133/// \return Spans with the associated data.
1134RooAbsData::RealSpans RooVectorDataStore::getBatches(std::size_t first, std::size_t len) const {
1136
1137 auto emplace = [this,&evalData,first,len](const RealVector* realVec) {
1138 auto span = realVec->getRange(first, first + len);
1139 auto result = evalData.emplace(realVec->_nativeReal, span);
1140 if (result.second == false || result.first->second.size() != len) {
1141 const auto size = result.second ? result.first->second.size() : 0;
1142 coutE(DataHandling) << "A batch of data for '" << realVec->_nativeReal->GetName()
1143 << "' was requested from " << first << " to " << first+len
1144 << ", but only the events [" << first << ", " << first + size << ") are available." << std::endl;
1145 }
1146 if (realVec->_real) {
1147 // If a buffer is attached, i.e. we are ready to load into a RooAbsReal outside of our dataset,
1148 // we can directly map our spans to this real.
1149 evalData.emplace(realVec->_real, span);
1150 }
1151 };
1152
1153 for (const auto realVec : _realStoreList) {
1155 }
1156 for (const auto realVec : _realfStoreList) {
1158 }
1159
1160 if (_cache) {
1161 for (const auto realVec : _cache->_realStoreList) {
1163 }
1164 for (const auto realVec : _cache->_realfStoreList) {
1166 }
1167 }
1168
1169 return evalData;
1170}
1171
1172
1175
1176 auto emplace = [this,&evalData,first,len](const CatVector* catVec) {
1177 auto span = catVec->getRange(first, first + len);
1178 auto result = evalData.emplace(catVec->_cat, span);
1179 if (result.second == false || result.first->second.size() != len) {
1180 const auto size = result.second ? result.first->second.size() : 0;
1181 coutE(DataHandling) << "A batch of data for '" << catVec->_cat->GetName()
1182 << "' was requested from " << first << " to " << first+len
1183 << ", but only the events [" << first << ", " << first + size << ") are available." << std::endl;
1184 }
1185 };
1186
1187 for (const auto& catVec : _catStoreList) {
1188 emplace(catVec);
1189 }
1190
1191 return evalData;
1192}
1193
1194
1195////////////////////////////////////////////////////////////////////////////////
1196/// Return the weights of all events in the range [first, first+len).
1197/// If an array with weights is stored, a batch with these weights will be returned. If
1198/// no weights are stored, an empty batch is returned. Use weight() to check if there's
1199/// a constant weight.
1200std::span<const double> RooVectorDataStore::getWeightBatch(std::size_t first, std::size_t len) const
1201{
1202 if (_extWgtArray) {
1203 return std::span<const double>(_extWgtArray + first, _extWgtArray + first + len);
1204 }
1205
1206 if (_wgtVar) {
1207 auto findWeightVar = [this](const RealVector* realVec) {
1208 return realVec->_nativeReal == _wgtVar || realVec->_nativeReal->GetName() == _wgtVar->GetName();
1209 };
1210
1211 auto storageIter = std::find_if(_realStoreList.begin(), _realStoreList.end(), findWeightVar);
1213 return (*storageIter)->getRange(first, first + len);
1214
1215 auto fstorageIter = std::find_if(_realfStoreList.begin(), _realfStoreList.end(), findWeightVar);
1217 return (*fstorageIter)->getRange(first, first + len);
1218
1219 throw std::logic_error("RooVectorDataStore::getWeightBatch(): Could not retrieve data for _wgtVar.");
1220 }
1221 return {};
1222}
1223
1224
1226
1227 // First try a match by name
1228 for (auto catVec : _catStoreList) {
1229 if (std::string(catVec->bufArg()->GetName())==cat->GetName()) {
1230 return catVec;
1231 }
1232 }
1233
1234 // If nothing found this will make an entry
1235 _catStoreList.push_back(new CatVector(cat)) ;
1236
1237 return _catStoreList.back() ;
1238}
1239
1240
1242
1243 // First try a match by name
1244 for (auto realVec : _realStoreList) {
1245 if (realVec->bufArg()->namePtr()==real->namePtr()) {
1246 return realVec;
1247 }
1248 }
1249
1250 // Then check if an entry already exists for a full real
1251 for (auto fullVec : _realfStoreList) {
1252 if (fullVec->bufArg()->namePtr()==real->namePtr()) {
1253 // Return full vector as RealVector base class here
1254 return fullVec;
1255 }
1256 }
1257
1258 // If nothing found this will make an entry
1259 _realStoreList.push_back(new RealVector(real)) ;
1260
1261 return _realStoreList.back() ;
1262}
1263
1264
1266
1267 // First try a match by name
1268 for (auto fullVec : _realfStoreList) {
1269 if (std::string(fullVec->bufArg()->GetName())==real->GetName()) {
1270 return true ;
1271 }
1272 }
1273 return false ;
1274}
1275
1276
1278
1279 // First try a match by name
1280 for (auto fullVec : _realfStoreList) {
1281 if (std::string(fullVec->bufArg()->GetName())==real->GetName()) {
1282 return fullVec->bufE();
1283 }
1284 }
1285 return false ;
1286}
1287
1288
1290
1291 // First try a match by name
1292 for (auto fullVec : _realfStoreList) {
1293 if (std::string(fullVec->bufArg()->GetName())==real->GetName()) {
1294 return fullVec->bufEL();
1295 }
1296 }
1297 return false ;
1298}
1299
1300
1302
1303 // First try a match by name
1304 for (auto fullVec : _realfStoreList) {
1305 if (std::string(fullVec->bufArg()->GetName())==real->GetName()) {
1306 return fullVec;
1307 }
1308 }
1309
1310 // Then check if an entry already exists for a bare real
1311 for (auto realVec : _realStoreList) {
1312 if (std::string(realVec->bufArg()->GetName())==real->GetName()) {
1313
1314 // Convert element to full and add to full list
1315 _realfStoreList.push_back(new RealFullVector(*realVec,real)) ;
1316
1317 // Delete bare element
1318 _realStoreList.erase(std::find(_realStoreList.begin(), _realStoreList.end(), realVec));
1319 delete realVec;
1320
1321 return _realfStoreList.back() ;
1322 }
1323 }
1324
1325 // If nothing found this will make an entry
1326 _realfStoreList.push_back(new RealFullVector(real)) ;
1327
1328 return _realfStoreList.back() ;
1329}
1330
1331
1332/// Trigger a recomputation of the cached weight sums. Meant for use by RooFit
1333/// dataset converter functions such as the NumPy converter functions
1334/// implemented as pythonizations.
1336 double const* arr = nullptr;
1337 if (_extWgtArray) {
1338 arr = _extWgtArray;
1339 }
1340 if (_wgtVar) {
1341 const std::string wgtName = _wgtVar->GetName();
1342 for(auto const* real : _realStoreList) {
1343 if(wgtName == real->_nativeReal->GetName())
1344 arr = real->_vec.data();
1345 }
1346 for(auto const* real : _realfStoreList) {
1347 if(wgtName == real->_nativeReal->GetName())
1348 arr = real->_vec.data();
1349 }
1350 }
1351 if(arr == nullptr) {
1352 _sumWeight = size();
1353 return;
1354 }
1356 _sumWeight = result.Sum();
1357 _sumWeightCarry = result.Carry();
1358}
1359
1360
1361/// Exports all arrays in this RooVectorDataStore into a simple datastructure
1362/// to be used by RooFit internal export functions.
1364 ArraysStruct out;
1365 out.size = size();
1366
1367 for(auto const* real : _realStoreList) {
1368 out.reals.emplace_back(real->_nativeReal->GetName(), real->_vec.data());
1369 }
1370 for(auto const* realf : _realfStoreList) {
1371 std::string name = realf->_nativeReal->GetName();
1372 out.reals.emplace_back(name, realf->_vec.data());
1373 if(realf->bufE()) out.reals.emplace_back(name + "Err", realf->dataE().data());
1374 if(realf->bufEL()) out.reals.emplace_back(name + "ErrLo", realf->dataEL().data());
1375 if(realf->bufEH()) out.reals.emplace_back(name + "ErrHi", realf->dataEH().data());
1376 }
1377 for(auto const* cat : _catStoreList) {
1378 out.cats.emplace_back(cat->_cat->GetName(), cat->_vec.data());
1379 }
1380
1381 if(_extWgtArray) out.reals.emplace_back("weight", _extWgtArray);
1382 if(_extWgtErrLoArray) out.reals.emplace_back("wgtErrLo", _extWgtErrLoArray);
1383 if(_extWgtErrHiArray) out.reals.emplace_back("wgtErrHi", _extWgtErrHiArray);
1384 if(_extSumW2Array) out.reals.emplace_back("sumW2",_extSumW2Array);
1385
1386 return out;
1387}
#define coutI(a)
#define coutE(a)
#define TRACE_DESTROY
Definition RooTrace.h:24
#define TRACE_CREATE
Definition RooTrace.h:23
int Int_t
Definition RtypesCore.h:45
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:110
#define hi
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2489
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:211
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:77
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:133
std::map< RooFit::Detail::DataKey, std::span< const RooAbsCategory::value_type > > CategorySpans
Definition RooAbsData.h:134
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition RooAbsReal.h:103
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:58
bool hasError(bool allowZero=true) const
Definition RooRealVar.h:59
bool hasAsymError(bool allowZero=true) const
Definition RooRealVar.h:64
double getAsymErrorHi() const
Definition RooRealVar.h:63
double getAsymErrorLo() const
Definition RooRealVar.h:62
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:174
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