85 _wgtVar(weightVar(vars,wgtVarName)),
101 arg->attachToVStore(*
this) ;
115 realVec->setNativeBuffer();
119 fullVec->setNativeBuffer();
123 catVec->setNativeBuffer();
169 _varsww(other._varsww),
170 _wgtVar(other._wgtVar),
171 _sumWeight(other._sumWeight),
172 _sumWeightCarry(other._sumWeightCarry),
173 _extWgtArray(other._extWgtArray),
174 _extWgtErrLoArray(other._extWgtErrLoArray),
175 _extWgtErrHiArray(other._extWgtErrHiArray),
176 _extSumW2Array(other._extSumW2Array),
177 _curWgt(other._curWgt),
178 _curWgtErrLo(other._curWgtErrLo),
179 _curWgtErrHi(other._curWgtErrHi),
180 _curWgtErr(other._curWgtErr),
206 RooAbsDataStore(other,varsNoWeight(vars,other._wgtVar?other._wgtVar->GetName():0),newname),
208 _wgtVar(weightVar(vars,other._wgtVar?other._wgtVar->GetName():0)),
212 _extWgtErrLoArray(0),
213 _extWgtErrHiArray(0),
248 RooAbsDataStore(other,varsNoWeight(vars,other._wgtVar?other._wgtVar->GetName():0),newname),
250 _wgtVar(other._wgtVar?weightVar(vars,other._wgtVar->GetName()):0),
251 _sumWeight(other._sumWeight),
252 _sumWeightCarry(other._sumWeightCarry),
253 _extWgtArray(other._extWgtArray),
254 _extWgtErrLoArray(other._extWgtErrLoArray),
255 _extWgtErrHiArray(other._extWgtErrHiArray),
256 _extSumW2Array(other._extSumW2Array),
257 _curWgt(other._curWgt),
258 _curWgtErrLo(other._curWgtErrLo),
259 _curWgtErrHi(other._curWgtErrHi),
260 _curWgtErr(other._curWgtErr),
265 auto real =
static_cast<RooAbsReal*
>(vars.
find(realVec->bufArg()->GetName()));
270 real->attachToVStore(*
this) ;
274 vector<RealFullVector*>::const_iterator fiter = other.
_realfStoreList.begin() ;
285 vector<CatVector*>::const_iterator citer = other.
_catStoreList.begin() ;
310 std::size_t nStart, std::size_t nStop,
Bool_t ,
const char* wgtVarName) :
314 _wgtVar(weightVar(vars,wgtVarName)),
318 _extWgtErrLoArray(0),
319 _extWgtErrHiArray(0),
349 loadValues(&tds,cloneVar,cutRange,nStart,nStop);
428 if (index < 0 ||
static_cast<std::size_t
>(index) >=
size())
return 0;
435 fullRealP->get(index);
444 for (
auto var :
_vars) {
445 var->setValueDirty();
489 if (index < 0 ||
static_cast<std::size_t
>(index) >=
size())
return 0;
492 realV->loadToNative(index) ;
496 fullRealP->loadToNative(index);
500 catP->loadToNative(index);
505 for (
auto var :
_vars) {
506 var->setValueDirty() ;
613 throw string(
Form(
"RooDataHist::weightError(%s) error type Auto not allowed here",
GetName())) ;
617 throw string(
Form(
"RooDataHist::weightError(%s) error type Expected not allowed here",
GetName())) ;
678 std::unique_ptr<RooFormulaVar> selectClone;
681 selectClone->recursiveRedirectServers(*ads->
get()) ;
689 const auto numEntr =
static_cast<std::size_t
>(ads->
numEntries());
690 const std::size_t nevent = nStop < numEntr ? nStop : numEntr;
710 std::vector<std::string> ranges;
716 for(
auto i=nStart; i < nevent ; ++i) {
720 if (selectClone && selectClone->getVal()==0) {
739 bool allValid =
true;
740 for (
const auto arg :
_varsww) {
741 allValid &= arg->isValid();
742 if (allValid && !ranges.empty()) {
745 allValid &= std::any_of(ranges.begin(), ranges.end(), [arg](
const std::string& range){
746 return arg->inRange(range.c_str());});
803 << valHolder->
GetName() <<
"\"" << endl;
808 const std::size_t numEvt =
size();
831 for (std::size_t i=0; i < numEvt; i++) {
837 if (rv) rv->
write(i) ;
838 if (cv) cv->
write(i) ;
861 const std::size_t numEvt =
size();
863 for (
const auto var : varList) {
866 holderSet->
add(*valHolder) ;
871 << valHolder->
GetName() <<
"\"" << endl;
877 if (!newVarCloneList) {
879 <<
") Couldn't deep-clone variable " << var->GetName() <<
", abort." << endl ;
882 RooAbsArg* newVarClone = newVarCloneList->
find(var->GetName()) ;
886 cloneSetList.
Add(newVarCloneList) ;
887 cloneSet.
add(*newVarClone) ;
895 for (
const auto holder : *holderSet) {
904 for (std::size_t i=0; i < numEvt; i++) {
907 for (
unsigned int j=0; j < holderSet->
size(); ++j) {
908 const auto holder = (*holderSet)[j];
909 const auto cloneArg = cloneSet[j];
911 cloneArg->syncCache(&
_vars) ;
913 holder->copyCache(cloneArg) ;
940 const auto nevt = dstoreList.front()->numEntries();
942 for (
int i=0 ; i<nevt ; i++) {
948 for (list<RooAbsDataStore*>::iterator iter = dstoreList.begin() ; iter!=dstoreList.end() ; ++iter) {
949 const RooArgSet* partSet = (*iter)->get(i) ;
950 mergedStore->
_vars = *partSet ;
953 mergedStore->
fill() ;
981 for (
int i=0 ; i<nevt ; i++) {
1032 vector<RooAbsArg*> trackArgs;
1033 for (
const auto arg : newVarSetCopy) {
1034 if (arg->getAttribute(
"ConstantExpression") && !arg->getAttribute(
"NOCacheAndTrack")) {
1035 orderedArgs.
add(*arg) ;
1042 if (arg->dependsOn(
_vars) && !arg->getAttribute(
"NOCacheAndTrack")) {
1043 trackArgs.push_back(arg) ;
1052 return right->dependsOn(*left);
1056 for (
const auto trackedArg : trackArgs) {
1057 orderedArgs.
add(*trackedArg);
1067 std::vector<RooArgSet*> vlist;
1070 for (
const auto var : orderedArgs) {
1074 RooAbsArg* newVarClone = newVarCloneList->
find(var->GetName()) ;
1077 vlist.push_back(newVarCloneList) ;
1078 cloneSet.
add(*newVarClone) ;
1087 std::vector<RooArgSet*> nsetList ;
1088 std::vector<RooArgSet*> argObsList ;
1092 for (
const auto arg : cloneSet) {
1093 arg->attachToVStore(*newCache) ;
1095 RooArgSet* argObs = nset ? arg->getObservables(*nset) : arg->getVariables() ;
1096 argObsList.push_back(argObs) ;
1099 const char* catNset = arg->getStringAttribute(
"CATNormSet") ;
1108 const char* catCset = arg->getStringAttribute(
"CATCondSet") ;
1123 nsetList.push_back(normSet) ;
1128 const std::size_t numEvt =
size();
1130 for (std::size_t i=0; i < numEvt; i++) {
1132 if (
weight()!=0 || !skipZeroWeights) {
1133 for (
unsigned int j = 0; j < cloneSet.
size(); ++j) {
1134 auto& cloneArg = cloneSet[j];
1135 auto argNSet = nsetList[j];
1137 cloneArg.syncCache(argNSet ? argNSet : nset) ;
1147 for (
const auto arg : orderedArgs) {
1148 arg->attachToVStore(*newCache) ;
1151 if (!arg->getAttribute(
"ConstantExpression") &&
dynamic_cast<RooAbsReal*
>(arg)) {
1160 coutI(
Optimization) <<
"RooVectorDataStore::cacheArg() element " << arg->
GetName() <<
" has change tracking enabled on parameters " << *deps << endl ;
1168 for (
auto set : vlist) {
1171 for (
auto set : argObsList) {
1193 std::vector<RooVectorDataStore::RealVector *> tv;
1199 tv.push_back(realVec);
1215 if (projectedArgs && projectedArgs->
getSize()>0) {
1218 usedNset = ownedNset ;
1224 for (
int i=firstEvent ; i<lastEvent ; i+=stepSize) {
1227 if (!zeroWeight || !skipZeroWeights) {
1228 for (
auto realVector : tv) {
1229 realVector->_nativeReal->_valueDirty =
kTRUE;
1230 realVector->_nativeReal->getValV(realVector->_nset ? realVector->_nset : usedNset);
1231 realVector->write(i);
1236 for (
auto realVector : tv) {
1258 for (
const auto elm : cacheElements) {
1259 auto real =
static_cast<RooAbsReal*
>(cachedVarsIn.
find(elm->bufArg()->GetName()));
1267 auto cat =
static_cast<RooAbsCategory*
>(cachedVarsIn.
find(catVec->bufArg()->GetName()));
1325 arg->attachToVStore(*
this);
1335 cout <<
"RooVectorDataStor::dump()" << endl ;
1338 cout <<
"realVector list is" << endl ;
1341 cout <<
"RealVector " << elm <<
" _nativeReal = " << elm->_nativeReal <<
" = " << elm->_nativeReal->GetName() <<
" bufptr = " << elm->_buf << endl ;
1342 cout <<
" values : " ;
1343 Int_t imax = elm->_vec.size()>10 ? 10 : elm->_vec.size() ;
1344 for (
Int_t i=0 ; i<imax ; i++) {
1345 cout << elm->_vec[i] <<
" " ;
1351 cout <<
"RealFullVector " << elm <<
" _nativeReal = " << elm->_nativeReal <<
" = " << elm->_nativeReal->GetName()
1352 <<
" bufptr = " << elm->_buf <<
" errbufptr = " << elm->_bufE << endl ;
1354 cout <<
" values : " ;
1355 Int_t imax = elm->_vec.size()>10 ? 10 : elm->_vec.size() ;
1356 for (
Int_t i=0 ; i<imax ; i++) {
1357 cout << elm->_vec[i] <<
" " ;
1361 cout <<
" errors : " ;
1362 for (
Int_t i=0 ; i<imax ; i++) {
1363 cout << (*elm->_vecE)[i] <<
" " ;
1375void RooVectorDataStore::Streamer(
TBuffer &R__b)
1402void RooVectorDataStore::RealFullVector::Streamer(
TBuffer &R__b)
1424 std::vector<RooSpan<const double>> ret;
1429 ret.emplace_back(realVec->getRange(firstEvent, lastEvent));
1436 ret.emplace_back(realVec->getRange(firstEvent, lastEvent));
1469 if (std::string(catVec->bufArg()->GetName())==cat->
GetName()) {
1485 if (realVec->bufArg()->namePtr()==real->
namePtr()) {
1492 if (fullVec->bufArg()->namePtr()==real->
namePtr()) {
1509 if (std::string(fullVec->bufArg()->GetName())==real->
GetName()) {
1521 if (std::string(fullVec->bufArg()->GetName())==real->
GetName()) {
1533 if (std::string(fullVec->bufArg()->GetName())==real->
GetName()) {
1545 if (std::string(fullVec->bufArg()->GetName())==real->
GetName()) {
1552 if (std::string(realVec->bufArg()->GetName())==real->
GetName()) {
float type_of_call hi(const int &, const int &)
char * Form(const char *fmt,...)
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
virtual RooAbsArg * cloneTree(const char *newname=0) const
Clone tree expression of objects.
const TNamed * namePtr() const
void attachDataStore(const RooAbsDataStore &set)
Replace server nodes with names matching the dataset variable names with those data set variables,...
virtual void copyCache(const RooAbsArg *source, Bool_t valueOnly=kFALSE, Bool_t setValDirty=kTRUE)=0
static void setDirtyInhibit(Bool_t flag)
Control global dirty inhibit mode.
virtual Bool_t isFundamental() const
Is this object a fundamental type that can be added to a dataset? Fundamental-type subclasses overrid...
RooArgSet * getParameters(const RooAbsData *data, Bool_t stripDisconnected=kTRUE) const
Create a list of leaf nodes in the arg tree starting with ourself as top node that don't match any of...
virtual void syncCache(const RooArgSet *nset=0)=0
virtual void attachToVStore(RooVectorDataStore &vstore)=0
Bool_t getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
virtual RooAbsArg * createFundamental(const char *newname=0) const =0
Create a fundamental-type object that stores our type of value.
Bool_t recursiveRedirectServers(const RooAbsCollection &newServerList, Bool_t mustReplaceAll=kFALSE, Bool_t nameChange=kFALSE, Bool_t recurseInNewSet=kTRUE)
RooAbsCategory is the base class for objects that represent a discrete value with a finite number of ...
virtual void attachToVStore(RooVectorDataStore &vstore)
Attach the category index and label to as branches to the given vector store.
RooAbsCollection * selectCommon(const RooAbsCollection &refColl) const
Create a subset of the current collection, consisting only of those elements that are contained as we...
RooAbsCollection & assignValueOnly(const RooAbsCollection &other, Bool_t oneSafe=kFALSE)
The assignment operator sets the value of any argument in our set that also appears in the other set.
Int_t index(const RooAbsArg *arg) const
Returns index of given arg, or -1 if arg is not in the collection.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
Storage_t::size_type size() const
virtual void Print(Option_t *options=0) const
This method must be overridden when a class wants to print itself.
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
TIterator * createIterator(Bool_t dir=kIterForward) const
TIterator-style iteration over contained elements.
RooAbsArg * find(const char *name) const
Find object with given name in list.
RooAbsDataStore is the abstract base class for data collection that use a TTree as internal storage m...
virtual const RooArgSet * get(Int_t index) const =0
virtual void checkInit() const
virtual Double_t weight() const =0
virtual Int_t numEntries() const =0
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
virtual void attachToVStore(RooVectorDataStore &vstore)
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.
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
virtual Bool_t add(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling add() for each element in the source coll...
Bool_t getPoissonInterval(Int_t n, Double_t &mu1, Double_t &mu2, Double_t nSigma=1) const
Return a confidence interval for the expected number of events given n observed (unweighted) events.
static const RooHistError & instance()
Return a reference to a singleton object that is created the first time this method is called.
RooNameSet is a utility class that stores the names the objects in a RooArget.
RooArgSet * select(const RooArgSet &list) const
Construct a RooArgSet of objects in input 'list' whose names match to those in the internal name list...
void setNameList(const char *givenList)
RooRealVar represents a variable that can be changed from the outside.
Double_t getAsymErrorLo() const
Bool_t hasAsymError(Bool_t allowZero=kTRUE) const
RooSpan< const double > getValBatch(std::size_t begin, std::size_t batchSize, const RooArgSet *=nullptr) const final
Return batch of data starting at begin.
Double_t getAsymErrorHi() const
Bool_t hasError(Bool_t allowZero=kTRUE) const
Double_t getError() const
virtual void setVal(Double_t value)
Set value of variable to 'value'.
A simple container to hold a batch of data values.
RooTreeDataStore is a TTree-backed data storage.
virtual const RooArgSet * get(Int_t index) const
Load the n-th data point (n='index') in memory and return a pointer to the internal RooArgSet holding...
RooArgSet _varsww
Was object constructed with default ctor?
virtual Int_t numEntries() const
void write(std::size_t i)
std::vector< double > * _vecE
std::vector< double > * _vecEL
std::vector< double > * _vecEH
void setNset(RooArgSet *newNset)
void setDependents(const RooArgSet &deps)
RooVectorDataStore is the abstract base class for data collection that use a TTree as internal storag...
const Double_t * _extWgtErrHiArray
External weight array - low error.
Bool_t hasAsymError(RooAbsReal *real)
virtual void resetCache() override
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
virtual std::vector< RooSpan< const double > > getBatch(std::size_t first, std::size_t last) const override
Return a batch of the data columns for all events in [firstEvent, lastEvent[.
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 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 ...
virtual Bool_t changeObservableName(const char *from, const char *to) override
RealFullVector * addRealFull(RooAbsReal *real)
const Double_t * _extWgtErrLoArray
External weight array.
virtual Bool_t valid() const override
Return true if currently loaded coordinate is considered valid within the current range definitions o...
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 ...
virtual Double_t weight() const override
Return the weight of the n-th data point (n='index') in memory.
virtual Int_t fill() override
Interface function to TTree::Fill.
virtual void append(RooAbsDataStore &other) 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 void attachBuffers(const RooArgSet &extObs) override
virtual void setDirtyProp(Bool_t flag) 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...
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
std::vector< RealVector * > & realStoreList()
Double_t _curWgt
External sum of weights array.
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)
virtual 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.
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 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.
Buffer base class used for serializing objects.
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
Iterator abstract base class.
virtual TObject * Next()=0
virtual void Add(TObject *obj)
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
virtual const char * GetTitle() const
Returns title of object.
virtual const char * GetName() const
Returns name of object.
std::vector< std::string > tokenise(const std::string &str, const std::string &delims, bool returnEmptyToken=true)
Tokenise the string by splitting at the characters in delims.