Commit 6429180c authored by Wouter Deconinck's avatar Wouter Deconinck
Browse files

Use G4IonTable to support beagle etc

parent 7f6ef5c2
Pipeline #20942 passed with stages
in 47 seconds
......@@ -12,6 +12,7 @@
#include "CLHEP/Units/SystemOfUnits.h"
#include "G4ParticleDefinition.hh"
#include "G4ParticleTable.hh"
#include "G4IonTable.hh"
#include "G4Event.hh"
#include "dd4pod/TrackerHitCollection.h"
......@@ -173,13 +174,20 @@ namespace dd4hep::sim {
// loop over particle and copy them to podio data model
for (const auto& [key, part] : pm) {
int charge = 0;
// particles
const auto part_def = m_particleTable->FindParticle(part->pdgID);
int charge = 0;
if (part_def == nullptr) {
// ions
int Z{0}, A{0}, L{0}, J{0};
double E{0.};
const auto is_ion = G4IonTable::GetNucleusByEncoding(part->pdgID, Z, A, L, E, J);
if (part_def != nullptr) {
charge = static_cast<int>(std::lround(part_def->GetPDGCharge() / CLHEP::eplus));
} else if (is_ion) {
charge = Z;
} else {
printout((part->genStatus == 1 ? ERROR : INFO), "Geant4Output2Podio",
"++ saveEvent: pdgID %d unknown, charge set to 0", part->pdgID);
} else {
charge = static_cast<int>(std::lround(part_def->GetPDGCharge() / CLHEP::eplus));
}
dd4pod::Geant4Particle podpart{
part->id,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment