DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Geant4TVUserParticleHandler.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_GEANT4TVUSERPARTICLEHANDLER_H
25 #define DD4HEP_DDG4_GEANT4TVUSERPARTICLEHANDLER_H
26 
27 // Framework include files
28 #include <DD4hep/Primitives.h>
29 #include <DD4hep/Volumes.h>
31 
33 namespace dd4hep {
34 
36  namespace sim {
37 
39 
48 
49  public:
52 
55 
57 
65  virtual void end(const G4Track* track, Particle& particle);
66 
68  virtual void end(const G4Event* event);
69 
70  };
71  } // End namespace sim
72 } // End namespace dd4hep
73 
74 #endif // DD4HEP_DDG4_GEANT4TVUSERPARTICLEHANDLER_H
75 
76 //====================================================================
77 // AIDA Detector description implementation
78 //--------------------------------------------------------------------
79 //
80 // Author : M.Frank
81 //
82 //====================================================================
83 // Framework include files
84 //#include <DDG4/Geant4TVUserParticleHandler.h>
85 #include <DDG4/Factories.h>
86 #include <DDG4/Geant4Particle.h>
87 #include <DDG4/Geant4Kernel.h>
89 
90 
91 using namespace dd4hep::sim;
93 
96 : Geant4UserParticleHandler(ctxt,nam)
97 {
99 }
100 
102 void Geant4TVUserParticleHandler::end(const G4Track* /* track */, Particle& p) {
103 
104  std::array<double, 3> start_point = {p.vsx, p.vsy, p.vsz};
105  bool starts_in_trk_vol = m_trackingVolume.ptr()->Contains(start_point.data());
106 
107  std::array<double, 3> end_point = {p.vex, p.vey, p.vez};
108  bool ends_in_trk_vol = m_trackingVolume.ptr()->Contains(end_point.data());
109 
110  setReason(p, starts_in_trk_vol, ends_in_trk_vol);
111  setSimulatorStatus(p, starts_in_trk_vol, ends_in_trk_vol);
112 }
113 
115 void Geant4TVUserParticleHandler::end(const G4Event* /* event */) {
116 
117 }
118 
Volumes.h
dd4hep::sim::Geant4TVUserParticleHandler::end
virtual void end(const G4Track *track, Particle &particle)
Post-track action callback.
dd4hep::sim::Geant4TVUserParticleHandler::m_trackingVolume
Volume m_trackingVolume
Definition: Geant4TVUserParticleHandler.cpp:47
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
dd4hep::sim::Geant4TVUserParticleHandler::~Geant4TVUserParticleHandler
virtual ~Geant4TVUserParticleHandler()
Default destructor.
Definition: Geant4TVUserParticleHandler.cpp:54
Geant4UserParticleHandler.h
dd4hep::sim::Geant4Kernel::detectorDescription
Detector & detectorDescription() const
Access to detector description.
Definition: Geant4Kernel.h:201
dd4hep::sim::Geant4TVUserParticleHandler::end
virtual void end(const G4Event *event)
Post-event action callback: avoid warning (...) was hidden [-Woverloaded-virtual].
Geant4UserParticleHandler
Geant4ParticleHandler user extension action called by the particle handler.
dd4hep::Volume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:378
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
Geant4TVUserParticleHandler
Rejects to keep particles, which are created outside a tracking cylinder.
dd4hep::Detector::trackingVolume
virtual Volume trackingVolume() const =0
Return handle to the volume containing the tracking devices.
Factories.h
Primitives.h
dd4hep::sim
Namespace for the Geant4 based simulation part of the AIDA detector description toolkit.
Definition: Geant4Output2EDM4hep.cpp:49
dd4hep::sim::Geant4Context::kernel
Geant4Kernel & kernel() const
Access to the kernel object.
Definition: Geant4Context.h:233
dd4hep::Handle::ptr
T * ptr() const
Access to the held object.
Definition: Handle.h:153
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
Geant4Particle.h
Geant4Kernel.h
dd4hep::sim::Geant4Particle
Data structure to store the MC particle information.
Definition: Geant4Particle.h:103
dd4hep::sim::Geant4TVUserParticleHandler::Geant4TVUserParticleHandler
Geant4TVUserParticleHandler(Geant4Context *context, const std::string &nam)
Standard constructor.
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