Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4RDAugerData.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4RDAugerData.cc v1.0
28 //
29 //
30 // Author: Alfonso Mmantero (Alfonso.Mantero@ge.infn.it)
31 //
32 // History:
33 // -----------
34 // Based on G4RDFluoData by Elena Guardincerri
35 //
36 // Modified: 30.07.02 VI Add select active Z + clean up against pedantic compiler
37 //
38 // -------------------------------------------------------------------
39 
40 #include <fstream>
41 #include <sstream>
42 
43 #include "G4RDAugerData.hh"
44 #include "G4PhysicalConstants.hh"
45 #include "G4SystemOfUnits.hh"
46 #include "G4DataVector.hh"
47 #include "G4Material.hh"
48 #include "G4Element.hh"
49 #include "G4ElementVector.hh"
50 
52 {
53 
54  G4int n = 0;
55  G4int pos = 0;
56 
57  for (pos = 0 ; pos < 100; pos++)
58  {
59  numberOfVacancies.push_back(n);
60  }
61 
63 
64 
65 }
66 
68 {
69  /*
70  std::map<G4int,std::vector<G4RDAugerTransition>,std::less<G4int> >::iterator pos;
71 
72  for (pos = augerTransitionTable.begin(); pos != augerTransitionTable.end(); pos++)
73  {
74  std::vector<G4RDAugerTransition> dataSet = (*pos).second;
75  delete dataSet;
76  }
77  for (pos = energyMap.begin(); pos != energyMap.end(); pos++)
78  {
79  std::map<G4Int,G4DataVector*,std::less<G4int>>* dataMap = (*pos).second;
80  for (pos2 = newIdProbabilityMap.begin(); pos2 != idMap.end(); pos2++)
81  {
82  G4DataVector* dataSet = (*pos2).second;
83  delete dataSet;
84  }
85  }
86  for (pos = probabilityMap.begin(); pos != probabilityMap.end(); pos++)
87  {
88  std::map<G4Int,G4DataVector*,std::less<G4int>>* dataMap = (*pos).second;
89  for (pos2 = newIdProbabilityMap.begin(); pos2 != idMap.end(); pos2++)
90  {
91  G4DataVector* dataSet = (*pos2).second;
92  delete dataSet;
93  }
94  }
95  for (pos2 = newIdMap.begin(); pos2 != idMap.end(); pos2++)
96  {
97  G4DataVector* dataSet = (*pos2).second;
98  delete dataSet;
99  }
100  for (pos2 = newIdEnergyMap.begin(); pos2 != idMap.end(); pos2++)
101  {
102  G4DataVector* dataSet = (*pos2).second;
103  delete dataSet;
104  }
105  for (pos2 = newIdProbabilityMap.begin(); pos2 != idMap.end(); pos2++)
106  {
107  G4DataVector* dataSet = (*pos2).second;
108  delete dataSet;
109  }
110  */
111 
112 }
113 
115 {
116  return numberOfVacancies[Z];
117 }
118 
120 {
121 
122  G4int n = 0;
123  if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies[Z])
124  {G4Exception("G4RDAugerData::VacancyId()", "OutOfRange",
125  FatalException, "VacancyIndex outside boundaries!");}
126  else {
127  trans_Table::const_iterator element = augerTransitionTable.find(Z);
128  if (element == augerTransitionTable.end())
129  {G4Exception("G4RDAugerData::VacancyId()", "NoDataFound",
130  FatalException, "Data not loaded!");}
131  std::vector<G4RDAugerTransition> dataSet = (*element).second;
132  n = (G4int) dataSet[vacancyIndex].FinalShellId();
133  }
134 
135  return n;
136 }
137 
138 
139 
140 // Attenzione: questa funzione vuole l'indice della vacanza, non l'Id
141 
142 
143 size_t G4RDAugerData::NumberOfTransitions(G4int Z, G4int vacancyIndex) const
144 {
145  G4int n = 0;
146  if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies[Z])
147  {G4Exception("G4RDAugerData::NumberOfTransitions()", "OutOfRange",
148  FatalException, "VacancyIndex outside boundaries!");}
149  else {
150  trans_Table::const_iterator element = augerTransitionTable.find(Z);
151  if (element == augerTransitionTable.end())
152  {G4Exception("G4RDAugerData::NumberOfTransitions()", "NoDataFound",
153  FatalException, "Data not loaded!");}
154  std::vector<G4RDAugerTransition> dataSet = (*element).second;
155  n = (G4int)dataSet[vacancyIndex].TransitionOriginatingShellIds()->size();
156  }
157  return n;
158 }
159 
160 
161 
162 size_t G4RDAugerData::NumberOfAuger(G4int Z, G4int initIndex, G4int vacancyId) const
163 {
164  size_t n = 0;
165  if (initIndex<0 || initIndex>=numberOfVacancies[Z])
166  {G4Exception("G4RDAugerData::NumberOfAuger()", "OutOfRange",
167  FatalException, "VacancyIndex outside boundaries!");}
168  else {
169  trans_Table::const_iterator element = augerTransitionTable.find(Z);
170  if (element == augerTransitionTable.end())
171  {G4Exception("G4RDAugerData::NumberOfAuger()", "NoDataFound",
172  FatalException, "Data not loaded!");}
173  std::vector<G4RDAugerTransition> dataSet = (*element).second;
174  const std::vector<G4int>* temp = dataSet[initIndex].AugerOriginatingShellIds(vacancyId);
175  n = temp->size();
176  }
177  return n;
178 }
179 
180 size_t G4RDAugerData::AugerShellId(G4int Z, G4int vacancyIndex, G4int transId, G4int augerIndex) const
181 {
182  size_t n = 0;
183  if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies[Z])
184  {G4Exception("G4RDAugerData::AugerShellId()", "OutOfRange",
185  FatalException, "VacancyIndex outside boundaries!");}
186  else {
187  trans_Table::const_iterator element = augerTransitionTable.find(Z);
188  if (element == augerTransitionTable.end())
189  {G4Exception("G4RDAugerData::AugerShellId()", "NoDataFound",
190  FatalException, "Data not loaded!");}
191  std::vector<G4RDAugerTransition> dataSet = (*element).second;
192  n = dataSet[vacancyIndex].AugerOriginatingShellId(augerIndex,transId);
193  }
194  return n;
195 }
196 
197 G4int G4RDAugerData::StartShellId(G4int Z, G4int vacancyIndex, G4int transitionShellIndex) const
198 {
199  G4int n = 0;
200 
201  if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies[Z])
202  {G4Exception("G4RDAugerData::StartShellId()", "OutOfRange",
203  FatalException, "VacancyIndex outside boundaries!");}
204  else {
205  trans_Table::const_iterator element = augerTransitionTable.find(Z);
206  if (element == augerTransitionTable.end())
207  {G4Exception("G4RDAugerData::StartShellId()", "NoDataFound",
208  FatalException, "Data not loaded!");}
209  std::vector<G4RDAugerTransition> dataSet = (*element).second;
210  n = dataSet[vacancyIndex].TransitionOriginatingShellId(transitionShellIndex);
211  }
212 
213 
214  return n;
215 }
216 
217 G4double G4RDAugerData::StartShellEnergy(G4int Z, G4int vacancyIndex, G4int transitionId, G4int augerIndex) const
218 {
219  G4double energy = 0;
220 
221  if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies[Z])
222  {G4Exception("G4RDAugerData::StartShellEnergy()", "OutOfRange",
223  FatalException, "VacancyIndex outside boundaries!");}
224  else {
225  trans_Table::const_iterator element = augerTransitionTable.find(Z);
226  if (element == augerTransitionTable.end())
227  {G4Exception("G4RDAugerData::StartShellEnergy()", "NoDataFound",
228  FatalException, "Data not loaded!");}
229  std::vector<G4RDAugerTransition> dataSet = (*element).second;
230  energy = dataSet[vacancyIndex].AugerTransitionEnergy(augerIndex,transitionId);
231 
232  }
233  return energy;
234 }
235 
236 
237 G4double G4RDAugerData::StartShellProb(G4int Z, G4int vacancyIndex,G4int transitionId,G4int augerIndex) const
238 {
239  G4double prob = 0;
240 
241  if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies[Z])
242  {G4Exception("G4RDAugerData::StartShellProb()", "OutOfRange",
243  FatalException, "VacancyIndex outside boundaries!");}
244  else {
245  trans_Table::const_iterator element = augerTransitionTable.find(Z);
246  if (element == augerTransitionTable.end())
247  {G4Exception("G4RDAugerData::StartShellProb()", "NoDataFound",
248  FatalException, "Data not loaded!");}
249  std::vector<G4RDAugerTransition> dataSet = (*element).second;
250  prob = dataSet[vacancyIndex].AugerTransitionProbability(augerIndex, transitionId);
251 
252 
253 
254  }
255  return prob;
256 }
257 
258 std::vector<G4RDAugerTransition> G4RDAugerData::LoadData(G4int Z)
259 {
260  // Build the complete string identifying the file with the data set
261 
262  std::ostringstream ost;
263  if(Z != 0){
264  ost << "au-tr-pr-"<< Z << ".dat";
265  }
266  else{
267  ost << "au-tr-pr-"<<".dat";
268  }
269  G4String name(ost.str());
270 
271  char* path = getenv("G4LEDATA");
272  if (!path)
273  {
274  G4String excep = "G4LEDATA environment variable not set";
275  G4Exception("G4RDAugerData::LoadData()", "InvalidSetup",
276  FatalException, excep);
277  }
278 
279  G4String pathString(path);
280  G4String dirFile = pathString + "/auger/" + name;
281  std::ifstream file(dirFile);
282  std::filebuf* lsdp = file.rdbuf();
283 
284  if (! (lsdp->is_open()) )
285  {
286  G4String excep = "Data file: " + dirFile + " not found!";
287  G4Exception("G4RDAugerData::LoadData()", "DataNotFound",
288  FatalException, excep);
289  }
290 
291 
292  G4double a = 0;
293  G4int k = 1;
294  G4int s = 0;
295 
296  G4int vacId = 0;
297  std::vector<G4int>* initIds = new std::vector<G4int>;
298  std::vector<G4int>* newIds = new std::vector<G4int>;
299  G4DataVector* transEnergies = new G4DataVector;
300  G4DataVector* transProbabilities = new G4DataVector;
301  std::vector<G4RDAugerTransition> augerTransitionVector;
302  std::map<G4int,std::vector<G4int>,std::less<G4int> >* newIdMap =
303  new std::map<G4int,std::vector<G4int>,std::less<G4int> >;
304  std::map<G4int,G4DataVector,std::less<G4int> >* newEnergyMap =
305  new std::map<G4int,G4DataVector,std::less<G4int> >;
306  std::map<G4int,G4DataVector,std::less<G4int> >* newProbabilityMap =
307  new std::map<G4int,G4DataVector,std::less<G4int> >;
308 
309 
310  do {
311  file >> a;
312 
313 
314  G4int nColumns = 4;
315 
316  if (a == -1)
317  {
318 
319 
320 
321  if (s == 0)
322  {
323  // End of a shell data set
324 
325 
326 
327  std::vector<G4int>::iterator vectorIndex = initIds->begin();
328 
329  vacId = *vectorIndex;
330 
331  //initIds->erase(vectorIndex);
332 
333 
334 
335  std::vector<G4int> identifiers;
336  for (vectorIndex = initIds->begin()+1 ; vectorIndex != initIds->end(); ++vectorIndex){
337 
338  identifiers.push_back(*vectorIndex);
339  }
340 
341  vectorIndex = (initIds->end())-1;
342 
343  G4int augerShellId = *(vectorIndex);
344 
345 
346  (*newIdMap)[augerShellId] = *newIds;
347  (*newEnergyMap)[augerShellId] = *transEnergies;
348  (*newProbabilityMap)[augerShellId] = *transProbabilities;
349 
350  augerTransitionVector.push_back(G4RDAugerTransition(vacId, identifiers, newIdMap, newEnergyMap, newProbabilityMap));
351 
352  // Now deleting all the variables I used, and creating new ones for the next shell
353 
354  delete newIdMap;
355  delete newEnergyMap;
356  delete newProbabilityMap;
357 
358  G4int n = initIds->size();
359  nInitShells.push_back(n);
360  numberOfVacancies[Z]++;
361  delete initIds;
362  delete newIds;
363  delete transEnergies;
364  delete transProbabilities;
365  initIds = new std::vector<G4int>;
366  newIds = new std::vector<G4int>;
367  transEnergies = new G4DataVector;
368  transProbabilities = new G4DataVector;
369  newIdMap = new std::map<G4int,std::vector<G4int>,std::less<G4int> >;
370  newEnergyMap = new std::map<G4int,G4DataVector,std::less<G4int> >;
371  newProbabilityMap = new std::map<G4int,G4DataVector,std::less<G4int> >;
372 
373 
374 
375  }
376  s++;
377  if (s == nColumns)
378  {
379  s = 0;
380  }
381  }
382  else if (a == -2)
383  {
384  // End of file; delete the empty vectors created
385  //when encountering the last -1 -1 row
386  delete initIds;
387  delete newIds;
388  delete transEnergies;
389  delete transProbabilities;
390  delete newIdMap ;
391  delete newEnergyMap;
392  delete newProbabilityMap;
393  }
394  else
395  {
396 
397  if (k%nColumns == 3){
398  // 3rd column is the transition probabilities
399  transProbabilities->push_back(a);
400 
401  k++;}
402  else if(k%nColumns == 2){
403  // 2nd column is new auger vacancy
404 
405  // 2nd column is new auger vacancy
406 
407  G4int l = (G4int)a;
408  newIds->push_back(l);
409 
410 
411  k++;
412  }
413  else if (k%nColumns == 1)
414  {
415  // 1st column is shell id
416 
417  if(initIds->size() == 0) {
418 
419  // if this is the first data of the shell, all the colums are equal
420  // to the shell Id; so we skip the next colums ang go to the next row
421 
422  initIds->push_back((G4int)a);
423  // first line of initIds is the original shell of the vacancy
424  file >> a;
425  file >> a;
426  file >> a;
427  k = k+3;
428  }
429  else {
430 
431  // std::vector<G4int>::iterator vectorIndex = (initIds->end())-1;
432  if((G4int)a != initIds->back()){
433 
434 
435  if((initIds->size()) == 1) {
436  initIds->push_back((G4int)a);
437  }
438  else {
439 
440 
441  G4int augerShellId = 0;
442  augerShellId = initIds->back();
443 
444  (*newIdMap)[augerShellId] = *newIds;
445  (*newEnergyMap)[augerShellId] = *transEnergies;
446  (*newProbabilityMap)[augerShellId] = *transProbabilities;
447  delete newIds;
448  delete transEnergies;
449  delete transProbabilities;
450  newIds = new std::vector<G4int>;
451  transEnergies = new G4DataVector;
452  transProbabilities = new G4DataVector;
453  initIds->push_back((G4int)a);
454  }
455  }
456  }
457 
458  k++;
459 
460  }
461  else if (k%nColumns == 0)
462 
463  {//fourth column is transition energies
464  G4double e = a * MeV;
465 
466  transEnergies->push_back(e);
467  k=1;
468 
469  }
470  }
471  }
472 
473 
474  while (a != -2); // end of file
475  file.close();
476  return augerTransitionVector;
477 
478 }
479 
481 {
482 
483  // trans_Table::iterator pos = augerTransitionTable.begin();
484 
485  const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
486 
488 
489  G4DataVector activeZ;
490  activeZ.clear();
491 
492  for (G4int m=0; m<nMaterials; m++) {
493 
494  const G4Material* material= (*materialTable)[m];
495  const G4ElementVector* elementVector = material->GetElementVector();
496  const size_t nElements = material->GetNumberOfElements();
497 
498  for (size_t iEl=0; iEl<nElements; iEl++) {
499  G4Element* element = (*elementVector)[iEl];
500  G4double Z = element->GetZ();
501  if (!(activeZ.contains(Z))) {
502  activeZ.push_back(Z);
503  }
504  }
505  }
506 
507 
508  for (G4int element = 6; element < 101; element++)
509  {
510  if(nMaterials == 0 || activeZ.contains(element)) {
511  augerTransitionTable.insert(trans_Table::value_type(element,LoadData(element)));
512 
513  G4cout << "G4RDAugerData for Element no. " << element << " are loaded" << G4endl;
514  // PrintData(element);
515  }
516  }
517 
518  G4cout << "AugerTransitionTable complete"<< G4endl;
519 }
520 
522 {
523 
524  for (G4int i = 0; i < numberOfVacancies[Z]; i++)
525  {
526  G4cout << "---- TransitionData for the vacancy nb "
527  <<i
528  <<" of the atomic number elemnt "
529  << Z
530  <<"----- "
531  <<G4endl;
532 
533  for (size_t k = 0; k<=NumberOfTransitions(Z,i); k++)
534  {
535  G4int id = StartShellId(Z,i,k);
536 
537  for (size_t a = 0; a <= NumberOfAuger(Z,i,id); a++) {
538 
539  G4double e = StartShellEnergy(Z,i,id,a) /MeV;
540  G4double p = StartShellProb(Z,i,id,a);
541  G4int augerId = AugerShellId(Z, i, id, a);
542  G4cout << k <<") Shell id: " << id <<G4endl;
543  G4cout << " Auger Originatig Shell Id :"<< augerId <<G4endl;
544  G4cout << " - Transition energy = " << e << " MeV "<<G4endl;
545  G4cout << " - Transition probability = " << p <<G4endl;
546  }
547  }
548  G4cout << "-------------------------------------------------"
549  << G4endl;
550  }
551 }
553  {
554  std::vector<G4RDAugerTransition>* dataSet = &augerTransitionTable[Z];
555  std::vector<G4RDAugerTransition>::iterator vectorIndex = dataSet->begin() + vacancyShellIndex;
556 
557  G4RDAugerTransition* augerTransition = &(*vectorIndex);
558  return augerTransition;
559  }
560 
561 std::vector<G4RDAugerTransition>* G4RDAugerData::GetAugerTransitions(G4int Z)
562  {
563  std::vector<G4RDAugerTransition>* dataSet = &augerTransitionTable[Z];
564  return dataSet;
565  }
566 
567 
568 
569 
570 
571 
572 
573 
574 
575 
576 
577 
578 
579 
580 
581 
582 
583 
584 
585 
586 
const XML_Char * name
Definition: expat.h:151
G4double StartShellProb(G4int Z, G4int vacancyIndex, G4int transitionId, G4int augerIndex) const
std::vector< G4Element * > G4ElementVector
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
const char * p
Definition: xmltok.h:285
G4double StartShellEnergy(G4int Z, G4int vacancyIndex, G4int transitionId, G4int augerIndex) const
G4int StartShellId(G4int Z, G4int initialVacancyIndex, G4int transitionShellIndex) const
G4double GetZ() const
Definition: G4Element.hh:131
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:587
std::vector< G4Material * > G4MaterialTable
size_t AugerShellId(G4int Z, G4int vacancyIndex, G4int transId, G4int augerIndex) const
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:190
int G4int
Definition: G4Types.hh:78
std::vector< G4RDAugerTransition > * GetAugerTransitions(G4int Z)
string material
Definition: eplot.py:19
std::vector< G4RDAugerTransition > LoadData(G4int Z)
const XML_Char * s
Definition: expat.h:262
G4GLOB_DLL std::ostream G4cout
static constexpr double m
Definition: G4SIunits.hh:129
size_t NumberOfTransitions(G4int Z, G4int vacancyIndex) const
G4int VacancyId(G4int Z, G4int vacancyIndex) const
const G4int n
static size_t GetNumberOfMaterials()
Definition: G4Material.cc:594
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4double energy(const ThreeVector &p, const G4double m)
G4RDAugerTransition * GetAugerTransition(G4int Z, G4int vacancyShellIndex)
size_t NumberOfAuger(G4int Z, G4int initIndex, G4int vacancyId) const
#define G4endl
Definition: G4ios.hh:61
size_t NumberOfVacancies(G4int Z) const
static constexpr double MeV
Definition: G4SIunits.hh:214
size_t GetNumberOfElements() const
Definition: G4Material.hh:186
double G4double
Definition: G4Types.hh:76
void BuildAugerTransitionTable()
G4bool contains(const G4double &) const
static const G4double pos
void PrintData(G4int Z)