00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "RooFit.h"
00031 #include "Riostream.h"
00032 #include <vector>
00033 #include "RooObjCacheManager.h"
00034 #include "RooMsgService.h"
00035
00036 using namespace std ;
00037
00038 ClassImp(RooObjCacheManager)
00039 ;
00040
00041
00042
00043 RooObjCacheManager::RooObjCacheManager(RooAbsArg* owner, Int_t maxSize, Bool_t clearCacheOnServerRedirect) :
00044 RooCacheManager<RooAbsCacheElement>(owner,maxSize),
00045 _clearOnRedirect(clearCacheOnServerRedirect),
00046 _optCacheModeSeen(kFALSE),
00047 _optCacheObservables(0)
00048 {
00049
00050
00051
00052
00053
00054 }
00055
00056
00057
00058 RooObjCacheManager::RooObjCacheManager(const RooObjCacheManager& other, RooAbsArg* owner) :
00059 RooCacheManager<RooAbsCacheElement>(other,owner),
00060 _clearOnRedirect(other._clearOnRedirect),
00061 _optCacheModeSeen(kFALSE),
00062 _optCacheObservables(0)
00063 {
00064
00065 }
00066
00067
00068
00069 RooObjCacheManager::~RooObjCacheManager()
00070 {
00071
00072
00073 if (_optCacheObservables) {
00074
00075 list<RooArgSet*>::iterator iter = _optCacheObsList.begin() ;
00076 for (; iter!=_optCacheObsList.end() ; ++iter) {
00077 delete *iter ;
00078 }
00079
00080 _optCacheObservables=0 ;
00081 }
00082 }
00083
00084
00085
00086 Bool_t RooObjCacheManager::redirectServersHook(const RooAbsCollection& newServerList, Bool_t mustReplaceAll, Bool_t nameChange, Bool_t isRecursive)
00087 {
00088
00089
00090
00091
00092
00093 if (_clearOnRedirect) {
00094
00095 sterilize() ;
00096
00097 } else {
00098
00099 for (Int_t i=0 ; i<_size ; i++) {
00100 _object[i]->redirectServersHook(newServerList,mustReplaceAll,nameChange,isRecursive) ;
00101 }
00102
00103 }
00104
00105 return kFALSE ;
00106 }
00107
00108
00109
00110
00111 void RooObjCacheManager::operModeHook()
00112 {
00113
00114
00115 if (!_owner) {
00116 return ;
00117 }
00118
00119 for (Int_t i=0 ; i<_size ; i++) {
00120 if (_object[i]) {
00121 _object[i]->operModeHook(_owner->operMode()) ;
00122 }
00123 }
00124 }
00125
00126
00127
00128
00129 void RooObjCacheManager::optimizeCacheMode(const RooArgSet& obs, RooArgSet& optNodes, RooLinkedList& processedNodes)
00130 {
00131
00132
00133
00134
00135
00136 oocxcoutD(_owner,Caching) << "RooObjCacheManager::optimizeCacheMode(owner=" << _owner->GetName() << ") obs = " << obs << endl ;
00137
00138 _optCacheModeSeen = kTRUE ;
00139
00140 _optCacheObservables = (RooArgSet*) obs.snapshot() ;
00141 _optCacheObsList.push_back(_optCacheObservables) ;
00142
00143 for (Int_t i=0 ; i<_size ; i++) {
00144 if (_object[i]) {
00145 _object[i]->optimizeCacheMode(obs,optNodes,processedNodes) ;
00146 }
00147 }
00148 }
00149
00150
00151
00152
00153 void RooObjCacheManager::insertObjectHook(RooAbsCacheElement& obj)
00154 {
00155
00156
00157
00158
00159 obj.setOwner(_owner) ;
00160
00161
00162 if (_optCacheModeSeen) {
00163 RooLinkedList l ;
00164 RooArgSet s ;
00165 obj.optimizeCacheMode(*_optCacheObservables,s,l) ;
00166 }
00167
00168 }
00169
00170
00171
00172
00173
00174 void RooObjCacheManager::printCompactTreeHook(std::ostream& os, const char *indent)
00175 {
00176
00177
00178 for (Int_t i=0 ; i<_size ; i++) {
00179 if (_object[i]) {
00180 _object[i]->printCompactTreeHook(os,indent,i,_size-1) ;
00181 }
00182 }
00183 }
00184
00185
00186
00187
00188 void RooObjCacheManager::findConstantNodes(const RooArgSet& obs, RooArgSet& cacheList, RooLinkedList& processedNodes)
00189 {
00190
00191
00192
00193 if (_clearOnRedirect) {
00194 return ;
00195 }
00196
00197 for (Int_t i=0 ; i<_size ; i++) {
00198 if (_object[i]) {
00199 _object[i]->findConstantNodes(obs,cacheList, processedNodes) ;
00200 }
00201 }
00202 }
00203
00204