From 4eea3d0f0ef0f6009e5624a806554046de132653 Mon Sep 17 00:00:00 2001 From: tmadlener Date: Tue, 30 Jan 2024 18:47:45 +0100 Subject: [PATCH] Make the renaming of TrackerHit -> TrackerHit3D transparent --- DDDigi/io/DigiEdm4hepOutput.cpp | 9 ++++----- DDDigi/io/DigiEdm4hepOutput.h | 13 ++++++++++--- DDDigi/io/DigiIO.cpp | 9 ++++++++- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/DDDigi/io/DigiEdm4hepOutput.cpp b/DDDigi/io/DigiEdm4hepOutput.cpp index 3a80639d8..cd3cf5ba5 100644 --- a/DDDigi/io/DigiEdm4hepOutput.cpp +++ b/DDDigi/io/DigiEdm4hepOutput.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -56,7 +55,7 @@ namespace dd4hep { /// MC particle collection particlecollection_t m_particles { }; /// Collection of all edm4hep tracker object collections - std::map > m_tracker_collections; + std::map > m_tracker_collections; /// Collection of all edm4hep calorimeter object collections std::map > m_calo_collections; /// Output section name @@ -114,7 +113,7 @@ namespace dd4hep { m_particles = std::make_pair(nam, std::make_unique()); } else if ( typ == "TrackerHits" ) { - m_tracker_collections.emplace(nam, std::make_unique()); + m_tracker_collections.emplace(nam, std::make_unique()); } else if ( typ == "CalorimeterHits" ) { m_calo_collections.emplace(nam, std::make_unique()); @@ -274,7 +273,7 @@ namespace dd4hep { template void DigiEdm4hepOutputProcessor::convert_depos(const T& cont, const predicate_t& predicate, - edm4hep::TrackerHitCollection* collection) const + edm4hep::TrackerHit3DCollection* collection) const { std::array covMat = {0., 0., m_pointResoutionRPhi*m_pointResoutionRPhi, 0., 0., m_pointResoutionZ*m_pointResoutionZ @@ -308,7 +307,7 @@ namespace dd4hep { if ( !cont.empty() ) { switch(cont.data_type) { case SegmentEntry::TRACKER_HITS: - convert_depos(cont, predicate, static_cast(coll)); + convert_depos(cont, predicate, static_cast(coll)); break; case SegmentEntry::CALORIMETER_HITS: convert_depos(cont, predicate, static_cast(coll)); diff --git a/DDDigi/io/DigiEdm4hepOutput.h b/DDDigi/io/DigiEdm4hepOutput.h index 09998b70f..8711967e6 100644 --- a/DDDigi/io/DigiEdm4hepOutput.h +++ b/DDDigi/io/DigiEdm4hepOutput.h @@ -17,10 +17,17 @@ #include /// C/C++ include files +#if __has_include("edm4hep/TrackerHitCollection.h") +#include +namespace edm4hep { + using TrackerHit3DCollection = edm4hep::TrackerHitCollection; +} +#else +#include +#endif /// Forward declarations from edm4hep namespace edm4hep { - class TrackerHitCollection; class CalorimeterHitCollection; } @@ -35,7 +42,7 @@ namespace dd4hep { * Supported output containers types are: * - edm4hep::MCParticles aka "MCParticles" * - edm4hep::CalorimeterHitCollection aka "CalorimeterHits" - * - edm4hep::TrackerHitCollection aka "TracketHits" + * - edm4hep::TrackerHit3DCollection aka "TracketHits" * * This entity actually is only the work dispatcher: * It opens files and dumps data into @@ -103,7 +110,7 @@ namespace dd4hep { /// Convert tracker hits to edm4hep template void - convert_depos(const T& cont, const predicate_t& predicate, edm4hep::TrackerHitCollection* collection) const; + convert_depos(const T& cont, const predicate_t& predicate, edm4hep::TrackerHit3DCollection* collection) const; /// Convert calorimeter hits to edm4hep template void diff --git a/DDDigi/io/DigiIO.cpp b/DDDigi/io/DigiIO.cpp index 10074ef94..e259a7865 100644 --- a/DDDigi/io/DigiIO.cpp +++ b/DDDigi/io/DigiIO.cpp @@ -28,7 +28,14 @@ #include #include #include +#if __has_include("edm4hep/TrackerHitCollection.h") #include +namespace edm4hep { + using TrackerHit3DCollection = edm4hep::TrackerHitCollection; +} +#else +#include +#endif #include #include #include @@ -224,7 +231,7 @@ namespace dd4hep { template <> template <> void data_io::_to_edm4hep(const std::pair& dep, const std::array& covMat, - edm4hep::TrackerHitCollection& collection, + edm4hep::TrackerHit3DCollection& collection, int hit_type) {