Skip to content

Commit

Permalink
Replace deprecated PodioDataSvc with k4DataSvc
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed May 23, 2024
1 parent 8e447dd commit 3ec3897
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions k4FWCore/components/PodioInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "PodioInput.h"
#include "Gaudi/Functional/Consumer.h"

#include "k4FWCore/PodioDataSvc.h"
#include "k4FWCore/k4DataSvc.h"

#include "edm4hep/CaloHitContributionCollection.h"
#include "edm4hep/CalorimeterHitCollection.h"
Expand Down Expand Up @@ -194,9 +194,9 @@ PodioInput::PodioInput(const std::string& name, ISvcLocator* svcLoc) : Consumer(
return;

// check whether we have the PodioEvtSvc active
m_podioDataSvc = dynamic_cast<PodioDataSvc*>(evtSvc().get());
m_podioDataSvc = dynamic_cast<k4DataSvc*>(evtSvc().get());
if (!m_podioDataSvc) {
error() << "Could not get PodioDataSvc" << endmsg;
error() << "Could not get k4DataSvc" << endmsg;
}
fillReaders();
}
Expand Down
4 changes: 2 additions & 2 deletions k4FWCore/components/PodioOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "GaudiKernel/MsgStream.h"

#include "PodioOutput.h"
#include "k4FWCore/PodioDataSvc.h"
#include "k4FWCore/k4DataSvc.h"
#include "rootUtils.h"

DECLARE_COMPONENT(PodioOutput)
Expand All @@ -36,7 +36,7 @@ StatusCode PodioOutput::initialize() {
return StatusCode::FAILURE;

// check whether we have the PodioEvtSvc active
m_podioDataSvc = dynamic_cast<PodioDataSvc*>(evtSvc().get());
m_podioDataSvc = dynamic_cast<k4DataSvc*>(evtSvc().get());
if (nullptr == m_podioDataSvc) {
error() << "Could not get DataSvc!" << endmsg;
return StatusCode::FAILURE;
Expand Down
2 changes: 1 addition & 1 deletion k4FWCore/components/PodioOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class PodioOutput : public Gaudi::Algorithm {

/// Initialization of PodioOutput. Acquires the data service, creates trees and root file.
StatusCode initialize();
/// Execute. For the first event creates branches for all collections known to PodioDataSvc and prepares them for
/// Execute. For the first event creates branches for all collections known to k4DataSvc and prepares them for
/// writing. For the following events it reconnects the branches with collections and prepares them for write.
StatusCode execute(const EventContext&) const;
/// Finalize. Writes the meta data tree; writes file and cleans up all ROOT-pointers.
Expand Down
4 changes: 2 additions & 2 deletions k4FWCore/include/k4FWCore/DataHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define K4FWCORE_DATAHANDLE_H

#include "k4FWCore/DataWrapper.h"
#include "k4FWCore/PodioDataSvc.h"
#include "k4FWCore/k4DataSvc.h"

#include "Gaudi/Algorithm.h"
#include "GaudiKernel/DataObjectHandle.h"
Expand Down Expand Up @@ -93,7 +93,7 @@ DataHandle<T>::DataHandle(const std::string& descriptor, Gaudi::DataHandle::Mode
if (a == Gaudi::DataHandle::Writer) {
m_eds.retrieve().ignore();
m_dataPtr = nullptr;
auto* podio_data_service = dynamic_cast<PodioDataSvc*>(m_eds.get());
auto* podio_data_service = dynamic_cast<k4DataSvc*>(m_eds.get());
if (nullptr != podio_data_service) {
if constexpr (std::is_integral_v<T> || std::is_floating_point_v<T>) {
m_dataPtr = new T();
Expand Down
18 changes: 9 additions & 9 deletions k4FWCore/include/k4FWCore/MetaDataHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// GAUDI
#include "Gaudi/Algorithm.h"

#include "k4FWCore/PodioDataSvc.h"
#include "k4FWCore/k4DataSvc.h"
#include "podio/GenericParameters.h"

#include "GaudiKernel/MsgStream.h"
Expand All @@ -41,12 +41,12 @@ template <typename T> class MetaDataHandle {

private:
std::string fullDescriptor() const;
void checkPodioDataSvc();
void checkk4DataSvc();

private:
ServiceHandle<IDataProviderSvc> m_eds;
std::string m_descriptor;
PodioDataSvc* m_podio_data_service{nullptr};
k4DataSvc* m_podio_data_service{nullptr};
const Gaudi::DataHandle* m_dataHandle{nullptr}; // holds the identifier in case we do collection metadata
Gaudi::DataHandle::Mode m_mode;
};
Expand All @@ -58,8 +58,8 @@ template <typename T>
MetaDataHandle<T>::MetaDataHandle(const std::string& descriptor, Gaudi::DataHandle::Mode a)
: m_eds("EventDataSvc", "DataHandle"), m_descriptor(descriptor), m_mode(a) {
m_eds.retrieve().ignore();
m_podio_data_service = dynamic_cast<PodioDataSvc*>(m_eds.get());
checkPodioDataSvc();
m_podio_data_service = dynamic_cast<k4DataSvc*>(m_eds.get());
checkk4DataSvc();
}

//---------------------------------------------------------------------------
Expand All @@ -68,8 +68,8 @@ MetaDataHandle<T>::MetaDataHandle(const Gaudi::DataHandle& handle, const std::st
Gaudi::DataHandle::Mode a)
: m_eds("EventDataSvc", "DataHandle"), m_descriptor(descriptor), m_dataHandle(&handle), m_mode(a) {
m_eds.retrieve().ignore();
m_podio_data_service = dynamic_cast<PodioDataSvc*>(m_eds.get());
checkPodioDataSvc();
m_podio_data_service = dynamic_cast<k4DataSvc*>(m_eds.get());
checkk4DataSvc();
}

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -109,14 +109,14 @@ template <typename T> std::string MetaDataHandle<T>::fullDescriptor() const {
}

//---------------------------------------------------------------------------
template <typename T> void MetaDataHandle<T>::checkPodioDataSvc() {
template <typename T> void MetaDataHandle<T>::checkk4DataSvc() {
// do not do this check during the genconf step
const std::string cmd = System::cmdLineArgs()[0];
if (cmd.find("genconf") != std::string::npos)
return;

if (nullptr == m_podio_data_service) {
std::cout << "ERROR: MetaDataHandles require the PodioDataSvc" << std::endl;
std::cout << "ERROR: MetaDataHandles require the k4DataSvc" << std::endl;
}
}

Expand Down

0 comments on commit 3ec3897

Please sign in to comment.