00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include "G4PixeShellDataSet.hh"
00042 #include "G4DataSet.hh"
00043 #include "G4IInterpolator.hh"
00044 #include <fstream>
00045 #include <sstream>
00046
00047
00048 G4PixeShellDataSet::G4PixeShellDataSet(G4int zeta,
00049 G4IInterpolator* algo,
00050 const G4String& modelK,
00051 const G4String& modelL,
00052 const G4String& modelM,
00053 G4double eUnit,
00054 G4double dataUnit):
00055 z(zeta),
00056 algorithm(algo),
00057 unitEnergies(eUnit),
00058 unitData(dataUnit)
00059 {
00060 if (algorithm == 0) G4Exception("G4PixeShellDataSet::G4PixeShellDataSet",
00061 "pii00000301",
00062 FatalException,
00063 "interpolation == 0");
00064
00065 crossModel.push_back(modelK);
00066 crossModel.push_back(modelL);
00067 crossModel.push_back(modelM);
00068
00069 shellName.push_back("k");
00070 shellName.push_back("l");
00071 shellName.push_back("m");
00072
00073 size_t sizeK = modelK.size();
00074 size_t sizeL = modelL.size();
00075 size_t sizeM = modelM.size();
00076
00077 if (sizeK > 0) subShellName.push_back("k");
00078
00079 if (sizeK > 0 && sizeL > 0)
00080 {
00081 subShellName.push_back("l1");
00082 subShellName.push_back("l2");
00083 subShellName.push_back("l3");
00084 }
00085 if (sizeK > 0 && sizeL > 0 && sizeM >0)
00086 {
00087 subShellName.push_back("m1");
00088 subShellName.push_back("m2");
00089 subShellName.push_back("m3");
00090 subShellName.push_back("m4");
00091 subShellName.push_back("m5");
00092 }
00093 }
00094
00095
00096 G4PixeShellDataSet::~G4PixeShellDataSet()
00097 {
00098 CleanUpComponents();
00099 if (algorithm) delete algorithm;
00100 }
00101
00102
00103 G4double G4PixeShellDataSet::FindValue(G4double energy, G4int ) const
00104 {
00105
00106 G4double value = 0.;
00107
00108 std::vector<G4IDataSet *>::const_iterator i(components.begin());
00109 std::vector<G4IDataSet *>::const_iterator end(components.end());
00110
00111 while (i != end)
00112 {
00113 value += (*i)->FindValue(energy);
00114 i++;
00115 }
00116 return value;
00117 }
00118
00119
00120 void G4PixeShellDataSet::PrintData(void) const
00121 {
00122 const size_t n = NumberOfComponents();
00123
00124 G4cout << "The data set has " << n << " components" << G4endl;
00125 G4cout << G4endl;
00126
00127 size_t i = 0;
00128
00129 while (i < n)
00130 {
00131 G4cout << "--- Component " << i << " ---" << G4endl;
00132 GetComponent(i)->PrintData();
00133 i++;
00134 }
00135 }
00136
00137
00138 void G4PixeShellDataSet::SetEnergiesData(G4DataVector* energies,
00139 G4DataVector* data,
00140 G4int componentId)
00141 {
00142 G4IDataSet* component = components[componentId];
00143
00144 if (component)
00145 {
00146 component->SetEnergiesData(energies, data, 0);
00147 return;
00148 }
00149
00150 std::ostringstream message;
00151 message << "G4PixeShellDataSet::SetEnergiesData - component " << componentId << " not found";
00152
00153 G4Exception("G4PixeShellDataSet::SetEnergiesData",
00154 "pii000000310",
00155 FatalException,
00156 message.str().c_str());
00157 }
00158
00159
00160 G4bool G4PixeShellDataSet::LoadData(const G4String& file)
00161 {
00162 CleanUpComponents();
00163
00164
00165
00166 G4int nShells = subShellName.size();
00167
00168 for (G4int subShellIndex=0; subShellIndex<nShells; subShellIndex++)
00169 {
00170 G4String subName = subShellName[subShellIndex];
00171 G4String fullFileName = FullFileName(file,subName);
00172
00173
00174 G4IDataSet* dataSet = new G4DataSet(z,algorithm);
00175 dataSet->LoadData(fullFileName);
00176
00177
00178 AddComponent(dataSet);
00179 }
00180
00181 return true;
00182 }
00183
00184
00185 G4bool G4PixeShellDataSet::SaveData(const G4String& ) const
00186 {
00187
00188 return true;
00189 }
00190
00191
00192 void G4PixeShellDataSet::CleanUpComponents(void)
00193 {
00194 while (!components.empty())
00195 {
00196 if (components.back()) delete components.back();
00197 components.pop_back();
00198 }
00199 }
00200
00201
00202 G4String G4PixeShellDataSet::FullFileName(const G4String& file,
00203 const G4String& subShell) const
00204 {
00205 char* path = getenv("G4PIIDATA");
00206 if (!path)
00207 G4Exception("G4PixeShellDataSet::FullFileName",
00208 "pii00000320",
00209 FatalException,
00210 "G4PIIDATA environment variable not set");
00211
00212
00213 G4int shellIndex = TranslateShell(subShell);
00214 G4String shellString = shellName[shellIndex];
00215 G4String shellModel = crossModel[shellIndex];
00216
00217 std::ostringstream fullFileName;
00218
00219 fullFileName
00220
00221 << "pixe/"
00222 << file
00223 << '/'
00224 << shellString
00225 << '/'
00226 << shellModel
00227 << '/'
00228 << subShell
00229 << '-' ;
00230
00231
00232
00233 G4String test(fullFileName.str().c_str());
00234
00235
00236 return G4String(fullFileName.str().c_str());
00237 }
00238
00239 G4int G4PixeShellDataSet::TranslateShell(const G4String& subShell) const
00240 {
00241
00242 G4int index = 0;
00243
00244 if (subShell == "l1" || subShell == "l2" || subShell == "l3" ) index = 1;
00245 if (subShell == "m1" ||
00246 subShell == "m2" ||
00247 subShell == "m3" ||
00248 subShell == "m4" ||
00249 subShell == "m5" ) index = 2;
00250 return index;
00251 }