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

The default ATLAS batch event loop manager. More...

#include <AthenaEventLoopMgr.h>

Inheritance diagram for AthenaEventLoopMgr:

Public Types

typedef IEvtSelector::Context EvtContext

Public Member Functions

 AthenaEventLoopMgr (const std::string &nam, ISvcLocator *svcLoc)
 Standard Constructor.
virtual ~AthenaEventLoopMgr ()
 Standard Destructor.
virtual StatusCode initialize () override
 implementation of IAppMgrUI::initalize
virtual StatusCode finalize () override
 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.

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

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.
virtual StatusCode executeAlgorithms (const EventContext &)
 Run the algorithms for the current event.
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

 AthenaEventLoopMgr ()
 no implementation
 AthenaEventLoopMgr (const AthenaEventLoopMgr &)
 no implementation
AthenaEventLoopMgr & operator= (const AthenaEventLoopMgr &)
 no implementation
StatusCode installEventContext (EventContext &ctx)
void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

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

The default ATLAS batch event loop manager.

It loops over input events according to job configuration. Among the main user-settable properties "FailureMode" controls behaviour of event loop depending on return code of Algorithms.

  • 0: all non-SUCCESSes terminate job.
  • 1: (DEFAULT) RECOVERABLE skips to next event, FAILURE terminates job.
  • 2: RECOVERABLE and FAILURE skip to next events

Definition at line 58 of file AthenaEventLoopMgr.h.

Member Typedef Documentation

◆ EvtContext

typedef IEvtSelector::Context AthenaEventLoopMgr::EvtContext

Definition at line 64 of file AthenaEventLoopMgr.h.

◆ IConversionSvc_t

typedef ServiceHandle<IConversionSvc> AthenaEventLoopMgr::IConversionSvc_t
protected

Definition at line 86 of file AthenaEventLoopMgr.h.

◆ IDataManagerSvc_t

typedef ServiceHandle<IDataManagerSvc> AthenaEventLoopMgr::IDataManagerSvc_t
protected

Definition at line 82 of file AthenaEventLoopMgr.h.

◆ IEvtIdModifierSvc_t

◆ IIncidentSvc_t

typedef ServiceHandle<IIncidentSvc> AthenaEventLoopMgr::IIncidentSvc_t
protected

Definition at line 67 of file AthenaEventLoopMgr.h.

◆ number_type

Definition at line 100 of file AthenaEventLoopMgr.h.

◆ StoreGateSvc_t

◆ tool_iterator

typedef tool_store::const_iterator AthenaEventLoopMgr::tool_iterator
protected

Definition at line 114 of file AthenaEventLoopMgr.h.

◆ tool_stats

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

Definition at line 115 of file AthenaEventLoopMgr.h.

◆ tool_stats_iterator

typedef tool_stats::const_iterator AthenaEventLoopMgr::tool_stats_iterator
protected

Definition at line 116 of file AthenaEventLoopMgr.h.

◆ tool_store

typedef ToolHandleArray< tool_type > AthenaEventLoopMgr::tool_store
protected

Definition at line 113 of file AthenaEventLoopMgr.h.

◆ tool_type

Constructor & Destructor Documentation

◆ AthenaEventLoopMgr() [1/3]

AthenaEventLoopMgr::AthenaEventLoopMgr ( const std::string & nam,
ISvcLocator * svcLoc )

Standard Constructor.

Definition at line 58 of file AthenaEventLoopMgr.cxx.

