Skip to content

[WIP] Deprecate the PodioDataSvc and friends #318

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions k4FWCore/components/EventHeaderCreator.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class EventHeaderCreator : public Gaudi::Algorithm {
"Event number offset, eventNumber will be filled with 'event_index + eventNumberOffset'"};

// datahandle for the EventHeader
mutable DataHandle<edm4hep::EventHeaderCollection> m_headerCol{edm4hep::labels::EventHeader,
Gaudi::DataHandle::Writer, this};
mutable k4FWCore::DataHandle<edm4hep::EventHeaderCollection> m_headerCol{edm4hep::labels::EventHeader,
Gaudi::DataHandle::Writer, this};
};

#endif
2 changes: 1 addition & 1 deletion k4FWCore/components/FCCDataSvc.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "k4FWCore/PodioDataSvc.h"

/// an alias to k4DataSvc for backwards compatibility
class FCCDataSvc : public PodioDataSvc {
class [[deprecated("Use the IOSvc instead")]] FCCDataSvc : public PodioDataSvc {
public:
/// Standard Constructor
FCCDataSvc(const std::string& name, ISvcLocator* svc);
Expand Down
6 changes: 6 additions & 0 deletions k4FWCore/components/PodioInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ PodioInput::PodioInput(const std::string& name, ISvcLocator* svcLoc) : Consumer(
}

StatusCode PodioInput::initialize() {
warning() << "PodioInput is deprecated and will be removed. Use the IOSvc instead" << endmsg;
// If someone uses the collections property from the command line and passes
// an empty string we assume they want all collections (as a simple way to
// override whatever is in the options file)
Expand All @@ -173,6 +174,11 @@ StatusCode PodioInput::initialize() {
return StatusCode::SUCCESS;
}

StatusCode PodioInput::finalize() {
warning() << "PodioInput is deprecated and will be removed. Use the IOSvc instead" << endmsg;
return StatusCode::SUCCESS;
}

void PodioInput::operator()() const {
if (m_podioDataSvc->getEventFrame().get(edm4hep::labels::EventHeader)) {
m_readers[edm4hep::EventHeaderCollection::typeName](edm4hep::labels::EventHeader);
Expand Down
4 changes: 3 additions & 1 deletion k4FWCore/components/PodioInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ class PodioDataSvc;

using BaseClass_t = Gaudi::Functional::Traits::BaseClass_t<Gaudi::Algorithm>;

class PodioInput final : public Gaudi::Functional::Consumer<void(), BaseClass_t> {
class [[deprecated("Use the IOSvc instead")]] PodioInput final
: public Gaudi::Functional::Consumer<void(), BaseClass_t> {
public:
PodioInput(const std::string& name, ISvcLocator* svcLoc);
void operator()() const override;

StatusCode initialize() final;
StatusCode finalize() final;

private:
template <typename T>
Expand Down
3 changes: 3 additions & 0 deletions k4FWCore/components/PodioOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ PodioOutput::PodioOutput(const std::string& name, ISvcLocator* svcLoc)
: Gaudi::Algorithm(name, svcLoc), m_firstEvent(true) {}

StatusCode PodioOutput::initialize() {
warning() << "PodioOutput is deprecated and will be removed. Use the IOSvc instead" << endmsg;
if (Gaudi::Algorithm::initialize().isFailure())
return StatusCode::FAILURE;

Expand Down Expand Up @@ -106,6 +107,8 @@ StatusCode PodioOutput::execute(const EventContext&) const {
*
*/
StatusCode PodioOutput::finalize() {
warning() << "PodioOutput is deprecated and will be removed. Use the IOSvc instead" << endmsg;

if (Gaudi::Algorithm::finalize().isFailure())
return StatusCode::FAILURE;
//// prepare job options metadata ///////////////////////
Expand Down
2 changes: 1 addition & 1 deletion k4FWCore/components/PodioOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
// forward declarations
class PodioDataSvc;

class PodioOutput : public Gaudi::Algorithm {
class [[deprecated("Use the IOSvc instead")]] PodioOutput : public Gaudi::Algorithm {
public:
/// Constructor.
PodioOutput(const std::string& name, ISvcLocator* svcLoc);
Expand Down
2 changes: 1 addition & 1 deletion k4FWCore/components/k4DataSvc.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "k4FWCore/PodioDataSvc.h"

class k4DataSvc : public PodioDataSvc {
class [[deprecated("Use the IOSvc instead")]] k4DataSvc : public PodioDataSvc {
public:
/// Standard Constructor
k4DataSvc(const std::string& name, ISvcLocator* svc);
Expand Down
9 changes: 7 additions & 2 deletions k4FWCore/include/k4FWCore/DataHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <string>
#include <type_traits>

namespace k4FWCore {
/**
* Specialisation of the Gaudi DataHandle
* for use with podio collections.
Expand Down Expand Up @@ -155,13 +156,17 @@ T* DataHandle<T>::createAndPut() {
this->put(objectp);
return objectp;
}
} // namespace k4FWCore

template <typename T>
using DataHandle [[deprecated("Use k4FWCore::DataHandle instead")]] = k4FWCore::DataHandle<T>;

// temporary to allow property declaration
namespace Gaudi {
template <class T>
class Property<::DataHandle<T>&> : public ::DataHandleProperty {
class Property<k4FWCore::DataHandle<T>&> : public ::DataHandleProperty {
public:
Property(const std::string& name, ::DataHandle<T>& value) : ::DataHandleProperty(name, value) {}
Property(const std::string& name, k4FWCore::DataHandle<T>& value) : ::DataHandleProperty(name, value) {}
};
} // namespace Gaudi

Expand Down
4 changes: 3 additions & 1 deletion k4FWCore/include/k4FWCore/DataWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
#include "podio/CollectionBase.h"

// forward declaration
namespace k4FWCore {
template <typename T>
class DataHandle;
}

class GAUDI_API DataWrapperBase : public DataObject {
public:
Expand All @@ -40,7 +42,7 @@ template <class T>
class GAUDI_API DataWrapper : public DataWrapperBase {
public:
template <class T2>
friend class DataHandle;
friend class k4FWCore::DataHandle;

public:
DataWrapper() : m_data(nullptr) {}
Expand Down
6 changes: 6 additions & 0 deletions k4FWCore/include/k4FWCore/MetaDataHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "k4FWCore/MetadataUtils.h"
#include "k4FWCore/PodioDataSvc.h"

namespace k4FWCore {

template <typename T>
class MetaDataHandle {
public:
Expand Down Expand Up @@ -164,5 +166,9 @@ void MetaDataHandle<T>::checkPodioDataSvc() {
std::cout << "Warning: MetaDataHandles require the PodioDataSvc or for compatibility the MetadataSvc" << std::endl;
}
}
} // namespace k4FWCore

template <typename T>
using MetaDataHandle [[deprecated("Use k4FWCore::MetaDataHandle instead")]] = k4FWCore::MetaDataHandle<T>;

#endif
6 changes: 4 additions & 2 deletions k4FWCore/include/k4FWCore/PodioDataSvc.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,20 @@
#include "k4FWCore/DataWrapper.h"
class DataWrapperBase;
class PodioOutput;
namespace k4FWCore {
template <typename T>
class MetaDataHandle;
}

/** @class PodioEvtSvc EvtDataSvc.h
*
* An EvtDataSvc for PODIO classes
*
* @author B. Hegner
*/
class PodioDataSvc : public DataSvc {
class [[deprecated("Use the IOSvc instead")]] PodioDataSvc : public DataSvc {
template <typename T>
friend class MetaDataHandle;
friend class k4FWCore::MetaDataHandle;
friend class PodioOutput;
friend class Lcio2EDM4hepTool;

Expand Down
2 changes: 2 additions & 0 deletions k4FWCore/src/PodioDataSvc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

/// Service initialisation
StatusCode PodioDataSvc::initialize() {
warning() << "The PodioDataSvc is deprecated and will be removed. Use the IOSvc instead" << endmsg;
// Nothing to do: just call base class initialisation
StatusCode status = DataSvc::initialize();
ISvcLocator* svc_loc = serviceLocator();
Expand Down Expand Up @@ -84,6 +85,7 @@ StatusCode PodioDataSvc::reinitialize() {
}
/// Service finalization
StatusCode PodioDataSvc::finalize() {
warning() << "The PodioDataSvc is deprecated and will be removed. Use the IOSvc instead" << endmsg;
m_cnvSvc = nullptr; // release
DataSvc::finalize().ignore();
return StatusCode::SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,14 @@ class k4FWCoreTest_AlgorithmWithTFile : public Gaudi::Algorithm {
Gaudi::Property<int> m_magicNumberOffset{this, "magicNumberOffset", 0,
"Integer to add to the dummy values written to the edm"};
/// Handle for the genparticles to be written
mutable DataHandle<edm4hep::MCParticleCollection> m_mcParticleHandle{"MCParticles", Gaudi::DataHandle::Writer, this};
mutable k4FWCore::DataHandle<edm4hep::MCParticleCollection> m_mcParticleHandle{"MCParticles",
Gaudi::DataHandle::Writer, this};
/// Handle for the genvertices to be written
mutable DataHandle<edm4hep::SimTrackerHitCollection> m_simTrackerHitHandle{"SimTrackerHit", Gaudi::DataHandle::Writer,
this};
mutable k4FWCore::DataHandle<edm4hep::SimTrackerHitCollection> m_simTrackerHitHandle{"SimTrackerHit",
Gaudi::DataHandle::Writer, this};

mutable DataHandle<podio::UserDataCollection<float>> m_vectorFloatHandle{"VectorFloat", Gaudi::DataHandle::Writer,
this};
mutable k4FWCore::DataHandle<podio::UserDataCollection<float>> m_vectorFloatHandle{"VectorFloat",
Gaudi::DataHandle::Writer, this};

/// for testing: write a second TFile by user in an algorithm
mutable Float_t m_value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ class k4FWCoreTest_CheckExampleEventData : public Gaudi::Algorithm {
Gaudi::Property<bool> m_keepEventNumberZero{this, "keepEventNumberZero", false,
"Don't add the event number to the dummy values written"};
/// Handle for the MCParticles to be written
mutable DataHandle<edm4hep::MCParticleCollection> m_mcParticleHandle{"MCParticles", Gaudi::DataHandle::Reader, this};
mutable DataHandle<podio::UserDataCollection<float>> m_vectorFloatHandle{"VectorFloat", Gaudi::DataHandle::Reader,
this};
mutable k4FWCore::DataHandle<edm4hep::MCParticleCollection> m_mcParticleHandle{"MCParticles",
Gaudi::DataHandle::Reader, this};
mutable k4FWCore::DataHandle<podio::UserDataCollection<float>> m_vectorFloatHandle{"VectorFloat",
Gaudi::DataHandle::Reader, this};

mutable int m_event{0};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,21 @@ class k4FWCoreTest_CreateExampleEventData : public Gaudi::Algorithm {
/// integer to add to the dummy values written to the edm
Gaudi::Property<int> m_magicNumberOffset{this, "magicNumberOffset", 0,
"Integer to add to the dummy values written to the edm"};
mutable DataHandle<edm4hep::MCParticleCollection> m_mcParticleHandle{"MCParticles", Gaudi::DataHandle::Writer, this};
mutable DataHandle<edm4hep::SimTrackerHitCollection> m_simTrackerHitHandle{"SimTrackerHits",
Gaudi::DataHandle::Writer, this};
mutable DataHandle<edm4hep::TrackerHit3DCollection> m_TrackerHitHandle{"TrackerHits", Gaudi::DataHandle::Writer,
this};
mutable k4FWCore::DataHandle<edm4hep::MCParticleCollection> m_mcParticleHandle{"MCParticles",
Gaudi::DataHandle::Writer, this};
mutable k4FWCore::DataHandle<edm4hep::SimTrackerHitCollection> m_simTrackerHitHandle{"SimTrackerHits",
Gaudi::DataHandle::Writer, this};
mutable k4FWCore::DataHandle<edm4hep::TrackerHit3DCollection> m_TrackerHitHandle{"TrackerHits",
Gaudi::DataHandle::Writer, this};

mutable DataHandle<edm4hep::TrackCollection> m_trackHandle{"Tracks", Gaudi::DataHandle::Writer, this};
mutable k4FWCore::DataHandle<edm4hep::TrackCollection> m_trackHandle{"Tracks", Gaudi::DataHandle::Writer, this};

mutable DataHandle<podio::UserDataCollection<float>> m_vectorFloatHandle{"VectorFloat", Gaudi::DataHandle::Writer,
this};
mutable DataHandle<edm4hep::ReconstructedParticleCollection> m_recoHandle{"RecoParticles", Gaudi::DataHandle::Writer,
this};
mutable DataHandle<edm4hep::RecoMCParticleLinkCollection> m_linkHandle{"Links", Gaudi::DataHandle::Writer, this};
mutable k4FWCore::DataHandle<podio::UserDataCollection<float>> m_vectorFloatHandle{"VectorFloat",
Gaudi::DataHandle::Writer, this};
mutable k4FWCore::DataHandle<edm4hep::ReconstructedParticleCollection> m_recoHandle{"RecoParticles",
Gaudi::DataHandle::Writer, this};
mutable k4FWCore::DataHandle<edm4hep::RecoMCParticleLinkCollection> m_linkHandle{"Links", Gaudi::DataHandle::Writer,
this};

mutable int m_event{0};
};
Expand Down
8 changes: 4 additions & 4 deletions test/k4FWCoreTest/src/components/k4FWCoreTest_cellID_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class k4FWCoreTest_cellID_reader : public Gaudi::Algorithm {

private:
/// Handle for the SimTrackerHits to be read
mutable DataHandle<edm4hep::SimTrackerHitCollection> m_simTrackerHitReaderHandle{"SimTrackerHits",
Gaudi::DataHandle::Reader, this};
mutable MetaDataHandle<std::string> m_cellIDHandle{m_simTrackerHitReaderHandle, edm4hep::labels::CellIDEncoding,
Gaudi::DataHandle::Reader};
mutable k4FWCore::DataHandle<edm4hep::SimTrackerHitCollection> m_simTrackerHitReaderHandle{
"SimTrackerHits", Gaudi::DataHandle::Reader, this};
mutable k4FWCore::MetaDataHandle<std::string> m_cellIDHandle{
m_simTrackerHitReaderHandle, edm4hep::labels::CellIDEncoding, Gaudi::DataHandle::Reader};
};
#endif /* K4FWCORE_K4FWCORETEST_CELLID */
8 changes: 4 additions & 4 deletions test/k4FWCoreTest/src/components/k4FWCoreTest_cellID_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ class k4FWCoreTest_cellID_writer : public Gaudi::Algorithm {

private:
/// Handle for the SimTrackerHits to be written
mutable DataHandle<edm4hep::SimTrackerHitCollection> m_simTrackerHitWriterHandle{"SimTrackerHits",
Gaudi::DataHandle::Writer, this};
MetaDataHandle<std::string> m_cellIDHandle{m_simTrackerHitWriterHandle, edm4hep::labels::CellIDEncoding,
Gaudi::DataHandle::Writer};
mutable k4FWCore::DataHandle<edm4hep::SimTrackerHitCollection> m_simTrackerHitWriterHandle{
"SimTrackerHits", Gaudi::DataHandle::Writer, this};
k4FWCore::MetaDataHandle<std::string> m_cellIDHandle{m_simTrackerHitWriterHandle, edm4hep::labels::CellIDEncoding,
Gaudi::DataHandle::Writer};

// Some properties for the configuration metadata
Gaudi::Property<int> m_intProp{this, "intProp", 42, "An integer property"};
Expand Down
Loading