ATLAS Offline Software
AthenaMtesEventLoopMgr.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "ClearStorePolicy.h"
8 
15 
16 #include "GaudiKernel/IAlgorithm.h"
17 #include "GaudiKernel/SmartIF.h"
18 #include "GaudiKernel/Incident.h"
19 #include "GaudiKernel/DataObject.h"
20 #include "GaudiKernel/IIncidentSvc.h"
21 #include "GaudiKernel/IDataManagerSvc.h"
22 #include "GaudiKernel/IDataProviderSvc.h"
23 #include "GaudiKernel/IConversionSvc.h"
24 #include "GaudiKernel/GaudiException.h"
25 #include "GaudiKernel/AppReturnCode.h"
26 #include "GaudiKernel/MsgStream.h"
27 #include "GaudiKernel/EventIDBase.h"
28 #include "GaudiKernel/ThreadLocalContext.h"
29 #include "GaudiKernel/FileIncident.h"
30 
31 #include "StoreGate/StoreGateSvc.h"
32 
33 #include "EventInfo/EventInfo.h"
34 #include "EventInfo/EventID.h"
35 #include "EventInfo/EventType.h"
38 
39 #include "tbb/tick_count.h"
40 #include "yampl/SocketFactory.h"
41 #include "CxxUtils/starts_with.h"
42 
43 #include <cassert>
44 #include <ios>
45 #include <iostream>
46 #include <fstream>
47 #include <iomanip>
48 #include <cstdlib>
49 #include <memory>
50 #include <unistd.h>
51 
52 namespace {
53  bool
54  leftString(std::string & s, char sc){
55  bool truncated{false};
56  auto n = s.find(sc);
57  if (n!=std::string::npos){
58  s.resize(n);
59  truncated=true;
60  }
61  return truncated;
62 }
63 
64  bool
65  leftString(std::string & s, int n){
66  bool truncated{false};
67  if (static_cast<size_t>(n) < s.size()){
68  s.resize(n);
69  truncated=true;
70  }
71  return truncated;
72  }
73 }
74 
76  , ISvcLocator* svcLoc)
77  : MinimalEventLoopMgr(nam, svcLoc)
78  , m_incidentSvc ( "IncidentSvc", nam )
79  , m_eventStore( "StoreGateSvc", nam )
80  , m_evtSelector{nullptr}
81  , m_evtContext{nullptr}
82  , m_histoDataMgrSvc( "HistogramDataSvc", nam )
83  , m_histoPersSvc ( "HistogramPersistencySvc", nam )
84  , m_evtIdModSvc("", nam)
85  , m_currentRun(0)
86  , m_firstRun(true)
87  , m_tools(this)
88  , m_nevt(0)
89  , m_writeHists(false)
90  , m_nev(0)
91  , m_proc(0)
92  , m_useTools(false)
93  , m_doEvtHeartbeat(false)
94  , m_conditionsCleaner( "Athena::ConditionsCleanerSvc", nam )
95  , m_outSeqSvc("OutputStreamSequencerSvc", nam)
96 {
97  declareProperty("EvtSel", m_evtsel,
98  "Name of Event Selector to use. If empty string (default) "
99  "take value from ApplicationMgr");
100  declareProperty("HistogramPersistency", m_histPersName="",
101  "Histogram persistency technology to use: ROOT, HBOOK, NONE. "
102  "By default (empty string) get property value from "
103  "ApplicationMgr");
104  declareProperty("HistWriteInterval", m_writeInterval=0 ,
105  "histogram write/update interval");
106  declareProperty("FailureMode", m_failureMode=1 ,
107  "Controls behaviour of event loop depending on return code of"
108  " Algorithms. 0: all non-SUCCESSes terminate job. "
109  "1: RECOVERABLE skips to next event, FAILURE terminates job "
110  "(DEFAULT). 2: RECOVERABLE and FAILURE skip to next events");
111  declareProperty("EventPrintoutInterval", m_eventPrintoutInterval=1,
112  "Print event heartbeat printouts every m_eventPrintoutInterval events");
113  declareProperty("ClearStorePolicy",
114  m_clearStorePolicy = "EndEvent",
115  "Configure the policy wrt handling of when the "
116  "'clear-the-event-store' event shall happen: at EndEvent "
117  "(default as it is makes things easier for memory management"
118  ") or at BeginEvent (easier e.g. for interactive use)");
119  declareProperty("PreSelectTools",m_tools,"AlgTools for event pre-selection")->
120  declareUpdateHandler( &AthenaMtesEventLoopMgr::setupPreSelectTools, this );
121 
122  declareProperty("SchedulerSvc", m_schedulerName="ForwardSchedulerSvc",
123  "Name of the scheduler to be used");
124 
125  declareProperty("WhiteboardSvc", m_whiteboardName="EventDataSvc",
126  "Name of the Whiteboard to be used");
127 
128  declareProperty("EventStore", m_eventStore);
129 
130  declareProperty("EvtIdModifierSvc", m_evtIdModSvc,
131  "ServiceHandle for EvtIdModifierSvc");
132 
133  declareProperty("FakeLumiBlockInterval", m_flmbi = 0,
134  "Event interval at which to increment lumiBlock# when "
135  "creating events without an EventSelector. Zero means "
136  "don't increment it");
137  declareProperty("FakeTimestampInterval", m_timeStampInt = 1,
138  "timestamp interval between events when creating Events "
139  "without an EventSelector");
140  declareProperty("RequireInputAttributeList", m_requireInputAttributeList = false,
141  "Require valid input attribute list to be present");
142  declareProperty("UseSecondaryEventNumber", m_useSecondaryEventNumber = false,
143  "In case of DoubleEventSelector use event number from secondary input");
144 
145  declareProperty("ESTestPilotMessages", m_testPilotMessages, "List of messages from fake pilot for test mode");
146 
147  m_scheduledStop = false;
148 
149 }
150 
152 {
153 }
154 
156 {
157  info() << "Initializing " << name() << endmsg;
158 
160  if(!sc.isSuccess()) {
161  error() << "Failed to initialize base class MinimalEventLoopMgr" << endmsg;
162  return sc;
163  }
164 
165 //-------------------------------------------------------------------------
166 // Setup stuff for hive
167 //-------------------------------------------------------------------------
168 
169  m_whiteboard = serviceLocator()->service(m_whiteboardName);
170  if(!m_whiteboard.isValid()) {
171  fatal() << "Error retrieving " << m_whiteboardName << " interface IHiveWhiteBoard." << endmsg;
172  return StatusCode::FAILURE;
173  }
174 
175  m_schedulerSvc = serviceLocator()->service(m_schedulerName);
176  if(!m_schedulerSvc.isValid()) {
177  fatal() << "Error retrieving SchedulerSvc interface ISchedulerSvc." << endmsg;
178  return StatusCode::FAILURE;
179  }
180 
181  m_algResourcePool = serviceLocator()->service("AlgResourcePool");
182  if(!m_algResourcePool.isValid()) {
183  fatal() << "Error retrieving AlgResourcePool" << endmsg;
184  return StatusCode::FAILURE;
185  }
186 
187  m_aess = serviceLocator()->service("AlgExecStateSvc");
188  if(!m_aess.isValid()) {
189  fatal() << "Error retrieving AlgExecStateSvc" << endmsg;
190  return StatusCode::FAILURE;
191  }
192 
193  ATH_CHECK(m_eventStore.retrieve());
194  ATH_CHECK(m_incidentSvc.retrieve());
195 
196 //--------------------------------------------------------------------------
197 // Access Property Manager interface:
198 //--------------------------------------------------------------------------
199  SmartIF<IProperty> prpMgr(serviceLocator());
200  if(!prpMgr.isValid()) {
201  fatal() << "IProperty interface not found in ApplicationMgr." << endmsg;
202  return StatusCode::FAILURE;
203  }
204 
205  ATH_CHECK(m_histoDataMgrSvc.retrieve());
206 
207  const std::string& histPersName(m_histPersName.value());
208  if(histPersName.empty()) {
209  ATH_CHECK(setProperty(prpMgr->getProperty("HistogramPersistency")));
210  }
211 
212  if(histPersName != "NONE") {
213 
214  m_histoPersSvc = IConversionSvc_t( "HistogramPersistencySvc",
215  this->name() );
216 
217  IService *is{nullptr};
218  sc = serviceLocator()->service("RootHistSvc", is);
219 
220  if (sc.isFailure()) {
221  error() << "could not locate actual Histogram persistency service" << endmsg;
222  }
223  else {
224  Service *s = dynamic_cast<Service*>(is);
225  if(!s) {
226  error() << "Could not dcast HistPersSvc to a Service" << endmsg;
227  }
228  else {
229  const Gaudi::Details::PropertyBase &prop = s->getProperty("OutputFile");
230  std::string val;
231  try {
232  const StringProperty &sprop = dynamic_cast<const StringProperty&>(prop);
233  val = sprop.value();
234  }
235  catch (...) {
236  verbose() << "could not dcast OutputFile property to a StringProperty."
237  << " Need to fix Gaudi."
238  << endmsg;
239 
240  val = prop.toString();
241  }
242 
243  if (val != ""
244  && val != "UndefinedROOTOutputFileName") {
245  m_writeHists = true;
246  }
247  }
248  }
249  }
250  else {
251  if (msgLevel(MSG::DEBUG)) {
252  debug() << "Histograms saving not required." << endmsg;
253  }
254  }
255 
256  //--------------------------------------------------------------------------
257  // Set up the EventID modifier Service
258  //--------------------------------------------------------------------------
259  if (m_evtIdModSvc.empty()) {
260  debug() << "EventID modifier Service not set. No run number, ... overrides "
261  "will "
262  "be applied."
263  << endmsg;
264  } else if (!m_evtIdModSvc.retrieve().isSuccess()) {
265  debug() << "Could not find EventID modifier Service. No run number, ... "
266  "overrides "
267  "will be applied."
268  << endmsg;
269  }
270 
271  //-------------------------------------------------------------------------
272  // Setup EventSelector service
273  //-------------------------------------------------------------------------
274  const std::string& selName(m_evtsel.value());
275  // the evt sel is usually specified as a property of ApplicationMgr
276  if (selName.empty()) {
277  sc = setProperty(prpMgr->getProperty("EvtSel"));
278  }
279  if (sc.isFailure()) {
280  warning() << "Unable to set EvtSel property" << endmsg;
281  }
282 
283  // We do not expect a Event Selector necessarily being declared
284  if( !selName.empty() && selName != "NONE") {
285  IEvtSelector* theEvtSel{nullptr};
286  sc = serviceLocator()->service(selName, theEvtSel);
287  if(sc.isSuccess() && (theEvtSel != m_evtSelector)) {
288  // Event Selector changed (or setup for the first time)
289  m_evtSelector = theEvtSel;
290 
291  // reset iterator
292  if (m_evtSelector->createContext(m_evtContext).isFailure()) {
293  fatal() << "Can not create the event selector Context." << endmsg;
294  return StatusCode::FAILURE;
295  }
296  if (msgLevel(MSG::INFO)) {
297  INamedInterface* named (dynamic_cast< INamedInterface* >(theEvtSel));
298  if (0 != named) {
299  info() << "Setup EventSelector service " << named->name( ) << endmsg;
300  }
301  }
302  }
303  else if (sc.isFailure()) {
304  fatal() << "No valid event selector called " << selName << endmsg;
305  return StatusCode::FAILURE;
306  }
307  }
308 
309 //-------------------------------------------------------------------------
310 // Setup 'Clear-Store' policy
311 //-------------------------------------------------------------------------
312  try {
314  } catch(...) {
315  return StatusCode::FAILURE;
316  }
317 
318  // Listen to the BeforeFork incident
319  m_incidentSvc->addListener(this,"BeforeFork",0);
320 
321  CHECK( m_conditionsCleaner.retrieve() );
322  CHECK( m_outSeqSvc.retrieve() );
323 
324  // Print if we override the event number using the one from secondary event
326  info() << "Using secondary event number." << endmsg;
327  }
328 
329  if( m_testPilotMessages.value().size() > 0 ) {
330  info() << "runnung in standalone TEST MODE" << endmsg;
331  info() << " test contains " << m_testPilotMessages.value().size() << " event ranges" << endmsg;
332  for( const std::string& range: m_testPilotMessages.value() ) {
333  debug() << " " << range << endmsg;
334  }
335  m_inTestMode = true;
336  }
337  return sc;
338 }
339 
340 inline
341 StoreGateSvc*
343  return m_eventStore.get();
344 }
345 
346 //=========================================================================
347 // property handlers
348 //=========================================================================
349 void
350 AthenaMtesEventLoopMgr::setClearStorePolicy(Gaudi::Details::PropertyBase&) {
351  const std::string& policyName = m_clearStorePolicy.value();
352 
353  if ( policyName != "BeginEvent" &&
354  policyName != "EndEvent" ) {
355 
356  fatal() << "Unknown policy [" << policyName
357  << "] for the 'ClearStore-policy !\n"
358  << " Valid values are: BeginEvent, EndEvent"
359  << endmsg;
360  throw GaudiException("Can not setup 'ClearStore'-policy",
361  name(),
362  StatusCode::FAILURE);
363  }
364 
365  return;
366 }
367 
368 void
369 AthenaMtesEventLoopMgr::setupPreSelectTools(Gaudi::Details::PropertyBase&) {
370 
371  m_toolInvoke.clear();
372  m_toolReject.clear();
373  m_toolAccept.clear();
374 
375  m_tools.retrieve().ignore();
376  if(m_tools.size() > 0) {
377  m_useTools=true;
378  m_toolInvoke.resize(m_tools.size());
379  m_toolReject.resize(m_tools.size());
380  m_toolAccept.resize(m_tools.size());
381 
382  tool_iterator firstTool = m_tools.begin();
383  tool_iterator lastTool = m_tools.end();
384  unsigned int toolCtr = 0;
385  for ( ; firstTool != lastTool; ++firstTool )
386  {
387  // reset statistics
388  m_toolInvoke[toolCtr] = 0;
389  m_toolReject[toolCtr] = 0;
390  m_toolAccept[toolCtr] = 0;
391  toolCtr++;
392  }
393  }
394 
395  return;
396 
397 }
398 
399 //=========================================================================
400 // implementation of IAppMgrUI::finalize
401 //=========================================================================
403 {
404 
406  if (sc.isFailure())
407  {
408  error() << "Error in Service base class Finalize"
409  << endmsg;
410  }
411 
412  StatusCode sc2 = writeHistograms(true);
413  if (sc2.isFailure())
414  {
415  error() << "Error in writing Histograms"
416  << endmsg;
417  }
418 
419  // Release all interfaces (ignore StatusCodes)
420  m_histoDataMgrSvc.release().ignore();
421  m_histoPersSvc.release().ignore();
422 
423  m_whiteboard = 0;
424  m_algResourcePool = 0;
425  m_schedulerSvc = 0;
426  // m_evtDataSvc = 0;
427 
428  m_incidentSvc.release().ignore();
429 
430  // Release event selector context
431  if ( m_evtSelector && m_evtContext ) {
432  m_evtSelector->releaseContext(m_evtContext).ignore();
433  // m_evtSelector = releaseInterface(m_evtSelector);
434  delete m_evtContext; m_evtContext = 0;
435  }
436 
437 
438  if(m_useTools) {
439  tool_iterator firstTool = m_tools.begin();
440  tool_iterator lastTool = m_tools.end();
441  unsigned int toolCtr = 0;
442  info() << "Summary of AthenaEvtLoopPreSelectTool invocation: (invoked/success/failure)" << endmsg;
443  info() << "-----------------------------------------------------" << endmsg;
444 
445  for ( ; firstTool != lastTool; ++firstTool ) {
446  info() << std::setw(2) << std::setiosflags(std::ios_base::right)
447  << toolCtr+1 << ".) " << std::resetiosflags(std::ios_base::right)
448  << std::setw(48) << std::setfill('.')
449  << std::setiosflags(std::ios_base::left)
450  << (*firstTool)->name() << std::resetiosflags(std::ios_base::left)
451  << std::setfill(' ')
452  << " ("
453  << std::setw(6) << std::setiosflags(std::ios_base::right)
454  << m_toolInvoke[toolCtr]
455  << "/"
456  << m_toolAccept[toolCtr]
457  << "/"
458  << m_toolReject[toolCtr]
459  << ")"
460  << endmsg;
461  toolCtr++;
462  }
463  }
464 
465  return ( sc.isFailure() || sc2.isFailure() ) ? StatusCode::FAILURE :
466  StatusCode::SUCCESS;
467 
468 }
469 
470 //=========================================================================
471 // write out the histograms
472 //=========================================================================
474 
475  StatusCode sc (StatusCode::SUCCESS);
476 
477  if ( 0 != m_histoPersSvc && m_writeHists ) {
478  std::vector<DataObject*> objects;
479  sc = m_histoDataMgrSvc->traverseTree( [&objects]( IRegistry* reg, int ) {
480  DataObject* obj = reg->object();
481  if ( !obj || obj->clID() == CLID_StatisticsFile ) return false;
482  objects.push_back( obj );
483  return true;
484  } );
485 
486  if ( !sc.isSuccess() ) {
487  error() << "Error while traversing Histogram data store" << endmsg;
488  return sc;
489  }
490 
491  if ( objects.size() > 0) {
492  int writeInterval(m_writeInterval.value());
493 
494  if ( m_nevt == 1 || force ||
495  (writeInterval != 0 && m_nevt%writeInterval == 0) ) {
496 
497  // skip /stat entry!
498  sc = std::accumulate( begin( objects ), end( objects ), sc, [&]( StatusCode isc, auto& i ) {
499  IOpaqueAddress* pAddr = nullptr;
500  StatusCode iret = m_histoPersSvc->createRep( i, pAddr );
501  if ( iret.isFailure() ) return iret;
502  i->registry()->setAddress( pAddr );
503  return isc;
504  } );
505  sc = std::accumulate( begin( objects ), end( objects ), sc, [&]( StatusCode isc, auto& i ) {
506  IRegistry* reg = i->registry();
507  StatusCode iret = m_histoPersSvc->fillRepRefs( reg->address(), i );
508  return iret.isFailure() ? iret : isc;
509  } );
510  if ( ! sc.isSuccess() ) {
511  error() << "Error while saving Histograms." << endmsg;
512  }
513  }
514 
515  if (force || (writeInterval != 0 && m_nevt%writeInterval == 0) ) {
516  if (msgLevel(MSG::DEBUG)) { debug() << "committing Histograms" << endmsg; }
517  m_histoPersSvc->conversionSvc()->commitOutput("",true).ignore();
518  }
519  }
520 
521  }
522 
523  return sc;
524 }
525 
526 //=========================================================================
527 // Call sysInitialize() on all algorithms and output streams
528 //=========================================================================
530 
531  return StatusCode::SUCCESS;
532 }
533 
534 //=========================================================================
535 // Run the algorithms for the current event
536 //=========================================================================
538 
539  return StatusCode::SUCCESS;
540 }
541 
542 
543 //=========================================================================
544 // executeEvent( EventContext &&ctx )
545 //=========================================================================
547 {
548 
549  // An incident may schedule a stop, in which case is better to exit before the actual execution.
550  if ( m_scheduledStop ) {
551  always() << "A stopRun was requested by an incidentListener. "
552  << "Do not process this event."
553  << endmsg;
554  m_terminateLoop = true;
555  return (StatusCode::SUCCESS);
556  }
557 
558  m_aess->reset( ctx );
559 
560  // Make sure context with slot is set before calling es->next().
561  Gaudi::Hive::setCurrentContext ( ctx );
562 
563  int declEvtRootSc = declareEventRootAddress(ctx);
564  if (declEvtRootSc == 0 ) { // We ran out of events!
565  m_terminateLoop = true; // we have finished!
566  return StatusCode::SUCCESS;
567  } else if ( declEvtRootSc == -1) {
568  error() << "declareEventRootAddress for context " << ctx << " failed"
569  << endmsg;
570  return StatusCode::FAILURE;
571  }
572 
573  EventID::event_number_t evtNumber = ctx.eventID().event_number();
574  unsigned int conditionsRun = ctx.eventID().run_number();
575  if (!m_evtIdModSvc.isSet()) {
576  const AthenaAttributeList* attr = nullptr;
577  if (eventStore()->contains<AthenaAttributeList>("Input") &&
578  eventStore()->retrieve(attr, "Input").isSuccess()) {
579  if (attr->exists("ConditionsRun")) {
580  conditionsRun = (*attr)["ConditionsRun"].data<unsigned int>();
581  }
582  }
583  }
585  Gaudi::Hive::setCurrentContext ( ctx );
586 
587  // Record EventContext in current whiteboard
588  if (eventStore()->record(std::make_unique<EventContext> (ctx),
589  "EventContext").isFailure())
590  {
591  error() << "Error recording event context object" << endmsg;
592  return (StatusCode::FAILURE);
593  }
594 
596  if (m_firstRun || (m_currentRun != ctx.eventID().run_number()) ) {
597  // Fire EndRun incident unless this is the first run
598  if (!m_firstRun) {
599  // FIXME!!!
600  m_incidentSvc->fireIncident(Incident(name(), IncidentType::EndRun));
601  }
602  m_firstRun=false;
603  m_currentRun = ctx.eventID().run_number();
604 
605  info() << " ===>>> start of run " << m_currentRun << " <<<==="
606  << endmsg;
607 
608  // FIXME!!! Fire BeginRun "Incident"
609  m_incidentSvc->fireIncident(Incident(name(),IncidentType::BeginRun,ctx));
610 
611  }
612 
613  bool toolsPassed=true;
614  // CGL: FIXME
615  // bool eventFailed = false;
616 
617  // Call any attached tools to reject events early
618  unsigned int toolCtr=0;
619  if(m_useTools) {
620  tool_store::iterator theTool = m_tools.begin();
621  tool_store::iterator lastTool = m_tools.end();
622  while(toolsPassed && theTool!=lastTool )
623  {
624  toolsPassed = (*theTool)->passEvent(ctx.eventID());
625  m_toolInvoke[toolCtr]++;
626  {toolsPassed ? m_toolAccept[toolCtr]++ : m_toolReject[toolCtr]++;}
627  ++toolCtr;
628  ++theTool;
629  }
630  }
631 
632  m_doEvtHeartbeat = (m_eventPrintoutInterval.value() > 0 &&
633  0 == (m_nev % m_eventPrintoutInterval.value()));
634  if (m_doEvtHeartbeat) {
635  if(!m_useTools)
636  info() << " ===>>> start processing event #" << evtNumber << ", run #" << m_currentRun
637  << " on slot " << ctx.slot() << ", " << m_proc
638  << " events processed so far <<<===" << endmsg;
639  else
640  info() << " ===>>> start processing event #" << evtNumber << ", run #" << m_currentRun
641  << " on slot " << ctx.slot() << ", "
642  << m_nev << " events read and " << m_proc
643  << " events processed so far <<<===" << endmsg;
644  }
645 
646  // Reset the timeout singleton
648  if(toolsPassed) {
649 
650  CHECK( m_conditionsCleaner->event (ctx, true) );
651 
652  // Remember the last event context for after event processing finishes.
653  m_lastEventContext = ctx;
654 
655  // Now add event to the scheduler
656  debug() << "Adding event " << ctx.evt()
657  << ", slot " << ctx.slot()
658  << " to the scheduler" << endmsg;
659 
660  m_incidentSvc->fireIncident(Incident(name(), IncidentType::BeginProcessing,
661  ctx));
662  StatusCode addEventStatus = m_schedulerSvc->pushNewEvent( new EventContext{ std::move(ctx) } );
663 
664  // If this fails, we need to wait for something to complete
665  if (!addEventStatus.isSuccess()){
666  fatal() << "An event processing slot should be now free in the scheduler, but it appears not to be the case." << endmsg;
667  }
668 
669  } // end of toolsPassed test
670 
671  ++m_nev;
672 
673  ++m_nevt;
674 
675  // invalidate thread local context once outside of event execute loop
676  Gaudi::Hive::setCurrentContext( EventContext() );
677 
678  return StatusCode::SUCCESS;
679 
680 }
681 
682 //=========================================================================
683 // implementation of IEventProcessor::executeRun
684 //=========================================================================
686 {
687  StatusCode sc = nextEvent(maxevt);
688  if (sc.isSuccess()) {
689  m_incidentSvc->fireIncident(Incident(name(),"EndEvtLoop"));
690  }
691  return sc;
692 }
693 
694 //-----------------------------------------------------------------------------
695 // Implementation of IEventProcessor::stopRun()
696 //-----------------------------------------------------------------------------
698  // Set the application return code
699  SmartIF<IProperty> appmgr(serviceLocator());
700  if(Gaudi::setAppReturnCode(appmgr, Gaudi::ReturnCode::ScheduledStop).isFailure()) {
701  error() << "Could not set return code of the application ("
702  << Gaudi::ReturnCode::ScheduledStop << ")" << endmsg;
703  }
704  m_scheduledStop = true;
705  return StatusCode::SUCCESS;
706 }
707 
708 
709 //-----------------------------------------------------------------------------
710 // Implementation of IService::stop()
711 //-----------------------------------------------------------------------------
713 {
714  // To enable conditions access during stop we set an invalid EventContext
715  // (no event/slot number) but with valid EventID (and extended EventContext).
716  m_lastEventContext.setValid(false);
717  Gaudi::Hive::setCurrentContext( m_lastEventContext );
718 
720 
721  // If we exit the event loop early due to an error, some event stores
722  // may not have been cleared. This can lead to segfaults later,
723  // as DetectorStore will usually get finalized before HiveSvcMgr.
724  // So make sure that all stores have been cleared at this point.
725  size_t nslot = m_whiteboard->getNumberOfStores();
726  for (size_t islot = 0; islot < nslot; islot++) {
727  sc &= clearWBSlot (islot);
728  }
729 
730  Gaudi::Hive::setCurrentContext( EventContext() );
731  return sc;
732 }
733 
734 
736 {
737  if(maxevt==0) return StatusCode::SUCCESS;
738 
739  yampl::ISocketFactory* socketFactory = new yampl::SocketFactory();
740  // Create a socket to communicate with the Pilot
741  m_socket = socketFactory->createClientSocket(yampl::Channel(m_eventRangeChannel.value(),yampl::LOCAL),
742  yampl::MOVE_DATA);
743 
744  // Reset the application return code.
746 
747  int finishedEvts =0;
748  int createdEvts =0;
749  info() << "Starting loop on events" << endmsg;
750 
751  StatusCode sc(StatusCode::SUCCESS);
752 
753  // Calculate runtime
754  auto start_time = tbb::tick_count::now();
755  auto secsFromStart = [&start_time]()->double{
756  return (tbb::tick_count::now()-start_time).seconds();
757  };
758 
759  std::unique_ptr<RangeStruct> range;
760  while(!range) {
762  usleep(1000);
763  }
764 
765  bool loop_ended = range->eventRangeID.empty();
766  if(!loop_ended) {
767  m_currentEvntNum = range->startEvent;
768  // Fire NextRange incident
769  m_incidentSvc->fireIncident(FileIncident(name(), "NextEventRange",range->eventRangeID));
770  }
771 
772  bool no_more_events = false;
773 
774  while(!loop_ended) {
775 
776  debug() << " -> createdEvts: " << createdEvts << endmsg;
777 
778  if(!m_terminateLoop // No scheduled loop termination
779  && !no_more_events // We are not yet done getting events
780  && m_schedulerSvc->freeSlots()>0) { // There are still free slots in the scheduler
781 
782  debug() << "createdEvts: " << createdEvts << ", freeslots: " << m_schedulerSvc->freeSlots() << endmsg;
783 
784  auto ctx = createEventContext();
785 
786  if ( !ctx.valid() ) {
787  sc = StatusCode::FAILURE;
788  }
789  else {
790  sc = executeEvent( std::move(ctx) );
791  }
792 
793  if (sc.isFailure()) {
794  error() << "Terminating event processing loop due to errors" << endmsg;
795  loop_ended = true;
796  }
797  else {
798  ++createdEvts;
799  if(++m_currentEvntNum > range->lastEvent) {
800  // Fetch next event range
801  range.reset();
802  while(!range) {
804  usleep(1000);
805  }
806  if(range->eventRangeID.empty()) {
807  no_more_events = true;
808  }
809  else {
810  m_currentEvntNum = range->startEvent;
811  // Fire NextRange incident
812  m_incidentSvc->fireIncident(FileIncident(name(), "NextEventRange",range->eventRangeID));
813  }
814  }
815  }
816  }
817  else {
818  // all the events were created but not all finished or the slots were
819  // all busy: the scheduler should finish its job
820 
821  debug() << "Draining the scheduler" << endmsg;
822 
823  // Pull out of the scheduler the finished events
824  int ir = drainScheduler(finishedEvts,true);
825  if(ir < 0) {
826  // some sort of error draining scheduler;
827  loop_ended = true;
828  sc = StatusCode::FAILURE;
829  }
830  else if(ir == 0) {
831  // no more events in scheduler
832  if(no_more_events) {
833  // We are done
834  loop_ended = true;
835  sc = StatusCode::SUCCESS;
836  }
837  }
838  else {
839  // keep going!
840  }
841  }
842  } // end main loop on finished events
843 
844  info() << "---> Loop Finished (seconds): " << secsFromStart() <<endmsg;
845 
846  delete m_socket;
847  m_socket=nullptr;
848  delete socketFactory;
849  return sc;
850 }
851 
852 
853 //=========================================================================
854 // Seek to a given event.
855 // The event selector must support the IEventSeek interface for this to work.
856 //=========================================================================
858 {
859  IEvtSelectorSeek* is = dynamic_cast<IEvtSelectorSeek*> (m_evtSelector);
860  if (is == 0) {
861  error() << "Seek failed; unsupported by event selector"
862  << endmsg;
863  return StatusCode::FAILURE;
864  }
865  //cppcheck-suppress nullPointerRedundantCheck
866  if (!m_evtContext) {
867  if (m_evtSelector->createContext(m_evtContext).isFailure()) {
868  fatal() << "Can not create the event selector Context."
869  << endmsg;
870  return StatusCode::FAILURE;
871  }
872  }
873  //m_evtContext cannot be null if createContext succeeded
874  //cppcheck-suppress nullPointerRedundantCheck
875  StatusCode sc = is->seek (*m_evtContext, evt);
876  if (sc.isSuccess()) {
877  m_nevt = evt;
878  }
879  else {
880  error() << "Seek failed." << endmsg;
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 == 0) {
901  error() << "Collection size unsupported by event selector"
902  << endmsg;
903  return -1;
904  }
905  //cppcheck-suppress nullPointerRedundantCheck
906  if (!m_evtContext) {
907  if (m_evtSelector->createContext(m_evtContext).isFailure()) {
908  fatal() << "Can not create the event selector Context."
909  << endmsg;
910  return -1;
911  }
912  }
913  //cppcheck-suppress nullPointerRedundantCheck
914  return cs->size (*m_evtContext);
915 }
916 
917 //=========================================================================
918 // Handle Incidents
919 //=========================================================================
920 void AthenaMtesEventLoopMgr::handle(const Incident& inc)
921 {
922 
923  if(inc.type()!="BeforeFork")
924  return;
925 
926  if(!m_evtContext || !m_firstRun) {
927  warning() << "Skipping BeforeFork handler. Either no event selector is provided or begin run has already passed" << endmsg;
928  }
929 
930  // Initialize Algorithms and Output Streams
932  if(sc.isFailure()) {
933  error() << "Failed to initialize Algorithms" << endmsg;
934  return;
935  }
936 
937  // Construct EventInfo
938  const EventInfo* pEvent(0);
939  IOpaqueAddress* addr = 0;
940  sc = m_evtSelector->next(*m_evtContext);
941  if(!sc.isSuccess()) {
942  info() << "No more events in event selection " << endmsg;
943  return;
944  }
945  sc = m_evtSelector->createAddress(*m_evtContext, addr);
946  if (sc.isFailure()) {
947  error() << "Could not create an IOpaqueAddress" << endmsg;
948  return;
949  }
950  if (0 != addr) {
951  //create its proxy
952  sc = eventStore()->recordAddress(addr);
953  if(!sc.isSuccess()) {
954  error() << "Error declaring Event object" << endmsg;
955  return;
956  }
957  }
958 
959  if(eventStore()->loadEventProxies().isFailure()) {
960  warning() << "Error loading Event proxies" << endmsg;
961  return;
962  }
963 
964  // Retrieve the Event object
965  sc = eventStore()->retrieve(pEvent);
966  if(!sc.isSuccess()) {
967  error() << "Unable to retrieve Event root object" << endmsg;
968  return;
969  }
970 
971  m_firstRun=false;
972  m_currentRun = pEvent->event_ID()->run_number();
973 
974  // Clear Store
975  const ClearStorePolicy::Type s_clearStore = clearStorePolicy( m_clearStorePolicy.value(), msgStream() );
976  if(s_clearStore==ClearStorePolicy::EndEvent) {
977  sc = eventStore()->clearStore();
978  if(!sc.isSuccess()) {
979  error() << "Clear of Event data store failed" << endmsg;
980  }
981  }
982 }
983 
984 // Query the interfaces.
985 // Input: riid, Requested interface ID
986 // ppvInterface, Pointer to requested interface
987 // Return: StatusCode indicating SUCCESS or FAILURE.
988 // N.B. Don't forget to release the interface after use!!!
989 StatusCode
990 AthenaMtesEventLoopMgr::queryInterface(const InterfaceID& riid,
991  void** ppvInterface)
992 {
993  if ( IEventSeek::interfaceID().versionMatch(riid) ) {
994  *ppvInterface = dynamic_cast<IEventSeek*>(this);
995  }
996  else if ( IEventProcessor::interfaceID().versionMatch(riid) ) {
997  *ppvInterface = dynamic_cast<IEventProcessor*>(this);
998  }
999  else if ( ICollectionSize::interfaceID().versionMatch(riid) ) {
1000  *ppvInterface = dynamic_cast<ICollectionSize*>(this);
1001  } else {
1002  // Interface is not directly available : try out a base class
1003  return MinimalEventLoopMgr::queryInterface(riid, ppvInterface);
1004  }
1005  addRef();
1006  return StatusCode::SUCCESS;
1007 }
1008 
1009 //---------------------------------------------------------------------------
1010 
1013  refpAddr = 0;
1015  if ( !sc.isSuccess() ) {
1016  return sc;
1017  }
1018  // Create root address and assign address to data service
1019  sc = m_evtSelector->createAddress(*m_evtContext,refpAddr);
1020  if( !sc.isSuccess() ) {
1021  sc = m_evtSelector->next(*m_evtContext);
1022  if ( sc.isSuccess() ) {
1023  sc = m_evtSelector->createAddress(*m_evtContext,refpAddr);
1024  if ( !sc.isSuccess() ) {
1025  warning() << "Error creating IOpaqueAddress." << endmsg;
1026  }
1027  }
1028  }
1029  return sc;
1030 }
1031 
1032 //---------------------------------------------------------------------------
1033 
1035 
1036  // return codes:
1037  // -1 : error
1038  // 0 : no more events in selection
1039  // 1 : ok
1040 
1041  StatusCode sc(StatusCode::SUCCESS);
1042 
1043  //-----------------------------------------------------------------------
1044  // we need an EventInfo Object to fire the incidents.
1045  //-----------------------------------------------------------------------
1046  std::unique_ptr<const EventInfo> pEvent;
1047  if ( m_evtContext ) {
1048  // Deal with the case when an EventSelector is provided
1049 
1050  //
1051  // FIXME: flow control if no more events in selector, etc.
1052  //
1053 
1054  IOpaqueAddress* addr = 0;
1055 
1056  IEvtSelectorSeek* is = dynamic_cast<IEvtSelectorSeek*> (m_evtSelector);
1057  if (is == 0) {
1058  error() << "Seek failed; unsupported by event selector" << endmsg;
1059  return 0;
1060  }
1061 
1062  sc = is->seek (*m_evtContext, m_currentEvntNum-1);
1063  if(sc.isFailure()) {
1064  error() << "Seek failed to Evt=" << m_currentEvntNum-1 << endmsg;
1065  return 0;
1066  }
1067 
1068  sc = m_evtSelector->next(*m_evtContext);
1069 
1070  if ( !sc.isSuccess() ) {
1071  // This is the end of the loop. No more events in the selection
1072  info() << "No more events in event selection " << endmsg;
1073  return 0;
1074  }
1075 
1076  if (m_evtSelector->createAddress(*m_evtContext, addr).isFailure()) {
1077  error() << "Could not create an IOpaqueAddress" << endmsg;
1078  return -1;
1079  }
1080 
1081 
1082  // Most iterators provide the IOA of an event header (EventInfo, DataHeader)
1083  if (0 != addr) {
1084  //create its proxy
1085  sc = eventStore()->recordAddress(addr);
1086  if( !sc.isSuccess() ) {
1088  warning() << "Error declaring Event object" << endmsg;
1089  return 0;
1090  }
1091  } if ((sc=eventStore()->loadEventProxies()).isFailure()) {
1092  error() << "Error loading Event proxies" << endmsg;
1093  return -1;
1094  }
1095  bool consume_modifier_stream = false;
1096  // Read the attribute list
1097  const AthenaAttributeList* pAttrList = eventStore()->tryConstRetrieve<AthenaAttributeList>("Input");
1098  if ( pAttrList != nullptr && pAttrList->size() > 6 ) { // Try making EventID-only EventInfo object from in-file TAG
1099  try {
1100  unsigned int runNumber = (*pAttrList)["RunNumber"].data<unsigned int>();
1101  unsigned long long eventNumber = (*pAttrList)["EventNumber"].data<unsigned long long>();
1102  unsigned int eventTime = (*pAttrList)["EventTime"].data<unsigned int>();
1103  unsigned int eventTimeNS = (*pAttrList)["EventTimeNanoSec"].data<unsigned int>();
1104  unsigned int lumiBlock = (*pAttrList)["LumiBlockN"].data<unsigned int>();
1105  unsigned int bunchId = (*pAttrList)["BunchId"].data<unsigned int>();
1106 
1107  consume_modifier_stream = true;
1108  // an option to override primary eventNumber with the secondary one in case of DoubleEventSelector
1109  if ( m_useSecondaryEventNumber ) {
1110  unsigned long long eventNumberSecondary{};
1111  if ( !(pAttrList->exists("hasSecondaryInput") && (*pAttrList)["hasSecondaryInput"].data<bool>()) ) {
1112  fatal() << "Secondary EventNumber requested, but secondary input does not exist!" << endmsg;
1113  return -1;
1114  }
1115  if ( pAttrList->exists("EventNumber_secondary") ) {
1116  eventNumberSecondary = (*pAttrList)["EventNumber_secondary"].data<unsigned long long>();
1117  }
1118  else {
1119  // try legacy EventInfo if secondary input did not have attribute list
1120  // primary input should not have this EventInfo type
1121  const EventInfo* pEventSecondary = eventStore()->tryConstRetrieve<EventInfo>();
1122  if (pEventSecondary) {
1123  eventNumberSecondary = pEventSecondary->event_ID()->event_number();
1124  }
1125  else {
1126  fatal() << "Secondary EventNumber requested, but it does not exist!" << endmsg;
1127  return -1;
1128  }
1129  }
1130  if (eventNumberSecondary != 0) {
1131  if (m_doEvtHeartbeat) {
1132  info() << " ===>>> using secondary event #" << eventNumberSecondary << " instead of #" << eventNumber << "<<<===" << endmsg;
1133  }
1134  eventNumber = eventNumberSecondary;
1135  }
1136  }
1137 
1138  // never recorded in the eventStore
1139  pEvent = std::make_unique<EventInfo>(
1140  new EventID(runNumber, eventNumber, eventTime, eventTimeNS,
1141  lumiBlock, bunchId),
1142  nullptr);
1143  } catch (...) {
1144  }
1145  } else if (m_requireInputAttributeList) {
1146  fatal() << "Valid input attribute list required but not present!";
1147  return -1;
1148  }
1149 
1150  const EventInfo* pEventObserver{pEvent.get()};
1151  if (!pEventObserver) {
1152  // Retrieve the Event object
1153  pEventObserver = eventStore()->tryConstRetrieve<EventInfo>();
1154  if( !pEventObserver ) {
1155 
1156  // Try to get the xAOD::EventInfo
1157  const xAOD::EventInfo* pXEvent{nullptr};
1158  sc = eventStore()->retrieve(pXEvent);
1159  if( !sc.isSuccess() ) {
1160  error() << "Unable to retrieve Event root object" << endmsg;
1161  return -1;
1162  }
1163  consume_modifier_stream = true;
1164  // Build the old-style Event Info object for those clients that still need it
1165  pEvent = std::make_unique<EventInfo>(
1166  new EventID(eventIDFromxAOD(pXEvent)),
1167  new EventType(eventTypeFromxAOD(pXEvent)));
1168  pEventObserver = pEvent.get();
1169  sc = eventStore()->record(std::move(pEvent), "");
1170  if( !sc.isSuccess() ) {
1171  error() << "Error declaring event data object" << endmsg;
1172  return -1;
1173  }
1174  } else {
1175  consume_modifier_stream = false;
1176  }
1177  }
1178 
1179  // the pEvent was moved to the eventStore, the object is still 'alive'.
1180  // so the raw pEventObserver pointer is also still valid
1181  // cppcheck-suppress invalidLifetime
1182  modifyEventContext(ctx, *(pEventObserver->event_ID()),
1183  consume_modifier_stream);
1184 
1185  } else {
1186 
1187  // with no iterator it's up to us to create an EventInfo
1188  // first event # == 1
1189  unsigned int runNmb{1}, evtNmb{m_nevt + 1};
1190 
1191  // increment the run/lumiBlock number if desired
1192  if (m_flmbi != 0) {
1193  runNmb = m_nevt / m_flmbi + 1;
1194  evtNmb = m_nevt % m_flmbi + 1;
1195  }
1196  auto eid = std::make_unique<EventID> (runNmb,evtNmb, m_timeStamp);
1197  // Change lumiBlock# to match runNumber
1198  eid->set_lumi_block( runNmb );
1199 
1201 
1202  pEvent = std::make_unique<EventInfo>(eid.release(), new EventType());
1203 
1204  modifyEventContext(ctx,*(pEvent->event_ID()), true);
1205 
1206  debug() << "selecting store: " << ctx.slot() << endmsg;
1207 
1208  m_whiteboard->selectStore( ctx.slot() ).ignore();
1209 
1210  debug() << "recording EventInfo " << *pEvent->event_ID() << " in "
1211  << eventStore()->name() << endmsg;
1212  sc = eventStore()->record(std::move(pEvent), "McEventInfo");
1213  if( !sc.isSuccess() ) {
1214  error() << "Error declaring event data object" << endmsg;
1215  return -1;
1216  }
1217  }
1218  return 1;
1219 }
1220 
1221 //---------------------------------------------------------------------------
1223  const EventID& eID,
1224  bool consume_modifier_stream) {
1225 
1226  if (m_evtIdModSvc.isSet()) {
1227  EventID new_eID(eID);
1228  // In Mtes EventLoopMgr ctx.evt() gets set to m_nevt and *then* m_nevt is
1229  // incremented later so it's zero-indexed and we don't need to subtract one
1230  m_evtIdModSvc->modify_evtid(new_eID, ctx.evt(), consume_modifier_stream);
1231  if (msgLevel(MSG::DEBUG)) {
1232  unsigned int oldrunnr = eID.run_number();
1233  unsigned int oldLB = eID.lumi_block();
1234  unsigned int oldTS = eID.time_stamp();
1235  unsigned int oldTSno = eID.time_stamp_ns_offset();
1236  debug() << "modifyEventContext: use evtIdModSvc runnr=" << oldrunnr
1237  << " -> " << new_eID.run_number() << endmsg;
1238  debug() << "modifyEventContext: use evtIdModSvc LB=" << oldLB << " -> "
1239  << new_eID.lumi_block() << endmsg;
1240  debug() << "modifyEventContext: use evtIdModSvc TimeStamp=" << oldTS
1241  << " -> " << new_eID.time_stamp() << endmsg;
1242  debug() << "modifyEventContext: use evtIdModSvc TimeStamp ns Offset="
1243  << oldTSno << " -> " << new_eID.time_stamp_ns_offset() << endmsg;
1244  }
1245  ctx.setEventID(new_eID);
1247  ctx.eventID().run_number());
1248  return;
1249  }
1250 
1251  ctx.setEventID(eID);
1252 }
1253 
1254 //---------------------------------------------------------------------------
1256 
1257  EventContext ctx{ m_nevt, m_whiteboard->allocateStore( m_nevt ) };
1258 
1259  StatusCode sc = m_whiteboard->selectStore( ctx.slot() );
1260  if (sc.isFailure()) {
1261  fatal() << "Slot " << ctx.slot()
1262  << " could not be selected for the WhiteBoard" << endmsg;
1263  return EventContext{}; // invalid EventContext
1264  } else {
1266 
1267  debug() << "created EventContext, num: " << ctx.evt() << " in slot: "
1268  << ctx.slot() << endmsg;
1269  }
1270 
1271  return ctx;
1272 }
1273 
1275 {
1276  Gaudi::setAppReturnCode(m_appMgrProperty, Gaudi::ReturnCode::Success, true).ignore();
1277 }
1278 
1281 }
1282 
1284  return m_terminateLoop;
1285 }
1286 //---------------------------------------------------------------------------
1287 
1288 int
1290 
1291  StatusCode sc(StatusCode::SUCCESS);
1292 
1293  // maybe we can do better
1294  std::vector<EventContext*> finishedEvtContexts;
1295 
1296  EventContext* finishedEvtContext(nullptr);
1297 
1298  // Here we wait not to loose cpu resources
1299  debug() << "drainScheduler: [" << finishedEvts << "] Waiting for a context" << endmsg;
1300  sc = m_schedulerSvc->popFinishedEvent(finishedEvtContext);
1301 
1302  // We got past it: cache the pointer
1303  if (sc.isSuccess()){
1304  debug() << "drainScheduler: scheduler not empty: Context "
1305  << finishedEvtContext << endmsg;
1306  finishedEvtContexts.push_back(finishedEvtContext);
1307  } else{
1308  // no more events left in scheduler to be drained
1309  debug() << "drainScheduler: scheduler empty" << endmsg;
1310  return 0;
1311  }
1312 
1313  // Let's see if we can pop other event contexts
1314  while (m_schedulerSvc->tryPopFinishedEvent(finishedEvtContext).isSuccess()){
1315  finishedEvtContexts.push_back(finishedEvtContext);
1316  }
1317 
1318  // Now we flush them
1319  bool fail(false);
1320  for (auto& thisFinishedEvtContext : finishedEvtContexts){
1321  if (!thisFinishedEvtContext) {
1322  fatal() << "Detected nullptr ctxt while clearing WB!"<< endmsg;
1323  fail = true;
1324  continue;
1325  }
1326 
1327  if (m_aess->eventStatus(*thisFinishedEvtContext) != EventStatus::Success) {
1328  fatal() << "Failed event detected on " << thisFinishedEvtContext
1329  << " w/ fail mode: "
1330  << m_aess->eventStatus(*thisFinishedEvtContext) << endmsg;
1331  delete thisFinishedEvtContext;
1332  fail = true;
1333  continue;
1334  }
1335 
1336  EventID::number_type n_run(0);
1337  EventID::event_number_t n_evt(0);
1338 
1339  if (m_whiteboard->selectStore(thisFinishedEvtContext->slot()).isSuccess()) {
1340  n_run = thisFinishedEvtContext->eventID().run_number();
1341  n_evt = thisFinishedEvtContext->eventID().event_number();
1342  } else {
1343  error() << "DrainSched: unable to select store "
1344  << thisFinishedEvtContext->slot() << endmsg;
1345  delete thisFinishedEvtContext;
1346  fail = true;
1347  continue;
1348  }
1349 
1350  // m_incidentSvc->fireIncident(Incident(name(), IncidentType::EndEvent,
1351  // *thisFinishedEvtContext ));
1352 
1353  // Some code still needs global context in addition to that passed in the incident
1354  Gaudi::Hive::setCurrentContext( *thisFinishedEvtContext );
1355  info() << "Firing EndProcessing" << endmsg;
1356  m_incidentSvc->fireIncident(Incident(name(), IncidentType::EndProcessing, *thisFinishedEvtContext ));
1357 
1358  if(report) {
1359  // If we completed an event range, then report it to the pilot
1360  OutputStreamSequencerSvc::RangeReport_ptr rangeReport = m_outSeqSvc->getRangeReport();
1361  if(rangeReport) {
1362  std::string outputFileReport = rangeReport->second + std::string(",ID:")
1363  + rangeReport->first + std::string(",CPU:N/A,WALL:N/A");
1364  if( not m_inTestMode ) {
1365  // In standalone test mode there is no pilot to talk to
1366  void* message2pilot = malloc(outputFileReport.size());
1367  memcpy(message2pilot,outputFileReport.data(),outputFileReport.size());
1368  m_socket->send(message2pilot,outputFileReport.size());
1369  }
1370  info() << "Reported the output " << outputFileReport << endmsg;
1371  }
1372  }
1373 
1374  debug() << "Clearing slot " << thisFinishedEvtContext->slot()
1375  << " (event " << thisFinishedEvtContext->evt()
1376  << ") of the whiteboard" << endmsg;
1377 
1378  StatusCode sc = clearWBSlot(thisFinishedEvtContext->slot());
1379  if (!sc.isSuccess()) {
1380  error() << "Whiteboard slot " << thisFinishedEvtContext->slot()
1381  << " could not be properly cleared";
1382  fail = true;
1383  delete thisFinishedEvtContext;
1384  continue;
1385  }
1386 
1387  finishedEvts++;
1388 
1389  writeHistograms().ignore();
1390  ++m_proc;
1391 
1392  if (m_doEvtHeartbeat) {
1393  if(!m_useTools)
1394  info() << " ===>>> done processing event #" << n_evt << ", run #" << n_run
1395  << " on slot " << thisFinishedEvtContext->slot() << ", "
1396  << m_proc << " events processed so far <<<===" << endmsg;
1397  else
1398  info() << " ===>>> done processing event #" << n_evt << ", run #" << n_run
1399  << " on slot " << thisFinishedEvtContext->slot() << ", "
1400  << m_nev << " events read and " << m_proc
1401  << " events processed so far <<<===" << endmsg;
1402  std::ofstream outfile( "eventLoopHeartBeat.txt");
1403  if ( !outfile ) {
1404  error() << " unable to open: eventLoopHeartBeat.txt" << endmsg;
1405  fail = true;
1406  delete thisFinishedEvtContext;
1407  continue;
1408  } else {
1409  outfile << " done processing event #" << n_evt << ", run #" << n_run
1410  << " " << m_nev << " events read so far <<<===" << std::endl;
1411  outfile.close();
1412  }
1413  }
1414 
1415  debug() << "drainScheduler thisFinishedEvtContext: " << thisFinishedEvtContext
1416  << endmsg;
1417 
1418  delete thisFinishedEvtContext;
1419  }
1420 
1421  return ( fail ? -1 : 1 );
1422 
1423 }
1424 
1425 //---------------------------------------------------------------------------
1426 
1428  StatusCode sc = m_whiteboard->clearStore(evtSlot);
1429  if( !sc.isSuccess() ) {
1430  warning() << "Clear of Event data store failed" << endmsg;
1431  }
1432  return m_whiteboard->freeStore(evtSlot);
1433 }
1434 //---------------------------------------------------------------------------
1435 
1436 std::unique_ptr<AthenaMtesEventLoopMgr::RangeStruct> AthenaMtesEventLoopMgr::getNextRange(yampl::ISocket* socket)
1437 {
1438  static const std::string strReady("Ready for events");
1439  static const std::string strStopProcessing("No more events");
1440 
1441  std::string range;
1442  if( m_inTestMode ) {
1443  static std::atomic<size_t> line_n = 0;
1444  info() <<"in TEST MODE, Range #" << line_n+1 << endmsg;
1445  range = (line_n < m_testPilotMessages.value().size()) ? m_testPilotMessages.value()[line_n++] : strStopProcessing;
1446  } else {
1447  // Signal the Pilot that we are ready for event processing
1448  void* ready_message = malloc(strReady.size());
1449  memcpy(ready_message,strReady.data(),strReady.size());
1450  socket->send(ready_message,strReady.size());
1451  void* eventRangeMessage;
1452  std::string strPeerId;
1453  ssize_t eventRangeSize = socket->recv(eventRangeMessage,strPeerId);
1454  range = std::string((const char*)eventRangeMessage,eventRangeSize);
1455  leftString(range, '\n');
1456  }
1457 
1458  std::unique_ptr<RangeStruct> result = std::make_unique<RangeStruct>();
1459  if(range.compare(strStopProcessing)==0) {
1460  info() << "No more events from the server" << endmsg;
1461  return result;
1462  }
1463  info() << "Got Event Range from the pilot: " << range << endmsg;
1464 
1465  // _____________________ Decode range string _____________________________
1466  // Expected the following format: [{KEY:VALUE[,KEY:VALUE]}]
1467  // First get rid of the leading '[{' and the trailing '}]'
1468  if(CxxUtils::starts_with (range, "[{")) range=range.substr(2);
1469  if(CxxUtils::ends_with (range, "}]")){
1470  const int truncate = range.size()-2;
1471  leftString(range, truncate);
1472  }
1473 
1474  std::map<std::string,std::string> eventRangeMap;
1475  size_t startpos(0);
1476  size_t endpos = range.find(',');
1477  while(endpos!=std::string::npos) {
1478  // Get the Key-Value pair
1479  std::string keyValue(range.substr(startpos,endpos-startpos));
1480  size_t colonPos = keyValue.find(':');
1481  std::string strKey = keyValue.substr(0,colonPos);
1482  std::string strVal = keyValue.substr(colonPos+1);
1483  trimRangeStrings(strKey);
1484  trimRangeStrings(strVal);
1485  eventRangeMap[strKey]=strVal;
1486 
1487  // Next iteration
1488  startpos = endpos+1;
1489  endpos = range.find(',',startpos);
1490  }
1491 
1492  // Get the final Key-Value pair
1493  std::string keyValue(range.substr(startpos));
1494  size_t colonPos = keyValue.find(':');
1495  std::string strKey = keyValue.substr(0,colonPos);
1496  std::string strVal = keyValue.substr(colonPos+1);
1497  trimRangeStrings(strKey);
1498  trimRangeStrings(strVal);
1499  eventRangeMap[strKey]=strVal;
1500 
1501  // _____________________ Consistency check for range string _____________________________
1502  // Three checks are performed:
1503  // 1. The existence of all required fields
1504  // 2. The consistency of field values
1505  // 3. Protection against having event ranges from different input files
1506  // NB. The last check is hopefully a temporary limitation of MTES
1507  std::string errorStr{""};
1508 
1509  if(eventRangeMap.find("eventRangeID")==eventRangeMap.end()
1510  || eventRangeMap.find("startEvent")==eventRangeMap.end()
1511  || eventRangeMap.find("lastEvent")==eventRangeMap.end()
1512  || eventRangeMap.find("PFN")==eventRangeMap.end()) {
1513  // Wrong format
1514  errorStr = "ERR_ATHENAMP_PARSE \"" + range + "\": Wrong format";
1515  }
1516 
1517  if(errorStr.empty()) {
1518  result->startEvent = std::atoi(eventRangeMap["startEvent"].c_str());
1519  result->lastEvent = std::atoi(eventRangeMap["lastEvent"].c_str());
1520 
1521  if(eventRangeMap["eventRangeID"].empty()
1522  || eventRangeMap["PFN"].empty()
1523  || result->lastEvent < result->startEvent) {
1524  // Wrong values of range fields
1525  errorStr = "ERR_ATHENAMP_PARSE \"" + range + "\": Wrong values of range fields";
1526  }
1527  else {
1528  // Update m_pfn if necessary
1529  if(m_pfn != eventRangeMap["PFN"]) {
1530  IProperty* propertyServer = dynamic_cast<IProperty*>(m_evtSelector);
1531  if(!propertyServer) {
1532  errorStr = "ERR_ATHENAMP_PARSE \"" + range + "\": Unable to dyn-cast the event selector to IProperty";
1533  }
1534  else {
1535  std::string strInpuCol("InputCollections");
1536  std::vector<std::string> vectInpCol{eventRangeMap["PFN"],};
1537  StringArrayProperty inputFileList(strInpuCol, vectInpCol);
1538  if(propertyServer->setProperty(inputFileList).isFailure()) {
1539  errorStr = "ERR_ATHENAMP_PARSE \"" + range + "\": Unable to set input file name property to the Event Selector";
1540  }
1541  else {
1542  m_pfn = eventRangeMap["PFN"];
1543  }
1544  }
1545  }
1546  }
1547  }
1548 
1549  if(errorStr.empty()) {
1550  // Event range parsing was successful
1551  debug() << "*** Decoded Event Range ***" << endmsg;
1552  for (const auto& fieldvalue : eventRangeMap) {
1553  debug() << fieldvalue.first << ":" << fieldvalue.second << endmsg;
1554  }
1555 
1556  result->eventRangeID = eventRangeMap["eventRangeID"];
1557  result->pfn = eventRangeMap["PFN"];
1558  }
1559  else {
1560  // We got here because there was an error
1561  // Report the error to the pilot and reset the result, so that the next range can be tried
1562  warning() << errorStr << endmsg;
1563  info() << "Ignoring this event range" << endmsg;
1564  if( not m_inTestMode ) {
1565  void* errorMessage = malloc(errorStr.size());
1566  memcpy(errorMessage,errorStr.data(),errorStr.size());
1567  socket->send(errorMessage,errorStr.size());
1568  }
1569  result.reset();
1570  }
1571 
1572  return result;
1573 }
1574 
1576 {
1577  size_t i(0);
1578  // get rid of leading spaces
1579  while(i<str.size() && str[i]==' ') i++;
1580  if(i) str = str.substr(i);
1581 
1582  if(str.empty()) return; // Corner case: string consists only of spaces
1583 
1584  // get rid of trailing spaces
1585  i=str.size()-1;
1586  while(str[i]==' ') i--;
1587  if(i) str.resize(i+1);
1588 
1589  // the string might be enclosed by either
1590  // "u\'" and "\'"
1591  // or
1592  // "\"" and "\""
1593  // Get rid of them!
1594  if(CxxUtils::starts_with (str, "u\'")) {
1595  str = str.substr(2);
1596  if(str.rfind('\'')==str.size()-1) {
1597  str.pop_back();
1598  }
1599  }
1600  else if(CxxUtils::starts_with (str, "\"")) {
1601  str = str.substr(1);
1602  if(str.rfind('\"')==str.size()-1) {
1603  str.pop_back();
1604  }
1605  }
1606 }
grepfile.info
info
Definition: grepfile.py:38
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
AthenaMtesEventLoopMgr::m_requireInputAttributeList
bool m_requireInputAttributeList
require input attribute list
Definition: AthenaMtesEventLoopMgr.h:124
StoreGateSvc::record
StatusCode record(T *p2BRegistered, const TKEY &key)
Record an object with a key.
AthenaMtesEventLoopMgr::m_writeInterval
UnsignedIntegerProperty m_writeInterval
Definition: AthenaMtesEventLoopMgr.h:239
ClearStorePolicy::EndEvent
@ EndEvent
Definition: ClearStorePolicy.h:15
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:53
AthenaMtesEventLoopMgr::m_tools
tool_store m_tools
internal tool store
Definition: AthenaMtesEventLoopMgr.h:113
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
CxxUtils::starts_with
bool starts_with(const char *s, const char *prefix)
Test whether one null-terminated byte string starts with another.
get_generator_info.result
result
Definition: get_generator_info.py:21
AthenaMtesEventLoopMgr::executeRun
virtual StatusCode executeRun(int maxevt) override
implementation of IEventProcessor::executeRun(int maxevt)
Definition: AthenaMtesEventLoopMgr.cxx:685
AthenaMtesEventLoopMgr::m_evtContext
EvtContext * m_evtContext
Gaudi event selector Context (may be used as a cursor by the evt selector)
Definition: AthenaMtesEventLoopMgr.h:73
LArConditions2Ntuple.objects
objects
Definition: LArConditions2Ntuple.py:56
AthenaMtesEventLoopMgr::m_nevt
unsigned int m_nevt
Definition: AthenaMtesEventLoopMgr.h:236
AthenaMtesEventLoopMgr::getNextRange
std::unique_ptr< RangeStruct > getNextRange(yampl::ISocket *socket)
Definition: AthenaMtesEventLoopMgr.cxx:1436
calibdata.force
bool force
Definition: calibdata.py:19
LArBadChanBlobUtils::Channel
Identifier32::value_type Channel
Definition: LArBadChanBlobUtils.h:24
CxxUtils::ends_with
bool ends_with(const char *s, const char *suffix)
Test whether one null-terminated byte string ends with another.
AthenaMtesEventLoopMgr::createEventContext
virtual EventContext createEventContext() override
implementation of IEventProcessor::createEventContext()
Definition: AthenaMtesEventLoopMgr.cxx:1255
AthenaMtesEventLoopMgr::m_whiteboard
SmartIF< IHiveWhiteBoard > m_whiteboard
Reference to the Whiteboard interface.
Definition: AthenaMtesEventLoopMgr.h:147
AthenaMtesEventLoopMgr::IConversionSvc_t
ServiceHandle< IConversionSvc > IConversionSvc_t
Definition: AthenaMtesEventLoopMgr.h:81
EventType
This class represents the "type of event" where the type is given by one or more "characteristics".
Definition: EventType.h:92
ExtendedEventContext.h
initialize
void initialize()
Definition: run_EoverP.cxx:894
accumulate
bool accumulate(AccumulateMap &map, std::vector< module_t > const &modules, FPGATrackSimMatrixAccumulator const &acc)
Accumulates an accumulator (e.g.
Definition: FPGATrackSimMatrixAccumulator.cxx:22
AthenaMtesEventLoopMgr::m_toolAccept
tool_stats m_toolAccept
tool returns StatusCode::SUCCESS counter
Definition: AthenaMtesEventLoopMgr.h:112
OutputStreamSequencerSvc.h
This file contains the class definition for the OutputStreamSequencerSvc class.
AthenaMtesEventLoopMgr::m_incidentSvc
IIncidentSvc_t m_incidentSvc
Reference to the incident service.
Definition: AthenaMtesEventLoopMgr.h:64
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
AthenaMtesEventLoopMgr::m_terminateLoop
bool m_terminateLoop
Definition: AthenaMtesEventLoopMgr.h:242
AthenaMtesEventLoopMgr::m_whiteboardName
std::string m_whiteboardName
Name of the Whiteboard to be used.
Definition: AthenaMtesEventLoopMgr.h:169
AthenaMtesEventLoopMgr::m_writeHists
bool m_writeHists
Definition: AthenaMtesEventLoopMgr.h:240
AthenaMtesEventLoopMgr::m_pfn
std::string m_pfn
Definition: AthenaMtesEventLoopMgr.h:299
checkTP.report
report
Definition: checkTP.py:127
clearStorePolicy
ClearStorePolicy::Type clearStorePolicy(const std::string &policyName, MsgStream &msg)
returns the enum-version of the policy (by name)
Definition: ClearStorePolicy.cxx:7
AthenaMtesEventLoopMgr::finalize
virtual StatusCode finalize() override
implementation of IAppMgrUI::finalize
Definition: AthenaMtesEventLoopMgr.cxx:402
AthenaMtesEventLoopMgr::m_eventRangeChannel
Gaudi::Property< std::string > m_eventRangeChannel
Definition: AthenaMtesEventLoopMgr.h:291
AthenaMtesEventLoopMgr::stop
virtual StatusCode stop() override
implementation of IService::stop
Definition: AthenaMtesEventLoopMgr.cxx:712
EventType.h
This class provides general information about an event. It extends EventInfo with a list of sub-evts ...
AthenaMtesEventLoopMgr::m_timeStamp
unsigned int m_timeStamp
Definition: AthenaMtesEventLoopMgr.h:237
AthenaMtesEventLoopMgr::drainScheduler
virtual int drainScheduler(int &finishedEvents, bool report) override
Drain the scheduler from all actions that may be queued.
Definition: AthenaMtesEventLoopMgr.cxx:1289
PixelModuleFeMask_create_db.stop
int stop
Definition: PixelModuleFeMask_create_db.py:76
AthenaMtesEventLoopMgr::m_outSeqSvc
ServiceHandle< OutputStreamSequencerSvc > m_outSeqSvc
Definition: AthenaMtesEventLoopMgr.h:289
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
python.DomainsRegistry.reg
reg
globals -----------------------------------------------------------------—
Definition: DomainsRegistry.py:343
AthenaMtesEventLoopMgr::m_appMgrProperty
SmartIF< IProperty > m_appMgrProperty
Property interface of ApplicationMgr.
Definition: AthenaMtesEventLoopMgr.h:156
empty
bool empty(TH1 *h)
Definition: computils.cxx:294
EventContextClid.h
Assign a CLID to EventContext.
python.FakeAthena.Service
def Service(name)
Definition: FakeAthena.py:38
AthenaMtesEventLoopMgr::curEvent
virtual int curEvent() const override
Return the current event count.
Definition: AthenaMtesEventLoopMgr.cxx:889
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
OutputStreamSequencerSvc::RangeReport_ptr
std::unique_ptr< RangeReport_t > RangeReport_ptr
Definition: OutputStreamSequencerSvc.h:37
AthenaMtesEventLoopMgr::m_proc
unsigned int m_proc
Definition: AthenaMtesEventLoopMgr.h:246
AthenaMtesEventLoopMgr::m_aess
SmartIF< IAlgExecStateSvc > m_aess
Reference to the Algorithm Execution State Svc.
Definition: AthenaMtesEventLoopMgr.h:153
python.HLT.Jet.JetMenuSequencesConfig.selName
def selName(recoSequenceName, hypoType=JetHypoAlgType.STANDARD)
Definition: JetMenuSequencesConfig.py:136
StoreGateSvc::retrieve
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
Atlas::getExtendedEventContext
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
Definition: ExtendedEventContext.cxx:32
EventInfoFromxAOD.h
AthenaMtesEventLoopMgr::m_inTestMode
bool m_inTestMode
Definition: AthenaMtesEventLoopMgr.h:259
IEvtSelectorSeek::seek
virtual StatusCode seek(IEvtSelector::Context &c, int evtnum) const =0
Seek to a given event number.
AthenaMtesEventLoopMgr::nextEvent
virtual StatusCode nextEvent(int maxevt) override
implementation of IAppMgrUI::nextEvent. maxevt==0 returns immediately
Definition: AthenaMtesEventLoopMgr.cxx:735
event_number_t
EventIDBase::event_number_t event_number_t
Definition: IEvtIdModifierSvc.h:30
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
AthenaMtesEventLoopMgr::m_doEvtHeartbeat
bool m_doEvtHeartbeat
Definition: AthenaMtesEventLoopMgr.h:248
EventID.h
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
AthenaMtesEventLoopMgr.h
IEvtIdModifierSvc.h
python.handimod.now
now
Definition: handimod.py:675
RunTileMonitoring.keyValue
keyValue
Definition: RunTileMonitoring.py:150
ICollectionSize::interfaceID
static const InterfaceID & interfaceID()
Definition: ICollectionSize.h:39
AthenaMtesEventLoopMgr::seek
virtual StatusCode seek(int evt) override
Seek to a given event.
Definition: AthenaMtesEventLoopMgr.cxx:857
EventID::number_type
EventIDBase::number_type number_type
Definition: EventID.h:37
lumiFormat.i
int i
Definition: lumiFormat.py:92
AthenaMtesEventLoopMgr::initialize
virtual StatusCode initialize() override
implementation of IAppMgrUI::initalize
Definition: AthenaMtesEventLoopMgr.cxx:155
beamspotman.n
n
Definition: beamspotman.py:731
Atlas::ExtendedEventContext
Definition: ExtendedEventContext.h:23
AthenaMtesEventLoopMgr::size
virtual int size() override
Return the size of the collection.
Definition: AthenaMtesEventLoopMgr.cxx:897
AthenaMtesEventLoopMgr::m_testPilotMessages
StringArrayProperty m_testPilotMessages
Definition: AthenaMtesEventLoopMgr.h:258
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
EventInfo::event_ID
EventID * event_ID()
the unique identification of the event.
Definition: EventInfo/EventInfo/EventInfo.h:210
ClearStorePolicy::Type
Type
Definition: ClearStorePolicy.h:13
IEvtSelectorSeek::size
virtual int size(IEvtSelector::Context &c) const =0
Return the size of the collection, or -1 if we can't get the size.
AthenaMtesEventLoopMgr::m_socket
yampl::ISocket * m_socket
Definition: AthenaMtesEventLoopMgr.h:302
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
AthenaMtesEventLoopMgr::m_currentEvntNum
int m_currentEvntNum
Definition: AthenaMtesEventLoopMgr.h:173
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ICollectionSize
Abstract interface for finding the size of an event collection.
Definition: ICollectionSize.h:31
AthenaMtesEventLoopMgr::m_lastEventContext
EventContext m_lastEventContext
Definition: AthenaMtesEventLoopMgr.h:270
AthenaAttributeList
An AttributeList represents a logical row of attributes in a metadata table. The name and type of eac...
Definition: PersistentDataModel/PersistentDataModel/AthenaAttributeList.h:45
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
TrigInDetValidation_Base.malloc
malloc
Definition: TrigInDetValidation_Base.py:129
AthenaMtesEventLoopMgr::m_toolReject
tool_stats m_toolReject
tool returns StatusCode::FAILURE counter
Definition: AthenaMtesEventLoopMgr.h:111
xAOD::eventNumber
eventNumber
Definition: EventInfo_v1.cxx:124
StoreGateSvc::clearStore
virtual StatusCode clearStore(bool forceRemove=false) override final
clear DataStore contents: called by the event loop mgrs
Definition: StoreGateSvc.cxx:461
AthenaMtesEventLoopMgr::m_evtSelector
IEvtSelector * m_evtSelector
Reference to the Event Selector.
Definition: AthenaMtesEventLoopMgr.h:71
python.LArCalib_HVCorrConfig.seconds
seconds
Definition: LArCalib_HVCorrConfig.py:86
AthenaMtesEventLoopMgr::setClearStorePolicy
void setClearStorePolicy(Gaudi::Details::PropertyBase &clearStorePolicy)
property update handler:set the clear-store policy value and check its value.
Definition: AthenaMtesEventLoopMgr.cxx:350
Athena::Timeout::instance
static Timeout & instance()
Get reference to Timeout singleton.
Definition: Timeout.h:64
AthenaMtesEventLoopMgr::writeHistograms
virtual StatusCode writeHistograms(bool force=false)
Dump out histograms as needed.
Definition: AthenaMtesEventLoopMgr.cxx:473
AthenaMtesEventLoopMgr::initializeAlgorithms
StatusCode initializeAlgorithms()
Initialize all algorithms and output streams.
Definition: AthenaMtesEventLoopMgr.cxx:529
AthenaMtesEventLoopMgr::queryInterface
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface) override
interface dispatcher
Definition: AthenaMtesEventLoopMgr.cxx:990
starts_with.h
C++20-like starts_with/ends_with for strings.
AthenaMtesEventLoopMgr::eventStore
StoreGateSvc * eventStore() const
Definition: AthenaMtesEventLoopMgr.cxx:342
AthenaMtesEventLoopMgr::m_eventStore
StoreGateSvc_t m_eventStore
Reference to StoreGateSvc;.
Definition: AthenaMtesEventLoopMgr.h:68
AthenaMtesEventLoopMgr::name
virtual const std::string & name() const override
Definition: AthenaMtesEventLoopMgr.h:229
AthenaMtesEventLoopMgr::resetAppReturnCode
virtual void resetAppReturnCode() override
Reset the application return code.
Definition: AthenaMtesEventLoopMgr.cxx:1274
trigbs_pickEvents.num
num
Definition: trigbs_pickEvents.py:76
Atlas::ExtendedEventContext::setConditionsRun
void setConditionsRun(EventIDBase::number_type conditionsRun)
Definition: ExtendedEventContext.h:36
AthenaMtesEventLoopMgr::executeEvent
virtual StatusCode executeEvent(EventContext &&ctx) override
implementation of IEventProcessor::executeEvent(void* par)
Definition: AthenaMtesEventLoopMgr.cxx:546
AthenaMtesEventLoopMgr::trimRangeStrings
void trimRangeStrings(std::string &str)
Definition: AthenaMtesEventLoopMgr.cxx:1575
debug
const bool debug
Definition: MakeUncertaintyPlots.cxx:53
checkRpcDigits.errorStr
string errorStr
Definition: checkRpcDigits.py:182
AthenaMtesEventLoopMgr::~AthenaMtesEventLoopMgr
virtual ~AthenaMtesEventLoopMgr()
Standard Destructor.
Definition: AthenaMtesEventLoopMgr.cxx:151
errorcheck.h
Helpers for checking error return status codes and reporting errors.
AthenaMtesEventLoopMgr::getEventRoot
StatusCode getEventRoot(IOpaqueAddress *&refpAddr)
Create event address using event selector.
Definition: AthenaMtesEventLoopMgr.cxx:1012
EventInfo
This class provides general information about an event. Event information is provided by the accessor...
Definition: EventInfo/EventInfo/EventInfo.h:42
AthenaMtesEventLoopMgr::m_evtIdModSvc
IEvtIdModifierSvc_t m_evtIdModSvc
Definition: AthenaMtesEventLoopMgr.h:87
AthenaMtesEventLoopMgr::m_useSecondaryEventNumber
bool m_useSecondaryEventNumber
read event number from secondary input
Definition: AthenaMtesEventLoopMgr.h:126
AthenaMtesEventLoopMgr::m_histoPersSvc
IConversionSvc_t m_histoPersSvc
Definition: AthenaMtesEventLoopMgr.h:83
AthenaMtesEventLoopMgr::declareEventRootAddress
int declareEventRootAddress(EventContext &)
Declare the root address of the event.
Definition: AthenaMtesEventLoopMgr.cxx:1034
AthenaMtesEventLoopMgr::tool_iterator
tool_store::const_iterator tool_iterator
Definition: AthenaMtesEventLoopMgr.h:106
StoreGateSvc::recordAddress
StatusCode recordAddress(const std::string &skey, IOpaqueAddress *pAddress, bool clearAddressFlag=true)
Create a proxy object using an IOpaqueAddress and a transient key.
AthenaMtesEventLoopMgr::m_toolInvoke
tool_stats m_toolInvoke
tool called counter
Definition: AthenaMtesEventLoopMgr.h:110
StoreGateSvc::tryConstRetrieve
const T * tryConstRetrieve() const
AthenaAttributeList.h
An AttributeList represents a logical row of attributes in a metadata table. The name and type of eac...
EventInfo.h
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
AthenaMtesEventLoopMgr::terminateLoop
virtual bool terminateLoop() override
Definition: AthenaMtesEventLoopMgr.cxx:1283
AthenaMtesEventLoopMgr::m_currentRun
number_type m_currentRun
current run number
Definition: AthenaMtesEventLoopMgr.h:94
ir
int ir
counter of the current depth
Definition: fastadd.cxx:49
DeMoAtlasDataLoss.runNumber
string runNumber
Definition: DeMoAtlasDataLoss.py:64
AthenaMtesEventLoopMgr::modifyEventContext
void modifyEventContext(EventContext &ctx, const EventID &eID, bool consume_modifier_stream)
Definition: AthenaMtesEventLoopMgr.cxx:1222
AthenaMtesEventLoopMgr::m_nev
unsigned int m_nev
events processed
Definition: AthenaMtesEventLoopMgr.h:245
AthenaMtesEventLoopMgr::clearWBSlot
StatusCode clearWBSlot(int evtSlot)
Clear a slot in the WB.
Definition: AthenaMtesEventLoopMgr.cxx:1427
AthenaMtesEventLoopMgr::m_algResourcePool
SmartIF< IAlgResourcePool > m_algResourcePool
Reference to the Algorithm resource pool.
Definition: AthenaMtesEventLoopMgr.h:150
AthenaMtesEventLoopMgr::executeAlgorithms
virtual StatusCode executeAlgorithms()
Run the algorithms for the current event.
Definition: AthenaMtesEventLoopMgr.cxx:537
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
AthenaMtesEventLoopMgr::m_schedulerSvc
SmartIF< IScheduler > m_schedulerSvc
A shortcut for the scheduler.
Definition: AthenaMtesEventLoopMgr.h:159
python.TriggerHandler.verbose
verbose
Definition: TriggerHandler.py:297
DEBUG
#define DEBUG
Definition: page_access.h:11
eventIDFromxAOD
EventID eventIDFromxAOD(const xAOD::EventInfo *xaod)
Create EventID object from xAOD::EventInfo.
Definition: EventInfoFromxAOD.cxx:16
AthenaMtesEventLoopMgr::m_flmbi
unsigned int m_flmbi
Definition: AthenaMtesEventLoopMgr.h:250
EventID
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition: EventID.h:35
AthenaMtesEventLoopMgr::m_eventPrintoutInterval
UnsignedIntegerProperty m_eventPrintoutInterval
Definition: AthenaMtesEventLoopMgr.h:101
IEventSeek
Abstract interface for seeking within an event stream.
Definition: IEventSeek.h:27
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85
AthenaMtesEventLoopMgr::AthenaMtesEventLoopMgr
AthenaMtesEventLoopMgr()=delete
str
Definition: BTagTrackIpAccessor.cxx:11
ClearStorePolicy.h
IEvtSelectorSeek.h
Extension to IEvtSelector to allow for seeking.
Athena::TimeoutMaster::resetTimeout
void resetTimeout(Timeout &instance)
Reset timeout.
Definition: Timeout.h:83
AthenaMtesEventLoopMgr::m_useTools
bool m_useTools
Definition: AthenaMtesEventLoopMgr.h:247
get_generator_info.error
error
Definition: get_generator_info.py:40
xAOD::lumiBlock
setTeId lumiBlock
Definition: L2StandAloneMuon_v1.cxx:327
python.PyAthena.obj
obj
Definition: PyAthena.py:135
eventTypeFromxAOD
EventType eventTypeFromxAOD(const xAOD::EventInfo *xaod)
Create EventType object from xAOD::EventInfo.
Definition: EventInfoFromxAOD.cxx:34
AthenaMtesEventLoopMgr::setCurrentEventNum
virtual void setCurrentEventNum(int num) override
Definition: AthenaMtesEventLoopMgr.cxx:1279
PrepareReferenceFile.outfile
outfile
Definition: PrepareReferenceFile.py:42
AthenaMtesEventLoopMgr::m_conditionsCleaner
ServiceHandle< Athena::IConditionsCleanerSvc > m_conditionsCleaner
Definition: AthenaMtesEventLoopMgr.h:266
StoreGateSvc.h
AthenaMtesEventLoopMgr::m_clearStorePolicy
StringProperty m_clearStorePolicy
Definition: AthenaMtesEventLoopMgr.h:121
AthenaMtesEventLoopMgr::m_schedulerName
std::string m_schedulerName
Name of the scheduler to be used.
Definition: AthenaMtesEventLoopMgr.h:167
AthenaMtesEventLoopMgr::m_evtsel
StringProperty m_evtsel
Definition: AthenaMtesEventLoopMgr.h:75
Atlas::setExtendedEventContext
void setExtendedEventContext(EventContext &ctx, ExtendedEventContext &&ectx)
Move an extended context into a context object.
Definition: ExtendedEventContext.cxx:50
AthenaMtesEventLoopMgr::m_histPersName
StringProperty m_histPersName
Definition: AthenaMtesEventLoopMgr.h:90
AthenaMtesEventLoopMgr::handle
virtual void handle(const Incident &inc) override
IIncidentListenet interfaces.
Definition: AthenaMtesEventLoopMgr.cxx:920
IEvtSelectorSeek
Abstract interface for seeking for an event selector.
Definition: IEvtSelectorSeek.h:28
AthenaMtesEventLoopMgr::m_scheduledStop
bool m_scheduledStop
Scheduled stop of event processing.
Definition: AthenaMtesEventLoopMgr.h:171
AthenaMtesEventLoopMgr::setupPreSelectTools
void setupPreSelectTools(Gaudi::Details::PropertyBase &)
property update handler:sets up the Pre-selection tools
Definition: AthenaMtesEventLoopMgr.cxx:369
AthenaMtesEventLoopMgr::m_timeStampInt
unsigned int m_timeStampInt
Definition: AthenaMtesEventLoopMgr.h:250
beamspotman.fail
def fail(message)
Definition: beamspotman.py:201
AthenaMtesEventLoopMgr::m_firstRun
bool m_firstRun
Definition: AthenaMtesEventLoopMgr.h:95
AthenaMtesEventLoopMgr::stopRun
virtual StatusCode stopRun() override
implementation of IEventProcessor::stopRun()
Definition: AthenaMtesEventLoopMgr.cxx:697
LArG4ShowerLibProcessing.truncate
truncate
Definition: LArG4ShowerLibProcessing.py:39
AthenaMtesEventLoopMgr::m_histoDataMgrSvc
IDataManagerSvc_t m_histoDataMgrSvc
Reference to the Histogram Data Service.
Definition: AthenaMtesEventLoopMgr.h:79