ATLAS Offline Software
Loading...
Searching...
No Matches
PyAthenaEventLoopMgr Class Reference

Implementation of the AthenaEventLoopMgr that allows selective and specific overrides in python. More...

#include <PyAthenaEventLoopMgr.h>

Inheritance diagram for PyAthenaEventLoopMgr:
Collaboration diagram for PyAthenaEventLoopMgr:

Public Types

typedef IEvtSelector::Context EvtContext

Public Member Functions

 PyAthenaEventLoopMgr (const std::string &name, ISvcLocator *svcLoc)
 Standard Constructor.
 ~PyAthenaEventLoopMgr ()
PyObject * setManager (PyObject *)
 actual manager object
PyObject * getManager ()
virtual StatusCode initialize ()
 implementation of IAppMgrUI::initalize
virtual StatusCode finalize ()
 implementation of IAppMgrUI::finalize
virtual StatusCode nextEvent (int maxevt) override
 implementation of IAppMgrUI::nextEvent. maxevt==0 returns immediately
virtual StatusCode executeEvent (EventContext &&ctx) override
 implementation of IEventProcessor::executeEvent(EventContext&& ctx)
virtual StatusCode executeRun (int maxevt) override
 implementation of IEventProcessor::executeRun(int maxevt)
virtual StatusCode seek (int evt) override
 Seek to a given event.
virtual int curEvent () const override
 Return the current event count.
virtual void setNextEventModifierIndex (long idx) override
 Supply absolute input event index for EvtIdModifierSvc. See IEventSeek.h.
virtual int size () override
 Return the size of the collection.
virtual void handle (const Incident &inc) override
 IIncidentListenet interfaces.
StatusCode execAtPreFork (const EventContext &ctx) const
 Execute certain algorithms/sequences in PreFork.
virtual StatusCode stopRun () override
 Called from ApplicationMgr::stopRun() to terminate the loop.
virtual const std::string & name () const override
virtual void modifyEventContext (EventContext &ctx, const EventID &eID, bool consume_modifier_stream)
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
bool msgLvl (const MSG::Level lvl) const
 Test the output level.
void setLevel (MSG::Level lvl)
 Change the current logging level.

Static Public Member Functions

static PyAthenaEventLoopMgr * pointer ()
 outside access

Protected Types

typedef ServiceHandle< IIncidentSvc > IIncidentSvc_t
typedef ServiceHandle< StoreGateSvc > StoreGateSvc_t
typedef ServiceHandle< IDataManagerSvc > IDataManagerSvc_t
typedef ServiceHandle< IConversionSvc > IConversionSvc_t
typedef ServiceHandle< IEvtIdModifierSvc > IEvtIdModifierSvc_t
typedef EventID::number_type number_type
typedef IAthenaEvtLoopPreSelectTool tool_type
typedef ToolHandleArray< tool_type > tool_store
typedef tool_store::const_iterator tool_iterator
typedef std::vector< unsigned int > tool_stats
typedef tool_stats::const_iterator tool_stats_iterator

Protected Member Functions

 PyAthenaEventLoopMgr ()
 Unimplemented features to keep Reflex happy.
 PyAthenaEventLoopMgr (const PyAthenaEventLoopMgr &)
PyAthenaEventLoopMgr & operator= (const PyAthenaEventLoopMgr &)
virtual StatusCode executeAlgorithms (const EventContext &)
 Run the algorithms for the current event.
void setupPreSelectTools (Gaudi::Details::PropertyBase &)
 property update handler:sets up the Pre-selection tools
void setClearStorePolicy (Gaudi::Details::PropertyBase &clearStorePolicy)
 property update handler:set the clear-store policy value and check its value.
virtual StatusCode writeHistograms (bool force=false)
 Dump out histograms as needed.
StatusCode initializeAlgorithms ()
 Initialize all algorithms and output streams.
void setTimeout (Timeout &instance)
 Set timeout.
void resetTimeout (Timeout &instance)
 Reset timeout.

Protected Attributes

IIncidentSvc_t m_incidentSvc
 Reference to the incident service.
StoreGateSvc_t m_eventStore
 Reference to StoreGateSvc;.
IEvtSelector * m_evtSelector
 Reference to the Event Selector.
IEvtSelector::Context * m_evtSelCtxt
 Gaudi EventSelector Context (may be used as a cursor by the evt selector).
StringProperty m_evtsel
IDataManagerSvc_t m_histoDataMgrSvc
 Reference to the Histogram Data Service.
IConversionSvc_t m_histoPersSvc
IEvtIdModifierSvc_t m_evtIdModSvc
StringArrayProperty m_execAtPreFork
StringProperty m_histPersName
number_type m_currentRun
 current run number
bool m_firstRun
IntegerProperty m_failureMode
UnsignedIntegerProperty m_eventPrintoutInterval
tool_stats m_toolInvoke
 tool called counter
tool_stats m_toolReject
 tool returns StatusCode::FAILURE counter
tool_stats m_toolAccept
 tool returns StatusCode::SUCCESS counter
tool_store m_tools
 internal tool store
bool m_requireInputAttributeList {}
 require input attribute list
bool m_useSecondaryEventNumber {}
 read event number from secondary input
StringProperty m_clearStorePolicy
SmartIF< IAlgExecStateSvc > m_aess
 Reference to the Algorithm Execution State Svc.

Private Member Functions

StatusCode installEventContext (EventContext &ctx)
void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

PyObject * m_manager
int m_nevt {}
long m_evtModIdxBase {-1}
int m_evtModBaseNevt {0}
long m_curEvtModIdx {-1}
IntegerProperty m_writeInterval
bool m_writeHists {}
unsigned int m_nev
 events processed
unsigned int m_proc
bool m_useTools
unsigned int m_lastNev {}
unsigned int m_intervalInSeconds
time_t m_lastTime {}
bool m_liteLoop
bool m_doChrono = false
ServiceHandle< IChronoStatSvc > m_chronoStatSvc
ServiceHandle< Athena::IConditionsCleanerSvc > m_conditionsCleaner
std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels).
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging).

Detailed Description

Implementation of the AthenaEventLoopMgr that allows selective and specific overrides in python.

The idea is to maximize code-sharing with AthenaEventLoopMgr to reduce maintainance.

Definition at line 34 of file PyAthenaEventLoopMgr.h.

Member Typedef Documentation

◆ EvtContext

typedef IEvtSelector::Context AthenaEventLoopMgr::EvtContext
inherited

Definition at line 64 of file AthenaEventLoopMgr.h.

◆ IConversionSvc_t

typedef ServiceHandle<IConversionSvc> AthenaEventLoopMgr::IConversionSvc_t
protectedinherited

Definition at line 86 of file AthenaEventLoopMgr.h.

◆ IDataManagerSvc_t

typedef ServiceHandle<IDataManagerSvc> AthenaEventLoopMgr::IDataManagerSvc_t
protectedinherited

Definition at line 82 of file AthenaEventLoopMgr.h.

◆ IEvtIdModifierSvc_t

Definition at line 90 of file AthenaEventLoopMgr.h.

◆ IIncidentSvc_t

typedef ServiceHandle<IIncidentSvc> AthenaEventLoopMgr::IIncidentSvc_t
protectedinherited

Definition at line 67 of file AthenaEventLoopMgr.h.

◆ number_type

Definition at line 100 of file AthenaEventLoopMgr.h.

◆ StoreGateSvc_t

Definition at line 71 of file AthenaEventLoopMgr.h.

◆ tool_iterator

typedef tool_store::const_iterator AthenaEventLoopMgr::tool_iterator
protectedinherited

Definition at line 114 of file AthenaEventLoopMgr.h.

◆ tool_stats

typedef std::vector<unsigned int> AthenaEventLoopMgr::tool_stats
protectedinherited

Definition at line 115 of file AthenaEventLoopMgr.h.

◆ tool_stats_iterator

typedef tool_stats::const_iterator AthenaEventLoopMgr::tool_stats_iterator
protectedinherited

Definition at line 116 of file AthenaEventLoopMgr.h.

◆ tool_store

