diff --git a/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.h b/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.h index 845282c9..e30bb095 100644 --- a/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.h +++ b/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.h @@ -22,7 +22,15 @@ #include #include #include -#include +#if __has_include("edm4hep/TrackerHit3DCollection.h") +#include "edm4hep/TrackerHit3DCollection.h" +#else +#include "edm4hep/TrackerHitCollection.h" +namespace edm4hep { + using TrackerHit3DCollection = edm4hep::TrackerHitCollection; + using TrackerHit3D = edm4hep::TrackerHit; +} // namespace edm4hep +#endif #include #include @@ -66,7 +74,7 @@ namespace EDM4hep2LCIOConv { struct CollectionsPairVectors { ObjectMapT tracks {}; - ObjectMapT trackerHits {}; + ObjectMapT trackerHits {}; ObjectMapT trackerHitPlanes {}; ObjectMapT simTrackerHits {}; ObjectMapT caloHits {}; @@ -87,7 +95,7 @@ namespace EDM4hep2LCIOConv { template lcio::LCCollectionVec* convTrackerHits( - const edm4hep::TrackerHitCollection* const trackerhits_coll, + const edm4hep::TrackerHit3DCollection* const trackerhits_coll, const std::string& cellIDstr, TrackerHitMapT& trackerhits_vec); diff --git a/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.ipp b/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.ipp index 20abcf5b..065eb1ff 100644 --- a/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.ipp +++ b/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.ipp @@ -101,7 +101,7 @@ namespace EDM4hep2LCIOConv { // Add LCIO Collection Vector to LCIO event template lcio::LCCollectionVec* convTrackerHits( - const edm4hep::TrackerHitCollection* const trackerhits_coll, + const edm4hep::TrackerHit3DCollection* const trackerhits_coll, const std::string& cellIDstr, TrackerHitMapT& trackerhits_vec) { diff --git a/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4Lcio2EDM4hepConv.h b/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4Lcio2EDM4hepConv.h index e3acdcee..2b92617c 100644 --- a/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4Lcio2EDM4hepConv.h +++ b/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4Lcio2EDM4hepConv.h @@ -24,7 +24,15 @@ #include "edm4hep/SimTrackerHitCollection.h" #include "edm4hep/RawTimeSeriesCollection.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; + using MutableTrackerHit3D = edm4hep::TrackerHit; +} // namespace edm4hep +#endif #include "edm4hep/TrackerHitPlaneCollection.h" #include "edm4hep/VertexCollection.h" @@ -71,7 +79,7 @@ namespace LCIO2EDM4hepConv { */ struct LcioEdmTypeMapping { ObjectMapT tracks {}; - ObjectMapT trackerHits {}; + ObjectMapT trackerHits {}; ObjectMapT simTrackerHits {}; ObjectMapT caloHits {}; ObjectMapT rawCaloHits {}; @@ -232,7 +240,7 @@ namespace LCIO2EDM4hepConv { * Simultaneously populates the mapping from LCIO to EDM4hep objects. */ template - std::unique_ptr + std::unique_ptr convertTrackerHits(const std::string& name, EVENT::LCCollection* LCCollection, HitMapT& TrackerHitMap); /** diff --git a/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4Lcio2EDM4hepConv.ipp b/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4Lcio2EDM4hepConv.ipp index 1b7cd9fa..06807256 100644 --- a/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4Lcio2EDM4hepConv.ipp +++ b/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4Lcio2EDM4hepConv.ipp @@ -277,10 +277,10 @@ namespace LCIO2EDM4hepConv { } template - std::unique_ptr + std::unique_ptr convertTrackerHits(const std::string& name, EVENT::LCCollection* LCCollection, HitMapT& TrackerHitMap) { - auto dest = std::make_unique(); + auto dest = std::make_unique(); for (unsigned i = 0, N = LCCollection->getNumberOfElements(); i < N; ++i) { auto* rval = static_cast(LCCollection->getElementAt(i)); auto lval = dest->create(); @@ -1067,7 +1067,7 @@ namespace LCIO2EDM4hepConv { return handleSubsetColl(LCCollection, typeMapping.tpcHits); } else if (type == "TrackerHit") { - return handleSubsetColl(LCCollection, typeMapping.trackerHits); + return handleSubsetColl(LCCollection, typeMapping.trackerHits); } else if (type == "TrackerHitPlane") { return handleSubsetColl(LCCollection, typeMapping.trackerHitPlanes); diff --git a/k4EDM4hep2LcioConv/src/k4EDM4hep2LcioConv.cpp b/k4EDM4hep2LcioConv/src/k4EDM4hep2LcioConv.cpp index 694b4b9b..d8abca79 100644 --- a/k4EDM4hep2LcioConv/src/k4EDM4hep2LcioConv.cpp +++ b/k4EDM4hep2LcioConv/src/k4EDM4hep2LcioConv.cpp @@ -41,7 +41,7 @@ namespace EDM4hep2LCIOConv { auto lcColl = convTracks(coll, objectMappings.tracks, objectMappings.trackerHits); lcioEvent->addCollection(lcColl, name); } - else if (auto coll = dynamic_cast(edmCollection)) { + else if (auto coll = dynamic_cast(edmCollection)) { auto lcColl = convTrackerHits(coll, cellIDStr, objectMappings.trackerHits); lcioEvent->addCollection(lcColl, name); } diff --git a/tests/compare_contents.cpp b/tests/compare_contents.cpp index 12b4739f..9df07909 100644 --- a/tests/compare_contents.cpp +++ b/tests/compare_contents.cpp @@ -91,7 +91,7 @@ int main(int argc, char* argv[]) ASSERT_COMPARE_OR_EXIT(edm4hep::MCParticleCollection) ASSERT_COMPARE_OR_EXIT(edm4hep::ReconstructedParticleCollection) ASSERT_COMPARE_OR_EXIT(edm4hep::TrackCollection) - ASSERT_COMPARE_OR_EXIT(edm4hep::TrackerHitCollection) + ASSERT_COMPARE_OR_EXIT(edm4hep::TrackerHit3DCollection) ASSERT_COMPARE_OR_EXIT(edm4hep::TrackerHitPlaneCollection) ASSERT_COMPARE_OR_EXIT(edm4hep::SimTrackerHitCollection) ASSERT_COMPARE_OR_EXIT(edm4hep::CalorimeterHitCollection) diff --git a/tests/edm4hep_roundtrip.cpp b/tests/edm4hep_roundtrip.cpp index 60ba4784..b040de48 100644 --- a/tests/edm4hep_roundtrip.cpp +++ b/tests/edm4hep_roundtrip.cpp @@ -24,7 +24,7 @@ int main() ASSERT_SAME_OR_ABORT(edm4hep::MCParticleCollection, "mcParticles"); ASSERT_SAME_OR_ABORT(edm4hep::SimCalorimeterHitCollection, "simCaloHits"); ASSERT_SAME_OR_ABORT(edm4hep::TrackCollection, "tracks"); - ASSERT_SAME_OR_ABORT(edm4hep::TrackerHitCollection, "trackerHits"); + ASSERT_SAME_OR_ABORT(edm4hep::TrackerHit3DCollection, "trackerHits"); ASSERT_SAME_OR_ABORT(edm4hep::TrackerHitPlaneCollection, "trackerHitPlanes"); ASSERT_SAME_OR_ABORT(edm4hep::ClusterCollection, "clusters"); diff --git a/tests/edm4hep_to_lcio.cpp b/tests/edm4hep_to_lcio.cpp index 587c1467..6e4d4c88 100644 --- a/tests/edm4hep_to_lcio.cpp +++ b/tests/edm4hep_to_lcio.cpp @@ -53,7 +53,7 @@ int main() ASSERT_COMPARE_OR_EXIT(edm4hep::MCParticleCollection) ASSERT_COMPARE_OR_EXIT(edm4hep::ReconstructedParticleCollection) ASSERT_COMPARE_OR_EXIT(edm4hep::TrackCollection) - ASSERT_COMPARE_OR_EXIT(edm4hep::TrackerHitCollection) + ASSERT_COMPARE_OR_EXIT(edm4hep::TrackerHit3DCollection) ASSERT_COMPARE_OR_EXIT(edm4hep::TrackerHitPlaneCollection) ASSERT_COMPARE_OR_EXIT(edm4hep::SimTrackerHitCollection) ASSERT_COMPARE_OR_EXIT(edm4hep::CalorimeterHitCollection) diff --git a/tests/src/CompareEDM4hepEDM4hep.cc b/tests/src/CompareEDM4hepEDM4hep.cc index 9f150c85..6b560bef 100644 --- a/tests/src/CompareEDM4hepEDM4hep.cc +++ b/tests/src/CompareEDM4hepEDM4hep.cc @@ -5,7 +5,6 @@ #include "edm4hep/MCParticleCollection.h" #include "edm4hep/SimCalorimeterHitCollection.h" #include "edm4hep/TrackCollection.h" -#include "edm4hep/TrackerHitCollection.h" #include "edm4hep/TrackerHitPlaneCollection.h" #include "edm4hep/ClusterCollection.h" @@ -199,7 +198,7 @@ bool compare(const edm4hep::TrackCollection& origColl, const edm4hep::TrackColle return true; } -bool compare(const edm4hep::TrackerHitCollection& origColl, const edm4hep::TrackerHitCollection& roundtripColl) +bool compare(const edm4hep::TrackerHit3DCollection& origColl, const edm4hep::TrackerHit3DCollection& roundtripColl) { REQUIRE_SAME(origColl.size(), roundtripColl.size(), "collection sizes"); for (size_t i = 0; i < origColl.size(); ++i) { diff --git a/tests/src/CompareEDM4hepEDM4hep.h b/tests/src/CompareEDM4hepEDM4hep.h index 0bbd9d5b..c5f1b7c5 100644 --- a/tests/src/CompareEDM4hepEDM4hep.h +++ b/tests/src/CompareEDM4hepEDM4hep.h @@ -13,7 +13,7 @@ bool compare( bool compare(const edm4hep::TrackCollection& origColl, const edm4hep::TrackCollection& roundtripColl); -bool compare(const edm4hep::TrackerHitCollection& origColl, const edm4hep::TrackerHitCollection& roundtripColl); +bool compare(const edm4hep::TrackerHit3DCollection& origColl, const edm4hep::TrackerHit3DCollection& roundtripColl); bool compare( const edm4hep::TrackerHitPlaneCollection& origColl, diff --git a/tests/src/CompareEDM4hepLCIO.cc b/tests/src/CompareEDM4hepLCIO.cc index dd40aa5a..0b86d8d8 100644 --- a/tests/src/CompareEDM4hepLCIO.cc +++ b/tests/src/CompareEDM4hepLCIO.cc @@ -414,7 +414,7 @@ bool compare( bool compare( const EVENT::TrackerHit* lcioElem, - const edm4hep::TrackerHit& edm4hepElem, + const edm4hep::TrackerHit3D& edm4hepElem, const ObjectMappings& objectMaps) { const auto lcioCellID = to64BitCellID(lcioElem); @@ -432,7 +432,7 @@ bool compare( bool compare( const lcio::LCCollection* lcioCollection, - const edm4hep::TrackerHitCollection& edm4hepCollection, + const edm4hep::TrackerHit3DCollection& edm4hepCollection, const ObjectMappings& objectMaps) { return compareCollection(lcioCollection, edm4hepCollection, objectMaps); diff --git a/tests/src/CompareEDM4hepLCIO.h b/tests/src/CompareEDM4hepLCIO.h index 3703499d..977496d1 100644 --- a/tests/src/CompareEDM4hepLCIO.h +++ b/tests/src/CompareEDM4hepLCIO.h @@ -23,7 +23,15 @@ #include "edm4hep/SimTrackerHitCollection.h" #include "edm4hep/RawTimeSeriesCollection.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; + using TrackerHit3D = edm4hep::TrackerHit; +} // namespace edm4hep +#endif #include "edm4hep/TrackerHitPlaneCollection.h" #include "edm4hep/VertexCollection.h" #include "podio/Frame.h" @@ -107,10 +115,10 @@ bool compare( const edm4hep::RawTimeSeriesCollection& edm4hepCollection, const ObjectMappings& objectMaps); -bool compare(const EVENT::TrackerHit* lcio, const edm4hep::TrackerHit& edm4hep, const ObjectMappings& objectMaps); +bool compare(const EVENT::TrackerHit* lcio, const edm4hep::TrackerHit3D& edm4hep, const ObjectMappings& objectMaps); bool compare( const lcio::LCCollection* lcioCollection, - const edm4hep::TrackerHitCollection& edm4hepCollection, + const edm4hep::TrackerHit3DCollection& edm4hepCollection, const ObjectMappings& objectMaps); bool compare( diff --git a/tests/src/EDM4hep2LCIOUtilities.cc b/tests/src/EDM4hep2LCIOUtilities.cc index 6fbeb6b0..6f09e6b4 100644 --- a/tests/src/EDM4hep2LCIOUtilities.cc +++ b/tests/src/EDM4hep2LCIOUtilities.cc @@ -4,7 +4,14 @@ #include "edm4hep/MCParticleCollection.h" #include "edm4hep/RawCalorimeterHitCollection.h" #include "edm4hep/SimCalorimeterHitCollection.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 #include #include @@ -142,9 +149,9 @@ edm4hep::RawTimeSeriesCollection createTPCHits(const int num_elements, const int return coll; } -edm4hep::TrackerHitCollection createTrackerHits(const int num_elements) +edm4hep::TrackerHit3DCollection createTrackerHits(const int num_elements) { - edm4hep::TrackerHitCollection coll {}; + edm4hep::TrackerHit3DCollection coll {}; for (int i = 0; i < num_elements; ++i) { auto elem = coll.create(); @@ -187,7 +194,7 @@ edm4hep::TrackCollection createTracks( const int num_elements, const int subdetectorhitnumbers, const int num_track_states, - const edm4hep::TrackerHitCollection& trackerHits, + const edm4hep::TrackerHit3DCollection& trackerHits, const std::vector& link_trackerhit_idcs, const std::vector& track_link_tracks_idcs) { diff --git a/tests/src/EDM4hep2LCIOUtilities.h b/tests/src/EDM4hep2LCIOUtilities.h index 2a73ff77..b4cda5df 100644 --- a/tests/src/EDM4hep2LCIOUtilities.h +++ b/tests/src/EDM4hep2LCIOUtilities.h @@ -6,12 +6,20 @@ #include #include +#if __has_include("edm4hep/TrackerHit3DCollection.h") +#include "edm4hep/TrackerHit3DCollection.h" +#else +#include "edm4hep/TrackerHitCollection.h" +namespace edm4hep { + using TrackerHit3DCollection = edm4hep::TrackerHitCollection; +} // namespace edm4hep +#endif + namespace edm4hep { class CalorimeterHitCollection; class MCParticleCollection; class RawCalorimeterHitCollection; class RawTimeSeriesCollection; - class TrackerHitCollection; class TrackerHitPlaneCollection; class TrackCollection; class SimCalorimeterHitCollection; @@ -110,7 +118,7 @@ edm4hep::RawTimeSeriesCollection createTPCHits(const int num_elements, const int /** * Create a TrackerHit collection */ -edm4hep::TrackerHitCollection createTrackerHits(const int num_elements); +edm4hep::TrackerHit3DCollection createTrackerHits(const int num_elements); /** * Create a track collection with tracks that have links to other tracks (in the @@ -120,7 +128,7 @@ edm4hep::TrackCollection createTracks( const int num_elements, const int subdetectorhitnumbers, const int num_track_states, - const edm4hep::TrackerHitCollection& trackerHits, + const edm4hep::TrackerHit3DCollection& trackerHits, const std::vector& link_trackerhit_idcs, const std::vector& track_link_tracks_idcs); diff --git a/tests/src/ObjectMapping.cc b/tests/src/ObjectMapping.cc index 06de56aa..a6ac8bb8 100644 --- a/tests/src/ObjectMapping.cc +++ b/tests/src/ObjectMapping.cc @@ -18,7 +18,14 @@ #include "UTIL/LCIterator.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/SimTrackerHitCollection.h" #include "edm4hep/ClusterCollection.h" @@ -67,7 +74,6 @@ ObjectMappings ObjectMappings::fromEvent(EVENT::LCEvent* lcEvt, const podio::Fra continue; } FILL_MAP(Track, mapping.tracks); - FILL_MAP(TrackerHit, mapping.trackerHits); FILL_MAP(TrackerHitPlane, mapping.trackerHitPlanes); FILL_MAP(SimTrackerHit, mapping.simTrackerHits); FILL_MAP(Cluster, mapping.clusters); @@ -82,6 +88,10 @@ ObjectMappings ObjectMappings::fromEvent(EVENT::LCEvent* lcEvt, const podio::Fra auto& edm4hepColl = edmEvt.get(name); fillMap(mapping.tpcHits, lcioColl, edm4hepColl); } + if (type == "TrackerHit") { + auto& edm4hepColl = edmEvt.get(name); + fillMap(mapping.trackerHits, lcioColl, edm4hepColl); + } } return mapping;