16#ifndef ROO_VECTOR_DATA_STORE
17#define ROO_VECTOR_DATA_STORE
38#define VECTOR_BUFFER_SIZE 1024
60 std::size_t nStart, std::size_t nStop,
Bool_t ,
const char* wgtVarName=0) ;
76 std::vector<ArrayInfo<double>>
reals;
77 std::vector<ArrayInfo<RooAbsCategory::value_type>>
cats;
155 virtual void reset()
override;
173 void loadValues(
const RooAbsDataStore *tds,
const RooFormulaVar* select=0,
const char* rangeName=0, std::size_t nStart=0, std::size_t nStop = std::numeric_limits<std::size_t>::max())
override;
175 void dump()
override;
225 if (&other==
this)
return *
this;
231 std::vector<Double_t> tmp;
233 tmp.assign(other.
_vec.begin(), other.
_vec.end());
278 assert(
static_cast<std::size_t
>(i) <
_vec.size());
286 inline void load(std::size_t idx)
const {
287 assert(idx <
_vec.size());
293 auto end = std::min(
_vec.cbegin() + last,
_vec.cend());
307 std::vector<Double_t> tmp;
310 tmp.assign(
_vec.begin(), std::min(
_vec.end(),
_vec.begin() + siz));
311 if (
Int_t(tmp.size()) != siz)
323 const std::vector<double>&
data()
const {
382 if (&other==
this)
return *
this;
392 for (
unsigned i = 0; i < 3; ++i) {
395 if (dst[i]->
size() <= src[i]->capacity() / 2 &&
397 std::vector<Double_t> tmp;
399 tmp.assign(src[i]->begin(), src[i]->end());
405 dst[i] =
new std::vector<Double_t>(*src[i]);
418 if (!
_vecE)
_vecE =
new std::vector<Double_t> ;
425 _vecEL =
new std::vector<Double_t> ;
426 _vecEH =
new std::vector<Double_t> ;
464 std::vector<Double_t> tmp;
468 std::vector<Double_t> tmp;
472 std::vector<Double_t> tmp;
487 for (
unsigned i = 0; i < 3; ++i) {
488 if (!vlist[i])
continue;
492 std::vector<Double_t> tmp;
494 if (!vlist[i]->empty())
495 tmp.assign(vlist[i]->begin(),
496 std::min(
_vec.end(),
_vec.begin() + siz));
497 if (
Int_t(tmp.size()) != siz)
501 vlist[i]->resize(siz);
536 _vec.reserve(initialCapacity);
542 _vec.reserve(initialCapacity);
555 if (&other==
this)
return *
this;
560 std::vector<RooAbsCategory::value_type> tmp;
562 tmp.assign(other.
_vec.begin(), other.
_vec.end());
590 std::vector<RooAbsCategory::value_type> tmp;
594 inline void load(std::size_t idx)
const {
600 auto end = std::min(
_vec.cbegin() + last,
_vec.cend());
615 std::vector<RooAbsCategory::value_type> tmp;
618 tmp.assign(
_vec.begin(), std::min(
_vec.end(),
_vec.begin() + siz));
619 if (
Int_t(tmp.size()) != siz)
634 std::vector<RooAbsCategory::value_type>&
data() {
return _vec; }
641 std::vector<RooAbsCategory::value_type>
_vec;
#define WRITE_TSTRING_COMPATIBLE_CONSTRUCTOR(Class_t)
#define VECTOR_BUFFER_SIZE
unsigned long long ULong64_t
#define ClassDef(name, id)
#define ClassDefOverride(name, id)
char * Form(const char *fmt,...)
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
RooAbsCategory is the base class for objects that represent a discrete value with a finite number of ...
void reserve(Storage_t::size_type count)
RooAbsDataStore is the abstract base class for data collection that use a TTree as internal storage m...
const RooArgSet & cachedVars() const
virtual Double_t weight() const =0
virtual const RooArgSet * get() const
std::map< RooFit::Detail::DataKey, RooSpan< const double > > RealSpans
std::map< RooFit::Detail::DataKey, RooSpan< const RooAbsCategory::value_type > > CategorySpans
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooChangeTracker is a meta object that tracks value changes in a given set of RooAbsArgs by registeri...
Bool_t hasChanged(Bool_t clearState)
Returns true if state has changed since last call with clearState=kTRUE.
RooArgSet parameters() const
RooRealVar represents a variable that can be changed from the outside.
A simple container to hold a batch of data values.
RooTreeDataStore is a TTree-backed data storage.
void setBufArg(RooAbsCategory *arg)
void setBuffer(RooAbsCategory::value_type *newBuf)
void write(std::size_t i)
RooSpan< const RooAbsCategory::value_type > getRange(std::size_t first, std::size_t last) const
CatVector(UInt_t initialCapacity=VECTOR_BUFFER_SIZE)
RooAbsCategory::value_type * _buf
CatVector(RooAbsCategory *cat, UInt_t initialCapacity=VECTOR_BUFFER_SIZE)
RooAbsCategory::value_type * _nativeBuf
CatVector & operator=(const CatVector &other)
void load(std::size_t idx) const
std::vector< RooAbsCategory::value_type > _vec
void setNativeBuffer(RooAbsCategory::value_type *newBuf=nullptr)
void loadToNative(std::size_t idx) const
const RooAbsCategory * bufArg() const
std::vector< RooAbsCategory::value_type > & data()
CatVector(const CatVector &other, RooAbsCategory *cat=nullptr)
void setAsymErrorBuffer(Double_t *newBufL, Double_t *newBufH)
std::vector< double > * dataEL()
RealFullVector(const RealFullVector &other, RooAbsReal *real=0)
std::vector< double > * _vecE
void get(Int_t idx) const
std::vector< double > * dataEH()
std::vector< double > * dataE()
RealFullVector(RooAbsReal *arg, UInt_t initialCapacity=(VECTOR_BUFFER_SIZE/sizeof(Double_t)))
void loadToNative(Int_t idx) const
RealFullVector(const RealVector &other, RooAbsReal *real=0)
void setErrorBuffer(Double_t *newBuf)
RealFullVector & operator=(const RealFullVector &other)
RealFullVector(UInt_t initialCapacity=(VECTOR_BUFFER_SIZE/sizeof(Double_t)))
std::vector< double > * _vecEL
virtual ~RealFullVector()
std::vector< double > * _vecEH
RealVector(RooAbsReal *arg, UInt_t initialCapacity=(VECTOR_BUFFER_SIZE/sizeof(Double_t)))
RealVector & operator=(const RealVector &other)
void setBuffer(RooAbsReal *real, Double_t *newBuf)
const RooAbsReal * bufArg() const
RooChangeTracker * _tracker
void setBufArg(RooAbsReal *arg)
void setNset(RooArgSet *newNset)
std::vector< double > & data()
void setNativeBuffer(Double_t *newBuf=0)
void loadToNative(std::size_t idx) const
RooSpan< const double > getRange(std::size_t first, std::size_t last) const
void setDependents(const RooArgSet &deps)
RealVector(UInt_t initialCapacity=(VECTOR_BUFFER_SIZE/sizeof(Double_t)))
void load(std::size_t idx) const
std::vector< double > _vec
RealVector(const RealVector &other, RooAbsReal *real=0)
const std::vector< double > & data() const
RooVectorDataStore uses std::vectors to store data columns.
const Double_t * _extWgtErrHiArray
External weight array - low error.
Bool_t hasAsymError(RooAbsReal *real)
virtual void resetCache() override
std::vector< CatVector * > & catStoreList()
virtual Int_t numEntries() const override
virtual void attachCache(const RooAbsArg *newOwner, const RooArgSet &cachedVars) override
Initialize cache of dataset: attach variables of cache ArgSet to the corresponding TTree branches.
std::vector< RealFullVector * > _realfStoreList
const RooVectorDataStore * cache() const
Bool_t isFullReal(RooAbsReal *real)
RooVectorDataStore * _cache
virtual void resetBuffers() override
RooRealVar * weightVar(const RooArgSet &allVars, const char *wgtName)
Utility function for constructors Return pointer to weight variable if it is defined.
std::vector< RealVector * > _realStoreList
CatVector * addCategory(RooAbsCategory *cat)
virtual RooArgSet * addColumns(const RooArgList &varList) override
Utility function to add multiple columns in one call See addColumn() for details.
void loadValues(const RooAbsDataStore *tds, const RooFormulaVar *select=0, const char *rangeName=0, std::size_t nStart=0, std::size_t nStop=std::numeric_limits< std::size_t >::max()) override
virtual Bool_t hasFilledCache() const override
virtual RooAbsDataStore * clone(const RooArgSet &vars, const char *newname=0) const override
virtual Bool_t changeObservableName(const char *from, const char *to) override
RealFullVector * addRealFull(RooAbsReal *real)
const Double_t * _extWgtErrLoArray
External weight array.
RooAbsData::RealSpans getBatches(std::size_t first, std::size_t len) const override
Return batches of the data columns for the requested events.
ULong64_t _currentWeightIndex
External sum of weights array.
virtual const RooArgSet * getNative(Int_t index) const
Load the n-th data point (n='index') into the variables of this dataset, and return a pointer to the ...
Double_t weight() const override
Return the weight of the last-retrieved data point.
virtual Int_t fill() override
Interface function to TTree::Fill.
std::vector< RealFullVector * > & realfStoreList()
virtual void append(RooAbsDataStore &other) override
void setExternalWeightArray(const Double_t *arrayWgt, const Double_t *arrayWgtErrLo, const Double_t *arrayWgtErrHi, const Double_t *arraySumW2) override
std::vector< CatVector * > _catStoreList
Bool_t _forcedUpdate
Cache owner.
void setAllBuffersNative()
const Double_t * _extSumW2Array
External weight array - high error.
virtual void reset() override
virtual Bool_t isWeighted() const override
virtual void attachBuffers(const RooArgSet &extObs) override
ArraysStruct getArrays() const
Exports all arrays in this RooVectorDataStore into a simple datastructure to be used by RooFit intern...
virtual void setDirtyProp(Bool_t flag) override
RooAbsData::CategorySpans getCategoryBatches(std::size_t, std::size_t len) const override
RooAbsDataStore * merge(const RooArgSet &allvars, std::list< RooAbsDataStore * > dstoreList) override
Merge columns of supplied data set(s) with this data set.
virtual void cacheArgs(const RooAbsArg *owner, RooArgSet &varSet, const RooArgSet *nset=0, Bool_t skipZeroWeights=kTRUE) override
Cache given RooAbsArgs: The tree is given direct write access of the args internal cache the args val...
virtual RooAbsDataStore * clone(const char *newname=0) const override
RealVector * addReal(RooAbsReal *real)
virtual Double_t weightError(RooAbsData::ErrorType etype=RooAbsData::Poisson) const override
Return the error of the current weight.
void forceCacheUpdate() override
void recomputeSumWeight()
Trigger a recomputation of the cached weight sums.
std::vector< RealVector * > & realStoreList()
virtual void recalculateCache(const RooArgSet *, Int_t firstEvent, Int_t lastEvent, Int_t stepSize, Bool_t skipZeroWeights) override
std::size_t size() const
Get size of stored dataset.
Bool_t hasError(RooAbsReal *real)
RooSpan< const double > getWeightBatch(std::size_t first, std::size_t len) const override
Return the weights of all events in the range [first, first+len).
virtual const RooArgSet * get() const
virtual ~RooVectorDataStore()
Destructor.
virtual Double_t sumEntries() const override
RooArgSet varsNoWeight(const RooArgSet &allVars, const char *wgtName)
Utility function for constructors Return RooArgSet that is copy of allVars minus variable matching wg...
const Double_t * _extWgtArray
virtual RooAbsArg * addColumn(RooAbsArg &var, Bool_t adjustRange=kTRUE) override
Add a new column to the data set which holds the pre-calculated values of 'newVar'.
virtual const RooAbsArg * cacheOwner() override
virtual void setArgStatus(const RooArgSet &set, Bool_t active) override
Disabling of branches is (intentionally) not implemented in vector data stores (as the doesn't result...
RooAbsArg * _cacheOwner
Optimization cache.
virtual const char * GetName() const
Returns name of object.
A TTree represents a columnar dataset.
ArrayInfo(std::string_view n, T const *d)
Output struct for the RooVectorDataStore::getArrays() helper function.
std::vector< ArrayInfo< double > > reals
std::vector< ArrayInfo< RooAbsCategory::value_type > > cats