| The Gaudi Framework v32r1 (f65d50dc)

Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
AlgExecStateSvc Class Reference

A service that keeps track of the execution state of Algorithm. More...

`#include <src/AlgExecStateSvc/AlgExecStateSvc.h>`

Inheritance diagram for AlgExecStateSvc:
[legend]
Collaboration diagram for AlgExecStateSvc:
[legend]

## Public Types
typedef IAlgExecStateSvc::AlgStateMap_t | AlgStateMap_t
Public Types inherited from extends< Service, IAlgExecStateSvc >
using | base_class = extends
| Typedef to this class. More...
using | extend_interfaces_base = extend_interfaces< Interfaces... >
| Typedef to the base of this class. More...
Public Types inherited from Service
using | Factory = Gaudi::PluginService::Factory< IService *(const std::string &, ISvcLocator *)>
Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using | PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
| Typedef used to refer to this class from derived classes, as in. More...
Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using | base_class = CommonMessaging
Public Types inherited from extend_interfaces< Interfaces... >
using | ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
| take union of the ext_iids of all Interfaces... More...

## Public Member Functions
const AlgExecState & | algExecState (const Gaudi::StringKey &algName, const EventContext &ctx) const override
AlgExecState & | algExecState (IAlgorithm *iAlg, const EventContext &ctx) override
const AlgStateMap_t & | algExecStates (const EventContext &ctx) const override
void | reset (const EventContext &ctx) override
void | addAlg (const Gaudi::StringKey &algName) override
const EventStatus::Status & | eventStatus (const EventContext &ctx) const override
void | setEventStatus (const EventStatus::Status &sc, const EventContext &ctx) override
void | updateEventStatus (const bool &b, const EventContext &ctx) override
unsigned int | algErrorCount (const IAlgorithm *iAlg) const override
void | resetErrorCount (const IAlgorithm *iAlg) override
unsigned int | incrementErrorCount (const IAlgorithm *iAlg) override
void | dump (std::ostringstream &ost, const EventContext &ctx) const override
virtual const AlgExecState & | algExecState (const Gaudi::StringKey &algName, const EventContext &ctx) const=0
const AlgExecState & | algExecState (IAlgorithm *iAlg, const EventContext &ctx) const
virtual AlgExecState & | algExecState (IAlgorithm *iAlg, const EventContext &ctx)=0
virtual void | addAlg (const Gaudi::StringKey &algName)=0
void | addAlg (IAlgorithm *iAlg)
Public Member Functions inherited from extends< Service, IAlgExecStateSvc >
void * | i_cast (const InterfaceID &tid) const override
| Implementation of IInterface::i_cast. More...
StatusCode | queryInterface (const InterfaceID &ti, void **pp) override
| Implementation of IInterface::queryInterface. More...
std::vector< std::string > | getInterfaceNames () const override
| Implementation of IInterface::getInterfaceNames. More...
Public Member Functions inherited from Service
const std::string & | name () const override
| Retrieve name of the service. More...
StatusCode | configure () override
StatusCode | initialize () override
StatusCode | start () override
StatusCode | stop () override
StatusCode | finalize () override
StatusCode | terminate () override
Gaudi::StateMachine::State | FSMState () const override
Gaudi::StateMachine::State | targetFSMState () const override
StatusCode | reinitialize () override
StatusCode | restart () override
StatusCode | sysInitialize () override
| Initialize Service. More...
StatusCode | sysStart () override
| Initialize Service. More...
StatusCode | sysStop () override
| Initialize Service. More...
StatusCode | sysFinalize () override
| Finalize Service. More...
StatusCode | sysReinitialize () override
| Re-initialize the Service. More...
StatusCode | sysRestart () override
| Re-initialize the Service. More...
| Service (std::string name, ISvcLocator *svcloc)
| Standard Constructor. More...
SmartIF< ISvcLocator > & | serviceLocator () const override
| Retrieve pointer to service locator. More...
StatusCode | setProperties ()
| Method for setting declared properties to the values specified for the job. More...
template<class T >
StatusCode | service (const std::string &name, const T *&psvc, bool createIf=true) const
| Access a service by name, creating it if it doesn't already exist. More...
template<class T >
StatusCode | service (const std::string &name, T *&psvc, bool createIf=true) const
template<typename IFace = IService>
SmartIF< IFace > | service (const std::string &name, bool createIf=true) const
template<class T >
StatusCode | service (const std::string &svcType, const std::string &svcName, T *&psvc) const
| Access a service by name and type, creating it if it doesn't already exist. More...
template<class T >
StatusCode | declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
| Declare used tool. More...
SmartIF< IAuditorSvc > & | auditorSvc () const
| The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
| PropertyHolder ()=default
Gaudi::Details::PropertyBase & | declareProperty (Gaudi::Details::PropertyBase &prop)
| Declare a property. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
| Helper to wrap a regular data member and use it as a regular property. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
| Declare a PropertyBase instance setting name and documentation. More...
Gaudi::Details::PropertyBase * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
| Declare a remote property. More...
StatusCode | setProperty (const Gaudi::Details::PropertyBase &p) override
| set the property form another property More...
StatusCode | setProperty (const std::string &s) override
| set the property from the formatted string More...
StatusCode | setProperty (const std::string &n, const std::string &v) override
| set the property from name and the value More...
StatusCode | setProperty (const std::string &name, const TYPE &value)
| set the property form the value More...
StatusCode | getProperty (Gaudi::Details::PropertyBase *p) const override
| get the property More...
const Gaudi::Details::PropertyBase & | getProperty (const std::string &name) const override
| get the property by name More...
StatusCode | getProperty (const std::string &n, std::string &v) const override
| convert the property to the string More...
const std::vector< Gaudi::Details::PropertyBase * > & | getProperties () const override
| get all properties More...
bool | hasProperty (const std::string &name) const override
| Return true if we have a property with the given name. More...
| PropertyHolder (const PropertyHolder &)=delete
PropertyHolder & | operator= (const PropertyHolder &)=delete
Public Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level | msgLevel () const
| get the cached level (originally extracted from the embedded MsgStream) More...
bool | msgLevel (MSG::Level lvl) const
| get the output level from the embedded MsgStream More...
MSG::Level | outputLevel () const
| Backward compatibility function for getting the output level. More...
Public Member Functions inherited from CommonMessagingBase
virtual | ~CommonMessagingBase ()=default
| Virtual destructor. More...
const SmartIF< IMessageSvc > & | msgSvc () const
| The standard message service. More...
MsgStream & | msgStream () const
| Return an uninitialized MsgStream. More...
MsgStream & | msgStream (const MSG::Level level) const
| Predefined configurable message stream for the efficient printouts. More...
MsgStream & | always () const
| shortcut for the method msgStream(MSG::ALWAYS) More...
MsgStream & | fatal () const
| shortcut for the method msgStream(MSG::FATAL) More...
MsgStream & | err () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | error () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | warning () const
| shortcut for the method msgStream(MSG::WARNING) More...
MsgStream & | info () const
| shortcut for the method msgStream(MSG::INFO) More...
MsgStream & | debug () const
| shortcut for the method msgStream(MSG::DEBUG) More...
MsgStream & | verbose () const
| shortcut for the method msgStream(MSG::VERBOSE) More...
MsgStream & | msg () const
| shortcut for the method msgStream(MSG::INFO) More...

