File indexing completed on 2025-01-31 09:22:08
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 #include <fstream>
0037 #include <sstream>
0038
0039 #include "G4RDFluoData.hh"
0040 #include "G4SystemOfUnits.hh"
0041 #include "G4DataVector.hh"
0042 #include "G4RDFluoTransition.hh"
0043
0044 G4RDFluoData::G4RDFluoData()
0045 {
0046 numberOfVacancies=0;
0047 }
0048
0049 G4RDFluoData::~G4RDFluoData()
0050 {
0051 std::map<G4int,G4DataVector*,std::less<G4int> >::iterator pos;
0052
0053 for (pos = idMap.begin(); pos != idMap.end(); ++pos)
0054 {
0055 G4DataVector* dataSet = (*pos).second;
0056 delete dataSet;
0057 }
0058 for (pos = energyMap.begin(); pos != energyMap.end(); ++pos)
0059 {
0060 G4DataVector* dataSet = (*pos).second;
0061 delete dataSet;
0062 }
0063 for (pos = probabilityMap.begin(); pos != probabilityMap.end(); ++pos)
0064 {
0065 G4DataVector* dataSet = (*pos).second;
0066 delete dataSet;
0067 }
0068 }
0069
0070 size_t G4RDFluoData::NumberOfVacancies() const
0071 {
0072 return numberOfVacancies;
0073 }
0074
0075 G4int G4RDFluoData::VacancyId(G4int vacancyIndex) const
0076 {
0077 G4int n = -1;
0078 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
0079 {G4Exception("G4RDFluoData::VacancyId()", "OutOfRange",
0080 FatalException, "VacancyIndex outside boundaries!");}
0081 else
0082 {
0083 std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos;
0084 pos = idMap.find(vacancyIndex);
0085 if (pos!= idMap.end())
0086 { G4DataVector dataSet = (*(*pos).second);
0087 n = (G4int) dataSet[0];
0088
0089 }
0090 }
0091 return n;
0092 }
0093
0094 size_t G4RDFluoData::NumberOfTransitions(G4int vacancyIndex) const
0095 {
0096 G4int n = 0;
0097 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
0098 {G4Exception("G4RDFluoData::NumberOfTransitions()", "OutOfRange",
0099 FatalException, "VacancyIndex outside boundaries!");}
0100 else
0101 {
0102 n = nInitShells[vacancyIndex]-1;
0103
0104
0105
0106 }
0107 return n;
0108 }
0109 G4int G4RDFluoData::StartShellId(G4int initIndex, G4int vacancyIndex) const
0110 {
0111 G4int n = -1;
0112
0113 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
0114 {G4Exception("G4RDFluoData::StartShellId()", "OutOfRange",
0115 FatalException, "VacancyIndex outside boundaries!");}
0116 else
0117 {
0118 std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos;
0119
0120 pos = idMap.find(vacancyIndex);
0121
0122 G4DataVector dataSet = *((*pos).second);
0123
0124 G4int nData = dataSet.size();
0125
0126
0127 if (initIndex >= 0 && initIndex < nData)
0128 {
0129 n = (G4int) dataSet[initIndex+1];
0130
0131 }
0132 }
0133 return n;
0134 }
0135
0136 G4double G4RDFluoData::StartShellEnergy(G4int initIndex, G4int vacancyIndex) const
0137 {
0138 G4double n = -1;
0139
0140 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
0141 {G4Exception("G4RDFluoData::StartShellEnergy()", "OutOfRange",
0142 FatalException, "VacancyIndex outside boundaries!");}
0143 else
0144 {
0145 std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos;
0146
0147 pos = energyMap.find(vacancyIndex);
0148
0149 G4DataVector dataSet = *((*pos).second);
0150
0151 G4int nData = dataSet.size();
0152 if (initIndex >= 0 && initIndex < nData)
0153 {
0154 n = dataSet[initIndex];
0155
0156 }
0157 }
0158 return n;
0159 }
0160
0161 G4double G4RDFluoData::StartShellProb(G4int initIndex, G4int vacancyIndex) const
0162 {
0163 G4double n = -1;
0164
0165 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
0166 {G4Exception("G4RDFluoData::StartShellProb()", "OutOfRange",
0167 FatalException, "VacancyIndex outside boundaries!");}
0168 else
0169 {
0170 std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos;
0171
0172 pos = probabilityMap.find(vacancyIndex);
0173
0174 G4DataVector dataSet = *((*pos).second);
0175
0176 G4int nData = dataSet.size();
0177 if (initIndex >= 0 && initIndex < nData)
0178 {
0179 n = dataSet[initIndex];
0180
0181 }
0182 }
0183 return n;
0184 }
0185
0186 void G4RDFluoData::LoadData(G4int Z)
0187 {
0188
0189
0190 std::ostringstream ost;
0191 if(Z != 0){
0192 ost << "fl-tr-pr-"<< Z << ".dat";
0193 }
0194 else{
0195 ost << "fl-tr-pr-"<<".dat";
0196 }
0197 G4String name(ost.str());
0198
0199 const char* path = G4FindDataDir("G4LEDATA");
0200 if (!path)
0201 {
0202 G4String excep("G4LEDATA environment variable not set!");
0203 G4Exception("G4RDEMDataSet::LoadData()", "InvalidSetup",
0204 FatalException, excep);
0205 }
0206
0207 G4String pathString(path);
0208 G4String fluor("/fluor/");
0209 G4String dirFile = pathString + fluor + name;
0210 std::ifstream file(dirFile);
0211 std::filebuf* lsdp = file.rdbuf();
0212
0213 if (! (lsdp->is_open()) )
0214 {
0215 G4String excep = "Data file: " + dirFile + " not found";
0216 G4Exception("G4RDEMDataSet::LoadData()", "DataNotFound",
0217 FatalException, excep);
0218 }
0219
0220 G4double a = 0;
0221 G4int k = 1;
0222 G4int s = 0;
0223
0224 G4int vacIndex = 0;
0225 G4DataVector* initIds = new G4DataVector;
0226 G4DataVector* transEnergies = new G4DataVector;
0227 G4DataVector* transProbabilities = new G4DataVector;
0228
0229 do {
0230 file >> a;
0231 G4int nColumns = 3;
0232 if (a == -1)
0233 {
0234 if (s == 0)
0235 {
0236
0237 idMap[vacIndex] = initIds;
0238 energyMap[vacIndex] = transEnergies;
0239 probabilityMap[vacIndex] = transProbabilities;
0240
0241 G4int n = initIds->size();
0242
0243 nInitShells.push_back(n);
0244 numberOfVacancies++;
0245
0246 initIds = new G4DataVector;
0247 transEnergies = new G4DataVector;
0248 transProbabilities = new G4DataVector;
0249 vacIndex++;
0250 }
0251 s++;
0252 if (s == nColumns)
0253 {
0254 s = 0;
0255 }
0256 }
0257 else if (a == -2)
0258 {
0259
0260
0261 delete initIds;
0262 delete transEnergies;
0263 delete transProbabilities;
0264 }
0265 else
0266 {
0267
0268 if(k%nColumns == 2)
0269 {
0270
0271
0272 if (a != -1) transProbabilities->push_back(a);
0273
0274 k++;
0275 }
0276 else if (k%nColumns == 1)
0277 {
0278
0279
0280
0281 if(initIds->size() == 0) {
0282 if (a != -1) initIds->push_back((G4int)a);
0283 file >> a;
0284 file >> a;
0285 k=k+2;
0286 }
0287 else{
0288 if (a != -1) initIds->push_back(a);
0289 }
0290 k++;
0291 }
0292 else if (k%nColumns == 0)
0293
0294 {
0295
0296 if (a != -1)
0297 {G4double e = a * MeV;
0298 transEnergies->push_back(e);}
0299
0300 k=1;
0301 }
0302 }
0303 }
0304 while (a != -2);
0305 file.close();
0306 }
0307
0308 void G4RDFluoData::PrintData()
0309 {
0310
0311 for (G4int i = 0; i <numberOfVacancies; i++)
0312 {
0313 G4cout << "---- TransitionData for the vacancy nb "
0314 <<i
0315 <<" ----- "
0316 <<G4endl;
0317
0318 for (size_t k = 0; k<NumberOfTransitions(i); k++)
0319 {
0320 G4int id = StartShellId(k,i);
0321
0322
0323 G4double e = StartShellEnergy(k,i) /MeV;
0324 G4double p = StartShellProb(k,i);
0325 G4cout << k <<") Shell id: " << id <<G4endl;
0326 G4cout << " - Transition energy = " << e << " MeV "<<G4endl;
0327 G4cout << " - Transition probability = " << p <<G4endl;
0328
0329 }
0330 G4cout << "-------------------------------------------------"
0331 << G4endl;
0332 }
0333 }