From cc3f0bef7e4661d95b2552a1606c11f65f6349f8 Mon Sep 17 00:00:00 2001 From: Marcin Nowak <Marcin.Nowak@cern.ch> Date: Tue, 18 Dec 2018 15:20:47 +0100 Subject: [PATCH] migrate PileUpEventInfo to xAOD::EvenInfo --- Control/AthenaServices/src/AthIncFirerAlg.cxx | 13 +- Control/IOVSvc/src/IOVSvcTool.cxx | 3 +- Control/PileUpComps/src/BkgStreamsCache.cxx | 78 ++-- Control/PileUpComps/src/BkgStreamsCache.h | 11 +- .../src/BkgStreamsConcentricCache.cxx | 35 +- .../src/BkgStreamsConcentricCache.h | 10 +- .../PileUpComps/src/BkgStreamsStepCache.cxx | 44 ++- Control/PileUpComps/src/BkgStreamsStepCache.h | 10 +- .../PileUpComps/src/PileUpEventLoopMgr.cxx | 361 ++++++++---------- Control/PileUpComps/src/PileUpEventLoopMgr.h | 3 +- .../PileUpComps/src/SplitBkgStreamsCache.cxx | 37 +- .../PileUpComps/src/SplitBkgStreamsCache.h | 17 +- Control/PileUpTools/CMakeLists.txt | 6 +- .../PileUpTools/IBkgStreamsCache.h | 6 +- Control/PileUpTools/PileUpTools/IPileUpTool.h | 2 - .../PileUpTools/PileUpTools/PileUpMergeSvc.h | 6 +- .../PileUpTools/PileUpMergeSvc.icc | 98 ++--- .../PileUpTools/PileUpTools/PileUpStream.h | 17 +- Control/PileUpTools/src/PileUpMergeSvc.cxx | 31 +- Control/PileUpTools/src/PileUpStream.cxx | 177 +++++++-- Control/SGTools/SGTools/EventIDFromStore.h | 59 +++ .../OutputStreamAthenaPool/CMakeLists.txt | 6 +- .../src/MakeEventStreamInfo.cxx | 37 +- .../src/MakeEventStreamInfo.h | 5 + Database/IOVDbSvc/src/IOVDbSvc.cxx | 21 +- Event/EventInfoMgt/src/TagInfoMgr.cxx | 40 +- .../share/OverlayOutputItemList_jobOptions.py | 2 +- .../share/SignalOutputItemList_jobOptions.py | 2 +- .../xAODCnvInterfaces/IEventInfoCnvTool.h | 8 + .../xAODEventInfoCnv/src/EventInfoCnvAlg.cxx | 2 + .../xAODEventInfoCnv/src/EventInfoCnvTool.cxx | 55 +++ .../xAODEventInfoCnv/src/EventInfoCnvTool.h | 6 + .../LArDigitization/src/LArPileUpTool.cxx | 33 +- .../CSC_Digitization/CscDigitizationTool.h | 2 - .../src/CscDigitizationTool.cxx | 13 +- Simulation/Digitization/python/DigiOutput.py | 3 +- .../TrigT1CaloSim/src/TriggerTowerMaker.cxx | 11 +- 37 files changed, 766 insertions(+), 504 deletions(-) create mode 100644 Control/SGTools/SGTools/EventIDFromStore.h diff --git a/Control/AthenaServices/src/AthIncFirerAlg.cxx b/Control/AthenaServices/src/AthIncFirerAlg.cxx index 8d126b468823..9b5f6191d1c4 100644 --- a/Control/AthenaServices/src/AthIncFirerAlg.cxx +++ b/Control/AthenaServices/src/AthIncFirerAlg.cxx @@ -24,12 +24,14 @@ StatusCode AthIncFirerAlg::execute(const EventContext& ctx)const { auto ctxcp=ctx; for(auto & i:m_incLists.value()){ ATH_MSG_VERBOSE("Firing incident "<<i); - if((i=="BeginEvent")||(i=="EndEvent")){ - const EventInfo* event(0); - evtStore()->retrieve(event).ignore(); - m_incSvc->fireIncident(std::make_unique<EventIncident>(*event, name(),i,ctxcp)); - if(m_Serial.value())m_incSvc->fireIncident(EventIncident(*event, name(),i,ctxcp)); + const EventInfo* event = evtStore()->tryConstRetrieve<EventInfo>(); + if( event ) { + m_incSvc->fireIncident(std::make_unique<EventIncident>(*event, name(),i,ctxcp)); + if(m_Serial.value())m_incSvc->fireIncident(EventIncident(*event, name(),i,ctxcp)); + } else { + ATH_MSG_WARNING("EventInfo not found, not Firing incident "<<i); + } }else{ m_incSvc->fireIncident(std::make_unique<Incident>(name(),i,ctxcp)); if(m_Serial.value())m_incSvc->fireIncident(Incident( name(),i,ctxcp)); @@ -38,6 +40,7 @@ StatusCode AthIncFirerAlg::execute(const EventContext& ctx)const { return StatusCode::SUCCESS; } + StatusCode AthIncFirerAlg::finalize(){ return StatusCode::SUCCESS; } diff --git a/Control/IOVSvc/src/IOVSvcTool.cxx b/Control/IOVSvc/src/IOVSvcTool.cxx index cbc548abf17e..5b05185596da 100644 --- a/Control/IOVSvc/src/IOVSvcTool.cxx +++ b/Control/IOVSvc/src/IOVSvcTool.cxx @@ -375,7 +375,8 @@ IOVSvcTool::handle(const Incident &inc) { } } else { - if (StatusCode::SUCCESS != p_sgSvc->retrieve(evt)) { + evt = p_sgSvc->tryConstRetrieve<EventInfo>(); + if( !evt ) { // If EventInfo is not in the event store, check whether it // has come via the BeginRun incident const EventIncident* eventInc = dynamic_cast<const EventIncident*>(&inc); diff --git a/Control/PileUpComps/src/BkgStreamsCache.cxx b/Control/PileUpComps/src/BkgStreamsCache.cxx index 08f3e313cda5..3e6404cb2f21 100644 --- a/Control/PileUpComps/src/BkgStreamsCache.cxx +++ b/Control/PileUpComps/src/BkgStreamsCache.cxx @@ -17,11 +17,13 @@ #include "CLHEP/Random/RandFlat.h" #include "CLHEP/Random/RandPoisson.h" -#include "EventInfo/PileUpEventInfo.h" + #include "EventInfo/PileUpTimeEventIndex.h" -#include "EventInfo/EventID.h" +#include "xAODEventInfo/EventInfoContainer.h" + #include "PileUpTools/IBeamIntensity.h" #include "AthenaBaseComps/AthMsgStreamMacros.h" +#include "AthenaKernel/errorcheck.h" #include "BkgStreamsCache.h" @@ -29,6 +31,8 @@ #include <algorithm> #endif +#include <iostream> +using namespace std; BkgStreamsCache::BkgStreamsCache( const std::string& type, const std::string& name, @@ -45,7 +49,7 @@ BkgStreamsCache::BkgStreamsCache( const std::string& type, , m_atRndmSvc("AtRndmGenSvc", name) , m_randomStreamName("PileUpCollXingStream") , m_pileUpEventTypeProp(0) - , m_pileUpEventType(PileUpTimeEventIndex::Signal) + , m_pileUpEventType(xAOD::EventInfo::PileUpType::Signal) , m_subtractBC0(0) , m_ignoreBM(false) , m_readEventRand(nullptr) @@ -68,7 +72,7 @@ BkgStreamsCache::BkgStreamsCache( const std::string& type, declareProperty("RndmGenSvc", m_atRndmSvc, "IAtRndmGenSvc controlling the distribution of bkg events/xing"); declareProperty("RndmStreamName", m_randomStreamName, "IAtRndmGenSvc stream used as engine for our various random distributions, including the CollPerXing one "); declareProperty("SubtractBC0", m_subtractBC0, "reduce the number of events at bunch xing t=0 by m_subtractBC0. Default=0, set to 1 when using the same type of events (e.g. minbias) for original and background streams"); - m_pileUpEventTypeProp.verifier().setUpper(PileUpTimeEventIndex::NTYPES-2); + m_pileUpEventTypeProp.verifier().setUpper(xAOD::EventInfo::PileUpType::ZeroBias); // FIX m_pileUpEventTypeProp.declareUpdateHandler(&BkgStreamsCache::PileUpEventTypeHandler, this); declareProperty("IgnoreBeamInt", m_ignoreBM, "Default=False, set to True to ignore the PileUpEventLoopMgr beam intensity tool in setting the number of events per xing."); declareProperty("IgnoreBeamLumi", m_ignoreSF, "Default=False, set to True to ignore the PileUpEventLoopMgr beam luminosity tool in setting the number of events per xing."); @@ -85,7 +89,7 @@ BkgStreamsCache::~BkgStreamsCache() void BkgStreamsCache::PileUpEventTypeHandler(Property&) { - m_pileUpEventType=PileUpTimeEventIndex::ushortToType(m_pileUpEventTypeProp.value()); + m_pileUpEventType=(xAOD::EventInfo::PileUpType)PileUpTimeEventIndex::ushortToType(m_pileUpEventTypeProp.value()); } StatusCode @@ -189,9 +193,9 @@ void BkgStreamsCache::newEvent() } //TODO update this method!! -const EventInfo* BkgStreamsCache::nextEvent(bool isCentralBunchCrossing) +const xAOD::EventInfo* BkgStreamsCache::nextEvent(bool isCentralBunchCrossing) { - const EventInfo* pNextEvt(0); + const xAOD::EventInfo* pNextEvt(0); StreamVector::size_type iS(0); do { iS = (StreamVector::size_type)m_chooseEventRand->fire(); @@ -202,6 +206,7 @@ const EventInfo* BkgStreamsCache::nextEvent(bool isCentralBunchCrossing) std::advance(m_cursor, iS); ATH_MSG_DEBUG ( "using store " << iS ); + cout << "MN: using store " << iS <<endl; PileUpStream* pCurrStream(current()); if (0 != pCurrStream) { p_activeStore->setStore(&(pCurrStream->store())); @@ -210,8 +215,9 @@ const EventInfo* BkgStreamsCache::nextEvent(bool isCentralBunchCrossing) //FIXME a more careful strategy would have the PileUpStreams knowing if //they have been used for the central bunch-crossing already. bool readEvent(isCentralBunchCrossing || (m_readEventRand->fire()<1.0)); - pNextEvt=pCurrStream->nextEventPre(readEvent); + pNextEvt = pCurrStream->nextEventPre( readEvent ); } + cout << "BkgStreamsCache::nextEvent returns " << pNextEvt<<endl; return pNextEvt; } @@ -262,10 +268,15 @@ PileUpStream* BkgStreamsCache::current() StatusCode BkgStreamsCache::initialize() { + this->msg().setLevel(MSG::DEBUG); + cout << "MN: Initializing " << name() + << " - cache for events of type " + << PileUpTimeEventIndex::typeName((PileUpTimeEventIndex::PileUpType)m_pileUpEventType) <<endl; ATH_MSG_DEBUG ( "Initializing " << name() << " - cache for events of type " - << PileUpTimeEventIndex::typeName(m_pileUpEventType) + << PileUpTimeEventIndex::typeName((PileUpTimeEventIndex::PileUpType)m_pileUpEventType) << " - package version " << PACKAGE_VERSION ) ; + PileUpEventTypeHandler(m_pileUpEventTypeProp); //locate the ActiveStoreSvc and initialize our local ptr ATH_CHECK(service("ActiveStoreSvc", p_activeStore)); @@ -362,27 +373,31 @@ unsigned int BkgStreamsCache::setNEvtsXing(unsigned int iXing) } StatusCode BkgStreamsCache::addSubEvts(unsigned int iXing, - PileUpEventInfo& overEvent, + xAOD::EventInfo* overEvent, int t0BinCenter) { return this->addSubEvts(iXing, overEvent, t0BinCenter, true, 0); } + StatusCode BkgStreamsCache::addSubEvts(unsigned int iXing, - PileUpEventInfo& overEvent, + xAOD::EventInfo* overEvent, int t0BinCenter, bool loadEventProxies, unsigned int BCID) { + cout << "MN: BkgStreamsCache::addSubEvts start" << endl; for (unsigned int iEvt=0; iEvt<nEvtsXing(iXing); ++iEvt) { // check if we're picking events for the central bunch-crossing, // so we can choose to only use fresh events here. bool isCentralBunchCrossing((0==t0BinCenter)&&m_forceReadForBC0); // increment event iterators - if(!loadEventProxies) - { + //cout << "MN: BkgStreamsCache::addSubEvts 1" << endl; + if(!loadEventProxies) { return this->nextEvent_passive(isCentralBunchCrossing); - } - const EventInfo* pBkgEvent(this->nextEvent(isCentralBunchCrossing)); //FIXME update this for the case where loadProxies=False + } + //cout << "MN: BkgStreamsCache::addSubEvts 2" << endl; + const xAOD::EventInfo* pBkgEvent = nextEvent( isCentralBunchCrossing ); //FIXME update this for the case where loadProxies=False + //cout << "MN: BkgStreamsCache::addSubEvts Bei=" << pBkgEvent <<endl; //check input selector is not empty PileUpStream* currStream(this->current()); @@ -393,17 +408,36 @@ StatusCode BkgStreamsCache::addSubEvts(unsigned int iXing, return StatusCode::FAILURE; } StoreGateSvc* pBkgStore = &(currStream->store()); - ATH_MSG_DEBUG ( "added event " << pBkgEvent->event_ID()->event_number() - << " run " << pBkgEvent->event_ID()->run_number() + ATH_MSG_DEBUG ( "added event " << pBkgEvent->eventNumber() + << " run " << pBkgEvent->runNumber() << " from store " << pBkgStore->name() << " @ Xing " << iXing ); - + cout << "MN: added event " << pBkgEvent->eventNumber() + << " run " << pBkgEvent->runNumber() << " from store " + << pBkgStore->name() << " @ Xing " << iXing << endl; + cout << "MN: overEvent->evtStore()=" << overEvent->evtStore() << endl; // register as sub event of the overlaid // ask if sufficient/needed - overEvent.addSubEvt(t0BinCenter, BCID, - m_pileUpEventType, - *pBkgEvent, pBkgStore); + + // get the SG container for subevents infos + xAOD::EventInfoContainer *subEvCnt (nullptr); + //cout << "MN: BkgStreamsCache::addSubEvts - trying to retrieve EI container" <<endl; + ATH_CHECK( overEvent->evtStore()->retrieve(subEvCnt) ); + // add subevent to the container + //cout << "MN: BkgStreamsCache::addSubEvts - after retrieve EI container" <<endl; + xAOD::EventInfo* sub_event = new xAOD::EventInfo( *pBkgEvent ); + sub_event->setBCID( BCID ); + subEvCnt->push_back( sub_event ); + // MN: FIX: Shold we also copy subevents of bkg event? + ElementLink< xAOD::EventInfoContainer > subEvtLink( "PileUpEventInfo", subEvCnt->size()-1, overEvent->evtStore() ); + unsigned sub_idx = overEvent->subEvents().size(); + xAOD::EventInfo::SubEvent subev( t0BinCenter, sub_idx, m_pileUpEventType, subEvtLink ); + overEvent->addSubEvent( subev ); + cout << "MN: subevent: " << sub_event->eventNumber() << " " << t0BinCenter << " " << sub_idx << " " << m_pileUpEventType << endl; + +// overEvent->addSubEvent(t0BinCenter, BCID, m_pileUpEventType, *pBkgEvent, pBkgStore); + #ifdef DEBUG_PILEUP const EventInfo* pStoreInfo(nullptr); if (pBkgStore->retrieve(pStoreInfo).isSuccess() && pStoreInfo && @@ -428,7 +462,7 @@ StatusCode BkgStreamsCache::finalize() StatusCode sc(StatusCode::SUCCESS); ATH_MSG_DEBUG ( "Finalizing " << name() << " - cache for events of type " - << PileUpTimeEventIndex::typeName(m_pileUpEventType) + // << PileUpTimeEventIndex::typeName(m_pileUpEventType) << " - package version " << PACKAGE_VERSION ); while (sc.isSuccess() && m_streams.size()>0) { diff --git a/Control/PileUpComps/src/BkgStreamsCache.h b/Control/PileUpComps/src/BkgStreamsCache.h index 33228a3e8e8a..4eb0512c6460 100644 --- a/Control/PileUpComps/src/BkgStreamsCache.h +++ b/Control/PileUpComps/src/BkgStreamsCache.h @@ -20,14 +20,11 @@ #include "GaudiKernel/Property.h" #include "PileUpTools/PileUpStream.h" #include "PileUpTools/IBkgStreamsCache.h" -#include "EventInfo/PileUpTimeEventIndex.h" /* needed for PileUpType */ class ActiveStoreSvc; -class EventInfo; class IEvtSelector; class IAtRndmGenSvc; class IBeamIntensity; -class PileUpEventInfo; namespace CLHEP { class RandFlat; class RandPoisson; @@ -65,7 +62,7 @@ public: @param t0BinCenter time wrto t0 of current bin center in ns */ virtual StatusCode addSubEvts(unsigned int iXing, - PileUpEventInfo& overlaidEvent, + xAOD::EventInfo* overlaidEvent, int t0BinCenter) override final; /** @brief Read input events in bkg stores and link them to overlay store @@ -76,7 +73,7 @@ public: @param BCID bunch-crossing ID of signal bunch crossing */ virtual StatusCode addSubEvts(unsigned int iXing, - PileUpEventInfo& overEvent, + xAOD::EventInfo* overEvent, int t0BinCenter, bool loadEventProxies, unsigned int /*BCID*/) override final; /// how many stores in this cache virtual unsigned int nStores() const override final { return m_nStores; } @@ -90,7 +87,7 @@ public: unsigned int numberOfCavernBkgForBunchCrossing(unsigned int iXing) const; private: /// get next bkg event from cache - const EventInfo* nextEvent(bool isCentralBunchCrossing); + const xAOD::EventInfo* nextEvent(bool isCentralBunchCrossing); /// as nextEvent except don't actually load anything StatusCode nextEvent_passive(bool isCentralBunchCrossing); /// get current (last asked) stream @@ -128,7 +125,7 @@ private: Gaudi::CheckedProperty<unsigned short> m_pileUpEventTypeProp; void PileUpEventTypeHandler(Property&); /// the type of events in this cache - PileUpTimeEventIndex::PileUpType m_pileUpEventType; + xAOD::EventInfo::PileUpType m_pileUpEventType; /// subtract from number of events at bunch xing = 0 Gaudi::Property<unsigned short> m_subtractBC0; /// ignore the PileUpEventLoopMgr beam intensity tool diff --git a/Control/PileUpComps/src/BkgStreamsConcentricCache.cxx b/Control/PileUpComps/src/BkgStreamsConcentricCache.cxx index ccc06ea2c8b3..8a37442399be 100644 --- a/Control/PileUpComps/src/BkgStreamsConcentricCache.cxx +++ b/Control/PileUpComps/src/BkgStreamsConcentricCache.cxx @@ -23,9 +23,8 @@ #include "CLHEP/Random/RandFlat.h" #include "CLHEP/Random/RandPoisson.h" -#include "EventInfo/PileUpEventInfo.h" #include "EventInfo/PileUpTimeEventIndex.h" -#include "EventInfo/EventID.h" +#include "xAODEventInfo/EventInfoContainer.h" #include "AthenaBaseComps/AthMsgStreamMacros.h" #include "BkgStreamsConcentricCache.h" @@ -50,7 +49,7 @@ BkgStreamsConcentricCache::BkgStreamsConcentricCache( const std::string& type, m_atRndmSvc("AtRndmGenSvc", name), m_randomStreamName("PileUpCollXingStream"), m_pileUpEventTypeProp(0), - m_pileUpEventType(PileUpTimeEventIndex::Signal), + m_pileUpEventType(xAOD::EventInfo::PileUpType::Signal), m_ringsProp(), m_allowRingMigProp(false), m_readEventRand(0), @@ -68,7 +67,7 @@ BkgStreamsConcentricCache::BkgStreamsConcentricCache( const std::string& type, declareProperty("RndmGenSvc", m_atRndmSvc, "IAtRndmGenSvc controlling the distribution of bkg events/xing"); declareProperty("RndmStreamName", m_randomStreamName, "IAtRndmGenSvc stream used as engine for our various random distributions, including the CollPerXing one "); declareProperty("PileUpEventType", m_pileUpEventTypeProp, "Type of the pileup events in this cache: 0:Signal, 1:MinimumBias, 2:Cavern, 3:HaloGas, 4:ZeroBias"); - m_pileUpEventTypeProp.verifier().setUpper(PileUpTimeEventIndex::NTYPES-2); + m_pileUpEventTypeProp.verifier().setUpper((xAOD::EventInfo::PileUpType)PileUpTimeEventIndex::NTYPES-2); m_pileUpEventTypeProp.declareUpdateHandler(&BkgStreamsConcentricCache::PileUpEventTypeHandler, this); declareProperty("NonIntersectingRings", m_ringsProp, "Array of rings specified in the form lowXing:hiXing. Rings must not intersect (e.g. -7:7, -3:0, -1:0) or an exception will be thrown"); @@ -87,7 +86,7 @@ BkgStreamsConcentricCache::~BkgStreamsConcentricCache() { void BkgStreamsConcentricCache::PileUpEventTypeHandler(Property&) { - m_pileUpEventType=PileUpTimeEventIndex::ushortToType(m_pileUpEventTypeProp.value()); + m_pileUpEventType=(xAOD::EventInfo::PileUpType)PileUpTimeEventIndex::ushortToType(m_pileUpEventTypeProp.value()); } void @@ -201,8 +200,8 @@ void BkgStreamsConcentricCache::newEvent() { mem_fun_ref(&PileUpStream::resetUsed)); } -const EventInfo* BkgStreamsConcentricCache::nextEvent(unsigned int iXing) { - const EventInfo* pNextEvt(0); +const xAOD::EventInfo* BkgStreamsConcentricCache::nextEvent(unsigned int iXing) { + const xAOD::EventInfo* pNextEvt(0); //find the first ring containing iXing unsigned int iRing(0); while (iRing<m_rings.size() && (!m_rings[iRing++].contains(iXing))) { } @@ -310,7 +309,7 @@ StatusCode BkgStreamsConcentricCache::initialize() { StatusCode sc(StatusCode::SUCCESS); ATH_MSG_INFO ( "Initializing " << name() << " - cache for events of type " - << PileUpTimeEventIndex::typeName(m_pileUpEventType) + << PileUpTimeEventIndex::typeName((PileUpTimeEventIndex::PileUpType)m_pileUpEventType) << " - package version " << PACKAGE_VERSION ) ; PileUpEventTypeHandler(m_pileUpEventTypeProp); //locate the ActiveStoreSvc and initialize our local ptr @@ -363,13 +362,13 @@ unsigned int BkgStreamsConcentricCache::setNEvtsXing(unsigned int iXing) { } StatusCode BkgStreamsConcentricCache::addSubEvts(unsigned int iXing, - PileUpEventInfo& overEvent, + xAOD::EventInfo* overEvent, int t0BinCenter) { return this->addSubEvts(iXing, overEvent, t0BinCenter, true, 0); } StatusCode BkgStreamsConcentricCache::addSubEvts(unsigned int iXing, - PileUpEventInfo& overEvent, + xAOD::EventInfo* overEvent, int t0BinCenter, bool loadEventProxies, unsigned int /*BCID*/) { for (unsigned int iEvt=0; iEvt<nEvtsXing(iXing); ++iEvt) { StoreGateSvc* pBkgStore(0); @@ -379,7 +378,7 @@ StatusCode BkgStreamsConcentricCache::addSubEvts(unsigned int iXing, { return this->nextEvent_passive(iXing); } - const EventInfo* pBkgEvent(nextEvent(iXing)); + const xAOD::EventInfo* pBkgEvent(nextEvent(iXing)); //check input selector is not empty PileUpStream* currStream(current()); @@ -389,8 +388,8 @@ StatusCode BkgStreamsConcentricCache::addSubEvts(unsigned int iXing, return StatusCode::FAILURE; } else { pBkgStore = &(currStream->store()); - ATH_MSG_DEBUG ( "added event " << pBkgEvent->event_ID()->event_number() - << " run " << pBkgEvent->event_ID()->run_number() + ATH_MSG_DEBUG ( "added event " << pBkgEvent->eventNumber() + << " run " << pBkgEvent->runNumber() << " from store " << pBkgStore->name() << " @ Xing " << iXing ); @@ -398,9 +397,11 @@ StatusCode BkgStreamsConcentricCache::addSubEvts(unsigned int iXing, // register as sub event of the overlaid // ask if sufficient/needed - overEvent.addSubEvt(t0BinCenter, - m_pileUpEventType, - pBkgEvent, pBkgStore);//,BCID); FIXME:Changes needed to PileUpEventInfo to do this. + + ATH_MSG_ERROR("NOT IMPLEMENTED!"); +// overEvent.addSubEvt(t0BinCenter, m_pileUpEventType, pBkgEvent, pBkgStore);//,BCID); FIXME:Changes needed to PileUpEventInfo to do this. + + #ifdef DEBUG_PILEUP const EventInfo* pStoreInfo(0); if (pBkgStore->retrieve(pStoreInfo).isSuccess() && pStoreInfo && @@ -423,7 +424,7 @@ StatusCode BkgStreamsConcentricCache::finalize() { StatusCode sc(StatusCode::SUCCESS); ATH_MSG_INFO ( "Finalizing " << name() << " - cache for events of type " - << PileUpTimeEventIndex::typeName(m_pileUpEventType) + << PileUpTimeEventIndex::typeName((PileUpTimeEventIndex::PileUpType)m_pileUpEventType) << " - package version " << PACKAGE_VERSION ) ; while (sc.isSuccess() && m_streams.size()>0) { sc=m_streams.back().finalize(); diff --git a/Control/PileUpComps/src/BkgStreamsConcentricCache.h b/Control/PileUpComps/src/BkgStreamsConcentricCache.h index 07b5b4c55df7..3eba5e30b957 100644 --- a/Control/PileUpComps/src/BkgStreamsConcentricCache.h +++ b/Control/PileUpComps/src/BkgStreamsConcentricCache.h @@ -31,11 +31,9 @@ #include "AthenaKernel/MsgStreamMember.h" class ActiveStoreSvc; -class EventInfo; class IEvtSelector; class IAtRndmGenSvc; class IBeamIntensity; -class PileUpEventInfo; namespace CLHEP { class RandFlat; class RandPoisson; @@ -73,7 +71,7 @@ public: @param t0BinCenter time wrto t0 of current bin center in ns */ virtual StatusCode addSubEvts(unsigned int iXing, - PileUpEventInfo& overlaidEvent, + xAOD::EventInfo* overlaidEvent, int t0BinCenter); /** @@ -85,7 +83,7 @@ public: @param loadEventProxies should we load the event proxies or not. */ virtual StatusCode addSubEvts(unsigned int iXing, - PileUpEventInfo& overEvent, + xAOD::EventInfo* overEvent, int t0BinCenter, bool loadEventProxies, unsigned int /*BCID*/); /// how many stores in cache virtual unsigned int nStores() const { return m_nStores; } @@ -137,7 +135,7 @@ public: private: /// get next bkg event for xing iXing from cache - const EventInfo* nextEvent(unsigned int iXing); + const xAOD::EventInfo* nextEvent(unsigned int iXing); /// as nextEvent except don't actually load anything StatusCode nextEvent_passive(unsigned int iXing); /// get current (last selected) stream @@ -177,7 +175,7 @@ private: Gaudi::CheckedProperty<unsigned short> m_pileUpEventTypeProp; void PileUpEventTypeHandler(Property&); /// the type of events in this cache - PileUpTimeEventIndex::PileUpType m_pileUpEventType; + xAOD::EventInfo::PileUpType m_pileUpEventType; void RingsPropHandler(Property&); /// the list of rings to be used in the form "lowXing:hiXing" Gaudi::Property<std::vector<std::string>> m_ringsProp; diff --git a/Control/PileUpComps/src/BkgStreamsStepCache.cxx b/Control/PileUpComps/src/BkgStreamsStepCache.cxx index c03485bf9e90..458801a3dcad 100644 --- a/Control/PileUpComps/src/BkgStreamsStepCache.cxx +++ b/Control/PileUpComps/src/BkgStreamsStepCache.cxx @@ -17,9 +17,8 @@ #include "CLHEP/Random/RandFlat.h" #include "CLHEP/Random/RandPoisson.h" -#include "EventInfo/PileUpEventInfo.h" #include "EventInfo/PileUpTimeEventIndex.h" -#include "EventInfo/EventID.h" +#include "xAODEventInfo/EventInfoContainer.h" #include "PileUpTools/IBeamIntensity.h" #include "AthenaBaseComps/AthMsgStreamMacros.h" @@ -47,7 +46,7 @@ BkgStreamsStepCache::BkgStreamsStepCache( const std::string& type, , m_atRndmSvc("AtRndmGenSvc", name) , m_randomStreamName("PileUpCollXingStream") , m_pileUpEventTypeProp(0) - , m_pileUpEventType(PileUpTimeEventIndex::Signal) + , m_pileUpEventType(xAOD::EventInfo::PileUpType::Signal) , m_subtractBC0(0) , m_ignoreBM(false) , m_readEventRand(nullptr) @@ -70,7 +69,7 @@ BkgStreamsStepCache::BkgStreamsStepCache( const std::string& type, declareProperty("RndmGenSvc", m_atRndmSvc, "IAtRndmGenSvc controlling the distribution of bkg events/xing"); declareProperty("RndmStreamName", m_randomStreamName, "IAtRndmGenSvc stream used as engine for our various random distributions, including the CollPerXing one "); declareProperty("SubtractBC0", m_subtractBC0, "reduce the number of events at bunch xing t=0 by m_subtractBC0. Default=0, set to 1 when using the same type of events (e.g. minbias) for original and background streams"); - m_pileUpEventTypeProp.verifier().setUpper(PileUpTimeEventIndex::NTYPES-2); + m_pileUpEventTypeProp.verifier().setUpper((xAOD::EventInfo::PileUpType)PileUpTimeEventIndex::NTYPES-2); m_pileUpEventTypeProp.declareUpdateHandler(&BkgStreamsStepCache::PileUpEventTypeHandler, this); declareProperty("IgnoreBeamInt", m_ignoreBM, "Default=False, set to True to ignore the PileUpEventLoopMgr beam intensity tool in setting the number of events per xing."); declareProperty("IgnoreBeamLumi", m_ignoreSF, "Default=False, set to True to ignore the PileUpEventLoopMgr beam luminosity tool in setting the number of events per xing."); @@ -87,7 +86,7 @@ BkgStreamsStepCache::~BkgStreamsStepCache() void BkgStreamsStepCache::PileUpEventTypeHandler(Property&) { - m_pileUpEventType=PileUpTimeEventIndex::ushortToType(m_pileUpEventTypeProp.value()); + m_pileUpEventType=(xAOD::EventInfo::PileUpType)PileUpTimeEventIndex::ushortToType(m_pileUpEventTypeProp.value()); } StatusCode @@ -263,8 +262,10 @@ void BkgStreamsStepCache::newEvent() { ATH_MSG_DEBUG ( "Ready to simulate BCID=" << m_currentXing ); } -const EventInfo* BkgStreamsStepCache::nextEvent() { - const EventInfo* pNextEvt(0); + +const xAOD::EventInfo* BkgStreamsStepCache::nextEvent() +{ + const xAOD::EventInfo* pNextEvt(0); StreamVector::size_type iS = *m_useCursor++; //get the next stream from the UseOrder and increment the useCursor @@ -323,7 +324,7 @@ StatusCode BkgStreamsStepCache::initialize() { StatusCode sc(StatusCode::SUCCESS); ATH_MSG_DEBUG ( "Initializing " << name() << " - cache for events of type " - << PileUpTimeEventIndex::typeName(m_pileUpEventType) + << PileUpTimeEventIndex::typeName((PileUpTimeEventIndex::PileUpType)m_pileUpEventType) << " - package version " << PACKAGE_VERSION ) ; PileUpEventTypeHandler(m_pileUpEventTypeProp); //locate the ActiveStoreSvc and initialize our local ptr @@ -410,13 +411,13 @@ unsigned int BkgStreamsStepCache::setNEvtsXing(unsigned int iXing) { } StatusCode BkgStreamsStepCache::addSubEvts(unsigned int iXing, - PileUpEventInfo& overEvent, + xAOD::EventInfo* overEvent, int t0BinCenter) { return this->addSubEvts(iXing, overEvent, t0BinCenter, true, 0); } StatusCode BkgStreamsStepCache::addSubEvts(unsigned int iXing, - PileUpEventInfo& overEvent, + xAOD::EventInfo* overEvent, int t0BinCenter, bool loadEventProxies, unsigned int BCID) { for (unsigned int iEvt=0; iEvt<nEvtsXing(iXing); ++iEvt) { StoreGateSvc* pBkgStore(0); @@ -426,7 +427,7 @@ StatusCode BkgStreamsStepCache::addSubEvts(unsigned int iXing, { return this->nextEvent_passive(); } - const EventInfo* pBkgEvent(nextEvent()); + const xAOD::EventInfo* pBkgEvent(nextEvent()); //check input selector is not empty PileUpStream* currStream(current()); @@ -436,8 +437,8 @@ StatusCode BkgStreamsStepCache::addSubEvts(unsigned int iXing, return StatusCode::FAILURE; } else { pBkgStore = &(currStream->store()); - ATH_MSG_DEBUG ( "added event " << pBkgEvent->event_ID()->event_number() - << " run " << pBkgEvent->event_ID()->run_number() + ATH_MSG_DEBUG ( "added event " << pBkgEvent->eventNumber() + << " run " << pBkgEvent->runNumber() << " from store " << pBkgStore->name() << " @ Xing " << iXing ); @@ -445,9 +446,18 @@ StatusCode BkgStreamsStepCache::addSubEvts(unsigned int iXing, // register as sub event of the overlaid // ask if sufficient/needed - overEvent.addSubEvt(t0BinCenter, BCID, - m_pileUpEventType, - *pBkgEvent, pBkgStore); + // overEvent.addSubEvt(t0BinCenter, BCID,m_pileUpEventType, *pBkgEvent, pBkgStore); + + // get the SG container for subevents infos + xAOD::EventInfoContainer *subEvCnt (nullptr); + ATH_CHECK( overEvent->evtStore()->retrieve(subEvCnt) ); + // add subevent to the container + subEvCnt->push_back( const_cast<xAOD::EventInfo*>(pBkgEvent) ); + + ElementLink< xAOD::EventInfoContainer > subEvtLink( "PileUpEventInfo", subEvCnt->size()-1, overEvent->evtStore() ); + xAOD::EventInfo::SubEvent subev( t0BinCenter, BCID, m_pileUpEventType, subEvtLink ); + + #ifdef DEBUG_PILEUP const EventInfo* pStoreInfo(0); if (pBkgStore->retrieve(pStoreInfo).isSuccess() && pStoreInfo && @@ -470,7 +480,7 @@ StatusCode BkgStreamsStepCache::finalize() { StatusCode sc(StatusCode::SUCCESS); ATH_MSG_DEBUG ( "Finalizing " << name() << " - cache for events of type " - << PileUpTimeEventIndex::typeName(m_pileUpEventType) + << PileUpTimeEventIndex::typeName((PileUpTimeEventIndex::PileUpType)m_pileUpEventType) << " - package version " << PACKAGE_VERSION ) ; while (sc.isSuccess() && m_streams.size()>0) { sc=m_streams.back().finalize(); diff --git a/Control/PileUpComps/src/BkgStreamsStepCache.h b/Control/PileUpComps/src/BkgStreamsStepCache.h index 70a1a394b6c1..cedff8b427ec 100644 --- a/Control/PileUpComps/src/BkgStreamsStepCache.h +++ b/Control/PileUpComps/src/BkgStreamsStepCache.h @@ -26,11 +26,9 @@ class ActiveStoreSvc; -class EventInfo; class IEvtSelector; class IAtRndmGenSvc; class IBeamIntensity; -class PileUpEventInfo; namespace CLHEP { class RandFlat; class RandPoisson; @@ -68,7 +66,7 @@ public: @param t0BinCenter time wrto t0 of current bin center in ns */ virtual StatusCode addSubEvts(unsigned int iXing, - PileUpEventInfo& overlaidEvent, + xAOD::EventInfo* overlaidEvent, int t0BinCenter) override final; /** @brief Read input events in bkg stores and link them to overlay store @@ -79,7 +77,7 @@ public: @param loadEventProxies should we load the event proxies or not. */ virtual StatusCode addSubEvts(unsigned int iXing, - PileUpEventInfo& overEvent, + xAOD::EventInfo* overEvent, int t0BinCenter, bool loadEventProxies, unsigned int /*BCID*/) override final; /// how many stores in cache virtual unsigned int nStores() const override final { return m_nStores; } @@ -93,7 +91,7 @@ public: unsigned int numberOfCavernBkgForBunchCrossing(unsigned int iXing) const; private: /// get next bkg event from cache - const EventInfo* nextEvent(); + const xAOD::EventInfo* nextEvent(); /// as nextEvent except don't actually load anything StatusCode nextEvent_passive(); /// get current (last asked) stream @@ -139,7 +137,7 @@ private: Gaudi::CheckedProperty<unsigned short> m_pileUpEventTypeProp; void PileUpEventTypeHandler(Property&); /// the type of events in this cache - PileUpTimeEventIndex::PileUpType m_pileUpEventType; + xAOD::EventInfo::PileUpType m_pileUpEventType; /// subtract from number of events at bunch xing = 0 Gaudi::Property<unsigned short> m_subtractBC0; /// ignore the PileUpEventLoopMgr beam intensity tool diff --git a/Control/PileUpComps/src/PileUpEventLoopMgr.cxx b/Control/PileUpComps/src/PileUpEventLoopMgr.cxx index 40de1fd4e315..35d3d0b435a6 100644 --- a/Control/PileUpComps/src/PileUpEventLoopMgr.cxx +++ b/Control/PileUpComps/src/PileUpEventLoopMgr.cxx @@ -30,10 +30,10 @@ #include "xAODEventInfo/EventAuxInfo.h" // NEW EDM #include "xAODEventInfo/EventInfoContainer.h" // NEW EDM #include "xAODEventInfo/EventInfoAuxContainer.h" // NEW EDM -#include "xAODCnvInterfaces/IEventInfoCnvTool.h" // xAOD include(s): -//#include "xAODCore/tools/PrintHelpers.h" +#include "xAODCore/tools/PrintHelpers.h" +#include "xAODCnvInterfaces/IEventInfoCnvTool.h" // Gaudi headers #include "GaudiKernel/IAlgorithm.h" @@ -48,7 +48,8 @@ // std library headers #include <cmath> -//#include <vector> +#include <iostream> +using namespace std; //========================================================================= // Standard Constructor @@ -308,14 +309,14 @@ StatusCode PileUpEventLoopMgr::nextEvent(int maxevt) } } - const EventInfo* pEvent(0); - const EventInfo* pEventSignal(0); + const xAOD::EventInfo* pEvent(0), *pEventSignal(0); + // loop over events if the maxevt (received as input) is different from -1. // if evtmax is -1 it means infinite loop (till time limit that is) bool noTimeLimit(false); while( (maxevt == -1 || m_nevt < maxevt) && (noTimeLimit = (m_timeKeeper.empty() || m_timeKeeper->nextIter()) ) && - 0 != (pEvent = m_origStream.nextEventPre()) ) //FIXME this call has to be able to cope with xAOD::EventInfo rather than EventInfo being in m_origStream + 0 != (pEvent = m_origStream.nextEventPre()) ) { if (m_isEventOverlayJob) { pEventSignal = m_signalStream.nextEventPre(); @@ -330,138 +331,158 @@ StatusCode PileUpEventLoopMgr::nextEvent(int maxevt) } ++m_nevt; ++total_nevt; ++m_ncurevt; ATH_MSG_INFO ( "nextEvent(): overlaying original event " << - pEvent->event_ID()->run_number() << '/' << - pEvent->event_ID()->event_number() << '/' << - pEvent->event_ID()->lumi_block() ); + pEvent->runNumber() << '/' << + pEvent->eventNumber() << '/' << + pEvent->lumiBlock() ); //----------------------------------------------------------------------- // Setup overlaid event in the event store //----------------------------------------------------------------------- + + // EventID* pOvrID = new EventID(*(pEvent->event_ID())); + // unsigned int t0BCID(pOvrID->bunch_crossing_id()); + // FIX experimental code replacement: + // PileUpEventInfo *pOverEvent = new PileUpEventInfo(pOvrID, pOvrEt); + + xAOD::EventInfo *pOverEvent = new xAOD::EventInfo(); + xAOD::EventAuxInfo *pOverEventAux = new xAOD::EventAuxInfo(); + pOverEvent->setStore( pOverEventAux ); + // Copy the eventInfo data from origStream event + *pOverEvent = *pEvent; + + // Record the xAOD object(s): + CHECK( m_evtStore->record( pOverEventAux, "McEventInfoAux." ) ); + CHECK( m_evtStore->record( pOverEvent, "McEventInfo" ) ); + pOverEvent->setEvtStore( &*m_evtStore ); // FIX: MN: why record() does not set this? is m_evtStore the right one to use? + // Create an EventInfoContainer for the pileup events: + xAOD::EventInfoContainer *puei(new xAOD::EventInfoContainer()); + xAOD::EventInfoAuxContainer *puaux(new xAOD::EventInfoAuxContainer()); + puei->setStore( puaux ); + + // Record the EI container object(s): + const std::string puei_sg_key( "PileUpEventInfo" ); // FIX MN: name? + CHECK( m_evtStore->record( puei, puei_sg_key ) ); + CHECK( m_evtStore->record( puaux, puei_sg_key+"Aux." ) ); + //ask the BeamIntensitySvc to choose (and remember) //in which xing this event will be wrto the beam int distribution m_beamInt->selectT0(); - EventID* pOvrID = new EventID(*(pEvent->event_ID())); - unsigned int t0BCID(pOvrID->bunch_crossing_id()); - if (!m_isEventOverlayJob) - { - // Use the position in the beam intensity array to set a BCID-like quantity - t0BCID = m_beamInt->getCurrentT0BunchCrossing(); - pOvrID->set_bunch_crossing_id(t0BCID); - } - else if (m_isEventOverlayJobMC) - { - pOvrID->set_event_number(pEventSignal->event_ID()->event_number()); - } - ATH_MSG_VERBOSE ( "BCID =" << pOvrID->bunch_crossing_id() ); - EventType *pOvrEt = new EventType(); //FIXME - pOvrEt->set_user_type("Overlaid"); //FIXME - if (m_isEventOverlayJob) - { - ATH_MSG_INFO ( "nextEvent(): using signal event " << - pEventSignal->event_type()->mc_channel_number() << '/' << - pEventSignal->event_type()->mc_event_number() ); - - pOvrEt->set_mc_channel_number(pEventSignal->event_type()->mc_channel_number()); - pOvrEt->set_mc_event_number(pEventSignal->event_type()->mc_event_number()); - const unsigned int nWeights(pEventSignal->event_type()->n_mc_event_weights()); - for (unsigned int iWeight(0); iWeight<nWeights; ++iWeight) - { - pOvrEt->set_mc_event_weight(pEventSignal->event_type()->mc_event_weight(iWeight),iWeight); - } - - // MC+MC overlay should always be marked as simulation - if (m_isEventOverlayJobMC) - { - pOvrEt->add_type(EventType::IS_SIMULATION); - } - } - else - { - pOvrEt->set_mc_channel_number(pEvent->event_type()->mc_channel_number()); - pOvrEt->set_mc_event_number(pEvent->event_type()->mc_event_number()); - const unsigned int nWeights(pEvent->event_type()->n_mc_event_weights()); - for (unsigned int iWeight(0); iWeight<nWeights; ++iWeight) - { - pOvrEt->set_mc_event_weight(pEvent->event_type()->mc_event_weight(iWeight),iWeight); - } - + if (!m_isEventOverlayJob) { + // Use the position in the beam intensity array to set a BCID-like quantity + pOverEvent->setBCID( m_beamInt->getCurrentT0BunchCrossing() ); + } + else if (m_isEventOverlayJobMC) { + pOverEvent->setEventNumber( pEventSignal->eventNumber() ); + } + + unsigned int t0BCID = pOverEvent->bcid(); + ATH_MSG_VERBOSE ( "BCID =" << t0BCID ); + + // EventType *pOvrEt = new EventType(); //FIXME + // pOvrEt->set_user_type("Overlaid"); //FIXME ?? MN: ?? what to do with that + + if (m_isEventOverlayJob) { + ATH_MSG_INFO ( "nextEvent(): using signal event " << + pEventSignal->mcChannelNumber() << '/' << + pEventSignal->mcEventNumber() ); + + pOverEvent->setMCChannelNumber( pEventSignal->mcChannelNumber() ); + pOverEvent->setMCEventNumber( pEventSignal->mcEventNumber() ); + pOverEvent->setMCEventWeights( pEventSignal->mcEventWeights() ); + // MC+MC overlay should always be marked as simulation + if (m_isEventOverlayJobMC) { + pOverEvent->setEventTypeBitmask( xAOD::EventInfo::IS_SIMULATION ); + } + } else { + ATH_MSG_INFO ( "MN: nextEvent(): NOT Overlay" ); // Overlay RDO files should be treated like data for reco // purposes, so only set this for SimHit level pile-up. - pOvrEt->add_type(EventType::IS_SIMULATION); - } + pOverEvent->setEventTypeBitmask( pEvent->eventTypeBitmask() | xAOD::EventInfo::IS_SIMULATION ); + } - PileUpEventInfo *pOverEvent = new PileUpEventInfo(pOvrID, pOvrEt); if(m_isEmbedding || m_isEventOverlayJobMC) { pOverEvent->setActualInteractionsPerCrossing(pEvent->actualInteractionsPerCrossing()); pOverEvent->setAverageInteractionsPerCrossing(pEvent->averageInteractionsPerCrossing()); + cout <<"MN: p2 " << m_isEmbedding <<" "<< m_isEventOverlayJobMC << endl; } if(m_isEventOverlayJob) { - // Propagate core event flags - pOverEvent->setEventFlags(EventInfo::Core, (pEventSignal->eventFlags(EventInfo::Core) | pEvent->eventFlags(EventInfo::Core))); - pOverEvent->setErrorState(EventInfo::Core, std::max(pEventSignal->errorState(EventInfo::Core), pEvent->errorState(EventInfo::Core))); + // Propagate core event flags + pOverEvent->setEventFlags(xAOD::EventInfo::Core, + pEventSignal->eventFlags(xAOD::EventInfo::Core) + | pEvent->eventFlags(xAOD::EventInfo::Core) ); + pOverEvent->setErrorState(xAOD::EventInfo::Core, + std::max( pEventSignal->errorState(xAOD::EventInfo::Core), + pEvent->errorState(xAOD::EventInfo::Core) ) ); } - ATH_MSG_VERBOSE ( "BCID =" << pOverEvent->event_ID()->bunch_crossing_id() ); + ATH_MSG_VERBOSE ( "BCID =" << pOverEvent->bcid() ); // when doing overlay add the hard-scatter event as sub-event - if (m_isEventOverlayJob) - { - pOverEvent->addSubEvt(0, PileUpTimeEventIndex::Signal, - pEventSignal, &m_signalStream.store()); - } + if( m_isEventOverlayJob ) { + ATH_MSG_INFO ( "MN: add EventSignal" ); + puei->push_back( new xAOD::EventInfo( *pEventSignal ) ); + // link to the fresh EI added to the container: + ElementLink< xAOD::EventInfoContainer > eilink( puei_sg_key, puei->size()-1, &*m_evtStore ); + xAOD::EventInfo::SubEvent subev( 0, pOverEvent->subEvents().size(), xAOD::EventInfo::Signal, eilink ); + pOverEvent->addSubEvent( subev ); + // pOverEvent->addSubEvt(0, PileUpTimeEventIndex::Signal, pEventSignal, &m_signalStream.store()); + } // register as sub event of the overlaid bool addpEvent(true); if(m_isEmbedding || m_isEventOverlayJobMC) - { - const PileUpEventInfo* pOldEvent(dynamic_cast<const PileUpEventInfo*>(pEvent)); - if(pOldEvent) - { - PileUpEventInfo::SubEvent::const_iterator it = pOldEvent->beginSubEvt(); - PileUpEventInfo::SubEvent::const_iterator end = pOldEvent->endSubEvt(); - if (m_isEventOverlayJobMC) - { - // we can skip the first sub-event when doing MC+MC overlay - ++it; - } - else - { - if (it != end) { addpEvent=false; } - } - for (; it != end; ++it) - { - const EventInfo* sevt = (*it).pSubEvt; - pOverEvent->addSubEvt((*it).time() , (*it).type(), sevt, &m_origStream.store()); - } - } - } - if(addpEvent) - { - pOverEvent->addSubEvt(0, PileUpTimeEventIndex::Signal, - pEvent, &m_origStream.store()); - } + { + auto it = pEvent->subEvents().begin(); + auto end = pEvent->subEvents().end(); + ATH_MSG_INFO ( "MN: nextEvent(): copy subevents " << (int)(end-it) ); + if( m_isEventOverlayJobMC ) { + // we can skip the first sub-event when doing MC+MC overlay + if( it != end ) ++it; + } + else { + if (it != end) { addpEvent=false; } + } + for (; it != end; ++it) { + //const EventInfo* sevt = (*it).pSubEvt; + // pOverEvent->addSubEvt((*it).time() , (*it).type(), sevt, &m_origStream.store()); + // FIX MN: do we need to copy subevent to the new EI container? + pOverEvent->addSubEvent( *it ); + } + } + + if( addpEvent ) { + ATH_MSG_INFO ( "MN: addpEvent" ); + xAOD::EventInfo* ei = new xAOD::EventInfo( *pEvent ); + puei->push_back( ei ); + // link to the fresh EI added to the container: + ElementLink< xAOD::EventInfoContainer > eilink( puei_sg_key, puei->size()-1, &*m_evtStore ); + xAOD::EventInfo::SubEvent subev( 0, pOverEvent->subEvents().size(), xAOD::EventInfo::Signal, eilink ); + pOverEvent->addSubEvent( subev ); + // pOverEvent->addSubEvent(0, PileUpTimeEventIndex::Signal, pEvent, &m_origStream.store()); + } - CHECK(m_evtStore->record(pOverEvent, "McEventInfo")); + ATH_MSG_INFO ( "set aliases" ); + CHECK(m_evtStore->setAlias(pOverEvent, "EventInfo")); //add an alias to "OverlayEvent" (backward compatibility) CHECK(m_evtStore->setAlias(pOverEvent, "OverlayEvent")); //add an alias to "MyEvent" (backward compatibility) CHECK(m_evtStore->setAlias(pOverEvent, "MyEvent")); //symlink to EventInfo to support transparent access for standard code - const EventInfo *pEI(0); - CHECK(m_evtStore->symLink(pOverEvent, pEI)); + //const EventInfo *pEI(0); + //CHECK(m_evtStore->symLink(pOverEvent, pEI)); //FIXME at this point one may want to look into the original event //FIXME to decide whether to skip it or to do the pile-up ///ask the BeamLuminositySvc to check for a new scalefactor bool needupdate; - float sf = m_beamLumi->scaleFactor(pEvent->event_ID()->run_number(), pEvent->event_ID()->lumi_block(), needupdate ); + float sf = m_beamLumi->scaleFactor( pEvent->runNumber(), pEvent->lumiBlock(), needupdate ); float currentaveragemu(sf*m_maxCollPerXing); - if(!m_isEmbedding && !m_isEventOverlayJobMC) - { + if( !m_isEmbedding && !m_isEventOverlayJobMC ) { + cout <<"MN: p1 " << m_isEmbedding <<" "<< m_isEventOverlayJobMC << endl; pOverEvent->setAverageInteractionsPerCrossing(currentaveragemu); //FIXME check whether actualInteractionsPerCrossing should be set //to mu for the central bunch crossing, as below, or whether it @@ -491,11 +512,13 @@ StatusCode PileUpEventLoopMgr::nextEvent(int maxevt) int t0BinCenter((int)m_xingFreq*iXing); unsigned int currentBCID = getBCID((t0BinCenter/25), t0BCID); //Should account for m_xingFreq>25. FIXME - hardcoded 25ns ATH_MSG_VERBOSE ( "Background BCID =" << currentBCID ); + ATH_MSG_INFO ( "MN: Background BCID =" << currentBCID ); cacheIterator = m_caches.begin(); + cout << "MN: iterating over " << (endOfCaches-cacheIterator) << " caches" << endl; while (cacheIterator != endOfCaches) { // Now set the BCID for background events - also requires changes to PileUpEventInfo, SubEvent - if (((*cacheIterator)->addSubEvts(iXing-m_firstXing, *pOverEvent, t0BinCenter, m_loadProxies, currentBCID)).isFailure()) { + if (((*cacheIterator)->addSubEvts(iXing-m_firstXing, pOverEvent, t0BinCenter, m_loadProxies, currentBCID)).isFailure()) { //if (((*cacheIterator)->addSubEvts(iXing-m_firstXing, *pOverEvent, t0BinCenter)).isFailure()) { if (maxevt == -1 && m_allowSubEvtsEOF) { ATH_MSG_INFO ( "No more sub events for " << cacheIterator->name() ); @@ -509,104 +532,10 @@ StatusCode PileUpEventLoopMgr::nextEvent(int maxevt) } } //loop over xings - //////////// START OF TEMPORARY HACK ///////////////////// - ATH_MSG_DEBUG("Converting PileUpEventInfo to xAOD::EventInfo"); - // Copy completed PileUpEventInfo into xAODEventInfo at this point temporarily - // Create the xAOD object(s): - std::unique_ptr< xAOD::EventAuxInfo > pxAODEventAuxInfo(new xAOD::EventAuxInfo()); - std::unique_ptr< xAOD::EventInfo > pxAODEventInfo( new xAOD::EventInfo()); - pxAODEventInfo->setStore( pxAODEventAuxInfo.get() ); - CHECK(m_xAODCnvTool->convert( pOverEvent, pxAODEventInfo.get(), true, false )); - // Before the record, keep a pointer to the EventInfo object, to be able - // to add ElementLinks to it afterwards. - xAOD::EventInfo* pLocalXAODEventInfo = pxAODEventInfo.get(); - - //ATH_MSG_INFO ("Dumping xAOD::EventInfo prior to adding SubEvents"); - //xAOD::dump( *pLocalXAODEventInfo ); - // Record the xAOD object(s): - CHECK( m_evtStore->record( std::move( pxAODEventAuxInfo ), "EventInfoAux." ) ); - CHECK( m_evtStore->record( std::move( pxAODEventInfo ), "EventInfo" ) ); - - // Create an EventInfoContainer for the pileup events: - std::unique_ptr< xAOD::EventInfoContainer > puei(new xAOD::EventInfoContainer()); - std::unique_ptr< xAOD::EventInfoAuxContainer > puaux(new xAOD::EventInfoAuxContainer()); - puei->setStore( puaux.get() ); - - // Sub-events for the main EventInfo object: - std::vector< xAOD::EventInfo::SubEvent > subEvents; - - // A map translating between the AOD and xAOD pileup event types: - static std::map< PileUpEventInfo::SubEvent::pileup_type, - xAOD::EventInfo::PileUpType > pileupTypeMap; - if( ! pileupTypeMap.size() ) { -#define DECLARE_SE_TYPE( TYPE ) \ - pileupTypeMap[ PileUpTimeEventIndex::TYPE ] = xAOD::EventInfo::TYPE - - DECLARE_SE_TYPE( Unknown ); - DECLARE_SE_TYPE( Signal ); - DECLARE_SE_TYPE( MinimumBias ); - DECLARE_SE_TYPE( Cavern ); - DECLARE_SE_TYPE( HaloGas ); - DECLARE_SE_TYPE( ZeroBias ); - -#undef DECLARE_SE_TYPE - } - - // A convenience type declaration: - typedef ElementLink< xAOD::EventInfoContainer > EiLink; - - // Create xAOD::EventInfo objects for each pileup EventInfo object: - PileUpEventInfo::SubEvent::const_iterator pu_itr = pOverEvent->beginSubEvt(); - PileUpEventInfo::SubEvent::const_iterator pu_end = pOverEvent->endSubEvt(); - const unsigned int countEvents = std::distance(pu_itr,pu_end); - ATH_MSG_VERBOSE( "CHECKING: There are " << countEvents << " subevents in this Event." ); - - for( ; pu_itr != pu_end; ++pu_itr ) { - // Create a new xAOD object: - xAOD::EventInfo* ei = new xAOD::EventInfo(); - puei->push_back( ei ); - // Fill it with information: - CHECK( m_xAODCnvTool->convert( pu_itr->pSubEvt, ei, true, false ) ); - StoreGateSvc* tmpSG = pu_itr->pSubEvtSG; - if(tmpSG) - { - ei->setEvtStore(tmpSG); - ATH_MSG_VERBOSE("FOUND A STOREGATE"); - } - else - { - ATH_MSG_ERROR("FAILED TO FIND A STOREGATE"); - } - // And now add a sub-event to the temporary list: - auto typeItr = pileupTypeMap.find( pu_itr->type() ); - xAOD::EventInfo::PileUpType type = xAOD::EventInfo::Unknown; - if( typeItr == pileupTypeMap.end() ) { - ATH_MSG_WARNING( "PileUpType not recognised: " << pu_itr->type() ); - } else { - type = typeItr->second; - } - ATH_MSG_VERBOSE("PileUpEventInfo: time = " << pu_itr->time() << ", index = " << pu_itr->index()); - subEvents.push_back( xAOD::EventInfo::SubEvent( pu_itr->time(), - pu_itr->index(), - type, - EiLink( "PileUpEventInfo", - puei->size() - - 1, - m_evtStore.operator->() ) ) ); - ATH_MSG_VERBOSE("PileUpEventInfo: time = " << subEvents.back().time() << ", index = " << subEvents.back().index()); - } - - // And now update the main EventInfo object with the sub-events: - pLocalXAODEventInfo->setSubEvents( subEvents ); - - // Record the xAOD object(s): - CHECK( m_evtStore->record( std::move( puaux ), "PileUpEventInfoAux." ) ); - CHECK( m_evtStore->record( std::move( puei ), "PileUpEventInfo" ) ); - //ATH_MSG_INFO("Dumping xAOD::EventInfo after adding SubEvents"); - //xAOD::dump( *pLocalXAODEventInfo ); - - //////////// END OF TEMPORARY HACK ///////////////////// - + cout << "===================================================================" << endl; + xAOD::dump( *pOverEvent ); + cout << "===================================================================" << endl; + //set active store back to the overlaid one pActiveStore->setStore(&(*m_evtStore)); @@ -614,8 +543,8 @@ StatusCode PileUpEventLoopMgr::nextEvent(int maxevt) // (PileUpEventInfo) is considered to be current if(m_skipExecAlgs) { - ATH_MSG_INFO ( "Firing reseed incident (" << pOverEvent->event_ID()->event_number() << "," << pOverEvent->event_ID()->run_number() << ")" ); - m_incidentSvc->fireIncident(ContextIncident<std::pair<unsigned,unsigned> >(this->name(),"ReseedIncident",std::pair<unsigned,unsigned>(pOverEvent->event_ID()->event_number(),pOverEvent->event_ID()->run_number()))); + ATH_MSG_INFO ( "Firing reseed incident (" << pOverEvent->eventNumber() << "," << pOverEvent->runNumber() << ")" ); + m_incidentSvc->fireIncident(ContextIncident<std::pair<unsigned,unsigned> >(this->name(),"ReseedIncident",std::pair<unsigned,unsigned>(pOverEvent->eventNumber(),pOverEvent->runNumber()))); m_incidentSvc->fireIncident(Incident(this->name(),"AfterReseedIncident")); ATH_MSG_INFO ( "Not going to process this event" ); } @@ -707,10 +636,13 @@ PileUpEventLoopMgr::setupStreams() return StatusCode::FAILURE; } } + // MN: FIX: Pass the converter tool to PileUpStream in an ugly hack + PileUpStream::m_xAODCnvTool = &*m_xAODCnvTool; //now get the bkg stream caches, and set them up CHECK(m_caches.retrieve()); ATH_MSG_DEBUG ( "retrieved BkgStreamsCaches " << m_caches ); + ATH_MSG_INFO ( "MN: retrieved BkgStreamsCaches " << m_caches ); ToolHandleArray<IBkgStreamsCache>::iterator cacheIterator(m_caches.begin()); ToolHandleArray<IBkgStreamsCache>::iterator endOfCaches(m_caches.end()); @@ -803,15 +735,16 @@ StatusCode PileUpEventLoopMgr::executeAlgorithms() StatusCode PileUpEventLoopMgr::executeEvent(void* par) { - const EventInfo* pEvent(reinterpret_cast<PileUpEventInfo*>(par)); //AUIII! + const xAOD::EventInfo* pEvent(reinterpret_cast<xAOD::EventInfo*>(par)); //AUIII! assert(pEvent); - m_eventContext->setEventID( *((EventIDBase*) pEvent->event_ID()) ); + // Make EventID for the Event Context + EventID ev_id = m_xAODCnvTool->eventIDFromXAOD( pEvent ); + m_eventContext->setEventID( ev_id ); m_eventContext->set(m_nevt,0); /// Is this correct, or should it be set to a pileup store? - m_eventContext->setExtension( Atlas::ExtendedEventContext(m_evtStore->hiveProxyDict(), - pEvent->event_ID()->run_number()) ); + m_eventContext->setExtension( Atlas::ExtendedEventContext(m_evtStore->hiveProxyDict(), pEvent->runNumber()) ); Gaudi::Hive::setCurrentContext( m_eventContext ); m_aess->reset(*m_eventContext); @@ -823,8 +756,11 @@ StatusCode PileUpEventLoopMgr::executeEvent(void* par) return (StatusCode::FAILURE); } + // Make EventInfo for incidents + EventInfo ei( new EventID(ev_id), new EventType( m_xAODCnvTool->eventTypeFromXAOD(pEvent) ) ); + /// Fire begin-Run incident if new run: - if (m_firstRun || (m_currentRun != pEvent->event_ID()->run_number()) ) + if (m_firstRun || (m_currentRun != pEvent->runNumber()) ) { // Fire EndRun incident unless this is the first run if (!m_firstRun) @@ -833,17 +769,23 @@ StatusCode PileUpEventLoopMgr::executeEvent(void* par) CHECK(this->endRunAlgorithms()); } m_firstRun=false; - m_currentRun = pEvent->event_ID()->run_number(); + m_currentRun = pEvent->runNumber(); ATH_MSG_INFO ( " ===>>> start of run " << m_currentRun << " <<<===" ); // Fire BeginRun "Incident" - m_incidentSvc->fireIncident(EventIncident(*pEvent, this->name(),"BeginRun")); + cout << "MN: Firing BeginRun incident" << endl; + m_incidentSvc->fireIncident(EventIncident(ei, this->name(), "BeginRun")); CHECK(this->beginRunAlgorithms()); } + std::vector<IIncidentListener*> listeners; + m_incidentSvc->getListeners( listeners, "BeginEvent" ); + cout << "Listeners: " << listeners.size() << endl; + // Fire BeginEvent "Incident" - //m_incidentSvc->fireIncident(EventIncident(*pEvent, this->name(),"BeginEvent")); + cout << "MN: Firing BeginEvent incident for run " << ei.event_ID()->event_number() << endl; + m_incidentSvc->fireIncident(EventIncident(ei, this->name(),"BeginEvent")); // Execute Algorithms // StatusCode sc = MinimalEventLoopMgr::executeEvent(par); @@ -895,7 +837,8 @@ StatusCode PileUpEventLoopMgr::executeEvent(void* par) } // Fire EndEvent "Incident" - //m_incidentSvc->fireIncident(EventIncident(*pEvent, this->name(),"EndEvent")); + cout << "MN: Firing EndEvent incident" << endl; + m_incidentSvc->fireIncident(EventIncident(ei, this->name(),"EndEvent")); //------------------------------------------------------------------------ // Check if there was an error processing current event diff --git a/Control/PileUpComps/src/PileUpEventLoopMgr.h b/Control/PileUpComps/src/PileUpEventLoopMgr.h index f2303c19b934..b964fa7e9a56 100644 --- a/Control/PileUpComps/src/PileUpEventLoopMgr.h +++ b/Control/PileUpComps/src/PileUpEventLoopMgr.h @@ -16,7 +16,6 @@ // Athena headers #include "AthenaKernel/MsgStreamMember.h" -#include "EventInfo/EventID.h" /* for EventID::number_type */ #include "PileUpTools/PileUpStream.h" // Gaudi headers @@ -162,7 +161,7 @@ private: //@} /// current run number - EventID::number_type m_currentRun; + uint32_t m_currentRun; bool m_firstRun; /// Private message stream member diff --git a/Control/PileUpComps/src/SplitBkgStreamsCache.cxx b/Control/PileUpComps/src/SplitBkgStreamsCache.cxx index 47ccc18ca775..003724fd4bef 100644 --- a/Control/PileUpComps/src/SplitBkgStreamsCache.cxx +++ b/Control/PileUpComps/src/SplitBkgStreamsCache.cxx @@ -17,9 +17,7 @@ #include "CLHEP/Random/RandFlat.h" #include "CLHEP/Random/RandPoisson.h" -#include "EventInfo/PileUpEventInfo.h" #include "EventInfo/PileUpTimeEventIndex.h" -#include "EventInfo/EventID.h" #include "PileUpTools/IBeamIntensity.h" #include "AthenaBaseComps/AthMsgStreamMacros.h" @@ -49,7 +47,7 @@ SplitBkgStreamsCache::SplitBkgStreamsCache( const std::string& type, m_atRndmSvc("AtRndmGenSvc", name), m_randomStreamName("PileUpCollXingStream"), m_pileUpEventTypeProp(0), - m_pileUpEventType(PileUpTimeEventIndex::Signal), + m_pileUpEventType(xAOD::EventInfo::PileUpType::Signal), m_subtractBC0(0), m_ignoreBM(false), m_ignoreSF(false), @@ -64,7 +62,7 @@ SplitBkgStreamsCache::SplitBkgStreamsCache( const std::string& type, m_f_numberOfBackgroundForBunchCrossing(0), m_collXingSF(1.0), m_zeroXing(-1), - m_beamInt(0) + m_beamInt(nullptr) { declareProperty("CollPerXing", m_meanCollisionsPerBunchCrossing, "(average) number of collisions per beam crossing"); declareProperty("OccupationFraction", m_occupationFraction, "The maximum fraction of bunch-crossings which will be occupied."); @@ -78,7 +76,7 @@ SplitBkgStreamsCache::SplitBkgStreamsCache( const std::string& type, declareProperty("RndmGenSvc", m_atRndmSvc, "IAtRndmGenSvc controlling the distribution of bkg events/xing"); declareProperty("RndmStreamName", m_randomStreamName, "IAtRndmGenSvc stream used as engine for our various random distributions, including the CollPerXing one "); declareProperty("SubtractBC0", m_subtractBC0, "reduce the number of events at bunch xing t=0 by m_subtractBC0. Default=0, set to 1 when using the same type of events (e.g. minbias) for original and background streams"); - m_pileUpEventTypeProp.verifier().setUpper(PileUpTimeEventIndex::NTYPES-2); + m_pileUpEventTypeProp.verifier().setUpper((xAOD::EventInfo::PileUpType)PileUpTimeEventIndex::NTYPES-2); m_pileUpEventTypeProp.declareUpdateHandler(&SplitBkgStreamsCache::PileUpEventTypeHandler, this); declareProperty("IgnoreBeamInt", m_ignoreBM, "Default=False, set to True to ignore the PileUpEventLoopMgr beam intensity tool in setting the number of events per xing."); declareProperty("IgnoreBeamLumi", m_ignoreSF, "Default=False, set to True to ignore the PileUpEventLoopMgr beam luminosity tool in setting the number of events per xing."); @@ -98,7 +96,7 @@ SplitBkgStreamsCache::~SplitBkgStreamsCache() void SplitBkgStreamsCache::PileUpEventTypeHandler(Property&) { - m_pileUpEventType=PileUpTimeEventIndex::ushortToType(m_pileUpEventTypeProp.value()); + m_pileUpEventType=(xAOD::EventInfo::PileUpType)PileUpTimeEventIndex::ushortToType(m_pileUpEventTypeProp.value()); } void SplitBkgStreamsCache::calculateCacheSizes() @@ -247,9 +245,10 @@ void SplitBkgStreamsCache::newEvent() m_usedStreams2.assign(m_streams2.size(), false); } -const EventInfo* SplitBkgStreamsCache::nextEvent(bool isCentralBunchCrossing) + +const xAOD::EventInfo* SplitBkgStreamsCache::nextEvent(bool isCentralBunchCrossing) { - const EventInfo* pNextEvt(NULL); + const xAOD::EventInfo* pNextEvt(nullptr); StreamVector::size_type iS(0); CLHEP::RandFlat* pChooseEventRand(NULL); CLHEP::RandFlat* pReadEventRand(NULL); @@ -417,7 +416,7 @@ StatusCode SplitBkgStreamsCache::initialize() { // configure our MsgStream ATH_MSG_DEBUG ( "Initializing " << name() << " - cache for events of type " - << PileUpTimeEventIndex::typeName(m_pileUpEventType) + << PileUpTimeEventIndex::typeName((PileUpTimeEventIndex::PileUpType)m_pileUpEventType) << " - package version " << PACKAGE_VERSION ) ; PileUpEventTypeHandler(m_pileUpEventTypeProp); //locate the ActiveStoreSvc and initialize our local ptr @@ -526,14 +525,14 @@ unsigned int SplitBkgStreamsCache::pickNumberOfBkgForBunchCrossing(unsigned int } StatusCode SplitBkgStreamsCache::addSubEvts(unsigned int iXing, - PileUpEventInfo& overEvent, + xAOD::EventInfo* overEvent, int t0BinCenter) { return this->addSubEvts(iXing, overEvent, t0BinCenter, true, 0); } StatusCode SplitBkgStreamsCache::addSubEvts(unsigned int iXing, - PileUpEventInfo& overEvent, + xAOD::EventInfo* overEvent, int t0BinCenter, bool loadEventProxies, unsigned int BCID) { for (unsigned int iEvt=0; iEvt<getNumberOfBkgForBunchCrossing(iXing); ++iEvt) @@ -548,7 +547,7 @@ StatusCode SplitBkgStreamsCache::addSubEvts(unsigned int iXing, { return this->nextEvent_passive(isCentralBunchCrossing); } - const EventInfo* pBkgEvent(nextEvent(isCentralBunchCrossing)); + const xAOD::EventInfo* pBkgEvent(nextEvent(isCentralBunchCrossing)); //check input selector is not empty PileUpStream* currStream(current()); @@ -571,8 +570,8 @@ StatusCode SplitBkgStreamsCache::addSubEvts(unsigned int iXing, } else { pBkgStore = &(currStream->store()); - ATH_MSG_VERBOSE ( "addSubEvts: added event " << pBkgEvent->event_ID()->event_number() - << " run " << pBkgEvent->event_ID()->run_number() + ATH_MSG_VERBOSE ( "addSubEvts: added event " << pBkgEvent->eventNumber() + << " run " << pBkgEvent->runNumber() << " from store " << pBkgStore->name() << " @ Xing " << iXing ); @@ -580,9 +579,11 @@ StatusCode SplitBkgStreamsCache::addSubEvts(unsigned int iXing, // register as sub event of the overlaid // ask if sufficient/needed - overEvent.addSubEvt(t0BinCenter, BCID, - m_pileUpEventType, - *pBkgEvent, pBkgStore); + + // MN: FIX - needs to be migrated !! + // overEvent->addSubEvt(t0BinCenter, BCID, m_pileUpEventType, *pBkgEvent, pBkgStore); + + #ifdef DEBUG_PILEUP const EventInfo* pStoreInfo(0); if (pBkgStore->retrieve(pStoreInfo).isSuccess() && pStoreInfo && @@ -607,7 +608,7 @@ StatusCode SplitBkgStreamsCache::finalize() StatusCode sc(StatusCode::SUCCESS); ATH_MSG_DEBUG ( "Finalizing " << name() << " - cache for events of type " - << PileUpTimeEventIndex::typeName(m_pileUpEventType) + << PileUpTimeEventIndex::typeName((PileUpTimeEventIndex::PileUpType)m_pileUpEventType) << " - package version " << PACKAGE_VERSION ) ; while (sc.isSuccess() && m_streams1.size()>0) { diff --git a/Control/PileUpComps/src/SplitBkgStreamsCache.h b/Control/PileUpComps/src/SplitBkgStreamsCache.h index d9d9908348f2..858ad26c29f3 100644 --- a/Control/PileUpComps/src/SplitBkgStreamsCache.h +++ b/Control/PileUpComps/src/SplitBkgStreamsCache.h @@ -25,11 +25,9 @@ class ActiveStoreSvc; -class EventInfo; class IAtRndmGenSvc; class IEvtSelector; class IBeamIntensity; -class PileUpEventInfo; namespace CLHEP { class RandFlat; class RandPoisson; @@ -66,9 +64,9 @@ public: @param overlaidEvent reference to resulting overlaid event @param t0BinCenter time wrto t0 of current bin center in ns */ - virtual StatusCode addSubEvts(unsigned int iXing, - PileUpEventInfo& overlaidEvent, - int t0BinCenter); + virtual StatusCode addSubEvts(unsigned int iXing, + xAOD::EventInfo* overlaidEvent, + int t0BinCenter) override final; /** @brief Read input events in bkg stores and link them to overlay store @param iXing offset to first xing number (=0 first Xing, =nXings for last xing) @@ -78,8 +76,9 @@ public: @param BCID bunch-crossing ID of signal bunch crossing */ virtual StatusCode addSubEvts(unsigned int iXing, - PileUpEventInfo& overEvent, - int t0BinCenter, bool loadEventProxies, unsigned int /*BCID*/); + xAOD::EventInfo* overEvent, + int t0BinCenter, bool loadEventProxies, unsigned int /*BCID*/) override final; + /// how many stores in this cache virtual unsigned int nStores() const { return (m_nStores1 + m_nStores2); } @@ -92,7 +91,7 @@ public: unsigned int numberOfCavernBkgForBunchCrossing(unsigned int iXing) const; private: /// get next bkg event from cache - const EventInfo* nextEvent(bool isCentralBunchCrossing); + const xAOD::EventInfo* nextEvent(bool isCentralBunchCrossing); /// as nextEvent except don't actually load anything StatusCode nextEvent_passive(bool isCentralBunchCrossing); /// get current (last asked) stream @@ -145,7 +144,7 @@ private: Gaudi::CheckedProperty<unsigned short> m_pileUpEventTypeProp; void PileUpEventTypeHandler(Property&); /// the type of events in this cache - PileUpTimeEventIndex::PileUpType m_pileUpEventType; + xAOD::EventInfo::PileUpType m_pileUpEventType; /// subtract from number of events at bunch xing = 0 Gaudi::Property<unsigned short> m_subtractBC0; /// ignore the PileUpEventLoopMgr beam intensity tool diff --git a/Control/PileUpTools/CMakeLists.txt b/Control/PileUpTools/CMakeLists.txt index 583846514ad4..d44bc5cd485c 100644 --- a/Control/PileUpTools/CMakeLists.txt +++ b/Control/PileUpTools/CMakeLists.txt @@ -14,13 +14,17 @@ atlas_depends_on_subdirs( PUBLIC Control/StoreGate Event/EventInfo Event/xAOD/xAODEventInfo + Event/xAOD/xAODCnvInterfaces GaudiKernel ) # Component(s) in the package: atlas_add_library( PileUpToolsLib src/*.cxx PUBLIC_HEADERS PileUpTools - LINK_LIBRARIES AthenaBaseComps AthenaKernel AthLinks SGTools EventInfo xAODEventInfo GaudiKernel StoreGateLib SGtests ) + LINK_LIBRARIES AthenaBaseComps AthenaKernel + AthLinks SGTools + EventInfo xAODEventInfo xAODCnvInterfaces + GaudiKernel StoreGateLib SGtests ) atlas_add_component( PileUpTools src/components/*.cxx diff --git a/Control/PileUpTools/PileUpTools/IBkgStreamsCache.h b/Control/PileUpTools/PileUpTools/IBkgStreamsCache.h index 15af6705ec7c..c1bf2118b312 100644 --- a/Control/PileUpTools/PileUpTools/IBkgStreamsCache.h +++ b/Control/PileUpTools/PileUpTools/IBkgStreamsCache.h @@ -13,9 +13,9 @@ #define PILEUPTOOLS_IBKGSTREAMSCACHE_H #include "GaudiKernel/IAlgTool.h" +#include "xAODEventInfo/EventInfo.h" class IBeamIntensity; -class PileUpEventInfo; /** @class IBkgStreamsCache * @brief Interface to in-memory cache for pileup events @@ -45,7 +45,7 @@ public: @param loadEventProxies should we load the event proxies or not. */ virtual StatusCode addSubEvts(unsigned int iXing, - PileUpEventInfo& overEvent, + xAOD::EventInfo* overEvent, int t0BinCenter, bool loadEventProxies, unsigned int BCID) = 0; /** @brief Read input events in bkg stores and link them to overlay store @@ -54,7 +54,7 @@ public: @param t0BinCenter time wrto t0 of current bin center in ns */ virtual StatusCode addSubEvts(unsigned int iXing, - PileUpEventInfo& overlaidEvent, + xAOD::EventInfo* overlaidEvent, int t0BinCenter) = 0; /// how many stores in cache virtual unsigned int nStores() const = 0; diff --git a/Control/PileUpTools/PileUpTools/IPileUpTool.h b/Control/PileUpTools/PileUpTools/IPileUpTool.h index 53523b200219..dacca3dce99c 100644 --- a/Control/PileUpTools/PileUpTools/IPileUpTool.h +++ b/Control/PileUpTools/PileUpTools/IPileUpTool.h @@ -16,11 +16,9 @@ */ #include "GaudiKernel/IAlgTool.h" -#include "EventInfo/PileUpEventInfo.h" /*SubEvent*/ #include "xAODEventInfo/EventInfo.h" #include <vector> -//typedef PileUpEventInfo::SubEvent::const_iterator SubEventIterator; typedef std::vector<xAOD::EventInfo::SubEvent>::const_iterator SubEventIterator; class IPileUpTool : virtual public IAlgTool{ diff --git a/Control/PileUpTools/PileUpTools/PileUpMergeSvc.h b/Control/PileUpTools/PileUpTools/PileUpMergeSvc.h index 2e998c1aeafc..41df8acaf505 100755 --- a/Control/PileUpTools/PileUpTools/PileUpMergeSvc.h +++ b/Control/PileUpTools/PileUpTools/PileUpMergeSvc.h @@ -14,8 +14,8 @@ #define PILEUPTOOLS_PILEUPMERGESVC_H #include "EventInfo/PileUpTimeEventIndex.h" -#include "EventInfo/PileUpEventInfo.h" /*needed by the icc*/ -#include "PileUpTools/IPileUpTool.h" /*needed by the icc*/ +#include "xAODEventInfo/EventInfo.h" +#include "PileUpTools/IPileUpTool.h" /* subEventIterator*/ #include "AthenaBaseComps/AthService.h" #include "GaudiKernel/ClassID.h" @@ -115,7 +115,7 @@ public: private: // hack to make gcc happy - const PileUpEventInfo* getPileUpEvent() const; + const xAOD::EventInfo* getPileUpEvent() const; ServiceHandle<StoreGateSvc> p_overStore; ///< overlaid SG (default) ServiceHandle<ActiveStoreSvc> p_activeStore; ///< current active store ToolHandleArray<IPileUpXingFolder> m_intervals; ///< Property: bunch xing intervals diff --git a/Control/PileUpTools/PileUpTools/PileUpMergeSvc.icc b/Control/PileUpTools/PileUpTools/PileUpMergeSvc.icc index dc50c5ffd11b..2b26090dea05 100755 --- a/Control/PileUpTools/PileUpTools/PileUpMergeSvc.icc +++ b/Control/PileUpTools/PileUpTools/PileUpMergeSvc.icc @@ -16,7 +16,7 @@ #include "StoreGate/ActiveStoreSvc.h" #include "StoreGate/StoreGateSvc.h" #include "AthenaKernel/ClassID_traits.h" -#include "EventInfo/EventID.h" +//#include "EventInfo/EventID.h" #include "AthenaBaseComps/AthMsgStreamMacros.h" namespace { @@ -37,16 +37,13 @@ template <typename KEY, typename DATA> StatusCode PileUpMergeSvc::retrieveOriginal(const KEY& dataKey, const DATA*& data) { StatusCode sc(StatusCode::FAILURE); - const PileUpEventInfo* pEvent = getPileUpEvent(); + const xAOD::EventInfo* pEvent = getPileUpEvent(); if (pEvent) { // access the sub events DATA objects... - PileUpEventInfo::SubEvent::const_iterator iEvt = pEvent->beginSubEvt(); - PileUpEventInfo::SubEvent::const_iterator endEvt = pEvent->endSubEvt(); - if (iEvt != endEvt) { - assert(iEvt->pSubEvtSG); - //here we assume that the original event is the first in pEvent list - sc = iEvt->pSubEvtSG->retrieve(data, dataKey); - } + if( pEvent->subEvents().size() ) { + //here we assume that the original event is the first in pEvent list + sc = pEvent->subEvents()[0].ptr()->evtStore()->retrieve(data, dataKey); + } } return sc; } @@ -64,40 +61,37 @@ PileUpMergeSvc::retrieveSubEvtsData(const KEY& dataKey, //orig evt key //the tdefs above in practice check that TIMEDDATA is what we want //FIXME we still have to check we are dealing with a sequence: // boost::function_requires < boost::SequenceConcept<TIMEDDATA> > (); - const PileUpEventInfo* pEvent = getPileUpEvent(); + const xAOD::EventInfo* pEvent = getPileUpEvent(); if (pEvent) { // access the sub events DATA objects... - PileUpEventInfo::SubEvent::const_iterator iEvt = pEvent->beginSubEvt(); - PileUpEventInfo::SubEvent::const_iterator endEvt = pEvent->endSubEvt(); - while (iEvt != endEvt) { - assert(iEvt->pSubEvtSG); - assert(iEvt->pSubEvt); + for( const xAOD::EventInfo::SubEvent& subEv : pEvent->subEvents() ) { //skip if dobj not active for this xing //FIXME if (!isLive<data_t>(dataKey, int(iEvt->time()))) { //FIXME turning the double iEvt->time() is fraught with peril. Luckily //FIXME it just works, but we should have the beam xing in iEvt - if (!isLive(ClassID_traits<data_t>::ID(), dataKey, int(iEvt->time()))) { + if (!isLive(ClassID_traits<data_t>::ID(), dataKey, int(subEv.time()))) { #ifndef NDEBUG ATH_MSG_VERBOSE ( "retrieveSubEvtsData: object of type " << System::typeinfoName(typeid(data_t)) << " with key " << dataKey << " OUT OF XING RANGE: SKIPPING " ); #endif } else { - p_activeStore->setStore(iEvt->pSubEvtSG); //FIXME DANGEROUS! + StoreGateSvc* pSubEvtSG( subEv.ptr()->evtStore() ); + p_activeStore->setStore( pSubEvtSG ); //FIXME DANGEROUS! DataLink_t dLink; - fillLink(dLink, dataKey, iEvt->pSubEvtSG); + fillLink( dLink, dataKey, pSubEvtSG ); double sigTime(0.0); unsigned int evtIndex(0); if (dLink.isValid()) { if (m_returnTimedData.value()) { - sigTime=iEvt->time(); + sigTime=subEv.time(); if (!m_pITriggerTime.empty()) sigTime-= m_pITriggerTime->time(); - evtIndex = iEvt->index(); + evtIndex = subEv.index(); } value_type tData(PileUpTimeEventIndex(int(sigTime),evtIndex), dLink); numberOfSimHits+=tData.second->size(); timedData.push_back(tData); - ATH_MSG_DEBUG ( "added entry from store " << iEvt->pSubEvtSG->name() + ATH_MSG_DEBUG ( "added entry from store " << pSubEvtSG->name() << " for object of type " << System::typeinfoName(typeid(data_t)) << "\n with key " << dataKey ); } @@ -105,8 +99,8 @@ PileUpMergeSvc::retrieveSubEvtsData(const KEY& dataKey, //orig evt key if (msg().level() <= MSG::VERBOSE) { msg() << MSG::VERBOSE << "SubEvt EventInfo : " - << " event: " << iEvt->pSubEvt->event_ID()->event_number() - << " run: " << iEvt->pSubEvt->event_ID()->run_number(); + << " event: " << subEv.ptr()->eventNumber() + << " run: " << subEv.ptr()->runNumber(); if (m_returnTimedData.value()) { msg() << " time offset: " << sigTime << " event index: " << evtIndex; @@ -115,27 +109,17 @@ PileUpMergeSvc::retrieveSubEvtsData(const KEY& dataKey, //orig evt key } #endif } - ++iEvt; } //reset active store pointer to default event store FIXME DANGEROUS p_activeStore->setStore(&*p_overStore); } else { - ATH_MSG_DEBUG ( "default PileUpEventInfo not found, trying with EventInfo" ); - const EventInfo* pSimpleEvent; - if (((*p_activeStore)->retrieve(pSimpleEvent)).isSuccess()) { - DataLink_t dLink; - fillLink(dLink, dataKey); - if (dLink.isValid()) { - timedData.push_back(std::make_pair(0, dLink)); - } - } else { - ATH_MSG_FATAL ( "no PileUpEventInfo and no EventInfo object found!" ); - return StatusCode::FAILURE; - } + ATH_MSG_FATAL ( "no EventInfo object found!" ); + return StatusCode::FAILURE; } return StatusCode::SUCCESS; } + ///retrieve keyed DATA objs for subset of sub-events template <typename KEY, typename TIMEDDATA> StatusCode @@ -217,40 +201,36 @@ PileUpMergeSvc::retrieveSubEvtsData(const KEY& dataKey, //orig evt key //the tdefs above in practice check that TIMEDDATA is what we want //FIXME we still have to check we are dealing with a sequence: // boost::function_requires < boost::SequenceConcept<TIMEDDATA> > (); - const PileUpEventInfo* pEvent = getPileUpEvent(); + const xAOD::EventInfo* pEvent = getPileUpEvent(); if (pEvent) { // access the sub events DATA objects... - PileUpEventInfo::SubEvent::const_iterator iEvt = pEvent->beginSubEvt(); - PileUpEventInfo::SubEvent::const_iterator endEvt = pEvent->endSubEvt(); - while (iEvt != endEvt) { - assert(iEvt->pSubEvtSG); - assert(iEvt->pSubEvt); + for( const xAOD::EventInfo::SubEvent& subEv : pEvent->subEvents() ) { //skip if dobj not active for this xing //FIXME if (!isLive<data_t>(dataKey, int(iEvt->time()))) { //FIXME turning the double iEvt->time() is fraught with peril. Luckily //FIXME it just works, but we should have the beam xing in iEvt - if (!isLive(ClassID_traits<data_t>::ID(), dataKey, int(iEvt->time()))) { + if (!isLive(ClassID_traits<data_t>::ID(), dataKey, int(subEv.time()))) { #ifndef NDEBUG ATH_MSG_VERBOSE ( "retrieveSubEvtsData: object of type " << System::typeinfoName(typeid(data_t)) << " with key " << dataKey << " OUT OF XING RANGE: SKIPPING " ); #endif } else { - p_activeStore->setStore(iEvt->pSubEvtSG); //FIXME DANGEROUS! - IProxyDict* pSG(const_cast<StoreGateSvc*>(iEvt->pSubEvtSG)); + StoreGateSvc* pSubEvtSG( subEv.ptr()->evtStore() ); + p_activeStore->setStore( pSubEvtSG ); //FIXME DANGEROUS! DataLink_t dLink; - fillLink(dLink, dataKey, pSG); + fillLink( dLink, dataKey, pSubEvtSG ); double sigTime(0.0); unsigned int evtIndex(0); if (dLink.isValid()) { if (m_returnTimedData.value()) { - sigTime=iEvt->time(); + sigTime=subEv.time(); if (!m_pITriggerTime.empty()) sigTime-= m_pITriggerTime->time(); - evtIndex = iEvt->index(); + evtIndex = subEv.index(); } value_type tData(PileUpTimeEventIndex(int(sigTime),evtIndex), dLink); timedData.push_back(tData); - ATH_MSG_DEBUG ( "added entry from store " << iEvt->pSubEvtSG->name() + ATH_MSG_DEBUG ( "added entry from store " << pSubEvtSG->name() << " for object of type " << System::typeinfoName(typeid(data_t)) << "\n with key " << dataKey ); } @@ -258,8 +238,8 @@ PileUpMergeSvc::retrieveSubEvtsData(const KEY& dataKey, //orig evt key if (msg().level() <= MSG::VERBOSE) { msg() << MSG::VERBOSE << "SubEvt EventInfo : " - << " event: " << iEvt->pSubEvt->event_ID()->event_number() - << " run: " << iEvt->pSubEvt->event_ID()->run_number(); + << " event: " << subEv.ptr()->eventNumber() + << " run: " << subEv.ptr()->runNumber(); if (m_returnTimedData.value()) { msg() << " time offset: " << sigTime << " event index: " << evtIndex; @@ -268,27 +248,17 @@ PileUpMergeSvc::retrieveSubEvtsData(const KEY& dataKey, //orig evt key } #endif } - ++iEvt; } //reset active store pointer to default event store FIXME DANGEROUS p_activeStore->setStore(&*p_overStore); } else { - ATH_MSG_DEBUG ( "default PileUpEventInfo not found, trying with EventInfo" ); - const EventInfo* pSimpleEvent; - if (((*p_activeStore)->retrieve(pSimpleEvent)).isSuccess()) { - DataLink_t dLink; - fillLink(dLink, dataKey); - if (dLink.isValid()) { - timedData.push_back(std::make_pair(0, dLink)); - } - } else { - ATH_MSG_FATAL ( "no PileUpEventInfo and no EventInfo object found!" ); - return StatusCode::FAILURE; - } + ATH_MSG_FATAL ( "no EventInfo object found!" ); + return StatusCode::FAILURE; } return StatusCode::SUCCESS; } + // ///retrieve default DATA objs for all sub-events and attach a time to them // template <typename TIMEDDATA> // StatusCode diff --git a/Control/PileUpTools/PileUpTools/PileUpStream.h b/Control/PileUpTools/PileUpTools/PileUpStream.h index eb93dd267b66..faff1bb2c51e 100755 --- a/Control/PileUpTools/PileUpTools/PileUpStream.h +++ b/Control/PileUpTools/PileUpTools/PileUpStream.h @@ -16,13 +16,17 @@ #include "GaudiKernel/IEvtSelector.h" #include "AthenaKernel/MsgStreamMember.h" -#include "EventInfo/EventInfo.h" +#include "xAODEventInfo/EventInfo.h" // Forward declarations class IMessageSvc; class ISvcLocator; class StoreGateSvc; class ActiveStoreSvc; +namespace xAODMaker +{ + class IEventInfoCnvTool; +} /** @class PileUpStream * @brief a triple selector/context/store defines a stream @@ -60,7 +64,7 @@ public: //@} ///return next Event, load store with next Event - const EventInfo* nextEventPre(bool readRecord=true); + const xAOD::EventInfo* nextEventPre(bool readRecord=true); ///like nextEventPre, but doesn't actually load anything bool nextEventPre_Passive(bool readRecord); @@ -70,6 +74,8 @@ public: /// backward compatibility inline bool setupStore(bool ) { return setupStore();} + void setEICnvTool( xAODMaker::IEventInfoCnvTool *tool ) { m_xAODCnvTool = tool; } + /// finalize and release store. To be called on ... finalize() StatusCode finalize(); @@ -91,6 +97,7 @@ public: MsgStream& msg( MSG::Level lvl ) const { return m_msg << lvl; } /// Check whether the logging system is active at the provided verbosity level bool msgLvl( MSG::Level lvl ) { return m_msg.get().level() <= lvl; } + private: ISvcLocator* serviceLocator() { return p_svcLoc; } @@ -132,6 +139,10 @@ private: bool m_used; ///has this stream already been used? (for the current event) bool m_hasRing; unsigned int m_iOriginalRing; ///> original ring in which event was used + +public: + /// EventInfo -> xAOD::EventInfo converter tool + static xAODMaker::IEventInfoCnvTool *m_xAODCnvTool; }; #endif // PILEUPSTREAM_PILEUPSTREAM_H @@ -139,5 +150,3 @@ private: - - diff --git a/Control/PileUpTools/src/PileUpMergeSvc.cxx b/Control/PileUpTools/src/PileUpMergeSvc.cxx index a712d56ecaf8..37d4402681f2 100755 --- a/Control/PileUpTools/src/PileUpMergeSvc.cxx +++ b/Control/PileUpTools/src/PileUpMergeSvc.cxx @@ -107,14 +107,14 @@ PileUpMergeSvc::initialize() { } -const PileUpEventInfo* PileUpMergeSvc::getPileUpEvent() const { - const PileUpEventInfo* p(0); - if (p_overStore->contains<PileUpEventInfo>("OverlayEvent")) { - if (p_overStore->retrieve(p).isFailure()) { - ATH_MSG_FATAL("Cannot retrieve OverlayEvent from " << p_overStore->name()); - } - } - return p; +const xAOD::EventInfo* PileUpMergeSvc::getPileUpEvent() const { + const xAOD::EventInfo* p = nullptr; + if( p_overStore->contains<xAOD::EventInfo>("OverlayEvent") ) { + if (p_overStore->retrieve(p).isFailure()) { + ATH_MSG_FATAL("Cannot retrieve OverlayEvent from " << p_overStore->name()); + } + } + return p; } const InterfaceID& @@ -159,13 +159,11 @@ PileUpMergeSvc::doRefresh(const Range& r, int iXing) { StatusCode PileUpMergeSvc::clearDataCaches() { StatusCode sc(StatusCode::FAILURE); - const PileUpEventInfo* pEvent; + const xAOD::EventInfo* pEvent; if (0 != (pEvent=getPileUpEvent())) { // access the sub events DATA objects... - PileUpEventInfo::SubEvent::const_iterator iEvt = pEvent->beginSubEvt(); - PileUpEventInfo::SubEvent::const_iterator endEvt = pEvent->endSubEvt(); - while (iEvt != endEvt) { - StoreGateSvc* pSubEvtSG(iEvt->pSubEvtSG); + for( const xAOD::EventInfo::SubEvent& subEv : pEvent->subEvents() ) { + StoreGateSvc* pSubEvtSG( subEv.ptr()->evtStore() ); assert(pSubEvtSG); //go object-by-object (driven by PileUpXingFolder settings) for (const auto& item : m_ranges) { @@ -174,7 +172,7 @@ PileUpMergeSvc::clearDataCaches() { SG::DataProxy* proxy = pSubEvtSG->proxy_exact (sgkey); //FIXME turning the double iEvt->time is fraught with peril. Luckily //FIXME it just works, but we should have the beam xing in iEvt - if (proxy && doRefresh (item.second, int(iEvt->time()))) { + if (proxy && doRefresh (item.second, int(subEv.time()))) { proxy->setObject ((DataObject*)0); if (msg().level() <= MSG::DEBUG) { msg() << MSG::DEBUG @@ -186,15 +184,14 @@ PileUpMergeSvc::clearDataCaches() { } } //even if we don't clear the store we need to empty the trash... - iEvt->pSubEvtSG->emptyTrash(); + pSubEvtSG->emptyTrash(); #ifndef NDEBUG if (msg().level() <= MSG::VERBOSE) { msg() << MSG::VERBOSE - << "clearDataCachesByFolder: done with store " << iEvt->pSubEvtSG->name() + << "clearDataCachesByFolder: done with store " << pSubEvtSG->name() << endmsg; } #endif - ++iEvt; } //stores loop sc=StatusCode::SUCCESS; } //NO PILEUP EVENT?!? diff --git a/Control/PileUpTools/src/PileUpStream.cxx b/Control/PileUpTools/src/PileUpStream.cxx index de9679ffdb42..169fd7ab0054 100755 --- a/Control/PileUpTools/src/PileUpStream.cxx +++ b/Control/PileUpTools/src/PileUpStream.cxx @@ -21,6 +21,15 @@ #include "EventInfo/EventInfo.h" #include "EventInfo/EventID.h" #include "EventInfo/EventType.h" +#include "EventInfo/PileUpEventInfo.h" +#include "EventInfo/PileUpTimeEventIndex.h" + +#include "xAODEventInfo/EventInfo.h" // NEW EDM +#include "xAODEventInfo/EventAuxInfo.h" // NEW EDM +#include "xAODEventInfo/EventInfoContainer.h" // NEW EDM +#include "xAODEventInfo/EventInfoAuxContainer.h" // NEW EDM +#include "xAODCnvInterfaces/IEventInfoCnvTool.h" +#include "xAODCore/tools/PrintHelpers.h" #include "StoreGate/ActiveStoreSvc.h" #include "AthenaBaseComps/AthMsgStreamMacros.h" @@ -28,8 +37,12 @@ /* #include "GaudiKernel/IOpaqueAddress.h" */ class IOpaqueAddress; +#include <iostream> using namespace std; +// EventInfo -> xAOD::EventInfo converter tool +xAODMaker::IEventInfoCnvTool* PileUpStream::m_xAODCnvTool = nullptr; + /// Structors PileUpStream::PileUpStream(): m_name("INVALID"), p_svcLoc(0), p_sel(0), p_SG(0), p_iter(0), @@ -231,30 +244,150 @@ bool PileUpStream::loadStore() } //return next event, load store with next event -const EventInfo* PileUpStream::nextEventPre(bool readRecord) { - if (m_neverLoaded) readRecord=true; - else if (readRecord) { - //do not reset these the first time we call nextEventPre - this->resetUsed(); - m_hasRing=false; - } - const EventInfo* pEvent(0); - // if (isNotEmpty()) { - if (readRecord && this->nextRecordPre().isFailure()) { - ATH_MSG_INFO ( "nextEventPre(): end of the loop. No more events in the selection" ); - return (const EventInfo*)0; - } - if( !(this->store().retrieve(pEvent)).isSuccess() ) { - ATH_MSG_DEBUG ( "nextEventPre(): Unable to retrieve Event root object" ); - } - if (readRecord) { +const xAOD::EventInfo* PileUpStream::nextEventPre(bool readRecord) +{ + if (m_neverLoaded) readRecord=true; + else if (readRecord) { + //do not reset these the first time we call nextEventPre + this->resetUsed(); + m_hasRing=false; + } + // if (isNotEmpty()) { + if (readRecord && this->nextRecordPre().isFailure()) { + ATH_MSG_INFO ( "nextEventPre(): end of the loop. No more events in the selection" ); + return nullptr; + } + + const xAOD::EventInfo* xAODEventInfo = store().tryConstRetrieve<xAOD::EventInfo>(); + + if( !xAODEventInfo ) { + // Try reading old EventInfo + const EventInfo* pEvent(0); + if( !(this->store().retrieve(pEvent)).isSuccess() ) { + ATH_MSG_DEBUG ( "nextEventPre(): Unable to retrieve Event root object" ); + return nullptr; + } + ATH_MSG_DEBUG("Converting PileUpEventInfo to xAOD::EventInfo"); + // Create the xAOD object(s): + std::unique_ptr< xAOD::EventInfo > pxAODEventInfo( new xAOD::EventInfo() ); + std::unique_ptr< xAOD::EventAuxInfo > pxAODEventAuxInfo(new xAOD::EventAuxInfo()); + pxAODEventInfo->setStore( pxAODEventAuxInfo.get() ); + if( !m_xAODCnvTool->convert( pEvent, pxAODEventInfo.get(), false, false ).isSuccess() ) { + ATH_MSG_ERROR("Failed to convert xAOD::EventInfo in SG"); + return nullptr; + } + + //ATH_MSG_INFO ("Dumping xAOD::EventInfo prior to adding SubEvents"); + //xAOD::dump( *xAODEventInfo ); + + const PileUpEventInfo* pileupEvent(dynamic_cast<const PileUpEventInfo*>(pEvent)); + if( pileupEvent ) { + cout << "MN: PileUpStream: converting PileUpEventInfo" << endl; + // Create an EventInfoContainer for the pileup events: + std::unique_ptr< xAOD::EventInfoContainer > puei(new xAOD::EventInfoContainer()); + std::unique_ptr< xAOD::EventInfoAuxContainer > puaux(new xAOD::EventInfoAuxContainer()); + puei->setStore( puaux.get() ); + + // Sub-events for the main EventInfo object: + std::vector< xAOD::EventInfo::SubEvent > subEvents; + + // A map translating between the AOD and xAOD pileup event types: + static std::map< PileUpEventInfo::SubEvent::pileup_type, + xAOD::EventInfo::PileUpType > pileupTypeMap; + if( ! pileupTypeMap.size() ) { +#define DECLARE_SE_TYPE( TYPE ) \ + pileupTypeMap[ PileUpTimeEventIndex::TYPE ] = xAOD::EventInfo::TYPE + + DECLARE_SE_TYPE( Unknown ); + DECLARE_SE_TYPE( Signal ); + DECLARE_SE_TYPE( MinimumBias ); + DECLARE_SE_TYPE( Cavern ); + DECLARE_SE_TYPE( HaloGas ); + DECLARE_SE_TYPE( ZeroBias ); + +#undef DECLARE_SE_TYPE + } + + // A convenience type declaration: + typedef ElementLink< xAOD::EventInfoContainer > EiLink; + + // Create xAOD::EventInfo objects for each pileup EventInfo object: + auto pu_itr = pileupEvent->beginSubEvt(); + auto pu_end = pileupEvent->endSubEvt(); + const unsigned int countEvents = std::distance(pu_itr,pu_end); + ATH_MSG_VERBOSE( "CHECKING: There are " << countEvents << " subevents in this Event." ); + cout << "MN: There are " << countEvents << " subevents in this Event." <<endl; + + for( ; pu_itr != pu_end; ++pu_itr ) { + // Create a new xAOD::EventInfo object: + std::unique_ptr< xAOD::EventInfo > ei( new xAOD::EventInfo() ); + // Fill it with information: + if( ! m_xAODCnvTool->convert( pu_itr->pSubEvt, ei.get(), true, false ).isSuccess() ) { + ATH_MSG_ERROR("Failed to convert EventInfo to xAOD::EventInfo"); + continue; + } + + StoreGateSvc* tmpSG = pu_itr->pSubEvtSG; + cout << "MN: PileUpStream: SG comparison: p_SG=" << p_SG << " tmpSG= " << tmpSG << endl; + if(tmpSG) { + ei->setEvtStore(tmpSG); + ATH_MSG_VERBOSE("FOUND A STOREGATE"); + } else { + ATH_MSG_ERROR("FAILED TO FIND A STOREGATE"); + } + // Store new EI into the container + puei->push_back( ei.release() ); + + // And now add a sub-event to the temporary list: + auto typeItr = pileupTypeMap.find( pu_itr->type() ); + xAOD::EventInfo::PileUpType type = xAOD::EventInfo::Unknown; + if( typeItr == pileupTypeMap.end() ) { + ATH_MSG_WARNING( "PileUpType not recognised: " << pu_itr->type() ); + } else { + type = typeItr->second; + } + ATH_MSG_VERBOSE("PileUpEventInfo: time = " << pu_itr->time() << ", index = " << pu_itr->index()); + subEvents.push_back( xAOD::EventInfo::SubEvent( pu_itr->time(), + pu_itr->index(), + type, + EiLink( "PileUpEventInfo", puei->size()-1, p_SG ))); // p_SG? +// m_evtStore.operator->() ) ) ); + ATH_MSG_VERBOSE("PileUpEventInfo: time = " << subEvents.back().time() << ", index = " << subEvents.back().index()); + } + + if( subEvents.size() ) { + // And now update the main EventInfo object with the sub-events: + pxAODEventInfo->setSubEvents( subEvents ); + + // Record the xAOD object(s): + if( !store().record( std::move( puaux ), "PileUpEventInfoAux." ).isSuccess() + || !store().record( std::move( puei ), "PileUpEventInfo" ).isSuccess() ) { //MN: FIX - make keys configurable + ATH_MSG_ERROR("Failed to record xAOD::EventInfoContainer in SG"); + } + } + } + + pxAODEventInfo->setEvtStore( &store() ); // FIX: MN: do we need this? + xAODEventInfo = pxAODEventInfo.get(); // remember pointer to return the new EventInfo + // Record the xAOD object(s): + if( ! store().record( std::move( pxAODEventAuxInfo ), "EventInfoAux." ).isSuccess() //MN: FIX? key + || ! store().record( std::move( pxAODEventInfo ), "EventInfo" ).isSuccess() ) { + ATH_MSG_ERROR("Failed to record the new xAOD::EventInfo in SG"); + } + } + + ATH_MSG_INFO("Dumping xAOD::EventInfo"); + xAOD::dump( *xAODEventInfo ); + + if (readRecord) { ATH_MSG_DEBUG ( "nextEventPre(): read new event " - << pEvent->event_ID()->event_number() - << " run " << pEvent->event_ID()->run_number() + << xAODEventInfo->eventNumber() + << " run " << xAODEventInfo->runNumber() << " into store " << this->store().name() ); - } - return pEvent; -} + } + + return xAODEventInfo; +} bool PileUpStream::nextEventPre_Passive(bool readRecord) { if (m_neverLoaded) readRecord=true; diff --git a/Control/SGTools/SGTools/EventIDFromStore.h b/Control/SGTools/SGTools/EventIDFromStore.h new file mode 100644 index 000000000000..e6dca6ca7ec3 --- /dev/null +++ b/Control/SGTools/SGTools/EventIDFromStore.h @@ -0,0 +1,59 @@ +// This file's extension implies that it's C, but it's really -*- C++ -*-. + +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file SGTools/EventIDFromStore.h + * @author Marcin Nowak + * @date Nov 2018 + * @brief Helper method to get EventID from an Event Store + */ + +#ifndef SGTOOLS_EVENTIDFROMSTORE_H +#define SGTOOLS_EVENTIDFROMSTORE_H + +#include "EventInfo/EventID.h" +#include "GaudiKernel/EventContext.h" +#include "AthenaKernel/IProxyDict.h" +#include "SGTools/DataProxy.h" +#include "StoreGate/StoreGateSvc.h" +#include "AthenaKernel/EventContextClid.h" + +/** + * @brief Retrieve the EventID from EventContext saved in store STORE. + * @param store The store from which to retrieve the EventID, or nullptr. + * + * If there is no context recorded in the store, return nullptr + */ +const EventIDBase* EventIDFromStore( IProxyDict* store ) +{ + if( store ) { + //MN: FIX: is this OK to have it static in case of multiple Stores? + static const SG::sgkey_t ctxkey = store->stringToKey( "EventContext", ClassID_traits<EventContext>::ID() ); + SG::DataProxy* proxy = store->proxy_exact(ctxkey); + if( proxy && proxy->object() ) { + return & SG::DataProxy_cast<EventContext>( proxy )->eventID(); + } + } + return nullptr; +} + + +// variation accepting a ServiceHandle to StoreGate +const EventIDBase* EventIDFromStore( const ServiceHandle<StoreGateSvc>& storeH ) +{ + return EventIDFromStore( &*storeH ); +} + + +// variation returning a StatusCode +StatusCode EventIDFromStore( IProxyDict* store, const EventIDBase*& evid ) +{ + evid = EventIDFromStore( store ); + return evid? StatusCode::SUCCESS : StatusCode::FAILURE; +} + +#endif + diff --git a/Database/AthenaPOOL/OutputStreamAthenaPool/CMakeLists.txt b/Database/AthenaPOOL/OutputStreamAthenaPool/CMakeLists.txt index 6e5182d57047..6db64f55782f 100644 --- a/Database/AthenaPOOL/OutputStreamAthenaPool/CMakeLists.txt +++ b/Database/AthenaPOOL/OutputStreamAthenaPool/CMakeLists.txt @@ -15,6 +15,7 @@ atlas_depends_on_subdirs( PRIVATE Database/AthenaPOOL/AthenaPoolUtilities Database/PersistentDataModel Event/EventInfo + Event/xAOD/xAODCnvInterfaces Event/xAOD/xAODEventInfo GaudiKernel ) @@ -26,7 +27,10 @@ atlas_add_component( OutputStreamAthenaPool src/EventInfoAttListTool.cxx src/EventInfoTagBuilder.cxx src/components/*.cxx - LINK_LIBRARIES AthenaBaseComps AthenaKernel SGTools StoreGateLib SGtests AthenaPoolCnvSvcLib AthenaPoolUtilities PersistentDataModel EventInfo xAODEventInfo GaudiKernel ) + LINK_LIBRARIES AthenaBaseComps AthenaKernel + SGTools StoreGateLib SGtests AthenaPoolCnvSvcLib + AthenaPoolUtilities PersistentDataModel EventInfo + xAODEventInfo xAODCnvInterfaces GaudiKernel ) # Install files from the package: atlas_install_python_modules( python/*.py ) diff --git a/Database/AthenaPOOL/OutputStreamAthenaPool/src/MakeEventStreamInfo.cxx b/Database/AthenaPOOL/OutputStreamAthenaPool/src/MakeEventStreamInfo.cxx index 5523dfbeb68b..e6444f6aa61d 100644 --- a/Database/AthenaPOOL/OutputStreamAthenaPool/src/MakeEventStreamInfo.cxx +++ b/Database/AthenaPOOL/OutputStreamAthenaPool/src/MakeEventStreamInfo.cxx @@ -17,13 +17,17 @@ #include "EventInfo/EventInfo.h" #include "EventInfo/EventID.h" #include "StoreGate/StoreGateSvc.h" +#include "xAODEventInfo/EventInfo.h" +#include "xAODCnvInterfaces/IEventInfoCnvTool.h" //___________________________________________________________________________ MakeEventStreamInfo::MakeEventStreamInfo(const std::string& type, const std::string& name, const IInterface* parent) : ::AthAlgTool(type, name, parent), m_metaDataStore("StoreGateSvc/MetaDataStore", name), - m_eventStore("StoreGateSvc", name) { + m_eventStore("StoreGateSvc", name), + m_xAODCnvTool("xAODMaker::EventInfoCnvTool/EventInfoCnvTool", this) +{ // Declare IAthenaOutputStreamTool interface declareInterface<IAthenaOutputTool>(this); @@ -45,6 +49,9 @@ StatusCode MakeEventStreamInfo::initialize() { ATH_MSG_FATAL("Could not find EventStore"); return(StatusCode::FAILURE); } + // Retrieve the converter tool: + CHECK(m_xAODCnvTool.retrieve()); + return(StatusCode::SUCCESS); } //___________________________________________________________________________ @@ -85,11 +92,25 @@ StatusCode MakeEventStreamInfo::postExecute() { ATH_MSG_ERROR("Unable to retrieve DataHeader for key = " << headerKey); return(StatusCode::FAILURE); } - const EventInfo* pEvent = nullptr; + EventType evtype; + unsigned long long runN = 0; + unsigned lumiN = 0; // Retrieve the EventInfo object - if (!m_eventStore->retrieve(pEvent).isSuccess()) { - ATH_MSG_ERROR("Unable to retrieve EventInfo object"); - return(StatusCode::FAILURE); + const EventInfo* pEvent = m_eventStore->tryConstRetrieve<EventInfo>(); + if( pEvent ) { + runN = pEvent->event_ID()->run_number(); + lumiN = pEvent->event_ID()->lumi_block(); + evtype = *pEvent->event_type(); + } else { + const xAOD::EventInfo* xEvent = m_eventStore->tryConstRetrieve<xAOD::EventInfo>(); + if( xEvent ) { + runN = xEvent->runNumber(); + lumiN = xEvent->lumiBlock(); + evtype = m_xAODCnvTool->eventTypeFromXAOD(xEvent); + } else { + ATH_MSG_ERROR("Unable to retrieve EventInfo object"); + return(StatusCode::FAILURE); + } } if (!m_metaDataStore->contains<EventStreamInfo>(m_key.value())) { EventStreamInfo* pEventStream = new EventStreamInfo(); @@ -106,13 +127,13 @@ StatusCode MakeEventStreamInfo::postExecute() { } pEventStream->addEvent(); pEventStream->insertProcessingTag(pHeader->getProcessTag()); - pEventStream->insertLumiBlockNumber(pEvent->event_ID()->lumi_block()); - pEventStream->insertRunNumber(pEvent->event_ID()->run_number()); + pEventStream->insertLumiBlockNumber( lumiN ); + pEventStream->insertRunNumber( runN ); for (std::vector<DataHeaderElement>::const_iterator iter = pHeader->begin(), iterEnd = pHeader->end(); iter != iterEnd; iter++) { pEventStream->insertItemList(iter->getPrimaryClassID(), iter->getKey()); } - pEventStream->insertEventType(*pEvent->event_type()); + pEventStream->insertEventType( evtype ); return(StatusCode::SUCCESS); } //___________________________________________________________________________ diff --git a/Database/AthenaPOOL/OutputStreamAthenaPool/src/MakeEventStreamInfo.h b/Database/AthenaPOOL/OutputStreamAthenaPool/src/MakeEventStreamInfo.h index d1d42f1c82a9..c18217b7ce8e 100644 --- a/Database/AthenaPOOL/OutputStreamAthenaPool/src/MakeEventStreamInfo.h +++ b/Database/AthenaPOOL/OutputStreamAthenaPool/src/MakeEventStreamInfo.h @@ -18,6 +18,7 @@ #include <string> class StoreGateSvc; +namespace xAODMaker { class IEventInfoCnvTool; } /** @class MakeEventStreamInfo * @brief This class provides an algorithm to make the EventStreamInfo object and update it. @@ -49,5 +50,9 @@ private: /// Pointer to the data stores ServiceHandle<StoreGateSvc> m_metaDataStore; ServiceHandle<StoreGateSvc> m_eventStore; + + /// Handle to the xAOD::EventInfo converter tool + ToolHandle< xAODMaker::IEventInfoCnvTool > m_xAODCnvTool; + }; #endif diff --git a/Database/IOVDbSvc/src/IOVDbSvc.cxx b/Database/IOVDbSvc/src/IOVDbSvc.cxx index f75d759fbf00..b7077c954779 100644 --- a/Database/IOVDbSvc/src/IOVDbSvc.cxx +++ b/Database/IOVDbSvc/src/IOVDbSvc.cxx @@ -20,9 +20,8 @@ #include "FileCatalog/IFileCatalog.h" #include "EventInfoMgt/ITagInfoMgr.h" -#include "EventInfo/EventInfo.h" -#include "EventInfo/EventID.h" #include "EventInfo/TagInfo.h" +#include "SGTools/EventIDFromStore.h" #include "IOVDbParser.h" @@ -433,6 +432,10 @@ StatusCode IOVDbSvc::loadAddresses(StoreID::type /*storeID*/, tadList& /*list*/ } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#include "CxxUtils/SealDebug.h" +#include <iostream> +using namespace std; +#include "AthenaKernel/EventContextClid.h" StatusCode IOVDbSvc::updateAddress(StoreID::type storeID, SG::TransientAddress* tad, const EventContext& /*ctx*/) @@ -469,15 +472,13 @@ StatusCode IOVDbSvc::updateAddress(StoreID::type storeID, SG::TransientAddress* return::StatusCode::SUCCESS; } if (m_state==IOVDbSvc::EVENT_LOOP) { - // determine iovTime from event - const DataHandle<EventInfo> evt; - const DataHandle<EventInfo> evtEnd; - if (StatusCode::SUCCESS==m_h_sgSvc->retrieve(evt,evtEnd)) { - m_iovTime.setRunEvent(evt->event_ID()->run_number(), - evt->event_ID()->lumi_block()); + // determine iovTime from eventID in the event context + const EventIDBase* evid = EventIDFromStore( m_h_sgSvc ); + if( evid ) { + m_iovTime.setRunEvent( evid->run_number(), evid->lumi_block()) ; // save both seconds and ns offset for timestamp - uint64_t nsTime=evt->event_ID()->time_stamp()*1000000000LL; - nsTime += evt->event_ID()->time_stamp_ns_offset(); + uint64_t nsTime = evid->time_stamp() *1000000000LL; + nsTime += evid->time_stamp_ns_offset(); m_iovTime.setTimestamp(nsTime); ATH_MSG_DEBUG( "updateAddress - using iovTime from EventInfo: " << m_iovTime); } else { diff --git a/Event/EventInfoMgt/src/TagInfoMgr.cxx b/Event/EventInfoMgt/src/TagInfoMgr.cxx index 3f24e54c47d1..19de7369ab6a 100755 --- a/Event/EventInfoMgt/src/TagInfoMgr.cxx +++ b/Event/EventInfoMgt/src/TagInfoMgr.cxx @@ -18,11 +18,12 @@ // Event includes #include "EventInfo/EventInfo.h" -#include "EventInfo/EventID.h" #include "EventInfo/EventType.h" #include "EventInfo/EventIncident.h" #include "EventInfo/TriggerInfo.h" +#include "SGTools/EventIDFromStore.h" + // IOVDbSvc #include "AthenaKernel/IIOVDbSvc.h" @@ -320,7 +321,9 @@ TagInfoMgr::fillTagInfo(const CondAttrListCollection* tagInfoCond, TagInfo* tagI // ***** READ WITH TAGS IN EVENT INFO ***** // ***** RDS 04/2009 ***** // ********************************************************** - + + //MN: FIX: Is this case still in use? If not, remove it + if (m_log.level() <= MSG::DEBUG) m_log << MSG::DEBUG << "fillTagInfo: Add in tags from EventInfo" << endmsg; const DataHandle<EventInfo> evtH; const DataHandle<EventInfo> evtHEnd; @@ -450,6 +453,9 @@ TagInfoMgr::fillTagInfo(const CondAttrListCollection* tagInfoCond, TagInfo* tagI } +#include <iostream> +using namespace std; + StatusCode TagInfoMgr::fillMetaData (const TagInfo* tagInfo, const CondAttrListCollection* tagInfoCond) { @@ -484,22 +490,21 @@ TagInfoMgr::fillMetaData (const TagInfo* tagInfo, const CondAttrListCollection // if (m_log.level() <= MSG::DEBUG) m_log << MSG::DEBUG << "entering fillMetaData" << endmsg; + cout << "MN: TagInfoMgr: start " << endl; // Get run number for IOV - const EventInfo* evt = 0; unsigned int runNumber = 0; - if (StatusCode::SUCCESS != m_storeGate->retrieve(evt)) { - // For simulation, we may be in the initialization phase and - // must get the run number from the event selector - if (StatusCode::SUCCESS != getRunNumber (runNumber)) { - m_log << MSG::ERROR << "fillMetaData: Could not get event info neither via retrieve nor from the EventSelectror" << endmsg; - return (StatusCode::FAILURE); - } + const EventIDBase* evid = EventIDFromStore( m_storeGate ); + if( evid ) { + runNumber = evid->run_number(); + } else { + // For simulation, we may be in the initialization phase and + // must get the run number from the event selector + if (StatusCode::SUCCESS != getRunNumber (runNumber)) { + m_log << MSG::ERROR << "fillMetaData: Could not get event info neither via retrieve nor from the EventSelectror" << endmsg; + return (StatusCode::FAILURE); + } } - else { - runNumber = evt->event_ID()->run_number(); - } - // Copy tags to AttributeList coral::AttributeList attrList; EventType::NameTagPairVec pairs; @@ -661,8 +666,10 @@ TagInfoMgr::handle(const Incident& inc) { } // Return quickly for BeginEvent if not needed - if (!m_newFileIncidentSeen && inc.type() == "BeginEvent") return; - + if (!m_newFileIncidentSeen && inc.type() == "BeginEvent") { + m_log << MSG::DEBUG << "Nothing to do, return" << endmsg; + return; + } // At first BeginRun we retrieve TagInfo and trigger IOVDbSvc to // use it if (inc.type() == "BeginRun" && m_isFirstBeginRun) { @@ -832,6 +839,7 @@ TagInfoMgr::handle(const Incident& inc) { if (m_log.level() <= MSG::DEBUG) m_log << MSG::DEBUG << "handle - BeginInputFile: Wrote TagInfo to MetaDataStore " << endmsg; } } + m_log << MSG::DEBUG << "Finished handling incident" << endmsg; } diff --git a/Event/EventOverlay/EventOverlayJobTransforms/share/OverlayOutputItemList_jobOptions.py b/Event/EventOverlay/EventOverlayJobTransforms/share/OverlayOutputItemList_jobOptions.py index 60d2003142c1..1674b759754f 100644 --- a/Event/EventOverlay/EventOverlayJobTransforms/share/OverlayOutputItemList_jobOptions.py +++ b/Event/EventOverlay/EventOverlayJobTransforms/share/OverlayOutputItemList_jobOptions.py @@ -12,7 +12,7 @@ outStream.Store = ServiceMgr.StoreGateSvc print "ACH123 new OverlayOutputItemList_jobOptions.py" # overlay output stream -outStream.ItemList += [ "EventInfo#*", "PileUpEventInfo#*" ] +outStream.ItemList += [ "xAOD::EventInfo#*" ] outStream.ItemList += [ "LumiBlockCollection#*" ] # timings diff --git a/Event/EventOverlay/EventOverlayJobTransforms/share/SignalOutputItemList_jobOptions.py b/Event/EventOverlay/EventOverlayJobTransforms/share/SignalOutputItemList_jobOptions.py index b7ffe031a183..67514440b99a 100644 --- a/Event/EventOverlay/EventOverlayJobTransforms/share/SignalOutputItemList_jobOptions.py +++ b/Event/EventOverlay/EventOverlayJobTransforms/share/SignalOutputItemList_jobOptions.py @@ -35,7 +35,7 @@ signalStream = AthenaPoolOutputStream( "StreamRDO_MC" ) signalStream.OutputFile = SignalCollection signalStream.Store = "TemporaryStore" -signalStream.ItemList += [ "EventInfo#*", "EventStreamInfo#*", "PileUpEventInfo#*" ] +signalStream.ItemList += [ "xAOD::EventInfo#*", "EventStreamInfo#*" ] if DetFlags.overlay.Truth_on(): signalStream.ItemList += [ diff --git a/Event/xAOD/xAODCnvInterfaces/xAODCnvInterfaces/IEventInfoCnvTool.h b/Event/xAOD/xAODCnvInterfaces/xAODCnvInterfaces/IEventInfoCnvTool.h index 8776f99f3451..b5d0e3342723 100644 --- a/Event/xAOD/xAODCnvInterfaces/xAODCnvInterfaces/IEventInfoCnvTool.h +++ b/Event/xAOD/xAODCnvInterfaces/xAODCnvInterfaces/IEventInfoCnvTool.h @@ -17,6 +17,8 @@ namespace xAOD { typedef EventInfo_v1 EventInfo; } class EventInfo; +class EventID; +class EventType; namespace xAODMaker { @@ -45,6 +47,12 @@ namespace xAODMaker { bool pileUpInfo = false, bool copyPileUpLinks = true ) const = 0; + /// Create EventID object from xAOD::EventInfo + virtual EventID eventIDFromXAOD( const xAOD::EventInfo* xaod ) const = 0; + + /// Create EventType object from xAOD::EventInfo + virtual EventType eventTypeFromXAOD( const xAOD::EventInfo* xaod ) const = 0; + /// Gaudi interface definition static const InterfaceID& interfaceID() { return IID_IEventInfoCnvTool; diff --git a/Event/xAOD/xAODEventInfoCnv/src/EventInfoCnvAlg.cxx b/Event/xAOD/xAODEventInfoCnv/src/EventInfoCnvAlg.cxx index 9ad9029219a1..38ea14b665c3 100644 --- a/Event/xAOD/xAODEventInfoCnv/src/EventInfoCnvAlg.cxx +++ b/Event/xAOD/xAODEventInfoCnv/src/EventInfoCnvAlg.cxx @@ -61,6 +61,8 @@ namespace xAODMaker { StatusCode EventInfoCnvAlg::execute (const EventContext& ctx) const { + ATH_MSG_WARNING( "MN: EventInfoCnvAlg::execute_r" ); + // Check if anything needs to be done: // FIXME: Job configuration should be fixed so we don't need this test. if( evtStore()->contains< xAOD::EventInfo >( m_xaodKey.key() ) ) { diff --git a/Event/xAOD/xAODEventInfoCnv/src/EventInfoCnvTool.cxx b/Event/xAOD/xAODEventInfoCnv/src/EventInfoCnvTool.cxx index 6a017fd2adf5..6c52c3f32dbe 100644 --- a/Event/xAOD/xAODEventInfoCnv/src/EventInfoCnvTool.cxx +++ b/Event/xAOD/xAODEventInfoCnv/src/EventInfoCnvTool.cxx @@ -127,6 +127,61 @@ namespace xAODMaker { return StatusCode::SUCCESS; } + /** + * Create EventID object from xAOD::EventInfo + * + * @param xaod The xAOD::EventInfo object + * @returns <code>EventID</code> + */ + + EventID EventInfoCnvTool::eventIDFromXAOD( const xAOD::EventInfo* xaod ) const + { + return EventID( xaod->runNumber(), + xaod->eventNumber(), + xaod->timeStamp(), + xaod->timeStampNSOffset(), + xaod->lumiBlock(), + xaod->bcid() ); + } + + + /** + * Create EventType object from xAOD::EventInfo + * + * @param xaod The xAOD::EventInfo object + * @returns <code>EventType</code> + */ + + EventType EventInfoCnvTool::eventTypeFromXAOD( const xAOD::EventInfo* xaod ) const + { + EventType et; + // Copy DetDescr tags + std::string ddtags; + for( const auto& ddtag: xaod->detDescrTags() ) { + //MN FIX: this is only my guess how it should look like + ddtags += '#' + ddtag.first + '#' + ddtag.second; + } + et.set_user_type( ddtags ); + + if( xaod->eventType(xAOD::EventInfo::IS_TESTBEAM) ) { + et.add_type(EventType::IS_TESTBEAM); + } + if( xaod->eventType(xAOD::EventInfo::IS_CALIBRATION) ) { + et.add_type(EventType::IS_CALIBRATION); + } + if( xaod->eventType(xAOD::EventInfo::IS_SIMULATION) ) { + et.add_type(EventType::IS_SIMULATION); + + et.set_mc_channel_number( xaod->mcChannelNumber() ); + et.set_mc_event_number( xaod->mcEventNumber() ); + for( size_t i=0; i< xaod->mcEventWeights().size(); i++ ) { + et.set_mc_event_weight( xaod->mcEventWeight(i), i, xaod->mcEventWeights().size() ); + } + } + + return et; + } + /** * This is the important function of the tool. It takes the EventInfo object * available in Athena, and fills an xAOD::EventInfo object with its contents. diff --git a/Event/xAOD/xAODEventInfoCnv/src/EventInfoCnvTool.h b/Event/xAOD/xAODEventInfoCnv/src/EventInfoCnvTool.h index 4130bea4d3f6..b2d09be5c218 100644 --- a/Event/xAOD/xAODEventInfoCnv/src/EventInfoCnvTool.h +++ b/Event/xAOD/xAODEventInfoCnv/src/EventInfoCnvTool.h @@ -54,6 +54,12 @@ namespace xAODMaker { bool pileUpInfo = false, bool copyPileUpLinks = true ) const; + /// Create EventID object from xAOD::EventInfo + virtual EventID eventIDFromXAOD( const xAOD::EventInfo* xaod ) const override; + + /// Create EventType object from xAOD::EventInfo + virtual EventType eventTypeFromXAOD( const xAOD::EventInfo* xaod ) const override; + private: #ifndef XAOD_ANALYSIS /// Connection to the beam spot service diff --git a/LArCalorimeter/LArDigitization/src/LArPileUpTool.cxx b/LArCalorimeter/LArDigitization/src/LArPileUpTool.cxx index 8bfd1fb145cd..c28a2ced9b37 100755 --- a/LArCalorimeter/LArDigitization/src/LArPileUpTool.cxx +++ b/LArCalorimeter/LArDigitization/src/LArPileUpTool.cxx @@ -27,6 +27,7 @@ #include "LArSimEvent/LArHit.h" #include "LArSimEvent/LArHitContainer.h" #include "PileUpTools/PileUpMergeSvc.h" +#include "SGTools/EventIDFromStore.h" #include <CLHEP/Random/Randomize.h> @@ -484,24 +485,22 @@ StatusCode LArPileUpTool::prepareEvent(unsigned int /*nInputEvents */) // if noise on, get random number engine and initialize with well defined seeds if (m_NoiseOnOff ||m_addPhase) { - //if use run-event number for seed - if (m_rndmEvtRun) { - const EventInfo* eventInfo; - StatusCode sc = evtStore()->retrieve(eventInfo); - int iSeedNumber=1; - if (sc.isFailure()) { - ATH_MSG_ERROR(" can not retrieve event info. Dummy rndm initialization..."); - m_engine = m_AtRndmGenSvc->setOnDefinedSeeds(iSeedNumber,this->name()); - } - else { - const EventID* myEventID=eventInfo->event_ID(); - const int iSeedNumber = myEventID->event_number()+1; - const int iRunNumber = myEventID->run_number(); - ATH_MSG_DEBUG(" Run/Event " << myEventID->run_number() << " " << myEventID->event_number()); - ATH_MSG_DEBUG(" iSeedNumber,iRunNumber " << iSeedNumber << " " << iRunNumber); - m_engine = m_AtRndmGenSvc->setOnDefinedSeeds(iSeedNumber,iRunNumber,this->name()); + //if use run-event number for seed + if (m_rndmEvtRun) { + const EventIDBase* evid = EventIDFromStore( evtStore() ); + if( evid ) { + const int iSeedNumber = evid->event_number()+1; + const int iRunNumber = evid->run_number(); + ATH_MSG_DEBUG(" Run/Event " << evid->run_number() << " " << evid->event_number()); + ATH_MSG_DEBUG(" iSeedNumber,iRunNumber " << iSeedNumber << " " << iRunNumber); + m_engine = m_AtRndmGenSvc->setOnDefinedSeeds(iSeedNumber,iRunNumber,this->name()); + } + else { + ATH_MSG_ERROR(" can not retrieve event info. Dummy rndm initialization..."); + int iSeedNumber=1; + m_engine = m_AtRndmGenSvc->setOnDefinedSeeds(iSeedNumber,this->name()); + } } - } } // get the trigger time if requested diff --git a/MuonSpectrometer/MuonDigitization/CSC_Digitization/CSC_Digitization/CscDigitizationTool.h b/MuonSpectrometer/MuonDigitization/CSC_Digitization/CSC_Digitization/CscDigitizationTool.h index 15fe8a923184..7bd2073a6b29 100644 --- a/MuonSpectrometer/MuonDigitization/CSC_Digitization/CSC_Digitization/CscDigitizationTool.h +++ b/MuonSpectrometer/MuonDigitization/CSC_Digitization/CSC_Digitization/CscDigitizationTool.h @@ -21,8 +21,6 @@ #include "MuonSimEvent/CSCSimHitCollection.h" #include "MuonSimData/CscSimDataCollection.h" -#include "EventInfo/PileUpEventInfo.h" /*SubEvent*/ - #include "xAODEventInfo/EventInfo.h" // NEW EDM #include "xAODEventInfo/EventAuxInfo.h" // NEW EDM diff --git a/MuonSpectrometer/MuonDigitization/CSC_Digitization/src/CscDigitizationTool.cxx b/MuonSpectrometer/MuonDigitization/CSC_Digitization/src/CscDigitizationTool.cxx index 3b3f7bb4bb1c..1b602a606737 100644 --- a/MuonSpectrometer/MuonDigitization/CSC_Digitization/src/CscDigitizationTool.cxx +++ b/MuonSpectrometer/MuonDigitization/CSC_Digitization/src/CscDigitizationTool.cxx @@ -22,7 +22,7 @@ #include "CLHEP/Random/RandomEngine.h" #include "CLHEP/Random/RandFlat.h" -#include "EventInfo/EventInfo.h" +#include "xAODEventInfo/EventInfo.h" using namespace MuonGM; @@ -214,14 +214,17 @@ StatusCode CscDigitizationTool::processAllSubEvents() { } +#include <iostream> +using namespace std; + StatusCode CscDigitizationTool::CoreDigitization(CscDigitContainer* cscDigits,CscSimDataCollection* cscSimData) { // get the iterator pairs for this DetEl //iterate over hits - const EventInfo* pevt = 0; - ATH_CHECK( evtStore()->retrieve(pevt, "") ); - m_evt = pevt->event_ID()->event_number(); - m_run = pevt->event_ID()->run_number(); + const xAOD::EventInfo* pevt = nullptr; + ATH_CHECK( evtStore()->retrieve(pevt) ); + m_evt = pevt->eventNumber(); + m_run = pevt->runNumber(); std::map <IdentifierHash,deposits> myDeposits; diff --git a/Simulation/Digitization/python/DigiOutput.py b/Simulation/Digitization/python/DigiOutput.py index e342b0897121..d3a8acdcf86d 100644 --- a/Simulation/Digitization/python/DigiOutput.py +++ b/Simulation/Digitization/python/DigiOutput.py @@ -65,7 +65,8 @@ def getStreamRDO_ItemList(log): if DetFlags.pileup.any_on() or digitizationFlags.doXingByXingPileUp(): if DetFlags.writeRDOPool.any_on(): #add to output stream - StreamRDO_ItemList+=["PileUpEventInfo#*"] +# StreamRDO_ItemList+=["PileUpEventInfo#*"] + StreamRDO_ItemList+=["xAOD::EventInfo#*"] # Set up for cosmics digitization from AthenaCommon.BeamFlags import jobproperties if jobproperties.Beam.beamType == "cosmics" : diff --git a/Trigger/TrigT1/TrigT1CaloSim/src/TriggerTowerMaker.cxx b/Trigger/TrigT1/TrigT1CaloSim/src/TriggerTowerMaker.cxx index 85c465f00cae..e0f1a7e594df 100755 --- a/Trigger/TrigT1/TrigT1CaloSim/src/TriggerTowerMaker.cxx +++ b/Trigger/TrigT1/TrigT1CaloSim/src/TriggerTowerMaker.cxx @@ -32,6 +32,7 @@ #include "LumiBlockComps/ILumiBlockMuTool.h" // Utilities +#include "SGTools/EventIDFromStore.h" #include "PathResolver/PathResolver.h" #include <sys/types.h> @@ -2821,15 +2822,11 @@ void LVL1::TriggerTowerMaker::digitize() void LVL1::TriggerTowerMaker::preProcess() { - - // Pedestal Correction: Get the BCID number - const EventInfo* evt; unsigned int eventBCID=0; - // unsigned int m_eventNumber=0; - if (StatusCode::SUCCESS == evtStore()->retrieve(evt)){ - eventBCID = evt->event_ID()->bunch_crossing_id(); - // m_eventNumber = evt->event_ID()->event_number(); + const EventIDBase* evid = EventIDFromStore( evtStore() ); + if( evid ) { + eventBCID = evid->bunch_crossing_id(); }else{ ATH_MSG_ERROR(" Unable to retrieve EventInfo from StoreGate "); } -- GitLab