typedef ToolHandleArray< tool_type > AthenaEventLoopMgr::tool_store
protectedinherited

Definition at line 113 of file AthenaEventLoopMgr.h.

◆ tool_type

Definition at line 112 of file AthenaEventLoopMgr.h.

Constructor & Destructor Documentation

◆ PyAthenaEventLoopMgr() [1/3]

PyAthenaEventLoopMgr::PyAthenaEventLoopMgr ( const std::string & name,
ISvcLocator * svcLoc )

Standard Constructor.

overrides the base-class default: for interactive use, it is mandatory to leave the store untouched at the end of the event (so people can interactively browse the store). Hence, we ask for store clean-up at the beginning of the event.

Definition at line 67 of file PyAthenaEventLoopMgr.cxx.

69 : AthenaEventLoopMgr( name, svcLoc ), m_manager( nullptr )
70{
76}
AthenaEventLoopMgr()
no implementation
StringProperty m_clearStorePolicy
virtual const std::string & name() const override

◆ ~PyAthenaEventLoopMgr()

PyAthenaEventLoopMgr::~PyAthenaEventLoopMgr ( )
inline

Definition at line 38 of file PyAthenaEventLoopMgr.h.

38{}

◆ PyAthenaEventLoopMgr() [2/3]

PyAthenaEventLoopMgr::PyAthenaEventLoopMgr ( )
protected

Unimplemented features to keep Reflex happy.

◆ PyAthenaEventLoopMgr() [3/3]

PyAthenaEventLoopMgr::PyAthenaEventLoopMgr ( const PyAthenaEventLoopMgr & )
protected

Member Function Documentation

◆ curEvent()

int AthenaEventLoopMgr::curEvent ( ) const
overridevirtualinherited

Return the current event count.

Definition at line 879 of file AthenaEventLoopMgr.cxx.

880{
881 return m_nevt;
882}

◆ execAtPreFork()

StatusCode AthenaEventLoopMgr::execAtPreFork ( const EventContext & ctx) const
inherited

Execute certain algorithms/sequences in PreFork.

Definition at line 997 of file AthenaEventLoopMgr.cxx.

997 {
998 IAlgManager* algMgr = Gaudi::svcLocator()->as<IAlgManager>();
999
1000 StatusCode sc;
1001 for (const std::string& name : m_execAtPreFork) {
1002 SmartIF<IAlgorithm>& alg = algMgr->algorithm(name, /*createIf*/false);
1003 if ( alg ) {
1004 ATH_MSG_INFO("Executing {}...", alg->name());
1005 sc &= alg->sysExecute(ctx);
1006 }
1007 else ATH_MSG_WARNING("Cannot find algorithm or sequence {}", name);
1008 }
1009 return sc;
1010}
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_INFO(x,...)
static Double_t sc
StringArrayProperty m_execAtPreFork
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ executeAlgorithms()

StatusCode PyAthenaEventLoopMgr::executeAlgorithms ( const EventContext & ctx)
protectedvirtual

Run the algorithms for the current event.

Reimplemented from AthenaEventLoopMgr.

Definition at line 186 of file PyAthenaEventLoopMgr.cxx.

187{
188 RootUtils::PyGILStateEnsure gil;
189// forward to call to the python-side object
190 if ( m_manager != nullptr )
191 {
192 // forward call, if python side manager available
193 PyObject* pycontext = PyCapsule_New ( const_cast<EventContext*>(&ctx), nullptr, nullptr);
194 PyObject* result = PyObject_CallMethod( m_manager, execalgs,
195 (char*)"O", pycontext);
196 Py_DECREF (pycontext);
197
198 if ( ! result )
199 {
200 PyErr_Print(); // should use MessageSvc instead
201 return StatusCode::FAILURE;
202 }
203
204 if ( PyLong_Check( result ) )
205 {
206 StatusCode sc = StatusCode( (int) PyLong_AS_LONG( result ) );
207 Py_DECREF( result );
208 return sc;
209 }
210
211 // FIXME: allow python result to be a statuscode
212 ATH_MSG_ERROR( "result from python event loop manager has unexpected type." );
213 Py_DECREF( result );
214 return StatusCode::FAILURE;
215 }
216
217// otherwise, let base class handle it
219}
#define ATH_MSG_ERROR(x,...)
_object PyObject
virtual StatusCode executeAlgorithms(const EventContext &)
Run the algorithms for the current event.

◆ executeEvent()

StatusCode AthenaEventLoopMgr::executeEvent ( EventContext && ctx)
overridevirtualinherited

implementation of IEventProcessor::executeEvent(EventContext&& ctx)

Fire begin-Run incident if new run:

m_failureMode 1, RECOVERABLE: skip algorithms, but do not terminate job FAILURE: terminate job

m_failureMode 2: skip algorithms, but do not terminate job

Definition at line 542 of file AthenaEventLoopMgr.cxx.

