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 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< StoreGateSvcStoreGateSvc_t
typedef ServiceHandle< IDataManagerSvc > IDataManagerSvc_t
typedef ServiceHandle< IConversionSvc > IConversionSvc_t
typedef ServiceHandle< IEvtIdModifierSvcIEvtIdModifierSvc_t
typedef EventID::number_type number_type
typedef IAthenaEvtLoopPreSelectTool tool_type
typedef ToolHandleArray< tool_typetool_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
AthenaEventLoopMgroperator= (const AthenaEventLoopMgr &)
 no implementation
StatusCode installEventContext (EventContext &ctx)
StoreGateSvceventStore () const
void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

int m_nevt {}
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::IConditionsCleanerSvcm_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 57 of file AthenaEventLoopMgr.cxx.

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

118{
119}

◆ 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 889 of file AthenaEventLoopMgr.cxx.

890{
891 return m_nevt;
892}

◆ eventStore()

StoreGateSvc * AthenaEventLoopMgr::eventStore ( ) const
private

Definition at line 1017 of file AthenaEventLoopMgr.cxx.

1017 {
1018 return m_eventStore.get();
1019}

◆ execAtPreFork()

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

Execute certain algorithms/sequences in PreFork.

Definition at line 1000 of file AthenaEventLoopMgr.cxx.

1000 {
1001 IAlgManager* algMgr = Gaudi::svcLocator()->as<IAlgManager>();
1002
1003 StatusCode sc;
1004 for (const std::string& name : m_execAtPreFork) {
1005 SmartIF<IAlgorithm>& alg = algMgr->algorithm(name, /*createIf*/false);
1006 if ( alg ) {
1007 ATH_MSG_INFO("Executing " << alg->name() << "...");
1008 sc &= alg->sysExecute(ctx);
1009 }
1010 else ATH_MSG_WARNING("Cannot find algorithm or sequence " << name);
1011 }
1012 return sc;
1013}
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(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 526 of file AthenaEventLoopMgr.cxx.

526 {
527
528 // Call the execute() method of all top algorithms
529 for ( ListAlg::iterator ita = m_topAlgList.begin();
530 ita != m_topAlgList.end();
531 ++ita )
532 {
533 const StatusCode& sc = (*ita)->sysExecute(ctx);
534 // this duplicates what is already done in Algorithm::sysExecute, which
535 // calls Algorithm::setExecuted, but eventually we plan to remove that
536 // function
537 m_aess->algExecState(*ita,ctx).setState(AlgExecState::State::Done, sc);
538 if ( !sc.isSuccess() ) {
539 ATH_MSG_INFO ( "Execution of algorithm "
540 << (*ita)->name() << " failed with StatusCode::" << sc );
541 return sc;
542 }
543 }
544
545 return StatusCode::SUCCESS;
546}
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 552 of file AthenaEventLoopMgr.cxx.

553{
554 //This is a lightweight implementation of the executeEvent, used when e.g. processing TTrees with RootNtupleEventSelector
555 if(m_liteLoop) {
556 m_incidentSvc->fireIncident(Incident("BeginEvent",IncidentType::BeginEvent));
558 m_incidentSvc->fireIncident(Incident("EndEvent",IncidentType::EndEvent));
559 ++m_proc;
560 ++m_nev;
561 return sc;
562 }
563
565
567 if (m_firstRun || (m_currentRun != ctx.eventID().run_number()) ) {
568 // Fire EndRun incident unless this is the first run
569 if (!m_firstRun) {
570 m_incidentSvc->fireIncident(Incident(name(),IncidentType::EndRun));
571 }
572 m_firstRun=false;
573 m_currentRun = ctx.eventID().run_number();
574
575 ATH_MSG_INFO ( " ===>>> start of run " << m_currentRun << " <<<===" );
576
577 m_incidentSvc->fireIncident(Incident(name(),IncidentType::BeginRun,ctx));
578 }
579
580 bool toolsPassed=true;
581 bool eventFailed = false;
582 // Call any attached tools to reject events early
583 unsigned int toolCtr=0;
584 if(m_useTools) {
585 //note: pEvent cannot be nullptr here, it has already been dereferenced
586 tool_store::iterator theTool = m_tools.begin();
587 tool_store::iterator lastTool = m_tools.end();
588 while(toolsPassed && theTool!=lastTool )
589 {
590 toolsPassed = (*theTool)->passEvent(ctx.eventID());
591 m_toolInvoke[toolCtr]++;
592 {toolsPassed ? m_toolAccept[toolCtr]++ : m_toolReject[toolCtr]++;}
593 ++toolCtr;
594 ++theTool;
595 }
596 }
597
598
599 uint64_t evtNumber = ctx.eventID().event_number();
600 bool doEvtHeartbeat(m_eventPrintoutInterval.value() > 0 &&
601 ( (!m_intervalInSeconds && 0 == (m_nev % m_eventPrintoutInterval.value())) ||
603 if (doEvtHeartbeat) {
604 if(!m_useTools) {
605 ATH_MSG_INFO ( " ===>>> start processing event #" << evtNumber << ", run #" << m_currentRun << " " << m_nev << " events processed so far <<<===" );
607 ATH_MSG_INFO(" ===>>> Event processing rate = " << double(m_nev-m_lastNev)/(time(nullptr)-m_lastTime) << " Hz <<<===");
608 m_lastNev = m_nev; m_lastTime = time(nullptr);
609 }
610 }
611
612 else ATH_MSG_INFO ( " ===>>> start processing event #" << evtNumber << ", run #" << m_currentRun
613 << " " << m_nev << " events read and " << m_proc
614 << " events processed so far <<<===" );
615 }
616
617 // Reset the timeout singleton
619 if(toolsPassed) {
620 // Fire BeginEvent "Incident"
621 //m_incidentSvc->fireIncident(Incident(*pEvent, name(),"BeginEvent"));
622
623 // An incident may schedule a stop, in which case is better to exit before the actual execution.
624 if ( m_scheduledStop ) {
625 ATH_MSG_ALWAYS ( "A stopRun was requested by an incidentListener. "
626 << "Do not process this event." );
627 return (StatusCode::SUCCESS);
628 }
629
630 CHECK( m_conditionsCleaner->event (ctx, false) );
631
632 // Call the execute() method of all top algorithms
634
635 if(!sc.isSuccess()) {
636 eventFailed = true;
637 m_aess->setEventStatus( EventStatus::AlgFail, ctx );
638
642 if (m_failureMode == 1 && sc.isRecoverable() ) {
643 ATH_MSG_WARNING ( "RECOVERABLE error returned by algorithm. "
644 << "Skipping remaining algorithms." << std::endl
645 << "\tNo output will be written for this event, "
646 << "but job will continue to next event" );
647 eventFailed = false;
648 }
649
651 if (m_failureMode >= 2) {
652 ATH_MSG_INFO ( "Skipping remaining algorithms." << std::endl
653 << "\tNo output will be written for this event, "
654 << "but job will continue to next event" );
655 eventFailed = false;
656 }
657
658 } else {
659
660 m_aess->setEventStatus( EventStatus::Success, ctx );
661
662 // Call the execute() method of all output streams
663 for (ListAlg::iterator ito = m_outStreamList.begin();
664 ito != m_outStreamList.end(); ++ito ) {
665 sc = (*ito)->sysExecute(ctx);
666 if( !sc.isSuccess() ) {
667 eventFailed = true;
668 }
669 }
670
671 writeHistograms().ignore();
672
673 }
674
675 // Fire EndEvent "Incident"
676 //m_incidentSvc->fireIncident(Incident(*pEvent, name(),"EndEvent"));
677 ++m_proc;
678 } // end of toolsPassed test
679 ++m_nev;
680 if (doEvtHeartbeat) {
682 if (!m_useTools)
683 ATH_MSG_INFO(" ===>>> done processing event #" << evtNumber << ", run #" << m_currentRun
684 << " " << m_nev << " events processed so far <<<===");
685 else
686 ATH_MSG_INFO(" ===>>> done processing event #" << evtNumber << ", run #" << m_currentRun
687 << " " << m_nev << " events read and " << m_proc
688 << " events processed so far <<<===");
689 }
690 std::ofstream outfile( "eventLoopHeartBeat.txt");
691 if ( !outfile ) {
692 ATH_MSG_ERROR ( " unable to open: eventLoopHeartBeat.txt" );
693 } else {
694 outfile << " done processing event #" << evtNumber << ", run #" << m_currentRun
695 << " " << m_nev << " events read so far <<<===" << std::endl;
696 outfile.close();
697 }
698
699 }
700
701 //------------------------------------------------------------------------
702 // Check if there was an error processing current event
703 //------------------------------------------------------------------------
704 return eventFailed?StatusCode::FAILURE:StatusCode::SUCCESS;
705
706}
#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 711 of file AthenaEventLoopMgr.cxx.

712{
713 if (!(this->nextEvent(maxevt)).isSuccess()) return StatusCode::FAILURE;
714 m_incidentSvc->fireIncident(Incident(name(),"EndEvtLoop"));
715 m_incidentSvc->fireIncident(Incident(name(),IncidentType::EndRun));
716
717 return StatusCode::SUCCESS;
718}
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 ( std::setw(2) << std::setiosflags(std::ios_base::right)
410 << toolCtr+1 << ".) " << std::resetiosflags(std::ios_base::right)
411 << std::setw(48) << std::setfill('.')
412 << std::setiosflags(std::ios_base::left)
413 << (*firstTool)->name() << std::resetiosflags(std::ios_base::left)
414 << std::setfill(' ')
415 << " ("
416 << std::setw(6) << std::setiosflags(std::ios_base::right)
417 << m_toolInvoke[toolCtr]
418 << "/"
419 << m_toolAccept[toolCtr]
420 << "/"
421 << m_toolReject[toolCtr]
422 << ")"
423 );
424 toolCtr++;
425 }
426 }
427 return ( sc.isFailure() || sc2.isFailure() ) ? StatusCode::FAILURE :
428 StatusCode::SUCCESS;
429
430}
tool_store::const_iterator tool_iterator

◆ handle()

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

IIncidentListenet interfaces.

Definition at line 919 of file AthenaEventLoopMgr.cxx.

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

◆ initialize()

StatusCode AthenaEventLoopMgr::initialize ( )
overridevirtual

implementation of IAppMgrUI::initalize

Reimplemented in PyAthenaEventLoopMgr.

Definition at line 124 of file AthenaEventLoopMgr.cxx.

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

491 {
492
493 // Initialize the list of Algorithms. Note that existing Algorithms
494 // are protected against multiple initialization attempts.
495 ListAlg::iterator ita;
496 for ( ita = m_topAlgList.begin(); ita != m_topAlgList.end(); ++ita )
497 {
498 StatusCode sc = (*ita)->sysInitialize();
499 if( sc.isFailure() )
500 {
501 ATH_MSG_ERROR ( "Unable to initialize Algorithm: "
502 << (*ita)->name() );
503 return sc;
504 }
505 }
506
507 // Initialize the list of Output Streams. Note that existing Output Streams
508 // are protected against multiple initialization attempts.
509 for (ita = m_outStreamList.begin(); ita != m_outStreamList.end(); ++ita )
510 {
511 StatusCode sc = (*ita)->sysInitialize();
512 if( sc.isFailure() ) {
513 ATH_MSG_ERROR ( "Unable to initialize Output Stream: "
514 << (*ita)->name() );
515 return sc;
516 }
517
518 }
519
520 return StatusCode::SUCCESS;
521}

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

◆ installEventContext()

StatusCode AthenaEventLoopMgr::installEventContext ( EventContext & ctx)
private

Definition at line 1025 of file AthenaEventLoopMgr.cxx.

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

1177 {
1178 if (m_evtIdModSvc.isSet()) {
1179 EventID new_eID(eID);
1180 // m_nevt - 1 because it's incremented early
1181 m_evtIdModSvc->modify_evtid(new_eID, m_nevt - 1, consume_modifier_stream);
1182 if (msgLevel(MSG::DEBUG)) {
1183 unsigned int oldrunnr=eID.run_number();
1184 unsigned int oldLB=eID.lumi_block();
1185 unsigned int oldTS=eID.time_stamp();
1186 unsigned int oldTSno=eID.time_stamp_ns_offset();
1187 ATH_MSG_DEBUG ( "modifyEventContext: use evtIdModSvc runnr=" << oldrunnr << " -> " << new_eID.run_number() );
1188 ATH_MSG_DEBUG ( "modifyEventContext: use evtIdModSvc LB=" << oldLB << " -> " << new_eID.lumi_block() );
1189 ATH_MSG_DEBUG ( "modifyEventContext: use evtIdModSvc TimeStamp=" << oldTS << " -> " << new_eID.time_stamp() );
1190 ATH_MSG_DEBUG ( "modifyEventContext: use evtIdModSvc TimeStamp ns Offset=" << oldTSno << " -> " << new_eID.time_stamp_ns_offset() );
1191 }
1192 ctx.setEventID( new_eID );
1193 Atlas::getExtendedEventContext(ctx).setConditionsRun( ctx.eventID().run_number() );
1194 return;
1195 }
1196
1197 ctx.setEventID( eID );
1198}
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.

