diff --git a/RecCalorimeter/src/components/CreateCaloCells.cpp b/RecCalorimeter/src/components/CreateCaloCells.cpp index 87f5d9db..bdfe04d9 100644 --- a/RecCalorimeter/src/components/CreateCaloCells.cpp +++ b/RecCalorimeter/src/components/CreateCaloCells.cpp @@ -15,7 +15,7 @@ DECLARE_COMPONENT(CreateCaloCells) CreateCaloCells::CreateCaloCells(const std::string& name, ISvcLocator* svcLoc) : -GaudiAlgorithm(name, svcLoc), m_geoSvc("GeoSvc", name), m_eventDataSvc("EventDataSvc", "CreateCaloCells") { +GaudiAlgorithm(name, svcLoc), m_geoSvc("GeoSvc", name) { declareProperty("hits", m_hits, "Hits from which to create cells (input)"); declareProperty("cells", m_cells, "The created calorimeter cells (output)"); @@ -63,12 +63,9 @@ StatusCode CreateCaloCells::initialize() { if (m_addPosition){ m_volman = m_geoSvc->lcdd()->volumeManager(); } - StatusCode sc_dataSvc = m_eventDataSvc.retrieve(); - m_podioDataSvc = dynamic_cast(m_eventDataSvc.get()); - if (sc_dataSvc == StatusCode::FAILURE) { - error() << "Error retrieving Event Data Service" << endmsg; - return StatusCode::FAILURE; - } + + // Copy over the CellIDEncoding string from the input collection to the output collection + m_cellsCellIDEncoding.put(m_hitsCellIDEncoding.get()); return StatusCode::SUCCESS; } @@ -131,9 +128,6 @@ StatusCode CreateCaloCells::execute() { // push the CaloHitCollection to event store m_cells.put(edmCellsCollection); - // Ship the metadata to the new collection - auto& coll_md = m_podioDataSvc->getProvider().getCollectionMetaData(m_cells.get()->getID()); - coll_md.setValue("CellIDEncodingString", m_hits.getCollMetadataCellID(hits->getID())); debug() << "Output Cell collection size: " << edmCellsCollection->size() << endmsg; diff --git a/RecCalorimeter/src/components/CreateCaloCells.h b/RecCalorimeter/src/components/CreateCaloCells.h index c772f042..116a0217 100644 --- a/RecCalorimeter/src/components/CreateCaloCells.h +++ b/RecCalorimeter/src/components/CreateCaloCells.h @@ -3,6 +3,7 @@ // FCCSW #include "k4FWCore/DataHandle.h" +#include "k4FWCore/MetaDataHandle.h" #include "k4Interface/ICalibrateCaloHitsTool.h" #include "k4Interface/ICalorimeterTool.h" #include "k4Interface/INoiseCaloCellsTool.h" @@ -75,8 +76,11 @@ class CreateCaloCells : public GaudiAlgorithm { /// Handle for calo hits (input collection) DataHandle m_hits{"hits", Gaudi::DataHandle::Reader, this}; + /// Handle for the cellID encoding string of the input collection + MetaDataHandle m_hitsCellIDEncoding{m_hits, "CellIDEncodingString", Gaudi::DataHandle::Reader}; /// Handle for calo cells (output collection) DataHandle m_cells{"cells", Gaudi::DataHandle::Writer, this}; + MetaDataHandle m_cellsCellIDEncoding{m_cells, "CellIDEncodingString", Gaudi::DataHandle::Writer}; /// Name of the detector readout Gaudi::Property m_readoutName{this, "readoutName", "ECalBarrelPhiEta", "Name of the detector readout"}; /// Name of active volumes @@ -105,8 +109,6 @@ class CreateCaloCells : public GaudiAlgorithm { /// Use only volume ID? If false, using PhiEtaSegmentation bool m_useVolumeIdOnly; - PodioDataSvc* m_podioDataSvc; - ServiceHandle m_eventDataSvc; /// Pointer to the geometry service ServiceHandle m_geoSvc; dd4hep::VolumeManager m_volman; diff --git a/RecFCCeeCalorimeter/src/components/CreateCaloCellPositionsFCCee.cpp b/RecFCCeeCalorimeter/src/components/CreateCaloCellPositionsFCCee.cpp index 99ff35fa..5609ab12 100644 --- a/RecFCCeeCalorimeter/src/components/CreateCaloCellPositionsFCCee.cpp +++ b/RecFCCeeCalorimeter/src/components/CreateCaloCellPositionsFCCee.cpp @@ -13,7 +13,7 @@ DECLARE_COMPONENT(CreateCaloCellPositionsFCCee) CreateCaloCellPositionsFCCee::CreateCaloCellPositionsFCCee(const std::string& name, ISvcLocator* svcLoc) - : GaudiAlgorithm(name, svcLoc), m_eventDataSvc("EventDataSvc", "CreateCaloCellPositionsFCCee") { + : GaudiAlgorithm(name, svcLoc) { declareProperty("hits", m_hits, "Hit collection (input)"); declareProperty("positionsECalBarrelTool", m_cellPositionsECalBarrelTool, "Handle for tool to retrieve cell positions in ECal Barrel"); @@ -31,12 +31,6 @@ CreateCaloCellPositionsFCCee::CreateCaloCellPositionsFCCee(const std::string& na StatusCode CreateCaloCellPositionsFCCee::initialize() { StatusCode sc = GaudiAlgorithm::initialize(); if (sc.isFailure()) return sc; - StatusCode sc_dataSvc = m_eventDataSvc.retrieve(); - m_podioDataSvc = dynamic_cast(m_eventDataSvc.get()); - if (sc_dataSvc == StatusCode::FAILURE) { - error() << "Error retrieving Event Data Service" << endmsg; - return sc_dataSvc; - } if (!m_cellPositionsECalBarrelTool) { error() << "CellPositionsTool for ECal Barrel is missing!" << endmsg; @@ -67,6 +61,9 @@ StatusCode CreateCaloCellPositionsFCCee::initialize() { return StatusCode::FAILURE; } + // Copy over the CellIDEncoding string from the input collection to the output collection + m_positionedHitsCellIDEncoding.put(m_hitsCellIDEncoding.get()); + return StatusCode::SUCCESS; } @@ -126,9 +123,6 @@ StatusCode CreateCaloCellPositionsFCCee::execute() { edmPositionedHitCollection->push_back(positionedHit); } - auto& coll_md = m_podioDataSvc->getProvider().getCollectionMetaData(m_positionedHits.get()->getID()); - coll_md.setValue("CellIDEncodingString", m_hits.getCollMetadataCellID(hits->getID())); - debug() << "Output positions collection size: " << edmPositionedHitCollection->size() << endmsg; return StatusCode::SUCCESS; } diff --git a/RecFCCeeCalorimeter/src/components/CreateCaloCellPositionsFCCee.h b/RecFCCeeCalorimeter/src/components/CreateCaloCellPositionsFCCee.h index a305d031..21e2996c 100644 --- a/RecFCCeeCalorimeter/src/components/CreateCaloCellPositionsFCCee.h +++ b/RecFCCeeCalorimeter/src/components/CreateCaloCellPositionsFCCee.h @@ -3,6 +3,7 @@ // FCCSW #include "k4FWCore/DataHandle.h" +#include "k4FWCore/MetaDataHandle.h" #include "k4Interface/ICellPositionsTool.h" // Gaudi @@ -91,10 +92,10 @@ class CreateCaloCellPositionsFCCee : public GaudiAlgorithm { dd4hep::DDSegmentation::BitFieldCoder* m_decoder = new dd4hep::DDSegmentation::BitFieldCoder("system:4"); /// Input collection DataHandle m_hits{"hits/hits", Gaudi::DataHandle::Reader, this}; + MetaDataHandle m_hitsCellIDEncoding{m_hits, "CellIDEncodingString", Gaudi::DataHandle::Reader}; /// Output collection DataHandle m_positionedHits{"hits/positionedHits", Gaudi::DataHandle::Writer, this}; - PodioDataSvc* m_podioDataSvc; - ServiceHandle m_eventDataSvc; + MetaDataHandle m_positionedHitsCellIDEncoding{m_positionedHits, "CellIDEncodingString", Gaudi::DataHandle::Reader}; int m_system_id = m_decoder->index("system"); std::unordered_map m_positions_cache{};