From 69a1322c26e6ed77d4e08b922e82f12e013c4a88 Mon Sep 17 00:00:00 2001
From: tmadlener <thomas.madlener@desy.de>
Date: Mon, 11 Dec 2023 13:58:44 +0100
Subject: [PATCH] Set the edm4hep momentum as doubles once it becomes possible

---
 DDG4/edm4hep/Geant4Output2EDM4hep.cpp | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/DDG4/edm4hep/Geant4Output2EDM4hep.cpp b/DDG4/edm4hep/Geant4Output2EDM4hep.cpp
index 9d9ed446d..2d9d0c3ca 100644
--- a/DDG4/edm4hep/Geant4Output2EDM4hep.cpp
+++ b/DDG4/edm4hep/Geant4Output2EDM4hep.cpp
@@ -24,6 +24,7 @@
 #include <edm4hep/SimTrackerHitCollection.h>
 #include <edm4hep/CaloHitContributionCollection.h>
 #include <edm4hep/SimCalorimeterHitCollection.h>
+#include <edm4hep/EDM4hepVersion.h>
 /// podio include files
 #include <podio/Frame.h>
 #include <podio/ROOTFrameWriter.h>
@@ -342,12 +343,13 @@ void Geant4Output2EDM4hep::saveParticles(Geant4ParticleMap* particles)    {
       auto mcp = m_particles.create();
       mcp.setPDG(p->pdgID);
 
-      float ps_fa[3] = {float(p->psx/CLHEP::GeV),float(p->psy/CLHEP::GeV),float(p->psz/CLHEP::GeV)};
-      mcp.setMomentum( ps_fa );
-
-      float pe_fa[3] = {float(p->pex/CLHEP::GeV),float(p->pey/CLHEP::GeV),float(p->pez/CLHEP::GeV)};
-      mcp.setMomentumAtEndpoint( pe_fa );
-
+#if edm4hep_VERSION < EDM4HEP_VERSION(0, 10, 3)
+      mcp.setMomentum( {float(p->psx/CLHEP::GeV),float(p->psy/CLHEP::GeV),float(p->psz/CLHEP::GeV)} );
+      mcp.setMomentumAtEndpoint( {float(p->pex/CLHEP::GeV),float(p->pey/CLHEP::GeV),float(p->pez/CLHEP::GeV)} );
+#else
+      mcp.setMomentum( {p->psx/CLHEP::GeV, p->psy/CLHEP::GeV, p->psz/CLHEP::GeV} );
+      mcp.setMomentumAtEndpoint( {p->pex/CLHEP::GeV, p->pey/CLHEP::GeV, p->pez/CLHEP::GeV} );
+#endif
       double vs_fa[3] = { p->vsx/CLHEP::mm, p->vsy/CLHEP::mm, p->vsz/CLHEP::mm } ;
       mcp.setVertex( vs_fa );
 
-- 
GitLab