Skip to content
Snippets Groups Projects
Commit 6429180c authored by Wouter Deconinck's avatar Wouter Deconinck
Browse files

Use G4IonTable to support beagle etc

parent 7f6ef5c2
No related branches found
No related tags found
2 merge requests!273Draft: Resolve "Support FastSim and GFlash",!239Use G4IonTable to support beagle etc
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "CLHEP/Units/SystemOfUnits.h" #include "CLHEP/Units/SystemOfUnits.h"
#include "G4ParticleDefinition.hh" #include "G4ParticleDefinition.hh"
#include "G4ParticleTable.hh" #include "G4ParticleTable.hh"
#include "G4IonTable.hh"
#include "G4Event.hh" #include "G4Event.hh"
#include "dd4pod/TrackerHitCollection.h" #include "dd4pod/TrackerHitCollection.h"
...@@ -173,13 +174,20 @@ namespace dd4hep::sim { ...@@ -173,13 +174,20 @@ namespace dd4hep::sim {
// loop over particle and copy them to podio data model // loop over particle and copy them to podio data model
for (const auto& [key, part] : pm) { for (const auto& [key, part] : pm) {
int charge = 0;
// particles
const auto part_def = m_particleTable->FindParticle(part->pdgID); const auto part_def = m_particleTable->FindParticle(part->pdgID);
int charge = 0; // ions
if (part_def == nullptr) { 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", printout((part->genStatus == 1 ? ERROR : INFO), "Geant4Output2Podio",
"++ saveEvent: pdgID %d unknown, charge set to 0", part->pdgID); "++ 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{ dd4pod::Geant4Particle podpart{
part->id, part->id,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment