Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/Geant4/G4EventManager.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4EventManager
0027 //
0028 // Class description:
0029 //
0030 // G4EventManager controls an event. This class must be a singleton
0031 // and should be constructed by G4RunManager.
0032 
0033 // Author: M.Asai, SLAC
0034 // --------------------------------------------------------------------
0035 #ifndef G4EventManager_hh
0036 #define G4EventManager_hh 1
0037 
0038 #include "G4StackManager.hh"
0039 #include "G4TrajectoryContainer.hh"
0040 #include "G4PrimaryTransformer.hh"
0041 #include "G4Event.hh"
0042 class G4UserEventAction;
0043 class G4UserStackingAction;
0044 class G4UserTrackingAction;
0045 class G4UserSteppingAction;
0046 class G4EvManMessenger;
0047 #include "G4TrackingManager.hh"
0048 #include "G4Track.hh"
0049 #include "G4VTrajectory.hh"
0050 #include "G4TrackStatus.hh"
0051 class G4SDManager;
0052 class G4StateManager;
0053 #include "globals.hh"
0054 class G4VUserEventInformation;
0055 
0056 class G4EventManager 
0057 {
0058  public:
0059     static G4EventManager* GetEventManager();
0060       // This method returns the singleton pointer of G4EventManager.
0061 
0062     G4EventManager();
0063    ~G4EventManager();
0064 
0065     G4EventManager(const G4EventManager &right) = delete;
0066     G4EventManager& operator=(const G4EventManager& right) = delete;
0067 
0068     void ProcessOneEvent(G4Event* anEvent);
0069       // This method is the main entry to this class for simulating an event.
0070 
0071     void ProcessOneEvent(G4TrackVector* trackVector, G4Event* anEvent= nullptr);
0072       // This is an alternative entry for HEP experiments which create G4Track
0073       // objects by themselves directly without using G4VPrimaryGenerator or a
0074       // user-primary-generator action. Dummy G4Event object will be created if
0075       // "anEvent" is null for internal use, but this dummy object will be
0076       // deleted at the end of this method and will never be available for use
0077       // after the processing.
0078       // Note that in this case of null G4Event pointer, no output of the
0079       // simulated event is returned by this method; the user must implement
0080       // some mechanism of storing the output, e.g. in the UserEventAction
0081       // and/or in sensitive detectors.
0082       // If a valid G4Event object is given, this object will not be deleted
0083       // by this method, and output objects such as hits collections and
0084       // trajectories will be associated to the event object. If the event
0085       // object has valid primary vertices/particles, they will be added to
0086       // the given "trackvector" input.
0087 
0088     void StackTracks(G4TrackVector* trackVector, G4bool IDhasAlreadySet= false);
0089       // Helper function to stack a vector of tracks for processing in the
0090       // current event.
0091 
0092     inline const G4Event* GetConstCurrentEvent()
0093       { return currentEvent; }
0094     inline G4Event* GetNonconstCurrentEvent()
0095       { return currentEvent; }
0096       // These methods returns the pointers of const G4Event*
0097       // and G4Event*, respectively. Null will be returned when
0098       // an event is not processing.
0099 
0100     void AbortCurrentEvent();
0101       // This method aborts the processing of the current event. All stacked
0102       // tracks are deleted. The contents of G4Event object is not completed,
0103       // but trajectories, hits, and/or digits which are created before the
0104       // moment of abortion can be used.
0105 
0106     void SetUserAction(G4UserEventAction* userAction);
0107     void SetUserAction(G4UserStackingAction* userAction);
0108     void SetUserAction(G4UserTrackingAction* userAction);
0109     void SetUserAction(G4UserSteppingAction* userAction);
0110     inline G4UserEventAction* GetUserEventAction()
0111       { return userEventAction; }
0112     inline G4UserStackingAction* GetUserStackingAction()
0113       { return userStackingAction; }
0114     inline G4UserTrackingAction* GetUserTrackingAction()
0115       { return userTrackingAction; }
0116     inline G4UserSteppingAction* GetUserSteppingAction()
0117       { return userSteppingAction; }
0118       // Set and get methods for user action classes. User action classes
0119       // which should belong to the other managers will be sent to the 
0120       // corresponding managers.
0121 
0122     void KeepTheCurrentEvent();
0123       // If the current event exists, it is kept undeleted until
0124       // the end of the current run
0125 
0126     inline G4StackManager* GetStackManager() const
0127       { return trackContainer; }
0128     inline G4TrackingManager* GetTrackingManager() const
0129       { return trackManager; }
0130 
0131     inline G4int GetVerboseLevel()
0132       { return verboseLevel; }
0133     inline void SetVerboseLevel( G4int value )
0134       {
0135         verboseLevel = value;
0136         trackContainer->SetVerboseLevel( value );
0137         transformer->SetVerboseLevel( value );
0138       }
0139       // Set and get method of the verbose level
0140 
0141     void SetUserInformation(G4VUserEventInformation* anInfo);
0142     G4VUserEventInformation* GetUserInformation();
0143       // Set and get method of G4VUserEventInformation object associating with
0144       // the current event. Both methods are valid only for G4State_EventProc
0145       // application state.
0146 
0147     inline G4PrimaryTransformer* GetPrimaryTransformer() const
0148       { return transformer; }
0149     inline void SetPrimaryTransformer(G4PrimaryTransformer* tf)
0150       { transformer = tf; }
0151     inline void StoreRandomNumberStatusToG4Event(G4int vl)
0152       { storetRandomNumberStatusToG4Event = vl; }
0153 
0154     inline void UseSubEventParallelism(G4bool worker = false)
0155       {
0156         subEventPara = true; 
0157         subEventParaWorker = worker;
0158       }
0159 
0160     G4SubEvent* PopSubEvent(G4int ty);
0161       // If this method is invoked by the G4RunManager while an event is still 
0162       // in process. Null is returned if the sub-event does not have enough tracks.
0163       // This method is Mutex-protected.
0164 
0165     void TerminateSubEvent(const G4SubEvent* se,const G4Event* evt);
0166       // G4Event "evt" contains the results made by the worker thread.
0167       // The ownership of "evt" remains to the worker thread and it will be
0168       // deleted after this method. All necessary information in "evt" must
0169       // be copied into the corresponding master G4Event object.
0170 
0171     G4int StoreSubEvent(G4Event*, G4int&, G4SubEvent*);
0172       // This method is exclusively used by G4SubEventTrackStack class to 
0173       // store a new G4SubEevnt into the current G4Event, with Mutex lock
0174       // shared with above two methods.
0175 
0176   private:
0177 
0178     void DoProcessing(G4Event* anEvent,
0179            G4TrackVector* trackVector = nullptr, G4bool IDhasAlreadySet= false);
0180   
0181   private:
0182 
0183     static G4ThreadLocal G4EventManager* fpEventManager;
0184 
0185     G4Event* currentEvent = nullptr;
0186 
0187     G4StackManager* trackContainer = nullptr;
0188     G4TrackingManager* trackManager = nullptr;
0189     G4TrajectoryContainer* trajectoryContainer = nullptr;
0190     G4int trackIDCounter = 0;
0191     G4int verboseLevel = 0;
0192     G4SDManager* sdManager = nullptr;
0193     G4PrimaryTransformer* transformer = nullptr;
0194     G4bool tracking = false;
0195     G4bool abortRequested = false;
0196     G4bool subEventPara = false;
0197     G4bool subEventParaWorker = false;
0198     G4int evID_inSubEv = -1;
0199 
0200     G4EvManMessenger* theMessenger = nullptr;
0201 
0202     G4UserEventAction*    userEventAction = nullptr;
0203     G4UserStackingAction* userStackingAction = nullptr;
0204     G4UserTrackingAction* userTrackingAction = nullptr;
0205     G4UserSteppingAction* userSteppingAction = nullptr;
0206 
0207     G4int storetRandomNumberStatusToG4Event = 0;
0208     G4String randomNumberStatusToG4Event;
0209 
0210     G4StateManager* stateManager = nullptr;
0211 };
0212 
0213 #endif