164{
165 MsgStream* ms = m_msg_tls.get();
166 if (!ms) {
167 if (!m_initialized.test_and_set()) initMessaging();
168 ms = new MsgStream(m_imsg,m_nm);
169 m_msg_tls.reset( ms );
170 }
171
172 ms->setLevel (m_lvl);
173 return *ms;
174}
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.

179{ 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 (m_lvl <= lvl) {
154 msg() << lvl;
155 return true;
156 } else {
157 return false;
158 }
159}

◆ name()

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

Definition at line 186 of file AthenaEventLoopMgr.h.

186{ 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 723 of file AthenaEventLoopMgr.cxx.

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

860{
861 IEvtSelectorSeek* is = dynamic_cast<IEvtSelectorSeek*> (m_evtSelector);
862 if (is == nullptr) {
863 ATH_MSG_ERROR ( "Seek failed; unsupported by event selector" );
864 return StatusCode::FAILURE;
865 }
866 //cppcheck-suppress nullPointerRedundantCheck
867 if (!m_evtSelCtxt) {
868 if (m_evtSelector->createContext(m_evtSelCtxt).isFailure()) {
869 ATH_MSG_FATAL ( "Can not create the event selector Context." );
870 return StatusCode::FAILURE;
871 }
872 }
873 //m_evtSelCtxt cannot be null if createContext succeeded
874 //cppcheck-suppress nullPointerRedundantCheck
875 StatusCode sc = is->seek (*m_evtSelCtxt, evt);
876 if (sc.isSuccess()) {
877 m_nevt = evt;
878 }
879 else {
880 ATH_MSG_ERROR ( "Seek failed." );
881 }
882 return sc;
883}
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 313 of file AthenaEventLoopMgr.cxx.

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

◆ 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}

◆ 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 897 of file AthenaEventLoopMgr.cxx.

898{
899 IEvtSelectorSeek* cs = dynamic_cast<IEvtSelectorSeek*> (m_evtSelector);
900 if (cs == nullptr) {
901 ATH_MSG_ERROR ( "Collection size unsupported by event selector" );
902 return -1;
903 }
904 //cppcheck-suppress nullPointerRedundantCheck
905 if (!m_evtSelCtxt) {
906 if (m_evtSelector->createContext(m_evtSelCtxt).isFailure()) {
907 ATH_MSG_FATAL ( "Can not create the event selector Context." );
908 return -1;
909 }
910 }
911 //m_evtSelCtxt cannot be null if createContext succeeded
912 //cppcheck-suppress nullPointerRedundantCheck
913 return cs->size (*m_evtSelCtxt);
914}
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 435 of file AthenaEventLoopMgr.cxx.

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

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 216 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 217 of file AthenaEventLoopMgr.h.

◆ 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 215 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_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 208 of file AthenaEventLoopMgr.h.

◆ m_lastNev

unsigned int AthenaEventLoopMgr::m_lastNev {}
private

Definition at line 207 of file AthenaEventLoopMgr.h.

207{};

◆ m_lastTime

time_t AthenaEventLoopMgr::m_lastTime {}
private

Definition at line 209 of file AthenaEventLoopMgr.h.

209{};

◆ m_liteLoop

bool AthenaEventLoopMgr::m_liteLoop
private

Definition at line 211 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 203 of file AthenaEventLoopMgr.h.

◆ m_nevt

int AthenaEventLoopMgr::m_nevt {}
private

Definition at line 197 of file AthenaEventLoopMgr.h.

197{};

◆ 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 204 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 205 of file AthenaEventLoopMgr.h.

◆ m_writeHists

bool AthenaEventLoopMgr::m_writeHists {}
private

Definition at line 200 of file AthenaEventLoopMgr.h.

200{};

◆ m_writeInterval

IntegerProperty AthenaEventLoopMgr::m_writeInterval
private

Definition at line 199 of file AthenaEventLoopMgr.h.


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