From 151c280c49487ff52c203f5f8e860427be894b37 Mon Sep 17 00:00:00 2001 From: Markus Frank <Markus.Frank@cern.ch> Date: Fri, 18 Nov 2022 16:51:58 +0100 Subject: [PATCH] Fix particle charge --- DDG4/hepmc/HepMC3EventReader.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/DDG4/hepmc/HepMC3EventReader.cpp b/DDG4/hepmc/HepMC3EventReader.cpp index 49d0d747b..dc6f7c897 100644 --- a/DDG4/hepmc/HepMC3EventReader.cpp +++ b/DDG4/hepmc/HepMC3EventReader.cpp @@ -10,6 +10,10 @@ // //==================================================================== +// Geant4 include files +#include <G4GlobalConfig.hh> +#include <G4ParticleTable.hh> + // Framework include files #include "HepMC3EventReader.h" #include "DD4hep/Printout.h" @@ -93,7 +97,9 @@ HEPMC3EventReader::readParticles(int event_number, Vertices& vertices, Particles const int pdg = mcp->pid(); PropertyMask status(p->status); p->pdgID = pdg; - p->charge = int(mcp->getCharge()*3.0); + // p->charge = int(mcp->getCharge()*3.0); + G4ParticleDefinition* def = G4ParticleTable::GetParticleTable()->FindParticle(p->pdgID); + p->charge = int(3.0 * (def ? def->GetPDGCharge() : -1.0)); // Assume e-/pi- p->psx = mom.get_component(0) * mom_unit; p->psy = mom.get_component(1) * mom_unit; p->psz = mom.get_component(2) * mom_unit; -- GitLab