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

#include <G4MuElecCrossSectionDataSet.hh>

Inheritance diagram for G4MuElecCrossSectionDataSet:
Collaboration diagram for G4MuElecCrossSectionDataSet:

Public Member Functions

 G4MuElecCrossSectionDataSet (G4VDataSetAlgorithm *algo, G4double xUnit=CLHEP::MeV, G4double dataUnit=CLHEP::barn)
 
virtual ~G4MuElecCrossSectionDataSet ()
 
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 G4MuElecCrossSectionDataSet.hh.

Constructor & Destructor Documentation

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

Definition at line 37 of file G4MuElecCrossSectionDataSet.cc.

40  :
41  algorithm(argAlgorithm), unitEnergies(argUnitEnergies), unitData(argUnitData)
42 {
43  z = 0;
44 }

Here is the call graph for this function:

Here is the caller graph for this function:

G4MuElecCrossSectionDataSet::~G4MuElecCrossSectionDataSet ( )
virtual

Definition at line 46 of file G4MuElecCrossSectionDataSet.cc.

47 {
48  CleanUpComponents();
49 
50  if (algorithm)
51  delete algorithm;
52 }

Member Function Documentation

virtual void G4MuElecCrossSectionDataSet::AddComponent ( G4VEMDataSet dataSet)
inlinevirtual

Implements G4VEMDataSet.

Definition at line 54 of file G4MuElecCrossSectionDataSet.hh.

55  { components.push_back(dataSet); }

Here is the caller graph for this function:

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

Implements G4VEMDataSet.

Definition at line 454 of file G4MuElecCrossSectionDataSet.cc.

455 {
456  // Returns the sum over the shells corresponding to e
457  G4double value = 0.;
458 
459  std::vector<G4VEMDataSet *>::const_iterator i(components.begin());
460  std::vector<G4VEMDataSet *>::const_iterator end(components.end());
461 
462  while (i!=end)
463  {
464  value+=(*i)->FindValue(argEnergy);
465  i++;
466  }
467 
468  return value;
469 }
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* G4MuElecCrossSectionDataSet::GetComponent ( G4int  componentId) const
inlinevirtual

Implements G4VEMDataSet.

Definition at line 51 of file G4MuElecCrossSectionDataSet.hh.

52  { return components[componentId]; }

Here is the caller graph for this function:

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

Implements G4VEMDataSet.

Definition at line 63 of file G4MuElecCrossSectionDataSet.hh.

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

Here is the call graph for this function:

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

Implements G4VEMDataSet.

Definition at line 60 of file G4MuElecCrossSectionDataSet.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& G4MuElecCrossSectionDataSet::GetLogData ( G4int  componentId) const
inlinevirtual

Implements G4VEMDataSet.

Definition at line 69 of file G4MuElecCrossSectionDataSet.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& G4MuElecCrossSectionDataSet::GetLogEnergies ( G4int  componentId) const
inlinevirtual

Implements G4VEMDataSet.

Definition at line 66 of file G4MuElecCrossSectionDataSet.hh.

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

Here is the call graph for this function:

G4bool G4MuElecCrossSectionDataSet::LoadData ( const G4String argFileName)
virtual

Implements G4VEMDataSet.

Definition at line 54 of file G4MuElecCrossSectionDataSet.cc.

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

Implements G4VEMDataSet.

Definition at line 221 of file G4MuElecCrossSectionDataSet.cc.

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

Here is the call graph for this function:

virtual size_t G4MuElecCrossSectionDataSet::NumberOfComponents ( void  ) const
inlinevirtual

Implements G4VEMDataSet.

Definition at line 57 of file G4MuElecCrossSectionDataSet.hh.

58  { return components.size(); }

Here is the caller graph for this function:

void G4MuElecCrossSectionDataSet::PrintData ( void  ) const
virtual

Implements G4VEMDataSet.

Definition at line 472 of file G4MuElecCrossSectionDataSet.cc.

473 {
474  const size_t n(NumberOfComponents());
475 
476  G4cout << "The data set has " << n << " components" << G4endl;
477  G4cout << G4endl;
478 
479  size_t i(0);
480 
481  while (i<n)
482  {
483  G4cout << "--- Component " << i << " ---" << G4endl;
484  GetComponent(i)->PrintData();
485  i++;
486  }
487 }
virtual size_t NumberOfComponents(void) const
virtual const G4VEMDataSet * GetComponent(G4int componentId) const
G4GLOB_DLL std::ostream G4cout
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 G4MuElecCrossSectionDataSet::RandomSelect ( G4int  ) const
inlinevirtual

Implements G4VEMDataSet.

Definition at line 85 of file G4MuElecCrossSectionDataSet.hh.

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

Implements G4VEMDataSet.

Definition at line 366 of file G4MuElecCrossSectionDataSet.cc.

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

Implements G4VEMDataSet.

Definition at line 490 of file G4MuElecCrossSectionDataSet.cc.

493 {
494  G4VEMDataSet * component(components[argComponentId]);
495 
496  if (component)
497  {
498  component->SetEnergiesData(argEnergies, argData, 0);
499  return;
500  }
501 
502  std::ostringstream message;
503  message << "Component " << argComponentId << " not found";
504 
505  G4Exception("G4MuElecCrossSectionDataSet::SetEnergiesData","em0005",
506  FatalException,message.str().c_str());
507 
508 }
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 G4MuElecCrossSectionDataSet::SetLogEnergiesData ( G4DataVector x,
G4DataVector values,
G4DataVector log_x,
G4DataVector log_values,
G4int  componentId 
)
virtual

Implements G4VEMDataSet.

Definition at line 511 of file G4MuElecCrossSectionDataSet.cc.

516 {
517  G4VEMDataSet * component(components[argComponentId]);
518 
519  if (component)
520  {
521  component->SetLogEnergiesData(argEnergies, argData, argLogEnergies, argLogData, 0);
522  return;
523  }
524 
525  std::ostringstream message;
526  message << "Component " << argComponentId << " not found";
527 
528  G4Exception("G4MuElecCrossSectionDataSet::SetLogEnergiesData","em0005",
529  FatalException,message.str().c_str());
530 
531 }
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: