197{
198
199 if (0 == maxevt) {
200 return StatusCode::SUCCESS;
201 }
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216 ListAlg::iterator ita;
217 for ( ita = m_topAlgList.begin(); ita != m_topAlgList.end(); ++ita ) {
218 if( !((*ita)->sysInitialize()).isSuccess() ) {
220 (*ita)->name() );
221 return StatusCode::FAILURE;
222 }
223 }
224
225
226
227 for (ita = m_outStreamList.begin(); ita != m_outStreamList.end(); ++ita ) {
228 if( !((*ita)->sysInitialize()).isSuccess() ) {
230 (*ita)->name() );
231 return StatusCode::FAILURE;
232 }
233 }
234
236
237
238
239 while( (maxevt == -1 ||
m_nevt < maxevt) &&
241
242 if ( m_scheduledStop ) {
243 m_scheduledStop = false;
244 ATH_MSG_ALWAYS (
"A stopRun was requested. Terminating event loop." );
245 break;
246 }
248
249
250
251
252
253 auto upOverEvent = std::make_unique<xAOD::EventInfo>();
254 auto upOverEventAux = std::make_unique<xAOD::EventAuxInfo>();
255 upOverEvent->setStore( upOverEventAux.get() );
258
259
260 *pOverEvent = *inputEventInfo;
262
263
265
266
271 } else {
273 }
274 } else {
277 <<
") and provided mcChannelNumber (" <<
m_mcChannelNumber.value() <<
") do not match.");
278 }
279 }
280
285 } else {
287 return StatusCode::FAILURE;
288 }
289 }
290
292 ATH_MSG_ERROR(
"Input mcEventWeights are empty. This should not happen.");
293 return StatusCode::FAILURE;
294 }
295
296
300
303 puei->setStore( puaux );
304
305
308
309
310
311 EventContext ctx;
313 bool consume_modifier_stream = false;
314
315 const AthenaAttributeList* pAttrList =
m_origStream.store().tryConstRetrieve<AthenaAttributeList>(
"Input");
316 if ( pAttrList != nullptr && pAttrList->size() > 6 ) {
317
318
319
320
321
322 consume_modifier_stream = true;
323 }
327 ctx.setExtension( Atlas::ExtendedEventContext(
m_evtStore->hiveProxyDict(),
328 ctx.eventID().run_number()) );
329 Gaudi::Hive::setCurrentContext( ctx );
331
332 auto puctx =std::make_unique<EventContext> ( ctx );
333 if (
m_evtStore->record( std::move(puctx) ,
"EventContext").isFailure()) {
335 return StatusCode::FAILURE;
336 }
337
338
344
345 ATH_MSG_INFO (
"nextEvent(): overlaying original event " <<
349
350
351
352 m_beamInt->selectT0(ctx.eventID().run_number(), ctx.eventID().event_number());
353
354
356
357 unsigned int t0BCID = pOverEvent->
bcid();
359
360
361
362
363
365
366
367 bool addpEvent(true);
368
369 ATH_MSG_DEBUG(
"inputEventInfo->evtStore()="<<inputEventInfo->evtStore()<<
", pOverEvent->evtStore()=" << pOverEvent->evtStore()<<
", &m_origStream.store()="<<&
m_origStream.store() );
370 if ( addpEvent ) {
377 ATH_MSG_DEBUG(
"Added inputEventInfo="<<inputEventInfo<<
" as subEvent "<<newEv<<
" to pOverEvent " << pOverEvent );
378 ATH_MSG_DEBUG(
" afterwards: newEv->evtStore()="<<newEv->evtStore()<<
", pOverEvent->evtStore()=" << pOverEvent->evtStore() );
380 }
381
383
385
386
387
388
390 bool needupdate;
394
395
396
397
402 ToolHandleArray<IBkgStreamsCache>::iterator cacheIterator(
m_caches.begin());
403 ToolHandleArray<IBkgStreamsCache>::iterator endOfCaches(
m_caches.end());
404 while (cacheIterator != endOfCaches) {
405 if (needupdate) {
406 (*cacheIterator)->resetEvtsPerXingScaleFactor(sf);
407 }
408 (*cacheIterator++)->newEvent();
409 }
410
411
412
414
415
416
417
419 unsigned int currentBCID =
getBCID((t0BinCenter/25), t0BCID);
422 while (cacheIterator != endOfCaches) {
423
424 if (((*cacheIterator)->addSubEvts(iXing-
m_firstXing, pOverEvent, t0BinCenter,
m_loadProxies, currentBCID)).isFailure()) {
425
427 ATH_MSG_INFO (
"No more sub events for " << cacheIterator->name() );
428 return StatusCode::SUCCESS;
429 }
430 else {
431 ATH_MSG_FATAL (
"Error adding sub events to " << cacheIterator->name() );
432 return StatusCode::FAILURE;
433 }
434 }
435 ++cacheIterator;
436 }
437 }
438
439
440 PileUpHashHelper pileUpHashHelper;
441
443
445
446
447 uuid_t pileUpHash;
449
451
453
454
456
457
458
461 m_incidentSvc->fireIncident(ContextIncident<std::pair<unsigned,unsigned> >(this->
name(),
"ReseedIncident",std::pair<unsigned,unsigned>(pOverEvent->
eventNumber(),pOverEvent->
runNumber())));
464 }
465 else {
467 ATH_MSG_ERROR (
"Terminating event processing loop due to errors" );
468 return StatusCode::FAILURE;
469 }
470 else {
472 }
473 }
474
475
476
478
479
482 }
484 }
485
488 }
489
490 return StatusCode::SUCCESS;
491
492}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_ALWAYS(x)
EventID eventIDFromxAOD(const xAOD::EventInfo *xaod)
Create EventID object from xAOD::EventInfo.
xAOD::EventInfo * addSubEvent(xAOD::EventInfo *targetEv, const xAOD::EventInfo::SubEvent &subev, xAOD::EventInfoContainer *eiContainer, const std::string &eiContKey, StoreGateSvc *subev_store=nullptr)
Gaudi::Property< bool > m_xingByXing
Gaudi::Property< float > m_xingFreq
Gaudi::Property< uint32_t > m_mcChannelNumber
Gaudi::Property< float > m_maxCollPerXing
void modifyEventContext(EventContext &ctx, const EventID &eID, bool consume_modifier_stream)
Gaudi::Property< std::string > m_evinfName
Gaudi::Property< int > m_firstXing
unsigned int getBCID(int bunchXing, unsigned int centralBCID) const
return the 'fake BCID' corresponding to bunchXing
virtual StatusCode executeEvent(EventContext &&ctx) override
Gaudi::Property< int > m_lastXing
ServiceHandle< IBeamLuminosity > m_beamLumi
ServiceHandle< IBeamIntensity > m_beamInt
Gaudi::Property< bool > m_allowSubEvtsEOF
Gaudi::Property< std::string > m_evinfContName
std::string hashSource() const
Get the current hash base.
void addToHashSource(const std::string &string)
Add a plain string to the stream.
void calculateHash(uuid_t &hash) const
Calculate the hash.
static xAOD::EventInfo::PileUpMixtureID uuidToPileUpMixtureId(const uuid_t &hash)
Convert uuid_t to xAOD::EventInfo::PileUpMixtureID.
uint64_t mcEventNumber() const
The MC generator's event number.
const std::vector< float > & mcEventWeights() const
The weights of all the MC events used in the simulation.
void setAverageInteractionsPerCrossing(float value)
Set average interactions per crossing for all BCIDs.
void setBCID(uint32_t value)
Set the bunch crossing ID of the event.
uint32_t lumiBlock() const
The current event's luminosity block number.
void setMCEventNumber(uint64_t value)
Set the MC generator's event number.
uint32_t eventTypeBitmask() const
The event type bitmask.
uint32_t bcid() const
The bunch crossing ID of the event.
void setTimeStamp(uint32_t value)
Set the POSIX time of the event.
void clearSubEvents()
Clear all the currently held sub-events.
void setEventNumber(uint64_t value)
Set the current event's event number.
float averageInteractionsPerCrossing() const
Average interactions per crossing for all BCIDs - for out-of-time pile-up.
PileUpMixtureID pileUpMixtureID() const
Unique pile-up mixture identifier.
float actualInteractionsPerCrossing() const
Average interactions per crossing for the current BCID - for in-time pile-up.
void setPileUpMixtureID(const PileUpMixtureID &value)
Set unique pile-up mixture identifier.
void setEventTypeBitmask(uint32_t value)
Set the event type bitmask.
void setMCChannelNumber(uint32_t value)
Set the MC generator's channel number.
const std::vector< SubEvent > & subEvents() const
Get the pileup events that were used in the simulation.
void setMCEventWeights(const std::vector< float > &value)
Set the weights of all the MC events used in the simulation.
void setRunNumber(uint32_t value)
Set the current event's run number.
void setEvtStore(StoreGateSvc *svc)
Set the pointer to the event store associated with this event.
@ Signal
The signal event.
@ IS_SIMULATION
true: simulation, false: data
uint32_t runNumber() const
The current event's run number.
uint32_t mcChannelNumber() const
The MC generator's channel number.
uint64_t eventNumber() const
The current event's event number.
void setLumiBlock(uint32_t value)
Set the current event's luminosity block number.
void setActualInteractionsPerCrossing(float value)
Set average interactions per crossing for the current BCID.
EventInfoContainer_v1 EventInfoContainer
Define the latest version of the container.
EventInfo_v1 EventInfo
Definition of the latest event info version.
EventInfoAuxContainer_v1 EventInfoAuxContainer
Define the latest version of the auxiliary container.