[816] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // |
---|
| 27 | // $Id: G4EventManager.hh,v 1.22 2007/03/08 23:56:12 asaim Exp $ |
---|
| 28 | // GEANT4 tag $Name: $ |
---|
| 29 | // |
---|
| 30 | // |
---|
| 31 | |
---|
| 32 | |
---|
| 33 | #ifndef G4EventManager_h |
---|
| 34 | #define G4EventManager_h 1 |
---|
| 35 | |
---|
| 36 | #include "evmandefs.hh" |
---|
| 37 | #include "G4StackManager.hh" |
---|
| 38 | #include "G4TrajectoryContainer.hh" |
---|
| 39 | #include "G4PrimaryTransformer.hh" |
---|
| 40 | class G4Event; |
---|
| 41 | class G4UserEventAction; |
---|
| 42 | class G4UserStackingAction; |
---|
| 43 | class G4UserTrackingAction; |
---|
| 44 | class G4UserSteppingAction; |
---|
| 45 | class G4EvManMessenger; |
---|
| 46 | #include "G4TrackingManager.hh" |
---|
| 47 | #include "G4Track.hh" |
---|
| 48 | #include "G4VTrajectory.hh" |
---|
| 49 | #include "G4TrackStatus.hh" |
---|
| 50 | class G4SDManager; |
---|
| 51 | #include "globals.hh" |
---|
| 52 | class G4VUserEventInformation; |
---|
| 53 | |
---|
| 54 | #ifdef CLHEP_HepMC // Temporarly disabled |
---|
| 55 | #include "CLHEP/HepMC/GenEvent.h" |
---|
| 56 | #endif |
---|
| 57 | |
---|
| 58 | // class description: |
---|
| 59 | // |
---|
| 60 | // G4EventManager controls an event. This class must be a singleton |
---|
| 61 | // and should be constructed by G4RunManager. |
---|
| 62 | // |
---|
| 63 | |
---|
| 64 | class G4EventManager |
---|
| 65 | { |
---|
| 66 | public: // with description |
---|
| 67 | static G4EventManager* GetEventManager(); |
---|
| 68 | // This method returns the singleton pointer of G4EventManager. |
---|
| 69 | |
---|
| 70 | private: |
---|
| 71 | static G4EventManager* fpEventManager; |
---|
| 72 | |
---|
| 73 | public: |
---|
| 74 | G4EventManager(); |
---|
| 75 | ~G4EventManager(); |
---|
| 76 | |
---|
| 77 | private: |
---|
| 78 | G4EventManager(const G4EventManager &right); |
---|
| 79 | G4EventManager& operator=(const G4EventManager& right); |
---|
| 80 | |
---|
| 81 | public: // with description |
---|
| 82 | void ProcessOneEvent(G4Event* anEvent); |
---|
| 83 | // This method is the main entry to this class for simulating an event. |
---|
| 84 | |
---|
| 85 | #ifdef CLHEP_HepMC // Temporarly disabled on Windows, until CLHEP |
---|
| 86 | // will support the HepMC module |
---|
| 87 | void ProcessOneEvent(const HepMC::GenEvent* hepmcevt,G4Event* anEvent=0); |
---|
| 88 | // This is an alternative entry for large HEP experiments which use |
---|
| 89 | // HepMC event class. Dummy G4Event object will be created if "anEvent" is null |
---|
| 90 | // for internal use, but this dummy object will be deleted at the end of this |
---|
| 91 | // method and will never be available for the use after the processing. |
---|
| 92 | // Note that in this case of null G4Event pointer no output of the simulated event |
---|
| 93 | // is returned by this method, but the user must implement some mechanism |
---|
| 94 | // of storing output by his/herself, e.g. in his/her UserEventAction and/or |
---|
| 95 | // sensitive detectors. |
---|
| 96 | // If valid G4Event object is given, this object will not be deleted with |
---|
| 97 | // this method and output objects such as hits collections and trajectories |
---|
| 98 | // will be associated to this event object. If this event object has valid |
---|
| 99 | // primary vertices/particles, they will be added to the given HepMC event input. |
---|
| 100 | #endif |
---|
| 101 | |
---|
| 102 | void ProcessOneEvent(G4TrackVector* trackVector,G4Event* anEvent=0); |
---|
| 103 | // This is an alternative entry for large HEP experiments which create G4Track |
---|
| 104 | // objects by themselves directly without using G4VPrimaryGenerator or user |
---|
| 105 | // primary generator action. Dummy G4Event object will be created if "anEvent" is null |
---|
| 106 | // for internal use, but this dummy object will be deleted at the end of this |
---|
| 107 | // method and will never be available for the use after the processing. |
---|
| 108 | // Note that in this case of null G4Event pointer no output of the simulated event |
---|
| 109 | // is returned by this method, but the user must implement some mechanism |
---|
| 110 | // of storing output by his/herself, e.g. in his/her UserEventAction and/or |
---|
| 111 | // sensitive detectors. |
---|
| 112 | // If valid G4Event object is given, this object will not be deleted with |
---|
| 113 | // this method and output objects such as hits collections and trajectories |
---|
| 114 | // will be associated to this event object. If this event object has valid |
---|
| 115 | // primary vertices/particles, they will be added to the given trackvector input. |
---|
| 116 | |
---|
| 117 | private: |
---|
| 118 | void DoProcessing(G4Event* anEvent); |
---|
| 119 | void StackTracks(G4TrackVector *trackVector, G4bool IDhasAlreadySet=false); |
---|
| 120 | |
---|
| 121 | G4Event* currentEvent; |
---|
| 122 | |
---|
| 123 | G4StackManager *trackContainer; |
---|
| 124 | G4TrackingManager *trackManager; |
---|
| 125 | G4TrajectoryContainer *trajectoryContainer; |
---|
| 126 | G4int trackIDCounter; |
---|
| 127 | G4int verboseLevel; |
---|
| 128 | G4SDManager* sdManager; |
---|
| 129 | G4PrimaryTransformer* transformer; |
---|
| 130 | G4bool tracking; |
---|
| 131 | G4bool abortRequested; |
---|
| 132 | |
---|
| 133 | G4EvManMessenger* theMessenger; |
---|
| 134 | |
---|
| 135 | G4UserEventAction* userEventAction; |
---|
| 136 | G4UserStackingAction* userStackingAction; |
---|
| 137 | G4UserTrackingAction* userTrackingAction; |
---|
| 138 | G4UserSteppingAction* userSteppingAction; |
---|
| 139 | |
---|
| 140 | G4int storetRandomNumberStatusToG4Event; |
---|
| 141 | G4String randomNumberStatusToG4Event; |
---|
| 142 | |
---|
| 143 | public: // with description |
---|
| 144 | inline const G4Event* GetConstCurrentEvent() |
---|
| 145 | { return currentEvent; } |
---|
| 146 | inline G4Event* GetNonconstCurrentEvent() |
---|
| 147 | { return currentEvent; } |
---|
| 148 | // These methods returns the pointers of const G4Event* |
---|
| 149 | // and G4Event*, respectively. Null will be returned when |
---|
| 150 | // an event is not processing. |
---|
| 151 | |
---|
| 152 | public: // with description |
---|
| 153 | inline void AbortCurrentEvent() |
---|
| 154 | { |
---|
| 155 | abortRequested = true; |
---|
| 156 | trackContainer->clear(); |
---|
| 157 | if(tracking) trackManager->EventAborted(); |
---|
| 158 | } |
---|
| 159 | // This method aborts the processing of the current event. All stacked |
---|
| 160 | // tracks are deleted. The contents of G4Event object is not completed, |
---|
| 161 | // but trajectories, hits, and/or digits which are created before the |
---|
| 162 | // moment of abortion can be used. |
---|
| 163 | |
---|
| 164 | public: // with description |
---|
| 165 | void SetUserAction(G4UserEventAction* userAction); |
---|
| 166 | void SetUserAction(G4UserStackingAction* userAction); |
---|
| 167 | void SetUserAction(G4UserTrackingAction* userAction); |
---|
| 168 | void SetUserAction(G4UserSteppingAction* userAction); |
---|
| 169 | inline G4UserEventAction* GetUserEventAction() |
---|
| 170 | { return userEventAction; } |
---|
| 171 | inline G4UserStackingAction* GetUserStackingAction() |
---|
| 172 | { return userStackingAction; } |
---|
| 173 | inline G4UserTrackingAction* GetUserTrackingAction() |
---|
| 174 | { return userTrackingAction; } |
---|
| 175 | inline G4UserSteppingAction* GetUserSteppingAction() |
---|
| 176 | { return userSteppingAction; } |
---|
| 177 | // Set and get methods for user action classes. User action classes |
---|
| 178 | // which should belong to the other managers will be sent to the |
---|
| 179 | // corresponding managers. |
---|
| 180 | void SetNumberOfAdditionalWaitingStacks(G4int iAdd) |
---|
| 181 | { trackContainer->SetNumberOfAdditionalWaitingStacks(iAdd); } |
---|
| 182 | |
---|
| 183 | void KeepTheCurrentEvent(); |
---|
| 184 | // If the current event exists, it is kept undeleted until the end of the current run |
---|
| 185 | |
---|
| 186 | inline G4StackManager* GetStackManager() const |
---|
| 187 | { return trackContainer; } |
---|
| 188 | inline G4TrackingManager* GetTrackingManager() const |
---|
| 189 | { return trackManager; } |
---|
| 190 | |
---|
| 191 | public: // with description |
---|
| 192 | inline G4int GetVerboseLevel() |
---|
| 193 | { return verboseLevel; } |
---|
| 194 | inline void SetVerboseLevel( G4int value ) |
---|
| 195 | { |
---|
| 196 | verboseLevel = value; |
---|
| 197 | trackContainer->SetVerboseLevel( value ); |
---|
| 198 | transformer->SetVerboseLevel( value ); |
---|
| 199 | } |
---|
| 200 | // Set and get method of the verbose level |
---|
| 201 | |
---|
| 202 | void SetUserInformation(G4VUserEventInformation* anInfo); |
---|
| 203 | G4VUserEventInformation* GetUserInformation(); |
---|
| 204 | // Set and get method of G4VUserEventInformation object associating with |
---|
| 205 | // the current event. Both methods are valid only for G4State_EventProc |
---|
| 206 | // application state. |
---|
| 207 | |
---|
| 208 | inline G4PrimaryTransformer* GetPrimaryTransformer() const |
---|
| 209 | { return transformer; } |
---|
| 210 | inline void SetPrimaryTransformer(G4PrimaryTransformer* tf) |
---|
| 211 | { transformer = tf; } |
---|
| 212 | inline void StoreRandomNumberStatusToG4Event(G4int vl) |
---|
| 213 | { storetRandomNumberStatusToG4Event = vl; } |
---|
| 214 | }; |
---|
| 215 | |
---|
| 216 | |
---|
| 217 | |
---|
| 218 | #endif |
---|
| 219 | |
---|