Back to home page

EIC code displayed by LXR

 
 

    


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 #ifndef DDG4_GEANT4TESTACTIONS_H
0014 #define DDG4_GEANT4TESTACTIONS_H
0015 
0016 // Framework include files
0017 #include <DDG4/Geant4Handle.h>
0018 #include <DDG4/Geant4Kernel.h>
0019 #include <DDG4/Geant4GeneratorAction.h>
0020 #include <DDG4/Geant4RunAction.h>
0021 #include <DDG4/Geant4EventAction.h>
0022 #include <DDG4/Geant4TrackingAction.h>
0023 #include <DDG4/Geant4SteppingAction.h>
0024 #include <DDG4/Geant4StackingAction.h>
0025 #include <DDG4/Geant4ActionPhase.h>
0026 #include <DDG4/Geant4SensDetAction.h>
0027 
0028 /// Namespace for the AIDA detector description toolkit
0029 namespace dd4hep {
0030 
0031   /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit
0032   namespace sim {
0033 
0034     /// Convenience namespace to separate test classes from the DDG4 simulation toolkit
0035     namespace Test {
0036 
0037       /// Common base class for test action
0038       /**
0039        *  \author  M.Frank
0040        *  \version 1.0
0041        *  \ingroup DD4HEP_SIMULATION
0042        */
0043       class Geant4TestBase {
0044       protected:
0045         int m_value1;
0046         double m_value2;
0047         std::string m_value3;
0048         std::string m_type;
0049       public:
0050         /// Standard constructor
0051         Geant4TestBase(Geant4Action* action, const std::string& typ);
0052         /// Default destructor
0053         virtual ~Geant4TestBase();
0054       };
0055 
0056       /// Example generator action doing nothing, but print
0057       /**
0058        *  \author  M.Frank
0059        *  \version 1.0
0060        *  \ingroup DD4HEP_SIMULATION
0061        */
0062       class Geant4TestGeneratorAction: public Geant4GeneratorAction, public Geant4TestBase {
0063       public:
0064         /// Standard constructor with initializing arguments
0065         Geant4TestGeneratorAction(Geant4Context* c, const std::string& n);
0066         /// Default destructor
0067         virtual ~Geant4TestGeneratorAction();
0068         /// Callback to generate primary particles
0069         virtual void operator()(G4Event*);
0070       };
0071 
0072       /// Example run action doing nothing, but print
0073       /**
0074        *  \author  M.Frank
0075        *  \version 1.0
0076        *  \ingroup DD4HEP_SIMULATION
0077        */
0078       class Geant4TestRunAction: public Geant4RunAction, public Geant4TestBase {
0079       public:
0080         /// Standard constructor with initializing arguments
0081         Geant4TestRunAction(Geant4Context* c, const std::string& n);
0082         /// Default destructor
0083         virtual ~Geant4TestRunAction();
0084         /// begin-of-run callback
0085         void begin(const G4Run*);
0086         /// End-of-run callback
0087         void end(const G4Run*);
0088         /// begin-of-event callback
0089         void beginEvent(const G4Event*);
0090         /// End-of-event callback
0091         void endEvent(const G4Event*);
0092       };
0093 
0094       /// Example event action doing nothing, but print
0095       /**
0096        *  \author  M.Frank
0097        *  \version 1.0
0098        *  \ingroup DD4HEP_SIMULATION
0099        */
0100       class Geant4TestEventAction: public Geant4EventAction, public Geant4TestBase {
0101       public:
0102         /// Standard constructor with initializing arguments
0103         Geant4TestEventAction(Geant4Context* c, const std::string& n);
0104         /// Default destructor
0105         virtual ~Geant4TestEventAction();
0106         /// begin-of-event callback
0107         virtual void begin(const G4Event*);
0108         /// End-of-event callback
0109         virtual void end(const G4Event*);
0110         /// begin-of-run callback
0111         void beginRun(const G4Run*);
0112         /// End-of-run callback
0113         void endRun(const G4Run*);
0114       };
0115 
0116       /// Example tracking action doing nothing, but print
0117       /**
0118        *  \author  M.Frank
0119        *  \version 1.0
0120        *  \ingroup DD4HEP_SIMULATION
0121 
0122        */
0123       class Geant4TestTrackAction: public Geant4TrackingAction, public Geant4TestBase {
0124       public:
0125         /// Standard constructor with initializing arguments
0126         Geant4TestTrackAction(Geant4Context* c, const std::string& n);
0127         /// Default destructor
0128         virtual ~Geant4TestTrackAction();
0129         /// Begin-of-tracking callback
0130         virtual void begin(const G4Track*)  override;
0131         /// End-of-tracking callback
0132         virtual void end(const G4Track*)  override;
0133       };
0134 
0135       /// Example stepping action doing nothing, but print
0136       /**
0137        *  \author  M.Frank
0138        *  \version 1.0
0139        *  \ingroup DD4HEP_SIMULATION
0140        */
0141       class Geant4TestStepAction: public Geant4SteppingAction, public Geant4TestBase {
0142       public:
0143         /// Standard constructor with initializing arguments
0144         Geant4TestStepAction(Geant4Context* c, const std::string& n);
0145         /// Default destructor
0146         virtual ~Geant4TestStepAction();
0147         /// User stepping callback
0148         void operator()(const G4Step*, G4SteppingManager*)  override;
0149       };
0150 
0151       /// Example stacking action doing nothing, but print
0152       /**
0153        *  \author  M.Frank
0154        *  \version 1.0
0155        *  \ingroup DD4HEP_SIMULATION
0156        */
0157       class Geant4TestStackAction: public Geant4StackingAction, public Geant4TestBase {
0158       public:
0159         /// Standard constructor with initializing arguments
0160         Geant4TestStackAction(Geant4Context* c, const std::string& n);
0161         /// Default destructor
0162         virtual ~Geant4TestStackAction();
0163         /// New-stage callback
0164         virtual void newStage(G4StackManager*)  override;
0165         /// Preparation callback
0166         virtual void prepare(G4StackManager*)  override;
0167         /// Return TrackClassification with enum G4ClassificationOfNewTrack or NoTrackClassification
0168         virtual TrackClassification classifyNewTrack(G4StackManager*, const G4Track*)  override;
0169       };
0170 
0171       /// Example sensitve detector action doing nothing, but print
0172       /**
0173        *  \author  M.Frank
0174        *  \version 1.0
0175        *  \ingroup DD4HEP_SIMULATION
0176        */
0177       class Geant4TestSensitive: public Geant4Sensitive, public Geant4TestBase {
0178       protected:
0179         size_t m_collectionID;
0180       public:
0181         /// Standard constructor with initializing arguments
0182         Geant4TestSensitive(Geant4Context* c, const std::string& n, DetElement det, Detector& description);
0183         /// Default destructor
0184         virtual ~Geant4TestSensitive();
0185         /// Begin-of-tracking callback
0186         virtual void begin(G4HCofThisEvent*)  override;
0187         /// End-of-tracking callback
0188         virtual void end(G4HCofThisEvent*)  override;
0189         /// Method for generating hit(s) using the information of G4Step object.
0190         virtual bool process(const G4Step*, G4TouchableHistory*)  override;
0191       };
0192     }   // End namespace Test
0193   }    // End namespace sim
0194 }      // End namespace dd4hep
0195 
0196 #endif // DDG4_GEANT4TESTACTIONS_H