ATLAS Offline Software
Loading...
Searching...
No Matches
AthenaEventLoopMgr.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#define GAUDISVC_EVENTLOOPMGR_CPP
6
7#include <cassert>
8#include <ios>
9#include <iostream>
10#include <fstream> /* ofstream */
11#include <iomanip>
12#include <memory>
13#include <stdexcept>
14
15// Athena includes
23
24#include "GaudiKernel/IAlgManager.h"
25#include "GaudiKernel/IAlgorithm.h"
26#include "GaudiKernel/SmartIF.h"
27#include "GaudiKernel/Incident.h"
28#include "GaudiKernel/DataObject.h"
29#include "GaudiKernel/IIncidentSvc.h"
30#include "GaudiKernel/IEvtSelector.h"
31#include "GaudiKernel/IDataManagerSvc.h"
32#include "GaudiKernel/IConversionSvc.h"
33#include "GaudiKernel/GaudiException.h"
34#include "GaudiKernel/EventContext.h"
35#include "GaudiKernel/EventIDBase.h"
36#include "GaudiKernel/ThreadLocalContext.h"
37#include "GaudiKernel/AppReturnCode.h"
38
40
41#include "EventInfo/EventInfo.h"
42#include "EventInfo/EventID.h"
43#include "EventInfo/EventType.h"
44
47
48#include "ClearStorePolicy.h"
49
50#include "AthenaEventLoopMgr.h"
52
53
54//=========================================================================
55// Standard Constructor
56//=========================================================================
58 ISvcLocator* svcLoc)
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}
113
114//=========================================================================
115// Standard Destructor
116//=========================================================================
120
121//=========================================================================
122// implementation of IAppMgrUI::initalize
123//=========================================================================
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}
308
309//=========================================================================
310// property handlers
311//=========================================================================
312void
313AthenaEventLoopMgr::setClearStorePolicy(Gaudi::Details::PropertyBase&) {
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}
331
332void
333AthenaEventLoopMgr::setupPreSelectTools(Gaudi::Details::PropertyBase&) {
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}
362
363/* Called from ApplicationMgr::stopRun()
364 usually when a stop was requested by a signal
365*/
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}
375
376//=========================================================================
377// implementation of IAppMgrUI::finalize
378//=========================================================================
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}
431
432//=========================================================================
433// write out the histograms
434//=========================================================================
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}
487
488//=========================================================================
489// Call sysInitialize() on all algorithms and output streams
490//=========================================================================
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}
522
523//=========================================================================
524// Run the algorithms for the current event
525//=========================================================================
526StatusCode AthenaEventLoopMgr::executeAlgorithms(const EventContext& ctx) {
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}
547
548
549//=========================================================================
550// Execute one event
551//=========================================================================
552StatusCode AthenaEventLoopMgr::executeEvent(EventContext&& ctx)
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));
557 StatusCode sc = executeAlgorithms(ctx);
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())) ||
602 (m_intervalInSeconds && (time(nullptr)-m_lastTime)>m_intervalInSeconds) ));
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
633 StatusCode sc = executeAlgorithms(ctx);
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}
707
708//=========================================================================
709// implementation of IEventProcessor::executeRun
710//=========================================================================
711StatusCode AthenaEventLoopMgr::executeRun(int maxevt)
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}
719
720//=========================================================================
721// implementation of IAppMgrUI::nextEvent
722//=========================================================================
723StatusCode AthenaEventLoopMgr::nextEvent(int maxevt)
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
745 StatusCode sc = initializeAlgorithms();
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}
853
854
855//=========================================================================
856// Seek to a given event.
857// The event selector must support the IEvtSelectorSeek interface for this to work.
858//=========================================================================
859StatusCode AthenaEventLoopMgr::seek (int evt)
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}
884
885
886//=========================================================================
887// Return the current event count.
888//=========================================================================
890{
891 return m_nevt;
892}
893
894//=========================================================================
895// Return the collection size
896//=========================================================================
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}
915
916//=========================================================================
917// Handle incidents
918//=========================================================================
919void AthenaEventLoopMgr::handle(const Incident& inc)
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
930 StatusCode sc = initializeAlgorithms();
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}
996
997//=========================================================================
998// Execute certain algorithms/sequence in PreFork
999//=========================================================================
1000StatusCode AthenaEventLoopMgr::execAtPreFork(const EventContext& ctx) const {
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}
1014
1015
1018 return m_eventStore.get();
1019}
1020
1021
1022//=========================================================================
1023// Fill in our EventContext object and make it current.
1024//=========================================================================
1025StatusCode AthenaEventLoopMgr::installEventContext(EventContext& ctx) {
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 =
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}
1174
1175//---------------------------------------------------------------------------
1176
1177void AthenaEventLoopMgr::modifyEventContext(EventContext& ctx, const EventID& eID, bool consume_modifier_stream) {
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}
#define endmsg
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_ALWAYS(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
The default ATLAS batch event loop manager.
ClearStorePolicy::Type clearStorePolicy(const std::string &policyName, MsgStream &msg)
returns the enum-version of the policy (by name)
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
Assign a CLID to EventContext.
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
EventID eventIDFromxAOD(const xAOD::EventInfo *xaod)
Create EventID object from xAOD::EventInfo.
EventType eventTypeFromxAOD(const xAOD::EventInfo *xaod)
Create EventType object from xAOD::EventInfo.
This class provides general information about an event.
This file contains the class definition for the IAthenaEvtLoopPreSelectTool class.
Extension to IEvtSelector to allow for seeking.
static Double_t sc
void setProperty(columnar::PythonToolHandle &self, const std::string &key, nb::object value)
An AttributeList represents a logical row of attributes in a metadata table.
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
An AttributeList represents a logical row of attributes in a metadata table.
virtual ~AthenaEventLoopMgr()
Standard Destructor.
UnsignedIntegerProperty m_eventPrintoutInterval
IntegerProperty m_failureMode
IEvtSelector::Context * m_evtSelCtxt
Gaudi EventSelector Context (may be used as a cursor by the evt selector)
virtual int curEvent() const override
Return the current event count.
tool_stats m_toolInvoke
tool called counter
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
tool_stats m_toolAccept
tool returns StatusCode::SUCCESS counter
virtual void handle(const Incident &inc) override
IIncidentListenet interfaces.
bool m_requireInputAttributeList
require input attribute list
SmartIF< IAlgExecStateSvc > m_aess
Reference to the Algorithm Execution State Svc.
virtual StatusCode writeHistograms(bool force=false)
Dump out histograms as needed.
StringProperty m_histPersName
tool_stats m_toolReject
tool returns StatusCode::FAILURE counter
AthenaEventLoopMgr()
no implementation
StatusCode execAtPreFork(const EventContext &ctx) const
Execute certain algorithms/sequences in PreFork.
IConversionSvc_t m_histoPersSvc
IEvtSelector * m_evtSelector
Reference to the Event Selector.
virtual StatusCode executeEvent(EventContext &&ctx) override
implementation of IEventProcessor::executeEvent(EventContext&& ctx)
virtual StatusCode initialize() override
implementation of IAppMgrUI::initalize
virtual StatusCode seek(int evt) override
Seek to a given event.
virtual int size() override
Return the size of the collection.
IEvtIdModifierSvc_t m_evtIdModSvc
StoreGateSvc * eventStore() const
StringProperty m_evtsel
virtual StatusCode finalize() override
implementation of IAppMgrUI::finalize
IntegerProperty m_writeInterval
StringProperty m_clearStorePolicy
ServiceHandle< IConversionSvc > IConversionSvc_t
StatusCode installEventContext(EventContext &ctx)
virtual StatusCode stopRun() override
Called from ApplicationMgr::stopRun() to terminate the loop.
void setupPreSelectTools(Gaudi::Details::PropertyBase &)
property update handler:sets up the Pre-selection tools
virtual const std::string & name() const override
virtual StatusCode executeAlgorithms(const EventContext &)
Run the algorithms for the current event.
StringArrayProperty m_execAtPreFork
virtual void modifyEventContext(EventContext &ctx, const EventID &eID, bool consume_modifier_stream)
number_type m_currentRun
current run number
unsigned int m_intervalInSeconds
StatusCode initializeAlgorithms()
Initialize all algorithms and output streams.
tool_store::const_iterator tool_iterator
tool_store m_tools
internal tool store
virtual StatusCode executeRun(int maxevt) override
implementation of IEventProcessor::executeRun(int maxevt)
virtual StatusCode nextEvent(int maxevt) override
implementation of IAppMgrUI::nextEvent. maxevt==0 returns immediately
ServiceHandle< IChronoStatSvc > m_chronoStatSvc
ServiceHandle< Athena::IConditionsCleanerSvc > m_conditionsCleaner
IDataManagerSvc_t m_histoDataMgrSvc
Reference to the Histogram Data Service.
void setClearStorePolicy(Gaudi::Details::PropertyBase &clearStorePolicy)
property update handler:set the clear-store policy value and check its value.
void resetTimeout(Timeout &instance)
Reset timeout.
Definition Timeout.h:83
static Timeout & instance()
Get reference to Timeout singleton.
Definition Timeout.h:64
void setConditionsRun(EventIDBase::number_type conditionsRun)
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition EventID.h:35
EventID * event_ID()
the unique identification of the event.
Abstract interface for seeking for an event selector.
virtual StatusCode seek(IEvtSelector::Context &c, int evtnum) const =0
Seek to a given event number.
virtual int size(IEvtSelector::Context &c) const =0
Return the size of the collection, or -1 if we can't get the size.
The Athena Transient Store API.
StatusCode recordAddress(const std::string &skey, CxxUtils::RefCountedPtr< IOpaqueAddress > pAddress, bool clearAddressFlag=true)
Create a proxy object using an IOpaqueAddress and a transient key.
StatusCode record(T *p2BRegistered, const TKEY &key)
Record an object with a key.
const T * tryConstRetrieve() const
virtual StatusCode clearStore(bool forceRemove=false) override final
clear DataStore contents: called by the event loop mgrs
uint32_t runNumber() const
The current event's run number.
void setExtendedEventContext(EventContext &ctx, ExtendedEventContext &&ectx)
Move an extended context into a context object.
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
thread_local event_number_t eventIndex
EventInfo_v1 EventInfo
Definition of the latest event info version.