543{
544 //This is a lightweight implementation of the executeEvent, used when e.g. processing TTrees with RootNtupleEventSelector
545 if(m_liteLoop) {
546 m_incidentSvc->fireIncident(Incident("BeginEvent",IncidentType::BeginEvent));
548 m_incidentSvc->fireIncident(Incident("EndEvent",IncidentType::EndEvent));
549 ++m_proc;
550 ++m_nev;
551 return sc;
552 }
553
555
557 if (m_firstRun || (m_currentRun != ctx.eventID().run_number()) ) {
558 // Fire EndRun incident unless this is the first run
559 if (!m_firstRun) {
560 m_incidentSvc->fireIncident(Incident(name(),IncidentType::EndRun));
561 }
562 m_firstRun=false;
563 m_currentRun = ctx.eventID().run_number();
564
565 ATH_MSG_INFO ( " ===>>> start of run {} <<<===", m_currentRun );
566
567 m_incidentSvc->fireIncident(Incident(name(),IncidentType::BeginRun,ctx));
568 }
569
570 bool toolsPassed=true;
571 bool eventFailed = false;
572 // Call any attached tools to reject events early
573 unsigned int toolCtr=0;
574 if(m_useTools) {
575 //note: pEvent cannot be nullptr here, it has already been dereferenced
576 tool_store::iterator theTool = m_tools.begin();
577 tool_store::iterator lastTool = m_tools.end();
578 while(toolsPassed && theTool!=lastTool )
579 {
580 toolsPassed = (*theTool)->passEvent(ctx.eventID());
581 m_toolInvoke[toolCtr]++;
582 {toolsPassed ? m_toolAccept[toolCtr]++ : m_toolReject[toolCtr]++;}
583 ++toolCtr;
584 ++theTool;
585 }
586 }
587
588
589 uint64_t evtNumber = ctx.eventID().event_number();
590 bool doEvtHeartbeat(m_eventPrintoutInterval.value() > 0 &&
591 ( (!m_intervalInSeconds && 0 == (m_nev % m_eventPrintoutInterval.value())) ||
593 if (doEvtHeartbeat) {
594 if(!m_useTools) {
595 ATH_MSG_INFO ( " ===>>> start processing event #{}, run #{} {} events processed so far <<<===",
596 evtNumber, m_currentRun, m_nev);
598 ATH_MSG_INFO(" ===>>> Event processing rate = {} Hz <<<===",
599 double(m_nev-m_lastNev)/(time(nullptr)-m_lastTime));
600 m_lastNev = m_nev; m_lastTime = time(nullptr);
601 }
602 }
603
604 else ATH_MSG_INFO ( " ===>>> start processing event #{}, run #{} {} events read and {} events processed so far <<<===",
605 evtNumber, m_currentRun, m_nev, m_proc);
606 }
607
608 // Reset the timeout singleton
610 if(toolsPassed) {
611 // Fire BeginEvent "Incident"
612 //m_incidentSvc->fireIncident(Incident(*pEvent, name(),"BeginEvent"));
613
614 // An incident may schedule a stop, in which case is better to exit before the actual execution.
615 if ( m_scheduledStop ) {
616 ATH_MSG_ALWAYS ( "A stopRun was requested by an incidentListener. "
617 "Do not process this event." );
618 return (StatusCode::SUCCESS);
619 }
620
621 CHECK( m_conditionsCleaner->event (ctx, false) );
622
623 // Call the execute() method of all top algorithms
625
626 if(!sc.isSuccess()) {
627 eventFailed = true;
628 m_aess->setEventStatus( EventStatus::AlgFail, ctx );
629
633 if (m_failureMode == 1 && sc.isRecoverable() ) {
634 ATH_MSG_WARNING ( "RECOVERABLE error returned by algorithm. "
635 "Skipping remaining algorithms.\n"
636 "\tNo output will be written for this event, "
637 "but job will continue to next event" );
638 eventFailed = false;
639 }
640
642 if (m_failureMode >= 2) {
643 ATH_MSG_INFO ( "Skipping remaining algorithms.\n"
644 "\tNo output will be written for this event, "
645 "but job will continue to next event" );
646 eventFailed = false;
647 }
648
649 } else {
650
651 m_aess->setEventStatus( EventStatus::Success, ctx );
652
653 // Call the execute() method of all output streams
654 for (ListAlg::iterator ito = m_outStreamList.begin();
655 ito != m_outStreamList.end(); ++ito ) {
656 sc = (*ito)->sysExecute(ctx);
657 if( !sc.isSuccess() ) {
658 eventFailed = true;
659 }
660 }
661
662 writeHistograms().ignore();
663
664 }
665
666 // Fire EndEvent "Incident"
667 //m_incidentSvc->fireIncident(Incident(*pEvent, name(),"EndEvent"));
668 ++m_proc;
669 } // end of toolsPassed test
670 ++m_nev;
671 if (doEvtHeartbeat) {
673 if (!m_useTools)
674 ATH_MSG_INFO(" ===>>> done processing event #{}, run #{} {} events processed so far <<<===",
675 evtNumber, m_currentRun, m_nev);
676 else
677 ATH_MSG_INFO(" ===>>> done processing event #{}, run #{} {} events read and {} events processed so far <<<===",
678 evtNumber, m_currentRun, m_nev, m_proc);
679 }
680 std::ofstream outfile( "eventLoopHeartBeat.txt");
681 if ( !outfile ) {
682 ATH_MSG_ERROR ( " unable to open: eventLoopHeartBeat.txt" );
683 } else {
684 std::println (outfile, " done processing event #{}, run #{} {} events read so far <<<===",
685 evtNumber, m_currentRun, m_nev);
686 outfile.close();
687 }
688
689 }
690
691 //------------------------------------------------------------------------
692 // Check if there was an error processing current event
693 //------------------------------------------------------------------------
694 return eventFailed?StatusCode::FAILURE:StatusCode::SUCCESS;
695
696}
#define ATH_MSG_ALWAYS(x,...)
#define CHECK(...)
Evaluate an expression and check for errors.
UnsignedIntegerProperty m_eventPrintoutInterval
IntegerProperty m_failureMode
tool_stats m_toolInvoke
tool called counter
IIncidentSvc_t m_incidentSvc
Reference to the incident service.
unsigned int m_nev
events processed
tool_stats m_toolAccept
tool returns StatusCode::SUCCESS counter
SmartIF< IAlgExecStateSvc > m_aess
Reference to the Algorithm Execution State Svc.
virtual StatusCode writeHistograms(bool force=false)
Dump out histograms as needed.
tool_stats m_toolReject
tool returns StatusCode::FAILURE counter
StatusCode installEventContext(EventContext &ctx)
number_type m_currentRun
current run number
unsigned int m_intervalInSeconds
tool_store m_tools
internal tool store
ServiceHandle< Athena::IConditionsCleanerSvc > m_conditionsCleaner
void resetTimeout(Timeout &instance)
Reset timeout.
Definition Timeout.h:83
static Timeout & instance()
Get reference to Timeout singleton.
Definition Timeout.h:64
time(flags, cells_name, *args, **kw)

◆ executeRun()

StatusCode AthenaEventLoopMgr::executeRun ( int maxevt)
overridevirtualinherited

implementation of IEventProcessor::executeRun(int maxevt)

Definition at line 701 of file AthenaEventLoopMgr.cxx.

702{
703 if (!(this->nextEvent(maxevt)).isSuccess()) return StatusCode::FAILURE;
704 m_incidentSvc->fireIncident(Incident(name(),"EndEvtLoop"));
705 m_incidentSvc->fireIncident(Incident(name(),IncidentType::EndRun));
706
707 return StatusCode::SUCCESS;
708}
virtual StatusCode nextEvent(int maxevt) override
implementation of IAppMgrUI::nextEvent. maxevt==0 returns immediately

◆ finalize()

StatusCode PyAthenaEventLoopMgr::finalize ( )
virtual

implementation of IAppMgrUI::finalize

Reimplemented from AthenaEventLoopMgr.

Definition at line 225 of file PyAthenaEventLoopMgr.cxx.

226{
227 RootUtils::PyGILStateEnsure gil;
228 Py_XDECREF( m_manager );
229
230 return this->AthenaEventLoopMgr::finalize();
231}
virtual StatusCode finalize() override
implementation of IAppMgrUI::finalize

◆ getManager()

PyObject * PyAthenaEventLoopMgr::getManager ( )

Definition at line 124 of file PyAthenaEventLoopMgr.cxx.

125{
126 RootUtils::PyGILStateEnsure gil;
127 if ( ! m_manager )
128 {
129 Py_INCREF( Py_None );
130 return Py_None;
131 }
132
133 Py_INCREF( m_manager );
134 return m_manager;
135}

◆ handle()

void AthenaEventLoopMgr::handle ( const Incident & inc)
overridevirtualinherited

IIncidentListenet interfaces.

Definition at line 916 of file AthenaEventLoopMgr.cxx.

917{
918 if(inc.type()!="BeforeFork")
919 return;
920
921 if(!m_firstRun) {
922 ATH_MSG_WARNING ( "Skipping BeforeFork handler. Begin run has already passed" );
923 return;
924 }
925
926 // Initialize Algorithms and Output Streams
928 if(sc.isFailure()) {
929 ATH_MSG_ERROR ( "Failed to initialize Algorithms" );
930 return;
931 }
932
933 if(!m_evtSelCtxt) {
934 ATH_MSG_WARNING ( "Skipping BeforeFork handler. No event selector is provided" );
935 return;
936 }
937
938 // Construct EventInfo
939 IOpaqueAddress* addr = nullptr;
940 sc = m_evtSelector->next(*m_evtSelCtxt);
941 if(!sc.isSuccess()) {
942 ATH_MSG_INFO ( "No more events in event selection " );
943 return;
944 }
945 sc = m_evtSelector->createAddress(*m_evtSelCtxt, addr);
946 if (sc.isFailure()) {
947 ATH_MSG_ERROR ( "Could not create an IOpaqueAddress" );
948 return;
949 }
950 if (nullptr != addr) {
951 //create its proxy
952 sc = m_eventStore->recordAddress(addr);
953 if(!sc.isSuccess()) {
954 ATH_MSG_ERROR ( "Error declaring Event object" );
955 return;
956 }
957 }
958
959 if(m_eventStore->loadEventProxies().isFailure()) {
960 ATH_MSG_WARNING ( "Error loading Event proxies" );
961 return;
962 }
963
964 // Need to make sure we have a valid EventContext in place before
965 // doing anything that could fire incidents.
966 EventContext ctx;
967 // In the case of the BeginRun incident, we just want to take the
968 // next IoV from the list in the EvtIdModifierSvc, but leave it to
969 // be used for the next executeEvent call. TODO CHECK
970 if( installEventContext(ctx).isFailure() ) {
971 throw std::runtime_error( "Error installing event context object" );
972 }
973
974 m_incidentSvc->fireIncident(Incident(name(),IncidentType::BeginRun,ctx));
975 m_firstRun=false;
976 m_currentRun = ctx.eventID().run_number();
977
978 // Execute requested algorithms/sequences
979 if ( execAtPreFork(ctx).isFailure() ) {
980 ATH_MSG_ERROR ( "Unable to execute requested algorithms/sequences during PreFork!" );
981 return;
982 }
983
984 // Clear Store
985 const ClearStorePolicy::Type s_clearStore = clearStorePolicy( m_clearStorePolicy.value(), msgStream() );
986 if(s_clearStore==ClearStorePolicy::EndEvent) {
987 sc = m_eventStore->clearStore();
988 if(!sc.isSuccess()) {
989 ATH_MSG_ERROR ( "Clear of Event data store failed" );
990 }
991 }
992}
ClearStorePolicy::Type clearStorePolicy(const std::string &policyName, MsgStream &msg)
returns the enum-version of the policy (by name)
IEvtSelector::Context * m_evtSelCtxt
Gaudi EventSelector Context (may be used as a cursor by the evt selector).
StoreGateSvc_t m_eventStore
Reference to StoreGateSvc;.
StatusCode execAtPreFork(const EventContext &ctx) const
Execute certain algorithms/sequences in PreFork.
IEvtSelector * m_evtSelector
Reference to the Event Selector.
StatusCode initializeAlgorithms()
Initialize all algorithms and output streams.

