LDMX Software
simcore::BertiniEventTopologyProcess Class Referenceabstract

Public Member Functions

 BertiniEventTopologyProcess (bool count_light_ions=true)
 
virtual bool acceptEvent () const =0
 
virtual bool acceptProjectile (const G4HadProjectile &projectile) const =0
 
virtual bool acceptTarget (const G4Nucleus &targetNucleus) const =0
 
G4HadFinalState * ApplyYourself (const G4HadProjectile &projectile, G4Nucleus &targetNucleus) override
 
void cleanupSecondaries ()
 
constexpr bool isLightIon (const int pdgCode) const
 Check if the PDG code corresponds to a light ion nucleus.
 
constexpr bool skipCountingParticle (const int pdgcode) const
 Whether or not to include a particular particle type in any counting.
 
virtual void incrementEventWeight (int N)
 

Private Attributes

bool count_light_ions_
 

Detailed Description

Definition at line 34 of file BertiniEventTopologyProcess.h.

Constructor & Destructor Documentation

◆ BertiniEventTopologyProcess()

simcore::BertiniEventTopologyProcess::BertiniEventTopologyProcess ( bool count_light_ions = true)
inline

Definition at line 36 of file BertiniEventTopologyProcess.h.

37 : G4CascadeInterface{}, count_light_ions_{count_light_ions} {}

Member Function Documentation

◆ ApplyYourself()

G4HadFinalState * simcore::BertiniEventTopologyProcess::ApplyYourself ( const G4HadProjectile & projectile,
G4Nucleus & targetNucleus )
override

Definition at line 19 of file BertiniEventTopologyProcess.cxx.

20 {
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}

◆ cleanupSecondaries()

void simcore::BertiniEventTopologyProcess::cleanupSecondaries ( )

Definition at line 4 of file BertiniEventTopologyProcess.cxx.

4 {
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}

◆ incrementEventWeight()

virtual void simcore::BertiniEventTopologyProcess::incrementEventWeight ( int N)
inlinevirtual

Definition at line 126 of file BertiniEventTopologyProcess.h.

126 {
127 auto event_info{static_cast<UserEventInformation*>(
128 G4EventManager::GetEventManager()->GetUserInformation())};
129 event_info->incWeight(1. / N);
130 }

◆ isLightIon()

bool simcore::BertiniEventTopologyProcess::isLightIon ( const int pdgCode) const
inlineconstexpr

Check if the PDG code corresponds to a light ion nucleus.

Nuclear PDG codes are given by ±10LZZZAAAI So to find the atomic number, we first divide by 10 (to lose the I-component) and then take the modulo with 1000.

Definition at line 93 of file BertiniEventTopologyProcess.h.

93 {
94 //
95 if (pdgCode > 1000000000) {
96 // Check if the atomic number is less than or equal to 4
97 return ((pdgCode / 10) % 1000) <= 4;
98 }
99 return false;
100 }

Referenced by skipCountingParticle().

◆ skipCountingParticle()

bool simcore::BertiniEventTopologyProcess::skipCountingParticle ( const int pdgcode) const
inlineconstexpr

Whether or not to include a particular particle type in any counting.

Unless count_light_ions_ is set, we don't count anything with a nuclear PDG code. This is consistent with the counting behaviour used in the PhotoNuclearDQM.

If count_light_ions_ is set, we also match PDG codes for nuclei with atomic number < 4. 

See also
isLightIon

Definition at line 114 of file BertiniEventTopologyProcess.h.

114 {
115 return !(pdgcode < 10000 || (count_light_ions_ && isLightIon(pdgcode)));
116 }
constexpr bool isLightIon(const int pdgCode) const
Check if the PDG code corresponds to a light ion nucleus.

References isLightIon().

Member Data Documentation

◆ count_light_ions_

bool simcore::BertiniEventTopologyProcess::count_light_ions_
private

Definition at line 133 of file BertiniEventTopologyProcess.h.


The documentation for this class was generated from the following files: