Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:17:27

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 Geant4TCUserParticleHandler
0018  * \brief Rejects to keep particles, which are created outside a tracking cylinder.
0019  *
0020  *
0021 @}
0022  */
0023 
0024 #ifndef DD4HEP_DDG4_GEANT4TCUSERPARTICLEHANDLER_H
0025 #define DD4HEP_DDG4_GEANT4TCUSERPARTICLEHANDLER_H
0026 
0027 // Framework include files
0028 #include <DD4hep/Primitives.h>
0029 #include <DDG4/Geant4UserParticleHandler.h>
0030 
0031 /// Namespace for the AIDA detector description toolkit
0032 namespace dd4hep {
0033 
0034   /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit
0035   namespace sim {
0036 
0037     ///  Rejects to keep particles, which are created outside a tracking cylinder.
0038     /** Geant4TCUserParticleHandler
0039      *
0040      *  TC stands for TrackingCylinder ;-)
0041      *
0042      * @author  M.Frank
0043      * @version 1.0
0044      */
0045     class Geant4TCUserParticleHandler : public Geant4UserParticleHandler  {
0046       double m_zTrackerMin, m_zTrackerMax, m_rTracker;
0047     public:
0048       /// Standard constructor
0049       Geant4TCUserParticleHandler(Geant4Context* context, const std::string& nam);
0050 
0051       /// Default destructor
0052       virtual ~Geant4TCUserParticleHandler() {}
0053 
0054       /// Post-track action callback
0055       /** Allow the user to force the particle handling in the post track action
0056        *  set the reason mask to NULL in order to drop the particle.
0057        *  The parent's reasoning mask will be or'ed with the particle's mask
0058        *  to preserve the MC truth for the hit creation.
0059        *  The default implementation is empty.
0060        *
0061        *  Note: The particle passed is a temporary and will be copied if kept.
0062        */
0063       virtual void end(const G4Track* track, Particle& particle);
0064 
0065       /// Post-event action callback: avoid warning (...) was hidden [-Woverloaded-virtual]
0066       virtual void end(const G4Event* event);
0067 
0068     };
0069   }    // End namespace sim
0070 }      // End namespace dd4hep
0071 
0072 #endif // DD4HEP_DDG4_GEANT4TCUSERPARTICLEHANDLER_H
0073 
0074 //====================================================================
0075 //  AIDA Detector description implementation
0076 //--------------------------------------------------------------------
0077 //
0078 //  Author     : M.Frank
0079 //
0080 //====================================================================
0081 // Framework include files
0082 //#include <DDG4/Geant4TCUserParticleHandler.h>
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 /// Standard constructor
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 /// Post-track action callback
0101 void Geant4TCUserParticleHandler::end(const G4Track* /* track */, 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 /// Post-event action callback
0122 void Geant4TCUserParticleHandler::end(const G4Event* /* event */)   {
0123 
0124 }
0125