60 : base_class(nam, svcLoc),
61 AthMessaging (nam),
62 m_incidentSvc ( "IncidentSvc", nam ),
63 m_eventStore( "StoreGateSvc", nam ),
64 m_evtSelector(nullptr), m_evtSelCtxt(nullptr),
65 m_histoDataMgrSvc( "HistogramDataSvc", nam ),
66 m_histoPersSvc ( "HistogramPersistencySvc", nam ),
67 m_evtIdModSvc ( "", nam ),
69 m_currentRun(0), m_firstRun(true), m_tools(this),
70 m_nevt(0), m_writeHists(false),
71 m_nev(0), m_proc(0), m_useTools(false),
72 m_chronoStatSvc( "ChronoStatSvc", nam ),
73 m_conditionsCleaner( "Athena::ConditionsCleanerSvc", nam )
74{
75 declareProperty("EvtStore", m_eventStore, "The StoreGateSvc instance to interact with for event payload" );
76 declareProperty("EvtSel", m_evtsel,
77 "Name of Event Selector to use. If empty string (default) "
78 "take value from ApplicationMgr");
79 declareProperty("HistogramPersistency", m_histPersName="",
80 "Histogram persistency technology to use: ROOT, HBOOK, NONE. "
81 "By default (empty string) get property value from "
82 "ApplicationMgr");
83 declareProperty("HistWriteInterval", m_writeInterval=0 ,
84 "histogram write/update interval");
85 declareProperty("FailureMode", m_failureMode=1 ,
86 "Controls behaviour of event loop depending on return code of"
87 " Algorithms. 0: all non-SUCCESSes terminate job. "
88 "1: RECOVERABLE skips to next event, FAILURE terminates job "
89 "(DEFAULT). 2: RECOVERABLE and FAILURE skip to next events");
90 declareProperty("EventPrintoutInterval", m_eventPrintoutInterval=1,
91 "Print event heartbeat printouts every m_eventPrintoutInterval events");
92 declareProperty("IntervalInSeconds", m_intervalInSeconds = 0,
93 "heartbeat time interval is seconds rather than events"
94 "you also get a nice event rate printout then");
95 declareProperty("DoLiteLoop",m_liteLoop=false,"Runs the bare minimum during executeEvent");
96 declareProperty("UseDetailChronoStat",m_doChrono=false);
97 declareProperty("ClearStorePolicy",
98 m_clearStorePolicy = "EndEvent",
99 "Configure the policy wrt handling of when the "
100 "'clear-the-event-store' event shall happen: at EndEvent "
101 "(default as it is makes things easier for memory management"
102 ") or at BeginEvent (easier e.g. for interactive use)");
103 declareProperty("PreSelectTools",m_tools,"AlgTools for event pre-selection")->
104 declareUpdateHandler( &AthenaEventLoopMgr::setupPreSelectTools, this );
105 declareProperty("RequireInputAttributeList", m_requireInputAttributeList = false,
106 "Require valid input attribute list to be present");
107 declareProperty("UseSecondaryEventNumber", m_useSecondaryEventNumber = false,
108 "In case of DoubleEventSelector use event number from secondary input");
109 declareProperty("EvtIdModifierSvc", m_evtIdModSvc,
110 "ServiceHandle for EvtIdModifierSvc");
111 declareProperty("ExecAtPreFork", m_execAtPreFork,
112 "List of algorithms/sequences to execute during PreFork");
113}
AthMessaging()
Default constructor:
UnsignedIntegerProperty m_eventPrintoutInterval
IntegerProperty m_failureMode
IEvtSelector::Context * m_evtSelCtxt
Gaudi EventSelector Context (may be used as a cursor by the evt selector).
IIncidentSvc_t m_incidentSvc
Reference to the incident service.
unsigned int m_nev
events processed
StoreGateSvc_t m_eventStore
Reference to StoreGateSvc;.
bool m_useSecondaryEventNumber
read event number from secondary input
bool m_requireInputAttributeList
require input attribute list
StringProperty m_histPersName
IConversionSvc_t m_histoPersSvc
IEvtSelector * m_evtSelector
Reference to the Event Selector.
IEvtIdModifierSvc_t m_evtIdModSvc
StringProperty m_evtsel
IntegerProperty m_writeInterval
StringProperty m_clearStorePolicy
void setupPreSelectTools(Gaudi::Details::PropertyBase &)
property update handler:sets up the Pre-selection tools
StringArrayProperty m_execAtPreFork
number_type m_currentRun
current run number
unsigned int m_intervalInSeconds
tool_store m_tools
internal tool store
ServiceHandle< IChronoStatSvc > m_chronoStatSvc
ServiceHandle< Athena::IConditionsCleanerSvc > m_conditionsCleaner
IDataManagerSvc_t m_histoDataMgrSvc
Reference to the Histogram Data Service.

◆ ~AthenaEventLoopMgr()

AthenaEventLoopMgr::~AthenaEventLoopMgr ( )
virtual

Standard Destructor.

Definition at line 118 of file AthenaEventLoopMgr.cxx.

119{
120}

◆ AthenaEventLoopMgr() [2/3]

AthenaEventLoopMgr::AthenaEventLoopMgr ( )
private

no implementation

◆ AthenaEventLoopMgr() [3/3]

AthenaEventLoopMgr::AthenaEventLoopMgr ( const AthenaEventLoopMgr & )
private

no implementation

Member Function Documentation

◆ curEvent()

int AthenaEventLoopMgr::curEvent ( ) const
overridevirtual

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

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
virtual const std::string & name() const override
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ executeAlgorithms()

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

Run the algorithms for the current event.

Reimplemented in PyAthenaEventLoopMgr.

Definition at line 515 of file AthenaEventLoopMgr.cxx.

515 {
516
517 // Call the execute() method of all top algorithms
518 for ( ListAlg::iterator ita = m_topAlgList.begin();
519 ita != m_topAlgList.end();
520 ++ita )
521 {
522 const StatusCode& sc = (*ita)->sysExecute(ctx);
523 // this duplicates what is already done in Algorithm::sysExecute, which
524 // calls Algorithm::setExecuted, but eventually we plan to remove that
525 // function
526 m_aess->algExecState(*ita,ctx).setState(AlgExecState::State::Done, sc);
527 if ( !sc.isSuccess() ) {
528 // StatusCode doesn't work with std::format
529 ATH_MSG_INFO ( "Execution of algorithm "
530 << (*ita)->name() << " failed with StatusCode::" << sc );
531 return sc;
532 }
533 }
534
535 return StatusCode::SUCCESS;
536}
SmartIF< IAlgExecStateSvc > m_aess
Reference to the Algorithm Execution State Svc.

◆ executeEvent()

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

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_ERROR(x,...)
#define ATH_MSG_ALWAYS(x,...)
#define CHECK(...)
Evaluate an expression and check for errors.
tool_stats m_toolInvoke
tool called counter
tool_stats m_toolAccept
tool returns StatusCode::SUCCESS counter
virtual StatusCode writeHistograms(bool force=false)
Dump out histograms as needed.
tool_stats m_toolReject
tool returns StatusCode::FAILURE counter
StatusCode installEventContext(EventContext &ctx)
virtual StatusCode executeAlgorithms(const EventContext &)
Run the algorithms for the current event.
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)
overridevirtual

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 AthenaEventLoopMgr::finalize ( )
overridevirtual

implementation of IAppMgrUI::finalize

Reimplemented in PyAthenaEventLoopMgr.

Definition at line 379 of file AthenaEventLoopMgr.cxx.

