Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:22

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_GEANT4ACTIONCONTAINER_H
0014 #define DDG4_GEANT4ACTIONCONTAINER_H
0015 
0016 // Framework include files
0017 #include <DD4hep/Printout.h>
0018 #include <DDG4/Geant4Action.h>
0019 #include <DDG4/Geant4Primitives.h>
0020 
0021 // C/C++ include files
0022 #include <map>
0023 #include <string>
0024 #include <typeinfo>
0025 
0026 /// Namespace for the AIDA detector description toolkit
0027 namespace dd4hep {
0028 
0029   /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit
0030   namespace sim {
0031 
0032     // Forward declarations
0033     class Geant4Context;
0034     class Geant4Action;
0035     class Geant4RunAction;
0036     class Geant4EventAction;
0037     class Geant4SteppingAction;
0038     class Geant4TrackingAction;
0039     class Geant4StackingAction;
0040     class Geant4GeneratorAction;
0041     class Geant4PhysicsList;
0042     class Geant4RunActionSequence;
0043     class Geant4EventActionSequence;
0044     class Geant4SteppingActionSequence;
0045     class Geant4TrackingActionSequence;
0046     class Geant4StackingActionSequence;
0047     class Geant4GeneratorActionSequence;
0048     class Geant4PhysicsListActionSequence;
0049     class Geant4DetectorConstructionSequence;
0050     class Geant4UserInitializationSequence;
0051     class Geant4SensDetActionSequence;
0052     class Geant4SensDetSequences;
0053 
0054     /// Class, which allows all Geant4Action to be stored
0055     /**
0056      *  \author  M.Frank
0057      *  \version 1.0
0058      *  \ingroup DD4HEP_SIMULATION
0059      */
0060     class Geant4ActionContainer {
0061     protected:
0062 
0063       /// Geant4 worker context (thread specific)
0064       Geant4Context*                      m_context             { nullptr };
0065 
0066       /// Reference to the Geant4 primary generator action
0067       Geant4GeneratorActionSequence*      m_generatorAction     { nullptr };
0068       /// Reference to the Geant4 run action
0069       Geant4RunActionSequence*            m_runAction           { nullptr };
0070       /// Reference to the Geant4 event action
0071       Geant4EventActionSequence*          m_eventAction         { nullptr };
0072       /// Reference to the Geant4 track action
0073       Geant4TrackingActionSequence*       m_trackingAction      { nullptr };
0074       /// Reference to the Geant4 step action
0075       Geant4SteppingActionSequence*       m_steppingAction      { nullptr };
0076       /// Reference to the Geant4 stacking action
0077       Geant4StackingActionSequence*       m_stackingAction      { nullptr };
0078       /// Reference to the Geant4 detector construction sequence
0079       Geant4DetectorConstructionSequence* m_constructionAction  { nullptr };
0080 
0081       /// Reference to the Geant4 sensitive action sequences
0082       Geant4SensDetSequences*             m_sensDetActions      { nullptr };
0083       /// Reference to the Geant4 physics list
0084       Geant4PhysicsListActionSequence*    m_physicsList         { nullptr };
0085       /// Reference to the user initialization object
0086       Geant4UserInitializationSequence*   m_userInit            { nullptr };
0087 
0088       /// Helper to register an action sequence
0089       template <typename C> bool registerSequence(C*& seq, const std::string& name);
0090 
0091       /// Standard constructor
0092       Geant4ActionContainer(Geant4Context* ctxt=0);
0093 
0094       /// Default destructor
0095       virtual ~Geant4ActionContainer();
0096 
0097       /// Set the thread's context
0098       void setContext(Geant4Context* ctxt);
0099 
0100     public:
0101       /// Thread's Geant4 execution context
0102       Geant4Context* workerContext();
0103 
0104       /// Terminate all associated action instances
0105       virtual int terminate();
0106 
0107       /// Access generator action sequence
0108       Geant4GeneratorActionSequence* generatorAction(bool create);
0109       /// Access generator action sequence
0110       Geant4GeneratorActionSequence& generatorAction() {
0111         return *generatorAction(true);
0112       }
0113 
0114       /// Access run action sequence
0115       Geant4RunActionSequence* runAction(bool create);
0116       /// Access run action sequence
0117       Geant4RunActionSequence& runAction() {
0118         return *runAction(true);
0119       }
0120 
0121       /// Access run action sequence
0122       Geant4EventActionSequence* eventAction(bool create);
0123       /// Access run action sequence
0124       Geant4EventActionSequence& eventAction() {
0125         return *eventAction(true);
0126       }
0127 
0128       /// Access stepping action sequence
0129       Geant4SteppingActionSequence* steppingAction(bool create);
0130       /// Access stepping action sequence
0131       Geant4SteppingActionSequence& steppingAction() {
0132         return *steppingAction(true);
0133       }
0134 
0135       /// Access tracking action sequence
0136       Geant4TrackingActionSequence* trackingAction(bool create);
0137       /// Access tracking action sequence
0138       Geant4TrackingActionSequence& trackingAction() {
0139         return *trackingAction(true);
0140       }
0141 
0142       /// Access stacking action sequence
0143       Geant4StackingActionSequence* stackingAction(bool create);
0144       /// Access stacking action sequence
0145       Geant4StackingActionSequence& stackingAction() {
0146         return *stackingAction(true);
0147       }
0148 
0149       /// Access detector construcion action sequence (geometry+sensitives+field)
0150       Geant4DetectorConstructionSequence* detectorConstruction(bool create);
0151       /// Access detector construcion action sequence (geometry+sensitives+field)
0152       Geant4DetectorConstructionSequence& detectorConstruction() {
0153         return *detectorConstruction(true);
0154       }
0155 
0156       /// Access to the sensitive detector sequences from the actioncontainer object
0157       Geant4SensDetSequences& sensitiveActions() const;
0158       /// Access to the sensitive detector action from the actioncontainer object
0159       Geant4SensDetActionSequence* sensitiveAction(const std::string& name);
0160 
0161       /// Access to the physics list
0162       Geant4PhysicsListActionSequence* physicsList(bool create);
0163       /// Access to the physics list
0164       Geant4PhysicsListActionSequence& physicsList() {
0165         return *physicsList(true);
0166       }
0167       /// Access to the user initialization object
0168       Geant4UserInitializationSequence* userInitialization(bool create);
0169       /// Access to the user initialization object
0170       Geant4UserInitializationSequence& userInitialization() {
0171         return *userInitialization(true);
0172       }
0173     };
0174 
0175   }    // End namespace sim
0176 }      // End namespace dd4hep
0177 #endif // DDG4_GEANT4ACTIONCONTAINER_H