|
ATLAS Offline Software
|
Go to the documentation of this file.
18 #include "EventInfo/EventInfo.h"
38 #include "GaudiKernel/IAlgorithm.h"
39 #include "GaudiKernel/IEvtSelector.h"
40 #include "GaudiKernel/IIncidentSvc.h"
41 #include "GaudiKernel/Incident.h"
42 #include "GaudiKernel/DataIncident.h"
43 #include "GaudiKernel/EventContext.h"
44 #include "GaudiKernel/ThreadLocalContext.h"
45 #include "GaudiKernel/Algorithm.h"
55 : base_class(
name, svcLoc)
57 , m_incidentSvc(
"IncidentSvc",
name)
58 , m_mergeSvc(
"PileUpMergeSvc",
name)
59 , m_evtStore(
"StoreGateSvc/StoreGateSvc",
name)
60 , m_evtIdModSvc(
"",
name)
61 , m_origSel(
"EventSelector",
name)
62 , m_signalSel(
"",
name)
64 , m_maxCollPerXing(23.0)
68 , m_allowSubEvtsEOF(true)
73 , m_beamInt(
"FlatBM",
name)
74 , m_beamLumi(
"LumiProfileSvc",
name)
77 , m_maxBunchCrossingPerOrbit(3564)
80 , m_skipExecAlgs(false)
82 , m_allowSerialAndMPToDiffer(true)
84 declareProperty(
"MaxBunchCrossingPerOrbit",
m_maxBunchCrossingPerOrbit,
"The number of slots in each LHC beam. Default: 3564.");
85 declareProperty(
"OrigSelector",
m_origSel,
"EventSelector for original (physics) events stream" );
86 declareProperty(
"SignalSelector",
m_signalSel,
"EventSelector for signal (hard-scatter) events stream" );
87 declareProperty(
"XingFrequency",
m_xingFreq,
"ns");
88 declareProperty(
"firstXing",
m_firstXing,
"time of first xing / XingFrequency (0th xing is 1st after trigger)");
89 declareProperty(
"lastXing",
m_lastXing,
"time of last xing / XingFrequency (0th xing is 1st after trigger)");
90 declareProperty(
"MaxMinBiasCollPerXing",
m_maxCollPerXing,
"Set to digitization numberOfCollisions prop. for variable-mu and RunDMC jobs.");
91 declareProperty(
"bkgCaches",
m_caches,
"list of tools managing bkg events");
92 declareProperty(
"AllowSubEvtsEOF",
m_allowSubEvtsEOF,
"if true(default) an EOF condition in the BkgStreamsCaches is not considered to be an error IF maxevt=-1 (loop over all available events)");
93 declareProperty(
"XingByXing",
m_xingByXing,
"if set to true we will not cache bkg events from one xing to then next. This greatly increases the amount of I/O and greatly reduces the memory required to run a job");
95 "Controls behaviour of event loop depending on return code of"
96 " Algorithms. 0: all non-SUCCESSes terminate job. "
97 "1: RECOVERABLE skips to next event, FAILURE terminates job "
98 "(DEFAULT). 2: RECOVERABLE and FAILURE skip to next events");
101 "The service providing the beam intensity distribution");
103 "The service providing the beam luminosity distribution vs. run");
104 declareProperty(
"PileUpMergeSvc",
m_mergeSvc,
"PileUp Merge Service");
105 declareProperty(
"EvtIdModifierSvc",
m_evtIdModSvc,
"ServiceHandle for EvtIdModifierSvc");
106 declareProperty(
"AllowSerialAndMPToDiffer",
m_allowSerialAndMPToDiffer,
"When set to False, this will allow the code to reproduce serial output in an AthenaMP job, albeit with a significant performance penalty.");
107 declareProperty(
"EventInfoName",
m_evinfName,
"SG key for the EventInfo object");
108 declareProperty(
"EventInfoContName",
m_evinfContName,
"SG key for the EventInfoContainer object");
124 ATH_MSG_WARNING (
"AllowSerialAndMPToDiffer=False! This will incur serious performance penalties! But Serial and MP output will be the same." );
145 SmartIF<IProperty> prpMgr(serviceLocator());
146 SmartIF<IEvtSelector> evtSelector;
147 if (prpMgr.isValid()) {
149 std::string evtSelName = prpMgr->getProperty(
"EvtSel").toString();
150 evtSelector = serviceLocator()->service(evtSelName);
151 CHECK(evtSelector.isValid());
154 ATH_MSG_ERROR (
"IProperty interface not found in ApplicationMgr" );
155 return StatusCode::FAILURE;
158 SmartIF<IProperty> prpMgr1(evtSelector);
159 if (prpMgr1.isValid()) {
160 std::string skipEventsStr = prpMgr1->getProperty(
"SkipEvents").toString();
164 ATH_MSG_ERROR (
"IProperty interface not found on the event selector" );
165 return StatusCode::FAILURE;
169 m_aess = serviceLocator()->service(
"AlgExecStateSvc");
172 return StatusCode::FAILURE;
179 ATH_MSG_DEBUG (
"EventID modifier Service not set. No run number, ... overrides will be applied." );
182 ATH_MSG_INFO (
"Could not find EventID modifier Service. No run number, ... overrides will be applied." );
202 while (cacheIterator != endOfCaches) {
232 unsigned int oldrunnr=eID.run_number();
233 unsigned int oldLB=eID.lumi_block();
234 unsigned int oldTS=eID.time_stamp();
235 unsigned int oldTSno=eID.time_stamp_ns_offset();
236 ATH_MSG_DEBUG (
"modifyEventContext: use evtIdModSvc runnr=" << oldrunnr <<
" -> " << new_eID.run_number() );
237 ATH_MSG_DEBUG (
"modifyEventContext: use evtIdModSvc LB=" << oldLB <<
" -> " << new_eID.lumi_block() );
238 ATH_MSG_DEBUG (
"modifyEventContext: use evtIdModSvc TimeStamp=" << oldTS <<
" -> " << new_eID.time_stamp() );
239 ATH_MSG_DEBUG (
"modifyEventContext: use evtIdModSvc TimeStamp ns Offset=" << oldTSno <<
" -> " << new_eID.time_stamp_ns_offset() );
241 ctx.setEventID(new_eID);
245 ctx.setEventID( eID );
256 return StatusCode::SUCCESS;
273 for ( ita = m_topAlgList.begin(); ita != m_topAlgList.end(); ++ita ) {
274 if( !((*ita)->sysInitialize()).isSuccess() ) {
277 return StatusCode::FAILURE;
283 for (ita = m_outStreamList.begin(); ita != m_outStreamList.end(); ++ita ) {
284 if( !((*ita)->sysInitialize()).isSuccess() ) {
287 return StatusCode::FAILURE;
295 while( (maxevt == -1 ||
m_nevt < maxevt) &&
298 if ( m_scheduledStop ) {
299 m_scheduledStop =
false;
300 ATH_MSG_ALWAYS (
"A stopRun was requested. Terminating event loop." );
311 pOverEvent->
setStore( pOverEventAux );
312 ATH_MSG_DEBUG(
" #subevents in the signal event =" << inputEventInfo->subEvents().size());
315 *pOverEvent = *inputEventInfo;
332 <<
") and provided mcChannelNumber (" <<
m_mcChannelNumber.value() <<
") do not match.");
342 return StatusCode::FAILURE;
347 ATH_MSG_ERROR(
"Input mcEventWeights are empty. This should not happen.");
348 return StatusCode::FAILURE;
358 puei->setStore( puaux );
368 bool consume_modifier_stream =
false;
371 if ( pAttrList !=
nullptr && pAttrList->size() > 6 ) {
377 consume_modifier_stream =
true;
383 ctx.eventID().run_number()) );
384 Gaudi::Hive::setCurrentContext( ctx );
387 auto puctx =std::make_unique<EventContext> ( ctx );
388 if (
m_evtStore->record( std::move(puctx) ,
"EventContext").isFailure()) {
390 return StatusCode::FAILURE;
400 ATH_MSG_INFO (
"nextEvent(): overlaying original event " <<
407 m_beamInt->selectT0(ctx.eventID().run_number(), ctx.eventID().event_number());
412 unsigned int t0BCID = pOverEvent->
bcid();
422 bool addpEvent(
true);
424 ATH_MSG_DEBUG(
"inputEventInfo->evtStore()="<<inputEventInfo->evtStore()<<
", pOverEvent->evtStore()=" << pOverEvent->evtStore()<<
", &m_origStream.store()="<<&
m_origStream.
store() );
432 ATH_MSG_DEBUG(
"Added inputEventInfo="<<inputEventInfo<<
" as subEvent "<<newEv<<
" to pOverEvent " << pOverEvent );
433 ATH_MSG_DEBUG(
" afterwards: newEv->evtStore()="<<newEv->evtStore()<<
", pOverEvent->evtStore()=" << pOverEvent->evtStore() );
459 while (cacheIterator != endOfCaches) {
461 (*cacheIterator)->resetEvtsPerXingScaleFactor(
sf);
463 (*cacheIterator++)->newEvent();
474 unsigned int currentBCID =
getBCID((t0BinCenter/25), t0BCID);
477 while (cacheIterator != endOfCaches) {
479 if (((*cacheIterator)->addSubEvts(iXing-
m_firstXing, pOverEvent, t0BinCenter,
m_loadProxies, currentBCID)).isFailure()) {
482 ATH_MSG_INFO (
"No more sub events for " << cacheIterator->name() );
483 return StatusCode::SUCCESS;
486 ATH_MSG_FATAL (
"Error adding sub events to " << cacheIterator->name() );
487 return StatusCode::FAILURE;
516 m_incidentSvc->fireIncident(ContextIncident<std::pair<unsigned,unsigned> >(this->
name(),
"ReseedIncident",std::pair<unsigned,unsigned>(pOverEvent->
eventNumber(),pOverEvent->
runNumber())));
522 ATH_MSG_ERROR (
"Terminating event processing loop due to errors" );
523 return StatusCode::FAILURE;
545 return StatusCode::SUCCESS;
554 " nevtsToAdvance=" << nevtsToAdvance );
557 for (
int i=0;
i<nevtsToAdvance; ++
i) {
561 if (this->
nextEvent(nParam).isFailure()) {
563 return StatusCode::FAILURE;
567 return StatusCode::SUCCESS;
588 return StatusCode::FAILURE;
598 unsigned int firstStore(0);
600 while ((cacheIterator != endOfCaches) &&
sc.isSuccess()) {
602 firstStore += (*cacheIterator)->nStores() ;
615 ita != m_topAlgList.end();
621 m_aess->algExecState(*ita, ctx ).setState(AlgExecState::State::Done,
sc);
622 if ( !
sc.isSuccess() ) {
624 (*ita)->name() <<
" failed with StatusCode::" <<
sc );
629 return StatusCode::SUCCESS;
653 bool eventFailed(
false);
657 if (!
sc.isSuccess()) {
659 m_aess->setEventStatus( EventStatus::AlgFail, ctx );
666 "Skipping remaining algorithms." << std::endl <<
667 "\tNo output will be written for this event, " <<
668 "but job will continue to next event" );
674 ATH_MSG_INFO (
"Skipping remaining algorithms." << std::endl <<
675 "\tNo output will be written for this event, " <<
676 "but job will continue to next event" );
681 m_aess->setEventStatus( EventStatus::Success, ctx );
685 ito != m_outStreamList.end(); ++ito ) {
686 sc = (*ito)->sysExecute( ctx );
687 if ( !
sc.isSuccess() ) {
696 return eventFailed?StatusCode::FAILURE:StatusCode::SUCCESS;
JetConstituentVector::iterator iterator
const std::string c_pileUpEventInfoContName
default value for the EventInfoContainer storing subevents for PileUp
A helper class to compute a hash of pile-up events.
void setActualInteractionsPerCrossing(float value)
Set average interactions per crossing for the current BCID.
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
void setEventNumber(uint64_t value)
Set the current event's event number.
ServiceHandle< IIncidentSvc > m_incidentSvc
Incident Service.
EventInfo_v1 EventInfo
Definition of the latest event info version.
uint64_t eventNumber() const
The current event's event number.
virtual ~PileUpEventLoopMgr()
Standard Destructor.
const std::vector< float > & mcEventWeights() const
The weights of all the MC events used in the simulation.
Gaudi::Property< bool > m_allowSerialAndMPToDiffer
property: Default true.
ServiceHandle< IEvtSelector > m_signalSel
Signal Event selector (for overlay).
Auxiliary information about the event.
void clearSubEvents()
Clear all the currently held sub-events.
virtual StatusCode nextEvent(int maxevt)
implementation of IAppMgreUI::terminate
ServiceHandle< IEvtSelector > m_origSel
Original (Physics) Event selector (background for overlay).
static xAOD::EventInfo::PileUpMixtureID uuidToPileUpMixtureId(const uuid_t &hash)
Convert uuid_t to xAOD::EventInfo::PileUpMixtureID.
std::string hashSource() const
Get the current hash base.
Gaudi::Property< float > m_xingFreq
Xing frequency(ns);.
This class provides general information about an event. It extends EventInfo with a list of sub-evts ...
#define ATH_MSG_VERBOSE(x)
ServiceHandle< StoreGateSvc > m_evtStore
output store
Gaudi::Property< std::string > m_evinfName
SG key for the EventInfoContainer.
virtual StatusCode executeAlgorithms(const EventContext &ctx)
Run the algorithms for the current event.
@ IS_SIMULATION
true: simulation, false: data
Assign a CLID to EventContext.
PileUpStream m_origStream
Input Stream.
uint32_t runNumber() const
The current event's run number.
unsigned int m_maxBunchCrossingPerOrbit
max bunch crossings per orbit
PileUpMixtureID pileUpMixtureID() const
Unique pile-up mixture identifier.
uint32_t mcChannelNumber() const
The MC generator's channel number.
void setPileUpMixtureID(const PileUpMixtureID &value)
Set unique pile-up mixture identifier.
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
const xAOD::EventInfo * nextEventPre(bool readRecord=true)
return next Event, load store with next Event
StatusCode finalize()
finalize and release store. To be called on ... finalize()
ServiceHandle< PileUpMergeSvc > m_mergeSvc
PileUp Merge Service.
void setMCEventNumber(uint64_t value)
Set the MC generator's event number.
void setEventTypeBitmask(uint32_t value)
Set the event type bitmask.
Gaudi::Property< bool > m_allowSubEvtsEOF
property: allow sub evts EOF condition when maxevt==-1
void setStore(const SG::IConstAuxStore *store)
Set the store associated with this object.
PileUpEventLoopMgr(const std::string &nam, ISvcLocator *svcLoc)
Standard Constructor.
bool setupStore()
setup input and overlay selectors and iters
::StatusCode StatusCode
StatusCode definition for legacy code.
ServiceHandle< IBeamIntensity > m_beamInt
property: beam intensity service handle for beam profile in local time
void addToHashSource(const std::string &string)
Add a plain string to the stream.
Class to provide easy MsgStream access and capabilities.
#define ATH_MSG_ALWAYS(x)
a triple selector/context/store defines a stream
An AttributeList represents a logical row of attributes in a metadata table. The name and type of eac...
#define CHECK(...)
Evaluate an expression and check for errors.
virtual StatusCode seek(int evt)
Seek to a given event.
Gaudi::Property< std::string > m_evinfContName
SG key for the EventInfoContainer.
StatusCode setupStreams()
setup input and overlay selectors and iters
void setTimeStamp(uint32_t value)
Set the POSIX time of the event.
void setBCID(uint32_t value)
Set the bunch crossing ID of the event.
uint32_t lumiBlock() const
The current event's luminosity block number.
Gaudi::Property< uint32_t > m_mcChannelNumber
EventAuxInfo_v3 EventAuxInfo
Definition of the latest event auxiliary info version.
Gaudi::Property< int > m_firstXing
first xing to be simulated (0th xing is 1st after trigger)
Auxiliary information about the pileup events.
unsigned int getBCID(int bunchXing, unsigned int centralBCID) const
return the 'fake BCID' corresponding to bunchXing
virtual StatusCode executeEvent(EventContext &&ctx)
implementation of IEventProcessor::executeEvent(void* par)
float averageInteractionsPerCrossing() const
Average interactions per crossing for all BCIDs - for out-of-time pile-up.
Gaudi::Property< float > m_maxCollPerXing
(max) minBias interactions per Xing, for setting MC luminosity
IEvtIdModifierSvc_t m_evtIdModSvc
virtual int curEvent() const
Return the current event count.
Helpers for checking error return status codes and reporting errors.
void setAverageInteractionsPerCrossing(float value)
Set average interactions per crossing for all BCIDs.
The ATLAS event loop for pile-up applications.
const T * tryConstRetrieve() const
Class describing the basic event information.
void setMCChannelNumber(uint32_t value)
Set the MC generator's channel number.
ToolHandleArray< IBkgStreamsCache > m_caches
BkgStreamsCaches managing background events.
@ Signal
The signal event.
Gaudi::Property< bool > m_xingByXing
property: process bkg events xing by xing without caching them
virtual StatusCode finalize()
implementation of IAppMgrUI::finalize
#define ATH_MSG_WARNING(x)
void setRunNumber(uint32_t value)
Set the current event's run number.
the preferred mechanism to access information from the different event stores in a pileup job.
provides the relative beam intensity as a function of the bunch xing.
const std::string c_pileUpEventInfoObjName
default value for the EventInfoContainer storing subevents for PileUp
uint32_t m_currentRun
current run number
SmartIF< IAlgExecStateSvc > m_aess
Reference to the Algorithm Execution State Svc.
void calculateHash(uuid_t &hash) const
Calculate the hash.
EventID eventIDFromxAOD(const xAOD::EventInfo *xaod)
Create EventID object from xAOD::EventInfo.
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Gaudi::Property< int > m_lastXing
last xing to be simulated (0th xing is 1st after trigger)
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Interface to in-memory cache for pileup events.
void setLumiBlock(uint32_t value)
Set the current event's luminosity block number.
const std::vector< SubEvent > & subEvents() const
Get the pileup events that were used in the simulation.
uint32_t bcid() const
The bunch crossing ID of the event.
Gaudi::Property< int > m_failureMode
property: control behaviour of event loop on algorithm failure
virtual StatusCode initialize()
implementation of IAppMgrUI::initialize
provides the relative beam luminosity as a function of the bunch xing.
xAOD::EventInfo * addSubEvent(xAOD::EventInfo *targetEv, const xAOD::EventInfo::SubEvent &subev, xAOD::EventInfoContainer *eiContainer, const std::string &eiContKey, StoreGateSvc *subev_store=nullptr)
virtual void modifyEventContext(EventContext &ctx, const EventID &eID, bool consume_modifier_stream)
uint64_t mcEventNumber() const
The MC generator's event number.
void setMCEventWeights(const std::vector< float > &value)
Set the weights of all the MC events used in the simulation.
float actualInteractionsPerCrossing() const
Average interactions per crossing for the current BCID - for in-time pile-up.
ServiceHandle< IBeamLuminosity > m_beamLumi
property: beam intensity service handle for luminosity profile in iovtime