380{
381
382 StatusCode sc = MinimalEventLoopMgr::finalize();
383 if (sc.isFailure()) {
384 ATH_MSG_ERROR ( "Error in Algorithm Finalize" );
385 }
386
387 StatusCode sc2 = writeHistograms(true);
388 if (sc2.isFailure()) {
389 ATH_MSG_ERROR ( "Error in writing Histograms" );
390 }
391
392 // Release all interfaces (ignore StatusCodes)
393 m_histoDataMgrSvc.release().ignore();
394 m_histoPersSvc.release().ignore();
395
396 if (m_evtSelector) m_evtSelector->release();
397 m_incidentSvc.release().ignore();
398
399 delete m_evtSelCtxt; m_evtSelCtxt = nullptr;
400
401 if(m_useTools) {
402 tool_iterator firstTool = m_tools.begin();
403 tool_iterator lastTool = m_tools.end();
404 unsigned int toolCtr = 0;
405 ATH_MSG_INFO ( "Summary of AthenaEvtLoopPreSelectTool invocation: (invoked/success/failure)" );
406 ATH_MSG_INFO ( "-----------------------------------------------------" );
407
408 for ( ; firstTool != lastTool; ++firstTool ) {
409 ATH_MSG_INFO ( "{:>2}.) {:.<48} ({:>6}/{:>6}/{:>6})",
410 toolCtr+1,
411 (*firstTool)->name(),
412 m_toolInvoke[toolCtr],
413 m_toolAccept[toolCtr],
414 m_toolReject[toolCtr]);
415 toolCtr++;
416 }
417 }
418 return ( sc.isFailure() || sc2.isFailure() ) ? StatusCode::FAILURE :
419 StatusCode::SUCCESS;
420
421}
tool_store::const_iterator tool_iterator

◆ handle()

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

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)
StatusCode execAtPreFork(const EventContext &ctx) const
Execute certain algorithms/sequences in PreFork.
StatusCode initializeAlgorithms()
Initialize all algorithms and output streams.

◆ initialize()

StatusCode AthenaEventLoopMgr::initialize ( )
overridevirtual

implementation of IAppMgrUI::initalize

Reimplemented in PyAthenaEventLoopMgr.

Definition at line 125 of file AthenaEventLoopMgr.cxx.

