ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4PhysicsTable.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4PhysicsTable.hh
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 //
28 //
29 // ------------------------------------------------------------
30 // GEANT 4 class header file
31 //
32 // Class description:
33 //
34 // G4PhysicsTable is an utility class for storage of pointers
35 // to G4PhysicsVector containers. It derives all functionalities
36 // of STL vector containers with the addition of few methods for
37 // compatibility with previous implementation based on Rogue-Wave
38 // pointer collections.
39 // The constructor given the 'capacity' of the table, pre-allocates
40 // memory for the specified value by invoking the STL's reserve()
41 // function, in order to avoid reallocation during insertions.
42 // G4PhysicsTable has a vector of boolean which are used
43 // as 'recalc-needed' flags when processes calculate physics tables.
44 // ------------------------------------------------------------
45 //
46 // History:
47 // -------
48 // - First implementation, based on object model of
49 // 2nd December 1995. G.Cosmo
50 // - 1st March 1996, modified. K.Amako
51 // - 24th February 2001, migration to STL vectors. H.Kurashige
52 // - 9th March 2001, added Store/RetrievePhysicsTable. H.Kurashige
53 // - 20th August 2004, added FlagArray and related methods H.Kurashige
54 //-------------------------------------
55 
56 #ifndef G4PhysicsTable_h
57 #define G4PhysicsTable_h 1
58 
59 #include <vector>
60 #include "globals.hh"
61 #include "G4ios.hh"
62 
63 class G4PhysicsVector;
64 
65 class G4PhysicsTable : public std::vector<G4PhysicsVector*>
66 {
67 
68  typedef std::vector<G4PhysicsVector*> G4PhysCollection;
69  typedef std::vector<G4bool> G4FlagCollection;
70 
71  public: // with description
72 
74  // Default constructor.
75 
76  explicit G4PhysicsTable(size_t cap);
77  // Constructor with capacity. Reserves memory for the
78  // specified capacity.
79 
80  virtual ~G4PhysicsTable();
81  // Destructor.
82  // Does not invoke deletion of contained pointed collections.
83 
84  G4PhysicsVector*& operator()(size_t);
85  G4PhysicsVector* const& operator()(size_t) const;
86  // Access operators.
87 
88  void clearAndDestroy();
89  // Removes all items and deletes them at the same time.
90 
91  void push_back( G4PhysicsVector* );
92  void insert (G4PhysicsVector*);
93  // Pushes new element to collection.
94 
95  void insertAt (size_t, G4PhysicsVector*);
96  // insert element at the specified position in the collection.
97 
98  void resize(size_t, G4PhysicsVector* vec = (G4PhysicsVector*)(0));
99  // resize collection
100 
101  size_t entries() const;
102  size_t length() const;
103  // Return collection's size.
104 
105  G4bool isEmpty() const;
106  // Flags if collection is empty or not.
107 
108  G4bool ExistPhysicsTable(const G4String& fileName) const;
109  // Check if the specified file exists or not
110 
111  G4bool StorePhysicsTable(const G4String& filename, G4bool ascii=false);
112  // Stores PhysicsTable in a file (returns false in case of failure).
113 
114  G4bool RetrievePhysicsTable(const G4String& filename, G4bool ascii=false);
115  // Retrieves Physics from a file (returns false in case of failure).
116 
117  void ResetFlagArray();
118  // Reset the array of flags and all flags are set "true"
119  // This flag is supposed to be used as "recalc-needed" flag
120  // associated with each physics vector
121 
122  G4bool GetFlag(size_t i) const;
123  void ClearFlag(size_t i);
124  // Get/Clear the flag for the 'i-th' physics vector
125 
126  friend std::ostream& operator<<(std::ostream& out, G4PhysicsTable& table);
127 
128  protected:
129 
132 
133  private:
134 
135  G4PhysicsTable(const G4PhysicsTable&) = delete;
136  G4PhysicsTable& operator=(const G4PhysicsTable&) = delete;
137  // Private copy constructor and assignment operator.
138 
139 };
140 
141 typedef G4PhysicsTable::iterator G4PhysicsTableIterator;
142 
143 #include "G4PhysicsVector.hh"
144 #include "G4PhysicsTable.icc"
145 
146 #endif