Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4PhysicsTable Class Reference

#include <G4PhysicsTable.hh>

+ Inheritance diagram for G4PhysicsTable:

Public Member Functions

 G4PhysicsTable ()
 
 G4PhysicsTable (size_t cap)
 
virtual ~G4PhysicsTable ()
 
 G4PhysicsTable (const G4PhysicsTable &)=delete
 
G4PhysicsTableoperator= (const G4PhysicsTable &)=delete
 
G4PhysicsVector *& operator() (std::size_t)
 
G4PhysicsVector *const & operator() (std::size_t) const
 
void clearAndDestroy ()
 
void push_back (G4PhysicsVector *)
 
void insert (G4PhysicsVector *)
 
void insertAt (std::size_t, G4PhysicsVector *)
 
void resize (std::size_t, G4PhysicsVector *vec=(G4PhysicsVector *)(0))
 
std::size_t entries () const
 
std::size_t length () const
 
G4bool isEmpty () const
 
G4bool ExistPhysicsTable (const G4String &fileName) const
 
G4bool StorePhysicsTable (const G4String &filename, G4bool ascii=false)
 
G4bool RetrievePhysicsTable (const G4String &filename, G4bool ascii=false)
 
void ResetFlagArray ()
 
G4bool GetFlag (std::size_t i) const
 
void ClearFlag (std::size_t i)
 

Protected Member Functions

G4PhysicsVectorCreatePhysicsVector (G4int type)
 

Protected Attributes

G4FlagCollection vecFlag
 

Friends

std::ostream & operator<< (std::ostream &out, G4PhysicsTable &table)
 

Detailed Description

Definition at line 55 of file G4PhysicsTable.hh.

Constructor & Destructor Documentation

◆ G4PhysicsTable() [1/3]

G4PhysicsTable::G4PhysicsTable ( )

Definition at line 50 of file G4PhysicsTable.cc.

51 : G4PhysCollection()
52{}

◆ G4PhysicsTable() [2/3]

G4PhysicsTable::G4PhysicsTable ( size_t  cap)
explicit

◆ ~G4PhysicsTable()

G4PhysicsTable::~G4PhysicsTable ( )
virtual

Definition at line 63 of file G4PhysicsTable.cc.

64{
65 G4PhysCollection::clear();
66 vecFlag.clear();
67}
G4FlagCollection vecFlag

◆ G4PhysicsTable() [3/3]

G4PhysicsTable::G4PhysicsTable ( const G4PhysicsTable )
delete

Member Function Documentation

◆ clearAndDestroy()

◆ ClearFlag()

◆ CreatePhysicsVector()

G4PhysicsVector * G4PhysicsTable::CreatePhysicsVector ( G4int  type)
protected

Definition at line 272 of file G4PhysicsTable.cc.

273{
274 G4PhysicsVector* pVector = nullptr;
275 switch(type)
276 {
278 pVector = new G4PhysicsLinearVector();
279 break;
280
282 pVector = new G4PhysicsLogVector();
283 break;
284
286 pVector = new G4PhysicsLogVector();
287 break;
288
290 pVector = new G4PhysicsFreeVector();
291 break;
292
294 pVector = new G4PhysicsOrderedFreeVector();
295 break;
296
298 pVector = new G4PhysicsFreeVector();
299 break;
300
301 default:
302 break;
303 }
304 return pVector;
305}
@ T_G4LPhysicsFreeVector
@ T_G4PhysicsOrderedFreeVector
@ T_G4PhysicsFreeVector
@ T_G4PhysicsLinearVector
@ T_G4PhysicsLogVector
@ T_G4PhysicsLnVector

Referenced by RetrievePhysicsTable().

◆ entries()

◆ ExistPhysicsTable()

G4bool G4PhysicsTable::ExistPhysicsTable ( const G4String fileName) const

Definition at line 132 of file G4PhysicsTable.cc.

133{
134 std::ifstream fIn;
135 G4bool value = true;
136 // open input file
137 fIn.open(fileName, std::ios::in);
138
139 // check if the file has been opened successfully
140 if(!fIn)
141 {
142 value = false;
143 }
144 fIn.close();
145 return value;
146}
bool G4bool
Definition: G4Types.hh:86

◆ GetFlag()

◆ insert()

◆ insertAt()

◆ isEmpty()

G4bool G4PhysicsTable::isEmpty ( ) const

◆ length()

◆ operator()() [1/2]

G4PhysicsVector *& G4PhysicsTable::operator() ( std::size_t  )

◆ operator()() [2/2]

G4PhysicsVector *const & G4PhysicsTable::operator() ( std::size_t  ) const

◆ operator=()

G4PhysicsTable & G4PhysicsTable::operator= ( const G4PhysicsTable )
delete

◆ push_back()

◆ ResetFlagArray()

void G4PhysicsTable::ResetFlagArray ( )

Definition at line 261 of file G4PhysicsTable.cc.

262{
263 size_t tableSize = G4PhysCollection::size();
264 vecFlag.clear();
265 for(std::size_t idx = 0; idx < tableSize; ++idx)
266 {
267 vecFlag.push_back(true);
268 }
269}

Referenced by G4PhysicsTableHelper::PreparePhysicsTable().

◆ resize()

void G4PhysicsTable::resize ( std::size_t  siz,
G4PhysicsVector vec = (G4PhysicsVector*) (0) 
)

Definition at line 70 of file G4PhysicsTable.cc.

71{
72 G4PhysCollection::resize(siz, vec);
73 vecFlag.resize(siz, true);
74}

Referenced by G4PhysicsTableHelper::PreparePhysicsTable().

◆ RetrievePhysicsTable()

G4bool G4PhysicsTable::RetrievePhysicsTable ( const G4String filename,
G4bool  ascii = false 
)

Definition at line 149 of file G4PhysicsTable.cc.

151{
152 std::ifstream fIn;
153 // open input file
154 if(ascii)
155 {
156 fIn.open(fileName, std::ios::in | std::ios::binary);
157 }
158 else
159 {
160 fIn.open(fileName, std::ios::in);
161 }
162
163 // check if the file has been opened successfully
164 if(!fIn)
165 {
166#ifdef G4VERBOSE
167 G4cerr << "G4PhysicsTable::RetrievePhysicsTable():";
168 G4cerr << " Cannot open file: " << fileName << G4endl;
169#endif
170 fIn.close();
171 return false;
172 }
173
174 // clear
176
177 // Number of elements
178 std::size_t tableSize = 0;
179 if(!ascii)
180 {
181 fIn.read((char*) (&tableSize), sizeof tableSize);
182 }
183 else
184 {
185 fIn >> tableSize;
186 }
187 reserve(tableSize);
188 vecFlag.clear();
189
190 // Physics Vector
191 for(std::size_t idx = 0; idx < tableSize; ++idx)
192 {
193 G4int vType = 0;
194 if(!ascii)
195 {
196 fIn.read((char*) (&vType), sizeof vType);
197 }
198 else
199 {
200 fIn >> vType;
201 }
203 if(pVec == nullptr)
204 {
205#ifdef G4VERBOSE
206 G4cerr << "G4PhysicsTable::RetrievePhysicsTable():";
207 G4cerr << " Illegal Physics Vector type: " << vType << " in: ";
208 G4cerr << fileName << G4endl;
209#endif
210 fIn.close();
211 return false;
212 }
213
214 if(!(pVec->Retrieve(fIn, ascii)))
215 {
216#ifdef G4VERBOSE
217 G4cerr << "G4PhysicsTable::RetrievePhysicsTable():";
218 G4cerr << " Rrror in retreiving " << idx
219 << "-th Physics Vector from file: ";
220 G4cerr << fileName << G4endl;
221#endif
222 fIn.close();
223 return false;
224 }
225
226 // add a PhysicsVector to this PhysicsTable
227 G4PhysCollection::push_back(pVec);
228 vecFlag.push_back(true);
229 }
230 fIn.close();
231 return true;
232}
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
void clearAndDestroy()
G4PhysicsVector * CreatePhysicsVector(G4int type)
virtual G4bool Retrieve(std::ifstream &fIn, G4bool ascii=false)

Referenced by G4DNABornExcitationModel2::Initialise(), and G4PhysicsTableHelper::RetrievePhysicsTable().

◆ StorePhysicsTable()

G4bool G4PhysicsTable::StorePhysicsTable ( const G4String filename,
G4bool  ascii = false 
)

Definition at line 77 of file G4PhysicsTable.cc.

78{
79 std::ofstream fOut;
80
81 // open output file
82 if(!ascii)
83 {
84 fOut.open(fileName, std::ios::out | std::ios::binary);
85 }
86 else
87 {
88 fOut.open(fileName, std::ios::out);
89 }
90
91 // check if the file has been opened successfully
92 if(!fOut)
93 {
94#ifdef G4VERBOSE
95 G4cerr << "G4PhysicsTable::StorePhysicsTable():";
96 G4cerr << " Cannot open file: " << fileName << G4endl;
97#endif
98 fOut.close();
99 return false;
100 }
101
102 // Number of elements
103 std::size_t tableSize = size();
104 if(!ascii)
105 {
106 fOut.write((char*) (&tableSize), sizeof tableSize);
107 }
108 else
109 {
110 fOut << tableSize << G4endl;
111 }
112
113 // Physics Vector
114 for(auto itr = cbegin(); itr != cend(); ++itr)
115 {
116 G4int vType = (*itr)->GetType();
117 if(!ascii)
118 {
119 fOut.write((char*) (&vType), sizeof vType);
120 }
121 else
122 {
123 fOut << vType << G4endl;
124 }
125 (*itr)->Store(fOut, ascii);
126 }
127 fOut.close();
128 return true;
129}

Referenced by G4VEmProcess::StorePhysicsTable(), and G4VMultipleScattering::StorePhysicsTable().

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  out,
G4PhysicsTable table 
)
friend

Definition at line 235 of file G4PhysicsTable.cc.

236{
237 // Printout Physics Vector
238 std::size_t i = 0;
239 for(auto itr = right.cbegin(); itr != right.cend(); ++itr)
240 {
241 out << std::setw(8) << i << "-th Vector ";
242 out << ": Type " << G4int((*itr)->GetType());
243 out << ": Flag ";
244 if(right.GetFlag(i))
245 {
246 out << " T";
247 }
248 else
249 {
250 out << " F";
251 }
252 out << G4endl;
253 out << *(*itr);
254 ++i;
255 }
256 out << G4endl;
257 return out;
258}

Member Data Documentation

◆ vecFlag

G4FlagCollection G4PhysicsTable::vecFlag
protected

Definition at line 119 of file G4PhysicsTable.hh.

Referenced by ResetFlagArray(), resize(), RetrievePhysicsTable(), and ~G4PhysicsTable().


The documentation for this class was generated from the following files: