Skip to content

Commit

Permalink
add get CellID String from DataHandle
Browse files Browse the repository at this point in the history
  • Loading branch information
fdplacido authored and vvolkl committed Jul 16, 2021
1 parent 1810394 commit 67e5d94
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions k4FWCore/include/k4FWCore/DataHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class DataHandle : public DataObjectHandle<DataWrapper<T>> {

T* put( std::unique_ptr<T> object );

///Retrieve CellID string from the Collection metadata
const std::string getCollMetadataCellID(const unsigned int id);

/**
* Create and register object in transient store
*/
Expand Down Expand Up @@ -170,13 +173,36 @@ void DataHandle<T>::put(T* objectp) {

}


//---------------------------------------------------------------------------
template <typename T>
T* DataHandle<T>::put( std::unique_ptr<T> objectp ){
put(objectp.get());
return objectp.release();
}


//---------------------------------------------------------------------------
// Get the CellID encoded String from the Metadata of the collection
// using Podio Data Service
// Give collection ID
template <typename T>
const std::string DataHandle<T>::getCollMetadataCellID(
const unsigned int id)
{
PodioDataSvc* pds;
pds = dynamic_cast<PodioDataSvc*>( 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
Expand Down
1 change: 1 addition & 0 deletions k4FWCore/include/k4FWCore/PodioDataSvc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 67e5d94

Please sign in to comment.