## Private Member Functions
void | init ()
void | checkInit () const

## Private Attributes
std::vector< AlgStateMap_t > | m_algStates
std::vector< EventStatus::Status > | m_eventStatus
std::vector< Gaudi::StringKey > | m_preInitAlgs
std::map< Gaudi::StringKey, std::atomic< unsigned int > > | m_errorCount
std::once_flag | m_initFlag
bool | m_isInit = false
std::mutex | m_mut

## Additional Inherited Members
Protected Member Functions inherited from Service
| ~Service () override
| Standard Destructor. More...
int | outputLevel () const
| get the `Service's` output level More...
Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
Gaudi::Details::PropertyBase * | property (const std::string &name) const
Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level | setUpMessaging () const
| Set up local caches. More...
MSG::Level | resetMessaging ()
| Reinitialize internal states. More...
void | updateMsgStreamOutputLevel (int level)
| Update the output level of the cached MsgStream. More...
Protected Attributes inherited from Service
Gaudi::StateMachine::State | m_state = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::StateMachine::State | m_targetState = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::Property< int > | m_outputLevel {this, "OutputLevel", MSG::NIL, "output level"}
Gaudi::Property< bool > | m_auditInit {this, "AuditServices", false, " unused"}
Gaudi::Property< bool > | m_auditorInitialize {this, "AuditInitialize", false, "trigger auditor on initialize()"}
Gaudi::Property< bool > | m_auditorStart {this, "AuditStart", false, "trigger auditor on start()"}
Gaudi::Property< bool > | m_auditorStop {this, "AuditStop", false, "trigger auditor on stop()"}
Gaudi::Property< bool > | m_auditorFinalize {this, "AuditFinalize", false, "trigger auditor on finalize()"}
Gaudi::Property< bool > | m_auditorReinitialize {this, "AuditReinitialize", false, "trigger auditor on reinitialize()"}
Gaudi::Property< bool > | m_auditorRestart {this, "AuditRestart", false, "trigger auditor on restart()"}
SmartIF< IAuditorSvc > | m_pAuditorSvc
| Auditor Service. More...

