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