File indexing completed on 2025-01-30 09:17:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include "Geant4UserParticleHandlerHelper.h"
0016 #include <DDG4/Geant4Particle.h>
0017 #include <DDG4/Geant4UserParticleHandler.h>
0018
0019
0020
0021 namespace dd4hep::sim {
0022
0023 void setReason(Geant4Particle& p, bool starts_in_trk_vol, bool ends_in_trk_vol) {
0024
0025 dd4hep::detail::ReferenceBitMask<int> reason(p.reason);
0026
0027 if( reason.isSet(G4PARTICLE_PRIMARY) ) {
0028
0029 } else if( starts_in_trk_vol && ! reason.isSet(G4PARTICLE_ABOVE_ENERGY_THRESHOLD) ) {
0030
0031 p.reason = 0;
0032 return;
0033 }
0034
0035
0036
0037
0038
0039
0040 if( not reason.isSet(G4PARTICLE_PRIMARY) ) {
0041 if( !starts_in_trk_vol ) {
0042 if( !ends_in_trk_vol ){
0043 p.reason = 0;
0044 }
0045
0046 else if( ! reason.isSet(G4PARTICLE_CREATED_TRACKER_HIT) ) {
0047 p.reason = 0;
0048 }
0049 }
0050 }
0051 }
0052
0053 void setSimulatorStatus(Geant4Particle& p, bool starts_in_trk_vol, bool ends_in_trk_vol) {
0054
0055 dd4hep::detail::ReferenceBitMask<int> simStatus(p.status);
0056
0057 if( ends_in_trk_vol ) {
0058 simStatus.set(G4PARTICLE_SIM_DECAY_TRACKER);
0059 }
0060
0061
0062 if( not ends_in_trk_vol && not simStatus.isSet(G4PARTICLE_SIM_LEFT_DETECTOR) ) {
0063 simStatus.set(G4PARTICLE_SIM_DECAY_CALO);
0064 }
0065
0066 if( not starts_in_trk_vol && ends_in_trk_vol ) {
0067 simStatus.set(G4PARTICLE_SIM_BACKSCATTER);
0068 }
0069 }
0070
0071 }