From 67e5d9452a49f4dee2c3010d0f74f925e4a11b6d Mon Sep 17 00:00:00 2001 From: Placido Fernandez Declara Date: Tue, 13 Jul 2021 20:05:46 +0200 Subject: [PATCH] add get CellID String from DataHandle --- k4FWCore/include/k4FWCore/DataHandle.h | 26 ++++++++++++++++++++++++ k4FWCore/include/k4FWCore/PodioDataSvc.h | 1 + 2 files changed, 27 insertions(+) diff --git a/k4FWCore/include/k4FWCore/DataHandle.h b/k4FWCore/include/k4FWCore/DataHandle.h index 8f8e9af2..563d5eae 100644 --- a/k4FWCore/include/k4FWCore/DataHandle.h +++ b/k4FWCore/include/k4FWCore/DataHandle.h @@ -41,6 +41,9 @@ class DataHandle : public DataObjectHandle> { T* put( std::unique_ptr object ); + ///Retrieve CellID string from the Collection metadata + const std::string getCollMetadataCellID(const unsigned int id); + /** * Create and register object in transient store */ @@ -170,6 +173,7 @@ void DataHandle::put(T* objectp) { } + //--------------------------------------------------------------------------- template T* DataHandle::put( std::unique_ptr objectp ){ @@ -177,6 +181,28 @@ T* DataHandle::put( std::unique_ptr objectp ){ return objectp.release(); } + +//--------------------------------------------------------------------------- +// Get the CellID encoded String from the Metadata of the collection +// using Podio Data Service +// Give collection ID +template +const std::string DataHandle::getCollMetadataCellID( + const unsigned int id) +{ + PodioDataSvc* pds; + pds = dynamic_cast( m_eds.get()); + + if (pds != nullptr) { + auto colMD = pds->getProvider().getCollectionMetaData( id ); + return colMD.getStringVal("CellIDEncodingString") ; + } else { + std::string msg("Could not get Podio Data Service."); + throw GaudiException(msg, "Failed to get Collection Metadata.", StatusCode::FAILURE); + } +} + + //--------------------------------------------------------------------------- /** * Create the collection, put it in the DataObjectHandle and return the diff --git a/k4FWCore/include/k4FWCore/PodioDataSvc.h b/k4FWCore/include/k4FWCore/PodioDataSvc.h index 7132d803..a26d33f8 100644 --- a/k4FWCore/include/k4FWCore/PodioDataSvc.h +++ b/k4FWCore/include/k4FWCore/PodioDataSvc.h @@ -43,6 +43,7 @@ class PodioDataSvc : public DataSvc { virtual const CollRegistry& getCollections() const { return m_collections; } virtual const CollRegistry& getReadCollections() const { return m_readCollections; } + const podio::EventStore& getProvider() const { return m_provider; } virtual podio::CollectionIDTable* getCollectionIDs() { return m_collectionIDs; } /// Set the collection IDs (if reading a file)