Geant4-11
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Member Functions | Private Attributes
G4eIonisationParameters Class Reference

#include <G4eIonisationParameters.hh>

Public Member Functions

G4double Excitation (G4int Z, G4double e) const
 
 G4eIonisationParameters ()
 
 G4eIonisationParameters (const G4eIonisationParameters &)=delete
 
G4eIonisationParametersoperator= (const G4eIonisationParameters &right)=delete
 
G4double Parameter (G4int Z, G4int shellIndex, G4int parameterIndex, G4double e) const
 
void PrintData () const
 
 ~G4eIonisationParameters ()
 

Private Member Functions

void LoadData ()
 

Private Attributes

G4DataVector activeZ
 
std::map< G4int, G4VEMDataSet *, std::less< G4int > > excit
 
size_t length = 24
 
std::map< G4int, G4VEMDataSet *, std::less< G4int > > param
 

Detailed Description

Definition at line 58 of file G4eIonisationParameters.hh.

Constructor & Destructor Documentation

◆ G4eIonisationParameters() [1/2]

G4eIonisationParameters::G4eIonisationParameters ( )
explicit

Definition at line 63 of file G4eIonisationParameters.cc.

References LoadData().

◆ ~G4eIonisationParameters()

G4eIonisationParameters::~G4eIonisationParameters ( )

Definition at line 70 of file G4eIonisationParameters.cc.

71{
72 // Reset the map of data sets: remove the data sets from the map
73 for (auto& pos : param)
74 {
75 G4VEMDataSet* dataSet = pos.second;
76 delete dataSet;
77 dataSet = nullptr;
78 }
79 for (auto& pos : excit)
80 {
81 G4VEMDataSet* dataSet = pos.second;
82 delete dataSet;
83 dataSet = nullptr;
84 }
85 activeZ.clear();
86}
static const G4double pos
std::map< G4int, G4VEMDataSet *, std::less< G4int > > param
std::map< G4int, G4VEMDataSet *, std::less< G4int > > excit

References activeZ, excit, param, and pos.

◆ G4eIonisationParameters() [2/2]

G4eIonisationParameters::G4eIonisationParameters ( const G4eIonisationParameters )
delete

Member Function Documentation

◆ Excitation()

G4double G4eIonisationParameters::Excitation ( G4int  Z,
G4double  e 
) const

Definition at line 124 of file G4eIonisationParameters.cc.

125{
126 G4double value = 0.;
127 auto pos = excit.find(Z);
128 if (pos!= excit.end()) {
129 G4VEMDataSet* dataSet = (*pos).second;
130
131 const G4DataVector ener = dataSet->GetEnergies(0);
132 G4double ee = std::max(ener.front(),std::min(ener.back(),e));
133 value = dataSet->FindValue(ee);
134 } else {
135 G4cout << "WARNING: G4IonisationParameters::Excitation "
136 << "did not find ID = "
137 << Z << G4endl;
138 }
139
140 return value;
141}
double G4double
Definition: G4Types.hh:83
const G4int Z[17]
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
virtual const G4DataVector & GetEnergies(G4int componentId) const =0
virtual G4double FindValue(G4double x, G4int componentId=0) const =0
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments

References excit, G4VEMDataSet::FindValue(), G4cout, G4endl, G4VEMDataSet::GetEnergies(), G4INCL::Math::max(), G4INCL::Math::min(), pos, and Z.

Referenced by G4eIonisationSpectrum::Excitation().

◆ LoadData()

void G4eIonisationParameters::LoadData ( )
private

Definition at line 145 of file G4eIonisationParameters.cc.

146{
147 // ---------------------------------------
148 // Please document what are the parameters
149 // ---------------------------------------
150
151 // define active elements
152
153 const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
154 if (materialTable == nullptr)
155 G4Exception("G4eIonisationParameters::LoadData",
156 "em1001",FatalException,"Unable to find MaterialTable");
157
159
160 for (G4int mLocal=0; mLocal<nMaterials; mLocal++) {
161
162 const G4Material* material= (*materialTable)[mLocal];
163 const G4ElementVector* elementVector = material->GetElementVector();
164 const size_t nElements = material->GetNumberOfElements();
165
166 for (size_t iEl=0; iEl<nElements; iEl++) {
167 G4double Z = (*elementVector)[iEl]->GetZ();
168 if (!(activeZ.contains(Z))) {
169 activeZ.push_back(Z);
170 }
171 }
172 }
173
174 char* path = std::getenv("G4LEDATA");
175 if (!path)
176 {
177 G4Exception("G4BremsstrahlungParameters::LoadData",
178 "em0006",FatalException,"G4LEDATA environment variable not set");
179 return;
180 }
181
182 G4String pathString(path);
183 G4String path2("/ioni/ion-sp-");
184 pathString += path2;
185
186 G4double energy, sum;
187
188 size_t nZ = activeZ.size();
189
190 for (size_t i=0; i<nZ; i++) {
191
192 G4int Z = (G4int)activeZ[i];
193 std::ostringstream ost;
194 ost << pathString << Z << ".dat";
195 G4String name(ost.str());
196
197 std::ifstream file(name);
198 std::filebuf* lsdp = file.rdbuf();
199
200 if (! (lsdp->is_open()) ) {
201 G4String excep = G4String("data file: ")
202 + name + G4String(" not found");
203 G4Exception("G4eIonisationParameters::LoadData",
204 "em0003",FatalException,excep);
205 }
206
207 // The file is organized into:
208 // For each shell there are two lines:
209 // 1st line:
210 // 1st column is the energy of incident e-,
211 // 2d column is the parameter of screan term;
212 // 2d line:
213 // 3 energy (MeV) subdividing different approximation area of the spectrum
214 // 20 point on the spectrum
215 // The shell terminates with the pattern: -1 -1
216 // The file terminates with the pattern: -2 -2
217
218 std::vector<G4VEMDataSet*> p;
219 for (size_t k=0; k<length; k++)
220 {
222 G4VEMDataSet* composite = new G4CompositeEMDataSet(inter,1.,1.);
223 p.push_back(composite);
224 }
225
226 G4int shell = 0;
227 std::vector<G4DataVector*> a;
228 a.resize(length);
229 G4DataVector e;
230 G4bool isReady = false;
231 do {
232 file >> energy >> sum;
233 //Check if energy is valid
234 if (energy < -2)
235 {
236 G4String excep("invalid data file");
237 G4Exception("G4eIonisationParameters::LoadData",
238 "em0005",FatalException,excep);
239 return;
240 }
241
242 if (energy == -2) break;
243
244 if (energy > -1) {
245 // new energy
246 if(!isReady) {
247 isReady = true;
248 e.clear();
249 for (size_t j=0; j<length; ++j) {
250 a[j] = new G4DataVector();
251 }
252 }
253 e.push_back(energy);
254 a[0]->push_back(sum);
255 for (size_t j=1; j<length; ++j) {
256 G4double qRead;
257 file >> qRead;
258 a[j]->push_back(qRead);
259 }
260
261 } else {
262
263 // End of set for a shell, fill the map
264 for (size_t k=0; k<length; k++) {
265
266 G4VDataSetAlgorithm* interp;
267 if(0 == k) { interp = new G4LinLogLogInterpolation(); }
268 else { interp = new G4LogLogInterpolation(); }
269
270 G4DataVector* eVector = new G4DataVector;
271 size_t eSize = e.size();
272 for (size_t sLocal=0; sLocal<eSize; sLocal++) {
273 eVector->push_back(e[sLocal]);
274 }
275 G4VEMDataSet* set = new G4EMDataSet(shell,eVector,a[k],interp,1.,1.);
276
277 p[k]->AddComponent(set);
278 }
279
280 // next shell
281 ++shell;
282 isReady = false;
283 }
284 } while (energy > -2);
285
286 file.close();
287
288 for (size_t kk=0; kk<length; kk++)
289 {
290 G4int id = Z*100 + kk;
291 param[id] = p[kk];
292 }
293 }
294
295 G4String pathString_a(path);
296 G4String name_a = pathString_a + G4String("/ioni/ion-ex-av.dat");
297 std::ifstream file_a(name_a);
298 std::filebuf* lsdp_a = file_a.rdbuf();
299 G4String pathString_b(path);
300 G4String name_b = pathString_b + G4String("/ioni/ion-ex-sig.dat");
301 std::ifstream file_b(name_b);
302 std::filebuf* lsdp_b = file_b.rdbuf();
303
304 if (! (lsdp_a->is_open()) ) {
305 G4String excep = G4String("cannot open file ")
306 + name_a;
307 G4Exception("G4eIonisationParameters::LoadData",
308 "em0003",FatalException,excep);
309 }
310 if (! (lsdp_b->is_open()) ) {
311 G4String excep = G4String("cannot open file ")
312 + name_b;
313 G4Exception("G4eIonisationParameters::LoadData",
314 "em0003",FatalException,excep);
315 }
316
317 // The file is organized into two columns:
318 // 1st column is the energy
319 // 2nd column is the corresponding value
320 // The file terminates with the pattern: -1 -1
321 // -2 -2
322
323 G4double ener, ener1, sig, sig1;
324 G4int z = 0;
325
326 G4DataVector e;
327 e.clear();
328 G4DataVector d;
329 d.clear();
330
331 do {
332 file_a >> ener >> sig;
333 file_b >> ener1 >> sig1;
334
335 if(ener != ener1) {
336 G4cout << "G4eIonisationParameters: problem in excitation data "
337 << "ener= " << ener
338 << " ener1= " << ener1
339 << G4endl;
340 }
341
342 // End of file
343 if (ener == -2) {
344 break;
345
346 // End of next element
347 } else if (ener == -1) {
348
349 z++;
350 G4double Z = (G4double)z;
351
352 // fill map if Z is used
353 if (activeZ.contains(Z)) {
354
356 G4DataVector* eVector = new G4DataVector;
357 G4DataVector* dVector = new G4DataVector;
358 size_t eSize = e.size();
359 for (size_t sLocal2=0; sLocal2<eSize; sLocal2++) {
360 eVector->push_back(e[sLocal2]);
361 dVector->push_back(d[sLocal2]);
362 }
363 G4VEMDataSet* set = new G4EMDataSet(z,eVector,dVector,inter,1.,1.);
364 excit[z] = set;
365 }
366 e.clear();
367 d.clear();
368
369 } else {
370
371 e.push_back(ener*MeV);
372 d.push_back(sig1*sig*barn*MeV);
373 }
374 } while (ener != -2);
375
376 file_a.close();
377
378}
std::vector< const G4Element * > G4ElementVector
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::vector< G4Material * > G4MaterialTable
static constexpr double barn
Definition: G4SIunits.hh:85
static constexpr double MeV
Definition: G4SIunits.hh:200
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4bool contains(const G4double &) const
static size_t GetNumberOfMaterials()
Definition: G4Material.cc:679
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:672
G4double energy(const ThreeVector &p, const G4double m)
const char * name(G4int ptype)
string material
Definition: eplot.py:19

