Geant4 9.6.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 ()
 
G4PhysicsVector *& operator() (size_t)
 
G4PhysicsVector *constoperator() (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() [1/2]

G4PhysicsTable::G4PhysicsTable ( )

Definition at line 51 of file G4PhysicsTable.cc.

52 : G4PhysCollection()
53{
54}

◆ G4PhysicsTable() [2/2]

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::~G4PhysicsTable ( )
virtual

Definition at line 85 of file G4PhysicsTable.cc.

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

Member Function Documentation

◆ clearAndDestroy()

void G4PhysicsTable::clearAndDestroy ( )

Referenced by G4hRDEnergyLoss::BuildDEDXTable(), G4VeLowEnergyLoss::BuildInverseRangeTable(), G4VEnergyLoss::BuildInverseRangeTable(), G4VeLowEnergyLoss::BuildLabTimeTable(), G4VEnergyLoss::BuildLabTimeTable(), G4ePolarizedIonisation::BuildPhysicsTable(), G4NeutronHPCaptureData::BuildPhysicsTable(), G4NeutronHPElasticData::BuildPhysicsTable(), G4NeutronHPFissionData::BuildPhysicsTable(), G4NeutronHPInelasticData::BuildPhysicsTable(), G4VeLowEnergyLoss::BuildProperTimeTable(), G4VEnergyLoss::BuildProperTimeTable(), G4VeLowEnergyLoss::BuildRangeCoeffATable(), G4VEnergyLoss::BuildRangeCoeffATable(), G4VeLowEnergyLoss::BuildRangeCoeffBTable(), G4VEnergyLoss::BuildRangeCoeffBTable(), G4VeLowEnergyLoss::BuildRangeCoeffCTable(), G4VEnergyLoss::BuildRangeCoeffCTable(), G4VeLowEnergyLoss::BuildRangeTable(), G4VEnergyLoss::BuildRangeTable(), G4LossTableBuilder::BuildTableForModel(), G4PenelopeBremsstrahlungFS::ClearTables(), G4VMscModel::GetParticleChangeForMSC(), G4VRangeToEnergyConverter::operator=(), G4VRangeToEnergyConverter::Reset(), RetrievePhysicsTable(), G4VEmModel::SetCrossSectionTable(), G4VEnergyLossProcess::SetDEDXTable(), G4Cerenkov::~G4Cerenkov(), G4DiffuseElastic::~G4DiffuseElastic(), G4eplusPolarizedAnnihilation::~G4eplusPolarizedAnnihilation(), G4ePolarizedIonisation::~G4ePolarizedIonisation(), G4hImpactIonisation::~G4hImpactIonisation(), G4hRDEnergyLoss::~G4hRDEnergyLoss(), G4KokoulinMuonNuclearXS::~G4KokoulinMuonNuclearXS(), G4NeutronHPCaptureData::~G4NeutronHPCaptureData(), G4NeutronHPElasticData::~G4NeutronHPElasticData(), G4NeutronHPFissionData::~G4NeutronHPFissionData(), G4NeutronHPInelasticData::~G4NeutronHPInelasticData(), G4NuclNuclDiffuseElastic::~G4NuclNuclDiffuseElastic(), G4OpRayleigh::~G4OpRayleigh(), G4OpWLS::~G4OpWLS(), G4PAIModel::~G4PAIModel(), G4PAIPhotonModel::~G4PAIPhotonModel(), G4PenelopeCrossSection::~G4PenelopeCrossSection(), G4PenelopePhotoElectricModel::~G4PenelopePhotoElectricModel(), G4PolarizedCompton::~G4PolarizedCompton(), G4Scintillation::~G4Scintillation(), G4UPiNuclearCrossSection::~G4UPiNuclearCrossSection(), G4VEmModel::~G4VEmModel(), G4VEmProcess::~G4VEmProcess(), and G4VEnergyLossProcess::~G4VEnergyLossProcess().

◆ ClearFlag()

◆ CreatePhysicsVector()

G4PhysicsVector * G4PhysicsTable::CreatePhysicsVector ( G4int  type)
protected

Definition at line 283 of file G4PhysicsTable.cc.

284{
285 G4PhysicsVector* pVector=0;
286 switch (type)
287 {
289 pVector = new G4PhysicsLinearVector();
290 break;
291
293 pVector = new G4PhysicsLogVector();
294 break;
295
297 pVector = new G4PhysicsLnVector();
298 break;
299
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}
@ 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 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:67

◆ GetFlag()

◆ insert()

◆ insertAt()

◆ isEmpty()

G4bool G4PhysicsTable::isEmpty ( ) const

◆ length()

◆ operator()() [1/2]

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

◆ operator()() [2/2]

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

◆ push_back()

◆ ResetFlagArray()

void G4PhysicsTable::ResetFlagArray ( )

Definition at line 273 of file G4PhysicsTable.cc.

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}

Referenced by G4PhysicsTableHelper::PreparePhysicsTable().

◆ resize()

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

Definition at line 91 of file G4PhysicsTable.cc.

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

Referenced by G4PhysicsTableHelper::PreparePhysicsTable().

◆ RetrievePhysicsTable()

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

Definition at line 165 of file G4PhysicsTable.cc.

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
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 }
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}
int G4int
Definition: G4Types.hh:66
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cerr
void clearAndDestroy()
G4PhysicsVector * CreatePhysicsVector(G4int type)
virtual G4bool Retrieve(std::ifstream &fIn, G4bool ascii=false)

Referenced by G4PhysicsTableHelper::RetrievePhysicsTable().

◆ StorePhysicsTable()

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

Definition at line 97 of file G4PhysicsTable.cc.

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}
G4PhysicsTable::iterator G4PhysicsTableIterator

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 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}

Member Data Documentation

◆ vecFlag

G4FlagCollection G4PhysicsTable::vecFlag
protected

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