Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions roofit/roofitcore/inc/RooVectorDataStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,7 @@ class RooVectorDataStore : public RooAbsDataStore {
mutable Double_t _curWgtErr ; // Weight of current event

RooVectorDataStore* _cache ; //! Optimization cache
std::vector<RooVectorDataStore::RealVector*> _cacheUpdateList ; //! Pointers to the optimization cache
RooAbsArg* _cacheOwner ; //! Cache owner

Bool_t _forcedUpdate ; //! Request for forced cache update
Expand Down
28 changes: 16 additions & 12 deletions roofit/roofitcore/src/RooVectorDataStore.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,7 @@ void RooVectorDataStore::cacheArgs(const RooAbsArg* owner, RooArgSet& newVarSet,
// Delete previous cache, if any
delete _cache ;
_cache = 0 ;
_cacheUpdateList.clear() ;

// Reorder cached elements. First constant nodes, then tracked nodes in order of dependence

Expand Down Expand Up @@ -1301,16 +1302,18 @@ void RooVectorDataStore::recalculateCache( const RooArgSet *projectedArgs, Int_t
{
if (!_cache) return ;

pRealVector tv[1000] ;
if (static_cast<Int_t>(_cacheUpdateList.size()) < _cache->_nReal) {
_cacheUpdateList.resize(_cache->_nReal) ;
}
Int_t ntv(0) ;

// Check which items need recalculation
for (Int_t i=0 ; i<_cache->_nReal ; i++) {
if ((*(_cache->_firstReal+i))->needRecalc() || _forcedUpdate) {
tv[ntv] = (*(_cache->_firstReal+i)) ;
tv[ntv]->_nativeReal->setOperMode(RooAbsArg::ADirty) ;
tv[ntv]->_nativeReal->_operMode=RooAbsArg::Auto ;
// cout << "recalculate: need to update " << tv[ntv]->_nativeReal->GetName() << endl ;
_cacheUpdateList[ntv] = (*(_cache->_firstReal+i)) ;
_cacheUpdateList[ntv]->_nativeReal->setOperMode(RooAbsArg::ADirty) ;
_cacheUpdateList[ntv]->_nativeReal->_operMode=RooAbsArg::Auto ;
// cout << "recalculate: need to update " << _cacheUpdateList[ntv]->_nativeReal->GetName() << endl ;
ntv++ ;
}
}
Expand Down Expand Up @@ -1340,19 +1343,19 @@ void RooVectorDataStore::recalculateCache( const RooArgSet *projectedArgs, Int_t
Bool_t zeroWeight = (weight()==0) ;
if (!zeroWeight || !skipZeroWeights) {
for (int j=0 ; j<ntv ; j++) {
tv[j]->_nativeReal->_valueDirty=kTRUE ;
tv[j]->_nativeReal->getValV(tv[j]->_nset ? tv[j]->_nset : usedNset) ;
tv[j]->write(i) ;
_cacheUpdateList[j]->_nativeReal->_valueDirty=kTRUE ;
_cacheUpdateList[j]->_nativeReal->getValV(_cacheUpdateList[j]->_nset ? _cacheUpdateList[j]->_nset : usedNset) ;
_cacheUpdateList[j]->write(i) ;
}
}
// if (zeroWeight) {
// // cout << "update - slot " << i << " has zero weight, ignoring event errors" << endl ;
// RooAbsReal::setEvalErrorLoggingMode(RooAbsReal::Ignore) ;
// }
// for (int j=0 ; j<ntv ; j++) {
// tv[j]->_nativeReal->_valueDirty=kTRUE ;
// tv[j]->_nativeReal->getValV(tv[j]->_nset ? tv[j]->_nset : usedNset) ;
// tv[j]->write(i) ;
// _cacheUpdateList[j]->_nativeReal->_valueDirty=kTRUE ;
// _cacheUpdateList[j]->_nativeReal->getValV(_cacheUpdateList[j]->_nset ? _cacheUpdateList[j]->_nset : usedNset) ;
// _cacheUpdateList[j]->write(i) ;
// }
// if (zeroWeight) {
// RooAbsReal::setEvalErrorLoggingMode(origMode) ;
Expand All @@ -1363,7 +1366,7 @@ void RooVectorDataStore::recalculateCache( const RooArgSet *projectedArgs, Int_t
// cout << "recalc error count after update = " << RooAbsReal::numEvalErrors() << endl ;

for (int j=0 ; j<ntv ; j++) {
tv[j]->_nativeReal->setOperMode(RooAbsArg::AClean) ;
_cacheUpdateList[j]->_nativeReal->setOperMode(RooAbsArg::AClean) ;
}

delete ownedNset ;
Expand Down Expand Up @@ -1422,6 +1425,7 @@ void RooVectorDataStore::resetCache()
{
delete _cache ;
_cache = 0 ;
_cacheUpdateList.clear() ;
_cacheOwner = 0 ;
return ;
}
Expand Down