◆ initialize()

StatusCode PyAthenaEventLoopMgr::initialize ( )
virtual

implementation of IAppMgrUI::initalize

Reimplemented from AthenaEventLoopMgr.

Definition at line 141 of file PyAthenaEventLoopMgr.cxx.

142{
143 RootUtils::PyGILStateEnsure gil;
144// get the PyAthenaEventLoopMgr python-side class
145 PyObject* modpyelm = PyImport_ImportModule( const_cast< char* >( "AthenaServices.PyAthenaEventLoopMgr" ) );
146 if ( modpyelm ) {
147
148 PyObject* pyelm = PyObject_GetAttrString( modpyelm, const_cast< char* >( "PyAthenaEventLoopMgr" ) );
149 Py_DECREF( modpyelm );
150
151 if ( pyelm ) {
152 PyObject* args = PyTuple_New( 0 );
153 PyObject* self = PyObject_Call( pyelm, args, nullptr );
154 Py_DECREF( args );
155 Py_DECREF( pyelm );
156
157 if ( self ) {
158 // initialize base class, which then allows queryInterface as appropriate
160
161 // set the interfaces on the python-side manager
162 PyObject* result = setManager( self );
163 Py_DECREF( self );
164
165 if ( ! result ) {
166 PyErr_Print();
167 sc.ignore();
168 return StatusCode::FAILURE;
169 }
170
171 return sc;
172 }
173
174 }
175
176 }
177
178 PyErr_Print();
179 return StatusCode::FAILURE;
180}
virtual StatusCode initialize() override
implementation of IAppMgrUI::initalize
PyObject * setManager(PyObject *)
actual manager object

◆ initializeAlgorithms()

StatusCode AthenaEventLoopMgr::initializeAlgorithms ( )
protectedinherited

Initialize all algorithms and output streams.

Definition at line 482 of file AthenaEventLoopMgr.cxx.

482 {
483
484 // Initialize the list of Algorithms. Note that existing Algorithms
485 // are protected against multiple initialization attempts.
486 ListAlg::iterator ita;
487 for ( ita = m_topAlgList.begin(); ita != m_topAlgList.end(); ++ita )
488 {
489 StatusCode sc = (*ita)->sysInitialize();
490 if( sc.isFailure() )
491 {
492 ATH_MSG_ERROR( "Unable to initialize Algorithm: {}", (*ita)->name()) ;
493 return sc;
494 }
495 }
496
497 // Initialize the list of Output Streams. Note that existing Output Streams
498 // are protected against multiple initialization attempts.
499 for (ita = m_outStreamList.begin(); ita != m_outStreamList.end(); ++ita )
500 {
501 StatusCode sc = (*ita)->sysInitialize();
502 if( sc.isFailure() ) {
503 ATH_MSG_ERROR ( "Unable to initialize Output Stream: {}", (*ita)->name() );
504 return sc;
505 }
506
507 }
508
509 return StatusCode::SUCCESS;
510}

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40{
42 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)
int outputLevel(const IMessageSvc *ims, const std::string &source)

◆ installEventContext()

StatusCode AthenaEventLoopMgr::installEventContext ( EventContext & ctx)
privateinherited

Definition at line 1015 of file AthenaEventLoopMgr.cxx.

