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 // Last Modification : 09/Dec/96 M.Asai 00031 // 00032 00033 00034 #ifndef G4TrackStack_h 00035 #define G4TrackStack_h 1 00036 00037 #include "G4StackedTrack.hh" 00038 #include "G4Types.hh" 00039 #include <vector> 00040 00041 class G4SmartTrackStack; 00042 00043 // class description: 00044 // 00045 // This is a stack class used by G4StackManager. This class object 00046 // stores G4StackedTrack class objects in the form of bi-directional 00047 // linked list. 00048 00049 class G4TrackStack : public std::vector<G4StackedTrack> 00050 { 00051 public: 00052 G4TrackStack() : safetyValve1(0), safetyValve2(0), nstick(0) {} 00053 G4TrackStack(size_t n) : safetyValve1(4*n/5), safetyValve2(4*n/5-100), nstick(100) { reserve(n);} 00054 ~G4TrackStack(); 00055 00056 private: 00057 const G4TrackStack & operator=(const G4TrackStack &right); 00058 G4int operator==(const G4TrackStack &right) const; 00059 G4int operator!=(const G4TrackStack &right) const; 00060 00061 public: 00062 void PushToStack(const G4StackedTrack& aStackedTrack) { push_back(aStackedTrack); } 00063 G4StackedTrack PopFromStack() { G4StackedTrack st = back(); pop_back(); return st; } 00064 void TransferTo(G4TrackStack* aStack); 00065 void TransferTo(G4SmartTrackStack* aStack); 00066 00067 void clearAndDestroy(); 00068 private: 00069 G4int safetyValve1; 00070 G4int safetyValve2; 00071 G4int nstick; 00072 00073 public: 00074 G4int GetNTrack() const { return size(); } 00075 G4int GetMaxNTrack() const { return max_size(); } 00076 inline G4int GetSafetyValve1() const { return safetyValve1; } 00077 inline G4int GetSafetyValve2() const { return safetyValve2; } 00078 inline G4int GetNStick() const { return nstick; } 00079 00080 G4double getTotalEnergy(void) const; 00081 void SetSafetyValve2(int x) { safetyValve2 = x < 0 ? 0 : x; } 00082 00083 }; 00084 00085 #endif