| 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 | // Author: Elena Guardincerri (Elena.Guardincerri@ge.infn.it)
|
|---|
| 29 | //
|
|---|
| 30 | // History:
|
|---|
| 31 | // -----------
|
|---|
| 32 | // 16 Sept 2001 First committed to cvs
|
|---|
| 33 | //
|
|---|
| 34 | // -------------------------------------------------------------------
|
|---|
| 35 |
|
|---|
| 36 | #include "G4FluoData.hh"
|
|---|
| 37 | #include "G4DataVector.hh"
|
|---|
| 38 | #include "G4FluoTransition.hh"
|
|---|
| 39 | #include <fstream>
|
|---|
| 40 | #include <sstream>
|
|---|
| 41 |
|
|---|
| 42 | G4FluoData::G4FluoData()
|
|---|
| 43 | {
|
|---|
| 44 | numberOfVacancies=0;
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| 47 | G4FluoData::~G4FluoData()
|
|---|
| 48 | {
|
|---|
| 49 | std::map<G4int,G4DataVector*,std::less<G4int> >::iterator pos;
|
|---|
| 50 |
|
|---|
| 51 | for (pos = idMap.begin(); pos != idMap.end(); ++pos)
|
|---|
| 52 | {
|
|---|
| 53 | G4DataVector* dataSet = (*pos).second;
|
|---|
| 54 | delete dataSet;
|
|---|
| 55 | }
|
|---|
| 56 | for (pos = energyMap.begin(); pos != energyMap.end(); ++pos)
|
|---|
| 57 | {
|
|---|
| 58 | G4DataVector* dataSet = (*pos).second;
|
|---|
| 59 | delete dataSet;
|
|---|
| 60 | }
|
|---|
| 61 | for (pos = probabilityMap.begin(); pos != probabilityMap.end(); ++pos)
|
|---|
| 62 | {
|
|---|
| 63 | G4DataVector* dataSet = (*pos).second;
|
|---|
| 64 | delete dataSet;
|
|---|
| 65 | }
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | size_t G4FluoData::NumberOfVacancies() const
|
|---|
| 69 | {
|
|---|
| 70 | return numberOfVacancies;
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | G4int G4FluoData::VacancyId(G4int vacancyIndex) const
|
|---|
| 74 | {
|
|---|
| 75 | G4int n = -1;
|
|---|
| 76 | if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
|
|---|
| 77 | {G4Exception("G4FluoData::vacancyIndex outside boundaries");}
|
|---|
| 78 | else
|
|---|
| 79 | {
|
|---|
| 80 | std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos;
|
|---|
| 81 | pos = idMap.find(vacancyIndex);
|
|---|
| 82 | if (pos!= idMap.end())
|
|---|
| 83 | { G4DataVector dataSet = (*(*pos).second);
|
|---|
| 84 | n = (G4int) dataSet[0];
|
|---|
| 85 |
|
|---|
| 86 | }
|
|---|
| 87 | }
|
|---|
| 88 | return n;
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 | size_t G4FluoData::NumberOfTransitions(G4int vacancyIndex) const
|
|---|
| 92 | {
|
|---|
| 93 | G4int n = 0;
|
|---|
| 94 | if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
|
|---|
| 95 | {G4Exception("G4FluoData::vacancyIndex outside boundaries");}
|
|---|
| 96 | else
|
|---|
| 97 | {
|
|---|
| 98 | n = nInitShells[vacancyIndex]-1;
|
|---|
| 99 | //-1 is necessary because the elements of the vector nInitShells
|
|---|
| 100 | //include also the vacancy shell:
|
|---|
| 101 | // -1 subtracts this last one
|
|---|
| 102 | }
|
|---|
| 103 | return n;
|
|---|
| 104 | }
|
|---|
| 105 | G4int G4FluoData::StartShellId(G4int initIndex, G4int vacancyIndex) const
|
|---|
| 106 | {
|
|---|
| 107 | G4int n = -1;
|
|---|
| 108 |
|
|---|
| 109 | if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
|
|---|
| 110 | {G4Exception("G4FluoData::vacancyIndex outside boundaries");}
|
|---|
| 111 | else
|
|---|
| 112 | {
|
|---|
| 113 | std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos;
|
|---|
| 114 |
|
|---|
| 115 | pos = idMap.find(vacancyIndex);
|
|---|
| 116 |
|
|---|
| 117 | G4DataVector dataSet = *((*pos).second);
|
|---|
| 118 |
|
|---|
| 119 | G4int nData = dataSet.size();
|
|---|
| 120 | //The first Element of idMap's dataSets is the original shell of the vacancy,
|
|---|
| 121 | //so we must start from the first element of dataSet
|
|---|
| 122 | if (initIndex >= 0 && initIndex < nData)
|
|---|
| 123 | {
|
|---|
| 124 | n = (G4int) dataSet[initIndex+1];
|
|---|
| 125 |
|
|---|
| 126 | }
|
|---|
| 127 | }
|
|---|
| 128 | return n;
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 | G4double G4FluoData::StartShellEnergy(G4int initIndex, G4int vacancyIndex) const
|
|---|
| 132 | {
|
|---|
| 133 | G4double n = -1;
|
|---|
| 134 |
|
|---|
| 135 | if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
|
|---|
| 136 | {G4Exception("G4FluoData::vacancyIndex outside boundaries");}
|
|---|
| 137 | else
|
|---|
| 138 | {
|
|---|
| 139 | std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos;
|
|---|
| 140 |
|
|---|
| 141 | pos = energyMap.find(vacancyIndex);
|
|---|
| 142 |
|
|---|
| 143 | G4DataVector dataSet = *((*pos).second);
|
|---|
| 144 |
|
|---|
| 145 | G4int nData = dataSet.size();
|
|---|
| 146 | if (initIndex >= 0 && initIndex < nData)
|
|---|
| 147 | {
|
|---|
| 148 | n = dataSet[initIndex];
|
|---|
| 149 |
|
|---|
| 150 | }
|
|---|
| 151 | }
|
|---|
| 152 | return n;
|
|---|
| 153 | }
|
|---|
| 154 |
|
|---|
| 155 | G4double G4FluoData::StartShellProb(G4int initIndex, G4int vacancyIndex) const
|
|---|
| 156 | {
|
|---|
| 157 | G4double n = -1;
|
|---|
| 158 |
|
|---|
| 159 | if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
|
|---|
| 160 | {G4Exception("G4FluoData::vacancyIndex outside boundaries");}
|
|---|
| 161 | else
|
|---|
| 162 | {
|
|---|
| 163 | std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos;
|
|---|
| 164 |
|
|---|
| 165 | pos = probabilityMap.find(vacancyIndex);
|
|---|
| 166 |
|
|---|
| 167 | G4DataVector dataSet = *((*pos).second);
|
|---|
| 168 |
|
|---|
| 169 | G4int nData = dataSet.size();
|
|---|
| 170 | if (initIndex >= 0 && initIndex < nData)
|
|---|
| 171 | {
|
|---|
| 172 | n = dataSet[initIndex];
|
|---|
| 173 |
|
|---|
| 174 | }
|
|---|
| 175 | }
|
|---|
| 176 | return n;
|
|---|
| 177 | }
|
|---|
| 178 |
|
|---|
| 179 | void G4FluoData::LoadData(G4int Z)
|
|---|
| 180 | {
|
|---|
| 181 | // Build the complete string identifying the file with the data set
|
|---|
| 182 |
|
|---|
| 183 | std::ostringstream ost;
|
|---|
| 184 | if(Z != 0){
|
|---|
| 185 | ost << "fl-tr-pr-"<< Z << ".dat";
|
|---|
| 186 | }
|
|---|
| 187 | else{
|
|---|
| 188 | ost << "fl-tr-pr-"<<".dat";
|
|---|
| 189 | }
|
|---|
| 190 | G4String name(ost.str());
|
|---|
| 191 |
|
|---|
| 192 | char* path = getenv("G4LEDATA");
|
|---|
| 193 | if (!path)
|
|---|
| 194 | {
|
|---|
| 195 | G4String excep("G4EMDataSet - G4LEDATA environment variable not set");
|
|---|
| 196 | G4Exception(excep);
|
|---|
| 197 | }
|
|---|
| 198 |
|
|---|
| 199 | G4String pathString(path);
|
|---|
| 200 | G4String fluor("/fluor/");
|
|---|
| 201 | G4String dirFile = pathString + fluor + name;
|
|---|
| 202 | std::ifstream file(dirFile);
|
|---|
| 203 | std::filebuf* lsdp = file.rdbuf();
|
|---|
| 204 |
|
|---|
| 205 | if (! (lsdp->is_open()) )
|
|---|
| 206 | {
|
|---|
| 207 | G4String excep = "G4FluoData - data file: " + dirFile + " not found";
|
|---|
| 208 | G4Exception(excep);
|
|---|
| 209 | }
|
|---|
| 210 |
|
|---|
| 211 | G4double a = 0;
|
|---|
| 212 | G4int k = 1;
|
|---|
| 213 | G4int s = 0;
|
|---|
| 214 |
|
|---|
| 215 | G4int vacIndex = 0;
|
|---|
| 216 | G4DataVector* initIds = new G4DataVector;
|
|---|
| 217 | G4DataVector* transEnergies = new G4DataVector;
|
|---|
| 218 | G4DataVector* transProbabilities = new G4DataVector;
|
|---|
| 219 |
|
|---|
| 220 | do {
|
|---|
| 221 | file >> a;
|
|---|
| 222 | G4int nColumns = 3;
|
|---|
| 223 | if (a == -1)
|
|---|
| 224 | {
|
|---|
| 225 | if (s == 0)
|
|---|
| 226 | {
|
|---|
| 227 | // End of a shell data set
|
|---|
| 228 | idMap[vacIndex] = initIds;
|
|---|
| 229 | energyMap[vacIndex] = transEnergies;
|
|---|
| 230 | probabilityMap[vacIndex] = transProbabilities;
|
|---|
| 231 | // G4double size=transProbabilities->size();
|
|---|
| 232 | G4int n = initIds->size();
|
|---|
| 233 |
|
|---|
| 234 | nInitShells.push_back(n);
|
|---|
| 235 | numberOfVacancies++;
|
|---|
| 236 | // Start of new shell data set
|
|---|
| 237 | initIds = new G4DataVector;
|
|---|
| 238 | transEnergies = new G4DataVector;
|
|---|
| 239 | transProbabilities = new G4DataVector;
|
|---|
| 240 | vacIndex++;
|
|---|
| 241 | }
|
|---|
| 242 | s++;
|
|---|
| 243 | if (s == nColumns)
|
|---|
| 244 | {
|
|---|
| 245 | s = 0;
|
|---|
| 246 | }
|
|---|
| 247 | }
|
|---|
| 248 | else if (a == -2)
|
|---|
| 249 | {
|
|---|
| 250 | // End of file; delete the empty vectors created
|
|---|
| 251 | //when encountering the last -1 -1 row
|
|---|
| 252 | delete initIds;
|
|---|
| 253 | delete transEnergies;
|
|---|
| 254 | delete transProbabilities;
|
|---|
| 255 | }
|
|---|
| 256 | else
|
|---|
| 257 | {
|
|---|
| 258 |
|
|---|
| 259 | if(k%nColumns == 2)
|
|---|
| 260 | {
|
|---|
| 261 | // 2nd column is transition probabilities
|
|---|
| 262 |
|
|---|
| 263 | if (a != -1) transProbabilities->push_back(a);
|
|---|
| 264 |
|
|---|
| 265 | k++;
|
|---|
| 266 | }
|
|---|
| 267 | else if (k%nColumns == 1)
|
|---|
| 268 | {
|
|---|
| 269 | // 1st column is shell id
|
|---|
| 270 | // if this is the first data of the shell, all the colums are equal
|
|---|
| 271 | // to the shell Id; so we skip the next colums ang go to the next row
|
|---|
| 272 | if(initIds->size() == 0) {
|
|---|
| 273 | if (a != -1) initIds->push_back((G4int)a);
|
|---|
| 274 | file >> a;
|
|---|
| 275 | file >> a;
|
|---|
| 276 | k=k+2;
|
|---|
| 277 | }
|
|---|
| 278 | else{
|
|---|
| 279 | if (a != -1) initIds->push_back(a);
|
|---|
| 280 | }
|
|---|
| 281 | k++;
|
|---|
| 282 | }
|
|---|
| 283 | else if (k%nColumns == 0)
|
|---|
| 284 |
|
|---|
| 285 | {//third column is transition energies
|
|---|
| 286 |
|
|---|
| 287 | if (a != -1)
|
|---|
| 288 | {G4double e = a * MeV;
|
|---|
| 289 | transEnergies->push_back(e);}
|
|---|
| 290 |
|
|---|
| 291 | k=1;
|
|---|
| 292 | }
|
|---|
| 293 | }
|
|---|
| 294 | }
|
|---|
| 295 | while (a != -2); // end of file
|
|---|
| 296 | file.close();
|
|---|
| 297 | }
|
|---|
| 298 |
|
|---|
| 299 | void G4FluoData::PrintData()
|
|---|
| 300 | {
|
|---|
| 301 |
|
|---|
| 302 | for (G4int i = 0; i <numberOfVacancies; i++)
|
|---|
| 303 | {
|
|---|
| 304 | G4cout << "---- TransitionData for the vacancy nb "
|
|---|
| 305 | <<i
|
|---|
| 306 | <<" ----- "
|
|---|
| 307 | <<G4endl;
|
|---|
| 308 |
|
|---|
| 309 | for (size_t k = 0; k<NumberOfTransitions(i); k++)
|
|---|
| 310 | {
|
|---|
| 311 | G4int id = StartShellId(k,i);
|
|---|
| 312 | // let's start from 1 because the first (index = 0) element of the vector
|
|---|
| 313 | // is the id of the intial vacancy
|
|---|
| 314 | G4double e = StartShellEnergy(k,i) /MeV;
|
|---|
| 315 | G4double p = StartShellProb(k,i);
|
|---|
| 316 | G4cout << k <<") Shell id: " << id <<G4endl;
|
|---|
| 317 | G4cout << " - Transition energy = " << e << " MeV "<<G4endl;
|
|---|
| 318 | G4cout << " - Transition probability = " << p <<G4endl;
|
|---|
| 319 |
|
|---|
| 320 | }
|
|---|
| 321 | G4cout << "-------------------------------------------------"
|
|---|
| 322 | << G4endl;
|
|---|
| 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 |
|
|---|
| 349 |
|
|---|
| 350 |
|
|---|
| 351 |
|
|---|
| 352 |
|
|---|
| 353 |
|
|---|
| 354 |
|
|---|
| 355 |
|
|---|
| 356 |
|
|---|
| 357 |
|
|---|
| 358 |
|
|---|
| 359 |
|
|---|
| 360 |
|
|---|
| 361 |
|
|---|
| 362 |
|
|---|
| 363 |
|
|---|