001 #ifndef METREFINEMENT_METREFINEDTOOLBASE_H
002 #define METREFINEMENT_METREFINEDTOOLBASE_H
003
004
005
006
007
008
009
010
011
012
013
014
015 #include "GaudiKernel/MsgStream.h"
016 #include "GaudiKernel/AlgTool.h"
017 #include "GaudiKernel/Service.h"
018
019 #include "StoreGate/StoreGateSvc.h"
020
021 #include "MissingETEvent/MissingEtMap.h"
022 #include "MissingETEvent/MissingET.h"
023
024 #include <string>
025 #include <vector>
026
027 #include <typeinfo>
028
029 template<typename KEYOBJECT,typename LISTOBJECT>
030
031
032
033
034
035
036
037
038
039
040
041 class METRefinedToolBase : public AlgTool
042 {
043 public:
044
045
046
047 typedef MissingEtMap<KEYOBJECT> map_t;
048 typedef std::vector<const LISTOBJECT*> list_t;
049
050 METRefinedToolBase(const std::string& type, const std::string& name,
051 const IInterface* pParent);
052 virtual ~METRefinedToolBase();
053
054 virtual StatusCode initialize() ;
055
056 virtual StatusCode execute(map_t* mapStore,list_t* listStore=0) = 0;
057
058 protected:
059
060
061 std::string m_missingETKey;
062
063
064 bool m_trackUsedObjects;
065
066
067 StoreGateSvc* m_storeGate;
068
069
070 template<typename RELOBJECT>
071 bool entrySelection(const KEYOBJECT* pKey, map_t* mapStore) const
072 {
073 return this->entrySelection<RELOBJECT>(mapStore->find(pKey),mapStore);
074 }
075
076 template<typename RELOBJECT>
077 bool entrySelection(const size_t& iKey, map_t* mapStore) const
078 {
079 return this->entrySelection<RELOBJECT>(mapStore->find(iKey),mapStore);
080 }
081
082 template<typename RELOBJECT>
083 bool entrySelection(typename map_t::const_iterator fKey,
084 map_t* mapStore) const
085 {
086
087
088 if ( fKey != mapStore->end() )
089 {
090
091 if ( (fKey.getRefStore()).empty() )
092 {
093
094
095
096
097
098
099
100 return true;
101 }
102
103 else
104 {
105
106
107
108
109
110
111
112
113
114
115
116
117 typename map_t::const_ref_iterator fRef = (fKey.getRefStore()).begin();
118 typename map_t::const_ref_iterator lRef = (fKey.getRefStore()).end();
119 unsigned int refCtr(0);
120 unsigned int refAssCtr(0);
121
122
123
124
125 for ( ; fRef != lRef; fRef++ )
126 {
127 ++refCtr;
128
129 if ( dynamic_cast<const RELOBJECT*>(fRef.getObjectPtr())
130 != 0 )
131 {
132
133 ++refAssCtr ;
134 }
135
136
137
138
139
140
141
142
143
144
145
146
147
148 }
149 return refCtr == refAssCtr;
150 }
151 }
152 else
153 {
154 return true;
155 }
156 }
157
158
159 virtual StatusCode initTool() { return StatusCode::SUCCESS; }
160
161
162 virtual MissingET* getMissingETObject();
163
164
165 virtual StatusCode recordMissingETObject(MissingET* pObj);
166
167
168 virtual StatusCode addUsedObject(const LISTOBJECT* pRef,
169 list_t* pList);
170 };
171
172
173
174
175
176 template<typename KEYOBJECT,typename LISTOBJECT>
177 METRefinedToolBase<KEYOBJECT,LISTOBJECT>::METRefinedToolBase(const std::string&
178 type,
179 const
180 std::string&
181 name,
182 const IInterface*
183 pParent)
184 : AlgTool(type,name,pParent),
185 m_trackUsedObjects(true)
186 {
187 declareProperty("MissingETKey",m_missingETKey);
188 declareProperty("TrackUsedObjects",m_trackUsedObjects);
189 }
190
191 template<typename KEYOBJECT,typename LISTOBJECT>
192 METRefinedToolBase<KEYOBJECT,LISTOBJECT>::~METRefinedToolBase()
193 { }
194
195
196
197
198
199 template<typename KEYOBJECT,typename LISTOBJECT>
200 StatusCode
201 METRefinedToolBase<KEYOBJECT,LISTOBJECT>::initialize()
202 {
203
204 if ( (service("StoreGateSvc",m_storeGate)).isFailure() )
205 {
206 MsgStream report(msgSvc(),name());
207 report << MSG::ERROR
208 << "cannot allocate StoreGate service"
209 << endreq;
210 return StatusCode::FAILURE;
211 }
212 else
213 {
214 return this->initTool();
215 }
216 }
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255 template<typename KEYOBJECT,typename LISTOBJECT>
256 MissingET*
257 METRefinedToolBase<KEYOBJECT,LISTOBJECT>::getMissingETObject()
258 {
259
260 MissingET* pEtMiss = new MissingET();
261
262 if ( m_storeGate == 0 ||
263 ( m_storeGate->record(pEtMiss,m_missingETKey) ).isFailure() )
264 {
265 delete pEtMiss;
266 return (MissingET*)0;
267 }
268 return pEtMiss;
269 }
270
271
272 template<typename KEYOBJECT,typename LISTOBJECT>
273 StatusCode
274 METRefinedToolBase<KEYOBJECT,LISTOBJECT>::recordMissingETObject(MissingET*
275 pEtObj)
276 {
277 return m_storeGate != 0 && pEtObj != 0
278 ? m_storeGate->setConst(pEtObj) : StatusCode::FAILURE;
279 }
280
281
282 template<typename KEYOBJECT,typename LISTOBJECT>
283 StatusCode
284 METRefinedToolBase<KEYOBJECT,LISTOBJECT>::addUsedObject(const LISTOBJECT* pObj,
285 list_t* pList)
286 {
287 size_t oldSize(pList->size());
288 pList->push_back(pObj);
289 return pList->size() > oldSize ? StatusCode::SUCCESS : StatusCode::FAILURE;
290 }
291
292
293 #endif
Due to the LXR bug, the updates fail sometimes to remove references to deleted files. The Saturday's full rebuilds fix these problems |
This page was automatically generated by the
LXR engine.
|
|