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();