Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure the calo hit collection metadata are updated when redoing s… #18

Merged
merged 1 commit into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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