126{
127 ATH_MSG_INFO ( "Initializing {}", name() ) ;
128
129 m_autoRetrieveTools = false;
130 m_checkToolDeps = false;
131
132 StatusCode sc = MinimalEventLoopMgr::initialize();
133 if ( !sc.isSuccess() )
134 {
135 ATH_MSG_ERROR ( "Failed to initialize base class MinimalEventLoopMgr" );
136 return sc;
137 }
138
139//-------------------------------------------------------------------------
140// Setup access to event data services
141//-------------------------------------------------------------------------
142
143 sc = m_eventStore.retrieve();
144 if( !sc.isSuccess() )
145 {
146 ATH_MSG_FATAL ( "Error retrieving pointer to StoreGateSvc" );
147 return sc;
148 }
149
150//--------------------------------------------------------------------------
151// Get the references to the services that are needed by the ApplicationMgr
152// itself
153//--------------------------------------------------------------------------
154 sc = m_incidentSvc.retrieve();
155 if( !sc.isSuccess() )
156 {
157 ATH_MSG_FATAL ( "Error retrieving IncidentSvc." );
158 return sc;
159 }
160
161//--------------------------------------------------------------------------
162// Access Property Manager interface:
163//--------------------------------------------------------------------------
164 SmartIF<IProperty> prpMgr(serviceLocator());
165 if ( !prpMgr.isValid() )
166 {
167 ATH_MSG_FATAL ( "IProperty interface not found in ApplicationMgr." );
168 return StatusCode::FAILURE;
169 }
170
171
172//--------------------------------------------------------------------------
173// Set up the Histogram Service
174//--------------------------------------------------------------------------
175 sc = m_histoDataMgrSvc.retrieve();
176 if( !sc.isSuccess() )
177 {
178 ATH_MSG_FATAL ( "Error retrieving HistogramDataSvc" );
179 return sc;
180 }
181
182 const std::string& histPersName(m_histPersName.value());
183 if ( histPersName.length() == 0 )
184 {
185 CHECK(setProperty(prpMgr->getProperty("HistogramPersistency")));
186 }
187
188 if ( histPersName != "NONE" ) {
189
190 m_histoPersSvc = IConversionSvc_t( "HistogramPersistencySvc",
191 this->name() );
192
193 if( !sc.isSuccess() ) {
194 ATH_MSG_WARNING ( "Histograms cannot not be saved - though required." );
195 } else {
196
197 SmartIF<IProperty> histSvc;
198 if (histPersName == "ROOT") {
199 histSvc = serviceLocator()->service("RootHistSvc");
200 } else if ( histPersName == "HBOOK" ) {
201 histSvc = serviceLocator()->service("HbookHistSvc");
202 }
203
204 if (!histSvc) {
205 ATH_MSG_ERROR ( "could not locate actual Histogram persistency service" );
206 } else {
207 const Gaudi::Details::PropertyBase &prop = histSvc->getProperty("OutputFile");
208 std::string val;
209 try {
210 const StringProperty &sprop = dynamic_cast<const StringProperty&>( prop );
211
212 val = sprop.value();
213
214 } catch (...) {
215 ATH_MSG_VERBOSE ( "could not dcast OutputFile property to a StringProperty."
216 " Need to fix Gaudi." );
217
218 val = prop.toString();
219
220 }
221
222 if (val != "" &&
223 val != "UndefinedROOTOutputFileName" &&
224 val != "UndefinedHbookOutputFileName" ) {
225 m_writeHists = true;
226 }
227 }
228 }
229
230 } else {
231 ATH_MSG_DEBUG ( "Histograms saving not required." );
232 }
233
234//--------------------------------------------------------------------------
235// Set up the EventID modifier Service
236//--------------------------------------------------------------------------
237 if( m_evtIdModSvc.empty() ) {
238 ATH_MSG_DEBUG ( "EventID modifier Service not set. No run number, ... overrides will be applied." );
239 }
240 else if ( !m_evtIdModSvc.retrieve().isSuccess() ) {
241 ATH_MSG_INFO ( "Could not find EventID modifier Service. No run number, ... overrides will be applied." );
242 }
243
244//-------------------------------------------------------------------------
245// Setup EventSelector service
246//-------------------------------------------------------------------------
247 const std::string& selName(m_evtsel.value());
248 // the evt sel is usually specified as a property of ApplicationMgr
249 if (selName.empty())
250 sc = setProperty(prpMgr->getProperty("EvtSel"));
251 if (sc.isFailure()) ATH_MSG_WARNING ( "Unable to set EvtSel property" );
252
253 // We do not expect a Event Selector necessarily being declared
254 if( !selName.empty() && selName != "NONE") {
255 SmartIF<IEvtSelector> theEvtSel{serviceLocator()->service( selName )};
256 if( theEvtSel && ( theEvtSel != m_evtSelector ) ) {
257 // Event Selector changed (or setup for the first time)
258 m_evtSelector = theEvtSel;
259
260 // reset iterator
261 if (m_evtSelector->createContext(m_evtSelCtxt).isFailure()) {
262 ATH_MSG_FATAL ( "Can not create the event selector Context."
263 );
264 return StatusCode::FAILURE;
265 }
266 if (msgLevel(MSG::INFO)) {
267 SmartIF<INamedInterface> named(theEvtSel);
268 if (named) {
269 ATH_MSG_INFO ( "Setup EventSelector service {}", named->name( )
270 );
271 }
272 }
273 } else if (sc.isFailure()) {
274 ATH_MSG_FATAL ( "No valid event selector called {}", selName
275 );
276 return StatusCode::FAILURE;
277 }
278 }
279
280//-------------------------------------------------------------------------
281// Setup 'Clear-Store' policy
282//-------------------------------------------------------------------------
283 try {
285 } catch(...) {
286 return StatusCode::FAILURE;
287 }
288
289 // Get the AlgExecStateSvc
290 m_aess = serviceLocator()->service("AlgExecStateSvc");
291 if( !m_aess.isValid() ) {
292 ATH_MSG_FATAL ( "Error retrieving AlgExecStateSvc" );
293 return StatusCode::FAILURE;
294 }
295
296 // Listen to the BeforeFork incident
297 m_incidentSvc->addListener(this,"BeforeFork",0);
298
299 CHECK( m_conditionsCleaner.retrieve() );
300
301 // Print if we override the event number using the one from secondary event
303 {
304 ATH_MSG_INFO ( "Using secondary event number." );
305 }
306
307 return sc;
308}
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_FATAL(x,...)
void setProperty(columnar::PythonToolHandle &self, const std::string &key, nb::object value)
ServiceHandle< IConversionSvc > IConversionSvc_t
void setClearStorePolicy(Gaudi::Details::PropertyBase &clearStorePolicy)
property update handler:set the clear-store policy value and check its value.
selName(recoSequenceName, hypoType=JetHypoAlgType.STANDARD)

