From ec32498bd6712239e3d69c54c552ff9f00004251 Mon Sep 17 00:00:00 2001 From: Andre Sailer Date: Fri, 15 Dec 2023 17:04:40 +0100 Subject: [PATCH] Geant4GeneratorWrapper: collect vertices before putting them in the set Geant4InputHandling: prevent adding same particle more than once --- DDG4/src/Geant4GeneratorWrapper.cpp | 6 +++--- DDG4/src/Geant4InputHandling.cpp | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/DDG4/src/Geant4GeneratorWrapper.cpp b/DDG4/src/Geant4GeneratorWrapper.cpp index b40bec032..858300e5f 100644 --- a/DDG4/src/Geant4GeneratorWrapper.cpp +++ b/DDG4/src/Geant4GeneratorWrapper.cpp @@ -70,13 +70,13 @@ void Geant4GeneratorWrapper::operator()(G4Event* event) { Geant4PrimaryMap* primaryMap = context()->event().extension(); set primaries; + // Now generate the new interaction + generator()->GeneratePrimaryVertex(event); + /// Collect all existing interactions (primary vertices) for(G4PrimaryVertex* v=event->GetPrimaryVertex(); v; v=v->GetNext()) primaries.insert(v); - // Now generate the new interaction - generator()->GeneratePrimaryVertex(event); - // Add all the missing interactions (primary vertices) to the primary event record. Geant4PrimaryInteraction* inter = createPrimary(m_mask, primaryMap, primaries); prim->add(m_mask, inter); diff --git a/DDG4/src/Geant4InputHandling.cpp b/DDG4/src/Geant4InputHandling.cpp index 279db4b6a..84c1a7a81 100644 --- a/DDG4/src/Geant4InputHandling.cpp +++ b/DDG4/src/Geant4InputHandling.cpp @@ -88,6 +88,11 @@ static void collectPrimaries(Geant4PrimaryMap* pm, Geant4Vertex* particle_origine, G4PrimaryParticle* gp) { + //if the particle is in the map, we do not have to do anything + if ( pm->get(gp) ) { + return; + } + int pid = int(interaction->particles.size()); Geant4Particle* p = createPrimary(pid,particle_origine,gp); G4PrimaryParticle* dau = gp->GetDaughter();