Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4MicroElecCrossSectionDataSet_new Class Reference

#include <G4MicroElecCrossSectionDataSet_new.hh>

+ Inheritance diagram for G4MicroElecCrossSectionDataSet_new:

Public Member Functions

 G4MicroElecCrossSectionDataSet_new (G4VDataSetAlgorithm *algo, G4double xUnit=CLHEP::MeV, G4double dataUnit=CLHEP::barn)
 
 ~G4MicroElecCrossSectionDataSet_new () override
 
G4double FindValue (G4double e, G4int componentId=0) const override
 
G4double FindShellValue (G4double argEnergy, G4int shell) const
 
void PrintData (void) const override
 
const G4VEMDataSetGetComponent (G4int componentId) const override
 
void AddComponent (G4VEMDataSet *dataSet) override
 
size_t NumberOfComponents (void) const override
 
const G4DataVectorGetEnergies (G4int componentId) const override
 
const G4DataVectorGetData (G4int componentId) const override
 
const G4DataVectorGetLogEnergies (G4int componentId) const override
 
const G4DataVectorGetLogData (G4int componentId) const override
 
void SetEnergiesData (G4DataVector *x, G4DataVector *values, G4int componentId) override
 
void SetLogEnergiesData (G4DataVector *x, G4DataVector *values, G4DataVector *log_x, G4DataVector *log_values, G4int componentId) override
 
G4bool LoadData (const G4String &argFileName) override
 
G4bool LoadNonLogData (const G4String &argFileName) override
 
G4bool SaveData (const G4String &argFileName) const override
 
G4double RandomSelect (G4int) const override
 
 G4MicroElecCrossSectionDataSet_new (const G4MicroElecCrossSectionDataSet_new &copy)=delete
 
G4MicroElecCrossSectionDataSet_newoperator= (const G4MicroElecCrossSectionDataSet_new &right)=delete
 
- Public Member Functions inherited from G4VEMDataSet
 G4VEMDataSet ()
 
virtual ~G4VEMDataSet ()
 
 G4VEMDataSet (const G4VEMDataSet &copy)=delete
 
G4VEMDataSetoperator= (const G4VEMDataSet &right)=delete
 

Detailed Description

Definition at line 36 of file G4MicroElecCrossSectionDataSet_new.hh.

Constructor & Destructor Documentation

◆ G4MicroElecCrossSectionDataSet_new() [1/2]

G4MicroElecCrossSectionDataSet_new::G4MicroElecCrossSectionDataSet_new ( G4VDataSetAlgorithm * algo,
G4double xUnit = CLHEP::MeV,
G4double dataUnit = CLHEP::barn )
explicit

Definition at line 40 of file G4MicroElecCrossSectionDataSet_new.cc.

43 :
44 algorithm(argAlgorithm), unitEnergies(argUnitEnergies), unitData(argUnitData)
45{;}

◆ ~G4MicroElecCrossSectionDataSet_new()

G4MicroElecCrossSectionDataSet_new::~G4MicroElecCrossSectionDataSet_new ( )
override

Definition at line 49 of file G4MicroElecCrossSectionDataSet_new.cc.

50{
51 CleanUpComponents();
52
53 if (algorithm)
54 delete algorithm;
55}

◆ G4MicroElecCrossSectionDataSet_new() [2/2]

G4MicroElecCrossSectionDataSet_new::G4MicroElecCrossSectionDataSet_new ( const G4MicroElecCrossSectionDataSet_new & copy)
delete

Member Function Documentation

◆ AddComponent()

void G4MicroElecCrossSectionDataSet_new::AddComponent ( G4VEMDataSet * dataSet)
inlineoverridevirtual

Implements G4VEMDataSet.

Definition at line 49 of file G4MicroElecCrossSectionDataSet_new.hh.

50 { components.push_back(dataSet); }

Referenced by LoadData(), and LoadNonLogData().

◆ FindShellValue()

G4double G4MicroElecCrossSectionDataSet_new::FindShellValue ( G4double argEnergy,
G4int shell ) const

Definition at line 500 of file G4MicroElecCrossSectionDataSet_new.cc.

501{
502 return components.at(shell)->FindValue(argEnergy);
503}

Referenced by G4MicroElecInelasticModel_new::CrossSectionPerVolume().

◆ FindValue()

G4double G4MicroElecCrossSectionDataSet_new::FindValue ( G4double e,
G4int componentId = 0 ) const
overridevirtual

Implements G4VEMDataSet.

Definition at line 481 of file G4MicroElecCrossSectionDataSet_new.cc.

482{
483 // Returns the sum over the shells corresponding to e
484 G4double value = 0.;
485
486 std::vector<G4VEMDataSet *>::const_iterator i(components.begin());
487 std::vector<G4VEMDataSet *>::const_iterator end(components.end());
488
489 while (i!=end)
490 {
491 value+=(*i)->FindValue(argEnergy);
492 i++;
493 }
494
495 return value;
496}
double G4double
Definition G4Types.hh:83

Referenced by G4MicroElecElasticModel_new::CrossSectionPerVolume(), and G4MicroElecInelasticModel_new::CrossSectionPerVolume().

◆ GetComponent()

const G4VEMDataSet * G4MicroElecCrossSectionDataSet_new::GetComponent ( G4int componentId) const
inlineoverridevirtual

Implements G4VEMDataSet.

Definition at line 47 of file G4MicroElecCrossSectionDataSet_new.hh.

48 { return components[componentId]; }

Referenced by GetData(), GetEnergies(), GetLogData(), GetLogEnergies(), PrintData(), and SaveData().

◆ GetData()

const G4DataVector & G4MicroElecCrossSectionDataSet_new::GetData ( G4int componentId) const
inlineoverridevirtual

Implements G4VEMDataSet.

Definition at line 55 of file G4MicroElecCrossSectionDataSet_new.hh.

56 { return GetComponent(componentId)->GetData(0); }
const G4VEMDataSet * GetComponent(G4int componentId) const override
virtual const G4DataVector & GetData(G4int componentId) const =0

◆ GetEnergies()

const G4DataVector & G4MicroElecCrossSectionDataSet_new::GetEnergies ( G4int componentId) const
inlineoverridevirtual

Implements G4VEMDataSet.

Definition at line 53 of file G4MicroElecCrossSectionDataSet_new.hh.

54 { return GetComponent(componentId)->GetEnergies(0); }
virtual const G4DataVector & GetEnergies(G4int componentId) const =0

Referenced by SaveData().

◆ GetLogData()

const G4DataVector & G4MicroElecCrossSectionDataSet_new::GetLogData ( G4int componentId) const
inlineoverridevirtual

Implements G4VEMDataSet.

Definition at line 59 of file G4MicroElecCrossSectionDataSet_new.hh.

60 { return GetComponent(componentId)->GetLogData(0); }
virtual const G4DataVector & GetLogData(G4int componentId) const =0

◆ GetLogEnergies()

const G4DataVector & G4MicroElecCrossSectionDataSet_new::GetLogEnergies ( G4int componentId) const
inlineoverridevirtual

Implements G4VEMDataSet.

Definition at line 57 of file G4MicroElecCrossSectionDataSet_new.hh.

58 { return GetComponent(componentId)->GetLogEnergies(0); }
virtual const G4DataVector & GetLogEnergies(G4int componentId) const =0

◆ LoadData()

G4bool G4MicroElecCrossSectionDataSet_new::LoadData ( const G4String & argFileName)
overridevirtual

Implements G4VEMDataSet.

Definition at line 59 of file G4MicroElecCrossSectionDataSet_new.cc.

60{
61 CleanUpComponents();
62 G4cout << "loaddata : " << argFileName << G4endl;
63 G4String fullFileName(FullFileName(argFileName));
64 std::ifstream in(fullFileName, std::ifstream::binary|std::ifstream::in);
65
66 if (!in.is_open())
67 {
68 G4String message("Data file \"");
69 message+=fullFileName;
70 message+="\" not found";
71 G4Exception("G4MicroElecCrossSectionDataSet_new::LoadData","em0003",
72 FatalException,message);
73 return false;
74 }
75
76 std::vector<G4DataVector *> columns;
77 std::vector<G4DataVector *> log_columns;
78
79 std::stringstream *stream(new std::stringstream);
80 char c;
81 G4bool comment(false);
82 G4bool space(true);
83 G4bool first(true);
84
85 try
86 {
87 while (!in.eof())
88 {
89 in.get(c);
90
91 switch (c)
92 {
93 case '\r':
94 case '\n':
95 if (!first)
96 {
97 unsigned long i(0);
98 G4double value;
99
100 while (!stream->eof())
101 {
102 (*stream) >> value;
103
104 while (i>=columns.size())
105 {
106 columns.push_back(new G4DataVector);
107 log_columns.push_back(new G4DataVector);
108 }
109
110 columns[i]->push_back(value);
111
112 // N. A. Karakatsanis
113 // A condition is applied to check if negative or zero values are present in the dataset.
114 // If yes, then a near-zero value is applied to allow the computation of the logarithmic value
115 // If a value is zero, this simplification is acceptable
116 // If a value is negative, then it is not acceptable and the data of the particular column of
117 // logarithmic values should not be used by interpolation methods.
118 //
119 // Therefore, G4LogLogInterpolation and G4LinLogLogInterpolation should not be used if negative values are present.
120 // Instead, G4LinInterpolation is safe in every case
121 // SemiLogInterpolation is safe only if the energy columns are non-negative
122 // G4LinLogInterpolation is safe only if the cross section data columns are non-negative
123
124 if (value <=0.) value = 1e-300;
125 log_columns[i]->push_back(std::log10(value));
126
127 i++;
128 }
129
130 delete stream;
131 stream=new std::stringstream;
132 }
133
134 first=true;
135 comment=false;
136 space=true;
137 break;
138
139 case '#':
140 comment=true;
141 break;
142
143 case '\t':
144 c=' ';
145 break;
146 //case ' ':
147 // if (space)
148 // break;
149 default:
150 if ((c==' ') && space)
151 break;
152
153 if (comment)
154 break;
155
156 if (c==' ')
157 space=true;
158 else
159 {
160 if (space && (!first))
161 (*stream) << ' ';
162
163 first=false;
164 (*stream) << c;
165 space=false;
166 }
167 }
168 }
169 }
170 catch(const std::ios::failure &e)
171 {
172 // some implementations of STL could throw a "failture" exception
173 // when read wants read characters after end of file
174 }
175 delete stream;
176
177 std::size_t maxI(columns.size());
178
179 if (maxI<2)
180 {
181 G4String message("Data file \"");
182 message+=fullFileName;
183 message+="\" should have at least two columns";
184 G4Exception("G4MicroElecCrossSectionDataSet_new::LoadData","em0005",
185 FatalException,message);
186 return false;
187 }
188
189 std::size_t i(1);
190 while (i<maxI)
191 {
192 std::size_t maxJ(columns[i]->size());
193
194 if (maxJ!=columns[0]->size())
195 {
196 G4String message("Data file \"");
197 message+=fullFileName;
198 message+="\" has lines with a different number of columns";
199 G4Exception("G4MicroElecCrossSectionDataSet_new::LoadData","em0005",
200 FatalException,message);
201 return false;
202 }
203
204 std::size_t j(0);
205
206 G4DataVector *argEnergies=new G4DataVector;
207 G4DataVector *argData=new G4DataVector;
208 G4DataVector *argLogEnergies=new G4DataVector;
209 G4DataVector *argLogData=new G4DataVector;
210
211 while(j<maxJ)
212 {
213 argEnergies->push_back(columns[0]->operator[] (j)*GetUnitEnergies());
214 argData->push_back(columns[i]->operator[] (j)*GetUnitData());
215 argLogEnergies->push_back(log_columns[0]->operator[] (j) + std::log10(GetUnitEnergies()));
216 argLogData->push_back(log_columns[i]->operator[] (j) + std::log10(GetUnitData()));
217 j++;
218 }
219
220 AddComponent(new G4EMDataSet(G4int(i-1), argEnergies, argData, argLogEnergies, argLogData, GetAlgorithm()->Clone(), GetUnitEnergies(), GetUnitData()));
221
222 ++i;
223 }
224
225 i=maxI;
226 while (i>0)
227 {
228 i--;
229 delete columns[i];
230 delete log_columns[i];
231 }
232
233 return true;
234}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
void AddComponent(G4VEMDataSet *dataSet) override

Referenced by G4MicroElecElasticModel_new::Initialise(), and G4MicroElecInelasticModel_new::Initialise().

◆ LoadNonLogData()

G4bool G4MicroElecCrossSectionDataSet_new::LoadNonLogData ( const G4String & argFileName)
overridevirtual

Implements G4VEMDataSet.

Definition at line 238 of file G4MicroElecCrossSectionDataSet_new.cc.

239{
240 CleanUpComponents();
241
242 G4String fullFileName(FullFileName(argFileName));
243 std::ifstream in(fullFileName, std::ifstream::binary|std::ifstream::in);
244
245 if (!in.is_open())
246 {
247 G4String message("Data file \"");
248 message+=fullFileName;
249 message+="\" not found";
250 G4Exception("G4MicroElecCrossSectionDataSet_new::LoadData","em0003",
251 FatalException,message);
252 return false;
253 }
254
255 std::vector<G4DataVector *> columns;
256
257 std::stringstream *stream(new std::stringstream);
258 char c;
259 G4bool comment(false);
260 G4bool space(true);
261 G4bool first(true);
262
263 try
264 {
265 while (!in.eof())
266 {
267 in.get(c);
268
269 switch (c)
270 {
271 case '\r':
272 case '\n':
273 if (!first)
274 {
275 unsigned long i(0);
276 G4double value;
277
278 while (!stream->eof())
279 {
280 (*stream) >> value;
281
282 while (i>=columns.size())
283 {
284 columns.push_back(new G4DataVector);
285 }
286
287 columns[i]->push_back(value);
288
289 i++;
290 }
291
292 delete stream;
293 stream=new std::stringstream;
294 }
295
296 first=true;
297 comment=false;
298 space=true;
299 break;
300
301 case '#':
302 comment=true;
303 break;
304
305 default:
306 if( c=='\t')
307 c=' ';
308 if( c==' ' && space)
309 break;
310
311 if (comment)
312 break;
313
314 if (c==' ')
315 space=true;
316 else
317 {
318 if (space && (!first))
319 (*stream) << ' ';
320
321 first=false;
322 (*stream) << c;
323 space=false;
324 }
325 }
326 }
327 }
328 catch(const std::ios::failure &e)
329 {
330 // some implementations of STL could throw a "failture" exception
331 // when read wants read characters after end of file
332 }
333
334 delete stream;
335
336 std::size_t maxI(columns.size());
337
338 if (maxI<2)
339 {
340 G4String message("Data file \"");
341 message+=fullFileName;
342 message+="\" should have at least two columns";
343 G4Exception("G4MicroElecCrossSectionDataSet_new::LoadData","em0005",
344 FatalException,message);
345 return false;
346 }
347
348 std::size_t i(1);
349 while (i<maxI)
350 {
351 std::size_t maxJ(columns[i]->size());
352
353
354 if (maxJ!=columns[0]->size())
355 {
356 G4String message("Data file \"");
357 message+=fullFileName;
358 message+="\" has lines with a different number of columns.";
359 G4Exception("G4MicroElecCrossSectionDataSet_new::LoadData","em0005",
360 FatalException,message);
361 return false;
362 }
363
364 std::size_t j(0);
365
366 G4DataVector *argEnergies=new G4DataVector;
367 G4DataVector *argData=new G4DataVector;
368
369 while(j<maxJ)
370 {
371 argEnergies->push_back(columns[0]->operator[] (j)*GetUnitEnergies());
372 argData->push_back(columns[i]->operator[] (j)*GetUnitData());
373 ++j;
374 }
375
376 AddComponent(new G4EMDataSet(G4int(i-1), argEnergies, argData, GetAlgorithm()->Clone(), GetUnitEnergies(), GetUnitData()));
377
378 ++i;
379 }
380
381 i=maxI;
382 while (i>0)
383 {
384 --i;
385 delete columns[i];
386 }
387
388 return true;
389}

◆ NumberOfComponents()

size_t G4MicroElecCrossSectionDataSet_new::NumberOfComponents ( void ) const
inlineoverridevirtual

Implements G4VEMDataSet.

Definition at line 51 of file G4MicroElecCrossSectionDataSet_new.hh.

52 { return components.size(); }

Referenced by PrintData(), and SaveData().

◆ operator=()

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

◆ PrintData()

void G4MicroElecCrossSectionDataSet_new::PrintData ( void ) const
overridevirtual

Implements G4VEMDataSet.

Definition at line 507 of file G4MicroElecCrossSectionDataSet_new.cc.

