Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions
G4ShellEMDataSet Class Reference

#include <G4ShellEMDataSet.hh>

Inheritance diagram for G4ShellEMDataSet:
G4VEMDataSet

Public Member Functions

 G4ShellEMDataSet (G4int Z, G4VDataSetAlgorithm *algo, G4double eUnit=CLHEP::MeV, G4double dataUnit=CLHEP::barn)
 
virtual ~G4ShellEMDataSet ()
 
virtual G4double FindValue (G4double energy, 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 *energies, G4DataVector *data, G4int componentId)
 
virtual void SetLogEnergiesData (G4DataVector *energies, G4DataVector *data, G4DataVector *log_energies, G4DataVector *log_data, G4int componentId)
 
virtual G4bool LoadData (const G4String &fileName)
 
virtual G4bool LoadNonLogData (const G4String &fileName)
 
virtual G4bool SaveData (const G4String &fileName) const
 
virtual G4double RandomSelect (G4int) const
 
- Public Member Functions inherited from G4VEMDataSet
 G4VEMDataSet ()
 
virtual ~G4VEMDataSet ()
 

Protected Member Functions

G4double GetUnitEnergies () const
 
G4double GetUnitData () const
 
const G4VDataSetAlgorithmGetAlgorithm () const
 
void CleanUpComponents (void)
 

Detailed Description

Definition at line 60 of file G4ShellEMDataSet.hh.

Constructor & Destructor Documentation

G4ShellEMDataSet::G4ShellEMDataSet ( G4int  Z,
G4VDataSetAlgorithm algo,
G4double  eUnit = CLHEP::MeV,
G4double  dataUnit = CLHEP::barn 
)

Definition at line 64 of file G4ShellEMDataSet.cc.

References FatalErrorInArgument, G4Exception(), and G4ShellEMDataSet().

Referenced by G4ShellEMDataSet().

