LDMX Software
BertiniEventTopologyProcess.cxx
1#include "SimCore/PhotoNuclearModels/BertiniEventTopologyProcess.h"
2namespace simcore {
3
4void BertiniEventTopologyProcess::cleanupSecondaries() {
5 int secondaries{theParticleChange.GetNumberOfSecondaries()};
6 // Geant4 won't clean up this memory for us by default
7 for (int i{0}; i < secondaries; ++i) {
8 // disable clang's use-after-free warning for this delete
9 // as far as we (@tomeichlersmith and @EinarElen) can tell,
10 // this is correct and clang is just getting confused since
11 // Geant4's inlined delete method is written in a wacky way
12#ifndef __clang_analyzer__
13 auto secondary{theParticleChange.GetSecondary(i)->GetParticle()};
14 delete secondary;
15#endif
16 }
17}
18
19G4HadFinalState* BertiniEventTopologyProcess::ApplyYourself(
20 const G4HadProjectile& projectile, G4Nucleus& targetNucleus) {
21 int attempts{1};
22 if (!acceptProjectile(projectile) || !acceptTarget(targetNucleus)) {
23 // Bertini will handle the particle change on its own here
24 return G4CascadeInterface::ApplyYourself(projectile, targetNucleus);
25 }
26
27 while (true) {
28 theParticleChange.Clear();
29 theParticleChange.SetStatusChange(stopAndKill);
30 G4CascadeInterface::ApplyYourself(projectile, targetNucleus);
31 if (acceptEvent()) {
32 incrementEventWeight(attempts);
33 return &theParticleChange;
34 }
35 attempts++;
36 cleanupSecondaries();
37 }
38}
39
40} // namespace simcore
Dynamically loadable photonuclear models either from SimCore or external libraries implementing this ...