◆ initializeAlgorithms()

StatusCode AthenaEventLoopMgr::initializeAlgorithms ( )
protected

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)
private

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}
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
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 )
virtual

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
inline

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
inline

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
inline

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
inlineoverridevirtual

Definition at line 188 of file AthenaEventLoopMgr.h.

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

◆ nextEvent()

StatusCode AthenaEventLoopMgr::nextEvent ( int maxevt)
overridevirtual

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)

◆ operator=()

AthenaEventLoopMgr & AthenaEventLoopMgr::operator= ( const AthenaEventLoopMgr & )
private

no implementation

◆ 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)
overridevirtual

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)
protected

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}

◆ setNextEventModifierIndex()

void AthenaEventLoopMgr::setNextEventModifierIndex ( long idx)
overridevirtual

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 & )
protected

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}

◆ size()

int AthenaEventLoopMgr::size ( )
overridevirtual

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 ( )
overridevirtual

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)
protectedvirtual

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}

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
protected

Reference to the Algorithm Execution State Svc.

Definition at line 152 of file AthenaEventLoopMgr.h.

◆ m_chronoStatSvc

ServiceHandle<IChronoStatSvc> AthenaEventLoopMgr::m_chronoStatSvc
private

Definition at line 222 of file AthenaEventLoopMgr.h.

◆ m_clearStorePolicy

StringProperty AthenaEventLoopMgr::m_clearStorePolicy
protected

Definition at line 135 of file AthenaEventLoopMgr.h.

◆ m_conditionsCleaner

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

Definition at line 223 of file AthenaEventLoopMgr.h.

◆ m_curEvtModIdx

long AthenaEventLoopMgr::m_curEvtModIdx {-1}
private

Definition at line 206 of file AthenaEventLoopMgr.h.

206{-1};

◆ m_currentRun

number_type AthenaEventLoopMgr::m_currentRun
protected

current run number

Definition at line 102 of file AthenaEventLoopMgr.h.

◆ m_doChrono

bool AthenaEventLoopMgr::m_doChrono = false
private

Definition at line 221 of file AthenaEventLoopMgr.h.

◆ m_eventPrintoutInterval

UnsignedIntegerProperty AthenaEventLoopMgr::m_eventPrintoutInterval
protected

Definition at line 109 of file AthenaEventLoopMgr.h.

◆ m_eventStore

StoreGateSvc_t AthenaEventLoopMgr::m_eventStore
protected

Reference to StoreGateSvc;.

Property

Definition at line 73 of file AthenaEventLoopMgr.h.

◆ m_evtIdModSvc

IEvtIdModifierSvc_t AthenaEventLoopMgr::m_evtIdModSvc
protected

Definition at line 92 of file AthenaEventLoopMgr.h.

◆ m_evtModBaseNevt

int AthenaEventLoopMgr::m_evtModBaseNevt {0}
private

Definition at line 205 of file AthenaEventLoopMgr.h.

205{0};

◆ m_evtModIdxBase

long AthenaEventLoopMgr::m_evtModIdxBase {-1}
private

Definition at line 204 of file AthenaEventLoopMgr.h.

204{-1};

◆ m_evtsel

StringProperty AthenaEventLoopMgr::m_evtsel
protected

Definition at line 80 of file AthenaEventLoopMgr.h.