References activeZ, barn, G4DataVector::contains(), G4INCL::KinematicsUtils::energy(), excit, FatalException, geant4_check_module_cycles::file, G4cout, G4endl, G4Exception(), G4Material::GetMaterialTable(), G4Material::GetNumberOfMaterials(), length, eplot::material, MeV, G4InuclParticleNames::name(), param, and Z.

Referenced by G4eIonisationParameters().

◆ operator=()

G4eIonisationParameters & G4eIonisationParameters::operator= ( const G4eIonisationParameters right)
delete

◆ Parameter()

G4double G4eIonisationParameters::Parameter ( G4int  Z,
G4int  shellIndex,
G4int  parameterIndex,
G4double  e 
) const

Definition at line 90 of file G4eIonisationParameters.cc.

93{
94 G4double value = 0.;
95 G4int id = Z*100 + parameterIndex;
96
97 auto pos = param.find(id);
98 if (pos!= param.end()) {
99 G4VEMDataSet* dataSet = (*pos).second;
100 G4int nShells = dataSet->NumberOfComponents();
101
102 if(shellIndex < nShells) {
103 const G4VEMDataSet* component = dataSet->GetComponent(shellIndex);
104 const G4DataVector ener = component->GetEnergies(0);
105 G4double ee = std::max(ener.front(),std::min(ener.back(),e));
106 value = component->FindValue(ee);
107 } else {
108 G4cout << "WARNING: G4IonisationParameters::FindParameter "
109 << "has no parameters for shell= " << shellIndex
110 << "; Z= " << Z
111 << G4endl;
112 }
113 } else {
114 G4cout << "WARNING: G4IonisationParameters::Parameter "
115 << "did not find ID = "
116 << shellIndex << G4endl;
117 }
118
119 return value;
120}
virtual const G4VEMDataSet * GetComponent(G4int componentId) const =0
virtual size_t NumberOfComponents(void) const =0

References G4VEMDataSet::FindValue(), G4cout, G4endl, G4VEMDataSet::GetComponent(), G4VEMDataSet::GetEnergies(), G4INCL::Math::max(), G4INCL::Math::min(), G4VEMDataSet::NumberOfComponents(), param, pos, and Z.

Referenced by G4eIonisationSpectrum::AverageEnergy(), G4eIonisationSpectrum::Probability(), and G4eIonisationSpectrum::SampleEnergy().

◆ PrintData()

void G4eIonisationParameters::PrintData ( void  ) const

Definition at line 382 of file G4eIonisationParameters.cc.

383{
384 G4cout << G4endl;
385 G4cout << "===== G4eIonisationParameters =====" << G4endl;
386 G4cout << G4endl;
387
388 size_t nZ = activeZ.size();
389 std::map<G4int,G4VEMDataSet*,std::less<G4int> >::const_iterator pos;
390
391 for (size_t i=0; i<nZ; i++) {
392 G4int Z = (G4int)activeZ[i];
393
394 for (size_t j=0; j<length; j++) {
395
396 G4int index = Z*100 + j;
397
398 pos = param.find(index);
399 if (pos!= param.end()) {
400 G4VEMDataSet* dataSet = (*pos).second;
401 size_t nShells = dataSet->NumberOfComponents();
402
403 for (size_t k=0; k<nShells; k++) {
404
405 G4cout << "===== Z= " << Z << " shell= " << k
406 << " parameter[" << j << "] ====="
407 << G4endl;
408 const G4VEMDataSet* comp = dataSet->GetComponent(k);
409 comp->PrintData();
410 }
411 }
412 }
413 }
414 G4cout << "====================================" << G4endl;
415}
virtual void PrintData(void) const =0

References activeZ, G4cout, G4endl, G4VEMDataSet::GetComponent(), length, G4VEMDataSet::NumberOfComponents(), param, pos, G4VEMDataSet::PrintData(), and Z.

Referenced by G4eIonisationSpectrum::PrintData().

Field Documentation

◆ activeZ

G4DataVector G4eIonisationParameters::activeZ
private

Definition at line 76 of file G4eIonisationParameters.hh.

Referenced by LoadData(), PrintData(), and ~G4eIonisationParameters().

◆ excit

std::map<G4int,G4VEMDataSet*,std::less<G4int> > G4eIonisationParameters::excit
private

Definition at line 79 of file G4eIonisationParameters.hh.

Referenced by Excitation(), LoadData(), and ~G4eIonisationParameters().

◆ length

size_t G4eIonisationParameters::length = 24
private

Definition at line 81 of file G4eIonisationParameters.hh.

Referenced by LoadData(), and PrintData().

◆ param

std::map<G4int,G4VEMDataSet*,std::less<G4int> > G4eIonisationParameters::param
private

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