## Detailed Description

A service that keeps track of the execution state of Algorithm.

Definition at line 16 of file AlgExecStateSvc.h.

## Member Typedef Documentation

## ◆ AlgStateMap_t

typedef IAlgExecStateSvc::AlgStateMap_t AlgExecStateSvc::AlgStateMap_t

Definition at line 20 of file AlgExecStateSvc.h.

## Member Function Documentation

## ◆ addAlg() [1/3]

virtual void IAlgExecStateSvc::addAlg

## ◆ addAlg() [2/3]

void IAlgExecStateSvc::addAlg
| inline

Definition at line 90 of file IAlgExecStateSvc.h.

90 { addAlg( iAlg->nameKey() ); }
AlgExecStateSvc::addAlg
void addAlg(const Gaudi::StringKey &algName) override
Definition: AlgExecStateSvc.cpp:83

## ◆ addAlg() [3/3]

void AlgExecStateSvc::addAlg | ( | const Gaudi::StringKey & | algName | ) |
| override

Definition at line 83 of file AlgExecStateSvc.cpp.

83 {
84 if ( !m_isInit ) {
85 if ( msgLevel( MSG::DEBUG ) ) debug() << "preInit: will add Alg " << alg.str() << " later" << endmsg;
86 m_preInitAlgs.push_back( alg );
87 return;
88 }
89
90 if ( !m_algStates.empty() && m_algStates.front().find( alg ) != m_algStates.front().end() ) {
91 // already added
92 return;
93 }
94
95 {
96 // in theory, this should only get called during initialization (serial)
97 // so shouldn't have to protect with a mutex...
98 std::lock_guard<std::mutex> lock( m_mut );
99
100 AlgExecState s;
101 for ( auto& a : m_algStates ) a[alg] = s;
102 m_errorCount[alg] = 0;
103 }
104
105 if ( msgLevel( MSG::DEBUG ) )
106 debug() << "adding alg " << alg.str() << " to " << m_algStates.size() << " slots" << endmsg;
107 }
ManySmallAlgs.alg
alg
Definition: ManySmallAlgs.py:69
AlgExecStateSvc::m_algStates
std::vector< AlgStateMap_t > m_algStates
Definition: AlgExecStateSvc.h:46
AlgExecStateSvc::m_errorCount
std::map< Gaudi::StringKey, std::atomic< unsigned int > > m_errorCount
Definition: AlgExecStateSvc.h:51
MSG::DEBUG
Definition: IMessageSvc.h:15
CommonMessaging< implements< IService, IProperty, IStateful > >::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:138
std::vector::push_back
T push_back(T... args)
std::lock
T lock(T... args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:107
AlgExecStateSvc::m_preInitAlgs
std::vector< Gaudi::StringKey > m_preInitAlgs
Definition: AlgExecStateSvc.h:49
AlgExecStateSvc::m_isInit
bool m_isInit
Definition: AlgExecStateSvc.h:56
AlgExecStateSvc::m_mut
std::mutex m_mut
Definition: AlgExecStateSvc.h:58
std::lock_guard
gaudirun.s
string s
Definition: gaudirun.py:316
AlgExecState
Definition: IAlgExecStateSvc.h:27
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

## ◆ algErrorCount()

unsigned int AlgExecStateSvc::algErrorCount | ( | const IAlgorithm * | iAlg | ) | const
| override

Definition at line 184 of file AlgExecStateSvc.cpp.

184 {
185 auto itr = m_errorCount.find( iAlg->nameKey() );
186 if ( itr == m_errorCount.end() ) {
187 error() << "Unable to find Algorithm \"" << iAlg->name() << "\" in map"
188 << " of ErrorCounts" << endmsg;
189 return 0;
190 }
191
192 return itr->second;
193 }
AlgExecStateSvc::m_errorCount
std::map< Gaudi::StringKey, std::atomic< unsigned int > > m_errorCount
Definition: AlgExecStateSvc.h:51
std::map::end
T end(T... args)
IAlgorithm::nameKey
virtual const Gaudi::StringKey & nameKey() const =0
StringKey rep of name.
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:98
std::map::find
T find(T... args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

## ◆ algExecState() [1/5]

virtual AlgExecState& IAlgExecStateSvc::algExecState

## ◆ algExecState() [2/5]

const AlgExecState& IAlgExecStateSvc::algExecState
| inline

Definition at line 79 of file IAlgExecStateSvc.h.

79 {
80 return algExecState( iAlg->nameKey(), ctx );
81 }
AlgExecStateSvc::algExecState
const AlgExecState & algExecState(const Gaudi::StringKey &algName, const EventContext &ctx) const override
Definition: AlgExecStateSvc.cpp:111

## ◆ algExecState() [3/5]

virtual const AlgExecState& IAlgExecStateSvc::algExecState

## ◆ algExecState() [4/5]

const AlgExecState & AlgExecStateSvc::algExecState | ( | const Gaudi::StringKey & | algName,
|  | const EventContext & | ctx
| ) |  | const
| override

Definition at line 111 of file AlgExecStateSvc.cpp.

111 {
112 checkInit();
113
114 auto& algState = m_algStates.at( ctx.slot() );
115 auto itr = algState.find( algName );
116 if ( UNLIKELY( itr == algState.end() ) ) {
117 throw GaudiException{"cannot find Alg " + algName.str() + " in AlgStateMap", name(), StatusCode::FAILURE};
118 }
119 return itr->second;
120 }
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:96
EventContext::slot
ContextID_t slot() const
Definition: EventContext.h:41
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:21
AlgExecStateSvc::m_algStates
std::vector< AlgStateMap_t > m_algStates
Definition: AlgExecStateSvc.h:46
Gaudi::StringKey::str
const std::string & str() const
the actual string
Definition: StringKey.h:45
AlgExecStateSvc::checkInit
void checkInit() const
Definition: AlgExecStateSvc.cpp:59
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:274
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86

## ◆ algExecState() [5/5]

AlgExecState & AlgExecStateSvc::algExecState | ( | IAlgorithm * | iAlg,
|  | const EventContext & | ctx
| ) |  |
| override

Definition at line 124 of file AlgExecStateSvc.cpp.

124 {
125 std::call_once( m_initFlag, &AlgExecStateSvc::init, this );
126
127 auto& algState = m_algStates.at( ctx.slot() );
128 auto itr = algState.find( iAlg->nameKey() );
129
130 if ( UNLIKELY( itr == algState.end() ) ) {
131 throw GaudiException{std::string{"cannot find Alg "} + iAlg->name() + " in AlgStateMap", name(),
132 StatusCode::FAILURE};
133 }
134
135 return itr->second;
136 }
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:96
EventContext::slot
ContextID_t slot() const
Definition: EventContext.h:41
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:21
AlgExecStateSvc::m_algStates
std::vector< AlgStateMap_t > m_algStates
Definition: AlgExecStateSvc.h:46
AlgExecStateSvc::init
void init()
Definition: AlgExecStateSvc.cpp:12
AlgExecStateSvc::m_initFlag
std::once_flag m_initFlag
Definition: AlgExecStateSvc.h:55
std::call_once
T call_once(T... args)
std::string
STL class.
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:274
IAlgorithm::nameKey
virtual const Gaudi::StringKey & nameKey() const =0
StringKey rep of name.
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86

## ◆ algExecStates()

const IAlgExecStateSvc::AlgStateMap_t & AlgExecStateSvc::algExecStates | ( | const EventContext & | ctx | ) | const
| override

Definition at line 140 of file AlgExecStateSvc.cpp.

140 {
141 checkInit();
142 return m_algStates.at( ctx.slot() );
143 }
EventContext::slot
ContextID_t slot() const
Definition: EventContext.h:41
AlgExecStateSvc::m_algStates
std::vector< AlgStateMap_t > m_algStates
Definition: AlgExecStateSvc.h:46
AlgExecStateSvc::checkInit
void checkInit() const
Definition: AlgExecStateSvc.cpp:59

## ◆ checkInit()

void AlgExecStateSvc::checkInit | ( |  | ) | const
| private

Definition at line 59 of file AlgExecStateSvc.cpp.

59 {
60
61 if ( !m_isInit ) {
62 fatal() << "AlgExecStateSvc not initialized before first use" << endmsg;
63 throw GaudiException( "AlgExecStateSvc not initialized before first use!", "AlgExecStateSvc", StatusCode::FAILURE );
64 }
65 }
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:21
AlgExecStateSvc::m_isInit
bool m_isInit
Definition: AlgExecStateSvc.h:56
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
CommonMessagingBase::fatal
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
Definition: CommonMessaging.h:92
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

## ◆ dump()

void AlgExecStateSvc::dump | ( | std::ostringstream & | ost,
|  | const EventContext & | ctx
| ) |  | const
| override

Definition at line 69 of file AlgExecStateSvc.cpp.

69 {
70 size_t slotID = ctx.valid() ? ctx.slot() : 0;
71
72 ost << " [slot: " << slotID << ", incident: " << m_eventStatus.at( slotID ) << "]:\n\n";
73
74 auto& algState = m_algStates.at( slotID );
75 auto ml = std::accumulate( begin( algState ), end( algState ), size_t{0},
76 []( size_t m, const auto& as ) { return std::max( m, as.first.str().length() ); } );
77
78 for ( auto& e : algState ) ost << " + " << std::setw( ml ) << e.first.str() << " " << e.second << '\n';
79 }
EventContext::slot
ContextID_t slot() const
Definition: EventContext.h:41
AlgExecStateSvc::m_algStates
std::vector< AlgStateMap_t > m_algStates
Definition: AlgExecStateSvc.h:46
EventContext::valid
bool valid() const
Definition: EventContext.h:44
std::setw
T setw(T... args)
std::vector::at
T at(T... args)
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:92
IOTest.end
def end
Definition: IOTest.py:112
std::max
T max(T... args)
AlgExecStateSvc::m_eventStatus
std::vector< EventStatus::Status > m_eventStatus
Definition: AlgExecStateSvc.h:48
Gaudi::Utils::begin
AttribStringParser::Iterator begin(const AttribStringParser &parser)
Definition: AttribStringParser.h:120
std::accumulate
T accumulate(T... args)

## ◆ eventStatus()

const EventStatus::Status & AlgExecStateSvc::eventStatus | ( | const EventContext & | ctx | ) | const
| override

Definition at line 147 of file AlgExecStateSvc.cpp.

147 {
148 checkInit();
149 return m_eventStatus.at( ctx.slot() );
150 }
EventContext::slot
ContextID_t slot() const
Definition: EventContext.h:41
AlgExecStateSvc::checkInit
void checkInit() const
Definition: AlgExecStateSvc.cpp:59
std::vector::at
T at(T... args)
AlgExecStateSvc::m_eventStatus
std::vector< EventStatus::Status > m_eventStatus
Definition: AlgExecStateSvc.h:48

## ◆ incrementErrorCount()

unsigned int AlgExecStateSvc::incrementErrorCount | ( | const IAlgorithm * | iAlg | ) |
| override

Definition at line 209 of file AlgExecStateSvc.cpp.

209 {
210 auto itr = m_errorCount.find( iAlg->nameKey() );
211 if ( itr == m_errorCount.end() ) {
212 error() << "Unable to find Algorithm \"" << iAlg->name() << "\" in map"
213 << " of ErrorCounts" << endmsg;
214 return 0;
215 }
216 return ++( itr->second );
217 }
AlgExecStateSvc::m_errorCount
std::map< Gaudi::StringKey, std::atomic< unsigned int > > m_errorCount
Definition: AlgExecStateSvc.h:51
std::map::end
T end(T... args)
IAlgorithm::nameKey
virtual const Gaudi::StringKey & nameKey() const =0
StringKey rep of name.
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:98
std::map::find
T find(T... args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

## ◆ init()

void AlgExecStateSvc::init | ( |  | ) |
| private

Definition at line 12 of file AlgExecStateSvc.cpp.

12 {
13
14 // seriously? do we have no way of getting a Service by type???
15 std::string wbn;
16 for ( auto& is : serviceLocator()->getServices() ) {
17 IHiveWhiteBoard* iwb = dynamic_cast<IHiveWhiteBoard*>( is );
18 if ( iwb ) {
19 wbn = is->name();
20 if ( msgLevel( MSG::VERBOSE ) ) verbose() << "HiveWhiteBoard service name is " << wbn << endmsg;
21 break;
22 }
23 }
24
25 SmartIF<IHiveWhiteBoard> wbs;
26 wbs = serviceLocator()->service( wbn, false );
27
28 if ( wbs.isValid() ) {
29 m_algStates.resize( wbs->getNumberOfStores() );
30 m_eventStatus.resize( wbs->getNumberOfStores() );
31 } else {
32 m_algStates.resize( 1 );
33 m_eventStatus.resize( 1 );
34 }
35
36 if ( msgLevel( MSG::DEBUG ) ) debug() << "resizing state containers to : " << m_algStates.size() << endmsg;
37
38 SmartIF<IAlgManager> algMan( serviceLocator() );
39 if ( !algMan.isValid() ) {
40 fatal() << "could not get the AlgManager" << endmsg;
41 throw GaudiException( "In AlgExecStateSvc, unable to get the AlgManager!", "AlgExecStateSvc", StatusCode::FAILURE );
42 }
43
44 m_isInit = true;
45
46 auto algos = algMan->getAlgorithms();
47 for ( auto& alg : algos ) addAlg( alg );
48 for ( auto& alg : m_preInitAlgs ) addAlg( alg );
49
50 if ( msgLevel( MSG::VERBOSE ) ) {
51 std::ostringstream ost;
52 dump( ost, Gaudi::Hive::currentContext() );
53 verbose() << "dumping state:\n" << ost.str() << endmsg;
54 }
55 }
SmartIF< IHiveWhiteBoard >
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:277
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:21
ManySmallAlgs.alg
alg
Definition: ManySmallAlgs.py:69
AlgExecStateSvc::m_algStates
std::vector< AlgStateMap_t > m_algStates
Definition: AlgExecStateSvc.h:46
MSG::DEBUG
Definition: IMessageSvc.h:15
SmartIF::isValid
bool isValid() const
Allow for check if smart pointer is valid.
Definition: SmartIF.h:62
AlgExecStateSvc::addAlg
void addAlg(const Gaudi::StringKey &algName) override
Definition: AlgExecStateSvc.cpp:83
AlgExecStateSvc::dump
void dump(std::ostringstream &ost, const EventContext &ctx) const override
Definition: AlgExecStateSvc.cpp:69
MSG::VERBOSE
Definition: IMessageSvc.h:15
CommonMessaging< implements< IService, IProperty, IStateful > >::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:138
std::vector::resize
T resize(T... args)
std::string
STL class.
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:76
std::ostringstream
STL class.
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:110
Gaudi::Hive::currentContext
GAUDI_API const EventContext & currentContext()
Definition: ThreadLocalContext.cpp:20
std::ostringstream::str
T str(T... args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:107
IHiveWhiteBoard::getNumberOfStores
virtual size_t getNumberOfStores() const =0
Get the number of 'slots'.
AlgExecStateSvc::m_preInitAlgs
std::vector< Gaudi::StringKey > m_preInitAlgs
Definition: AlgExecStateSvc.h:49
IHiveWhiteBoard
Definition: IHiveWhiteBoard.h:17
AlgExecStateSvc::m_isInit
bool m_isInit
Definition: AlgExecStateSvc.h:56
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
AlgExecStateSvc::m_eventStatus
std::vector< EventStatus::Status > m_eventStatus
Definition: AlgExecStateSvc.h:48
CommonMessagingBase::fatal
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
Definition: CommonMessaging.h:92
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

## ◆ reset()

void AlgExecStateSvc::reset | ( | const EventContext & | ctx | ) |
| override

Definition at line 173 of file AlgExecStateSvc.cpp.

173 {
174 if ( msgLevel( MSG::DEBUG ) ) verbose() << "reset(" << ctx.slot() << ")" << endmsg;
175
176 std::call_once( m_initFlag, &AlgExecStateSvc::init, this );
177 for ( auto& e : m_algStates.at( ctx.slot() ) ) e.second.reset();
178
179 m_eventStatus.at( ctx.slot() ) = EventStatus::Invalid;
180 }
EventContext::slot
ContextID_t slot() const
Definition: EventContext.h:41
AlgExecStateSvc::m_algStates
std::vector< AlgStateMap_t > m_algStates
Definition: AlgExecStateSvc.h:46
AlgExecStateSvc::init
void init()
Definition: AlgExecStateSvc.cpp:12
MSG::DEBUG
Definition: IMessageSvc.h:15
AlgExecStateSvc::m_initFlag
std::once_flag m_initFlag
Definition: AlgExecStateSvc.h:55
std::call_once
T call_once(T... args)
CommonMessaging< implements< IService, IProperty, IStateful > >::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:138
std::vector::at
T at(T... args)
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:110
EventStatus::Invalid
Definition: IAlgExecStateSvc.h:63
AlgExecStateSvc::m_eventStatus
std::vector< EventStatus::Status > m_eventStatus
Definition: AlgExecStateSvc.h:48
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

## ◆ resetErrorCount()

void AlgExecStateSvc::resetErrorCount | ( | const IAlgorithm * | iAlg | ) |
| override

Definition at line 197 of file AlgExecStateSvc.cpp.

197 {
198 auto itr = m_errorCount.find( iAlg->nameKey() );
199 if ( itr != m_errorCount.end() ) {
200 itr->second = 0;
201 } else {
202 error() << "Unable to find Algorithm \"" << iAlg->name() << "\" in map"
203 << " of ErrorCounts" << endmsg;
204 }
205 }
AlgExecStateSvc::m_errorCount
std::map< Gaudi::StringKey, std::atomic< unsigned int > > m_errorCount
Definition: AlgExecStateSvc.h:51
std::map::end
T end(T... args)
IAlgorithm::nameKey
virtual const Gaudi::StringKey & nameKey() const =0
StringKey rep of name.
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:98
std::map::find
T find(T... args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

## ◆ setEventStatus()

void AlgExecStateSvc::setEventStatus | ( | const EventStatus::Status & | sc,
|  | const EventContext & | ctx
| ) |  |
| override

Definition at line 154 of file AlgExecStateSvc.cpp.

154 {
155 std::call_once( m_initFlag, &AlgExecStateSvc::init, this );
156 m_eventStatus.at( ctx.slot() ) = sc;
157 }
EventContext::slot
ContextID_t slot() const
Definition: EventContext.h:41
AlgExecStateSvc::init
void init()
Definition: AlgExecStateSvc.cpp:12
AlgExecStateSvc::m_initFlag
std::once_flag m_initFlag
Definition: AlgExecStateSvc.h:55
std::call_once
T call_once(T... args)
std::vector::at
T at(T... args)
AlgExecStateSvc::m_eventStatus
std::vector< EventStatus::Status > m_eventStatus
Definition: AlgExecStateSvc.h:48

## ◆ updateEventStatus()

void AlgExecStateSvc::updateEventStatus | ( | const bool & | b,
|  | const EventContext & | ctx
| ) |  |
| override

Definition at line 161 of file AlgExecStateSvc.cpp.

161 {
162 std::call_once( m_initFlag, &AlgExecStateSvc::init, this );
163 auto& status = m_eventStatus.at( ctx.slot() );
164 if ( status == EventStatus::Success ) {
165 if ( fail ) status = EventStatus::AlgFail;
166 } else if ( status == EventStatus::Invalid ) {
167 status = ( fail ? EventStatus::AlgFail : EventStatus::Success );
168 }
169 }
EventContext::slot
ContextID_t slot() const
Definition: EventContext.h:41
AlgExecStateSvc::init
void init()
Definition: AlgExecStateSvc.cpp:12
AlgExecStateSvc::m_initFlag
std::once_flag m_initFlag
Definition: AlgExecStateSvc.h:55
std::call_once
T call_once(T... args)
std::vector::at
T at(T... args)
EventStatus::Invalid
Definition: IAlgExecStateSvc.h:63
EventStatus::Success
Definition: IAlgExecStateSvc.h:63
EventStatus::AlgFail
Definition: IAlgExecStateSvc.h:63
AlgExecStateSvc::m_eventStatus
std::vector< EventStatus::Status > m_eventStatus
Definition: AlgExecStateSvc.h:48

## Member Data Documentation

## ◆ m_algStates

std::vector<AlgStateMap_t> AlgExecStateSvc::m_algStates
| private

Definition at line 46 of file AlgExecStateSvc.h.

## ◆ m_errorCount

std::map<Gaudi::StringKey, std::atomic<unsigned int> > AlgExecStateSvc::m_errorCount
| private

Definition at line 51 of file AlgExecStateSvc.h.

## ◆ m_eventStatus

std::vector<EventStatus::Status> AlgExecStateSvc::m_eventStatus
| private

Definition at line 48 of file AlgExecStateSvc.h.

## ◆ m_initFlag

std::once_flag AlgExecStateSvc::m_initFlag
| private

Definition at line 55 of file AlgExecStateSvc.h.

## ◆ m_isInit

bool AlgExecStateSvc::m_isInit = false
| private

Definition at line 56 of file AlgExecStateSvc.h.

## ◆ m_mut

std::mutex AlgExecStateSvc::m_mut
| private

Definition at line 58 of file AlgExecStateSvc.h.

## ◆ m_preInitAlgs

std::vector<Gaudi::StringKey> AlgExecStateSvc::m_preInitAlgs
| private

Definition at line 49 of file AlgExecStateSvc.h.

The documentation for this class was generated from the following files:

- GaudiCoreSvc/src/AlgExecStateSvc/AlgExecStateSvc.h
- GaudiCoreSvc/src/AlgExecStateSvc/AlgExecStateSvc.cpp