Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // 23 // 27 // 24 // 28 // Author: Elena Guardincerri (Elena.Guardince 25 // Author: Elena Guardincerri (Elena.Guardincerri@ge.infn.it) 29 // 26 // 30 // History: 27 // History: 31 // ----------- 28 // ----------- 32 // 16 Sept 2001 First committed to cvs 29 // 16 Sept 2001 First committed to cvs 33 // 30 // 34 // ------------------------------------------- 31 // ------------------------------------------------------------------- 35 32 36 #include <fstream> << 37 #include <sstream> << 38 << 39 #include "G4FluoData.hh" 33 #include "G4FluoData.hh" 40 #include "G4SystemOfUnits.hh" << 41 #include "G4DataVector.hh" 34 #include "G4DataVector.hh" 42 #include "G4FluoTransition.hh" 35 #include "G4FluoTransition.hh" 43 //....oooOO0OOooo........oooOO0OOooo........oo << 36 #include "g4std/fstream" 44 G4FluoData::G4FluoData(const G4String& dir) << 37 #include "g4std/strstream" >> 38 >> 39 G4FluoData::G4FluoData() 45 { 40 { 46 fluoDirectory = dir; << 41 numberOfVacancies=0; 47 } 42 } 48 43 49 //....oooOO0OOooo........oooOO0OOooo........oo << 50 << 51 G4FluoData::~G4FluoData() 44 G4FluoData::~G4FluoData() 52 { 45 { 53 for (auto& pos : idMap) << 46 G4std::map<G4int,G4DataVector*,G4std::less<G4int> >::iterator pos; >> 47 >> 48 for (pos = idMap.begin(); pos != idMap.end(); ++pos) 54 { 49 { 55 G4DataVector* dataSet = pos.second; << 50 G4DataVector* dataSet = (*pos).second; 56 delete dataSet; 51 delete dataSet; 57 } 52 } 58 << 53 for (pos = energyMap.begin(); pos != energyMap.end(); ++pos) 59 for (auto& pos : energyMap) << 60 { 54 { 61 G4DataVector* dataSet = pos.second; << 55 G4DataVector* dataSet = (*pos).second; 62 delete dataSet; 56 delete dataSet; 63 } 57 } 64 << 58 for (pos = probabilityMap.begin(); pos != probabilityMap.end(); ++pos) 65 for (auto& pos: probabilityMap) << 66 { 59 { 67 G4DataVector* dataSet = pos.second; << 60 G4DataVector* dataSet = (*pos).second; 68 delete dataSet; 61 delete dataSet; 69 } 62 } 70 } 63 } 71 64 72 //....oooOO0OOooo........oooOO0OOooo........oo << 65 size_t G4FluoData::NumberOfVacancies() const 73 << 74 std::size_t G4FluoData::NumberOfVacancies() co << 75 { 66 { 76 return numberOfVacancies; 67 return numberOfVacancies; 77 } 68 } 78 69 79 //....oooOO0OOooo........oooOO0OOooo........oo << 80 << 81 G4int G4FluoData::VacancyId(G4int vacancyIndex 70 G4int G4FluoData::VacancyId(G4int vacancyIndex) const 82 { 71 { 83 G4int n = -1; 72 G4int n = -1; 84 if (vacancyIndex<0 || vacancyIndex>=numberOf 73 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies) 85 { << 74 {G4Exception("G4FluoData::vacancyIndex outside boundaries");} 86 G4Exception("G4FluoData::vacancyId()","d << 87 "vacancyIndex outside boundaries"); << 88 } << 89 else 75 else 90 { 76 { 91 auto pos = idMap.find(vacancyIndex); << 77 G4std::map<G4int,G4DataVector*,G4std::less<G4int> >::const_iterator pos; >> 78 pos = idMap.find(vacancyIndex); 92 if (pos!= idMap.end()) 79 if (pos!= idMap.end()) 93 { G4DataVector dataSet = (*(*pos).second); 80 { G4DataVector dataSet = (*(*pos).second); 94 n = (G4int) dataSet[0]; 81 n = (G4int) dataSet[0]; 95 82 96 } 83 } 97 } 84 } 98 return n; 85 return n; 99 } 86 } 100 87 101 //....oooOO0OOooo........oooOO0OOooo........oo << 88 size_t G4FluoData::NumberOfTransitions(G4int vacancyIndex) const 102 << 103 std::size_t G4FluoData::NumberOfTransitions(G4 << 104 { 89 { 105 G4int n = 0; 90 G4int n = 0; 106 if (vacancyIndex<0 || vacancyIndex>=numberOf 91 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies) 107 { << 92 {G4Exception("G4FluoData::vacancyIndex outside boundaries");} 108 G4Exception("G4FluoData::NumberOfTransit << 109 "vacancyIndex outside boundaries, energy << 110 return 0; << 111 } << 112 else 93 else 113 { 94 { 114 n = nInitShells[vacancyIndex]-1; 95 n = nInitShells[vacancyIndex]-1; 115 //-1 is necessary because the elements o 96 //-1 is necessary because the elements of the vector nInitShells 116 //include also the vacancy shell: 97 //include also the vacancy shell: 117 // -1 subtracts this last one 98 // -1 subtracts this last one 118 } 99 } 119 return n; 100 return n; 120 } 101 } 121 << 122 //....oooOO0OOooo........oooOO0OOooo........oo << 123 << 124 G4int G4FluoData::StartShellId(G4int initIndex 102 G4int G4FluoData::StartShellId(G4int initIndex, G4int vacancyIndex) const 125 { 103 { 126 G4int n = -1; 104 G4int n = -1; 127 105 128 if (vacancyIndex<0 || vacancyIndex>=numberOfV << 106 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies) 129 G4Exception("G4FluoData::StartShellId()","d << 107 {G4Exception("G4FluoData::vacancyIndex outside boundaries");} 130 "vacancyIndex outside boundaries"); << 108 else 131 } else { << 109 { 132 auto pos = idMap.find(vacancyIndex); << 110 G4std::map<G4int,G4DataVector*,G4std::less<G4int> >::const_iterator pos; 133 if (pos != idMap.end()) { << 111 134 G4DataVector* dataSet = (*pos).second; << 112 pos = idMap.find(vacancyIndex); >> 113 >> 114 G4DataVector dataSet = *((*pos).second); 135 115 136 G4int nData = (G4int)dataSet->size(); << 116 G4int nData = dataSet.size(); 137 // The first Element of idMap's dataSets << 117 if (initIndex >= 0 && initIndex < nData) 138 // the vacancy, so we must start from the << 118 { 139 if (initIndex >= 0 && initIndex < nData) << 119 n = (G4int) dataSet[initIndex]; 140 n = (*dataSet)[initIndex+1]; << 120 141 } << 121 } 142 } 122 } 143 } << 144 return n; 123 return n; 145 } 124 } 146 << 147 //....oooOO0OOooo........oooOO0OOooo........oo << 148 125 149 G4double G4FluoData::StartShellEnergy(G4int in 126 G4double G4FluoData::StartShellEnergy(G4int initIndex, G4int vacancyIndex) const 150 { 127 { 151 G4double n = -1; 128 G4double n = -1; 152 129 153 if (vacancyIndex<0 || vacancyIndex>=numberOf 130 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies) 154 { << 131 {G4Exception("G4FluoData::vacancyIndex outside boundaries");} 155 G4Exception("G4FluoData::StartShellEnerg << 132 else 156 "vacancyIndex outside boundaries");} << 133 { 157 else << 134 G4std::map<G4int,G4DataVector*,G4std::less<G4int> >::const_iterator pos; 158 { << 159 auto pos = energyMap.find(vacancyIndex); << 160 135 161 G4DataVector dataSet = *((*pos).second); << 136 pos = energyMap.find(vacancyIndex); 162 137 163 G4int nData = (G4int)dataSet.size(); << 138 G4DataVector dataSet = *((*pos).second); 164 if (initIndex >= 0 && initIndex < nData) << 139 165 { << 140 G4int nData = dataSet.size(); 166 n = dataSet[initIndex]; << 141 if (initIndex >= 0 && initIndex < nData) 167 } << 142 { 168 } << 143 n = dataSet[initIndex]; >> 144 >> 145 } >> 146 } 169 return n; 147 return n; 170 } 148 } 171 149 172 //....oooOO0OOooo........oooOO0OOooo........oo << 173 << 174 G4double G4FluoData::StartShellProb(G4int init 150 G4double G4FluoData::StartShellProb(G4int initIndex, G4int vacancyIndex) const 175 { 151 { 176 G4double n = -1; 152 G4double n = -1; 177 153 178 if (vacancyIndex<0 || vacancyIndex>=numberOf 154 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies) 179 { << 155 {G4Exception("G4FluoData::vacancyIndex outside boundaries");} 180 G4Exception("G4FluoData::StartShellEnerg << 181 "vacancyIndex outside boundaries, energy << 182 return 0; << 183 } << 184 else 156 else 185 { 157 { 186 auto pos = probabilityMap.find(vacancyIn << 158 G4std::map<G4int,G4DataVector*,G4std::less<G4int> >::const_iterator pos; 187 159 188 G4DataVector dataSet = *((*pos).second); << 160 pos = probabilityMap.find(vacancyIndex); 189 161 190 G4int nData = (G4int)dataSet.size(); << 162 G4DataVector dataSet = *((*pos).second); 191 if (initIndex >= 0 && initIndex < nData) << 163 192 { << 164 G4int nData = dataSet.size(); 193 n = dataSet[initIndex]; << 165 if (initIndex >= 0 && initIndex < nData) 194 } << 166 { >> 167 n = dataSet[initIndex]; >> 168 >> 169 } 195 } 170 } 196 return n; 171 return n; 197 } 172 } 198 173 199 //....oooOO0OOooo........oooOO0OOooo........oo << 200 << 201 void G4FluoData::LoadData(G4int Z) 174 void G4FluoData::LoadData(G4int Z) 202 { 175 { 203 // Build the complete string identifying the 176 // Build the complete string identifying the file with the data set 204 std::ostringstream ost; << 177 >> 178 char nameChar[100] = {""}; >> 179 G4std::ostrstream ost(nameChar, 100, G4std::ios::out); 205 if(Z != 0){ 180 if(Z != 0){ 206 ost << "/fl-tr-pr-"<< Z << ".dat"; << 181 ost << "fl-tr-pr-"<< Z << ".dat"; 207 } 182 } 208 else{ 183 else{ 209 ost << "/fl-tr-pr-"<<".dat"; << 184 ost << "fl-tr-pr-"<<".dat"; 210 } 185 } 211 G4String name(ost.str()); << 186 G4String name(nameChar); 212 << 213 187 214 const char* path = G4FindDataDir("G4LEDATA") << 188 char* path = getenv("G4LEDATA"); 215 if (!path) 189 if (!path) 216 { 190 { 217 G4String excep("G4FluoData::LoadData()") << 191 G4String excep("G4EMDataSet - G4LEDATA environment variable not set"); 218 G4Exception(excep,"em0006",FatalExceptio << 192 G4Exception(excep); 219 return; << 220 } 193 } 221 194 222 G4String pathString(path); 195 G4String pathString(path); 223 << 196 G4String fluor("/fluor/"); 224 G4String dirFile = pathString + fluoDirector << 197 G4String dirFile = pathString + fluor + name; 225 << 198 G4std::ifstream file(dirFile); 226 //G4cout << "G4FluoData:: LoadData() name: " << 199 G4std::filebuf* lsdp = file.rdbuf(); 227 << 228 << 229 std::ifstream file(dirFile); << 230 std::filebuf* lsdp = file.rdbuf(); << 231 200 232 if (! (lsdp->is_open()) ) 201 if (! (lsdp->is_open()) ) 233 { 202 { 234 G4String excep = "G4FluoData::LoadData() << 203 G4String excep = "G4FluoData - data file: " + dirFile + " not found"; 235 G4String msg = "data file: " + dirFile + << 204 G4Exception(excep); 236 G4Exception(excep, "em0003",FatalExcepti << 237 return; << 238 } 205 } 239 206 240 G4double a = 0; 207 G4double a = 0; 241 G4int k = 1; 208 G4int k = 1; 242 G4int sLocal = 0; << 209 G4int s = 0; 243 210 244 G4int vacIndex = 0; << 211 G4int vacId = 0; 245 G4DataVector* initIds = new G4DataVector; 212 G4DataVector* initIds = new G4DataVector; 246 G4DataVector* transEnergies = new G4DataVect 213 G4DataVector* transEnergies = new G4DataVector; 247 G4DataVector* transProbabilities = new G4Dat 214 G4DataVector* transProbabilities = new G4DataVector; 248 215 249 do { 216 do { 250 file >> a; 217 file >> a; 251 G4int nColumns = 3; 218 G4int nColumns = 3; 252 if (a == -1) 219 if (a == -1) 253 { 220 { 254 if (sLocal == 0) << 221 if (s == 0) 255 { 222 { 256 // End of a shell data set 223 // End of a shell data set 257 idMap[vacIndex] = initIds; << 224 idMap[vacId] = initIds; 258 energyMap[vacIndex] = transEnergie << 225 energyMap[vacId] = transEnergies; 259 probabilityMap[vacIndex] = transPr << 226 probabilityMap[vacId] = transProbabilities; 260 G4int n = (G4int)initIds->size(); << 227 // G4double size=transProbabilities->size(); >> 228 G4int n = initIds->size(); 261 229 262 nInitShells.push_back(n); 230 nInitShells.push_back(n); 263 numberOfVacancies++; 231 numberOfVacancies++; 264 // Start of new shell data set 232 // Start of new shell data set 265 initIds = new G4DataVector; 233 initIds = new G4DataVector; 266 transEnergies = new G4DataVector; 234 transEnergies = new G4DataVector; 267 transProbabilities = new G4DataVector; 235 transProbabilities = new G4DataVector; 268 vacIndex++; << 236 vacId++; 269 } 237 } 270 sLocal++; << 238 s++; 271 if (sLocal == nColumns) << 239 if (s == nColumns) 272 { 240 { 273 sLocal = 0; << 241 s = 0; 274 } 242 } 275 } 243 } 276 // moved to the end in order to avoid poss << 244 else if (a == -2) 277 /* else if (a == -2) << 278 { 245 { 279 // End of file; delete the empty vectors cre 246 // End of file; delete the empty vectors created 280 //when encountering the last -1 -1 row 247 //when encountering the last -1 -1 row 281 delete initIds; 248 delete initIds; 282 delete transEnergies; 249 delete transEnergies; 283 delete transProbabilities; 250 delete transProbabilities; 284 }*/ << 251 } 285 else 252 else 286 { << 253 { >> 254 287 if(k%nColumns == 2) 255 if(k%nColumns == 2) 288 { 256 { 289 // 2nd column is transition probabiliti 257 // 2nd column is transition probabilities 290 258 291 if (a != -1) transProbabilities->push_bac << 259 transProbabilities->push_back(a); 292 260 293 k++; 261 k++; 294 } 262 } 295 else if (k%nColumns == 1) 263 else if (k%nColumns == 1) 296 { 264 { 297 // 1st column is shell id << 265 // 1st column is shell id 298 // if this is the first data of the shel << 266 299 // to the shell Id; so we skip the next << 267 initIds->push_back(a); 300 if(initIds->size() == 0) { << 301 if (a != -1) initIds->push_back((G4int << 302 file >> a; << 303 file >> a; << 304 k=k+2; << 305 } << 306 else{ << 307 if (a != -1) initIds->push_back(a); << 308 } << 309 k++; 268 k++; >> 269 310 } 270 } 311 else if (k%nColumns == 0) 271 else if (k%nColumns == 0) 312 272 313 {//third column is transition energies 273 {//third column is transition energies 314 274 315 if (a != -1) << 275 G4double e = a * MeV; 316 {G4double e = a * MeV; << 276 transEnergies->push_back(e); 317 transEnergies->push_back(e);} << 318 277 319 k=1; 278 k=1; 320 } 279 } 321 } 280 } 322 } 281 } 323 while (a != -2); // end of file 282 while (a != -2); // end of file 324 file.close(); 283 file.close(); 325 delete initIds; << 326 delete transEnergies; << 327 delete transProbabilities; << 328 } 284 } 329 285 330 //....oooOO0OOooo........oooOO0OOooo........oo << 331 << 332 void G4FluoData::PrintData() 286 void G4FluoData::PrintData() 333 { 287 { 334 for (G4int i = 0; i <numberOfVacancies; ++i) << 288 >> 289 for (G4int i = 0; i <numberOfVacancies; i++) 335 { 290 { 336 G4cout << "---- TransitionData for the v 291 G4cout << "---- TransitionData for the vacancy nb " 337 << i << 292 <<i 338 << " ----- " << 293 <<" ----- " 339 << G4endl; << 294 <<G4endl; 340 295 341 for (G4int k = 0; k<(G4int)NumberOfTrans << 296 for (size_t k = 0; k<=NumberOfTransitions(i); k++) 342 { 297 { 343 G4int id = StartShellId(k,i); 298 G4int id = StartShellId(k,i); 344 // let's start from 1 because the first (ind << 345 // is the id of the initial vacancy << 346 G4double e = StartShellEnergy(k,i) /MeV; 299 G4double e = StartShellEnergy(k,i) /MeV; 347 G4double p = StartShellProb(k,i); 300 G4double p = StartShellProb(k,i); 348 G4cout << k <<") Shell id: " << id <<G4end 301 G4cout << k <<") Shell id: " << id <<G4endl; 349 G4cout << " - Transition energy = " << e < 302 G4cout << " - Transition energy = " << e << " MeV "<<G4endl; 350 G4cout << " - Transition probability = " 303 G4cout << " - Transition probability = " << p <<G4endl; 351 304 352 } 305 } 353 G4cout << "----------------------------- 306 G4cout << "-------------------------------------------------" 354 << G4endl; 307 << G4endl; 355 } 308 } 356 } 309 } >> 310 >> 311 >> 312 >> 313 >> 314 >> 315 >> 316 >> 317 >> 318 >> 319 >> 320 >> 321 >> 322 >> 323 >> 324 >> 325 >> 326 >> 327 >> 328 >> 329 >> 330 >> 331 >> 332 >> 333 >> 334 >> 335 >> 336 >> 337 >> 338 >> 339 >> 340 >> 341 >> 342 >> 343 >> 344 >> 345 >> 346 >> 347 >> 348 357 349