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 #include "G4RDDopplerProfile.hh"
0037 #include "G4DataVector.hh"
0038 #include "G4SystemOfUnits.hh"
0039 #include "G4RDVEMDataSet.hh"
0040 #include "G4RDEMDataSet.hh"
0041 #include "G4RDCompositeEMDataSet.hh"
0042 #include "G4RDVDataSetAlgorithm.hh"
0043 #include "G4RDLogLogInterpolation.hh"
0044
0045 #include <fstream>
0046 #include <sstream>
0047 #include "Randomize.hh"
0048
0049
0050
0051
0052
0053
0054 G4RDDopplerProfile::G4RDDopplerProfile(G4int minZ, G4int maxZ)
0055 : zMin(minZ), zMax(maxZ)
0056 {
0057 nBiggs = 31;
0058
0059 LoadBiggsP("/doppler/p-biggs");
0060
0061 for (G4int Z=zMin; Z<zMax+1; Z++)
0062 {
0063 LoadProfile("/doppler/profile",Z);
0064 }
0065 }
0066
0067
0068 G4RDDopplerProfile::~G4RDDopplerProfile()
0069 {
0070 std::map<G4int,G4RDVEMDataSet*,std::less<G4int> >::iterator pos;
0071 for (pos = profileMap.begin(); pos != profileMap.end(); ++pos)
0072 {
0073 G4RDVEMDataSet* dataSet = (*pos).second;
0074 delete dataSet;
0075 dataSet = 0;
0076 }
0077 }
0078
0079
0080 size_t G4RDDopplerProfile::NumberOfProfiles(G4int Z) const
0081 {
0082 G4int n = 0;
0083 if (Z>= zMin && Z <= zMax) n = nShells[Z-1];
0084 return n;
0085 }
0086
0087
0088 const G4RDVEMDataSet* G4RDDopplerProfile::Profiles(G4int Z) const
0089 {
0090 std::map<G4int,G4RDVEMDataSet*,std::less<G4int> >::const_iterator pos;
0091 if (Z < zMin || Z > zMax)
0092 G4Exception("G4RDDopplerProfile::Profiles()", "OutOfRange",
0093 FatalException, "Z outside boundaries!");
0094 pos = profileMap.find(Z);
0095 G4RDVEMDataSet* dataSet = (*pos).second;
0096 return dataSet;
0097 }
0098
0099
0100 const G4RDVEMDataSet* G4RDDopplerProfile::Profile(G4int Z, G4int shellIndex) const
0101 {
0102 const G4RDVEMDataSet* profis = Profiles(Z);
0103 const G4RDVEMDataSet* profi = profis->GetComponent(shellIndex);
0104 return profi;
0105 }
0106
0107
0108 void G4RDDopplerProfile::PrintData() const
0109 {
0110 for (G4int Z=zMin; Z<zMax; Z++)
0111 {
0112 const G4RDVEMDataSet* profis = Profiles(Z);
0113 profis->PrintData();
0114 }
0115 }
0116
0117
0118 void G4RDDopplerProfile::LoadBiggsP(const G4String& fileName)
0119 {
0120 std::ostringstream ost;
0121 ost << fileName << ".dat";
0122 G4String name(ost.str());
0123
0124 const char* path = G4FindDataDir("G4LEDATA");
0125 if (!path)
0126 {
0127 G4String excep("G4LEDATA environment variable not set!");
0128 G4Exception("G4RDDopplerProfile::LoadBiggsP()",
0129 "InvalidSetup", FatalException, excep);
0130 }
0131
0132 G4String pathString(path);
0133 G4String dirFile = pathString + name;
0134 std::ifstream file(dirFile);
0135 std::filebuf* lsdp = file.rdbuf();
0136
0137 if (! (lsdp->is_open()) )
0138 {
0139 G4String s1("Data file: ");
0140 G4String s2(" not found");
0141 G4String excep = s1 + dirFile + s2;
0142 G4Exception("G4RDDopplerProfile::LoadBiggsP()",
0143 "DataNotFound", FatalException, excep);
0144 }
0145
0146 G4double p;
0147 while(!file.eof())
0148 {
0149 file >> p;
0150 biggsP.push_back(p);
0151 }
0152
0153
0154 if (biggsP.size() != nBiggs)
0155 G4Exception("G4RDDopplerProfile::LoadBiggsP()", "InvalidCondition",
0156 FatalException, "Number of momenta read in is not 31!");
0157 }
0158
0159
0160 void G4RDDopplerProfile::LoadProfile(const G4String& fileName,G4int Z)
0161 {
0162 std::ostringstream ost;
0163 ost << fileName << "-" << Z << ".dat";
0164 G4String name(ost.str());
0165
0166 const char* path = G4FindDataDir("G4LEDATA");
0167 if (!path)
0168 {
0169 G4String excep("G4LEDATA environment variable not set!");
0170 G4Exception("G4RDDopplerProfile::LoadProfile()",
0171 "InvalidSetup", FatalException, excep);
0172 }
0173
0174 G4String pathString(path);
0175 G4String dirFile = pathString + name;
0176 std::ifstream file(dirFile);
0177 std::filebuf* lsdp = file.rdbuf();
0178
0179 if (! (lsdp->is_open()) )
0180 {
0181 G4String s1("Data file: ");
0182 G4String s2(" not found");
0183 G4String excep = s1 + dirFile + s2;
0184 G4Exception("G4RDDopplerProfile::LoadProfile()",
0185 "DataNotFound", FatalException, excep);
0186 }
0187
0188 G4double p;
0189 G4int nShell = 0;
0190
0191
0192 G4RDVDataSetAlgorithm* interpolation = new G4RDLogLogInterpolation;
0193 G4RDVEMDataSet* dataSetForZ = new G4RDCompositeEMDataSet(interpolation,1.,1.,1,1);
0194
0195 while (!file.eof())
0196 {
0197 nShell++;
0198 G4DataVector* profi = new G4DataVector;
0199 G4DataVector* biggs = new G4DataVector;
0200
0201
0202 for (size_t i=0; i<nBiggs; i++)
0203 {
0204 file >> p;
0205 profi->push_back(p);
0206 biggs->push_back(biggsP[i]);
0207
0208 }
0209
0210
0211 G4RDVDataSetAlgorithm* algo = interpolation->Clone();
0212 G4RDVEMDataSet* dataSet = new G4RDEMDataSet(Z, biggs, profi, algo, 1., 1., true);
0213
0214
0215 dataSetForZ->AddComponent(dataSet);
0216 }
0217
0218
0219 nShells.push_back(nShell);
0220
0221 profileMap[Z] = dataSetForZ;
0222 }
0223
0224
0225 G4double G4RDDopplerProfile::RandomSelectMomentum(G4int Z, G4int shellIndex) const
0226 {
0227 G4double value = 0.;
0228 const G4RDVEMDataSet* profis = Profiles(Z);
0229 value = profis->RandomSelect(shellIndex);
0230 return value;
0231 }