File indexing completed on 2025-01-31 09:22:07
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
0037
0038
0039
0040
0041
0042
0043
0044 #include <fstream>
0045 #include <sstream>
0046
0047 #include "G4RDeIonisationParameters.hh"
0048 #include "G4RDVEMDataSet.hh"
0049 #include "G4RDShellEMDataSet.hh"
0050 #include "G4RDEMDataSet.hh"
0051 #include "G4RDCompositeEMDataSet.hh"
0052 #include "G4RDLinInterpolation.hh"
0053 #include "G4RDLogLogInterpolation.hh"
0054 #include "G4RDLinLogLogInterpolation.hh"
0055 #include "G4RDSemiLogInterpolation.hh"
0056 #include "G4SystemOfUnits.hh"
0057 #include "G4Material.hh"
0058 #include "G4DataVector.hh"
0059
0060 G4RDeIonisationParameters:: G4RDeIonisationParameters(G4int minZ, G4int maxZ)
0061 : zMin(minZ), zMax(maxZ),
0062 length(24)
0063 {
0064 LoadData();
0065 }
0066
0067
0068 G4RDeIonisationParameters::~G4RDeIonisationParameters()
0069 {
0070
0071 std::map<G4int,G4RDVEMDataSet*,std::less<G4int> >::iterator pos;
0072
0073 for (pos = param.begin(); pos != param.end(); ++pos)
0074 {
0075 G4RDVEMDataSet* dataSet = (*pos).second;
0076 delete dataSet;
0077 }
0078
0079 for (pos = excit.begin(); pos != excit.end(); ++pos)
0080 {
0081 G4RDVEMDataSet* dataSet = (*pos).second;
0082 delete dataSet;
0083 }
0084
0085 activeZ.clear();
0086 }
0087
0088
0089 G4double G4RDeIonisationParameters::Parameter(G4int Z, G4int shellIndex,
0090 G4int parameterIndex,
0091 G4double e) const
0092 {
0093 G4double value = 0.;
0094 G4int id = Z*100 + parameterIndex;
0095 std::map<G4int,G4RDVEMDataSet*,std::less<G4int> >::const_iterator pos;
0096
0097 pos = param.find(id);
0098 if (pos!= param.end()) {
0099 G4RDVEMDataSet* dataSet = (*pos).second;
0100 G4int nShells = dataSet->NumberOfComponents();
0101
0102 if(shellIndex < nShells) {
0103 const G4RDVEMDataSet* component = dataSet->GetComponent(shellIndex);
0104 const G4DataVector ener = component->GetEnergies(0);
0105 G4double ee = std::max(ener.front(),std::min(ener.back(),e));
0106 value = component->FindValue(ee);
0107 } else {
0108 G4cout << "WARNING: G4IonisationParameters::FindParameter "
0109 << "has no parameters for shell= " << shellIndex
0110 << "; Z= " << Z
0111 << G4endl;
0112 }
0113 } else {
0114 G4cout << "WARNING: G4IonisationParameters::Parameter "
0115 << "did not find ID = "
0116 << shellIndex << G4endl;
0117 }
0118
0119 return value;
0120 }
0121
0122 G4double G4RDeIonisationParameters::Excitation(G4int Z, G4double e) const
0123 {
0124 G4double value = 0.;
0125 std::map<G4int,G4RDVEMDataSet*,std::less<G4int> >::const_iterator pos;
0126
0127 pos = excit.find(Z);
0128 if (pos!= excit.end()) {
0129 G4RDVEMDataSet* dataSet = (*pos).second;
0130
0131 const G4DataVector ener = dataSet->GetEnergies(0);
0132 G4double ee = std::max(ener.front(),std::min(ener.back(),e));
0133 value = dataSet->FindValue(ee);
0134 } else {
0135 G4cout << "WARNING: G4IonisationParameters::Excitation "
0136 << "did not find ID = "
0137 << Z << G4endl;
0138 }
0139
0140 return value;
0141 }
0142
0143
0144 void G4RDeIonisationParameters::LoadData()
0145 {
0146
0147
0148
0149
0150
0151
0152 const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
0153 if (materialTable == 0)
0154 G4Exception("G4RDeIonisationParameters::LoadData()", "InvalidSetup",
0155 FatalException, "No MaterialTable found!");
0156
0157 G4int nMaterials = G4Material::GetNumberOfMaterials();
0158
0159 for (G4int m=0; m<nMaterials; m++) {
0160
0161 const G4Material* material= (*materialTable)[m];
0162 const G4ElementVector* elementVector = material->GetElementVector();
0163 const size_t nElements = material->GetNumberOfElements();
0164
0165 for (size_t iEl=0; iEl<nElements; iEl++) {
0166 G4Element* element = (*elementVector)[iEl];
0167 G4double Z = element->GetZ();
0168 if (!(activeZ.contains(Z))) {
0169 activeZ.push_back(Z);
0170 }
0171 }
0172 }
0173
0174 const char* path = G4FindDataDir("G4LEDATA");
0175 if (!path)
0176 {
0177 G4String excep("G4LEDATA environment variable not set!");
0178 G4Exception("G4RDeIonisationParameters::LoadData()", "InvalidSetup",
0179 FatalException, excep);
0180 }
0181
0182 G4String pathString(path);
0183 G4String path2("/ioni/ion-sp-");
0184 pathString += path2;
0185
0186 G4double energy, sum;
0187
0188 size_t nZ = activeZ.size();
0189
0190 for (size_t i=0; i<nZ; i++) {
0191
0192 G4int Z = (G4int)activeZ[i];
0193 std::ostringstream ost;
0194 ost << pathString << Z << ".dat";
0195 G4String name(ost.str());
0196
0197 std::ifstream file(name);
0198 std::filebuf* lsdp = file.rdbuf();
0199
0200 if (! (lsdp->is_open()) ) {
0201 G4String excep = G4String("Data file: ")
0202 + name + G4String(" not found. The version 1.# of G4LEDATA should be used");
0203 G4Exception("G4RDeIonisationParameters::LoadData()", "DataNotFound",
0204 FatalException, excep);
0205 }
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218 std::vector<G4RDVEMDataSet*> p;
0219 for (size_t k=0; k<length; k++)
0220 {
0221 G4RDVDataSetAlgorithm* inter = new G4RDLinLogLogInterpolation();
0222 G4RDVEMDataSet* composite = new G4RDCompositeEMDataSet(inter,1.,1.);
0223 p.push_back(composite);
0224 }
0225
0226 G4int shell = 0;
0227 std::vector<G4DataVector*> a;
0228 for (size_t j=0; j<length; j++)
0229 {
0230 G4DataVector* aa = new G4DataVector();
0231 a.push_back(aa);
0232 }
0233 G4DataVector e;
0234 e.clear();
0235 do {
0236 file >> energy >> sum;
0237 if (energy == -2) break;
0238
0239 if (energy > -1) {
0240 e.push_back(energy);
0241 a[0]->push_back(sum);
0242 for (size_t j=0; j<length-1; j++) {
0243 G4double qRead;
0244 file >> qRead;
0245 a[j + 1]->push_back(qRead);
0246 }
0247
0248 } else {
0249
0250
0251 for (size_t k=0; k<length; k++) {
0252
0253 G4RDVDataSetAlgorithm* interp;
0254 if(0 == k) interp = new G4RDLinLogLogInterpolation();
0255 else interp = new G4RDLogLogInterpolation();
0256
0257 G4DataVector* eVector = new G4DataVector;
0258 size_t eSize = e.size();
0259 for (size_t s=0; s<eSize; s++) {
0260 eVector->push_back(e[s]);
0261 }
0262 G4RDVEMDataSet* set = new G4RDEMDataSet(shell,eVector,a[k],interp,1.,1.);
0263
0264 p[k]->AddComponent(set);
0265 }
0266
0267
0268 for (size_t j2=0; j2<length; j2++) {
0269 a[j2] = new G4DataVector();
0270 }
0271 shell++;
0272 e.clear();
0273 }
0274 } while (energy > -2);
0275
0276 file.close();
0277
0278 for (size_t kk=0; kk<length; kk++)
0279 {
0280 G4int id = Z*100 + kk;
0281 param[id] = p[kk];
0282 }
0283 }
0284
0285 G4String pathString_a(path);
0286 G4String name_a = pathString_a + G4String("/ioni/ion-ex-av.dat");
0287 std::ifstream file_a(name_a);
0288 std::filebuf* lsdp_a = file_a.rdbuf();
0289 G4String pathString_b(path);
0290 G4String name_b = pathString_b + G4String("/ioni/ion-ex-sig.dat");
0291 std::ifstream file_b(name_b);
0292 std::filebuf* lsdp_b = file_b.rdbuf();
0293
0294 if (! (lsdp_a->is_open()) ) {
0295 G4String excep = G4String("Cannot open file ")
0296 + name_a;
0297 G4Exception("G4RDeIonisationParameters::LoadData()", "CannotOpenFile",
0298 FatalException, excep);
0299 }
0300 if (! (lsdp_b->is_open()) ) {
0301 G4String excep = G4String("Cannot open file ")
0302 + name_b;
0303 G4Exception("G4RDeIonisationParameters::LoadData()", "CannotOpenFile",
0304 FatalException, excep);
0305 }
0306
0307
0308
0309
0310
0311
0312
0313 G4double ener, ener1, sig, sig1;
0314 G4int z = 0;
0315
0316 G4DataVector e;
0317 e.clear();
0318 G4DataVector d;
0319 d.clear();
0320
0321 do {
0322 file_a >> ener >> sig;
0323 file_b >> ener1 >> sig1;
0324
0325 if(ener != ener1) {
0326 G4cout << "G4RDeIonisationParameters: problem in excitation data "
0327 << "ener= " << ener
0328 << " ener1= " << ener1
0329 << G4endl;
0330 }
0331
0332
0333 if (ener == -2) {
0334 break;
0335
0336
0337 } else if (ener == -1) {
0338
0339 z++;
0340 G4double Z = (G4double)z;
0341
0342
0343 if (activeZ.contains(Z)) {
0344
0345 G4RDVDataSetAlgorithm* inter = new G4RDLinInterpolation();
0346 G4DataVector* eVector = new G4DataVector;
0347 G4DataVector* dVector = new G4DataVector;
0348 size_t eSize = e.size();
0349 for (size_t s=0; s<eSize; s++) {
0350 eVector->push_back(e[s]);
0351 dVector->push_back(d[s]);
0352 }
0353 G4RDVEMDataSet* set = new G4RDEMDataSet(z,eVector,dVector,inter,1.,1.);
0354 excit[z] = set;
0355 }
0356 e.clear();
0357 d.clear();
0358
0359 } else {
0360
0361 e.push_back(ener*MeV);
0362 d.push_back(sig1*sig*barn*MeV);
0363 }
0364 } while (ener != -2);
0365
0366 file_a.close();
0367
0368 }
0369
0370
0371 void G4RDeIonisationParameters::PrintData() const
0372 {
0373 G4cout << G4endl;
0374 G4cout << "===== G4RDeIonisationParameters =====" << G4endl;
0375 G4cout << G4endl;
0376
0377 size_t nZ = activeZ.size();
0378 std::map<G4int,G4RDVEMDataSet*,std::less<G4int> >::const_iterator pos;
0379
0380 for (size_t i=0; i<nZ; i++) {
0381 G4int Z = (G4int)activeZ[i];
0382
0383 for (size_t j=0; j<length; j++) {
0384
0385 G4int index = Z*100 + j;
0386
0387 pos = param.find(index);
0388 if (pos!= param.end()) {
0389 G4RDVEMDataSet* dataSet = (*pos).second;
0390 size_t nShells = dataSet->NumberOfComponents();
0391
0392 for (size_t k=0; k<nShells; k++) {
0393
0394 G4cout << "===== Z= " << Z << " shell= " << k
0395 << " parameter[" << j << "] ====="
0396 << G4endl;
0397 const G4RDVEMDataSet* comp = dataSet->GetComponent(k);
0398 comp->PrintData();
0399 }
0400 }
0401 }
0402 }
0403 G4cout << "====================================" << G4endl;
0404 }
0405
0406