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