1015 {
1016 // first get EventInfo and conditionsRun
1017 std::unique_ptr<EventInfo> eventInfo;
1018 EventID eventID;
1019 unsigned int conditionsRun = EventIDBase::UNDEFNUM;
1020 bool consume_modifier_stream = false; // FIXME/CHECK: was true inside TP converter and checks for active storegate
1021
1022 // Event index for run-dependent EventID modification: m_nevt-1 in serial,
1023 // or the absolute index supplied by the AthenaMP consumer (chunk base +
1024 // in-chunk offset derived from m_nevt without mutating state).
1026 ? static_cast<long>(m_nevt - 1)
1028
1029 if (m_evtSelCtxt) { // Deal with the case when an EventSelector is provided
1030 // First try to build a legacy EventInfo object from the TAG information
1031 // Read the attribute list
1032 const AthenaAttributeList* pAttrList =
1033 m_eventStore->tryConstRetrieve<AthenaAttributeList>("Input");
1034 if (pAttrList != nullptr && pAttrList->size() > 6) {
1035 // Try making EventID-only EventInfo object from in-file TAG
1036 try {
1037 unsigned int runNumber = (*pAttrList)["RunNumber"].data<unsigned int>();
1038 unsigned long long eventNumber = (*pAttrList)["EventNumber"].data<unsigned long long>();
1039 unsigned int eventTime = (*pAttrList)["EventTime"].data<unsigned int>();
1040 unsigned int eventTimeNS = (*pAttrList)["EventTimeNanoSec"].data<unsigned int>();
1041 unsigned int lumiBlock = (*pAttrList)["LumiBlockN"].data<unsigned int>();
1042 unsigned int bunchId = (*pAttrList)["BunchId"].data<unsigned int>();
1043
1044 ATH_MSG_DEBUG("use TAG with runNumber={}", runNumber);
1045 consume_modifier_stream = true;
1046 // an option to override primary eventNumber with the secondary one in
1047 // case of DoubleEventSelector
1049 unsigned long long eventNumberSecondary{};
1050 if (!(pAttrList->exists("hasSecondaryInput") &&
1051 (*pAttrList)["hasSecondaryInput"].data<bool>())) {
1052 ATH_MSG_FATAL("Secondary EventNumber requested, but secondary input does not exist!");
1053 return StatusCode::FAILURE;
1054 }
1055 if (pAttrList->exists("EventNumber_secondary")) {
1056 eventNumberSecondary = (*pAttrList)["EventNumber_secondary"].data<unsigned long long>();
1057 } else {
1058 // try legacy EventInfo if secondary input did not have attribute
1059 // list primary input should not have this EventInfo type
1060 const EventInfo* pEventSecondary = m_eventStore->tryConstRetrieve<EventInfo>();
1061 if (pEventSecondary) {
1062 eventNumberSecondary = pEventSecondary->event_ID()->event_number();
1063 } else {
1064 ATH_MSG_FATAL("Secondary EventNumber requested, but it does not exist!");
1065 return StatusCode::FAILURE;
1066 }
1067 }
1068 if (eventNumberSecondary != 0) {
1069 bool doEvtHeartbeat(m_eventPrintoutInterval.value() > 0 &&
1070 0 == (m_nev % m_eventPrintoutInterval.value()));
1071 if (doEvtHeartbeat) {
1072 ATH_MSG_INFO(" ===>>> using secondary event #{} instead of #{} <<<===",
1073 eventNumberSecondary, eventNumber);
1074 }
1075 eventNumber = eventNumberSecondary;
1076 }
1077 }
1078
1079 eventInfo = std::make_unique<EventInfo>(
1080 std::make_unique<EventID>(runNumber, eventNumber, eventTime,
1081 eventTimeNS, lumiBlock, bunchId),
1082 nullptr);
1083 eventID = *(eventInfo->event_ID());
1084
1085 if (!m_evtIdModSvc.isSet() && pAttrList->exists("ConditionsRun")) {
1086 conditionsRun = (*pAttrList)["ConditionsRun"].data<unsigned int>();
1087 } else {
1088 conditionsRun = runNumber;
1089 }
1090
1091 } catch (...) {
1092 }
1093 /* FIXME: PvG, not currently written
1094 if( pEvent != 0 && pAttrList->size() > 7 ) {
1095 // Try adding EventType information
1096 try {
1097 float eventWeight = (*pAttrList)["EventWeight"].data<float>();
1098 const EventType* pType = new EventType(); pEvent->setEventType(pType);
1099 pEvent->event_type()->set_mc_event_weight(eventWeight);
1100 } catch (...) {
1101 pEvent->setEventType(0);
1102 }
1103 }
1104 */
1105 } else if (m_requireInputAttributeList) {
1106 ATH_MSG_FATAL("Valid input attribute list required but not present!");
1107 return StatusCode::FAILURE;
1108 }
1109 // In the case that there is no TAG information
1110 if( !eventInfo ) {
1111 // Secondly try to retrieve a legacy EventInfo object from the input file
1113 const EventInfo* pei = m_eventStore->tryConstRetrieve<EventInfo>();
1114 if( pei ) {
1115 eventID = *(pei->event_ID());
1116 } else {
1117 // Finally try to retrieve an xAOD::EventInfo object from the
1118 // input file and build a legacy EventInfo object from that.
1119 const xAOD::EventInfo* xAODEvent = m_eventStore->tryConstRetrieve<xAOD::EventInfo>();
1120 if (xAODEvent == nullptr) {
1121 ATH_MSG_ERROR("Failed to get EventID from input. Tried old-style and xAOD::EventInfo");
1122 return StatusCode::FAILURE;
1123 }
1124 ATH_MSG_DEBUG("use xAOD::EventInfo with runNumber={}", xAODEvent->runNumber());
1125 // Record the old-style object for those clients that still need it
1126 eventInfo = std::make_unique<EventInfo>(
1127 std::make_unique<EventID>(eventIDFromxAOD(xAODEvent)),
1128 std::make_unique<EventType>(eventTypeFromxAOD(xAODEvent)));
1129 eventID = *(eventInfo->event_ID());
1130 StatusCode sc = m_eventStore->record(std::move(eventInfo), "");
1131 if (!sc.isSuccess()) {
1132 ATH_MSG_ERROR("Error declaring event data object");
1133 return StatusCode::FAILURE;
1134 }
1135 }
1136 }
1137 } else {
1138 // No EventSelector is provided, so with no iterator it's up to us
1139 // to create an EventInfo
1140 eventInfo = std::make_unique<EventInfo>(
1141 std::make_unique<EventID>(1, m_nevt, 0), std::make_unique<EventType>());
1142 eventInfo->event_ID()->set_lumi_block(m_nevt);
1143 eventID = *(eventInfo->event_ID());
1144 StatusCode sc = m_eventStore->record(std::move(eventInfo), "");
1145 if (!sc.isSuccess()) {
1146 ATH_MSG_ERROR("Error declaring event data object");
1147 return (StatusCode::FAILURE);
1148 }
1149 }
1150
1151 ctx.setEventID( eventID );
1152 ctx.set(m_nev,0);
1154 Atlas::ExtendedEventContext( m_eventStore->hiveProxyDict(),
1155 conditionsRun) );
1156 modifyEventContext(ctx, eventID, consume_modifier_stream);
1157 Gaudi::Hive::setCurrentContext( ctx );
1158
1159 m_aess->reset( ctx );
1160 if (m_eventStore->record(std::make_unique<EventContext> ( ctx ),
1161 "EventContext").isFailure())
1162 {
1163 ATH_MSG_ERROR ( "Error recording event context object" );
1164 return (StatusCode::FAILURE);
1165 }
1166
1167 return StatusCode::SUCCESS;
1168}
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_FATAL(x,...)
EventID eventIDFromxAOD(const xAOD::EventInfo *xaod)
Create EventID object from xAOD::EventInfo.
EventType eventTypeFromxAOD(const xAOD::EventInfo *xaod)
Create EventType object from xAOD::EventInfo.
EventInfo
bool m_useSecondaryEventNumber
read event number from secondary input
bool m_requireInputAttributeList
require input attribute list
IEvtIdModifierSvc_t m_evtIdModSvc
virtual void modifyEventContext(EventContext &ctx, const EventID &eID, bool consume_modifier_stream)
EventID * event_ID()
the unique identification of the event.
uint32_t runNumber() const
The current event's run number.
void setExtendedEventContext(EventContext &ctx, ExtendedEventContext &&ectx)
Move an extended context into a context object.
event_number_t eventIndex
EventInfo_v1 EventInfo
Definition of the latest event info version.
setTeId lumiBlock

◆ modifyEventContext()

void AthenaEventLoopMgr::modifyEventContext ( EventContext & ctx,
const EventID & eID,
bool consume_modifier_stream )
virtualinherited

Definition at line 1172 of file AthenaEventLoopMgr.cxx.

1172 {
1173 if (m_evtIdModSvc.isSet()) {
1174 EventID new_eID(eID);
1175 m_evtIdModSvc->modify_evtid(new_eID, m_curEvtModIdx, consume_modifier_stream);
1176 if (msgLevel(MSG::DEBUG)) {
1177 unsigned int oldrunnr=eID.run_number();
1178 unsigned int oldLB=eID.lumi_block();
1179 unsigned int oldTS=eID.time_stamp();
1180 unsigned int oldTSno=eID.time_stamp_ns_offset();
1181 ATH_MSG_DEBUG ( "modifyEventContext: use evtIdModSvc runnr={} -> {}",
1182 oldrunnr, new_eID.run_number());
1183 ATH_MSG_DEBUG ( "modifyEventContext: use evtIdModSvc LB={} -> {}",
1184 oldLB, new_eID.lumi_block());
1185 ATH_MSG_DEBUG ( "modifyEventContext: use evtIdModSvc TimeStamp={} -> {}",
1186 oldTS, new_eID.time_stamp());
1187 ATH_MSG_DEBUG ( "modifyEventContext: use evtIdModSvc TimeStamp ns Offset={} -> {}",
1188 oldTSno, new_eID.time_stamp_ns_offset());
1189 }
1190 ctx.setEventID( new_eID );
1191 Atlas::getExtendedEventContext(ctx).setConditionsRun( ctx.eventID().run_number() );
1192 return;
1193 }
1194
1195 ctx.setEventID( eID );
1196}
void setConditionsRun(EventIDBase::number_type conditionsRun)
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 92 of file AthMessaging.h.

168{
169 MsgStream* ms = m_msg_tls.get();
170 if (!ms) {
171 if (!m_initialized.test_and_set()) initMessaging();
172 ms = new MsgStream(m_imsg,m_nm);
173 m_msg_tls.reset( ms );
174 }
175
176 ms->setLevel (m_lvl);
177 return *ms;
178}
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels).
void initMessaging() const
Initialize our message level and MessageSvc.

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 99 of file AthMessaging.h.

183{ return msg() << lvl; }
MsgStream & msg() const
The standard message stream.

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 86 of file AthMessaging.h.

152{
153 // If user did not set explicit message level we have to initialize
154 // the messaging and retrieve the default via the MessageSvc.
155 if (m_lvl==MSG::NIL && !m_initialized.test_and_set()) initMessaging();
156
157 if (m_lvl <= lvl) {
158 msg() << lvl;
159 return true;
160 } else {
161 return false;
162 }
163}

◆ name()

virtual const std::string & AthenaEventLoopMgr::name ( ) const
inlineoverridevirtualinherited

Definition at line 188 of file AthenaEventLoopMgr.h.

188{ return Service::name(); } //FIXME

◆ nextEvent()

StatusCode AthenaEventLoopMgr::nextEvent ( int maxevt)
overridevirtualinherited

