Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:13

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 // Class description:
0027 //
0028 // This is a stack class used by G4StackManager. This class object
0029 // stores G4StackedTrack class objects in the form of bi-directional
0030 // linked list.
0031 
0032 // Author: Makoto Asai (SLAC) - 09/Dec/96
0033 // --------------------------------------------------------------------
0034 #ifndef G4TrackStack_hh
0035 #define G4TrackStack_hh 1
0036 
0037 #include <vector>
0038 
0039 #include "G4StackedTrack.hh"
0040 #include "G4Types.hh"
0041 
0042 class G4SmartTrackStack;
0043 
0044 class G4TrackStack : public std::vector<G4StackedTrack>
0045 {
0046   public:
0047 
0048     G4TrackStack() = default;
0049     explicit G4TrackStack(std::size_t n)
0050       : safetyValue1(G4int(4*n/5)),
0051         safetyValue2(G4int(4*n/5-100)), nstick(100) { reserve(n); }
0052    ~G4TrackStack();
0053   
0054     G4TrackStack& operator=(const G4TrackStack&) = delete;
0055     G4bool operator==(const G4TrackStack&) const = delete;
0056     G4bool operator!=(const G4TrackStack&) const = delete;
0057   
0058     inline void PushToStack(const G4StackedTrack& aStackedTrack)
0059       {
0060         push_back(aStackedTrack);
0061         if(size()>maxEntry) maxEntry = size();
0062       }
0063     inline G4StackedTrack PopFromStack()
0064       { G4StackedTrack st = back(); pop_back(); return st; }
0065     void TransferTo(G4TrackStack* aStack);
0066     void TransferTo(G4SmartTrackStack* aStack);
0067   
0068     void clearAndDestroy();
0069 
0070     inline std::size_t GetNTrack() const { return size(); }
0071     inline std::size_t GetMaxNTrack() const { return maxEntry; }
0072     inline G4int GetSafetyValue1() const { return safetyValue1; }
0073     inline G4int GetSafetyValue2() const { return safetyValue2; }
0074     inline G4int GetNStick() const { return nstick; }
0075   
0076     G4double getTotalEnergy() const;
0077     inline void SetSafetyValue2(G4int x) { safetyValue2 = x  < 0 ? 0 : x; }
0078   
0079   private:
0080 
0081     G4int safetyValue1{0};
0082     G4int safetyValue2{0};
0083     G4int nstick{0};
0084     std::size_t maxEntry{0};
0085 };
0086 
0087 #endif