| The Gaudi Framework v29r0 (ff2e7097)

- 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/DataObject.h"
8 #include "GaudiKernel/IAlgContextSvc.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, ISvcLocator* pSvcLocator )
36 : GaudiCommon<Algorithm>( name, pSvcLocator )
37 {
38 setProperty( "RegisterForContextService", true ).ignore();
39 }
40 // ============================================================================
41 // standard initialization method
42 // ============================================================================
43 StatusCode GaudiAlgorithm::initialize()
44 {
45 // initialize the base class
46 const StatusCode sc = GaudiCommon<Algorithm>::initialize();
47 if ( sc.isFailure() ) {
48 return sc;
49 }
50
51 // Add any customisations here, that cannot go in GaudiCommon
52
53 // return
54 return sc;
55 }
56 // ============================================================================
57 // standard finalization method
58 // ============================================================================
59 StatusCode GaudiAlgorithm::finalize()
60 {
61 if ( msgLevel( MSG::DEBUG ) ) 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() { return Error( "Default GaudiAlgorithm execute method called !!" ); }
73 // ============================================================================
74 // The standard event collection service
75 // ============================================================================
76 SmartIF<INTupleSvc>& GaudiAlgorithm::evtColSvc() const
77 {
78 if ( !m_evtColSvc ) {
79 m_evtColSvc = svc<INTupleSvc>( "EvtTupleSvc", true );
80 }
81 //
82 return m_evtColSvc;
83 }
84 // ============================================================================
85 /* The generic actions for the execution.
86 * @see Algorithm
87 * @see IAlgorithm
88 * @see Algorithm::sysExecute
89 * @return status code
90 */
91 // ============================================================================
92 StatusCode GaudiAlgorithm::sysExecute( const EventContext& evtCtx )
93 {
94 IAlgContextSvc* ctx = nullptr;
95 if ( registerContext() ) {
96 ctx = contextSvc();
97 }
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 ) ) debug() << *it << " found, skipping event " << endmsg;
106 return StatusCode::SUCCESS;
107 }
108
109 // Execute if m_requireObjs is empty
110 // or if one or more of the m_requireObjs exist in TES
111 bool doIt =
112 m_requireObjs.empty() || std::any_of( std::begin( m_requireObjs ), std::end( m_requireObjs ),
113 [&]( const std::string& loc ) { return this->exist<DataObject>( loc ); } );
114
115 // execute the generic method:
116 if ( doIt ) return Algorithm::sysExecute( evtCtx );
117 return StatusCode::SUCCESS;
118 }
119 // ============================================================================
120
121 // ============================================================================
122 // The END
123 // ============================================================================
Algorithm::contextSvc
SmartIF< IAlgContextSvc > & contextSvc() const
get Algorithm Context Service
Definition: Algorithm.cpp:805
StatusCode::SUCCESS
Definition: StatusCode.h:31
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:77
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
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:208
GaudiAlgorithm::initialize
StatusCode initialize() override
standard initialization method
Definition: GaudiAlgorithm.cpp:43
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:16
std::end
T end(T...args)
GaudiCommon::finalize
StatusCode finalize() override
standard finalization method
Definition: GaudiCommon.icpp:208
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:24
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
GaudiAlgorithm::evtColSvc
SmartIF< INTupleSvc > & evtColSvc() const
Access the standard event collection service.
Definition: GaudiAlgorithm.cpp:76
std::string
STL class.
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
GaudiAlgorithm::sysExecute
StatusCode sysExecute(const EventContext &ctx) override
the generic actions for the execution.
Definition: GaudiAlgorithm.cpp:92
GaudiAlgorithm::finalize
StatusCode finalize() override
standard finalization method
Definition: GaudiAlgorithm.cpp:59
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:120
std::begin
T begin(T...args)
Algorithm::registerContext
bool registerContext() const
register for Algorithm Context Service?
Definition: Algorithm.h:334
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:92
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:109
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
Definition: CommonMessaging.h:129
GaudiAlgorithm::GaudiAlgorithm
GaudiAlgorithm()
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Algorithm::sysExecute
StatusCode sysExecute(const EventContext &ctx) override
The actions to be performed by the algorithm on an event.
Definition: Algorithm.cpp:502
DataObject.h