From c8f426734a3a5df8cecbe7ebd220ca2d2d222c04 Mon Sep 17 00:00:00 2001 From: Andre Sailer <andre.philippe.sailer@cern.ch> Date: Wed, 13 Jul 2022 10:47:31 +0200 Subject: [PATCH] DDG4: move ion handling to Geant4Particle --- DDG4/src/Geant4InputHandling.cpp | 7 +------ DDG4/src/Geant4Particle.cpp | 25 ++++++++++++++++++------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/DDG4/src/Geant4InputHandling.cpp b/DDG4/src/Geant4InputHandling.cpp index 27ad22bf6..d88b46e2a 100644 --- a/DDG4/src/Geant4InputHandling.cpp +++ b/DDG4/src/Geant4InputHandling.cpp @@ -22,7 +22,6 @@ // Geant4 include files #include <G4Event.hh> -#include <G4IonTable.hh> #include <G4ParticleDefinition.hh> #include <G4PrimaryParticle.hh> #include <G4PrimaryVertex.hh> @@ -344,11 +343,7 @@ int dd4hep::sim::smearInteraction(const Geant4Action* caller, static G4PrimaryParticle* createG4Primary(const Geant4ParticleHandle p) { G4PrimaryParticle* g4 = 0; - if ( 1000000000 < p->pdgID ) { - const G4ParticleDefinition* def = G4IonTable::GetIonTable()->GetIon(p->pdgID); - g4 = new G4PrimaryParticle(def, p->psx, p->psy, p->psz, p.energy()); - g4->SetCharge(p.charge()); - } else if ( 0 != p->pdgID ) { + if ( 0 != p->pdgID ) { g4 = new G4PrimaryParticle(p->pdgID, p->psx, p->psy, p->psz, p.energy()); } else { diff --git a/DDG4/src/Geant4Particle.cpp b/DDG4/src/Geant4Particle.cpp index a3dad3c72..2b2c00716 100644 --- a/DDG4/src/Geant4Particle.cpp +++ b/DDG4/src/Geant4Particle.cpp @@ -12,17 +12,20 @@ //========================================================================== // Framework include files -#include <DD4hep/Printout.h> -#include <DD4hep/Primitives.h> #include <DD4hep/InstanceCount.h> +#include <DD4hep/Primitives.h> +#include <DD4hep/Printout.h> #include <DDG4/Geant4Particle.h> -#include <TDatabasePDG.h> -#include <TParticlePDG.h> -#include <G4ParticleTable.hh> -#include <G4ParticleDefinition.hh> -#include <G4VProcess.hh> + #include <G4ChargedGeantino.hh> #include <G4Geantino.hh> +#include <G4IonTable.hh> +#include <G4ParticleDefinition.hh> +#include <G4ParticleTable.hh> +#include <G4VProcess.hh> + +#include <TDatabasePDG.h> +#include <TParticlePDG.h> #include <sstream> #include <iostream> @@ -114,6 +117,14 @@ void Geant4Particle::removeDaughter(int id_daughter) { const G4ParticleDefinition* Geant4ParticleHandle::definition() const { G4ParticleTable* tab = G4ParticleTable::GetParticleTable(); G4ParticleDefinition* def = tab->FindParticle(particle->pdgID); + if( 1000000000 < particle->pdgID) { + if(particle->pdgID % 10) { + // this is an excited ion, not sure how to handle this + std::cout << "We are ignoring excited state!!!!" << std::endl; + } + // last digit is the excitation level, we just set this to zero + return G4IonTable::GetIonTable()->GetIon((particle->pdgID / 10) * 10); + } if ( 0 == def && 0 == particle->pdgID ) { if ( 0 == particle->charge ) return G4Geantino::Definition(); -- GitLab