Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4MicroElecCrossSectionDataSet Class Reference

#include <G4MicroElecCrossSectionDataSet.hh>

Inheritance diagram for G4MicroElecCrossSectionDataSet:
Collaboration diagram for G4MicroElecCrossSectionDataSet:

Public Member Functions

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

Detailed Description

Definition at line 37 of file G4MicroElecCrossSectionDataSet.hh.

Constructor & Destructor Documentation

G4MicroElecCrossSectionDataSet::G4MicroElecCrossSectionDataSet ( G4VDataSetAlgorithm algo,
G4double  xUnit = CLHEP::MeV,
G4double  dataUnit = CLHEP::barn 
)

Definition at line 40 of file G4MicroElecCrossSectionDataSet.cc.

43  :
44  algorithm(argAlgorithm), unitEnergies(argUnitEnergies), unitData(argUnitData)
45 {
46  z = 0;
47 
48 }

Here is the call graph for this function:

Here is the caller graph for this function:

G4MicroElecCrossSectionDataSet::~G4MicroElecCrossSectionDataSet ( )
virtual

Definition at line 51 of file G4MicroElecCrossSectionDataSet.cc.

52 {
53  CleanUpComponents();
54 
55  if (algorithm)
56  delete algorithm;
57 }

Member Function Documentation

virtual void G4MicroElecCrossSectionDataSet::AddComponent ( G4VEMDataSet dataSet)
inlinevirtual

Implements G4VEMDataSet.

Definition at line 54 of file G4MicroElecCrossSectionDataSet.hh.

55  { components.push_back(dataSet); }

Here is the caller graph for this function:

G4double G4MicroElecCrossSectionDataSet::FindValue ( G4double  e,
G4int  componentId = 0 
) const
virtual

Implements G4VEMDataSet.

Definition at line 459 of file G4MicroElecCrossSectionDataSet.cc.

460 {
461  // Returns the sum over the shells corresponding to e
462  G4double value = 0.;
463 
464  std::vector<G4VEMDataSet *>::const_iterator i(components.begin());
465  std::vector<G4VEMDataSet *>::const_iterator end(components.end());
466 
467  while (i!=end)
468  {
469  value+=(*i)->FindValue(argEnergy);
470  i++;
471  }
472 
473  return value;
474 }
const XML_Char int const XML_Char * value
Definition: expat.h:331
double G4double
Definition: G4Types.hh:76

Here is the caller graph for this function:

virtual const G4VEMDataSet* G4MicroElecCrossSectionDataSet::GetComponent ( G4int  componentId) const
inlinevirtual

Implements G4VEMDataSet.

Definition at line 51 of file G4MicroElecCrossSectionDataSet.hh.

52  { return components[componentId]; }

Here is the caller graph for this function:

virtual const G4DataVector& G4MicroElecCrossSectionDataSet::GetData ( G4int  componentId) const
inlinevirtual

Implements G4VEMDataSet.

Definition at line 63 of file G4MicroElecCrossSectionDataSet.hh.

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

Here is the call graph for this function:

virtual const G4DataVector& G4MicroElecCrossSectionDataSet::GetEnergies ( G4int  componentId) const
inlinevirtual

Implements G4VEMDataSet.

Definition at line 60 of file G4MicroElecCrossSectionDataSet.hh.

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

Here is the call graph for this function:

Here is the caller graph for this function:

virtual const G4DataVector& G4MicroElecCrossSectionDataSet::GetLogData ( G4int  componentId) const
inlinevirtual

Implements G4VEMDataSet.

Definition at line 69 of file G4MicroElecCrossSectionDataSet.hh.

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

Here is the call graph for this function:

virtual const G4DataVector& G4MicroElecCrossSectionDataSet::GetLogEnergies ( G4int  componentId) const
inlinevirtual

Implements G4VEMDataSet.

Definition at line 66 of file G4MicroElecCrossSectionDataSet.hh.

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

Here is the call graph for this function:

G4bool G4MicroElecCrossSectionDataSet::LoadData ( const G4String argFileName)
virtual

Implements G4VEMDataSet.

Definition at line 59 of file G4MicroElecCrossSectionDataSet.cc.

60 {
61  CleanUpComponents();
62 
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::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);
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  case ' ':
145  space = true;
146  break;
147 
148  default:
149  if (comment) { break; }
150  if (space && (!first)) { (*stream) << ' '; }
151 
152  first=false;
153  (*stream) << c;
154  space=false;
155  }
156  }
157  }
158  catch(const std::ios::failure &e)
159  {
160  // some implementations of STL could throw a "failture" exception
161  // when read wants read characters after end of file
162  }
163 
164  delete stream;
165 
166  std::vector<G4DataVector *>::size_type maxI(columns.size());
167 
168  if (maxI<2)
169  {
170  G4String message("Data file \"");
171  message+=fullFileName;
172  message+="\" should have at least two columns";
173  G4Exception("G4MicroElecCrossSectionDataSet::LoadData","em0005",
174  FatalException,message);
175  return false;
176  }
177 
178  std::vector<G4DataVector*>::size_type i(1);
179  while (i<maxI)
180  {
181  G4DataVector::size_type maxJ(columns[i]->size());
182 
183  if (maxJ!=columns[0]->size())
184  {
185  G4String message("Data file \"");
186  message+=fullFileName;
187  message+="\" has lines with a different number of columns";
188  G4Exception("G4MicroElecCrossSectionDataSet::LoadData","em0005",
189  FatalException,message);
190  return false;
191  }
192 
193  G4DataVector::size_type j(0);
194 
195  G4DataVector *argEnergies=new G4DataVector;
196  G4DataVector *argData=new G4DataVector;
197  G4DataVector *argLogEnergies=new G4DataVector;
198  G4DataVector *argLogData=new G4DataVector;
199 
200  while(j<maxJ)
201  {
202  argEnergies->push_back(columns[0]->operator[] (j)*GetUnitEnergies());
203  argData->push_back(columns[i]->operator[] (j)*GetUnitData());
204  argLogEnergies->push_back(log_columns[0]->operator[] (j) + std::log10(GetUnitEnergies()));
205  argLogData->push_back(log_columns[i]->operator[] (j) + std::log10(GetUnitData()));
206  j++;
207  }
208 
209  AddComponent(new G4EMDataSet(i-1, argEnergies, argData, argLogEnergies, argLogData, GetAlgorithm()->Clone(), GetUnitEnergies(), GetUnitData()));
210 
211  i++;
212  }
213 
214  i=maxI;
215  while (i>0)
216  {
217  i--;
218  delete columns[i];
219  delete log_columns[i];
220  }
221 
222  return true;
223 }
virtual void AddComponent(G4VEMDataSet *dataSet)
const XML_Char int const XML_Char * value
Definition: expat.h:331
bool G4bool
Definition: G4Types.hh:79
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double G4double
Definition: G4Types.hh:76
tuple c
Definition: test.py:13

Here is the call graph for this function:

Here is the caller graph for this function:

G4bool G4MicroElecCrossSectionDataSet::LoadNonLogData ( const G4String argFileName)
virtual

Implements G4VEMDataSet.

Definition at line 226 of file G4MicroElecCrossSectionDataSet.cc.

227 {
228  CleanUpComponents();
229 
230  G4String fullFileName(FullFileName(argFileName));
231  std::ifstream in(fullFileName, std::ifstream::binary|std::ifstream::in);
232 
233  if (!in.is_open())
234  {
235  G4String message("Data file \"");
236  message+=fullFileName;
237  message+="\" not found";
238  G4Exception("G4MicroElecCrossSectionDataSet::LoadData","em0003",
239  FatalException,message);
240  return false;
241  }
242 
243  std::vector<G4DataVector *> columns;
244 
245  std::stringstream *stream(new std::stringstream);
246  char c;
247  G4bool comment(false);
248  G4bool space(true);
249  G4bool first(true);
250 
251  try
252  {
253  while (!in.eof())
254  {
255  in.get(c);
256 
257  switch (c)
258  {
259  case '\r':
260  case '\n':
261  if (!first)
262  {
263  unsigned long i(0);
264  G4double value;
265 
266  while (!stream->eof())
267  {
268  (*stream) >> value;
269 
270  while (i>=columns.size())
271  {
272  columns.push_back(new G4DataVector);
273  }
274 
275  columns[i]->push_back(value);
276 
277  i++;
278  }
279 
280  delete stream;
281  stream=new std::stringstream;
282  }
283 
284  first=true;
285  comment=false;
286  space=true;
287  break;
288 
289  case '#':
290  comment=true;
291  break;
292 
293  case '\t':
294  case ' ':
295  space = true;
296  break;
297 
298  default:
299  if (comment) { break; }
300  if (space && (!first)) { (*stream) << ' '; }
301 
302  first=false;
303  (*stream) << c;
304  space=false;
305  }
306  }
307  }
308  catch(const std::ios::failure &e)
309  {
310  // some implementations of STL could throw a "failture" exception
311  // when read wants read characters after end of file
312  }
313 
314  delete stream;
315 
316  std::vector<G4DataVector *>::size_type maxI(columns.size());
317 
318  if (maxI<2)
319  {
320  G4String message("Data file \"");
321  message+=fullFileName;
322  message+="\" should have at least two columns";
323  G4Exception("G4MicroElecCrossSectionDataSet::LoadData","em0005",
324  FatalException,message);
325  return false;
326  }
327 
328  std::vector<G4DataVector*>::size_type i(1);
329  while (i<maxI)
330  {
331  G4DataVector::size_type maxJ(columns[i]->size());
332 
333  if (maxJ!=columns[0]->size())
334  {
335  G4String message("Data file \"");
336  message+=fullFileName;
337  message+="\" has lines with a different number of columns.";
338  G4Exception("G4MicroElecCrossSectionDataSet::LoadData","em0005",
339  FatalException,message);
340  return false;
341  }
342 
343  G4DataVector::size_type j(0);
344 
345  G4DataVector *argEnergies=new G4DataVector;
346  G4DataVector *argData=new G4DataVector;
347 
348  while(j<maxJ)
349  {
350  argEnergies->push_back(columns[0]->operator[] (j)*GetUnitEnergies());
351  argData->push_back(columns[i]->operator[] (j)*GetUnitData());
352  j++;
353  }
354 
355  AddComponent(new G4EMDataSet(i-1, argEnergies, argData, GetAlgorithm()->Clone(), GetUnitEnergies(), GetUnitData()));
356 
357  i++;
358  }
359 
360  i=maxI;
361  while (i>0)
362  {
363  i--;
364  delete columns[i];
365  }
366 
367  return true;
368 }
virtual void AddComponent(G4VEMDataSet *dataSet)
const XML_Char int const XML_Char * value
Definition: expat.h:331
bool G4bool
Definition: G4Types.hh:79
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double G4double
Definition: G4Types.hh:76
tuple c
Definition: test.py:13

Here is the call graph for this function:

virtual size_t G4MicroElecCrossSectionDataSet::NumberOfComponents ( void  ) const
inlinevirtual

Implements G4VEMDataSet.

Definition at line 57 of file G4MicroElecCrossSectionDataSet.hh.

58  { return components.size(); }

Here is the caller graph for this function:

void G4MicroElecCrossSectionDataSet::PrintData ( void  ) const
virtual

Implements G4VEMDataSet.

Definition at line 477 of file G4MicroElecCrossSectionDataSet.cc.

478 {
479  const size_t n(NumberOfComponents());
480 
481  G4cout << "The data set has " << n << " components" << G4endl;
482  G4cout << G4endl;
483 
484  size_t i(0);
485 
486  while (i<n)
487  {
488  G4cout << "--- Component " << i << " ---" << G4endl;
489  GetComponent(i)->PrintData();
490  i++;
491  }
492 }
virtual const G4VEMDataSet * GetComponent(G4int componentId) const
G4GLOB_DLL std::ostream G4cout
virtual size_t NumberOfComponents(void) const
const G4int n
virtual void PrintData(void) const =0
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

virtual G4double G4MicroElecCrossSectionDataSet::RandomSelect ( G4int  ) const
inlinevirtual

Implements G4VEMDataSet.

Definition at line 85 of file G4MicroElecCrossSectionDataSet.hh.

85 { return -1.; };
G4bool G4MicroElecCrossSectionDataSet::SaveData ( const G4String argFileName) const
virtual

Implements G4VEMDataSet.

Definition at line 371 of file G4MicroElecCrossSectionDataSet.cc.

372 {
373  const size_t n(NumberOfComponents());
374 
375  if (n==0)
376  {
377  G4Exception("G4MicroElecCrossSectionDataSet::SaveData","em0005",
378  FatalException,"Expected at least one component");
379 
380  return false;
381  }
382 
383  G4String fullFileName(FullFileName(argFileName));
384  std::ofstream out(fullFileName);
385 
386  if (!out.is_open())
387  {
388  G4String message("Cannot open \"");
389  message+=fullFileName;
390  message+="\"";
391  G4Exception("G4MicroElecCrossSectionDataSet::SaveData","em0005",
392  FatalException,message);
393  return false;
394  }
395 
396  G4DataVector::const_iterator iEnergies(GetComponent(0)->GetEnergies(0).begin());
397  G4DataVector::const_iterator iEnergiesEnd(GetComponent(0)->GetEnergies(0).end());
398  G4DataVector::const_iterator * iData(new G4DataVector::const_iterator[n]);
399 
400  size_t k(n);
401 
402  while (k>0)
403  {
404  k--;
405  iData[k]=GetComponent(k)->GetData(0).begin();
406  }
407 
408  while (iEnergies!=iEnergiesEnd)
409  {
410  out.precision(10);
411  out.width(15);
412  out.setf(std::ofstream::left);
413  out << ((*iEnergies)/GetUnitEnergies());
414 
415  k=0;
416 
417  while (k<n)
418  {
419  out << ' ';
420  out.precision(10);
421  out.width(15);
422  out.setf(std::ofstream::left);
423  out << ((*(iData[k]))/GetUnitData());
424 
425  iData[k]++;
426  k++;
427  }
428 
429  out << std::endl;
430 
431  iEnergies++;
432  }
433 
434  delete[] iData;
435 
436  return true;
437 }
virtual const G4VEMDataSet * GetComponent(G4int componentId) const
virtual const G4DataVector & GetData(G4int componentId) const =0
virtual size_t NumberOfComponents(void) const
const G4int n
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
virtual const G4DataVector & GetEnergies(G4int componentId) const

Here is the call graph for this function:

void G4MicroElecCrossSectionDataSet::SetEnergiesData ( G4DataVector x,
G4DataVector values,
G4int  componentId 
)
virtual

Implements G4VEMDataSet.

Definition at line 495 of file G4MicroElecCrossSectionDataSet.cc.

498 {
499  G4VEMDataSet * component(components[argComponentId]);
500 
501  if (component)
502  {
503  component->SetEnergiesData(argEnergies, argData, 0);
504  return;
505  }
506 
507  std::ostringstream message;
508  message << "Component " << argComponentId << " not found";
509 
510  G4Exception("G4MicroElecCrossSectionDataSet::SetEnergiesData","em0005",
511  FatalException,message.str().c_str());
512 
513 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Here is the call graph for this function:

void G4MicroElecCrossSectionDataSet::SetLogEnergiesData ( G4DataVector x,
G4DataVector values,
G4DataVector log_x,
G4DataVector log_values,
G4int  componentId 
)
virtual

Implements G4VEMDataSet.

Definition at line 516 of file G4MicroElecCrossSectionDataSet.cc.

521 {
522  G4VEMDataSet * component(components[argComponentId]);
523 
524  if (component)
525  {
526  component->SetLogEnergiesData(argEnergies, argData, argLogEnergies, argLogData, 0);
527  return;
528  }
529 
530  std::ostringstream message;
531  message << "Component " << argComponentId << " not found";
532 
533  G4Exception("G4MicroElecCrossSectionDataSet::SetLogEnergiesData","em0005",
534  FatalException,message.str().c_str());
535 
536 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Here is the call graph for this function:


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