◆ m_evtSelCtxt

IEvtSelector::Context* AthenaEventLoopMgr::m_evtSelCtxt
protected

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
protected

Reference to the Event Selector.

Definition at line 76 of file AthenaEventLoopMgr.h.

◆ m_execAtPreFork

StringArrayProperty AthenaEventLoopMgr::m_execAtPreFork
protected

Definition at line 95 of file AthenaEventLoopMgr.h.

◆ m_failureMode

IntegerProperty AthenaEventLoopMgr::m_failureMode
protected

Definition at line 106 of file AthenaEventLoopMgr.h.

◆ m_firstRun

bool AthenaEventLoopMgr::m_firstRun
protected

Definition at line 103 of file AthenaEventLoopMgr.h.

◆ m_histoDataMgrSvc

IDataManagerSvc_t AthenaEventLoopMgr::m_histoDataMgrSvc
protected

Reference to the Histogram Data Service.

Definition at line 84 of file AthenaEventLoopMgr.h.

◆ m_histoPersSvc

IConversionSvc_t AthenaEventLoopMgr::m_histoPersSvc
protected

Definition at line 88 of file AthenaEventLoopMgr.h.

◆ m_histPersName

StringProperty AthenaEventLoopMgr::m_histPersName
protected

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
protected

Reference to the incident service.

Definition at line 69 of file AthenaEventLoopMgr.h.

◆ m_intervalInSeconds

unsigned int AthenaEventLoopMgr::m_intervalInSeconds
private

Definition at line 217 of file AthenaEventLoopMgr.h.

◆ m_lastNev

unsigned int AthenaEventLoopMgr::m_lastNev {}
private

Definition at line 216 of file AthenaEventLoopMgr.h.

216{};

◆ m_lastTime

time_t AthenaEventLoopMgr::m_lastTime {}
private

Definition at line 218 of file AthenaEventLoopMgr.h.

218{};

◆ m_liteLoop

bool AthenaEventLoopMgr::m_liteLoop
private

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_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
private

events processed

Definition at line 212 of file AthenaEventLoopMgr.h.

◆ m_nevt

int AthenaEventLoopMgr::m_nevt {}
private

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
private

Definition at line 213 of file AthenaEventLoopMgr.h.

◆ m_requireInputAttributeList

bool AthenaEventLoopMgr::m_requireInputAttributeList {}
protected

require input attribute list

Definition at line 124 of file AthenaEventLoopMgr.h.

124{};

◆ m_toolAccept

tool_stats AthenaEventLoopMgr::m_toolAccept
protected

tool returns StatusCode::SUCCESS counter

Definition at line 120 of file AthenaEventLoopMgr.h.

◆ m_toolInvoke

tool_stats AthenaEventLoopMgr::m_toolInvoke
protected

tool called counter

Definition at line 118 of file AthenaEventLoopMgr.h.

◆ m_toolReject

tool_stats AthenaEventLoopMgr::m_toolReject
protected

tool returns StatusCode::FAILURE counter

Definition at line 119 of file AthenaEventLoopMgr.h.

◆ m_tools

tool_store AthenaEventLoopMgr::m_tools
protected

internal tool store

Definition at line 121 of file AthenaEventLoopMgr.h.

◆ m_useSecondaryEventNumber

bool AthenaEventLoopMgr::m_useSecondaryEventNumber {}
protected

read event number from secondary input

Definition at line 127 of file AthenaEventLoopMgr.h.

127{};

◆ m_useTools

bool AthenaEventLoopMgr::m_useTools
private

Definition at line 214 of file AthenaEventLoopMgr.h.

◆ m_writeHists

bool AthenaEventLoopMgr::m_writeHists {}
private

Definition at line 209 of file AthenaEventLoopMgr.h.

209{};

◆ m_writeInterval

IntegerProperty AthenaEventLoopMgr::m_writeInterval
private

Definition at line 208 of file AthenaEventLoopMgr.h.


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