Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | Friends
G4PhysicsTable Class Reference

#include <G4PhysicsTable.hh>

Inheritance 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.

References vecFlag.

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

Definition at line 85 of file G4PhysicsTable.cc.

References vecFlag.

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

Member Function Documentation

void G4PhysicsTable::clearAndDestroy ( )

Referenced by G4eLowEnergyLoss::BuildDEDXTable(), G4hRDEnergyLoss::BuildDEDXTable(), G4RDVeLowEnergyLoss::BuildInverseRangeTable(), G4RDVeLowEnergyLoss::BuildLabTimeTable(), G4NeutronHPFissionData::BuildPhysicsTable(), G4NeutronHPInelasticData::BuildPhysicsTable(), G4NeutronHPCaptureData::BuildPhysicsTable(), G4NeutronHPElasticData::BuildPhysicsTable(), G4ePolarizedIonisation::BuildPhysicsTable(), G4RDVeLowEnergyLoss::BuildProperTimeTable(), G4RDVeLowEnergyLoss::BuildRangeCoeffATable(), G4RDVeLowEnergyLoss::BuildRangeCoeffBTable(), G4RDVeLowEnergyLoss::BuildRangeCoeffCTable(), G4RDVeLowEnergyLoss::BuildRangeTable(), G4LossTableBuilder::BuildTableForModel(), G4VRangeToEnergyConverter::G4VRangeToEnergyConverter(), G4VMscModel::GetParticleChangeForMSC(), G4VRangeToEnergyConverter::operator=(), G4VEnergyLossProcess::PreparePhysicsTable(), G4VRangeToEnergyConverter::Reset(), RetrievePhysicsTable(), G4VEmModel::SetCrossSectionTable(), G4Cerenkov::~G4Cerenkov(), G4DiffuseElastic::~G4DiffuseElastic(), G4eLowEnergyLoss::~G4eLowEnergyLoss(), G4hImpactIonisation::~G4hImpactIonisation(), G4hRDEnergyLoss::~G4hRDEnergyLoss(), G4KokoulinMuonNuclearXS::~G4KokoulinMuonNuclearXS(), G4NeutronHPCaptureData::~G4NeutronHPCaptureData(), G4NeutronHPElasticData::~G4NeutronHPElasticData(), G4NeutronHPFissionData::~G4NeutronHPFissionData(), G4NeutronHPInelasticData::~G4NeutronHPInelasticData(), G4NuclNuclDiffuseElastic::~G4NuclNuclDiffuseElastic(), G4OpRayleigh::~G4OpRayleigh(), G4OpWLS::~G4OpWLS(), G4Scintillation::~G4Scintillation(), and WLSPrimaryGeneratorAction::~WLSPrimaryGeneratorAction().

void G4PhysicsTable::ClearFlag ( size_t  i)
G4PhysicsVector * G4PhysicsTable::CreatePhysicsVector ( G4int  type)
protected

Definition at line 283 of file G4PhysicsTable.cc.

References T_G4LPhysicsFreeVector, T_G4PhysicsFreeVector, T_G4PhysicsLinearVector, T_G4PhysicsLnVector, T_G4PhysicsLogVector, and T_G4PhysicsOrderedFreeVector.

Referenced by RetrievePhysicsTable().

284 {
285  G4PhysicsVector* pVector=0;
286  switch (type)
287  {
289  pVector = new G4PhysicsLinearVector();
290  break;
291 
292  case T_G4PhysicsLogVector:
293  pVector = new G4PhysicsLogVector();
294  break;
295 
296  case T_G4PhysicsLnVector:
297  pVector = new G4PhysicsLnVector();
298  break;
299 
300  case T_G4PhysicsFreeVector:
301  pVector = new G4PhysicsFreeVector();
302  break;
303 
305  pVector = new G4PhysicsOrderedFreeVector();
306  break;
307 
309  pVector = new G4LPhysicsFreeVector();
310  break;
311 
312  default:
313  break;
314  }
315  return pVector;
316 }
size_t G4PhysicsTable::entries ( ) const
G4bool G4PhysicsTable::ExistPhysicsTable ( const G4String fileName) const

Definition at line 149 of file G4PhysicsTable.cc.

150 {
151  std::ifstream fIn;
152  G4bool value=true;
153  // open input file
154  fIn.open(fileName,std::ios::in);
155 
156  // check if the file has been opened successfully
157  if (!fIn)
158  {
159  value = false;
160  }
161  fIn.close();
162  return value;
163 }
bool G4bool
Definition: G4Types.hh:79
const XML_Char int const XML_Char * value
G4bool G4PhysicsTable::GetFlag ( size_t  i) const
void G4PhysicsTable::insert ( G4PhysicsVector )
void G4PhysicsTable::insertAt ( size_t  ,
G4PhysicsVector  
)
G4bool G4PhysicsTable::isEmpty ( ) const
size_t G4PhysicsTable::length ( ) const
G4PhysicsVector*& G4PhysicsTable::operator() ( size_t  )
G4PhysicsVector* const& G4PhysicsTable::operator() ( size_t  ) const
void G4PhysicsTable::push_back ( G4PhysicsVector )
void G4PhysicsTable::ResetFlagArray ( )

Definition at line 273 of file G4PhysicsTable.cc.

References vecFlag.

Referenced by G4PhysicsTableHelper::PreparePhysicsTable().

274 {
275  size_t tableSize = G4PhysCollection::size();
276  vecFlag.clear();
277  for (size_t idx=0; idx<tableSize; idx++)
278  {
279  vecFlag.push_back(true);
280  }
281 }
G4FlagCollection vecFlag
void G4PhysicsTable::resize ( size_t  siz,
G4PhysicsVector vec = (G4PhysicsVector*)(0) 
)

Definition at line 91 of file G4PhysicsTable.cc.

References vecFlag.

Referenced by G4PhysicsTableHelper::PreparePhysicsTable().

92 {
93  G4PhysCollection::resize(siz, vec);
94  vecFlag.resize(siz, true);
95 }
G4FlagCollection vecFlag
G4bool G4PhysicsTable::RetrievePhysicsTable ( const G4String filename,
G4bool  ascii = false 
)

Definition at line 165 of file G4PhysicsTable.cc.

References clearAndDestroy(), CreatePhysicsVector(), G4cerr, G4endl, G4PhysicsVector::Retrieve(), and vecFlag.

Referenced by G4PhysicsTableHelper::RetrievePhysicsTable().

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

Definition at line 97 of file G4PhysicsTable.cc.

References G4cerr, and G4endl.

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

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

Friends And Related Function Documentation

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

Definition at line 247 of file G4PhysicsTable.cc.

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

Field Documentation

G4FlagCollection G4PhysicsTable::vecFlag
protected

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