00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // 00027 // $Id$ 00028 // 00029 // 00030 00031 00032 #ifndef G4EventManager_h 00033 #define G4EventManager_h 1 00034 00035 #include "evmandefs.hh" 00036 #include "G4StackManager.hh" 00037 #include "G4TrajectoryContainer.hh" 00038 #include "G4PrimaryTransformer.hh" 00039 class G4Event; 00040 class G4UserEventAction; 00041 class G4UserStackingAction; 00042 class G4UserTrackingAction; 00043 class G4UserSteppingAction; 00044 class G4EvManMessenger; 00045 #include "G4TrackingManager.hh" 00046 #include "G4Track.hh" 00047 #include "G4VTrajectory.hh" 00048 #include "G4TrackStatus.hh" 00049 class G4SDManager; 00050 #include "globals.hh" 00051 class G4VUserEventInformation; 00052 00053 // class description: 00054 // 00055 // G4EventManager controls an event. This class must be a singleton 00056 // and should be constructed by G4RunManager. 00057 // 00058 00059 class G4EventManager 00060 { 00061 public: // with description 00062 static G4EventManager* GetEventManager(); 00063 // This method returns the singleton pointer of G4EventManager. 00064 00065 private: 00066 static G4EventManager* fpEventManager; 00067 00068 public: 00069 G4EventManager(); 00070 ~G4EventManager(); 00071 00072 private: 00073 G4EventManager(const G4EventManager &right); 00074 G4EventManager& operator=(const G4EventManager& right); 00075 00076 public: // with description 00077 void ProcessOneEvent(G4Event* anEvent); 00078 // This method is the main entry to this class for simulating an event. 00079 00080 void ProcessOneEvent(G4TrackVector* trackVector,G4Event* anEvent=0); 00081 // This is an alternative entry for large HEP experiments which create G4Track 00082 // objects by themselves directly without using G4VPrimaryGenerator or user 00083 // primary generator action. Dummy G4Event object will be created if "anEvent" is null 00084 // for internal use, but this dummy object will be deleted at the end of this 00085 // method and will never be available for the use after the processing. 00086 // Note that in this case of null G4Event pointer no output of the simulated event 00087 // is returned by this method, but the user must implement some mechanism 00088 // of storing output by his/herself, e.g. in his/her UserEventAction and/or 00089 // sensitive detectors. 00090 // If valid G4Event object is given, this object will not be deleted with 00091 // this method and output objects such as hits collections and trajectories 00092 // will be associated to this event object. If this event object has valid 00093 // primary vertices/particles, they will be added to the given trackvector input. 00094 00095 private: 00096 void DoProcessing(G4Event* anEvent); 00097 void StackTracks(G4TrackVector *trackVector, G4bool IDhasAlreadySet=false); 00098 00099 G4Event* currentEvent; 00100 00101 G4StackManager *trackContainer; 00102 G4TrackingManager *trackManager; 00103 G4TrajectoryContainer *trajectoryContainer; 00104 G4int trackIDCounter; 00105 G4int verboseLevel; 00106 G4SDManager* sdManager; 00107 G4PrimaryTransformer* transformer; 00108 G4bool tracking; 00109 G4bool abortRequested; 00110 00111 G4EvManMessenger* theMessenger; 00112 00113 G4UserEventAction* userEventAction; 00114 G4UserStackingAction* userStackingAction; 00115 G4UserTrackingAction* userTrackingAction; 00116 G4UserSteppingAction* userSteppingAction; 00117 00118 G4int storetRandomNumberStatusToG4Event; 00119 G4String randomNumberStatusToG4Event; 00120 00121 public: // with description 00122 inline const G4Event* GetConstCurrentEvent() 00123 { return currentEvent; } 00124 inline G4Event* GetNonconstCurrentEvent() 00125 { return currentEvent; } 00126 // These methods returns the pointers of const G4Event* 00127 // and G4Event*, respectively. Null will be returned when 00128 // an event is not processing. 00129 00130 public: // with description 00131 void AbortCurrentEvent(); 00132 // This method aborts the processing of the current event. All stacked 00133 // tracks are deleted. The contents of G4Event object is not completed, 00134 // but trajectories, hits, and/or digits which are created before the 00135 // moment of abortion can be used. 00136 00137 public: // with description 00138 void SetUserAction(G4UserEventAction* userAction); 00139 void SetUserAction(G4UserStackingAction* userAction); 00140 void SetUserAction(G4UserTrackingAction* userAction); 00141 void SetUserAction(G4UserSteppingAction* userAction); 00142 inline G4UserEventAction* GetUserEventAction() 00143 { return userEventAction; } 00144 inline G4UserStackingAction* GetUserStackingAction() 00145 { return userStackingAction; } 00146 inline G4UserTrackingAction* GetUserTrackingAction() 00147 { return userTrackingAction; } 00148 inline G4UserSteppingAction* GetUserSteppingAction() 00149 { return userSteppingAction; } 00150 // Set and get methods for user action classes. User action classes 00151 // which should belong to the other managers will be sent to the 00152 // corresponding managers. 00153 void SetNumberOfAdditionalWaitingStacks(G4int iAdd) 00154 { trackContainer->SetNumberOfAdditionalWaitingStacks(iAdd); } 00155 00156 void KeepTheCurrentEvent(); 00157 // If the current event exists, it is kept undeleted until the end of the current run 00158 00159 inline G4StackManager* GetStackManager() const 00160 { return trackContainer; } 00161 inline G4TrackingManager* GetTrackingManager() const 00162 { return trackManager; } 00163 00164 public: // with description 00165 inline G4int GetVerboseLevel() 00166 { return verboseLevel; } 00167 inline void SetVerboseLevel( G4int value ) 00168 { 00169 verboseLevel = value; 00170 trackContainer->SetVerboseLevel( value ); 00171 transformer->SetVerboseLevel( value ); 00172 } 00173 // Set and get method of the verbose level 00174 00175 void SetUserInformation(G4VUserEventInformation* anInfo); 00176 G4VUserEventInformation* GetUserInformation(); 00177 // Set and get method of G4VUserEventInformation object associating with 00178 // the current event. Both methods are valid only for G4State_EventProc 00179 // application state. 00180 00181 inline G4PrimaryTransformer* GetPrimaryTransformer() const 00182 { return transformer; } 00183 inline void SetPrimaryTransformer(G4PrimaryTransformer* tf) 00184 { transformer = tf; } 00185 inline void StoreRandomNumberStatusToG4Event(G4int vl) 00186 { storetRandomNumberStatusToG4Event = vl; } 00187 }; 00188 00189 00190 00191 #endif 00192