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.*.* ]   [ 15.*.* ] 

001 // $Id: GaudiTool.h,v 1.13 2008/10/10 13:38:28 marcocle Exp $
002 // ============================================================================
003 #ifndef GAUDIALG_GAUDITOOL_H
004 #define GAUDIALG_GAUDITOOL_H 1
005 // ============================================================================
006 // Include files
007 // ============================================================================
008 // GaudiKernel
009 // ============================================================================
010 #include "GaudiKernel/AlgTool.h"
011 #include "GaudiKernel/DataObject.h"
012 // ============================================================================
013 // GaudiAlg
014 // ============================================================================
015 #include "GaudiAlg/GaudiAlg.h"
016 #include "GaudiAlg/GaudiCommon.h"
017 // ============================================================================
018 // forward declarations
019 // ============================================================================
020 class          IDataProviderSvc ;
021 class          IChronoStatSvc   ;
022 class          IIncidentSvc     ;
023 class          IHistogramSvc    ;
024 class          GaudiException   ;
025 class          INTupleSvc       ;
026 class          IAlgContextSvc   ;
027 namespace std { class exception ; }
028 // ============================================================================
029 /** @file GaudiTool.h
030  *
031  * Header file for class GaudiAlgorithm.
032  * The actual code is mainly imported from
033  *   - LHCb Calorimeter software and
034  *   - LHCb C++ toolkit for smart and friendly physics analysis "LoKi"
035  *
036  * This base class allows "easy"(=="1 line") access to tools
037  * and services. This access is safe in the sense that there
038  * is no need to worry about the reference counts for tools
039  * and services.
040  *
041  * The base class allows "easy" (=="1 line") access to data in
042  * Gaudi Transient Stores. The functionality includes the checking
043  * of the presence of the data at the given location, checking the
044  * validity of the data, retrieval of valid data and "forced" retrive
045  * of valid data (create if there is no data).
046  *
047  * The base class allows to perform an easy error, warning and exception
048  * treatments, including the accumulated statistics of exceptions, errors
049  * and warnings.
050  *
051  * The base class included also utilities for general statistical counters.
052  *
053  * It has been reported that usage of this base class results in
054  * significant shrinkage of existing code lines.
055  *
056  *  @attention
057  *  See also the class GaudiCommon, which implements some of the common
058  *  functionality between GaudiTool and GaudiAlgorithm.
059  *
060  *  @author Vanya BELYAEV Ivan.Belyaev@itep.ru
061  *  @author Chris Jones   Christopher.Rob.Jones@cern.ch
062  *  @date 01/11/2001
063  */
064 // ============================================================================
065 /** @class GaudiTool GaudiTool.h GaudiTools/GaudiTool.h
066  *
067  *  The useful base class for tools.
068  *  Small extension of ordinary the AlgTool base class.
069  *
070  *  This base class allows "easy"(=="1 line") access to tools
071  *  and services. This access is safe in the sense that there
072  *  is no need to worry about the reference counts for tools
073  *  and services.
074  *
075  *  The base class allows "easy" (=="1 line") access to data in
076  *  Gaudi Transient Stores. The functionality includes the checking
077  *  of the presence of the data at the given location, checking the
078  *  validity of the data, retrieval of valid data and "forced" retrive
079  *  of valid data (create if there is no data).
080  *
081  *  The base class allows to perform an easy error, warning and exception
082  *  treatments, including the accumulated statistics of exceptions, errors
083  *  and warnings.
084  *
085  *  The base class also includes utilities for general statistical counters.
086  *
087  *  It has been reported that usage of this base class results in
088  *  significant shrinkage of existing code lines.
089  *
090  *  @attention
091  *  See the class GaudiCommon, which implements some of the common functionality
092  *  between GaudiTool and GaudiAlgorithm
093  *
094  *  @author Vanya BELYAEV Ivan.Belyaev@itep.ru
095  *  @author Chris Jones   Christopher.Rob.Jones@cern.ch
096  *  @date   2003-07-07
097  */
098 // ============================================================================
099 class GaudiTool: public GaudiCommon<AlgTool>
100 {
101 public:
102 
103   /** standard initialization method
104    *  @see  AlgTool
105    *  @see IAlgTool
106    *  @return status code
107    */
108   virtual StatusCode    initialize ();
109 
110   /** standard finalization method
111    *  @see  AlgTool
112    *  @see IAlgTool
113    *  @return status code
114    */
115   virtual StatusCode    finalize   ();
116 
117 public: // accessors
118 
119   /** Access the standard N-Tuple
120    *  @return pointer to N-Tuple service .
121    */
122   INTupleSvc*          ntupleSvc () const;
123 
124   /** Access the standard event collection service
125    *  @return pointer to the event collection service
126    */
127   INTupleSvc*          evtColSvc () const;
128 
129   /** accessor to detector service
130    *  @return pointer to detector service
131    */
132   IDataProviderSvc*    detSvc    () const ;
133 
134   /** accessor to event service  service
135    *  @return pointer to detector service
136    */
137   IDataProviderSvc*    evtSvc    () const ;
138 
139   /** accessor to Incident Service
140    *  @return pointer to the Incident Service
141    */
142   IIncidentSvc*        incSvc    () const ;
143 
144   /** accessor to Chrono & Stat Service
145    *  @return pointer to the Chrono & Stat Service
146    */
147   IChronoStatSvc*      chronoSvc () const ;
148 
149   /** acessor to the histogram service
150    *  @return pointer to the histogram service
151    */
152   IHistogramSvc*       histoSvc  () const ;
153   
154   /** acessor to the Algorithm Context Service 
155    *  @return pointer to the Algorithm Contetx Service 
156    */
157   IAlgContextSvc*     contextSvc () const ;
158 
159 public:
160 
161   // following methods cannot go in GaudiCommon since they use methods ( evtSvc()
162   // and detDvc() ) that are not members of AlgTool.
163   // Also some methods seem which are members of the base class do not seem
164   // to be found unless forwarding methods are put here ??
165 
166   /** @brief Register a data object or container into Gaudi Event Transient Store
167    *
168    *  @code
169    *
170    *  MCHits * hits = new MCHits();
171    *  put( evtSvc(), hits, "/Event/MC/Hits" );
172    *
173    *  @endcode
174    *
175    *  @attention The method respects the setting of the job option
176    *             RootInTES by prepending the value of this to the
177    *             data location that is passed. 
178    *             The default setting for RootInTES is "" so has no effect.
179    *             This behaviour can be suppressed by passing the arguement 
180    *             useRootInTES = false
181    *
182    *  @see IDataProviderSvc
183    *
184    *  @param svc        Pointer to data provider service
185    *  @param object     Data object or container to be registered
186    *  @param address    Address in Gaudi Event Transient Store ("/Event" could be omitted )
187    *  @param useRootInTES Flag to turn on(TRUE) off(FALSE) the use of
188    *                      the RootInTES location property
189    *  @exception        GaudiException for invalid event data service
190    *  @exception        GaudiException for invalid object
191    *  @exception        GaudiException for error result from event data service
192    *  @return StatusCode
193    *  @retval StatusCode::SUCCESS Data was successfully placed in the TES.
194    *  @retval StatusCode::FAILURE Failed to store data in the TES.
195    */
196   inline DataObject* put ( IDataProviderSvc*  svc     ,
197                     DataObject*        object  ,
198                     const std::string& address ,
199                     const bool useRootInTES = true ) const
200   {
201     return GaudiCommon<AlgTool>::put ( svc , object , address , useRootInTES ) ;
202   }
203 
204   /** @brief Register a data object or container into Gaudi Event Transient Store
205    *
206    *  @see IDataProviderSvc
207    *
208    *  @code
209    *
210    *  MCHits * hits = put( new MCHits(), "/Event/MC/Hits" );
211    *
212    *  @endcode
213    *
214    *  @attention The method respects the setting of the job option
215    *             RootInTES by prepending the value of this to the
216    *             data location that is passed. 
217    *             The default setting for RootInTES is "" so has no effect.
218    *             This behaviour can be suppressed by passing the arguement 
219    *             useRootInTES = false
220    *
221    *  @param object     Data object or container to be registered
222    *  @param address    Address in Gaudi Event Transient Store ("/Event" could be omitted )
223    *  @param useRootInTES Flag to turn on(TRUE) off(FALSE) the use of
224    *                      the RootInTES location property
225    *  @exception        GaudiException for invalid event data service
226    *  @exception        GaudiException for invalid object
227    *  @exception        GaudiException for error result from event data service
228    *  @return StatusCode
229    *  @retval StatusCode::SUCCESS Data was successfully placed in the TES.
230    *  @retval StatusCode::FAILURE Failed to store data in the TES.
231    */
232   inline DataObject* put ( DataObject*        object   ,
233                     const std::string& address  ,
234                     const bool useRootInTES = true ) const
235   {
236     return GaudiCommon<AlgTool>::put ( evtSvc() , object , address , useRootInTES ) ;
237   }
238 
239   /** @brief Templated access to the data in Gaudi Transient Store
240    *
241    *  Quick and safe access to the data in Gaudi transient store.
242    *  The method located the data at given address and perform the
243    *  debug printout about located data
244    *
245    *  @code
246    *
247    *  MCHits* hits = get<MCHits>( evtSvc() , "/Event/MC/Hits" );
248    *
249    *  @endcode
250    *
251    *  @attention The method respects the setting of the job option
252    *             RootInTES by prepending the value of this to the
253    *             data location that is passed. 
254    *             The default setting for RootInTES is "" so has no effect.
255    *             This behaviour can be suppressed by passing the arguement 
256    *             useRootInTES = false
257    *
258    *  @see IDataProviderSvc
259    *  @see SmartDataPtr
260    *
261    *  @exception      GaudiException for Invalid Data Provider Service
262    *  @exception      GaudiException for invalid/unavailable data
263    *
264    *  @param svc      Pointer to data service (data provider)
265    *  @param location data location/address in Gaudi Transient Store
266    *  @param useRootInTES Flag to turn on(TRUE) off(FALSE) the use of
267    *                      the RootInTES location property
268    *  @return pointer to the data object
269    */
270   template < class TYPE  >
271   inline typename Gaudi::Utils::GetData<TYPE>::return_type
272   get  (  IDataProviderSvc*  svc       ,
273           const std::string& location  ,
274           const bool useRootInTES = true ) const
275   {
276     return GaudiCommon<AlgTool>::get<TYPE> ( svc , location , useRootInTES ) ;
277   }
278 
279   /** @brief Templated access to the data from Gaudi Event Transient Store
280    *
281    *  Quick and safe access to the data in Gaudi transient store.
282    *
283    *  The method located the data at the given address and perform the
284    *  debug printout about located data.
285    *
286    *  @code
287    *
288    *  MCParticles* mcps = get<MCParticles>( MCParticleLocation::Default );
289    *
290    *  @endcode
291    *
292    *  @attention The method respects the setting of the job option
293    *             RootInTES by prepending the value of this to the
294    *             data location that is passed. 
295    *             The default setting for RootInTES is "" so has no effect.
296    *             This behaviour can be suppressed by passing the arguement 
297    *             useRootInTES = false
298    *
299    *  @param location Data location/address in Gaudi Transient Store
300    *  @param useRootInTES Flag to turn on(TRUE) off(FALSE) the use of
301    *                      the RootInTES location property
302    *  @return         Pointer to the data object
303    */
304   template < class TYPE  >
305   inline typename Gaudi::Utils::GetData<TYPE>::return_type
306   get  ( const std::string& location  ,
307          const bool useRootInTES = true ) const
308   {
309     return GaudiCommon<AlgTool>::get<TYPE> ( evtSvc() , location , useRootInTES ) ;
310   }
311 
312   /** @brief Templated access to the detector data from the
313    *         Gaudi Detector Transient Store
314    *
315    *  Quick and safe access to the detector data in Gaudi transient store.
316    *
317    *  The method located the detector at the given address and perform the
318    *  debug printout about located detector.
319    *
320    *  @code
321    *
322    *  MyDet* mdet = getDet<MyDet>( detSvc() , "/dd/Structure/LHCb/MyDet" );
323    *
324    *  @endcode
325    *
326    *  @param svc       Pointer to data service (data provider)
327    *  @param location  Detector location/address in Gaudi Transient Store
328    *  @return          Pointer to the detector object
329    */
330   template < class TYPE  >
331   inline TYPE* getDet ( IDataProviderSvc*  svc        ,
332                         const std::string& location   ) const
333   {
334     return GaudiCommon<AlgTool>::get<TYPE> ( svc , location , false ) ;
335   }
336 
337   /** @brief Templated access to the detector data from the
338    *         Gaudi Detector Transient Store
339    *
340    *  Quick and safe access to the detector data in Gaudi transient store.
341    *
342    *  The method located the detector at the given address and perform the
343    *  debug printout about located detector.
344    *
345    *  @code
346    *
347    *  MyDet* mdet = getDet<MyDet>( "/dd/Structure/LHCb/MyDet" );
348    *
349    *  @endcode
350    *
351    *  @param location  Detector location/address in Gaudi Transient Store
352    *  @return          Pointer to the detector object
353    */
354   template < class TYPE  >
355   inline TYPE* getDet ( const std::string& location   ) const
356   {
357     return GaudiCommon<AlgTool>::get<TYPE> ( detSvc() , location , false ) ;
358   }
359 
360   /** @brief Check the existence of a data object or container
361    *         in the Gaudi Transient Event Store
362    *
363    *  @code
364    *
365    *  bool a1 = exist<DataObject>( evtSvc(), "/Event/MyObject" ) ;
366    *  bool a2 = exist<MyHits>    ( evtSvc(), "/Event/MyHits"   ) ;
367    *
368    *  @endcode
369    *
370    *  @attention The method respects the setting of the job option
371    *             RootInTES by prepending the value of this to the
372    *             data location that is passed. 
373    *             The default setting for RootInTES is "" so has no effect.
374    *             This behaviour can be suppressed by passing the arguement 
375    *             useRootInTES = false
376    *
377    *  @param svc       Pointer to data service (data provider)
378    *  @param  location Address in Gaudi Transient Event Store
379    *  @param useRootInTES Flag to turn on(TRUE) off(FALSE) the use of
380    *                      the RootInTES location property
381    *  @return          Boolean indicating status of the request
382    *  @retval true     Data object or container exists and implements a proper interface
383    *  @retval true     Failed to locate the data object or container
384    */
385   template < class TYPE  >
386   inline bool  exist    ( IDataProviderSvc*  svc      ,
387                           const std::string& location ,
388                           const bool useRootInTES = true ) const
389   {
390     return GaudiCommon<AlgTool>::exist<TYPE> ( svc , location , useRootInTES ) ;
391   }
392 
393   /** @brief Check the existence of a data object or container
394    *         in the Gaudi Transient Event Store
395    *
396    *  @code
397    *
398    *  bool a1 = exist<DataObject>( "/Event/MyObject" ) ;
399    *  bool a2 = exist<MyHits>    ( "/Event/MyHits"   ) ;
400    *
401    *  @endcode
402    *  
403    *  @attention The method respects the setting of the job option
404    *             RootInTES by prepending the value of this to the
405    *             data location that is passed. 
406    *             The default setting for RootInTES is "" so has no effect.
407    *             This behaviour can be suppressed by passing the arguement 
408    *             useRootInTES = false
409    *
410    *  @param  location Address in Gaudi Transient Event Store
411    *  @return          Boolean indicating status of the request
412    *  @retval true     Data object or container exists and implements a proper interface
413    *  @retval true     Failed to locate the data object or container
414    */
415   template < class TYPE  >
416   inline bool  exist    ( const std::string& location ,
417                           const bool useRootInTES = true ) const
418   {
419     return GaudiCommon<AlgTool>::exist<TYPE> ( evtSvc() , location , useRootInTES ) ;
420   }
421 
422   /** @brief Check the existence of detector objects in the Gaudi
423    *         Transient Detector Store
424    *
425    *  @code
426    *
427    *  bool a1 = existDet<DataObject> ( detSvc(), "/dd/Structure/MyObject"     ) ;
428    *  bool a2 = existDet<Material>   ( detSvc(), "/dd/Structure/Material/Air" ) ;
429    *
430    *  @endcode
431    *
432    *  @param svc       Pointer to data service (data provider)
433    *  @param  location Address in Gaudi Transient Detector Store
434    *  @return          Boolean indicating status of the request
435    *  @retval true     Detector object exists and implements a proper interface
436    *  @retval false    Failed to locate the data object
437    */
438   template < class TYPE  >
439   inline bool  existDet    ( IDataProviderSvc*  svc      ,
440                              const std::string& location ) const
441   {
442     return GaudiCommon<AlgTool>::exist<TYPE> ( svc , location , false ) ;
443   }
444 
445   /** @brief Check the existence of detector objects in the Gaudi
446    *         Transient Detector Store
447    *
448    *  @code
449    *
450    *  bool a1 = existDet<DataObject> ( "/dd/Structure/MyObject"     ) ;
451    *  bool a2 = existDet<Material>   ( "/dd/Structure/Material/Air" ) ;
452    *
453    *  @endcode
454    *
455    *  @param  location Address in Gaudi Transient Detector Store
456    *  @return          Boolean indicating status of the request
457    *  @retval true     Detector object exists and implements a proper interface
458    *  @retval false    Failed to locate the data object
459    */
460   template < class TYPE  >
461   inline bool  existDet    ( const std::string& location ) const
462   {
463     return GaudiCommon<AlgTool>::exist<TYPE> ( detSvc() , location , false ) ;
464   }
465 
466   /** @brief Get the existing data object from Gaudi Event Transient store.
467    *         Alternatively, create new object and register it in TES
468    *         and return if object does not exist.
469    *
470    *  @code
471    *
472    *  MyHits* hits = getOrCreate<MyHits,MyHits>( evtSvc() , "/Event/MyHits" ) ;
473    *
474    *  @endcode
475    *
476    *  @attention The method respects the setting of the job option
477    *             RootInTES by prepending the value of this to the
478    *             data location that is passed. 
479    *             The default setting for RootInTES is "" so has no effect.
480    *             This behaviour can be suppressed by passing the arguement 
481    *             useRootInTES = false
482    *
483    *  @exception GaudiException for Invalid Data Provider Service
484    *  @exception GaudiException for invalid/unavailable  data
485    *
486    *  @param svc        Pointer to data service (data provider)
487    *  @param  location  Location in Gaudi Transient Event Store
488    *  @param useRootInTES Flag to turn on(TRUE) off(FALSE) the use of
489    *                      the RootInTES location property
490    *  @return A valid pointer to the object
491    */
492   template < class TYPE , class TYPE2 >
493   inline TYPE* getOrCreate ( IDataProviderSvc*  svc      ,
494                              const std::string& location ,
495                              const bool useRootInTES = true ) const
496   {
497     return GaudiCommon<AlgTool>::getOrCreate<TYPE,TYPE2> ( svc , location , useRootInTES ) ;
498   }
499 
500   /** @brief Get the existing data object from Gaudi Event Transient store.
501    *         Alternatively, create new object and register it in TES
502    *         and return if object does not exist.
503    *
504    *  @code
505    *
506    *  MyHits* hits = getOrCreate<MyHits,MyHits>( "/Event/MyHits" ) ;
507    *
508    *  @endcode
509    *
510    *  @attention The method respects the setting of the job option
511    *             RootInTES by prepending the value of this to the
512    *             data location that is passed. 
513    *             The default setting for RootInTES is "" so has no effect.
514    *             This behaviour can be suppressed by passing the arguement 
515    *             useRootInTES = false
516    *
517    *  @exception GaudiException for Invalid Data Provider Service
518    *  @exception GaudiException for invalid/unavailable  data
519    *
520    *  @param  location  Location in Gaudi Transient Event Store
521    *  @param useRootInTES Flag to turn on(TRUE) off(FALSE) the use of
522    *                      the RootInTES location property
523    *  @return A valid pointer to the object
524    */
525   template < class TYPE , class TYPE2 >
526   inline TYPE* getOrCreate ( const std::string& location ,
527                              const bool useRootInTES = true ) const
528   {
529     return GaudiCommon<AlgTool>::getOrCreate<TYPE,TYPE2> ( evtSvc() , location , useRootInTES ) ;
530   }
531 
532 protected:
533 
534   /** Standard constructor
535    *  @see AlgTool
536    *  @param type tool type (useless)
537    *  @param name tool name
538    *  @param parent pointer to parent object (service, algorithm or tool)
539    */
540   GaudiTool ( const std::string& type   ,
541               const std::string& name   ,
542               const IInterface*  parent );
543 
544   /// destructor, virtual and protected
545   virtual ~GaudiTool();
546 
547 private:
548 
549   /// no public default constructor
550   GaudiTool();
551 
552   /// no public copy constructor
553   GaudiTool             ( const GaudiTool& );
554 
555   /// no public assignment operator
556   GaudiTool& operator = ( const GaudiTool& );
557 
558 private:
559 
560   /// pointer to the N-Tuple service
561   mutable INTupleSvc*    m_ntupleSvc          ;
562   /// pointer to the event tag collection service
563   mutable INTupleSvc*    m_evtColSvc          ;
564   /// pointer to Event Data Service
565   mutable IDataProviderSvc* m_evtSvc          ;
566   /// pointer to Detector Data Service
567   mutable IDataProviderSvc* m_detSvc          ;
568   /// pointer to Chrono & Stat Service
569   mutable IChronoStatSvc*   m_chronoSvc       ;
570   /// pointer to Incident Service
571   mutable IIncidentSvc*     m_incSvc          ;
572   /// pointer for histogram service
573   mutable IHistogramSvc *  m_histoSvc         ;
574   // Pointer to the Algorithm Context Service 
575   mutable IAlgContextSvc* m_contextSvc     ; ///< Algorithm Context Service 
576   // The name of the Algorithm Context Service 
577   std::string             m_contextSvcName ; ///< Algorithm Context Service 
578 
579 private:
580 
581   /// full tool name "type/name"
582   const std::string m_local ;
583 
584 };
585 // ============================================================================
586 
587 // ============================================================================
588 // The END
589 // ============================================================================
590 #endif  // GAUDIALG_GAUDITOOL_H
591 // ============================================================================
592 
593 

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!