|
||||
File indexing completed on 2025-01-18 09:14:21
0001 //========================================================================== 0002 // AIDA Detector description implementation 0003 //-------------------------------------------------------------------------- 0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) 0005 // All rights reserved. 0006 // 0007 // For the licensing terms see $DD4hepINSTALL/LICENSE. 0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS. 0009 // 0010 // Author : M.Frank 0011 // 0012 //========================================================================== 0013 0014 /** \addtogroup Geant4Action 0015 * 0016 @{ 0017 \package Geant4TVUserParticleHandler 0018 * \brief Rejects to keep particles, which are created outside a tracking cylinder. 0019 * 0020 * 0021 @} 0022 */ 0023 0024 #ifndef DD4HEP_DDG4_GEANT4TVUSERPARTICLEHANDLER_H 0025 #define DD4HEP_DDG4_GEANT4TVUSERPARTICLEHANDLER_H 0026 0027 // Framework include files 0028 #include <DD4hep/Primitives.h> 0029 #include <DD4hep/Volumes.h> 0030 #include <DDG4/Geant4UserParticleHandler.h> 0031 0032 /// Namespace for the AIDA detector description toolkit 0033 namespace dd4hep { 0034 0035 /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit 0036 namespace sim { 0037 0038 /// Rejects to keep particles, which are created outside a tracking volume. 0039 /** Geant4TVUserParticleHandler 0040 * 0041 * TV stands for TrackingVolume ;-) 0042 * 0043 * @author M.Frank 0044 * @version 1.0 0045 */ 0046 class Geant4TVUserParticleHandler : public Geant4UserParticleHandler { 0047 Volume m_trackingVolume; 0048 0049 public: 0050 /// Standard constructor 0051 Geant4TVUserParticleHandler(Geant4Context* context, const std::string& nam); 0052 0053 /// Default destructor 0054 virtual ~Geant4TVUserParticleHandler() {} 0055 0056 /// Post-track action callback 0057 /** Allow the user to force the particle handling in the post track action 0058 * set the reason mask to NULL in order to drop the particle. 0059 * The parent's reasoning mask will be or'ed with the particle's mask 0060 * to preserve the MC truth for the hit creation. 0061 * The default implementation is empty. 0062 * 0063 * Note: The particle passed is a temporary and will be copied if kept. 0064 */ 0065 virtual void end(const G4Track* track, Particle& particle); 0066 0067 /// Post-event action callback: avoid warning (...) was hidden [-Woverloaded-virtual] 0068 virtual void end(const G4Event* event); 0069 0070 }; 0071 } // End namespace sim 0072 } // End namespace dd4hep 0073 0074 #endif // DD4HEP_DDG4_GEANT4TVUSERPARTICLEHANDLER_H 0075 0076 //==================================================================== 0077 // AIDA Detector description implementation 0078 //-------------------------------------------------------------------- 0079 // 0080 // Author : M.Frank 0081 // 0082 //==================================================================== 0083 // Framework include files 0084 //#include <DDG4/Geant4TVUserParticleHandler.h> 0085 #include <DDG4/Factories.h> 0086 #include <DDG4/Geant4Particle.h> 0087 #include <DDG4/Geant4Kernel.h> 0088 #include "Geant4UserParticleHandlerHelper.h" 0089 0090 0091 using namespace dd4hep::sim; 0092 DECLARE_GEANT4ACTION(Geant4TVUserParticleHandler) 0093 0094 /// Standard constructor 0095 Geant4TVUserParticleHandler::Geant4TVUserParticleHandler(Geant4Context* ctxt, const std::string& nam) 0096 : Geant4UserParticleHandler(ctxt,nam) 0097 { 0098 m_trackingVolume = ctxt->kernel().detectorDescription().trackingVolume(); 0099 } 0100 0101 /// Post-track action callback 0102 void Geant4TVUserParticleHandler::end(const G4Track* /* track */, Particle& p) { 0103 0104 std::array<double, 3> start_point = {p.vsx, p.vsy, p.vsz}; 0105 bool starts_in_trk_vol = m_trackingVolume.ptr()->Contains(start_point.data()); 0106 0107 std::array<double, 3> end_point = {p.vex, p.vey, p.vez}; 0108 bool ends_in_trk_vol = m_trackingVolume.ptr()->Contains(end_point.data()); 0109 0110 setReason(p, starts_in_trk_vol, ends_in_trk_vol); 0111 setSimulatorStatus(p, starts_in_trk_vol, ends_in_trk_vol); 0112 } 0113 0114 /// Post-event action callback 0115 void Geant4TVUserParticleHandler::end(const G4Event* /* event */) { 0116 0117 } 0118
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |