Report problems to ATLAS LXR Team (with time and IP address indicated)

The LXR Cross Referencer

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Architecture: linux ]
Version: head ] [ nightly ] [ GaudiDev ]
  Links to LXR source navigation pages for stable releases [ 12.*.* ]   [ 13.*.* ]   [ 14.*.* ] 

001 #ifndef METREFINEMENT_METREFINEDTOOLBASE_H
002 #define METREFINEMENT_METREFINEDTOOLBASE_H
003 /*****************************************************************************
004 
005 NAME:     METRefinedToolBase
006 PACKAGE:  offline/Reconstruction/MissingET
007 
008 AUTHORS:  P. Loch
009 CREATED:  Apr, 2006
010 
011 PURPOSE:  Templated base class for Refined MissingEt calculation tools.
012           Each RefTool needs the association map as argument in the execute
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   * METRefinedToolBase class.
033   * 
034   * Templated base class for Refined MissingEt calculation tools.
035   * Each RefTool needs the association map as argument in the execute
036   * 
037   * 
038   * @author loch@physics.arizona.edu
039   */
040 
041 class METRefinedToolBase : public AlgTool
042 {
043 public:
044 
045   // example: KEYOBJECT  = CaloCell
046   //          LISTOBJECT = CaloCluster
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   // property: StoreGate key for missing Et object
061   std::string m_missingETKey;
062 
063   // property: flag requests tracking of used obejcts (true) or not.
064   bool m_trackUsedObjects;
065 
066   // StoreGate service pointer
067   StoreGateSvc* m_storeGate;
068 
069   // helper: make entry selection based on object type only
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     //MsgStream report(msgSvc(),name());
087     
088     if ( fKey != mapStore->end() ) //if the key is already inside the map
089       {
090         // faster check on associations
091         if ( (fKey.getRefStore()).empty() )
092           {
093             //      report << MSG::INFO
094             //             << "object (index/pointer): ("
095             //             << fKey - (mapStore->begin())
096             //             << "/"
097             //             << fKey.getKeyObject()
098             //             << "): no associations yet!"
099             //     << endreq;
100             return true; // cell can be added to map
101           }
102         // some associations already existing
103         else
104           {
105             // debug
106             //      report << MSG::INFO
107             //             << "object (index/pointer): "
108             //             << "(" << fKey-(mapStore->begin())
109             //             << "/" << fKey.getKeyObject()
110             //             << ") has "
111             //             << (fKey.getRefStore()).size()
112             //             << " associations already"
113             //             << endreq;
114             // check if ALL referenced objects are of allowed type!
115             //      typename map_t::ref_iterator fRef = mapStore->begin(fKey);
116             //      typename map_t::ref_iterator lRef = mapStore->end(fKey);
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             // debugging only: create a dummy object for type info 
122             ///*debug*/     const RELOBJECT* tstObj = new RELOBJECT();
123             ///*debug*/     std::string tryType = typeid(tstObj).name();
124             ///*debug*/     delete tstObj;
125             for ( ; fRef != lRef; fRef++ )  //loop on all associated ref obj
126               {
127                 ++refCtr;        //count the ref obj
128                 //              std::string assType = typeid(fRef.getObjectPtr()).name();
129                 if ( dynamic_cast<const RELOBJECT*>(fRef.getObjectPtr()) 
130                      != 0 ) 
131                   {
132                     //              assType = tryType;
133                     ++refAssCtr ;
134                   }
135                 //              report << MSG::INFO
136                 //                     << "object (index/pointer): ("
137                 //                     << fKey-(mapStore->begin())
138                 //                     << "/"
139                 //                     << fKey.getKeyObject()
140                 //                     << ") requested association type <"
141                 //                     << tryType
142                 //                     << ">, found association type <"
143                 //                     << assType
144                 //                     << ">, counters: "
145                 //                     << refAssCtr << "/"
146                 //                     << refCtr
147                 //                     << endreq;
148               }
149             return refCtr == refAssCtr;
150           }  
151       }
152     else
153       {
154         return true;
155       }
156   }
157 
158   // helper: private tool initialization
159   virtual StatusCode initTool() { return StatusCode::SUCCESS; }
160 
161   // helper: get new missing Et object
162   virtual MissingET* getMissingETObject();
163 
164   // helper: record missing Et object
165   virtual StatusCode recordMissingETObject(MissingET* pObj);
166 
167   // helper: add list object to list of used objects
168   virtual StatusCode addUsedObject(const LISTOBJECT* pRef,
169                                    list_t* pList);   
170 };
171 
172 /////////////////////////////////
173 // Constructors and Destructor //
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 // Common Tool Initialization //
197 ////////////////////////////////
198 
199 template<typename KEYOBJECT,typename LISTOBJECT>
200 StatusCode
201 METRefinedToolBase<KEYOBJECT,LISTOBJECT>::initialize()
202 {
203   // allocate StoreGate service
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 // Helpers //
220 /////////////
221 
222 // The entrySelection(...) method is the most general implementation of an
223 // acceptor for a new entry into the map relating key objects with
224 // referenced objects. The idea that if ALL referenced objects are of the
225 // same type for which the client wants to add a new relation to a key
226 // object, the acceptor returns "true". If there is a relation to ANY other
227 // reference object type in the map, the acceptor returns "false". The
228 // consequential action should be implemented in the concrete tool itself.
229 
230 // entry selection by object pointer
231 //template<typename KEYOBJECT,typename LISTOBJECT,typename RELOBJECT>
232 //bool
233 //METRefinedToolBase<KEYOBJECT,LISTOBJECT>::
234 //entrySelection(const KEYOBJECT* pKey,map_t* mapStore)
235 //{
236 //  return this->entrySelection<RELOBJECT>(mapStore->find(pKey),mapStore);
237 //}
238 
239 // entry selection by index
240 //template<typename KEYOBJECT,typename LISTOBJECT,typename RELOBJECT>
241 //bool
242 //METRefinedToolBase<KEYOBJECT,LISTOBJECT>::entrySelection(const 
243 //                                                                  size_t& 
244 //                                                                  iKey,
245 //                                                                  map_t*
246 //                                                                  mapStore)
247 
248 // entry selection by iterator
249 //template<typename KEYOBJECT,typename LISTOBJECT,typename RELOBJECT>
250 //bool
251 //METRefinedToolBase<KEYOBJECT,LISTOBJECT>::
252 //entrySelection(map_t::const_iterator fKey, map_t* mapStore)
253 
254 // create and record a new missing Et object
255 template<typename KEYOBJECT,typename LISTOBJECT>
256 MissingET*
257 METRefinedToolBase<KEYOBJECT,LISTOBJECT>::getMissingETObject()
258 {
259   // new object
260   MissingET* pEtMiss = new MissingET();
261   // record in StoreGate
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 // lock missing Et object in StoreGate
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 // add used LISTOBJECT to list
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

source navigation ] diff markup ] identifier search ] general search ]

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. Valid HTML 4.01!