67  :
68  z(zeta),
69  algorithm(algo),
70  unitEnergies(eUnit),
71  unitData(dataUnit)
72 {
73  if (algorithm == 0) G4Exception("G4ShellEMDataSet::G4ShellEMDataSet()","em0007",FatalErrorInArgument, "Interpolation == 0");
74 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4ShellEMDataSet::~G4ShellEMDataSet ( )
virtual

Definition at line 77 of file G4ShellEMDataSet.cc.

References CleanUpComponents().

78 {
80  if (algorithm) delete algorithm;
81 }
void CleanUpComponents(void)

Member Function Documentation

virtual void G4ShellEMDataSet::AddComponent ( G4VEMDataSet dataSet)
inlinevirtual

Implements G4VEMDataSet.

Definition at line 75 of file G4ShellEMDataSet.hh.

Referenced by LoadData(), and LoadNonLogData().

75 { components.push_back(dataSet); }
void G4ShellEMDataSet::CleanUpComponents ( void  )
protected

Definition at line 389 of file G4ShellEMDataSet.cc.

Referenced by LoadData(), LoadNonLogData(), and ~G4ShellEMDataSet().

390 {
391  while (!components.empty())
392  {
393  if (components.back()) delete components.back();
394  components.pop_back();
395  }
396 }
G4double G4ShellEMDataSet::FindValue ( G4double  energy,
G4int  componentId = 0 
) const
virtual

Implements G4VEMDataSet.

Definition at line 84 of file G4ShellEMDataSet.cc.

85 {
86  // Returns the sum over the shells corresponding to e
87  G4double value = 0.;
88 
89  std::vector<G4VEMDataSet *>::const_iterator i(components.begin());
90  std::vector<G4VEMDataSet *>::const_iterator end(components.end());
91 
92  while (i != end)
93  {
94  value += (*i)->FindValue(energy);
95  i++;
96  }
97 
98  return value;
99 }
double precision function energy(A, Z)
Definition: dpm25nuc6.f:4106
const XML_Char int const XML_Char * value
double G4double
Definition: G4Types.hh:76
const G4VDataSetAlgorithm* G4ShellEMDataSet::GetAlgorithm ( ) const
inlineprotected

Definition at line 101 of file G4ShellEMDataSet.hh.

101 { return algorithm; }
virtual const G4VEMDataSet* G4ShellEMDataSet::GetComponent ( G4int  componentId) const
inlinevirtual

Implements G4VEMDataSet.

Definition at line 74 of file G4ShellEMDataSet.hh.

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

74 { return components[componentId]; }
virtual const G4DataVector& G4ShellEMDataSet::GetData ( G4int  componentId) const
inlinevirtual

Implements G4VEMDataSet.

Definition at line 79 of file G4ShellEMDataSet.hh.

References GetComponent(), and G4VEMDataSet::GetData().

79 { return GetComponent(componentId)->GetData(0); }
virtual const G4DataVector & GetData(G4int componentId) const =0
virtual const G4VEMDataSet * GetComponent(G4int componentId) const
virtual const G4DataVector& G4ShellEMDataSet::GetEnergies ( G4int  componentId) const
inlinevirtual

Implements G4VEMDataSet.

Definition at line 78 of file G4ShellEMDataSet.hh.

References GetComponent(), and G4VEMDataSet::GetEnergies().

78 { return GetComponent(componentId)->GetEnergies(0); }
virtual const G4DataVector & GetEnergies(G4int componentId) const =0
virtual const G4VEMDataSet * GetComponent(G4int componentId) const
virtual const G4DataVector& G4ShellEMDataSet::GetLogData ( G4int  componentId) const
inlinevirtual

Implements G4VEMDataSet.

Definition at line 81 of file G4ShellEMDataSet.hh.

References GetComponent(), and G4VEMDataSet::GetLogData().

81 { return GetComponent(componentId)->GetLogData(0); }
virtual const G4VEMDataSet * GetComponent(G4int componentId) const
virtual const G4DataVector & GetLogData(G4int componentId) const =0
virtual const G4DataVector& G4ShellEMDataSet::GetLogEnergies ( G4int  componentId) const
inlinevirtual

Implements G4VEMDataSet.

Definition at line 80 of file G4ShellEMDataSet.hh.

References GetComponent(), and G4VEMDataSet::GetLogEnergies().

80 { return GetComponent(componentId)->GetLogEnergies(0); }
virtual const G4VEMDataSet * GetComponent(G4int componentId) const
virtual const G4DataVector & GetLogEnergies(G4int componentId) const =0
G4double G4ShellEMDataSet::GetUnitData ( ) const
inlineprotected

Definition at line 100 of file G4ShellEMDataSet.hh.

100 { return unitData; }
G4double G4ShellEMDataSet::GetUnitEnergies ( ) const
inlineprotected

Definition at line 99 of file G4ShellEMDataSet.hh.

99 { return unitEnergies; }
G4bool G4ShellEMDataSet::LoadData ( const G4String fileName)
virtual

Implements G4VEMDataSet.

Definition at line 160 of file G4ShellEMDataSet.cc.

References test::a, AddComponent(), CleanUpComponents(), G4VDataSetAlgorithm::Clone(), FatalException, and G4Exception().

161 {
163 
164  G4String fullFileName = FullFileName(file);
165  std::ifstream in(fullFileName);
166 
167  if (!in.is_open())
168  {
169  G4String message("Data file \"");
170  message += fullFileName;
171  message += "\" not found";
172  G4Exception("G4ShellEMDataSet::LoadData()", "em0003",FatalException, message);
173  return 0;
174  }
175 
176  G4DataVector* orig_shell_energies = 0;
177  G4DataVector* orig_shell_data = 0;
178  G4DataVector* log_shell_energies = 0;
179  G4DataVector* log_shell_data = 0;
180 
181  G4double a = 0.;
182  G4int shellIndex = 0;
183  G4int k = 0;
184  G4int nColumns = 2;
185 
186  do
187  {
188  in >> a;
189 
190  if (a==0.) a=1e-300;
191 
192  // The file is organized into four columns:
193  // 1st column contains the values of energy
194  // 2nd column contains the corresponding data value
195  // The file terminates with the pattern: -1 -1
196  // -2 -2
197  //
198  if (a == -1)
199  {
200  if ((k%nColumns == 0) && (orig_shell_energies != 0) )
201  {
202  AddComponent(new G4EMDataSet(shellIndex, orig_shell_energies, orig_shell_data, log_shell_energies, log_shell_data, algorithm->Clone(), unitEnergies, unitData));
203  orig_shell_energies = 0;
204  orig_shell_data = 0;
205  log_shell_energies = 0;
206  log_shell_data = 0;
207  }
208  }
209  else if (a != -2)
210  {
211  if (orig_shell_energies == 0)
212  {
213  orig_shell_energies = new G4DataVector;
214  orig_shell_data = new G4DataVector;
215  log_shell_energies = new G4DataVector;
216  log_shell_data = new G4DataVector;
217  }
218  if (k%nColumns == 0)
219  {
220  orig_shell_energies->push_back(a*unitEnergies);
221  log_shell_energies->push_back(std::log10(a) + std::log10(unitEnergies));
222  }
223  else if (k%nColumns == 1)
224  {
225  orig_shell_data->push_back(a*unitData);
226  log_shell_data->push_back(std::log10(a) + std::log10(unitData));
227  }
228  k++;
229  }
230  else k = 1;
231  }
232  while (a != -2); // End of file
233 
234 
235  delete orig_shell_energies;
236  delete orig_shell_data;
237  delete log_shell_energies;
238  delete log_shell_data;
239 
240  return true;
241 }
void CleanUpComponents(void)
int G4int
Definition: G4Types.hh:78
virtual G4VDataSetAlgorithm * Clone() const =0
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double G4double
Definition: G4Types.hh:76
virtual void AddComponent(G4VEMDataSet *dataSet)
G4bool G4ShellEMDataSet::LoadNonLogData ( const G4String fileName)
virtual

Implements G4VEMDataSet.

Definition at line 244 of file G4ShellEMDataSet.cc.

References test::a, AddComponent(), CleanUpComponents(), G4VDataSetAlgorithm::Clone(), FatalException, and G4Exception().

245 {
247 
248  G4String fullFileName = FullFileName(file);
249  std::ifstream in(fullFileName);
250 
251  if (!in.is_open())
252  {
253  G4String message("G4ShellEMDataSet::LoadData - data file \"");
254  message += fullFileName;
255  message += "\" not found";
256  G4Exception("G4ShellEMDataSet::LoadNonLogData()", "em0003",FatalException, message);
257  return 0;
258  }
259 
260  G4DataVector* orig_shell_energies = 0;
261  G4DataVector* orig_shell_data = 0;
262 
263  G4double a = 0.;
264  G4int shellIndex = 0;
265  G4int k = 0;
266  G4int nColumns = 2;
267 
268  do
269  {
270  in >> a;
271 
272  // The file is organized into four columns:
273  // 1st column contains the values of energy
274  // 2nd column contains the corresponding data value
275  // The file terminates with the pattern: -1 -1
276  // -2 -2
277  //
278  if (a == -1)
279  {
280  if ((k%nColumns == 0) && (orig_shell_energies != 0) )
281  {
282  AddComponent(new G4EMDataSet(shellIndex, orig_shell_energies, orig_shell_data, algorithm->Clone(), unitEnergies, unitData));
283  orig_shell_energies = 0;
284  orig_shell_data = 0;
285  }
286  }
287  else if (a != -2)
288  {
289  if (orig_shell_energies == 0)
290  {
291  orig_shell_energies = new G4DataVector;
292  orig_shell_data = new G4DataVector;
293  }
294  if (k%nColumns == 0)
295  {
296  orig_shell_energies->push_back(a*unitEnergies);
297  }
298  else if (k%nColumns == 1)
299  {
300  orig_shell_data->push_back(a*unitData);
301  }
302  k++;
303  }
304  else k = 1;
305  }
306  while (a != -2); // End of file
307 
308 
309  delete orig_shell_energies;
310  delete orig_shell_data;
311 
312  return true;
313 }
void CleanUpComponents(void)
int G4int
Definition: G4Types.hh:78
virtual G4VDataSetAlgorithm * Clone() const =0
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double G4double
Definition: G4Types.hh:76
virtual void AddComponent(G4VEMDataSet *dataSet)
virtual size_t G4ShellEMDataSet::NumberOfComponents ( void  ) const
inlinevirtual

Implements G4VEMDataSet.

Definition at line 76 of file G4ShellEMDataSet.hh.

Referenced by PrintData(), and SaveData().

76 { return components.size(); }
void G4ShellEMDataSet::PrintData ( void  ) const
virtual

Implements G4VEMDataSet.

Definition at line 102 of file G4ShellEMDataSet.cc.

References G4cout, G4endl, GetComponent(), n, NumberOfComponents(), and G4VEMDataSet::PrintData().

103 {
104  const size_t n = NumberOfComponents();
105 
106  G4cout << "The data set has " << n << " components" << G4endl;
107  G4cout << G4endl;
108 
109  size_t i = 0;
110 
111  while (i < n)
112  {
113  G4cout << "--- Component " << i << " ---" << G4endl;
114  GetComponent(i)->PrintData();
115  i++;
116  }
117 }
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
virtual G4double G4ShellEMDataSet::RandomSelect ( G4int  ) const
inlinevirtual

Implements G4VEMDataSet.

Definition at line 95 of file G4ShellEMDataSet.hh.

95 { return -1.; };
G4bool G4ShellEMDataSet::SaveData ( const G4String fileName) const
virtual

Implements G4VEMDataSet.

Definition at line 317 of file G4ShellEMDataSet.cc.

References FatalException, G4Exception(), GetComponent(), G4VEMDataSet::GetData(), G4VEMDataSet::GetEnergies(), left, n, and NumberOfComponents().

318 {
319  G4String fullFileName = FullFileName(file);
320  std::ofstream out(fullFileName);
321 
322  if (!out.is_open())
323  {
324  G4String message("Cannot open \"");
325  message += fullFileName;
326  message += "\"";
327  G4Exception("G4EMDataSet::SaveData()","em0005",FatalException,message);
328  }
329 
330  const size_t n = NumberOfComponents();
331  size_t k = 0;
332 
333  while (k < n)
334  {
335  const G4VEMDataSet* component = GetComponent(k);
336 
337  if (component)
338  {
339  const G4DataVector& energies = component->GetEnergies(0);
340  const G4DataVector& data = component->GetData(0);
341 
342  G4DataVector::const_iterator i = energies.begin();
343  G4DataVector::const_iterator endI = energies.end();
344  G4DataVector::const_iterator j = data.begin();
345 
346  while (i != endI)
347  {
348  out.precision(10);
349  out.width(15);
350  out.setf(std::ofstream::left);
351  out << ((*i)/unitEnergies) << ' ';
352 
353  out.precision(10);
354  out.width(15);
355  out.setf(std::ofstream::left);
356  out << ((*j)/unitData) << std::endl;
357  i++;
358  j++;
359  }
360  }
361 
362  out.precision(10);
363  out.width(15);
364  out.setf(std::ofstream::left);
365  out << -1.f << ' ';
366 
367  out.precision(10);
368  out.width(15);
369  out.setf(std::ofstream::left);
370  out << -1.f << std::endl;
371 
372  k++;
373  }
374 
375  out.precision(10);
376  out.width(15);
377  out.setf(std::ofstream::left);
378  out << -2.f << ' ';
379 
380  out.precision(10);
381  out.width(15);
382  out.setf(std::ofstream::left);
383  out << -2.f << std::endl;
384 
385  return true;
386 }
virtual const G4DataVector & GetEnergies(G4int componentId) const =0
virtual size_t NumberOfComponents(void) const
virtual const G4DataVector & GetData(G4int componentId) const =0
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
const XML_Char const XML_Char * data
void G4ShellEMDataSet::SetEnergiesData ( G4DataVector energies,
G4DataVector data,
G4int  componentId 
)
virtual

Implements G4VEMDataSet.

Definition at line 120 of file G4ShellEMDataSet.cc.

References FatalErrorInArgument, G4Exception(), and G4VEMDataSet::SetEnergiesData().

123 {
124  G4VEMDataSet* component = components[componentId];
125 
126  if (component)
127  {
128  component->SetEnergiesData(energies, data, 0);
129  return;
130  }
131 
132  G4String msg = "component " + (G4String)componentId + " not found";
133 
134  G4Exception("G4ShellEMDataSet::SetEnergiesData()","em0008", FatalErrorInArgument ,msg);
135 }
virtual void SetEnergiesData(G4DataVector *x, G4DataVector *data, G4int component=0)=0
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void G4ShellEMDataSet::SetLogEnergiesData ( G4DataVector energies,
G4DataVector data,
G4DataVector log_energies,
G4DataVector log_data,
G4int  componentId 
)
virtual

Implements G4VEMDataSet.

Definition at line 138 of file G4ShellEMDataSet.cc.

References FatalErrorInArgument, G4Exception(), and G4VEMDataSet::SetLogEnergiesData().

143 {
144  G4VEMDataSet* component = components[componentId];
145 
146  if (component)
147  {
148  component->SetLogEnergiesData(energies, data, log_energies, log_data, 0);
149  return;
150  }
151 
152  G4String msg = "component " + (G4String)componentId + " not found";
153 
154  G4Exception("G4ShellEMDataSet::SetLogEnergiesData()","em0008", FatalErrorInArgument ,msg);
155 
156 }
virtual void SetLogEnergiesData(G4DataVector *x, G4DataVector *data, G4DataVector *Log_x, G4DataVector *Log_data, G4int component=0)=0
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

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