Skip to content

Commit

Permalink
Geant4GeneratorWrapper: collect vertices before putting them in the set
Browse files Browse the repository at this point in the history
Geant4InputHandling: prevent adding same particle more than once
  • Loading branch information
andresailer committed Dec 15, 2023
1 parent 424f39c commit fbb91b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions DDG4/src/Geant4GeneratorWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ void Geant4GeneratorWrapper::operator()(G4Event* event) {
Geant4PrimaryMap* primaryMap = context()->event().extension<Geant4PrimaryMap>();
set<G4PrimaryVertex*> 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);
Expand Down
5 changes: 5 additions & 0 deletions DDG4/src/Geant4InputHandling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit fbb91b1

Please sign in to comment.