|
||||
File indexing completed on 2025-01-18 09:55:24
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 Geant4ParticleHandler 0018 * \brief Geant4Action to collect the MC particle information. 0019 * 0020 * 0021 @} 0022 */ 0023 0024 #ifndef DDG4_GEANT4PARTICLEHANDLER_H 0025 #define DDG4_GEANT4PARTICLEHANDLER_H 0026 0027 // Framework include files 0028 #include <DDG4/Geant4Primary.h> 0029 #include <DDG4/Geant4GeneratorAction.h> 0030 #include <DDG4/Geant4MonteCarloTruth.h> 0031 0032 // Forward declarations 0033 class G4Step; 0034 class G4Track; 0035 class G4Event; 0036 class G4SteppingManager; 0037 0038 /// Namespace for the AIDA detector description toolkit 0039 namespace dd4hep { 0040 0041 /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit 0042 namespace sim { 0043 0044 // Forward declarations 0045 class Geant4UserParticleHandler; 0046 0047 /// Geant4Action to collect the MC particle information. 0048 /** 0049 * Extract the relevant particle information during the simulation step. 0050 * 0051 * This procedure works as follows: 0052 * - At the beginning of the event generation the object registers itself as 0053 * Monte-Carlo truth handler to the event context. 0054 * - At the begin of each track action a particle candidate is created and filled 0055 * with all properties known at this time. 0056 * - At each stepping action a flag is set if the step produced secondaries. 0057 * - Sensitive detectors call the MC truth handler if a hit was created. 0058 * This fact is remembered. 0059 * - At the end of the tracking action a first decision is taken if the candidate is to be 0060 * kept for the final record. 0061 * - At the end of the event action finally all particles are reduced to the 0062 * final record. This logic can be overridden by a user handler to be attached. 0063 * . 0064 * Any of these actions may be intercepted by a {\tt{Geant4UserParticleHandler}} 0065 * attached to the particle handler. 0066 * See class {\tt{Geant4UserParticleHandler}} for details. 0067 * 0068 * \author M.Frank 0069 * \version 1.0 0070 * \ingroup DD4HEP_SIMULATION 0071 */ 0072 class Geant4ParticleHandler : public Geant4GeneratorAction, public Geant4MonteCarloTruth { 0073 public: 0074 typedef Geant4ParticleMap::Particle Particle; 0075 typedef Geant4ParticleMap::ParticleMap ParticleMap; 0076 typedef Geant4ParticleMap::TrackEquivalents TrackEquivalents; 0077 #if defined(__CINT__) || defined(__MAKECINT__) || defined(G__DICTIONARY) 0078 // Need to force to public for the ROOT dictionary 0079 public: 0080 #else 0081 private: 0082 #endif 0083 /// No default constructor 0084 Geant4ParticleHandler(); 0085 /// No assignment operator 0086 Geant4ParticleHandler& operator=(const Geant4ParticleHandler& c); 0087 0088 public: 0089 typedef std::vector<std::string> Processes; 0090 0091 protected: 0092 0093 /** Property variables used to configure the object */ 0094 /// Property: Steer printout at tracking action begin 0095 bool m_printStartTracking; 0096 /// Property: Steer printout at tracking action end 0097 bool m_printEndTracking; 0098 /// Property: Flag to keep all particles generated 0099 bool m_keepAll; 0100 /// Property: Flag if the handler is executed in standalone mode and hence must manage particles 0101 bool m_ownsParticles; 0102 /// Property: Energy cut below which particles are not collected, but assigned to the parent 0103 double m_kinEnergyCut; 0104 /// Property: Minimal distance after which the vertexIsNotEndpointOfParent flag is set 0105 double m_minDistToParentVertex; 0106 /// Property: All the processes of which the decay products will be explicitly stored 0107 Processes m_processNames; 0108 0109 /** Object variables, which are constant after initialization */ 0110 /// User action pointer 0111 Geant4UserParticleHandler* m_userHandler; 0112 0113 /** EVENT DEPENDENT: variables containing data depending on the current event. */ 0114 /// Global particle identifier. Obtained at the begin of the event. 0115 int m_globalParticleID; 0116 /// Primary map 0117 Geant4PrimaryMap* m_primaryMap; 0118 /// Local buffer about the 'current' G4Track 0119 Particle m_currTrack; 0120 /// Map with stored MC Particles 0121 ParticleMap m_particleMap; 0122 /// Map with stored MC Particles that were suspended by the stepping action 0123 ParticleMap m_suspendedPM; 0124 bool m_haveSuspended = false; 0125 /// Map associating the G4Track identifiers with identifiers of existing MCParticles 0126 TrackEquivalents m_equivalentTracks; 0127 0128 /// Recombine particles and associate the to parents with cleanup 0129 int recombineParents(); 0130 /// Clear particle maps 0131 void clear(); 0132 /// Check the record consistency 0133 void checkConsistency() const; 0134 0135 /// Rebase the simulated tracks, so that they fit to the generator particles 0136 void rebaseSimulatedTracks(int base); 0137 /// Debugging: Dump Geant4 particle map 0138 void dumpMap(const char* tag) const; 0139 0140 /// set the endpointIsNotVertexOfParentFlag at the end of the event 0141 void setVertexEndpointBit(); 0142 0143 public: 0144 /// Standard constructor 0145 Geant4ParticleHandler(Geant4Context* context, const std::string& nam); 0146 /// Default destructor 0147 virtual ~Geant4ParticleHandler(); 0148 /// Adopt the user particle handler 0149 bool adopt(Geant4Action* action); 0150 /// Event generation action callback 0151 virtual void operator()(G4Event* event); 0152 /// User stepping callback 0153 virtual void step(const G4Step* step, G4SteppingManager* mgr); 0154 /// Pre-event action callback 0155 virtual void beginEvent(const G4Event* event); 0156 /// Post-event action callback 0157 virtual void endEvent(const G4Event* event); 0158 /// Pre-track action callback 0159 virtual void begin(const G4Track* track); 0160 /// Post-track action callback 0161 virtual void end(const G4Track* track); 0162 0163 /// Mark a Geant4 track to be kept for later MC truth analysis. Default flag: CREATED_HIT 0164 virtual void mark(const G4Track* track); 0165 /// Store a track 0166 virtual void mark(const G4Track* track, int reason); 0167 /// Mark a Geant4 track of the step to be kept for later MC truth analysis. Default flag: CREATED_HIT 0168 virtual void mark(const G4Step* step); 0169 /// Store a track produced in a step to be kept for later MC truth analysis 0170 virtual void mark(const G4Step* step, int reason); 0171 0172 /// Default callback to be answered if the particle should be kept if NO user handler is installed 0173 static bool defaultKeepParticle(Particle& particle); 0174 0175 }; 0176 } // End namespace sim 0177 } // End namespace dd4hep 0178 0179 #endif // DDG4_GEANT4PARTICLEHANDLER_H
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |