DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Geant4TCUserParticleHandler.cpp
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 
24 #ifndef DD4HEP_DDG4_GEANT4TCUSERPARTICLEHANDLER_H
25 #define DD4HEP_DDG4_GEANT4TCUSERPARTICLEHANDLER_H
26 
27 // Framework include files
28 #include <DD4hep/Primitives.h>
30 
32 namespace dd4hep {
33 
35  namespace sim {
36 
38 
47  public:
50 
53 
55 
63  virtual void end(const G4Track* track, Particle& particle);
64 
66  virtual void end(const G4Event* event);
67 
68  };
69  } // End namespace sim
70 } // End namespace dd4hep
71 
72 #endif // DD4HEP_DDG4_GEANT4TCUSERPARTICLEHANDLER_H
73 
74 //====================================================================
75 // AIDA Detector description implementation
76 //--------------------------------------------------------------------
77 //
78 // Author : M.Frank
79 //
80 //====================================================================
81 // Framework include files
82 //#include <DDG4/Geant4TCUserParticleHandler.h>
83 #include <DDG4/Geant4Particle.h>
84 #include <DDG4/Factories.h>
86 
87 
88 using namespace dd4hep::sim;
90 
93 : Geant4UserParticleHandler(ctxt,nam)
94 {
95  declareProperty("TrackingVolume_Zmin",m_zTrackerMin=-1e100);
96  declareProperty("TrackingVolume_Zmax",m_zTrackerMax=1e100);
97  declareProperty("TrackingVolume_Rmax",m_rTracker=1e100);
98 }
99 
101 void Geant4TCUserParticleHandler::end(const G4Track* /* track */, Particle& p) {
102 
103  double r_prod = std::sqrt(p.vsx*p.vsx + p.vsy*p.vsy);
104  double z_prod = p.vsz;
105  bool starts_in_trk_vol = ( r_prod <= m_rTracker
106  && z_prod >= (m_zTrackerMin == -1e100? -m_zTrackerMax : m_zTrackerMin)
107  && z_prod <= m_zTrackerMax
108  ) ;
109 
110  double r_end = std::sqrt(p.vex*p.vex + p.vey*p.vey);
111  double z_end = p.vez;
112  bool ends_in_trk_vol = ( r_end <= m_rTracker
113  && z_end >= (m_zTrackerMin == -1e100? -m_zTrackerMax : m_zTrackerMin)
114  && z_end <= m_zTrackerMax
115  ) ;
116 
117  setReason(p, starts_in_trk_vol, ends_in_trk_vol);
118  setSimulatorStatus(p, starts_in_trk_vol, ends_in_trk_vol);
119 }
120 
122 void Geant4TCUserParticleHandler::end(const G4Event* /* event */) {
123 
124 }
125 
Geant4TCUserParticleHandler
Rejects to keep particles, which are created outside a tracking cylinder.
dd4hep::sim::Geant4TCUserParticleHandler::m_zTrackerMax
double m_zTrackerMax
Definition: Geant4TCUserParticleHandler.cpp:46
Geant4UserParticleHandlerHelper.h
dd4hep::sim::setReason
void setReason(Geant4Particle &p, bool starts_in_trk_vol, bool ends_in_trk_vol)
determines if particle should be kept and sets p.reason = 0 otherwise
Definition: Geant4UserParticleHandlerHelper.cpp:23
DECLARE_GEANT4ACTION
#define DECLARE_GEANT4ACTION(name)
Plugin defintion to create Geant4Action objects.
Definition: Factories.h:210
Geant4UserParticleHandler.h
Geant4UserParticleHandler
Geant4ParticleHandler user extension action called by the particle handler.
dd4hep::sim::setSimulatorStatus
void setSimulatorStatus(Geant4Particle &p, bool starts_in_trk_vol, bool ends_in_trk_vol)
determines if particle has ended in the tracker, calorimeter or if it is backscatter and sets simulat...
Definition: Geant4UserParticleHandlerHelper.cpp:53
dd4hep::sim::Geant4Action::declareProperty
Geant4Action & declareProperty(const std::string &nam, T &val)
Declare property.
Definition: Geant4Action.h:366
dd4hep::sim::Geant4TCUserParticleHandler::~Geant4TCUserParticleHandler
virtual ~Geant4TCUserParticleHandler()
Default destructor.
Definition: Geant4TCUserParticleHandler.cpp:52
dd4hep::sim::Geant4TCUserParticleHandler::Geant4TCUserParticleHandler
Geant4TCUserParticleHandler(Geant4Context *context, const std::string &nam)
Standard constructor.
Factories.h
Primitives.h
dd4hep::sim
Namespace for the Geant4 based simulation part of the AIDA detector description toolkit.
Definition: Geant4Output2EDM4hep.cpp:49
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
Geant4Particle.h
dd4hep::sim::Geant4TCUserParticleHandler::end
virtual void end(const G4Track *track, Particle &particle)
Post-track action callback.
dd4hep::sim::Geant4TCUserParticleHandler::m_rTracker
double m_rTracker
Definition: Geant4TCUserParticleHandler.cpp:46
dd4hep::sim::Geant4Particle
Data structure to store the MC particle information.
Definition: Geant4Particle.h:103
dd4hep::sim::Geant4TCUserParticleHandler::end
virtual void end(const G4Event *event)
Post-event action callback: avoid warning (...) was hidden [-Woverloaded-virtual].
dd4hep::sim::Geant4TCUserParticleHandler::m_zTrackerMin
double m_zTrackerMin
Definition: Geant4TCUserParticleHandler.cpp:46
dd4hep::sim::Geant4Context
Generic context to extend user, run and event information.
Definition: Geant4Context.h:201
dd4hep::sim::Geant4Action::context
Geant4Context * context() const
Access the context.
Definition: Geant4Action.h:270