Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4PhysicsTable Class Reference

#include <G4PhysicsTable.hh>

Inheritance diagram for G4PhysicsTable:
Collaboration diagram for G4PhysicsTable:

Public Member Functions

 G4PhysicsTable ()
 
 G4PhysicsTable (size_t cap)
 
virtual ~G4PhysicsTable ()
 
G4PhysicsVector *& operator() (size_t)
 
G4PhysicsVector *const & operator() (size_t) const
 
void clearAndDestroy ()
 
void push_back (G4PhysicsVector *)
 
void insert (G4PhysicsVector *)
 
void insertAt (size_t, G4PhysicsVector *)
 
void resize (size_t, G4PhysicsVector *vec=(G4PhysicsVector *)(0))
 
size_t entries () const
 
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 (size_t i) const
 
void ClearFlag (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 66 of file G4PhysicsTable.hh.

Constructor & Destructor Documentation

G4PhysicsTable::G4PhysicsTable ( )

Definition at line 51 of file G4PhysicsTable.cc.

52  : G4PhysCollection()
53 {
54 }
G4PhysicsTable::G4PhysicsTable ( size_t  cap)
explicit

Definition at line 56 of file G4PhysicsTable.cc.

57  : G4PhysCollection()
58 {
59  reserve(cap);
60  vecFlag.reserve(cap);
61 }
G4FlagCollection vecFlag
G4PhysicsTable::~G4PhysicsTable ( )
virtual

Definition at line 86 of file G4PhysicsTable.cc.

87 {
88  G4PhysCollection::clear();
89  vecFlag.clear();
90 }
G4FlagCollection vecFlag

Member Function Documentation

void G4PhysicsTable::clearAndDestroy ( )

Here is the caller graph for this function:

void G4PhysicsTable::ClearFlag ( size_t  i)

Here is the caller graph for this function:

G4PhysicsVector * G4PhysicsTable::CreatePhysicsVector ( G4int  type)
protected

Definition at line 284 of file G4PhysicsTable.cc.

285 {
286  G4PhysicsVector* pVector = nullptr;
287  switch (type)
288  {
290  pVector = new G4PhysicsLinearVector();
291  break;
292 
293  case T_G4PhysicsLogVector:
294  pVector = new G4PhysicsLogVector();
295  break;
296 
297  case T_G4PhysicsLnVector:
298  pVector = new G4PhysicsLogVector();
299  break;
300 
301  case T_G4PhysicsFreeVector:
302  pVector = new G4PhysicsFreeVector();
303  break;
304 
306  pVector = new G4PhysicsOrderedFreeVector();
307  break;
308 
310  pVector = new G4PhysicsFreeVector();
311  break;
312 
313  default:
314  break;
315  }
316  return pVector;
317 }

Here is the caller graph for this function:

size_t G4PhysicsTable::entries ( ) const

Here is the caller graph for this function:

G4bool G4PhysicsTable::ExistPhysicsTable ( const G4String fileName) const

Definition at line 150 of file G4PhysicsTable.cc.

151 {
152  std::ifstream fIn;
153  G4bool value=true;
154  // open input file
155  fIn.open(fileName,std::ios::in);
156 
157  // check if the file has been opened successfully
158  if (!fIn)
159  {
160  value = false;
161  }
162  fIn.close();
163  return value;
164 }
const XML_Char int const XML_Char * value
Definition: expat.h:331
bool G4bool
Definition: G4Types.hh:79
G4bool G4PhysicsTable::GetFlag ( size_t  i) const

Here is the caller graph for this function:

void G4PhysicsTable::insert ( G4PhysicsVector )

Here is the caller graph for this function:

void G4PhysicsTable::insertAt ( size_t  ,
G4PhysicsVector  
)

Here is the caller graph for this function:

G4bool G4PhysicsTable::isEmpty ( ) const
size_t G4PhysicsTable::length ( ) const

Here is the caller graph for this function:

G4PhysicsVector*& G4PhysicsTable::operator() ( size_t  )
G4PhysicsVector* const& G4PhysicsTable::operator() ( size_t  ) const
void G4PhysicsTable::push_back ( G4PhysicsVector )

Here is the caller graph for this function:

void G4PhysicsTable::ResetFlagArray ( )

Definition at line 274 of file G4PhysicsTable.cc.

275 {
276  size_t tableSize = G4PhysCollection::size();
277  vecFlag.clear();
278  for (size_t idx=0; idx<tableSize; idx++)
279  {
280  vecFlag.push_back(true);
281  }
282 }
G4FlagCollection vecFlag

Here is the caller graph for this function:

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

Definition at line 92 of file G4PhysicsTable.cc.

93 {
94  G4PhysCollection::resize(siz, vec);
95  vecFlag.resize(siz, true);
96 }
G4FlagCollection vecFlag

Here is the caller graph for this function:

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

Definition at line 166 of file G4PhysicsTable.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 98 of file G4PhysicsTable.cc.

100 {
101  std::ofstream fOut;
102 
103  // open output file //
104  if (!ascii)
105  { fOut.open(fileName, std::ios::out|std::ios::binary); }
106  else
107  { fOut.open(fileName, std::ios::out); }
108 
109  // check if the file has been opened successfully
110  if (!fOut)
111  {
112 #ifdef G4VERBOSE
113  G4cerr << "G4PhysicsTable::StorePhysicsTable():";
114  G4cerr << " Cannot open file: " << fileName << G4endl;
115 #endif
116  fOut.close();
117  return false;
118  }
119 
120  // Number of elements
121  size_t tableSize = size();
122  if (!ascii)
123  {
124  fOut.write( (char*)(&tableSize), sizeof tableSize);
125  }
126  else
127  {
128  fOut << tableSize << G4endl;
129  }
130 
131  // Physics Vector
132  for (G4PhysicsTableIterator itr=begin(); itr!=end(); ++itr)
133  {
134  G4int vType = (*itr)->GetType();
135  if (!ascii)
136  {
137  fOut.write( (char*)(&vType), sizeof vType);
138  }
139  else
140  {
141  fOut << vType << G4endl;
142  }
143  (*itr)->Store(fOut,ascii);
144  }
145  fOut.close();
146  return true;
147 }
int G4int
Definition: G4Types.hh:78
G4PhysicsTable::iterator G4PhysicsTableIterator
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr

Here is the caller graph for this function:

Friends And Related Function Documentation

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

Definition at line 248 of file G4PhysicsTable.cc.

250 {
251  // Printout Physics Vector
252  size_t i=0;
253  for (G4PhysicsTableIterator itr=right.begin(); itr!=right.end(); ++itr)
254  {
255  out << std::setw(8) << i << "-th Vector ";
256  out << ": Type " << G4int((*itr)->GetType()) ;
257  out << ": Flag ";
258  if (right.GetFlag(i))
259  {
260  out << " T";
261  }
262  else
263  {
264  out << " F";
265  }
266  out << G4endl;
267  out << *(*itr);
268  i +=1;
269  }
270  out << G4endl;
271  return out;
272 }
int G4int
Definition: G4Types.hh:78
G4PhysicsTable::iterator G4PhysicsTableIterator
#define G4endl
Definition: G4ios.hh:61

Member Data Documentation

G4FlagCollection G4PhysicsTable::vecFlag
protected

Definition at line 132 of file G4PhysicsTable.hh.


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