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 // Last Modification : 04/Oct/11 P. Mato - making use of G4TrackStack with value semantics 00031 00032 00033 #ifndef G4StackManager_h 00034 #define G4StackManager_h 1 00035 00036 #include "G4UserStackingAction.hh" 00037 #include "G4StackedTrack.hh" 00038 #include "G4TrackStack.hh" 00039 #include "G4SmartTrackStack.hh" 00040 #include "G4ClassificationOfNewTrack.hh" 00041 #include "G4Track.hh" 00042 #include "G4TrackStatus.hh" 00043 #include "globals.hh" 00044 #include "evmandefs.hh" 00045 00046 class G4StackingMessenger; 00047 class G4VTrajectory; 00048 00049 // class description: 00050 // 00051 // This is the manager class of handling stacks of G4Track objects. 00052 // This class must be a singleton and be constructed by G4EventManager. 00053 // Almost all methods must be invoked exclusively by G4EventManager. 00054 // Especially, some Clear() methods MUST NOT be invoked by the user. 00055 // Event abortion is handled by G4EventManager. 00056 // 00057 // This G4StackingManager has three stacks, the urgent stack, the 00058 // waiting stack, and the postpone to next event stack. The meanings 00059 // of each stack is descrived in the Geant4 user's manual. 00060 // 00061 00062 class G4StackManager 00063 { 00064 public: 00065 G4StackManager(); 00066 ~G4StackManager(); 00067 00068 private: 00069 const G4StackManager& operator=(const G4StackManager &right); 00070 G4int operator==(const G4StackManager &right) const; 00071 G4int operator!=(const G4StackManager &right) const; 00072 00073 public: 00074 G4int PushOneTrack(G4Track *newTrack, G4VTrajectory *newTrajectory = 0); 00075 G4Track * PopNextTrack(G4VTrajectory**newTrajectory); 00076 G4int PrepareNewEvent(); 00077 00078 public: // with description 00079 void ReClassify(); 00080 // Send all tracks stored in the Urgent stack one by one to 00081 // the user's concrete ClassifyNewTrack() method. This method 00082 // can be invoked from the user's G4UserStackingAction concrete 00083 // class, especially fron its NewStage() method. Be aware that 00084 // when the urgent stack becomes empty, all tracks in the waiting 00085 // stack are send to the urgent stack and then the user's NewStage() 00086 // method is invoked. 00087 00088 void SetNumberOfAdditionalWaitingStacks(G4int iAdd); 00089 // Set the number of additional (optional) waiting stacks. 00090 // This method must be invoked at PreInit, Init or Idle states. 00091 // Once the user set the number of additional waiting stacks, 00092 // he/she can use the corresponding ENUM in G4ClassificationOfNewTrack. 00093 // The user should invoke G4RunManager::SetNumberOfAdditionalWaitingStacks 00094 // method, which invokes this method. 00095 00096 void TransferStackedTracks(G4ClassificationOfNewTrack origin, G4ClassificationOfNewTrack destination); 00097 // Transfter all stacked tracks from the origin stack to the destination stack. 00098 // The destination stack needs not be empty. 00099 // If the destination is fKill, tracks are deleted. 00100 // If the origin is fKill, nothing happen. 00101 00102 void TransferOneStackedTrack(G4ClassificationOfNewTrack origin, G4ClassificationOfNewTrack destination); 00103 // Transfter one stacked track from the origin stack to the destination stack. 00104 // The transfered track is the one which came last to the origin stack. 00105 // The destination stack needs not be empty. 00106 // If the destination is fKill, the track is deleted. 00107 // If the origin is fKill, nothing happen. 00108 00109 private: 00110 G4UserStackingAction * userStackingAction; 00111 G4int verboseLevel; 00112 #ifdef G4_USESMARTSTACK 00113 G4SmartTrackStack * urgentStack; 00114 #else 00115 G4TrackStack * urgentStack; 00116 #endif 00117 G4TrackStack * waitingStack; 00118 G4TrackStack * postponeStack; 00119 G4StackingMessenger* theMessenger; 00120 std::vector<G4TrackStack*> additionalWaitingStacks; 00121 G4int numberOfAdditionalWaitingStacks; 00122 00123 public: 00124 void clear(); 00125 void ClearUrgentStack(); 00126 void ClearWaitingStack(int i=0); 00127 void ClearPostponeStack(); 00128 G4int GetNTotalTrack() const; 00129 G4int GetNUrgentTrack() const; 00130 G4int GetNWaitingTrack(int i=0) const; 00131 G4int GetNPostponedTrack() const; 00132 void SetVerboseLevel( G4int const value ); 00133 void SetUserStackingAction(G4UserStackingAction* value); 00134 00135 private: 00136 G4ClassificationOfNewTrack DefaultClassification(G4Track *aTrack); 00137 }; 00138 00139 #endif 00140