| The Gaudi Framework v28r2-patches (bc4ad17a)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

GaudiAlgorithm.cpp
Go to the documentation of this file.
1 #define GAUDIALG_GAUDIALGORITHM_CPP 1
2 // ============================================================================
3 // include files
4 // ============================================================================
5 // GaudiKernel
6 // ============================================================================
7 #include "GaudiKernel/IAlgContextSvc.h"
8 #include "GaudiKernel/DataObject.h"
9 #include "GaudiKernel/ThreadLocalContext.h"
10 // ============================================================================
11 // GaudiAlg
12 // ============================================================================
13 #include "GaudiAlg/GaudiAlgorithm.h"
14 // ============================================================================
26 // ============================================================================
27 // templated methods
28 // ============================================================================
29 #include "GaudiCommon.icpp"
30 // ============================================================================
31 template class GaudiCommon<Algorithm>;
32 // ============================================================================
33 // Standard algorithm like constructor
34 // ============================================================================
35 GaudiAlgorithm::GaudiAlgorithm ( const std::string& name ,
36 ISvcLocator* pSvcLocator )
37 : GaudiCommon<Algorithm> ( name , pSvcLocator )
38 {
39 setProperty ( "RegisterForContextService" , true ).ignore() ;
40 }
41 // ============================================================================
42 // standard initialization method
43 // ============================================================================
44 StatusCode GaudiAlgorithm::initialize()
45 {
46 // initialize the base class
47 const StatusCode sc = GaudiCommon<Algorithm>::initialize() ;
48 if ( sc.isFailure() ) { return sc; }
49
50 // Add any customisations here, that cannot go in GaudiCommon
51
52 // return
53 return sc;
54 }
55 // ============================================================================
56 // standard finalization method
57 // ============================================================================
58 StatusCode GaudiAlgorithm::finalize()
59 {
60 if ( msgLevel(MSG::DEBUG) )
61 debug() << "Finalize base class GaudiAlgorithm" << endmsg;
62
63 // reset pointers
64 m_evtColSvc.reset() ;
65
66 // finalize the base class and return
67 return GaudiCommon<Algorithm>::finalize() ;
68 }
69 // ============================================================================
70 // standard execution method
71 // ============================================================================
72 StatusCode GaudiAlgorithm::execute()
73 {
74 return Error ( "Default GaudiAlgorithm execute method called !!" ) ;
75 }
76 // ============================================================================
77 // The standard event collection service
78 // ============================================================================
79 SmartIF<INTupleSvc>& GaudiAlgorithm::evtColSvc() const
80 {
81 if ( !m_evtColSvc )
82 { m_evtColSvc = svc< INTupleSvc > ( "EvtTupleSvc" , true ) ; }
83 //
84 return m_evtColSvc ;
85 }
86 // ============================================================================
87 /* The generic actions for the execution.
88 * @see Algorithm
89 * @see IAlgorithm
90 * @see Algorithm::sysExecute
91 * @return status code
92 */
93 // ============================================================================
94 StatusCode GaudiAlgorithm::sysExecute (const EventContext& evtCtx)
95 {
96 IAlgContextSvc* ctx = nullptr ;
97 if ( registerContext() ) { ctx = contextSvc() ; }
98 // Lock the context
99 Gaudi::Utils::AlgContext cnt ( ctx , this ) ;
100
101 // Do not execute if one or more of the m_vetoObjs exist in TES
102 auto it = std::find_if( std::begin(m_vetoObjs), std::end(m_vetoObjs),
103 [&](const std::string& loc) { return this->exist<DataObject>(loc); } );
104 if ( it != std::end(m_vetoObjs) ) {
105 if ( msgLevel(MSG::DEBUG) )
106 debug() << *it << " found, skipping event " << endmsg;
107 return StatusCode::SUCCESS;
108 }
109
110 // Execute if m_requireObjs is empty
111 // or if one or more of the m_requireObjs exist in TES
112 bool doIt = m_requireObjs.empty() ||
113 std::any_of( std::begin(m_requireObjs), std::end(m_requireObjs),
114 [&](const std::string& loc) { return this->exist<DataObject>(loc); } );
115
116 // execute the generic method:
117 if( doIt ) return Algorithm::sysExecute(evtCtx) ;
118 return StatusCode::SUCCESS;
119 }
120 // ============================================================================
121
122 // ============================================================================
123 // The END
124 // ============================================================================
Algorithm::contextSvc
SmartIF< IAlgContextSvc > & contextSvc() const
get Algorithm Context Service
Definition: Algorithm.cpp:783
StatusCode::SUCCESS
Definition: StatusCode.h:30
SmartIF< INTupleSvc >
GaudiAlgorithm::m_evtColSvc
SmartIF< INTupleSvc > m_evtColSvc
Event Tag Collection Service.
Definition: GaudiAlgorithm.h:665
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
Gaudi::Utils::AlgContext
Helper "sentry" class to automatize the safe register/unregister the algorithm&#39;s context.
Definition: IAlgContextSvc.h:76
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:28
PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >::setProperty
StatusCode setProperty(const Gaudi::Details::PropertyBase &p) override
set the property form another property
Definition: PropertyHolder.h:210
GaudiAlgorithm::initialize
StatusCode initialize() override
standard initialization method
Definition: GaudiAlgorithm.cpp:44
ThreadLocalContext.h
GaudiCommon< Algorithm >::Error
StatusCode Error(const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
Print the error message and return with the given StatusCode.
GaudiAlgorithm.h
Header file for class GaudiAlgorithm.
MSG::DEBUG
Definition: IMessageSvc.h:18
std::end
T end(T...args)
GaudiCommon::finalize
StatusCode finalize() override
standard finalization method
Definition: GaudiCommon.icpp:207
GaudiAlgorithm::execute
StatusCode execute() override
standard execution method
Definition: GaudiAlgorithm.cpp:72
EventContext
This class represents an entry point to all the event specific data.
Definition: EventContext.h:25
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:84
GaudiAlgorithm::evtColSvc
SmartIF< INTupleSvc > & evtColSvc() const
Access the standard event collection service.
Definition: GaudiAlgorithm.cpp:79
std::string
STL class.
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
GaudiAlgorithm::sysExecute
StatusCode sysExecute(const EventContext &ctx) override
the generic actions for the execution.
Definition: GaudiAlgorithm.cpp:94
GaudiAlgorithm::finalize
StatusCode finalize() override
standard finalization method
Definition: GaudiAlgorithm.cpp:58
GaudiCommon.icpp
GaudiCommon::initialize
StatusCode initialize() override
standard initialization method
Definition: GaudiCommon.icpp:114
IAlgContextSvc.h
Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:78
std::find_if
T find_if(T...args)
GaudiAlgorithm::m_requireObjs
Gaudi::Property< std::vector< std::string > > m_requireObjs
Definition: GaudiAlgorithm.h:669
GaudiAlgorithm::m_vetoObjs
Gaudi::Property< std::vector< std::string > > m_vetoObjs
Definition: GaudiAlgorithm.h:667
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:126
std::begin
T begin(T...args)
Algorithm::registerContext
bool registerContext() const
register for Algorithm Context Service?
Definition: Algorithm.h:330
std::any_of
T any_of(T...args)
GaudiCommon< Algorithm >
IAlgContextSvc
An abstract interface for Algorithm Context Service.
Definition: IAlgContextSvc.h:23
SmartIF::reset
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:88
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:106
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
Definition: CommonMessaging.h:135
GaudiAlgorithm::GaudiAlgorithm
GaudiAlgorithm()
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
Algorithm::sysExecute
StatusCode sysExecute(const EventContext &ctx) override
The actions to be performed by the algorithm on an event.
Definition: Algorithm.cpp:484
DataObject.h