source: trunk/source/processes/electromagnetic/lowenergy/src/G4AugerData.cc@ 966

Last change on this file since 966 was 961, checked in by garnier, 17 years ago

update processes

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