implementation of IAppMgrUI::nextEvent. maxevt==0 returns immediately

Reimplemented in MultipleEventLoopMgr.

Definition at line 713 of file AthenaEventLoopMgr.cxx.

714{
715 // make nextEvent(0) a dummy call
716 if (0 == maxevt) return StatusCode::SUCCESS;
717
718 static std::atomic<int> total_nevt = 0;
719
720 // the current 'clear-store' policy
721 static const ClearStorePolicy::Type s_clearStore =
722 clearStorePolicy( m_clearStorePolicy.value(), msgStream() );
723
724
725 // These following two initialization loops are performed here in case new
726 // Top level Algorithms or Output Streams have been created interactively
727 // at run-time instead of configuration time. Note also that it is possible
728 // that some newly created Algorithms are still not initialized as a result
729 // of these loops (e.g. where the membership of an existing Sequencer is
730 // changed at run-time. In this case, the Algorithm::sysExecute() function
731 // will ensure that the Algorithm is correctly initialized. This mechanism
732 // actually makes loops redundant, but they do provide a well defined
733 // location for the initialization to take place in the non-interactive case.
734
736 if(sc.isFailure())
737 return sc;
738
739 // loop over events if the maxevt (received as input) is different from -1.
740 // if evtmax is -1 it means infinite loop
741
742 while(maxevt == -1 || m_nevt < maxevt) {
743
744 if(m_doChrono && total_nevt>0) m_chronoStatSvc->chronoStart("EventLoopMgr"); //start after first event
745 if(m_doChrono && total_nevt>0) m_chronoStatSvc->chronoStart("EventLoopMgr_preexec");
746
747 // Check if there is a scheduled stop issued by some algorithm/sevice
748 if ( m_scheduledStop ) {
749 m_scheduledStop = false;
750 ATH_MSG_ALWAYS ( "A stopRun was requested. Terminating event loop." );
751 break;
752 }
753
754
755
756 ++m_nevt; ++total_nevt;
757 //-----------------------------------------------------------------------
758 // Clear the event store, if used in the event loop
759 //-----------------------------------------------------------------------
760 if( s_clearStore == ClearStorePolicy::BeginEvent &&
761 0 != total_nevt ) {
762 sc = m_eventStore->clearStore();
763 if( !sc.isSuccess() ) {
764 ATH_MSG_ERROR ( "Clear of Event data store failed" );
765 m_incidentSvc->fireIncident(Incident(name(),"EndEvtLoop"));
766 return sc;
767 }
768 }
769
770
771
772 //-----------------------------------------------------------------------
773 // we need an EventInfo Object to fire the incidents.
774 //-----------------------------------------------------------------------
775 if ( m_evtSelCtxt )
776 { // Deal with the case when an EventSelector is provided
777
778 IOpaqueAddress* addr = nullptr;
779
780 sc = m_evtSelector->next(*m_evtSelCtxt);
781
782 if ( !sc.isSuccess() )
783 {
784 // This is the end of the loop. No more events in the selection
785 ATH_MSG_INFO ( "No more events in event selection " );
786 sc = StatusCode::SUCCESS;
787 break;
788 }
789
790 if (m_evtSelector->createAddress(*m_evtSelCtxt, addr).isFailure()) {
791 ATH_MSG_ERROR ( "Could not create an IOpaqueAddress" );
792 break;
793 }
794
795
796 // Most iterators provide the IOA of an event header (EventInfo, DataHeader)
797 if (nullptr != addr) {
798 //create its proxy
799 sc = m_eventStore->recordAddress(addr);
800 if( !sc.isSuccess() ) {
801 ATH_MSG_WARNING ( "Error declaring Event object" );
802 continue;
803 }
804 }
805 if ((sc=m_eventStore->loadEventProxies()).isFailure()) {
806 ATH_MSG_ERROR ( "Error loading Event proxies" );
807 continue;
808 }
809 }
810 if(m_doChrono && total_nevt>1) m_chronoStatSvc->chronoStop("EventLoopMgr_preexec");
811 if(m_doChrono && total_nevt>1) m_chronoStatSvc->chronoStart("EventLoopMgr_execute");
812 // create an empty EventContext that will get set inside executeEvent
813 EventContext ctx;
814 // Execute event for all required algorithms
815 sc = executeEvent( std::move( ctx ) );
816 if(m_doChrono && total_nevt>1) m_chronoStatSvc->chronoStop("EventLoopMgr_execute");
817 if(m_doChrono && total_nevt>1) m_chronoStatSvc->chronoStart("EventLoopMgr_postexec");
818 if( !sc.isSuccess() )
819 {
820 ATH_MSG_ERROR ( "Terminating event processing loop due to errors" );
821 break;
822 }
823
824 //-----------------------------------------------------------------------
825 // Clear the event store, if used in the event loop
826 //-----------------------------------------------------------------------
827 if ( s_clearStore == ClearStorePolicy::EndEvent ) {
828 sc = m_eventStore->clearStore();
829 if( !sc.isSuccess() ) {
830 ATH_MSG_ERROR ( "Clear of Event data store failed" );
831 break;
832 }
833 }
834 if(m_doChrono && total_nevt>1) m_chronoStatSvc->chronoStop("EventLoopMgr_postexec");
835 if(m_doChrono && total_nevt>1) m_chronoStatSvc->chronoStop("EventLoopMgr");
836 } //event loop
837
838
839
840 return sc;
841
842}
virtual StatusCode executeEvent(EventContext &&ctx) override
implementation of IEventProcessor::executeEvent(EventContext&& ctx)
ServiceHandle< IChronoStatSvc > m_chronoStatSvc

◆ operator=()

PyAthenaEventLoopMgr & PyAthenaEventLoopMgr::operator= ( const PyAthenaEventLoopMgr & )
protected

◆ pointer()

PyAthenaEventLoopMgr * PyAthenaEventLoopMgr::pointer ( )
static

outside access

Definition at line 52 of file PyAthenaEventLoopMgr.cxx.

52 {
53
54 SmartIF<IEventProcessor> ep{Gaudi::svcLocator()->service( "PyAthenaEventLoopMgr", /*createIf*/false )};
55 if ( ep ) {
56 ep->addRef();
57 return dynamic_cast< PyAthenaEventLoopMgr* >( ep.get() );
58 }
59
60 return nullptr;
61}
PyAthenaEventLoopMgr(const std::string &name, ISvcLocator *svcLoc)
Standard Constructor.

◆ resetTimeout()

void Athena::TimeoutMaster::resetTimeout ( Timeout & instance)
inlineprotectedinherited

Reset timeout.

Definition at line 83 of file Timeout.h.

83{ instance.reset(); }
std::map< std::string, double > instance

◆ seek()

StatusCode AthenaEventLoopMgr::seek ( int evt)
overridevirtualinherited

Seek to a given event.

Definition at line 849 of file AthenaEventLoopMgr.cxx.

850{
851 IEvtSelectorSeek* is = dynamic_cast<IEvtSelectorSeek*> (m_evtSelector);
852 if (is == nullptr) {
853 ATH_MSG_ERROR ( "Seek failed; unsupported by event selector" );
854 return StatusCode::FAILURE;
855 }
856 //cppcheck-suppress nullPointerRedundantCheck
857 if (!m_evtSelCtxt) {
858 if (m_evtSelector->createContext(m_evtSelCtxt).isFailure()) {
859 ATH_MSG_FATAL ( "Can not create the event selector Context." );
860 return StatusCode::FAILURE;
861 }
862 }
863 //m_evtSelCtxt cannot be null if createContext succeeded
864 //cppcheck-suppress nullPointerRedundantCheck
865 StatusCode sc = is->seek (*m_evtSelCtxt, evt);
866 if (sc.isSuccess()) {
867 m_nevt = evt;
868 }
869 else {
870 ATH_MSG_ERROR ( "Seek failed." );
871 }
872 return sc;
873}
virtual StatusCode seek(IEvtSelector::Context &c, int evtnum) const =0
Seek to a given event number.

◆ setClearStorePolicy()