508{
509 const std::size_t n(NumberOfComponents());
510
511 G4cout << "The data set has " << n << " components" << G4endl;
512 G4cout << G4endl;
513
514 G4int i(0);
515
516 while (i<(G4int)n)
517 {
518 G4cout << "--- Component " << i << " ---" << G4endl;
520 ++i;
521 }
522}
virtual void PrintData(void) const =0

◆ RandomSelect()

G4double G4MicroElecCrossSectionDataSet_new::RandomSelect ( G4int ) const
inlineoverridevirtual

Implements G4VEMDataSet.

Definition at line 70 of file G4MicroElecCrossSectionDataSet_new.hh.

71 { return -1.; };

◆ SaveData()

G4bool G4MicroElecCrossSectionDataSet_new::SaveData ( const G4String & argFileName) const
overridevirtual

Implements G4VEMDataSet.

Definition at line 393 of file G4MicroElecCrossSectionDataSet_new.cc.

394{
395 const std::size_t n(NumberOfComponents());
396
397 if (n==0)
398 {
399 G4Exception("G4MicroElecCrossSectionDataSet_new::SaveData","em0005",
400 FatalException,"Expected at least one component");
401
402 return false;
403 }
404
405 G4String fullFileName(FullFileName(argFileName));
406 std::ofstream out(fullFileName);
407
408 if (!out.is_open())
409 {
410 G4String message("Cannot open \"");
411 message+=fullFileName;
412 message+="\"";
413 G4Exception("G4MicroElecCrossSectionDataSet_new::SaveData","em0005",
414 FatalException,message);
415 return false;
416 }
417
418 G4DataVector::const_iterator iEnergies(GetComponent(0)->GetEnergies(0).begin());
419 G4DataVector::const_iterator iEnergiesEnd(GetComponent(0)->GetEnergies(0).end());
420 G4DataVector::const_iterator * iData(new G4DataVector::const_iterator[n]);
421
422 std::size_t k(n);
423
424 while (k>0)
425 {
426 --k;
427 iData[k]=GetComponent((G4int)k)->GetData(0).begin();
428 }
429
430 while (iEnergies!=iEnergiesEnd)
431 {
432 out.precision(10);
433 out.width(15);
434 out.setf(std::ofstream::left);
435 out << ((*iEnergies)/GetUnitEnergies());
436
437 k=0;
438
439 while (k<n)
440 {
441 out << ' ';
442 out.precision(10);
443 out.width(15);
444 out.setf(std::ofstream::left);
445 out << ((*(iData[k]))/GetUnitData());
446
447 iData[k]++;
448 ++k;
449 }
450
451 out << std::endl;
452
453 ++iEnergies;
454 }
455
456 delete[] iData;
457
458 return true;
459}
const G4DataVector & GetEnergies(G4int componentId) const override

◆ SetEnergiesData()

void G4MicroElecCrossSectionDataSet_new::SetEnergiesData ( G4DataVector * x,
G4DataVector * values,
G4int componentId )
overridevirtual

Implements G4VEMDataSet.

Definition at line 526 of file G4MicroElecCrossSectionDataSet_new.cc.

529{
530 G4VEMDataSet * component(components[argComponentId]);
531
532 if (component)
533 {
534 component->SetEnergiesData(argEnergies, argData, 0);
535 return;
536 }
537
538 std::ostringstream message;
539 message << "Component " << argComponentId << " not found";
540
541 G4Exception("G4MicroElecCrossSectionDataSet_new::SetEnergiesData","em0005",
542 FatalException,message.str().c_str());
543
544}

◆ SetLogEnergiesData()

void G4MicroElecCrossSectionDataSet_new::SetLogEnergiesData ( G4DataVector * x,
G4DataVector * values,
G4DataVector * log_x,
G4DataVector * log_values,
G4int componentId )
overridevirtual

Implements G4VEMDataSet.

Definition at line 548 of file G4MicroElecCrossSectionDataSet_new.cc.

553{
554 G4VEMDataSet * component(components[argComponentId]);
555
556 if (component)
557 {
558 component->SetLogEnergiesData(argEnergies, argData, argLogEnergies, argLogData, 0);
559 return;
560 }
561
562 std::ostringstream message;
563 message << "Component " << argComponentId << " not found";
564
565 G4Exception("G4MicroElecCrossSectionDataSet_new::SetLogEnergiesData","em0005",
566 FatalException,message.str().c_str());
567
568}

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