// Class RooObjCacheManager is an implementation of class RooCacheManager<RooAbsCacheElement>
// and specializes in the storage of cache elements that contain RooAbsArg objects.
// Caches with RooAbsArg derived payload require special care as server redirects
// cache operation mode changes and constant term optimization calls may need to be
// forwarded to such cache payload. This cache manager takes are of all these operations
// by forwarding these calls to the RooAbsCacheElement interface functions, which
// have a sensible default implementation.
// END_HTML
#include "RooFit.h"
#include "Riostream.h"
#include <vector>
#include "RooObjCacheManager.h"
#include "RooMsgService.h"
using namespace std ;
ClassImp(RooObjCacheManager)
;
RooObjCacheManager::RooObjCacheManager(RooAbsArg* owner, Int_t maxSize, Bool_t clearCacheOnServerRedirect) :
RooCacheManager<RooAbsCacheElement>(owner,maxSize),
_clearOnRedirect(clearCacheOnServerRedirect),
_optCacheModeSeen(kFALSE),
_optCacheObservables(0)
{
}
RooObjCacheManager::RooObjCacheManager(const RooObjCacheManager& other, RooAbsArg* owner) :
RooCacheManager<RooAbsCacheElement>(other,owner),
_clearOnRedirect(other._clearOnRedirect),
_optCacheModeSeen(kFALSE),
_optCacheObservables(0)
{
}
RooObjCacheManager::~RooObjCacheManager()
{
if (_optCacheObservables) {
list<RooArgSet*>::iterator iter = _optCacheObsList.begin() ;
for (; iter!=_optCacheObsList.end() ; ++iter) {
delete *iter ;
}
_optCacheObservables=0 ;
}
}
Bool_t RooObjCacheManager::redirectServersHook(const RooAbsCollection& newServerList, Bool_t mustReplaceAll, Bool_t nameChange, Bool_t isRecursive)
{
if (_clearOnRedirect) {
sterilize() ;
} else {
for (Int_t i=0 ; i<_size ; i++) {
_object[i]->redirectServersHook(newServerList,mustReplaceAll,nameChange,isRecursive) ;
}
}
return kFALSE ;
}
void RooObjCacheManager::operModeHook()
{
if (!_owner) {
return ;
}
for (Int_t i=0 ; i<_size ; i++) {
if (_object[i]) {
_object[i]->operModeHook(_owner->operMode()) ;
}
}
}
void RooObjCacheManager::optimizeCacheMode(const RooArgSet& obs, RooArgSet& optNodes, RooLinkedList& processedNodes)
{
oocxcoutD(_owner,Caching) << "RooObjCacheManager::optimizeCacheMode(owner=" << _owner->GetName() << ") obs = " << obs << endl ;
_optCacheModeSeen = kTRUE ;
_optCacheObservables = (RooArgSet*) obs.snapshot() ;
_optCacheObsList.push_back(_optCacheObservables) ;
for (Int_t i=0 ; i<_size ; i++) {
if (_object[i]) {
_object[i]->optimizeCacheMode(obs,optNodes,processedNodes) ;
}
}
}
void RooObjCacheManager::insertObjectHook(RooAbsCacheElement& obj)
{
obj.setOwner(_owner) ;
if (_optCacheModeSeen) {
RooLinkedList l ;
RooArgSet s ;
obj.optimizeCacheMode(*_optCacheObservables,s,l) ;
}
}
void RooObjCacheManager::printCompactTreeHook(std::ostream& os, const char *indent)
{
for (Int_t i=0 ; i<_size ; i++) {
if (_object[i]) {
_object[i]->printCompactTreeHook(os,indent,i,_size-1) ;
}
}
}
void RooObjCacheManager::findConstantNodes(const RooArgSet& obs, RooArgSet& cacheList, RooLinkedList& processedNodes)
{
if (_clearOnRedirect) {
return ;
}
for (Int_t i=0 ; i<_size ; i++) {
if (_object[i]) {
_object[i]->findConstantNodes(obs,cacheList, processedNodes) ;
}
}
}
Last change: Mon Aug 25 11:36:42 2008
Last generated: 2008-08-25 11:36
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.