Skip to content

Commit

Permalink
Make sure the calo hit collection metadata are updated when redoing s…
Browse files Browse the repository at this point in the history
…egmentation
  • Loading branch information
BrieucF authored and vvolkl committed May 23, 2022
1 parent c8d31a8 commit e4f439c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Detector/DetComponents/src/RedoSegmentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

DECLARE_COMPONENT(RedoSegmentation)

RedoSegmentation::RedoSegmentation(const std::string& aName, ISvcLocator* aSvcLoc) : GaudiAlgorithm(aName, aSvcLoc), m_geoSvc("GeoSvc", aName) {
RedoSegmentation::RedoSegmentation(const std::string& aName, ISvcLocator* aSvcLoc) : GaudiAlgorithm(aName, aSvcLoc), m_geoSvc("GeoSvc", aName), m_eventDataSvc("EventDataSvc", "RedoSegmentation") {
declareProperty("inhits", m_inHits, "Hit collection with old segmentation (input)");
declareProperty("outhits", m_outHits, "Hit collection with modified segmentation (output)");
}
Expand All @@ -39,6 +39,12 @@ StatusCode RedoSegmentation::initialize() {
}
// Take readout, bitfield from GeoSvc
m_oldDecoder = m_geoSvc->lcdd()->readout(m_oldReadoutName).idSpec().decoder();
StatusCode sc_dataSvc = m_eventDataSvc.retrieve();
m_podioDataSvc = dynamic_cast<PodioDataSvc*>(m_eventDataSvc.get());
if (sc_dataSvc == StatusCode::FAILURE) {
error() << "Error retrieving Event Data Service" << endmsg;
return StatusCode::FAILURE;
}
// segmentation identifiers to be overwritten
if (m_oldIdentifiers.size() == 0) {
// it is not an error, maybe no segmentation was used previously
Expand Down Expand Up @@ -107,6 +113,9 @@ StatusCode RedoSegmentation::execute() {
debugIter++;
}
}
// Define the metadata
auto& coll_md = m_podioDataSvc->getProvider().getCollectionMetaData(m_outHits.get()->getID());
coll_md.setValue("CellIDEncodingString", m_segmentation->decoder()->fieldDescription());
return StatusCode::SUCCESS;
}

Expand Down
2 changes: 2 additions & 0 deletions Detector/DetComponents/src/RedoSegmentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class RedoSegmentation : public GaudiAlgorithm {
uint64_t volumeID(uint64_t aCellId) const;
/// Pointer to the geometry service
ServiceHandle<IGeoSvc> m_geoSvc;
PodioDataSvc* m_podioDataSvc;
ServiceHandle<IDataProviderSvc> m_eventDataSvc;
/// Handle for the EDM positioned hits to be read
DataHandle<edm4hep::CalorimeterHitCollection> m_inHits{"hits/caloInHits", Gaudi::DataHandle::Reader, this};
/// Handle for the EDM hits to be written
Expand Down

0 comments on commit e4f439c

Please sign in to comment.