Geant4-11
Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Friends
G4PhysicsTable Class Reference

#include <G4PhysicsTable.hh>

Inheritance diagram for G4PhysicsTable:

Public Member Functions

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

Protected Member Functions

G4PhysicsVectorCreatePhysicsVector (G4int type, G4bool spline)
 

Protected Attributes

G4FlagCollection vecFlag
 

Private Types

using G4FlagCollection = std::vector< G4bool >
 
using G4PhysCollection = std::vector< G4PhysicsVector * >
 

Friends

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

Detailed Description

Definition at line 55 of file G4PhysicsTable.hh.

Member Typedef Documentation

◆ G4FlagCollection

using G4PhysicsTable::G4FlagCollection = std::vector<G4bool>
private

Definition at line 58 of file G4PhysicsTable.hh.

◆ G4PhysCollection

using G4PhysicsTable::G4PhysCollection = std::vector<G4PhysicsVector*>
private

Definition at line 57 of file G4PhysicsTable.hh.

Constructor & Destructor Documentation

◆ G4PhysicsTable() [1/3]

G4PhysicsTable::G4PhysicsTable ( )

Definition at line 47 of file G4PhysicsTable.cc.

49{}
std::vector< G4PhysicsVector * > G4PhysCollection

◆ G4PhysicsTable() [2/3]

G4PhysicsTable::G4PhysicsTable ( size_t  cap)
explicit

◆ ~G4PhysicsTable()

G4PhysicsTable::~G4PhysicsTable ( )
virtual

Definition at line 60 of file G4PhysicsTable.cc.

61{
62 G4PhysCollection::clear();
63 vecFlag.clear();
64}
G4FlagCollection vecFlag

References vecFlag.

◆ G4PhysicsTable() [3/3]

G4PhysicsTable::G4PhysicsTable ( const G4PhysicsTable )
delete

Member Function Documentation

◆ clearAndDestroy()

void G4PhysicsTable::clearAndDestroy ( )

Referenced by G4hRDEnergyLoss::BuildDEDXTable(), G4hRDEnergyLoss::BuildInverseRangeTable(), G4hImpactIonisation::BuildLambdaTable(), G4hImpactIonisation::BuildLossTable(), G4ParticleHPCaptureData::BuildPhysicsTable(), G4ParticleHPElasticData::BuildPhysicsTable(), G4ParticleHPFissionData::BuildPhysicsTable(), G4ParticleHPInelasticData::BuildPhysicsTable(), G4VLEPTSModel::BuildPhysicsTable(), G4Scintillation::BuildPhysicsTable(), G4OpWLS::BuildPhysicsTable(), G4OpWLS2::BuildPhysicsTable(), G4hRDEnergyLoss::BuildRangeCoeffATable(), G4hRDEnergyLoss::BuildRangeCoeffBTable(), G4hRDEnergyLoss::BuildRangeCoeffCTable(), G4hRDEnergyLoss::BuildRangeTable(), G4LossTableBuilder::BuildTableForModel(), G4hRDEnergyLoss::BuildTimeTables(), G4PolarizedCompton::CleanTable(), G4PolarizedAnnihilation::CleanTables(), G4PolarizedIonisation::CleanTables(), G4PenelopeBremsstrahlungAngular::ClearTables(), G4PenelopeBremsstrahlungFS::ClearTables(), G4VEnergyLossProcess::PreparePhysicsTable(), RetrievePhysicsTable(), G4PhysicsTableHelper::RetrievePhysicsTable(), G4VEmModel::SetCrossSectionTable(), G4Cerenkov::~G4Cerenkov(), G4hImpactIonisation::~G4hImpactIonisation(), G4hRDEnergyLoss::~G4hRDEnergyLoss(), G4NeutronElectronElModel::~G4NeutronElectronElModel(), G4OpWLS::~G4OpWLS(), G4OpWLS2::~G4OpWLS2(), G4ParticleHPCaptureData::~G4ParticleHPCaptureData(), G4ParticleHPElasticData::~G4ParticleHPElasticData(), G4ParticleHPFissionData::~G4ParticleHPFissionData(), G4ParticleHPInelasticData::~G4ParticleHPInelasticData(), G4PenelopeCrossSection::~G4PenelopeCrossSection(), G4PenelopePhotoElectricModel::~G4PenelopePhotoElectricModel(), G4Scintillation::~G4Scintillation(), G4TablesForExtrapolator::~G4TablesForExtrapolator(), G4UPiNuclearCrossSection::~G4UPiNuclearCrossSection(), G4VEmModel::~G4VEmModel(), G4VEnergyLossProcess::~G4VEnergyLossProcess(), G4VLEPTSModel::~G4VLEPTSModel(), and G4VXTRenergyLoss::~G4VXTRenergyLoss().

◆ ClearFlag()

void G4PhysicsTable::ClearFlag ( std::size_t  i)

◆ CreatePhysicsVector()

G4PhysicsVector * G4PhysicsTable::CreatePhysicsVector ( G4int  type,
G4bool  spline 
)
protected

Definition at line 269 of file G4PhysicsTable.cc.

270{
271 G4PhysicsVector* pVector = nullptr;
272 switch(type)
273 {
275 pVector = new G4PhysicsLinearVector(spline);
276 break;
277
279 pVector = new G4PhysicsLogVector(spline);
280 break;
281
282 default:
283 pVector = new G4PhysicsVector(spline);
284 break;
285 }
286 return pVector;
287}
@ T_G4PhysicsLinearVector
@ T_G4PhysicsLogVector

References T_G4PhysicsLinearVector, and T_G4PhysicsLogVector.

Referenced by RetrievePhysicsTable().

◆ entries()

std::size_t G4PhysicsTable::entries ( ) const

◆ ExistPhysicsTable()

G4bool G4PhysicsTable::ExistPhysicsTable ( const G4String fileName) const

Definition at line 129 of file G4PhysicsTable.cc.

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

Referenced by G4VEnergyLossProcess::RetrieveTable().

◆ GetFlag()

G4bool G4PhysicsTable::GetFlag ( std::size_t  i) const

◆ insert()

void G4PhysicsTable::insert ( G4PhysicsVector )

◆ insertAt()

void G4PhysicsTable::insertAt ( std::size_t  ,
G4PhysicsVector  
)

◆ isEmpty()

G4bool G4PhysicsTable::isEmpty ( ) const

◆ length()

std::size_t G4PhysicsTable::length ( ) const

◆ 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()

void G4PhysicsTable::push_back ( G4PhysicsVector )

◆ ResetFlagArray()

void G4PhysicsTable::ResetFlagArray ( )

Definition at line 258 of file G4PhysicsTable.cc.

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

References vecFlag.

Referenced by G4PhysicsTableHelper::PreparePhysicsTable().

◆ resize()

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

Definition at line 67 of file G4PhysicsTable.cc.

68{
69 G4PhysCollection::resize(siz, vec);
70 vecFlag.resize(siz, true);
71}

References vecFlag.

Referenced by G4PhysicsTableHelper::PreparePhysicsTable().

◆ RetrievePhysicsTable()

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

Definition at line 146 of file G4PhysicsTable.cc.

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

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

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

◆ StorePhysicsTable()

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

Definition at line 74 of file G4PhysicsTable.cc.

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

References G4cerr, and G4endl.

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

Friends And Related Function Documentation

◆ operator<<

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

Definition at line 232 of file G4PhysicsTable.cc.

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

Field 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: