diff --git a/Generators/GeneratorObjectsTPCnv/src/HepMcParticleLinkCnv_p1.cxx b/Generators/GeneratorObjectsTPCnv/src/HepMcParticleLinkCnv_p1.cxx index 819b293ef19c656531a29af73936052fe9e6402c..06809d4a80289174a0cf6b1a94e53e48783a2688 100755 --- a/Generators/GeneratorObjectsTPCnv/src/HepMcParticleLinkCnv_p1.cxx +++ b/Generators/GeneratorObjectsTPCnv/src/HepMcParticleLinkCnv_p1.cxx @@ -6,6 +6,8 @@ // Framework includes #include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/ThreadLocalContext.h" +#include "AthenaKernel/ExtendedEventContext.h" // GeneratorObjectsAthenaPool includes #include "GeneratorObjectsTPCnv/HepMcParticleLinkCnv_p1.h" @@ -54,11 +56,13 @@ void HepMcParticleLinkCnv_p1::transToPers( const HepMcParticleLink* transObj, // NB This method assumes that there all GenEvents are stored in a // single McEventCollection, as running with split // McEventCollections is not supported in 21.0. + const EventContext& ctx = Gaudi::Hive::currentContext(); + const IProxyDict* proxy = Atlas::getExtendedEventContext(ctx).proxy(); unsigned short index{0}; const HepMcParticleLink::index_type position = HepMcParticleLink::getEventPositionInCollection(transObj->eventIndex(), transObj->getEventCollection(), - SG::CurrentEventStore::store()).at(0); + proxy).at(0); if (position!=0) { index = transObj->eventIndex(); if(transObj->eventIndex()!=static_cast<HepMcParticleLink::index_type>(index)) { diff --git a/Generators/GeneratorObjectsTPCnv/src/HepMcParticleLinkCnv_p2.cxx b/Generators/GeneratorObjectsTPCnv/src/HepMcParticleLinkCnv_p2.cxx index 206fb6138ca7c3c4b6661bd8249f874899167997..d448d8cca25e65c1ab378bd32c247b658633cd76 100755 --- a/Generators/GeneratorObjectsTPCnv/src/HepMcParticleLinkCnv_p2.cxx +++ b/Generators/GeneratorObjectsTPCnv/src/HepMcParticleLinkCnv_p2.cxx @@ -6,6 +6,8 @@ // Framework includes #include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/ThreadLocalContext.h" +#include "AthenaKernel/ExtendedEventContext.h" // GeneratorObjectsAthenaPool includes #include "GeneratorObjectsTPCnv/HepMcParticleLinkCnv_p2.h" @@ -48,11 +50,13 @@ void HepMcParticleLinkCnv_p2::transToPers( const HepMcParticleLink* transObj, // m_mcEvtIndex of zero as a special case, in which m_mcEvtIndex // should be interpreted as the position in the McEventCollection // rather than the value of GenEvent::event_number(). + const EventContext& ctx = Gaudi::Hive::currentContext(); + const IProxyDict* proxy = Atlas::getExtendedEventContext(ctx).proxy(); unsigned short index{0}; const HepMcParticleLink::index_type position = HepMcParticleLink::getEventPositionInCollection(transObj->eventIndex(), transObj->getEventCollection(), - SG::CurrentEventStore::store()).at(0); + proxy).at(0); if (position!=0) { index = transObj->eventIndex(); if(transObj->eventIndex()!=static_cast<HepMcParticleLink::index_type>(index)) { diff --git a/Generators/GeneratorObjectsTPCnv/src/initMcEventCollection.cxx b/Generators/GeneratorObjectsTPCnv/src/initMcEventCollection.cxx index 4714e3d384374dc98b338b4cf4ada1e3ecf3c648..cbea6c770cee14d04a6998f5f45ee9e7876ffe4c 100644 --- a/Generators/GeneratorObjectsTPCnv/src/initMcEventCollection.cxx +++ b/Generators/GeneratorObjectsTPCnv/src/initMcEventCollection.cxx @@ -29,6 +29,12 @@ namespace Athena_test { // HepMcParticleLink knows about SG::WriteHandle<McEventCollection> inputTestDataHandle{"TruthEvent"}; inputTestDataHandle = std::make_unique<McEventCollection>(); + + // create a dummy EventContext + EventContext ctx; + ctx.setExtension( Atlas::ExtendedEventContext( SG::CurrentEventStore::store() ) ); + Gaudi::Hive::setCurrentContext( ctx ); + // Add a dummy GenEvent const int process_id1(20); const int event_number1(17); diff --git a/Generators/GeneratorObjectsTPCnv/test/HepMcParticleLinkCnv_p1_test.cxx b/Generators/GeneratorObjectsTPCnv/test/HepMcParticleLinkCnv_p1_test.cxx index 63a095bbc4012dc8463a5cb33a2ff78e31ff3ded..cba5f66338a69b3d66e46093e1ca857758b10de5 100644 --- a/Generators/GeneratorObjectsTPCnv/test/HepMcParticleLinkCnv_p1_test.cxx +++ b/Generators/GeneratorObjectsTPCnv/test/HepMcParticleLinkCnv_p1_test.cxx @@ -113,6 +113,11 @@ void createMcEventCollectionInStoreGate(std::vector<HepMC::GenParticle*>& genPar // HepMcParticleLink knows about SG::WriteHandle<McEventCollection> inputTestDataHandle{"TruthEvent"}; inputTestDataHandle = std::make_unique<McEventCollection>(); + + EventContext ctx; + ctx.setExtension( Atlas::ExtendedEventContext( SG::CurrentEventStore::store() ) ); + Gaudi::Hive::setCurrentContext( ctx ); + // Add a dummy GenEvent const int process_id1(20); const int event_number1(2147483647); diff --git a/Generators/GeneratorObjectsTPCnv/test/HepMcParticleLinkCnv_p2_test.cxx b/Generators/GeneratorObjectsTPCnv/test/HepMcParticleLinkCnv_p2_test.cxx index d5ff7c2969045c8946d77ffacfc10aff5ff4161d..2fa9d29de83e01978b22e6de6fab755737a83e59 100644 --- a/Generators/GeneratorObjectsTPCnv/test/HepMcParticleLinkCnv_p2_test.cxx +++ b/Generators/GeneratorObjectsTPCnv/test/HepMcParticleLinkCnv_p2_test.cxx @@ -113,6 +113,11 @@ void createMcEventCollectionInStoreGate(std::vector<HepMC::GenParticle*>& genPar // HepMcParticleLink knows about SG::WriteHandle<McEventCollection> inputTestDataHandle{"TruthEvent"}; inputTestDataHandle = std::make_unique<McEventCollection>(); + // create a dummy EventContext + EventContext ctx; + ctx.setExtension( Atlas::ExtendedEventContext( SG::CurrentEventStore::store() ) ); + Gaudi::Hive::setCurrentContext( ctx ); + // Add a dummy GenEvent const int process_id1(20); const int event_number1(2147483647); diff --git a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/CMakeLists.txt b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/CMakeLists.txt index 2fd4f5c476e202374a504b60103e28f731bea51b..5c31dc0a6617240870c805a4ed42293c4b150b01 100644 --- a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/CMakeLists.txt +++ b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/CMakeLists.txt @@ -13,6 +13,7 @@ atlas_depends_on_subdirs( PUBLIC InnerDetector/InDetSimEvent PRIVATE AtlasTest/TestTools + Control/AthenaKernel Control/StoreGate DetectorDescription/Identifier ) @@ -27,7 +28,7 @@ atlas_add_library( InDetSimEventTPCnv PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} PRIVATE_DEFINITIONS ${CLHEP_DEFINITIONS} LINK_LIBRARIES GaudiKernel GeneratorObjectsTPCnv InDetSimEvent AthenaPoolCnvSvcLib StoreGateLib SGtests - PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} TestTools Identifier ) + PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} TestTools Identifier AthenaKernel ) atlas_add_dictionary( InDetSimEventTPCnvDict InDetSimEventTPCnv/InDetSimEventTPCnvDict.h diff --git a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/src/InDetHits/SiHitCollectionCnv_p3.cxx b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/src/InDetHits/SiHitCollectionCnv_p3.cxx index 4f57109b96ebb2c0e9d1fff8721d246ec72af9c3..e329c1c4adbfe0c8c7c92aa2b594f4d99b3d19c6 100644 --- a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/src/InDetHits/SiHitCollectionCnv_p3.cxx +++ b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/src/InDetHits/SiHitCollectionCnv_p3.cxx @@ -14,7 +14,10 @@ #include "CLHEP/Geometry/Point3D.h" // Gaudi #include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/ThreadLocalContext.h" + // Athena +#include "AthenaKernel/ExtendedEventContext.h" #include "StoreGate/StoreGateSvc.h" // * * * stolen from eflowRec * * * // @@ -77,6 +80,8 @@ void SiHitCollectionCnv_p3::transToPers(const SiHitCollection* transCont, SiHitC static const double dRcut = 1.0e-7; static const double dTcut = 1.0; + const EventContext& ctx = Gaudi::Hive::currentContext(); + const IProxyDict* proxy = Atlas::getExtendedEventContext(ctx).proxy(); const HepMcParticleLink * lastLink=nullptr; int lastId = -1; double stringFirstTheta = 0.0; @@ -106,7 +111,7 @@ void SiHitCollectionCnv_p3::transToPers(const SiHitCollection* transCont, SiHitC const HepMcParticleLink::index_type position = HepMcParticleLink::getEventPositionInCollection(lastLink->eventIndex(), lastLink->getEventCollection(), - SG::CurrentEventStore::store()).at(0); + proxy).at(0); if (position!=0) { index = lastLink->eventIndex(); if(lastLink->eventIndex()!=static_cast<HepMcParticleLink::index_type>(index)) { diff --git a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/src/InDetHits/TRT_HitCollectionCnv_p4.cxx b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/src/InDetHits/TRT_HitCollectionCnv_p4.cxx index 5b0aa141fab956e82e3029fc00b1c85982b0345a..a4986a1e28335c36a3e44a64851fbd414773ce0c 100644 --- a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/src/InDetHits/TRT_HitCollectionCnv_p4.cxx +++ b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/src/InDetHits/TRT_HitCollectionCnv_p4.cxx @@ -15,8 +15,10 @@ // Gaudi #include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/ThreadLocalContext.h" // Athena +#include "AthenaKernel/ExtendedEventContext.h" #include "StoreGate/StoreGateSvc.h" // Transient(Geant) to Persistent(Disk) @@ -50,6 +52,8 @@ void TRT_HitCollectionCnv_p4::transToPers(const TRTUncompressedHitCollection* tr // if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "In TRT_HitCollectionCnv_p4::transToPers()" << endmsg; + const EventContext& ctx = Gaudi::Hive::currentContext(); + const IProxyDict* proxy = Atlas::getExtendedEventContext(ctx).proxy(); const HepMcParticleLink * lastLink=NULL; int lastId = -1; double lastT = 0.0*CLHEP::ns; @@ -71,7 +75,7 @@ void TRT_HitCollectionCnv_p4::transToPers(const TRTUncompressedHitCollection* tr const HepMcParticleLink::index_type position = HepMcParticleLink::getEventPositionInCollection(lastLink->eventIndex(), lastLink->getEventCollection(), - SG::CurrentEventStore::store()).at(0); + proxy).at(0); if (position!=0) { index = lastLink->eventIndex(); if(lastLink->eventIndex()!=static_cast<HepMcParticleLink::index_type>(index)) {