Geant4  10.02.p03
G4eIonisationParameters Class Reference

#include <G4eIonisationParameters.hh>

Collaboration diagram for G4eIonisationParameters:

Public Member Functions

 G4eIonisationParameters (G4int minZ=1, G4int maxZ=99)
 
 ~G4eIonisationParameters ()
 
G4double Parameter (G4int Z, G4int shellIndex, G4int parameterIndex, G4double e) const
 
G4double Excitation (G4int Z, G4double e) const
 
void PrintData () const
 

Private Member Functions

 G4eIonisationParameters (const G4eIonisationParameters &)
 
G4eIonisationParametersoperator= (const G4eIonisationParameters &right)
 
void LoadData ()
 

Private Attributes

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

Detailed Description

Definition at line 61 of file G4eIonisationParameters.hh.

Constructor & Destructor Documentation

◆ G4eIonisationParameters() [1/2]

G4eIonisationParameters::G4eIonisationParameters ( G4int  minZ = 1,
G4int  maxZ = 99 
)

Definition at line 63 of file G4eIonisationParameters.cc.

Here is the call graph for this function:

◆ ~G4eIonisationParameters()

G4eIonisationParameters::~G4eIonisationParameters ( )

Definition at line 71 of file G4eIonisationParameters.cc.

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

◆ G4eIonisationParameters() [2/2]

G4eIonisationParameters::G4eIonisationParameters ( const G4eIonisationParameters )
private

Member Function Documentation

◆ Excitation()

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

Definition at line 125 of file G4eIonisationParameters.cc.

126 {
127  G4double value = 0.;
128  std::map<G4int,G4VEMDataSet*,std::less<G4int> >::const_iterator pos;
129 
130  pos = excit.find(Z);
131  if (pos!= excit.end()) {
132  G4VEMDataSet* dataSet = (*pos).second;
133 
134  const G4DataVector ener = dataSet->GetEnergies(0);
135  G4double ee = std::max(ener.front(),std::min(ener.back(),e));
136  value = dataSet->FindValue(ee);
137  } else {
138  G4cout << "WARNING: G4IonisationParameters::Excitation "
139  << "did not find ID = "
140  << Z << G4endl;
141  }
142 
143  return value;
144 }
virtual const G4DataVector & GetEnergies(G4int componentId) const =0
virtual G4double FindValue(G4double x, G4int componentId=0) const =0
G4GLOB_DLL std::ostream G4cout
Float_t Z
std::map< G4int, G4VEMDataSet *, std::less< G4int > > excit
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
static const G4double pos
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadData()

void G4eIonisationParameters::LoadData ( )
private

Definition at line 147 of file G4eIonisationParameters.cc.

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

◆ operator=()

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

◆ Parameter()

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

Definition at line 92 of file G4eIonisationParameters.cc.

95 {
96  G4double value = 0.;
97  G4int id = Z*100 + parameterIndex;
98  std::map<G4int,G4VEMDataSet*,std::less<G4int> >::const_iterator pos;
99 
100  pos = param.find(id);
101  if (pos!= param.end()) {
102  G4VEMDataSet* dataSet = (*pos).second;
103  G4int nShells = dataSet->NumberOfComponents();
104 
105  if(shellIndex < nShells) {
106  const G4VEMDataSet* component = dataSet->GetComponent(shellIndex);
107  const G4DataVector ener = component->GetEnergies(0);
108  G4double ee = std::max(ener.front(),std::min(ener.back(),e));
109  value = component->FindValue(ee);
110  } else {
111  G4cout << "WARNING: G4IonisationParameters::FindParameter "
112  << "has no parameters for shell= " << shellIndex
113  << "; Z= " << Z
114  << G4endl;
115  }
116  } else {
117  G4cout << "WARNING: G4IonisationParameters::Parameter "
118  << "did not find ID = "
119  << shellIndex << G4endl;
120  }
121 
122  return value;
123 }
virtual const G4DataVector & GetEnergies(G4int componentId) const =0
virtual G4double FindValue(G4double x, G4int componentId=0) const =0
std::map< G4int, G4VEMDataSet *, std::less< G4int > > param
int G4int
Definition: G4Types.hh:78
virtual const G4VEMDataSet * GetComponent(G4int componentId) const =0
G4GLOB_DLL std::ostream G4cout
virtual size_t NumberOfComponents(void) const =0
Float_t Z
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
static const G4double pos
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PrintData()

void G4eIonisationParameters::PrintData ( void  ) const

Definition at line 384 of file G4eIonisationParameters.cc.

385 {
386  G4cout << G4endl;
387  G4cout << "===== G4eIonisationParameters =====" << G4endl;
388  G4cout << G4endl;
389 
390  size_t nZ = activeZ.size();
391  std::map<G4int,G4VEMDataSet*,std::less<G4int> >::const_iterator pos;
392 
393  for (size_t i=0; i<nZ; i++) {
394  G4int Z = (G4int)activeZ[i];
395 
396  for (size_t j=0; j<length; j++) {
397 
398  G4int index = Z*100 + j;
399 
400  pos = param.find(index);
401  if (pos!= param.end()) {
402  G4VEMDataSet* dataSet = (*pos).second;
403  size_t nShells = dataSet->NumberOfComponents();
404 
405  for (size_t k=0; k<nShells; k++) {
406 
407  G4cout << "===== Z= " << Z << " shell= " << k
408  << " parameter[" << j << "] ====="
409  << G4endl;
410  const G4VEMDataSet* comp = dataSet->GetComponent(k);
411  comp->PrintData();
412  }
413  }
414  }
415  }
416  G4cout << "====================================" << G4endl;
417 }
Int_t index
std::map< G4int, G4VEMDataSet *, std::less< G4int > > param
int G4int
Definition: G4Types.hh:78
virtual const G4VEMDataSet * GetComponent(G4int componentId) const =0
G4GLOB_DLL std::ostream G4cout
virtual size_t NumberOfComponents(void) const =0
Float_t Z
virtual void PrintData(void) const =0
#define G4endl
Definition: G4ios.hh:61
static const G4double pos
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ activeZ

G4DataVector G4eIonisationParameters::activeZ
private

Definition at line 87 of file G4eIonisationParameters.hh.

◆ excit

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

Definition at line 91 of file G4eIonisationParameters.hh.

◆ length

size_t G4eIonisationParameters::length
private

Definition at line 93 of file G4eIonisationParameters.hh.

◆ param

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

Definition at line 90 of file G4eIonisationParameters.hh.

◆ zMax

G4int G4eIonisationParameters::zMax
private

Definition at line 85 of file G4eIonisationParameters.hh.

◆ zMin

G4int G4eIonisationParameters::zMin
private

Definition at line 84 of file G4eIonisationParameters.hh.


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