ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4AugerData.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4AugerData.cc
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 //
28 //
29 // Author: Alfonso Mmantero (Alfonso.Mantero@ge.infn.it)
30 //
31 // History:
32 // -----------
33 // Based on G4FluoData by Elena Guardincerri
34 //
35 // Modified: 30.07.02 VI Add select active Z + clean up against pedantic compiler
36 //
37 // -------------------------------------------------------------------
38 
39 #include <fstream>
40 #include <sstream>
41 
42 #include "G4AugerData.hh"
43 #include "G4SystemOfUnits.hh"
44 #include "G4DataVector.hh"
45 #include "G4Material.hh"
46 #include "G4Element.hh"
47 #include "G4ElementVector.hh"
48 
50 {
51 
52  G4int n = 0;
53  G4int pos = 0;
54 
55  for (pos = 0 ; pos < 100; pos++)
56  {
57  numberOfVacancies.push_back(n);
58  }
59 
61 
62 
63 }
64 
66 {
67  /*
68  std::map<G4int,std::vector<G4AugerTransition>,std::less<G4int> >::iterator pos;
69 
70  for (pos = augerTransitionTable.begin(); pos != augerTransitionTable.end(); pos++)
71  {
72  std::vector<G4AugerTransition> dataSet = (*pos).second;
73  delete dataSet;
74  }
75  for (pos = energyMap.begin(); pos != energyMap.end(); pos++)
76  {
77  std::map<G4Int,G4DataVector*,std::less<G4int>>* dataMap = (*pos).second;
78  for (pos2 = newIdProbabilityMap.begin(); pos2 != idMap.end(); pos2++)
79  {
80  G4DataVector* dataSet = (*pos2).second;
81  delete dataSet;
82  }
83  }
84  for (pos = probabilityMap.begin(); pos != probabilityMap.end(); pos++)
85  {
86  std::map<G4Int,G4DataVector*,std::less<G4int>>* dataMap = (*pos).second;
87  for (pos2 = newIdProbabilityMap.begin(); pos2 != idMap.end(); pos2++)
88  {
89  G4DataVector* dataSet = (*pos2).second;
90  delete dataSet;
91  }
92  }
93  for (pos2 = newIdMap.begin(); pos2 != idMap.end(); pos2++)
94  {
95  G4DataVector* dataSet = (*pos2).second;
96  delete dataSet;
97  }
98  for (pos2 = newIdEnergyMap.begin(); pos2 != idMap.end(); pos2++)
99  {
100  G4DataVector* dataSet = (*pos2).second;
101  delete dataSet;
102  }
103  for (pos2 = newIdProbabilityMap.begin(); pos2 != idMap.end(); pos2++)
104  {
105  G4DataVector* dataSet = (*pos2).second;
106  delete dataSet;
107  }
108  */
109 
110 }
111 
113 {
114  return numberOfVacancies[Z];
115 }
116 
118 {
119 
120  G4int n = 0;
121  if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies[Z])
122  {
123  G4Exception("G4AugerData::VacancyId()","de0002", FatalErrorInArgument,"");
124  }
125  else {
126  trans_Table::const_iterator element = augerTransitionTable.find(Z);
127  if (element == augerTransitionTable.end()) {
128  G4Exception("G4AugerData::VacancyId()","de0004", FatalErrorInArgument, "Check element");
129  return 0;
130  }
131  std::vector<G4AugerTransition> dataSet = (*element).second;
132  n = (G4int) dataSet[vacancyIndex].FinalShellId();
133  }
134 
135  return n;
136 }
137 
138 
139 // Attention: this method wants the vacancy index, not the Id
140 
141 size_t G4AugerData::NumberOfTransitions(G4int Z, G4int vacancyIndex) const
142 {
143  G4int n = 0;
144  if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies[Z])
145  {
146  G4Exception("G4AugerData::VacancyId()","de0002", JustWarning, "Energy deposited locally");
147  return 0;
148  }
149  else {
150  trans_Table::const_iterator element = augerTransitionTable.find(Z);
151  if (element == augerTransitionTable.end())
152  {
153  G4Exception("G4AugerData::VacancyId()","de0004", FatalErrorInArgument, "Check element");
154  return 0;
155  }
156  std::vector<G4AugerTransition> dataSet = (*element).second;
157  n = (G4int)dataSet[vacancyIndex].TransitionOriginatingShellIds()->size();
158  }
159  return n;
160 }
161 
162 
163 
164 size_t G4AugerData::NumberOfAuger(G4int Z, G4int initIndex, G4int vacancyId) const
165 {
166  size_t n = 0;
167  if (initIndex<0 || initIndex>=numberOfVacancies[Z])
168  {
169  G4Exception("G4AugerData::VacancyId()","de0002", FatalErrorInArgument,"");
170  return 0;
171  }
172  else {
173  trans_Table::const_iterator element = augerTransitionTable.find(Z);
174  if (element == augerTransitionTable.end()) {
175  G4Exception("G4AugerData::VacancyId()","de0004", FatalErrorInArgument, "Check element");
176  return 0;
177  }
178  std::vector<G4AugerTransition> dataSet = (*element).second;
179  const std::vector<G4int>* temp = dataSet[initIndex].AugerOriginatingShellIds(vacancyId);
180  n = temp->size();
181  }
182  return n;
183 }
184 
185 size_t G4AugerData::AugerShellId(G4int Z, G4int vacancyIndex, G4int transId, G4int augerIndex) const
186 {
187  size_t n = 0;
188  if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies[Z])
189  {
190  G4Exception("G4AugerData::VacancyId()","de0002", FatalErrorInArgument,"");
191  return 0;
192  }
193  else {
194  trans_Table::const_iterator element = augerTransitionTable.find(Z);
195  if (element == augerTransitionTable.end()) {
196  G4Exception("G4AugerData::VacancyId()","de0004", FatalErrorInArgument, "Check element");
197  return 0;
198  }
199  std::vector<G4AugerTransition> dataSet = (*element).second;
200  n = dataSet[vacancyIndex].AugerOriginatingShellId(augerIndex,transId);
201  }
202  return n;
203 }
204 
205 G4int G4AugerData::StartShellId(G4int Z, G4int vacancyIndex, G4int transitionShellIndex) const
206 {
207  G4int n = 0;
208 
209  if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies[Z])
210  {
211  G4Exception("G4AugerData::VacancyId()","de0002", FatalErrorInArgument,"");
212  return 0;
213  }
214  else {
215  trans_Table::const_iterator element = augerTransitionTable.find(Z);
216  if (element == augerTransitionTable.end()) {
217  G4Exception("G4AugerData::VacancyId()","de0004", FatalErrorInArgument, "Check element");
218  return 0;
219  }
220  std::vector<G4AugerTransition> dataSet = (*element).second;
221  n = dataSet[vacancyIndex].TransitionOriginatingShellId(transitionShellIndex);
222  }
223 
224 
225  return n;
226 }
227 
228 G4double G4AugerData::StartShellEnergy(G4int Z, G4int vacancyIndex, G4int transitionId, G4int augerIndex) const
229 {
230  G4double energy = 0;
231 
232  if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies[Z])
233  {
234  G4Exception("G4AugerData::VacancyId()","de0002", FatalErrorInArgument,"");
235  return 0;
236  }
237  else {
238  trans_Table::const_iterator element = augerTransitionTable.find(Z);
239  if (element == augerTransitionTable.end()) {
240  G4Exception("G4AugerData::VacancyId()","de0004", FatalErrorInArgument, "Check element");
241  return 0;
242  }
243  std::vector<G4AugerTransition> dataSet = (*element).second;
244  energy = dataSet[vacancyIndex].AugerTransitionEnergy(augerIndex,transitionId);
245 
246  }
247  return energy;
248 }
249 
250 
251 G4double G4AugerData::StartShellProb(G4int Z, G4int vacancyIndex,G4int transitionId,G4int augerIndex) const
252 {
253  G4double prob = 0;
254 
255  if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies[Z])
256  {
257  G4Exception("G4AugerData::VacancyId()","de0002", FatalErrorInArgument,"");
258  return 0;
259  }
260  else {
261  trans_Table::const_iterator element = augerTransitionTable.find(Z);
262  if (element == augerTransitionTable.end()) {
263  G4Exception("G4AugerData::VacancyId()","de0004", FatalErrorInArgument, "Check element");
264  return 0;
265  }
266  std::vector<G4AugerTransition> dataSet = (*element).second;
267  prob = dataSet[vacancyIndex].AugerTransitionProbability(augerIndex, transitionId);
268 
269 
270 
271  }
272  return prob;
273 }
274 
275 std::vector<G4AugerTransition> G4AugerData::LoadData(G4int Z)
276 {
277  // Build the complete string identifying the file with the data set
278 
279  std::ostringstream ost;
280  if(Z != 0){
281  ost << "au-tr-pr-"<< Z << ".dat";
282  }
283  else{
284  ost << "au-tr-pr-"<<".dat";
285  }
286  G4String name(ost.str());
287 
288  char* path = std::getenv("G4LEDATA");
289  if (!path)
290  {
291  G4String excep = "G4AugerData::LoadData";
292  G4Exception(excep,"em0006", FatalException,"" );
293  std::vector<G4AugerTransition> a;
294  return a;
295  }
296 
297  G4String pathString(path);
298  G4String dirFile = pathString + "/auger/" + name;
299  std::ifstream file(dirFile);
300  std::filebuf* lsdp = file.rdbuf();
301 
302  if (! (lsdp->is_open()) )
303  {
304  G4String excep = "G4AugerData::LoadData";
305  G4String msg = "Missing" + dirFile;
306  G4Exception(excep,"em0003", FatalException, msg);
307  }
308 
309 
310  G4double a = 0;
311  G4int k = 1;
312  G4int sLocal = 0;
313 
314  G4int vacId = 0;
315  std::vector<G4int>* initIds = new std::vector<G4int>;
316  std::vector<G4int>* newIds = new std::vector<G4int>;
317  G4DataVector* transEnergies = new G4DataVector;
318  G4DataVector* transProbabilities = new G4DataVector;
319  std::vector<G4AugerTransition> augerTransitionVector;
320  std::map<G4int,std::vector<G4int>,std::less<G4int> >* newIdMap =
321  new std::map<G4int,std::vector<G4int>,std::less<G4int> >;
322  std::map<G4int,G4DataVector,std::less<G4int> >* newEnergyMap =
323  new std::map<G4int,G4DataVector,std::less<G4int> >;
324  std::map<G4int,G4DataVector,std::less<G4int> >* newProbabilityMap =
325  new std::map<G4int,G4DataVector,std::less<G4int> >;
326 
327 
328  do {
329  file >> a;
330 
331 
332  G4int nColumns = 4;
333 
334  if (a == -1)
335  {
336 
337 
338 
339  if (sLocal == 0)
340  {
341  // End of a shell data set
342 
343 
344 
345  std::vector<G4int>::iterator vectorIndex = initIds->begin();
346 
347  vacId = *vectorIndex;
348 
349  //initIds->erase(vectorIndex);
350 
351 
352 
353  std::vector<G4int> identifiers;
354  for (vectorIndex = initIds->begin()+1 ; vectorIndex != initIds->end(); ++vectorIndex){
355 
356  identifiers.push_back(*vectorIndex);
357  }
358 
359  vectorIndex = (initIds->end())-1;
360 
361  G4int augerShellId = *(vectorIndex);
362 
363 
364  (*newIdMap)[augerShellId] = *newIds;
365  (*newEnergyMap)[augerShellId] = *transEnergies;
366  (*newProbabilityMap)[augerShellId] = *transProbabilities;
367 
368  augerTransitionVector.push_back(G4AugerTransition(vacId, identifiers, newIdMap, newEnergyMap, newProbabilityMap));
369 
370  // Now deleting all the variables I used, and creating new ones for the next shell
371 
372  delete newIdMap;
373  delete newEnergyMap;
374  delete newProbabilityMap;
375 
376  G4int n = initIds->size();
377  nInitShells.push_back(n);
378  numberOfVacancies[Z]++;
379  delete initIds;
380  delete newIds;
381  delete transEnergies;
382  delete transProbabilities;
383  initIds = new std::vector<G4int>;
384  newIds = new std::vector<G4int>;
385  transEnergies = new G4DataVector;
386  transProbabilities = new G4DataVector;
387  newIdMap = new std::map<G4int,std::vector<G4int>,std::less<G4int> >;
388  newEnergyMap = new std::map<G4int,G4DataVector,std::less<G4int> >;
389  newProbabilityMap = new std::map<G4int,G4DataVector,std::less<G4int> >;
390 
391 
392 
393  }
394  sLocal++;
395  if (sLocal == nColumns)
396  {
397  sLocal = 0;
398  }
399  }
400  // moved to the end in order to avoid leaks
401  /*
402  else if (a == -2)
403  {
404  // End of file; delete the empty vectors created
405  //when encountering the last -1 -1 row
406  delete initIds;
407  delete newIds;
408  delete transEnergies;
409  delete transProbabilities;
410  delete newIdMap ;
411  delete newEnergyMap;
412  delete newProbabilityMap;
413  }*/
414  else
415  {
416 
417  if (k%nColumns == 3){
418  // 3rd column is the transition probabilities
419  transProbabilities->push_back(a);
420 
421  k++;}
422  else if(k%nColumns == 2){
423  // 2nd column is new auger vacancy
424 
425  // 2nd column is new auger vacancy
426 
427  G4int l = (G4int)a;
428  newIds->push_back(l);
429 
430 
431  k++;
432  }
433  else if (k%nColumns == 1)
434  {
435  // 1st column is shell id
436 
437  if(initIds->size() == 0) {
438 
439  // if this is the first data of the shell, all the colums are equal
440  // to the shell Id; so we skip the next colums ang go to the next row
441 
442  initIds->push_back((G4int)a);
443  // first line of initIds is the original shell of the vacancy
444  file >> a;
445  file >> a;
446  file >> a;
447  k = k+3;
448  }
449  else {
450 
451  // std::vector<G4int>::iterator vectorIndex = (initIds->end())-1;
452  if((G4int)a != initIds->back()){
453 
454 
455  if((initIds->size()) == 1) {
456  initIds->push_back((G4int)a);
457  }
458  else {
459 
460 
461  G4int augerShellId = 0;
462  augerShellId = initIds->back();
463 
464  (*newIdMap)[augerShellId] = *newIds;
465  (*newEnergyMap)[augerShellId] = *transEnergies;
466  (*newProbabilityMap)[augerShellId] = *transProbabilities;
467  delete newIds;
468  delete transEnergies;
469  delete transProbabilities;
470  newIds = new std::vector<G4int>;
471  transEnergies = new G4DataVector;
472  transProbabilities = new G4DataVector;
473  initIds->push_back((G4int)a);
474  }
475  }
476  }
477 
478  k++;
479 
480  }
481  else if (k%nColumns == 0)
482 
483  {//fourth column is transition energies
484  G4double e = a * MeV;
485 
486  transEnergies->push_back(e);
487  k=1;
488 
489  }
490  }
491  }
492 
493 
494  while (a != -2); // end of file
495  file.close();
496  delete initIds;
497  delete newIds;
498  delete transEnergies;
499  delete transProbabilities;
500  delete newIdMap ;
501  delete newEnergyMap;
502  delete newProbabilityMap;
503  return augerTransitionVector;
504 
505 }
506 
508 {
509 
510  // trans_Table::iterator pos = augerTransitionTable.begin();
511 
512  const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
513 
515 
516  G4DataVector activeZ;
517  activeZ.clear();
518 
519  for (G4int mLocal=0; mLocal<nMaterials; mLocal++) {
520 
521  const G4Material* material= (*materialTable)[mLocal];
522  const G4ElementVector* elementVector = material->GetElementVector();
523  const size_t nElements = material->GetNumberOfElements();
524 
525  for (size_t iEl=0; iEl<nElements; iEl++) {
526  G4Element* element = (*elementVector)[iEl];
527  G4double Z = element->GetZ();
528  if (!(activeZ.contains(Z))) {
529  activeZ.push_back(Z);
530  }
531  }
532  }
533 
534 
535  for (G4int element = 6; element < 100; element++)
536  {
537  // if(nMaterials == 0 || activeZ.contains(element)) {
538  augerTransitionTable.insert(trans_Table::value_type(element,LoadData(element)));
539  // G4cout << "G4AugerData for Element no. " << element << " are loaded" << G4endl;
540  // G4cout << "G4AugerData for Element no. " << element << " are loaded" << G4endl;
541  //G4cout << "AugerTransitionTable complete"<< G4endl;
542  }
543 }
544 
546 {
547 
548  for (G4int i = 0; i < numberOfVacancies[Z]; i++)
549  {
550  G4cout << "---- TransitionData for the vacancy nb "
551  <<i
552  <<" of the atomic number elemnt "
553  << Z
554  <<"----- "
555  <<G4endl;
556 
557  for (size_t k = 0; k<=NumberOfTransitions(Z,i); k++)
558  {
559  G4int id = StartShellId(Z,i,k);
560 
561  for (size_t a = 0; a <= NumberOfAuger(Z,i,id); a++) {
562 
563  G4double e = StartShellEnergy(Z,i,id,a)/MeV;
564  G4double p = StartShellProb(Z,i,id,a);
565  G4int augerId = AugerShellId(Z, i, id, a);
566  G4cout << k <<") Shell id: " << id <<G4endl;
567  G4cout << " Auger Originatig Shell Id :"<< augerId <<G4endl;
568  G4cout << " - Transition energy = " << e << " MeV "<<G4endl;
569  G4cout << " - Transition probability = " << p <<G4endl;
570  }
571  }
572  G4cout << "-------------------------------------------------"
573  << G4endl;
574  }
575 }
577  {
578  std::vector<G4AugerTransition>* dataSet = &augerTransitionTable[Z];
579  std::vector<G4AugerTransition>::iterator vectorIndex = dataSet->begin() + vacancyShellIndex;
580 
581  G4AugerTransition* augerTransition = &(*vectorIndex);
582  return augerTransition;
583  }
584 
585 std::vector<G4AugerTransition>* G4AugerData::GetAugerTransitions(G4int Z)
586  {
587  std::vector<G4AugerTransition>* dataSet = &augerTransitionTable[Z];
588  return dataSet;
589  }
590 
591 
592 
593 
594 
595 
596 
597 
598 
599 
600 
601 
602 
603 
604 
605 
606 
607 
608 
609 
610