Skip to content

Commit

Permalink
EDM4hepOutput: determine edm4hep::MCParticle momentum vector type aut…
Browse files Browse the repository at this point in the history
…omagically
  • Loading branch information
andresailer committed Apr 4, 2024
1 parent 0207c48 commit 4a5099b
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions DDG4/edm4hep/Geant4Output2EDM4hep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,14 +354,11 @@ void Geant4Output2EDM4hep::saveParticles(Geant4ParticleMap* particles) {
const G4ParticleDefinition* def = p.definition();
auto mcp = m_particles.create();
mcp.setPDG(p->pdgID);
// Because EDM4hep is switching between vector3f[loat] and vector3d[ouble]
using MT = decltype(std::declval<edm4hep::MCParticle>().getMomentum().x);
mcp.setMomentum( {MT(p->psx/CLHEP::GeV),MT(p->psy/CLHEP::GeV),MT(p->psz/CLHEP::GeV)} );
mcp.setMomentumAtEndpoint( {MT(p->pex/CLHEP::GeV),MT(p->pey/CLHEP::GeV),MT(p->pez/CLHEP::GeV)} );

#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 );

Expand Down

0 comments on commit 4a5099b

Please sign in to comment.