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
0016
0017
0018
0019
0020
0021
0022
0023
0024 #ifndef DD4HEP_DDG4_GEANT4TCUSERPARTICLEHANDLER_H
0025 #define DD4HEP_DDG4_GEANT4TCUSERPARTICLEHANDLER_H
0026
0027
0028 #include <DD4hep/Primitives.h>
0029 #include <DDG4/Geant4UserParticleHandler.h>
0030
0031
0032 namespace dd4hep {
0033
0034
0035 namespace sim {
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 class Geant4TCUserParticleHandler : public Geant4UserParticleHandler {
0046 double m_zTrackerMin, m_zTrackerMax, m_rTracker;
0047 public:
0048
0049 Geant4TCUserParticleHandler(Geant4Context* context, const std::string& nam);
0050
0051
0052 virtual ~Geant4TCUserParticleHandler() {}
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063 virtual void end(const G4Track* track, Particle& particle);
0064
0065
0066 virtual void end(const G4Event* event);
0067
0068 };
0069 }
0070 }
0071
0072 #endif
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083 #include <DDG4/Geant4Particle.h>
0084 #include <DDG4/Factories.h>
0085 #include "Geant4UserParticleHandlerHelper.h"
0086
0087
0088 using namespace dd4hep::sim;
0089 DECLARE_GEANT4ACTION(Geant4TCUserParticleHandler)
0090
0091
0092 Geant4TCUserParticleHandler::Geant4TCUserParticleHandler(Geant4Context* ctxt, const std::string& nam)
0093 : Geant4UserParticleHandler(ctxt,nam)
0094 {
0095 declareProperty("TrackingVolume_Zmin",m_zTrackerMin=-1e100);
0096 declareProperty("TrackingVolume_Zmax",m_zTrackerMax=1e100);
0097 declareProperty("TrackingVolume_Rmax",m_rTracker=1e100);
0098 }
0099
0100
0101 void Geant4TCUserParticleHandler::end(const G4Track* , Particle& p) {
0102
0103 double r_prod = std::sqrt(p.vsx*p.vsx + p.vsy*p.vsy);
0104 double z_prod = p.vsz;
0105 bool starts_in_trk_vol = ( r_prod <= m_rTracker
0106 && z_prod >= (m_zTrackerMin == -1e100? -m_zTrackerMax : m_zTrackerMin)
0107 && z_prod <= m_zTrackerMax
0108 ) ;
0109
0110 double r_end = std::sqrt(p.vex*p.vex + p.vey*p.vey);
0111 double z_end = p.vez;
0112 bool ends_in_trk_vol = ( r_end <= m_rTracker
0113 && z_end >= (m_zTrackerMin == -1e100? -m_zTrackerMax : m_zTrackerMin)
0114 && z_end <= m_zTrackerMax
0115 ) ;
0116
0117 setReason(p, starts_in_trk_vol, ends_in_trk_vol);
0118 setSimulatorStatus(p, starts_in_trk_vol, ends_in_trk_vol);
0119 }
0120
0121
0122 void Geant4TCUserParticleHandler::end(const G4Event* ) {
0123
0124 }
0125