 |
ATLAS Offline Software
|
Go to the documentation of this file.
32 #include "GaudiKernel/IAlgorithm.h"
33 #include "GaudiKernel/IEvtSelector.h"
34 #include "GaudiKernel/IIncidentSvc.h"
35 #include "GaudiKernel/Incident.h"
36 #include "GaudiKernel/DataIncident.h"
37 #include "GaudiKernel/EventContext.h"
38 #include "GaudiKernel/ThreadLocalContext.h"
48 : base_class(
name, svcLoc)
50 , m_incidentSvc(
"IncidentSvc",
name)
51 , m_evtStore(
"StoreGateSvc/StoreGateSvc",
name)
68 ATH_MSG_WARNING (
"AllowSerialAndMPToDiffer=False! This will incur serious performance penalties! But Serial and MP output will be the same." );
89 SmartIF<IProperty> prpMgr(serviceLocator());
90 SmartIF<IEvtSelector> evtSelector;
91 if (prpMgr.isValid()) {
93 evtSelector = serviceLocator()->service(prpMgr->getProperty(
"EvtSel").toString());
94 CHECK(evtSelector.isValid());
97 ATH_MSG_ERROR (
"IProperty interface not found in ApplicationMgr" );
98 return StatusCode::FAILURE;
101 SmartIF<IProperty> prpMgr1(evtSelector);
102 if (prpMgr1.isValid()) {
103 std::string skipEventsStr = prpMgr1->getProperty(
"SkipEvents").toString();
107 ATH_MSG_ERROR (
"IProperty interface not found on the event selector" );
108 return StatusCode::FAILURE;
112 m_aess = serviceLocator()->service(
"AlgExecStateSvc");
115 return StatusCode::FAILURE;
122 ATH_MSG_DEBUG (
"EventID modifier Service not set. No run number, ... overrides will be applied." );
125 ATH_MSG_INFO (
"Could not find EventID modifier Service. No run number, ... overrides will be applied." );
145 while (cacheIterator != endOfCaches) {
175 unsigned int oldrunnr=eID.run_number();
176 unsigned int oldLB=eID.lumi_block();
177 unsigned int oldTS=eID.time_stamp();
178 unsigned int oldTSno=eID.time_stamp_ns_offset();
179 ATH_MSG_DEBUG (
"modifyEventContext: use evtIdModSvc runnr=" << oldrunnr <<
" -> " << new_eID.run_number() );
180 ATH_MSG_DEBUG (
"modifyEventContext: use evtIdModSvc LB=" << oldLB <<
" -> " << new_eID.lumi_block() );
181 ATH_MSG_DEBUG (
"modifyEventContext: use evtIdModSvc TimeStamp=" << oldTS <<
" -> " << new_eID.time_stamp() );
182 ATH_MSG_DEBUG (
"modifyEventContext: use evtIdModSvc TimeStamp ns Offset=" << oldTSno <<
" -> " << new_eID.time_stamp_ns_offset() );
184 ctx.setEventID(new_eID);
188 ctx.setEventID( eID );
199 return StatusCode::SUCCESS;
216 for ( ita = m_topAlgList.begin(); ita != m_topAlgList.end(); ++ita ) {
217 if( !((*ita)->sysInitialize()).isSuccess() ) {
220 return StatusCode::FAILURE;
226 for (ita = m_outStreamList.begin(); ita != m_outStreamList.end(); ++ita ) {
227 if( !((*ita)->sysInitialize()).isSuccess() ) {
230 return StatusCode::FAILURE;
238 while( (maxevt == -1 ||
m_nevt < maxevt) &&
241 if ( m_scheduledStop ) {
242 m_scheduledStop =
false;
243 ATH_MSG_ALWAYS (
"A stopRun was requested. Terminating event loop." );
252 auto upOverEvent = std::make_unique<xAOD::EventInfo>();
253 auto upOverEventAux = std::make_unique<xAOD::EventAuxInfo>();
254 upOverEvent->setStore( upOverEventAux.get() );
256 ATH_MSG_DEBUG(
" #subevents in the signal event =" << inputEventInfo->subEvents().size());
259 *pOverEvent = *inputEventInfo;
276 <<
") and provided mcChannelNumber (" <<
m_mcChannelNumber.value() <<
") do not match.");
286 return StatusCode::FAILURE;
291 ATH_MSG_ERROR(
"Input mcEventWeights are empty. This should not happen.");
292 return StatusCode::FAILURE;
302 puei->setStore( puaux );
312 bool consume_modifier_stream =
false;
315 if ( pAttrList !=
nullptr && pAttrList->size() > 6 ) {
321 consume_modifier_stream =
true;
327 ctx.eventID().run_number()) );
328 Gaudi::Hive::setCurrentContext( ctx );
331 auto puctx =std::make_unique<EventContext> ( ctx );
332 if (
m_evtStore->record( std::move(puctx) ,
"EventContext").isFailure()) {
334 return StatusCode::FAILURE;
344 ATH_MSG_INFO (
"nextEvent(): overlaying original event " <<
351 m_beamInt->selectT0(ctx.eventID().run_number(), ctx.eventID().event_number());
356 unsigned int t0BCID = pOverEvent->
bcid();
366 bool addpEvent(
true);
368 ATH_MSG_DEBUG(
"inputEventInfo->evtStore()="<<inputEventInfo->evtStore()<<
", pOverEvent->evtStore()=" << pOverEvent->evtStore()<<
", &m_origStream.store()="<<&
m_origStream.
store() );
376 ATH_MSG_DEBUG(
"Added inputEventInfo="<<inputEventInfo<<
" as subEvent "<<newEv<<
" to pOverEvent " << pOverEvent );
377 ATH_MSG_DEBUG(
" afterwards: newEv->evtStore()="<<newEv->evtStore()<<
", pOverEvent->evtStore()=" << pOverEvent->evtStore() );
403 while (cacheIterator != endOfCaches) {
405 (*cacheIterator)->resetEvtsPerXingScaleFactor(
sf);
407 (*cacheIterator++)->newEvent();
418 unsigned int currentBCID =
getBCID((t0BinCenter/25), t0BCID);
421 while (cacheIterator != endOfCaches) {
423 if (((*cacheIterator)->addSubEvts(iXing-
m_firstXing, pOverEvent, t0BinCenter,
m_loadProxies, currentBCID)).isFailure()) {
426 ATH_MSG_INFO (
"No more sub events for " << cacheIterator->name() );
427 return StatusCode::SUCCESS;
430 ATH_MSG_FATAL (
"Error adding sub events to " << cacheIterator->name() );
431 return StatusCode::FAILURE;
460 m_incidentSvc->fireIncident(ContextIncident<std::pair<unsigned,unsigned> >(this->
name(),
"ReseedIncident",std::pair<unsigned,unsigned>(pOverEvent->
eventNumber(),pOverEvent->
runNumber())));
466 ATH_MSG_ERROR (
"Terminating event processing loop due to errors" );
467 return StatusCode::FAILURE;
489 return StatusCode::SUCCESS;
498 " nevtsToAdvance=" << nevtsToAdvance );
501 for (
int i=0;
i<nevtsToAdvance; ++
i) {
505 if (this->
nextEvent(nParam).isFailure()) {
507 return StatusCode::FAILURE;
511 return StatusCode::SUCCESS;
532 return StatusCode::FAILURE;
542 unsigned int firstStore(0);
544 while ((cacheIterator != endOfCaches) &&
sc.isSuccess()) {
546 firstStore += (*cacheIterator)->nStores() ;
559 ita != m_topAlgList.end();
565 m_aess->algExecState(*ita, ctx ).setState(AlgExecState::State::Done,
sc);
566 if ( !
sc.isSuccess() ) {
568 (*ita)->name() <<
" failed with StatusCode::" <<
sc );
573 return StatusCode::SUCCESS;
597 bool eventFailed(
false);
601 if (!
sc.isSuccess()) {
603 m_aess->setEventStatus( EventStatus::AlgFail, ctx );
610 "Skipping remaining algorithms." << std::endl <<
611 "\tNo output will be written for this event, " <<
612 "but job will continue to next event" );
618 ATH_MSG_INFO (
"Skipping remaining algorithms." << std::endl <<
619 "\tNo output will be written for this event, " <<
620 "but job will continue to next event" );
625 m_aess->setEventStatus( EventStatus::Success, ctx );
629 ito != m_outStreamList.end(); ++ito ) {
630 sc = (*ito)->sysExecute( ctx );
631 if ( !
sc.isSuccess() ) {
640 return eventFailed?StatusCode::FAILURE:StatusCode::SUCCESS;
JetConstituentVector::iterator iterator
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.
virtual StatusCode executeEvent(EventContext &&ctx) override
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.
virtual int curEvent() const override
Gaudi::Property< bool > m_allowSerialAndMPToDiffer
void clearSubEvents()
Clear all the currently held sub-events.
ServiceHandle< IEvtSelector > m_origSel
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
#define ATH_MSG_VERBOSE(x)
ServiceHandle< StoreGateSvc > m_evtStore
output store
Gaudi::Property< std::string > m_evinfName
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.
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.
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
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
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.
virtual StatusCode seek(int evt) override
ServiceHandle< IEvtIdModifierSvc > m_evtIdModSvc
ServiceHandle< IBeamIntensity > m_beamInt
void addToHashSource(const std::string &string)
Add a plain string to the stream.
virtual StatusCode nextEvent(int maxevt) override
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.
Gaudi::Property< std::string > m_evinfContName
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
Gaudi::Property< int > m_firstXing
Auxiliary information about the pileup events.
unsigned int getBCID(int bunchXing, unsigned int centralBCID) const
return the 'fake BCID' corresponding to bunchXing
float averageInteractionsPerCrossing() const
Average interactions per crossing for all BCIDs - for out-of-time pile-up.
Gaudi::Property< float > m_maxCollPerXing
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.
virtual StatusCode finalize() override
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
@ Signal
The signal event.
virtual StatusCode initialize() override
Gaudi::Property< bool > m_xingByXing
#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.
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
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
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)
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