Gaudi Framework, version v22r1

Home   Generated: Mon Feb 28 2011

GaudiAlgorithm.cpp

Go to the documentation of this file.
00001 // $Id: GaudiAlgorithm.cpp,v 1.12 2008/11/04 22:49:25 marcocle Exp $
00002 // ============================================================================
00003 #define  GAUDIALG_GAUDIALGORITHM_CPP 1
00004 // ============================================================================
00005 // include files
00006 // ============================================================================
00007 // GaudiKernel
00008 // ============================================================================
00009 #include "GaudiKernel/IAlgContextSvc.h"
00010 #include "GaudiKernel/DataObject.h"
00011 // ============================================================================
00012 // GaudiAlg
00013 // ============================================================================
00014 #include "GaudiAlg/GaudiAlgorithm.h"
00015 // ============================================================================
00027 // ============================================================================
00028 // templated methods
00029 // ============================================================================
00030 #include "GaudiCommon.icpp"
00031 // ============================================================================
00032 template class GaudiCommon<Algorithm>;
00033 // ============================================================================
00034 // Standard algorithm like constructor
00035 // ============================================================================
00036 GaudiAlgorithm::GaudiAlgorithm ( const std::string&  name        ,
00037                                  ISvcLocator*        pSvcLocator )
00038   : GaudiCommon<Algorithm> ( name , pSvcLocator )
00039   //
00040   , m_evtColSvc  ()  // pointer to Event Tag Collection Service
00041 {
00042   m_vetoObjs.clear();
00043   m_requireObjs.clear();
00044   
00045   setProperty ( "RegisterForContextService" , true ).ignore() ;
00046   
00047   declareProperty( "VetoObjects", m_vetoObjs,
00048                    "Skip execute if one or more of these TES objects exists" );
00049   declareProperty( "RequireObjects", m_requireObjs,
00050                    "Execute only if one or more of these TES objects exists" );
00051 }
00052 // ============================================================================
00053 // Destructor
00054 // ============================================================================
00055 GaudiAlgorithm::~GaudiAlgorithm() { }
00056 // ============================================================================
00057 // standard initialization method
00058 // ============================================================================
00059 StatusCode GaudiAlgorithm::initialize()
00060 {
00061   // initialize the base class
00062   const StatusCode sc = GaudiCommon<Algorithm>::initialize() ;
00063   if ( sc.isFailure() ) { return sc; }
00064 
00065   // Add any customisations here, that cannot go in GaudiCommon
00066 
00067   // return
00068   return sc;
00069 }
00070 // ============================================================================
00071 // standard finalization method
00072 // ============================================================================
00073 StatusCode GaudiAlgorithm::finalize()
00074 {
00075   if ( msgLevel(MSG::DEBUG) )
00076     debug() << "Finalize base class GaudiAlgorithm" << endmsg;
00077   
00078   // reset pointers
00079   m_evtColSvc.reset() ;
00080   
00081   // finalize the base class and return
00082   return GaudiCommon<Algorithm>::finalize() ;
00083 }
00084 // ============================================================================
00085 // standard execution method
00086 // ============================================================================
00087 StatusCode GaudiAlgorithm::execute()
00088 {
00089   return Error ( "Default GaudiAlgorithm execute method called !!" ) ;
00090 }
00091 // ============================================================================
00092 // The standard event collection service
00093 // ============================================================================
00094 SmartIF<INTupleSvc>& GaudiAlgorithm::evtColSvc() const
00095 {
00096   if ( !m_evtColSvc.isValid() )
00097   { m_evtColSvc = svc< INTupleSvc > ( "EvtTupleSvc" , true ) ; }
00098   //
00099   return m_evtColSvc ;
00100 }
00101 // ============================================================================
00102 /*  The generic actions for the execution.
00103  *  @see  Algorithm
00104  *  @see IAlgorithm
00105  *  @see Algorithm::sysExecute
00106  *  @return status code
00107  */
00108 // ============================================================================
00109 StatusCode GaudiAlgorithm::sysExecute ()
00110 {
00111   IAlgContextSvc* ctx = 0 ;
00112   if ( registerContext() ) { ctx = contextSvc() ; }
00113   // Lock the context
00114   Gaudi::Utils::AlgContext cnt ( ctx , this ) ;  
00115 
00116   // Do not execute if one or more of the m_vetoObjs exist in TES
00117   for( std::vector<std::string>::iterator it  = m_vetoObjs.begin();
00118                                           it != m_vetoObjs.end(); it++ ) {
00119     if( exist<DataObject>(*it) ) {
00120       debug() << *it << " found, skipping event " << endmsg;
00121       return StatusCode::SUCCESS;
00122     }
00123   }
00124 
00125   // Execute if m_requireObjs is empty
00126   bool doIt = m_requireObjs.empty() ? true : false;
00127 
00128   // Execute also if one or more of the m_requireObjs exist in TES
00129   for( std::vector<std::string>::iterator it  = m_requireObjs.begin();
00130                                           it != m_requireObjs.end(); it++ ) {
00131     if( exist<DataObject>(*it) ) {
00132       doIt = true;
00133       break;
00134     }
00135   }
00136 
00137   if( doIt )
00138     // execute the generic method:
00139     return Algorithm::sysExecute() ;
00140   else
00141     return StatusCode::SUCCESS;
00142 }
00143 // ============================================================================
00144 
00145 
00146 
00147 
00148 // ============================================================================
00149 // The END
00150 // ============================================================================
00151 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Mon Feb 28 2011 18:27:04 for Gaudi Framework, version v22r1 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004