Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-01 08:18:58

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 Geant4UserParticleHandler
0018  * \brief Geant4ParticleHandler user extension action called by the particle handler.
0019  *
0020  *
0021 @}
0022  */
0023 
0024 
0025 #ifndef DDG4_GEANT4USERPARTICLEHANDLER_H
0026 #define DDG4_GEANT4USERPARTICLEHANDLER_H
0027 
0028 // Framework include files
0029 #include <DDG4/Geant4Data.h>
0030 #include <DDG4/Geant4Action.h>
0031 
0032 // Forward declarations
0033 class G4Step;
0034 class G4Track;
0035 class G4Event;
0036 class G4SteppingManager;
0037 
0038 
0039 /// Namespace for the AIDA detector description toolkit
0040 namespace dd4hep {
0041 
0042   /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit
0043   namespace sim {
0044 
0045     // Forward declarations
0046     class Geant4Particle;
0047     class Geant4ParticleHandler;
0048     class Geant4SensDetActionSequence;
0049 
0050     /// Geant4ParticleHandler user extension action called by the particle handler.
0051     /**
0052      *  Collect optional MC particle information and attach it to the particle object
0053      *  Clients may inherit from this class and override the approriate methods
0054      *  to add additional information in form of a DataExtension object to the Particle.
0055      *
0056      *  The default implementation is always empty!
0057      *
0058      * @author  M.Frank
0059      * @version 1.0
0060      */
0061     class Geant4UserParticleHandler : public Geant4Action  {
0062     public:
0063       typedef Geant4Particle Particle;
0064 
0065     protected:
0066       /// Property: Energy cut below which particles are not collected, but assigned to the parent
0067       double m_kinEnergyCut;
0068 
0069     public:
0070       /// Standard constructor
0071       Geant4UserParticleHandler(Geant4Context* context, const std::string& nam);
0072       /// Default destructor
0073       virtual ~Geant4UserParticleHandler();
0074       /// Event generation action callback
0075       virtual void generate(G4Event* event, Geant4ParticleHandler* handler);
0076       /// Pre-event action callback
0077       virtual void begin(const G4Event* event);
0078       /// Post-event action callback
0079       virtual void end(const G4Event* event);
0080 
0081       /// User stepping callback
0082       /** Allow the user to intercept particle handling in the pre track action.
0083        *  The default implementation is empty.
0084        *
0085        *  Note: The particle passed is a temporary and will be copied if kept.
0086        */
0087       virtual void step(const G4Step* step, G4SteppingManager* mgr, Particle& particle);
0088 
0089       /// Pre-track action callback.
0090       /** Allow the user to intercept particle handling in the pre track action.
0091        *  e.g. attach relevant user information.
0092        *  The default implementation is empty.
0093        *
0094        *  Note: The particle passed is a temporary and will be copied if kept.
0095        */
0096       virtual void begin(const G4Track* track, Particle& particle);
0097 
0098       /// Post-track action callback
0099       /** Allow the user to force the particle handling in the post track action
0100        *  set the reason mask to NULL in order to drop the particle.
0101        *  The parent's reasoning mask will be or'ed with the particle's mask
0102        *  to preserve the MC truth for the hit creation.
0103        *  The default implementation is empty.
0104        *
0105        *  Note: The particle passed is a temporary and will be copied if kept.
0106        */
0107       virtual void end(const G4Track* track, Particle& particle);
0108 
0109       /// Callback to be answered if the particle MUST be kept during recombination step
0110       /** Allow the user to force the particle handling either by
0111        *  or the reason mask with G4PARTICLE_KEEP_USER or
0112        *  to set the reason mask to NULL in order to drop it.
0113        *  The default implementation is empty.
0114        *
0115        *  If the reason mask entry is set to G4PARTICLE_FORCE_KILL
0116        *  or is set to NULL, the particle is ALWAYS removed
0117        *
0118        *  The default implementation calls
0119        *  Geant4ParticleHandler::defaultKeepParticle(particle)
0120        *  Please have a look therein if it suffices your needs!
0121        *
0122        *  Note: This may override all other decisions!
0123        *        Default implementation is empty.
0124        *
0125        */
0126       virtual bool keepParticle(Particle& particle);
0127 
0128       /// Callback when parent should be combined
0129       /** Called before a particle is removed from the final record.
0130        *  Relevant particle properties of the parent may be updated.
0131        *  The default implementation is empty.
0132        */
0133       virtual void combine(Particle& to_be_deleted, Particle& remaining_parent);
0134 
0135       /// User overload to handle particle settings when processing the track in the Geant4ParticleHandler.
0136       /** Called when a particle should be modified during the tracking
0137        *  to e.g. change the particle reason mask.
0138        *  Default implementation is empty.
0139        */
0140       virtual void mark_track(const G4Track* track, Particle* current_track);
0141       
0142     };
0143   }    // End namespace sim
0144 }      // End namespace dd4hep
0145 
0146 #endif // DDG4_GEANT4USERPARTICLEHANDLER_H