Skip to content

Commit

Permalink
Make it possible to transparently migrate to TrackerHit interface (ke…
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener authored Feb 22, 2024
1 parent 63822df commit e392581
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 14 deletions.
12 changes: 11 additions & 1 deletion k4FWCore/components/PodioInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@
#include "edm4hep/SimTrackerHitCollection.h"
#include "edm4hep/TimeSeriesCollection.h"
#include "edm4hep/TrackCollection.h"
#if __has_include("edm4hep/TrackerHit3DCollection.h")
#include "edm4hep/TrackerHit3DCollection.h"
#else
#include "edm4hep/TrackerHitCollection.h"
namespace edm4hep {
using TrackerHit3DCollection = edm4hep::TrackerHitCollection;
} // namespace edm4hep
#endif
#include "edm4hep/TrackerHitPlaneCollection.h"
#include "edm4hep/TrackerPulseCollection.h"
#include "edm4hep/VertexCollection.h"
Expand Down Expand Up @@ -85,8 +92,11 @@ void PodioInput::fillReaders() {
m_readers["edm4hep::ClusterCollection"] = [&](std::string_view collName) {
maybeRead<edm4hep::ClusterCollection>(collName);
};
m_readers["edm4hep::TrackerHit3DCollection"] = [&](std::string_view collName) {
maybeRead<edm4hep::TrackerHit3DCollection>(collName);
};
m_readers["edm4hep::TrackerHitCollection"] = [&](std::string_view collName) {
maybeRead<edm4hep::TrackerHitCollection>(collName);
maybeRead<edm4hep::TrackerHit3DCollection>(collName);
};
m_readers["edm4hep::TrackerHitPlaneCollection"] = [&](std::string_view collName) {
maybeRead<edm4hep::TrackerHitPlaneCollection>(collName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@
#include "edm4hep/MCParticleCollection.h"
#include "edm4hep/SimTrackerHitCollection.h"
#include "edm4hep/TrackCollection.h"
#if __has_include("edm4hep/TrackerHit3DCollection.h")
#include "edm4hep/TrackerHit3DCollection.h"
#else
#include "edm4hep/TrackerHitCollection.h"
namespace edm4hep {
using TrackerHit3DCollection = edm4hep::TrackerHitCollection;
} // namespace edm4hep
#endif
#include "podio/UserDataCollection.h"

// Define BaseClass_t
Expand All @@ -37,7 +44,7 @@
using FloatColl = podio::UserDataCollection<float>;
using ParticleColl = edm4hep::MCParticleCollection;
using SimTrackerHitColl = edm4hep::SimTrackerHitCollection;
using TrackerHitColl = edm4hep::TrackerHitCollection;
using TrackerHitColl = edm4hep::TrackerHit3DCollection;
using TrackColl = edm4hep::TrackCollection;

struct ExampleFunctionalConsumerMultiple final
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@
#include "edm4hep/MCParticleCollection.h"
#include "edm4hep/SimTrackerHitCollection.h"
#include "edm4hep/TrackCollection.h"
#if __has_include("edm4hep/TrackerHit3DCollection.h")
#include "edm4hep/TrackerHit3DCollection.h"
#else
#include "edm4hep/TrackerHitCollection.h"
namespace edm4hep {
using TrackerHit3DCollection = edm4hep::TrackerHitCollection;
} // namespace edm4hep
#endif
#include "podio/UserDataCollection.h"

#include <string>
Expand All @@ -33,7 +40,7 @@
using Float = podio::UserDataCollection<float>;
using Particle = edm4hep::MCParticleCollection;
using SimTrackerHit = edm4hep::SimTrackerHitCollection;
using TrackerHit = edm4hep::TrackerHitCollection;
using TrackerHit = edm4hep::TrackerHit3DCollection;
using Track = edm4hep::TrackCollection;

struct ExampleFunctionalProducerMultiple final
Expand Down Expand Up @@ -71,7 +78,7 @@ struct ExampleFunctionalProducerMultiple final
auto hit = simTrackerHits.create();
hit.setPosition({3, 4, 5});

auto trackerHits = edm4hep::TrackerHitCollection();
auto trackerHits = edm4hep::TrackerHit3DCollection();
auto trackerHit = trackerHits.create();
trackerHit.setPosition({3, 4, 5});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@
#include "edm4hep/MCParticleCollection.h"
#include "edm4hep/SimTrackerHitCollection.h"
#include "edm4hep/TrackCollection.h"
#if __has_include("edm4hep/TrackerHit3DCollection.h")
#include "edm4hep/TrackerHit3DCollection.h"
#else
#include "edm4hep/TrackerHitCollection.h"
namespace edm4hep {
using TrackerHit3DCollection = edm4hep::TrackerHitCollection;
} // namespace edm4hep
#endif
#include "edm4hep/TrackerHit3DCollection.h"
#include "podio/UserDataCollection.h"

// Define BaseClass_t
Expand All @@ -35,7 +43,7 @@
using FloatColl = podio::UserDataCollection<float>;
using ParticleColl = edm4hep::MCParticleCollection;
using SimTrackerHitColl = edm4hep::SimTrackerHitCollection;
using TrackerHitColl = edm4hep::TrackerHitCollection;
using TrackerHitColl = edm4hep::TrackerHit3DCollection;
using TrackColl = edm4hep::TrackCollection;

// As a simple example, we'll write an integer and a collection of MCParticles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@
#include "edm4hep/MCParticleCollection.h"
#include "edm4hep/SimTrackerHitCollection.h"
#include "edm4hep/TrackCollection.h"
#if __has_include("edm4hep/TrackerHit3DCollection.h")
#include "edm4hep/TrackerHit3DCollection.h"
#else
#include "edm4hep/TrackerHitCollection.h"
namespace edm4hep {
using TrackerHit3DCollection = edm4hep::TrackerHitCollection;
} // namespace edm4hep
#endif
#include "edm4hep/TrackerHitPlaneCollection.h"

DECLARE_COMPONENT(k4FWCoreTest_CheckExampleEventData)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@
// datamodel
namespace edm4hep {
class MCParticleCollection;
class SimTrackerHitCollection;
class TrackerHitCollection;
class SimCaloHitCollection;
class TrackCollection;
} // namespace edm4hep

class k4FWCoreTest_CheckExampleEventData : public GaudiAlgorithm {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "edm4hep/MCParticleCollection.h"
#include "edm4hep/SimTrackerHitCollection.h"
#include "edm4hep/TrackCollection.h"
#include "edm4hep/TrackerHitCollection.h"
#if __has_include("edm4hep/EDM4hepVersion.h")
#include "edm4hep/EDM4hepVersion.h"
#else
Expand Down Expand Up @@ -74,8 +73,8 @@ StatusCode k4FWCoreTest_CreateExampleEventData::execute() {
auto hit = simTrackerHits->create();
hit.setPosition({3, 4, 5});

edm4hep::TrackerHitCollection* trackerHits = m_TrackerHitHandle.createAndPut();
auto trackerHit = trackerHits->create();
edm4hep::TrackerHit3DCollection* trackerHits = m_TrackerHitHandle.createAndPut();
auto trackerHit = trackerHits->create();
trackerHit.setPosition({3, 4, 5});

edm4hep::TrackCollection* tracks = m_trackHandle.createAndPut();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,23 @@
// key4hep
#include "k4FWCore/DataHandle.h"

// edm4hep
#if __has_include("edm4hep/TrackerHit3DCollection.h")
#include "edm4hep/TrackerHit3DCollection.h"
#else
#include "edm4hep/TrackerHitCollection.h"
namespace edm4hep {
using TrackerHit3DCollection = edm4hep::TrackerHitCollection;
} // namespace edm4hep
#endif

// podio
#include "podio/UserDataCollection.h"

// datamodel
namespace edm4hep {
class MCParticleCollection;
class SimTrackerHitCollection;
class TrackerHitCollection;
class SimCaloHitCollection;
class TrackCollection;
} // namespace edm4hep
Expand Down Expand Up @@ -69,7 +78,7 @@ class k4FWCoreTest_CreateExampleEventData : public GaudiAlgorithm {
DataHandle<edm4hep::MCParticleCollection> m_mcParticleHandle{"MCParticles", Gaudi::DataHandle::Writer, this};
/// Handle for the SimTrackerHits to be written
DataHandle<edm4hep::SimTrackerHitCollection> m_simTrackerHitHandle{"SimTrackerHits", Gaudi::DataHandle::Writer, this};
DataHandle<edm4hep::TrackerHitCollection> m_TrackerHitHandle{"TrackerHits", Gaudi::DataHandle::Writer, this};
DataHandle<edm4hep::TrackerHit3DCollection> m_TrackerHitHandle{"TrackerHits", Gaudi::DataHandle::Writer, this};

/// Handle for the Tracks to be written
DataHandle<edm4hep::TrackCollection> m_trackHandle{"Tracks", Gaudi::DataHandle::Writer, this};
Expand Down

0 comments on commit e392581

Please sign in to comment.