44 algorithm(argAlgorithm), unitEnergies(argUnitEnergies), unitData(argUnitData)
63 G4String fullFileName(FullFileName(argFileName));
64 std::ifstream in(fullFileName, std::ifstream::binary|std::ifstream::in);
69 message+=fullFileName;
70 message+=
"\" not found";
71 G4Exception(
"G4MicroElecCrossSectionDataSet_new::LoadData",
"em0003",
76 std::vector<G4DataVector *> columns;
77 std::vector<G4DataVector *> log_columns;
79 std::stringstream *stream(
new std::stringstream);
100 while (!stream->eof())
104 while (i>=columns.size())
110 columns[i]->push_back(value);
124 if (value <=0.) value = 1e-300;
125 log_columns[i]->push_back(std::log10(value));
131 stream=
new std::stringstream;
150 if ((c==
' ') && space)
160 if (space && (!first))
170 catch(
const std::ios::failure &e)
177 std::size_t maxI(columns.size());
182 message+=fullFileName;
183 message+=
"\" should have at least two columns";
184 G4Exception(
"G4MicroElecCrossSectionDataSet_new::LoadData",
"em0005",
192 std::size_t maxJ(columns[i]->size());
194 if (maxJ!=columns[0]->size())
197 message+=fullFileName;
198 message+=
"\" has lines with a different number of columns";
199 G4Exception(
"G4MicroElecCrossSectionDataSet_new::LoadData",
"em0005",
213 argEnergies->push_back(columns[0]->
operator[] (j)*GetUnitEnergies());
214 argData->push_back(columns[i]->
operator[] (j)*GetUnitData());
215 argLogEnergies->push_back(log_columns[0]->
operator[] (j) + std::log10(GetUnitEnergies()));
216 argLogData->push_back(log_columns[i]->
operator[] (j) + std::log10(GetUnitData()));
220 AddComponent(
new G4EMDataSet(
G4int(i-1), argEnergies, argData, argLogEnergies, argLogData, GetAlgorithm()->Clone(), GetUnitEnergies(), GetUnitData()));
230 delete log_columns[i];
242 G4String fullFileName(FullFileName(argFileName));
243 std::ifstream in(fullFileName, std::ifstream::binary|std::ifstream::in);
248 message+=fullFileName;
249 message+=
"\" not found";
250 G4Exception(
"G4MicroElecCrossSectionDataSet_new::LoadData",
"em0003",
255 std::vector<G4DataVector *> columns;
257 std::stringstream *stream(
new std::stringstream);
278 while (!stream->eof())
282 while (i>=columns.size())
287 columns[i]->push_back(value);
293 stream=
new std::stringstream;
318 if (space && (!first))
328 catch(
const std::ios::failure &e)
336 std::size_t maxI(columns.size());
341 message+=fullFileName;
342 message+=
"\" should have at least two columns";
343 G4Exception(
"G4MicroElecCrossSectionDataSet_new::LoadData",
"em0005",
351 std::size_t maxJ(columns[i]->size());
354 if (maxJ!=columns[0]->size())
357 message+=fullFileName;
358 message+=
"\" has lines with a different number of columns.";
359 G4Exception(
"G4MicroElecCrossSectionDataSet_new::LoadData",
"em0005",
371 argEnergies->push_back(columns[0]->
operator[] (j)*GetUnitEnergies());
372 argData->push_back(columns[i]->
operator[] (j)*GetUnitData());
399 G4Exception(
"G4MicroElecCrossSectionDataSet_new::SaveData",
"em0005",
405 G4String fullFileName(FullFileName(argFileName));
406 std::ofstream out(fullFileName);
411 message+=fullFileName;
413 G4Exception(
"G4MicroElecCrossSectionDataSet_new::SaveData",
"em0005",
420 G4DataVector::const_iterator * iData(
new G4DataVector::const_iterator[n]);
430 while (iEnergies!=iEnergiesEnd)
434 out.setf(std::ofstream::left);
435 out << ((*iEnergies)/GetUnitEnergies());
444 out.setf(std::ofstream::left);
445 out << ((*(iData[k]))/GetUnitData());
463G4String G4MicroElecCrossSectionDataSet_new::FullFileName(
const G4String& argFileName)
const
468 G4Exception(
"G4MicroElecCrossSectionDataSet_new::Initialise",
"em0006",
FatalException,
"G4LEDATA environment variable not set.");
474 std::ostringstream fullFileName;
475 fullFileName << path <<
"/microelec/" << argFileName <<
".dat";
476 return G4String(fullFileName.str().c_str());
486 std::vector<G4VEMDataSet *>::const_iterator i(components.begin());
487 std::vector<G4VEMDataSet *>::const_iterator end(components.end());
491 value+=(*i)->FindValue(argEnergy);
502 return components.at(shell)->FindValue(argEnergy);
511 G4cout <<
"The data set has " << n <<
" components" <<
G4endl;
528 G4int argComponentId)
538 std::ostringstream message;
539 message <<
"Component " << argComponentId <<
" not found";
541 G4Exception(
"G4MicroElecCrossSectionDataSet_new::SetEnergiesData",
"em0005",
552 G4int argComponentId)
562 std::ostringstream message;
563 message <<
"Component " << argComponentId <<
" not found";
565 G4Exception(
"G4MicroElecCrossSectionDataSet_new::SetLogEnergiesData",
"em0005",
572void G4MicroElecCrossSectionDataSet_new::CleanUpComponents()
574 while (!components.empty())
576 if (components.back())
delete components.back();
577 components.pop_back();
const char * G4FindDataDir(const char *)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4GLOB_DLL std::ostream G4cout
~G4MicroElecCrossSectionDataSet_new() override
const G4DataVector & GetEnergies(G4int componentId) const override
G4double FindShellValue(G4double argEnergy, G4int shell) const
const G4VEMDataSet * GetComponent(G4int componentId) const override
void PrintData(void) const override
G4bool LoadNonLogData(const G4String &argFileName) override
size_t NumberOfComponents(void) const override
void AddComponent(G4VEMDataSet *dataSet) override
G4bool LoadData(const G4String &argFileName) override
G4double FindValue(G4double e, G4int componentId=0) const override
G4MicroElecCrossSectionDataSet_new(G4VDataSetAlgorithm *algo, G4double xUnit=CLHEP::MeV, G4double dataUnit=CLHEP::barn)
void SetEnergiesData(G4DataVector *x, G4DataVector *values, G4int componentId) override
G4bool SaveData(const G4String &argFileName) const override
void SetLogEnergiesData(G4DataVector *x, G4DataVector *values, G4DataVector *log_x, G4DataVector *log_values, G4int componentId) override
virtual void SetEnergiesData(G4DataVector *x, G4DataVector *data, G4int component=0)=0
virtual const G4DataVector & GetData(G4int componentId) const =0
virtual void SetLogEnergiesData(G4DataVector *x, G4DataVector *data, G4DataVector *Log_x, G4DataVector *Log_data, G4int component=0)=0
virtual void PrintData(void) const =0