From c3ef1b921cd1a1504f5c6e8f80bf30727a43bdc2 Mon Sep 17 00:00:00 2001 From: Dave Casper <dcasper@uci.edu> Date: Tue, 7 Dec 2021 15:48:12 -0800 Subject: [PATCH] HepMCParticleLink compatibility changes --- .../FaserCaloSimEventTPCnv/CMakeLists.txt | 2 +- .../src/CaloHits/CaloHitCollectionCnv_p1.cxx | 30 +++++++++++++++--- .../NeutrinoSimEventTPCnv/CMakeLists.txt | 2 +- .../NeutrinoHitCollectionCnv_p1.cxx | 30 +++++++++++++++--- .../ScintSimEventTPCnv/CMakeLists.txt | 2 +- .../ScintHits/ScintHitCollectionCnv_p1.cxx | 30 +++++++++++++++--- .../TrackerSimEventTPCnv/CMakeLists.txt | 2 +- .../FaserSiHitCollectionCnv_p3.cxx | 31 ++++++++++++++++--- 8 files changed, 109 insertions(+), 20 deletions(-) diff --git a/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/CMakeLists.txt b/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/CMakeLists.txt index dbbd1a37..ef770c2b 100644 --- a/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/CMakeLists.txt +++ b/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/CMakeLists.txt @@ -22,5 +22,5 @@ atlas_add_dictionary( FaserCaloSimEventTPCnvDict FaserCaloSimEventTPCnv/CaloSimEventTPCnvDict.h FaserCaloSimEventTPCnv/selection.xml INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthenaPoolCnvSvcLib GaudiKernel GeneratorObjectsTPCnv FaserCaloSimEvent TestTools StoreGateLib SGtests Identifier FaserCaloSimEventTPCnv ) + LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthenaPoolCnvSvcLib GaudiKernel GeneratorObjectsTPCnv FaserCaloSimEvent TestTools StoreGateLib SGtests Identifier FaserCaloSimEventTPCnv AthenaKernel) diff --git a/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/src/CaloHits/CaloHitCollectionCnv_p1.cxx b/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/src/CaloHits/CaloHitCollectionCnv_p1.cxx index c54f8765..77d4262f 100644 --- a/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/src/CaloHits/CaloHitCollectionCnv_p1.cxx +++ b/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/src/CaloHits/CaloHitCollectionCnv_p1.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 * * * // @@ -60,7 +63,7 @@ const double CaloHitCollectionCnv_p1::m_2bHalfMaximum = pow(2.0, 15.0); const int CaloHitCollectionCnv_p1::m_2bMaximum = (unsigned short)(-1); -void CaloHitCollectionCnv_p1::transToPers(const CaloHitCollection* transCont, CaloHitCollection_p1* persCont, MsgStream &/*log*/) +void CaloHitCollectionCnv_p1::transToPers(const CaloHitCollection* transCont, CaloHitCollection_p1* persCont, MsgStream &log) { // Finds hits belonging to a "string" (in which the end point of one hit is the same as the start point of the next) and // persistifies the end point of each hit plus the start point of the first hit in each string. @@ -77,6 +80,8 @@ void CaloHitCollectionCnv_p1::transToPers(const CaloHitCollection* transCont, Ca 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; @@ -98,11 +103,22 @@ void CaloHitCollectionCnv_p1::transToPers(const CaloHitCollection* transCont, Ca if ( !lastLink || (siHit->particleLink() != *lastLink) ) { - // store barcode once for set of consecutive hits with same barcode + // store barcode, eventIndex and McEventCollection once for set of consecutive hits with same barcode lastLink = &(siHit->particleLink()); persCont->m_barcode.push_back(lastLink->barcode()); - persCont->m_mcEvtIndex.push_back(lastLink->eventIndex()); + unsigned short index{0}; + const HepMcParticleLink::index_type position = + HepMcParticleLink::getEventPositionInCollection(lastLink->eventIndex(), + lastLink->getEventCollection(), + proxy).at(0); + if (position!=0) { + index = lastLink->eventIndex(); + if(lastLink->eventIndex()!=static_cast<HepMcParticleLink::index_type>(index)) { + log << MSG::WARNING << "Attempting to persistify an eventIndex larger than max unsigned short!" << endmsg; + } + } + persCont->m_mcEvtIndex.push_back(index); persCont->m_evtColl.push_back(lastLink->getEventCollectionAsChar()); if (idx > 0) { @@ -250,6 +266,8 @@ CaloHitCollection* CaloHitCollectionCnv_p1::createTransient(const CaloHitCollect void CaloHitCollectionCnv_p1::persToTrans(const CaloHitCollection_p1* persCont, CaloHitCollection* transCont, MsgStream &/*log*/) { + const EventContext& ctx = Gaudi::Hive::currentContext(); + unsigned int hitCount = 0; unsigned int angleCount = 0; unsigned int idxBC = 0; @@ -299,7 +317,11 @@ void CaloHitCollectionCnv_p1::persToTrans(const CaloHitCollection_p1* persCont, HepGeom::Point3D<double> endThis( endLast + r ); - HepMcParticleLink partLink( persCont->m_barcode[idxBC], persCont->m_mcEvtIndex[idxBC], HepMcParticleLink::ExtendedBarCode::eventCollectionFromChar(persCont->m_evtColl[idxBC]), HepMcParticleLink::IS_INDEX ); + HepMcParticleLink::PositionFlag flag = HepMcParticleLink::IS_INDEX; + if (persCont->m_mcEvtIndex[idxBC] == 0) { + flag = HepMcParticleLink::IS_POSITION; + } + HepMcParticleLink partLink( persCont->m_barcode[idxBC], persCont->m_mcEvtIndex[idxBC], HepMcParticleLink::ExtendedBarCode::eventCollectionFromChar(persCont->m_evtColl[idxBC]), flag, ctx ); transCont->Emplace( endLast, endThis, eneLoss, meanTime, partLink, persCont->m_id[idxId]); endLast = endThis; diff --git a/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/CMakeLists.txt b/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/CMakeLists.txt index defef98b..332a16c7 100644 --- a/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/CMakeLists.txt +++ b/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/CMakeLists.txt @@ -22,5 +22,5 @@ atlas_add_dictionary( NeutrinoSimEventTPCnvDict NeutrinoSimEventTPCnv/NeutrinoSimEventTPCnvDict.h NeutrinoSimEventTPCnv/selection.xml INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthenaPoolCnvSvcLib GaudiKernel GeneratorObjectsTPCnv NeutrinoSimEvent TestTools StoreGateLib SGtests Identifier NeutrinoSimEventTPCnv ) + LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthenaPoolCnvSvcLib GaudiKernel GeneratorObjectsTPCnv NeutrinoSimEvent TestTools StoreGateLib SGtests Identifier NeutrinoSimEventTPCnv AthenaKernel ) diff --git a/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/src/NeutrinoHits/NeutrinoHitCollectionCnv_p1.cxx b/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/src/NeutrinoHits/NeutrinoHitCollectionCnv_p1.cxx index 3b85676a..444ad417 100644 --- a/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/src/NeutrinoHits/NeutrinoHitCollectionCnv_p1.cxx +++ b/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/src/NeutrinoHits/NeutrinoHitCollectionCnv_p1.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 * * * // @@ -60,7 +63,7 @@ const double NeutrinoHitCollectionCnv_p1::m_2bHalfMaximum = pow(2.0, 15.0); const int NeutrinoHitCollectionCnv_p1::m_2bMaximum = (unsigned short)(-1); -void NeutrinoHitCollectionCnv_p1::transToPers(const NeutrinoHitCollection* transCont, NeutrinoHitCollection_p1* persCont, MsgStream &/*log*/) +void NeutrinoHitCollectionCnv_p1::transToPers(const NeutrinoHitCollection* transCont, NeutrinoHitCollection_p1* persCont, MsgStream &log) { // Finds hits belonging to a "string" (in which the end point of one hit is the same as the start point of the next) and // persistifies the end point of each hit plus the start point of the first hit in each string. @@ -77,6 +80,8 @@ void NeutrinoHitCollectionCnv_p1::transToPers(const NeutrinoHitCollection* trans 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; @@ -102,7 +107,18 @@ void NeutrinoHitCollectionCnv_p1::transToPers(const NeutrinoHitCollection* trans lastLink = &(siHit->particleLink()); persCont->m_barcode.push_back(lastLink->barcode()); - persCont->m_mcEvtIndex.push_back(lastLink->eventIndex()); + unsigned short index{0}; + const HepMcParticleLink::index_type position = + HepMcParticleLink::getEventPositionInCollection(lastLink->eventIndex(), + lastLink->getEventCollection(), + proxy).at(0); + if (position!=0) { + index = lastLink->eventIndex(); + if(lastLink->eventIndex()!=static_cast<HepMcParticleLink::index_type>(index)) { + log << MSG::WARNING << "Attempting to persistify an eventIndex larger than max unsigned short!" << endmsg; + } + } + persCont->m_mcEvtIndex.push_back(index); persCont->m_evtColl.push_back(lastLink->getEventCollectionAsChar()); if (idx > 0) { @@ -113,7 +129,7 @@ void NeutrinoHitCollectionCnv_p1::transToPers(const NeutrinoHitCollection* trans if ( (int)siHit->identify() != lastId ) { - // store id once for set of consecutive hits with same barcode + // store barcode, eventIndex and McEventCollection once for set of consecutive hits with same barcode lastId = siHit->identify(); persCont->m_id.push_back(lastId); @@ -250,6 +266,8 @@ NeutrinoHitCollection* NeutrinoHitCollectionCnv_p1::createTransient(const Neutri void NeutrinoHitCollectionCnv_p1::persToTrans(const NeutrinoHitCollection_p1* persCont, NeutrinoHitCollection* transCont, MsgStream &/*log*/) { + const EventContext& ctx = Gaudi::Hive::currentContext(); + unsigned int hitCount = 0; unsigned int angleCount = 0; unsigned int idxBC = 0; @@ -299,7 +317,11 @@ void NeutrinoHitCollectionCnv_p1::persToTrans(const NeutrinoHitCollection_p1* pe HepGeom::Point3D<double> endThis( endLast + r ); - HepMcParticleLink partLink( persCont->m_barcode[idxBC], persCont->m_mcEvtIndex[idxBC], HepMcParticleLink::ExtendedBarCode::eventCollectionFromChar(persCont->m_evtColl[idxBC]), HepMcParticleLink::IS_INDEX ); + HepMcParticleLink::PositionFlag flag = HepMcParticleLink::IS_INDEX; + if (persCont->m_mcEvtIndex[idxBC] == 0) { + flag = HepMcParticleLink::IS_POSITION; + } + HepMcParticleLink partLink( persCont->m_barcode[idxBC], persCont->m_mcEvtIndex[idxBC], HepMcParticleLink::ExtendedBarCode::eventCollectionFromChar(persCont->m_evtColl[idxBC]), flag, ctx ); transCont->Emplace( endLast, endThis, eneLoss, meanTime, partLink, persCont->m_id[idxId]); endLast = endThis; diff --git a/Scintillator/ScintEventCnv/ScintSimEventTPCnv/CMakeLists.txt b/Scintillator/ScintEventCnv/ScintSimEventTPCnv/CMakeLists.txt index 89c0c08d..04ca202d 100644 --- a/Scintillator/ScintEventCnv/ScintSimEventTPCnv/CMakeLists.txt +++ b/Scintillator/ScintEventCnv/ScintSimEventTPCnv/CMakeLists.txt @@ -22,5 +22,5 @@ atlas_add_dictionary( ScintSimEventTPCnvDict ScintSimEventTPCnv/ScintSimEventTPCnvDict.h ScintSimEventTPCnv/selection.xml INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthenaPoolCnvSvcLib GaudiKernel GeneratorObjectsTPCnv ScintSimEvent TestTools StoreGateLib SGtests Identifier ScintSimEventTPCnv ) + LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthenaPoolCnvSvcLib GaudiKernel GeneratorObjectsTPCnv ScintSimEvent TestTools StoreGateLib SGtests Identifier ScintSimEventTPCnv AthenaKernel ) diff --git a/Scintillator/ScintEventCnv/ScintSimEventTPCnv/src/ScintHits/ScintHitCollectionCnv_p1.cxx b/Scintillator/ScintEventCnv/ScintSimEventTPCnv/src/ScintHits/ScintHitCollectionCnv_p1.cxx index 08e4c55e..42b4160a 100644 --- a/Scintillator/ScintEventCnv/ScintSimEventTPCnv/src/ScintHits/ScintHitCollectionCnv_p1.cxx +++ b/Scintillator/ScintEventCnv/ScintSimEventTPCnv/src/ScintHits/ScintHitCollectionCnv_p1.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 * * * // @@ -60,7 +63,7 @@ const double ScintHitCollectionCnv_p1::m_2bHalfMaximum = pow(2.0, 15.0); const int ScintHitCollectionCnv_p1::m_2bMaximum = (unsigned short)(-1); -void ScintHitCollectionCnv_p1::transToPers(const ScintHitCollection* transCont, ScintHitCollection_p1* persCont, MsgStream &/*log*/) +void ScintHitCollectionCnv_p1::transToPers(const ScintHitCollection* transCont, ScintHitCollection_p1* persCont, MsgStream &log) { // Finds hits belonging to a "string" (in which the end point of one hit is the same as the start point of the next) and // persistifies the end point of each hit plus the start point of the first hit in each string. @@ -77,6 +80,8 @@ void ScintHitCollectionCnv_p1::transToPers(const ScintHitCollection* transCont, 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; @@ -98,11 +103,22 @@ void ScintHitCollectionCnv_p1::transToPers(const ScintHitCollection* transCont, if ( !lastLink || (siHit->particleLink() != *lastLink) ) { - // store barcode once for set of consecutive hits with same barcode + // store barcode, eventIndex and McEventCollection once for set of consecutive hits with same barcode lastLink = &(siHit->particleLink()); persCont->m_barcode.push_back(lastLink->barcode()); - persCont->m_mcEvtIndex.push_back(lastLink->eventIndex()); + unsigned short index{0}; + const HepMcParticleLink::index_type position = + HepMcParticleLink::getEventPositionInCollection(lastLink->eventIndex(), + lastLink->getEventCollection(), + proxy).at(0); + if (position!=0) { + index = lastLink->eventIndex(); + if(lastLink->eventIndex()!=static_cast<HepMcParticleLink::index_type>(index)) { + log << MSG::WARNING << "Attempting to persistify an eventIndex larger than max unsigned short!" << endmsg; + } + } + persCont->m_mcEvtIndex.push_back(index); persCont->m_evtColl.push_back(lastLink->getEventCollectionAsChar()); if (idx > 0) { @@ -250,6 +266,8 @@ ScintHitCollection* ScintHitCollectionCnv_p1::createTransient(const ScintHitColl void ScintHitCollectionCnv_p1::persToTrans(const ScintHitCollection_p1* persCont, ScintHitCollection* transCont, MsgStream &/*log*/) { + const EventContext& ctx = Gaudi::Hive::currentContext(); + unsigned int hitCount = 0; unsigned int angleCount = 0; unsigned int idxBC = 0; @@ -299,7 +317,11 @@ void ScintHitCollectionCnv_p1::persToTrans(const ScintHitCollection_p1* persCont HepGeom::Point3D<double> endThis( endLast + r ); - HepMcParticleLink partLink( persCont->m_barcode[idxBC], persCont->m_mcEvtIndex[idxBC], HepMcParticleLink::ExtendedBarCode::eventCollectionFromChar(persCont->m_evtColl[idxBC]), HepMcParticleLink::IS_INDEX ); + HepMcParticleLink::PositionFlag flag = HepMcParticleLink::IS_INDEX; + if (persCont->m_mcEvtIndex[idxBC] == 0) { + flag = HepMcParticleLink::IS_POSITION; + } + HepMcParticleLink partLink( persCont->m_barcode[idxBC], persCont->m_mcEvtIndex[idxBC], HepMcParticleLink::ExtendedBarCode::eventCollectionFromChar(persCont->m_evtColl[idxBC]), flag, ctx ); transCont->Emplace( endLast, endThis, eneLoss, meanTime, partLink, persCont->m_id[idxId]); endLast = endThis; diff --git a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/CMakeLists.txt b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/CMakeLists.txt index f18b0945..7e51dca0 100644 --- a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/CMakeLists.txt +++ b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/CMakeLists.txt @@ -22,5 +22,5 @@ atlas_add_dictionary( TrackerSimEventTPCnvDict TrackerSimEventTPCnv/TrackerSimEventTPCnvDict.h TrackerSimEventTPCnv/selection.xml INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthenaPoolCnvSvcLib GaudiKernel GeneratorObjectsTPCnv TrackerSimEvent TestTools StoreGateLib SGtests Identifier TrackerSimEventTPCnv ) + LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthenaPoolCnvSvcLib GaudiKernel GeneratorObjectsTPCnv TrackerSimEvent TestTools StoreGateLib SGtests Identifier TrackerSimEventTPCnv AthenaKernel ) diff --git a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/src/TrackerHits/FaserSiHitCollectionCnv_p3.cxx b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/src/TrackerHits/FaserSiHitCollectionCnv_p3.cxx index e8c95490..ee4b293a 100644 --- a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/src/TrackerHits/FaserSiHitCollectionCnv_p3.cxx +++ b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/src/TrackerHits/FaserSiHitCollectionCnv_p3.cxx @@ -14,8 +14,12 @@ #include "CLHEP/Geometry/Point3D.h" // Gaudi #include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/ThreadLocalContext.h" + // Athena #include "StoreGate/StoreGateSvc.h" +#include "AthenaKernel/ExtendedEventContext.h" + // * * * stolen from eflowRec * * * // inline double phicorr(double a) @@ -60,7 +64,7 @@ const double FaserSiHitCollectionCnv_p3::m_2bHalfMaximum = pow(2.0, 15.0); const int FaserSiHitCollectionCnv_p3::m_2bMaximum = (unsigned short)(-1); -void FaserSiHitCollectionCnv_p3::transToPers(const FaserSiHitCollection* transCont, FaserSiHitCollection_p3* persCont, MsgStream &/*log*/) +void FaserSiHitCollectionCnv_p3::transToPers(const FaserSiHitCollection* transCont, FaserSiHitCollection_p3* persCont, MsgStream &log) { // Finds hits belonging to a "string" (in which the end point of one hit is the same as the start point of the next) and // persistifies the end point of each hit plus the start point of the first hit in each string. @@ -77,6 +81,8 @@ void FaserSiHitCollectionCnv_p3::transToPers(const FaserSiHitCollection* transCo 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; @@ -98,11 +104,22 @@ void FaserSiHitCollectionCnv_p3::transToPers(const FaserSiHitCollection* transCo if ( !lastLink || (siHit->particleLink() != *lastLink) ) { - // store barcode once for set of consecutive hits with same barcode + // store barcode, eventIndex and McEventCollection once for set of consecutive hits with same barcode lastLink = &(siHit->particleLink()); persCont->m_barcode.push_back(lastLink->barcode()); - persCont->m_mcEvtIndex.push_back(lastLink->eventIndex()); + unsigned short index{0}; + const HepMcParticleLink::index_type position = + HepMcParticleLink::getEventPositionInCollection(lastLink->eventIndex(), + lastLink->getEventCollection(), + proxy).at(0); + if (position!=0) { + index = lastLink->eventIndex(); + if(lastLink->eventIndex()!=static_cast<HepMcParticleLink::index_type>(index)) { + log << MSG::WARNING << "Attempting to persistify an eventIndex larger than max unsigned short!" << endmsg; + } + } + persCont->m_mcEvtIndex.push_back(index); persCont->m_evtColl.push_back(lastLink->getEventCollectionAsChar()); if (idx > 0) { @@ -250,6 +267,8 @@ FaserSiHitCollection* FaserSiHitCollectionCnv_p3::createTransient(const FaserSiH void FaserSiHitCollectionCnv_p3::persToTrans(const FaserSiHitCollection_p3* persCont, FaserSiHitCollection* transCont, MsgStream &/*log*/) { + const EventContext& ctx = Gaudi::Hive::currentContext(); + unsigned int hitCount = 0; unsigned int angleCount = 0; unsigned int idxBC = 0; @@ -299,7 +318,11 @@ void FaserSiHitCollectionCnv_p3::persToTrans(const FaserSiHitCollection_p3* pers HepGeom::Point3D<double> endThis( endLast + r ); - HepMcParticleLink partLink( persCont->m_barcode[idxBC], persCont->m_mcEvtIndex[idxBC], HepMcParticleLink::ExtendedBarCode::eventCollectionFromChar(persCont->m_evtColl[idxBC]), HepMcParticleLink::IS_INDEX ); + HepMcParticleLink::PositionFlag flag = HepMcParticleLink::IS_INDEX; + if (persCont->m_mcEvtIndex[idxBC] == 0) { + flag = HepMcParticleLink::IS_POSITION; + } + HepMcParticleLink partLink( persCont->m_barcode[idxBC], persCont->m_mcEvtIndex[idxBC], HepMcParticleLink::ExtendedBarCode::eventCollectionFromChar(persCont->m_evtColl[idxBC]), flag, ctx ); transCont->Emplace( endLast, endThis, eneLoss, meanTime, partLink, persCont->m_id[idxId]); endLast = endThis; -- GitLab