void AthenaEventLoopMgr::setClearStorePolicy ( Gaudi::Details::PropertyBase & clearStorePolicy)
protectedinherited

property update handler:set the clear-store policy value and check its value.

Definition at line 314 of file AthenaEventLoopMgr.cxx.

314 {
315 const std::string& policyName = m_clearStorePolicy.value();
316
317 if ( policyName != "BeginEvent" &&
318 policyName != "EndEvent" ) {
319
320 ATH_MSG_FATAL ( "Unknown policy [{}] for the 'ClearStore-policy !\n"
321 "Valid values are: BeginEvent, EndEvent",
322 policyName
323 );
324 throw GaudiException("Can not setup 'ClearStore'-policy",
325 name(),
326 StatusCode::FAILURE);
327 }
328
329 return;
330}

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29{
30 m_lvl = lvl;
31}

◆ setManager()

PyObject * PyAthenaEventLoopMgr::setManager ( PyObject * mgr)

actual manager object

Definition at line 82 of file PyAthenaEventLoopMgr.cxx.

83{
84 RootUtils::PyGILStateEnsure gil;
85 if ( ! PyObject_HasAttrString( mgr, execalgs ) )
86 {
87 PyErr_SetString( PyExc_TypeError, "given object is not a manager" );
88 return nullptr;
89 }
90
91// set on ourselves
93 Py_INCREF( mgr );
94 m_manager = mgr;
95
96// set onto the module as a module global (this may replace the old one, so
97// users are best served to only access this through the module)
98 PyObject* pyelm = PyImport_AddModule( const_cast< char* >( "AthenaServices.PyAthenaEventLoopMgr" ) );
99 if ( pyelm ) {
100 Py_INCREF( mgr );
101 if (PyModule_AddObject( pyelm, const_cast< char* >( "EventLoopMgr" ), mgr ) < 0) {
102 Py_DECREF( mgr );
103 }
104 }
105
106// hand the python side its interfaces
107 PyObject* pyself = PyCapsule_New( (void*)static_cast< IEventSeek* >( this ), nullptr, nullptr );
108 PyObject* method = PyUnicode_FromString( "_installServices" );
109 PyObject* result = PyObject_CallMethodObjArgs( mgr, method, pyself, 0 );
110 Py_DECREF( method );
111 Py_DECREF( pyself );
112
113 if ( ! result )
114 return nullptr;
115
116// return old value (with its refcount), if set previously; or None
117 if ( old != nullptr )
118 return old;
119
120 Py_INCREF( Py_None );
121 return Py_None;
122}

◆ setNextEventModifierIndex()

void AthenaEventLoopMgr::setNextEventModifierIndex ( long idx)
overridevirtualinherited

Supply absolute input event index for EvtIdModifierSvc. See IEventSeek.h.

Definition at line 885 of file AthenaEventLoopMgr.cxx.

◆ setTimeout()

void Athena::TimeoutMaster::setTimeout ( Timeout & instance)
inlineprotectedinherited

Set timeout.

Definition at line 80 of file Timeout.h.

80{ instance.set(); }

◆ setupPreSelectTools()

void AthenaEventLoopMgr::setupPreSelectTools ( Gaudi::Details::PropertyBase & )
protectedinherited

property update handler:sets up the Pre-selection tools

Definition at line 333 of file AthenaEventLoopMgr.cxx.

333 {
334
335 m_toolInvoke.clear();
336 m_toolReject.clear();
337 m_toolAccept.clear();
338
339 m_tools.retrieve().ignore();
340 if(m_tools.size() > 0) {
341 m_useTools=true;
342 m_toolInvoke.resize(m_tools.size());
343 m_toolReject.resize(m_tools.size());
344 m_toolAccept.resize(m_tools.size());
345
346 tool_iterator firstTool = m_tools.begin();
347 tool_iterator lastTool = m_tools.end();
348 unsigned int toolCtr = 0;
349 for ( ; firstTool != lastTool; ++firstTool )
350 {
351 // reset statistics
352 m_toolInvoke[toolCtr] = 0;
353 m_toolReject[toolCtr] = 0;
354 m_toolAccept[toolCtr] = 0;
355 toolCtr++;
356 }
357 }
358
359 return;
360
361}
tool_store::const_iterator tool_iterator

◆ size()

int AthenaEventLoopMgr::size ( )
overridevirtualinherited

Return the size of the collection.

Definition at line 894 of file AthenaEventLoopMgr.cxx.

895{
896 IEvtSelectorSeek* cs = dynamic_cast<IEvtSelectorSeek*> (m_evtSelector);
897 if (cs == nullptr) {
898 ATH_MSG_ERROR ( "Collection size unsupported by event selector" );
899 return -1;
900 }
901 //cppcheck-suppress nullPointerRedundantCheck
902 if (!m_evtSelCtxt) {
903 if (m_evtSelector->createContext(m_evtSelCtxt).isFailure()) {
904 ATH_MSG_FATAL ( "Can not create the event selector Context." );
905 return -1;
906 }
907 }
908 //m_evtSelCtxt cannot be null if createContext succeeded
909 //cppcheck-suppress nullPointerRedundantCheck
910 return cs->size (*m_evtSelCtxt);
911}
virtual int size(IEvtSelector::Context &c) const =0
Return the size of the collection, or -1 if we can't get the size.

◆ stopRun()

StatusCode AthenaEventLoopMgr::stopRun ( )
overridevirtualinherited

Called from ApplicationMgr::stopRun() to terminate the loop.

Definition at line 366 of file AthenaEventLoopMgr.cxx.

367{
368 ATH_MSG_DEBUG("In stopRun()");
369 CHECK( MinimalEventLoopMgr::stopRun() );
370 // change the appMgr return code to ScheduledStop so no errors are reported
371 auto appProp = m_appMgrUI.as<IProperty>();
372 CHECK( Gaudi::setAppReturnCode( appProp, Gaudi::ReturnCode::ScheduledStop, true ) );
373 return StatusCode::SUCCESS;
374}

◆ writeHistograms()

StatusCode AthenaEventLoopMgr::writeHistograms ( bool force = false)
protectedvirtualinherited

Dump out histograms as needed.

Definition at line 426 of file AthenaEventLoopMgr.cxx.

426 {
427
428 StatusCode sc (StatusCode::SUCCESS);
429
430 if ( 0 != m_histoPersSvc && m_writeHists ) {
431 std::vector<DataObject*> objects;
432 sc = m_histoDataMgrSvc->traverseTree( [&objects]( IRegistry* reg, int ) {
433 DataObject* obj = reg->object();
434 if ( !obj || obj->clID() == CLID_StatisticsFile ) return false;
435 objects.push_back( obj );
436 return true;
437 } );
438
439 if ( !sc.isSuccess() ) {
440 ATH_MSG_ERROR ( "Error while traversing Histogram data store" );
441 return sc;
442 }
443
444 if ( objects.size() > 0) {
445 int writeInterval(m_writeInterval.value());
446
447 if ( m_nevt == 1 || force ||
448 (writeInterval != 0 && m_nevt%writeInterval == 0) ) {
449
450 // skip /stat entry!
451 sc = std::accumulate( begin( objects ), end( objects ), sc, [&]( StatusCode isc, auto& i ) {
452 IOpaqueAddress* pAddr = nullptr;
453 StatusCode iret = m_histoPersSvc->createRep( i, pAddr );
454 if ( iret.isFailure() ) return iret;
455 i->registry()->setAddress( pAddr );
456 return isc;
457 } );
458 sc = std::accumulate( begin( objects ), end( objects ), sc, [&]( StatusCode isc, auto& i ) {
459 IRegistry* reg = i->registry();
460 StatusCode iret = m_histoPersSvc->fillRepRefs( reg->address(), i );
461 return iret.isFailure() ? iret : isc;
462 } );
463 if ( ! sc.isSuccess() ) {
464 ATH_MSG_ERROR ( "Error while saving Histograms." );
465 }
466 }
467
468 if (force || (writeInterval != 0 && m_nevt%writeInterval == 0) ) {
469 ATH_MSG_DEBUG ( "committing Histograms" );
470 m_histoPersSvc->conversionSvc()->commitOutput("",true).ignore();
471 }
472 }
473
474 }
475
476 return sc;
477}
IConversionSvc_t m_histoPersSvc
IntegerProperty m_writeInterval
IDataManagerSvc_t m_histoDataMgrSvc
Reference to the Histogram Data Service.

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging).

