From 3af7e26c7ee1381f1baa9f4f229b211392453ed8 Mon Sep 17 00:00:00 2001 From: Placido Fernandez Declara Date: Thu, 30 Sep 2021 17:43:56 +0200 Subject: [PATCH] add cellid only for current collection --- SimG4Components/src/SimG4SaveCalHits.cpp | 17 ++++++++--------- SimG4Components/src/SimG4SaveTrackerHits.cpp | 16 ++++++++-------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/SimG4Components/src/SimG4SaveCalHits.cpp b/SimG4Components/src/SimG4SaveCalHits.cpp index 8144218..102981f 100644 --- a/SimG4Components/src/SimG4SaveCalHits.cpp +++ b/SimG4Components/src/SimG4SaveCalHits.cpp @@ -66,16 +66,15 @@ StatusCode SimG4SaveCalHits::saveOutput(const G4Event& aEvent) { auto edmHits = m_caloHits.createAndPut(); for (int iter_coll = 0; iter_coll < collections->GetNumberOfCollections(); iter_coll++) { collect = collections->GetHC(iter_coll); - - // Add CellID encoding string to collection metadata - auto lcdd = m_geoSvc->lcdd(); - auto allReadouts = lcdd->readouts(); - auto idspec = lcdd->idSpecification(collect->GetName()); - auto field_str = idspec.fieldDescription(); - auto& coll_md = m_podioDataSvc->getProvider().getCollectionMetaData( m_caloHits.get()->getID() ); - coll_md.setValue("CellIDEncodingString", field_str); - if (std::find(m_readoutNames.begin(), m_readoutNames.end(), collect->GetName()) != m_readoutNames.end()) { + // Add CellID encoding string to collection metadata + auto lcdd = m_geoSvc->lcdd(); + auto allReadouts = lcdd->readouts(); + auto idspec = lcdd->idSpecification(collect->GetName()); + auto field_str = idspec.fieldDescription(); + auto& coll_md = m_podioDataSvc->getProvider().getCollectionMetaData( m_caloHits.get()->getID() ); + coll_md.setValue("CellIDEncodingString", field_str); + size_t n_hit = collect->GetSize(); debug() << "\t" << n_hit << " hits are stored in a collection #" << iter_coll << ": " << collect->GetName() << endmsg; diff --git a/SimG4Components/src/SimG4SaveTrackerHits.cpp b/SimG4Components/src/SimG4SaveTrackerHits.cpp index a569e72..5a4bf92 100644 --- a/SimG4Components/src/SimG4SaveTrackerHits.cpp +++ b/SimG4Components/src/SimG4SaveTrackerHits.cpp @@ -70,16 +70,16 @@ StatusCode SimG4SaveTrackerHits::saveOutput(const G4Event& aEvent) { edm4hep::SimTrackerHitCollection* edmHits = m_trackHits.createAndPut(); for (int iter_coll = 0; iter_coll < collections->GetNumberOfCollections(); iter_coll++) { collect = collections->GetHC(iter_coll); + if (std::find(m_readoutNames.begin(), m_readoutNames.end(), collect->GetName()) != m_readoutNames.end()) { - // Add CellID encoding string to collection metadata - auto lcdd = m_geoSvc->lcdd(); - auto allReadouts = lcdd->readouts(); - auto idspec = lcdd->idSpecification(collect->GetName()); - auto field_str = idspec.fieldDescription(); - auto& coll_md = m_podioDataSvc->getProvider().getCollectionMetaData( m_trackHits.get()->getID() ); - coll_md.setValue("CellIDEncodingString", field_str); + // Add CellID encoding string to collection metadata + auto lcdd = m_geoSvc->lcdd(); + auto allReadouts = lcdd->readouts(); + auto idspec = lcdd->idSpecification(collect->GetName()); + auto field_str = idspec.fieldDescription(); + auto& coll_md = m_podioDataSvc->getProvider().getCollectionMetaData( m_trackHits.get()->getID() ); + coll_md.setValue("CellIDEncodingString", field_str); - if (std::find(m_readoutNames.begin(), m_readoutNames.end(), collect->GetName()) != m_readoutNames.end()) { size_t n_hit = collect->GetSize(); verbose() << "\t" << n_hit << " hits are stored in a tracker collection #" << iter_coll << ": " << collect->GetName() << endmsg;