Definition at line 141 of file AthMessaging.h.

◆ m_aess

SmartIF<IAlgExecStateSvc> AthenaEventLoopMgr::m_aess
protectedinherited

Reference to the Algorithm Execution State Svc.

Definition at line 152 of file AthenaEventLoopMgr.h.

◆ m_chronoStatSvc

ServiceHandle<IChronoStatSvc> AthenaEventLoopMgr::m_chronoStatSvc
privateinherited

Definition at line 222 of file AthenaEventLoopMgr.h.

◆ m_clearStorePolicy

StringProperty AthenaEventLoopMgr::m_clearStorePolicy
protectedinherited

Definition at line 135 of file AthenaEventLoopMgr.h.

◆ m_conditionsCleaner

ServiceHandle<Athena::IConditionsCleanerSvc> AthenaEventLoopMgr::m_conditionsCleaner
privateinherited

Definition at line 223 of file AthenaEventLoopMgr.h.

◆ m_curEvtModIdx

long AthenaEventLoopMgr::m_curEvtModIdx {-1}
privateinherited

Definition at line 206 of file AthenaEventLoopMgr.h.

206{-1};

◆ m_currentRun

number_type AthenaEventLoopMgr::m_currentRun
protectedinherited

current run number

Definition at line 102 of file AthenaEventLoopMgr.h.

◆ m_doChrono

bool AthenaEventLoopMgr::m_doChrono = false
privateinherited

Definition at line 221 of file AthenaEventLoopMgr.h.

◆ m_eventPrintoutInterval

UnsignedIntegerProperty AthenaEventLoopMgr::m_eventPrintoutInterval
protectedinherited

Definition at line 109 of file AthenaEventLoopMgr.h.

◆ m_eventStore

StoreGateSvc_t AthenaEventLoopMgr::m_eventStore
protectedinherited

Reference to StoreGateSvc;.

Property

Definition at line 73 of file AthenaEventLoopMgr.h.

◆ m_evtIdModSvc

IEvtIdModifierSvc_t AthenaEventLoopMgr::m_evtIdModSvc
protectedinherited

Definition at line 92 of file AthenaEventLoopMgr.h.

◆ m_evtModBaseNevt

int AthenaEventLoopMgr::m_evtModBaseNevt {0}
privateinherited

Definition at line 205 of file AthenaEventLoopMgr.h.

205{0};

◆ m_evtModIdxBase

long AthenaEventLoopMgr::m_evtModIdxBase {-1}
privateinherited

Definition at line 204 of file AthenaEventLoopMgr.h.

204{-1};

◆ m_evtsel

StringProperty AthenaEventLoopMgr::m_evtsel
protectedinherited

Definition at line 80 of file AthenaEventLoopMgr.h.

◆ m_evtSelCtxt

IEvtSelector::Context* AthenaEventLoopMgr::m_evtSelCtxt
protectedinherited

Gaudi EventSelector Context (may be used as a cursor by the evt selector).

Definition at line 78 of file AthenaEventLoopMgr.h.

◆ m_evtSelector

IEvtSelector* AthenaEventLoopMgr::m_evtSelector
protectedinherited

Reference to the Event Selector.

Definition at line 76 of file AthenaEventLoopMgr.h.

◆ m_execAtPreFork

StringArrayProperty AthenaEventLoopMgr::m_execAtPreFork
protectedinherited

Definition at line 95 of file AthenaEventLoopMgr.h.

◆ m_failureMode

IntegerProperty AthenaEventLoopMgr::m_failureMode
protectedinherited

Definition at line 106 of file AthenaEventLoopMgr.h.

◆ m_firstRun

bool AthenaEventLoopMgr::m_firstRun
protectedinherited

Definition at line 103 of file AthenaEventLoopMgr.h.

◆ m_histoDataMgrSvc

IDataManagerSvc_t AthenaEventLoopMgr::m_histoDataMgrSvc
protectedinherited

Reference to the Histogram Data Service.

Definition at line 84 of file AthenaEventLoopMgr.h.

◆ m_histoPersSvc

IConversionSvc_t AthenaEventLoopMgr::m_histoPersSvc
protectedinherited

Definition at line 88 of file AthenaEventLoopMgr.h.

◆ m_histPersName

StringProperty AthenaEventLoopMgr::m_histPersName
protectedinherited

Definition at line 98 of file AthenaEventLoopMgr.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_incidentSvc

IIncidentSvc_t AthenaEventLoopMgr::m_incidentSvc
protectedinherited

Reference to the incident service.

Definition at line 69 of file AthenaEventLoopMgr.h.

◆ m_intervalInSeconds

unsigned int AthenaEventLoopMgr::m_intervalInSeconds
privateinherited

Definition at line 217 of file AthenaEventLoopMgr.h.

◆ m_lastNev

unsigned int AthenaEventLoopMgr::m_lastNev {}
privateinherited

Definition at line 216 of file AthenaEventLoopMgr.h.

216{};

◆ m_lastTime

time_t AthenaEventLoopMgr::m_lastTime {}
privateinherited

Definition at line 218 of file AthenaEventLoopMgr.h.

218{};

◆ m_liteLoop

bool AthenaEventLoopMgr::m_liteLoop
privateinherited

Definition at line 220 of file AthenaEventLoopMgr.h.

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ m_manager

PyObject* PyAthenaEventLoopMgr::m_manager
private

Definition at line 60 of file PyAthenaEventLoopMgr.h.

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels).

Definition at line 132 of file AthMessaging.h.

◆ m_nev

unsigned int AthenaEventLoopMgr::m_nev
privateinherited

events processed

Definition at line 212 of file AthenaEventLoopMgr.h.

◆ m_nevt

int AthenaEventLoopMgr::m_nevt {}
privateinherited

Definition at line 199 of file AthenaEventLoopMgr.h.

199{};

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_proc

unsigned int AthenaEventLoopMgr::m_proc
privateinherited

Definition at line 213 of file AthenaEventLoopMgr.h.

◆ m_requireInputAttributeList

bool AthenaEventLoopMgr::m_requireInputAttributeList {}
protectedinherited

require input attribute list

Definition at line 124 of file AthenaEventLoopMgr.h.

124{};

◆ m_toolAccept

tool_stats AthenaEventLoopMgr::m_toolAccept
protectedinherited

tool returns StatusCode::SUCCESS counter

Definition at line 120 of file AthenaEventLoopMgr.h.

◆ m_toolInvoke

tool_stats AthenaEventLoopMgr::m_toolInvoke
protectedinherited

tool called counter

Definition at line 118 of file AthenaEventLoopMgr.h.

◆ m_toolReject

tool_stats AthenaEventLoopMgr::m_toolReject
protectedinherited

tool returns StatusCode::FAILURE counter

Definition at line 119 of file AthenaEventLoopMgr.h.

◆ m_tools

tool_store AthenaEventLoopMgr::m_tools
protectedinherited

internal tool store

Definition at line 121 of file AthenaEventLoopMgr.h.

◆ m_useSecondaryEventNumber

bool AthenaEventLoopMgr::m_useSecondaryEventNumber {}
protectedinherited

read event number from secondary input

Definition at line 127 of file AthenaEventLoopMgr.h.

127{};

◆ m_useTools

bool AthenaEventLoopMgr::m_useTools
privateinherited

Definition at line 214 of file AthenaEventLoopMgr.h.

◆ m_writeHists

bool AthenaEventLoopMgr::m_writeHists {}
privateinherited

Definition at line 209 of file AthenaEventLoopMgr.h.

209{};

◆ m_writeInterval

IntegerProperty AthenaEventLoopMgr::m_writeInterval
privateinherited

Definition at line 208 of file AthenaEventLoopMgr.h.


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