44 algorithm(argAlgorithm), unitEnergies(argUnitEnergies), unitData(argUnitData)
66 G4String fullFileName(FullFileName(argFileName));
67 std::ifstream in(fullFileName, std::ifstream::binary|std::ifstream::in);
72 message+=fullFileName;
73 message+=
"\" not found";
74 G4Exception(
"G4MicroElecCrossSectionDataSet_new::LoadData",
"em0003",
79 std::vector<G4DataVector *> columns;
80 std::vector<G4DataVector *> log_columns;
82 std::stringstream *stream(
new std::stringstream);
103 while (!stream->eof())
107 while (i>=columns.size())
113 columns[i]->push_back(value);
127 if (value <=0.) value = 1e-300;
128 log_columns[i]->push_back(std::log10(value));
134 stream=
new std::stringstream;
153 if ((c==
' ') && space)
163 if (space && (!first))
173 catch(
const std::ios::failure &e)
181 std::vector<G4DataVector *>::size_type maxI(columns.size());
186 message+=fullFileName;
187 message+=
"\" should have at least two columns";
188 G4Exception(
"G4MicroElecCrossSectionDataSet_new::LoadData",
"em0005",
193 std::vector<G4DataVector*>::size_type i(1);
196 G4DataVector::size_type maxJ(columns[i]->size());
198 if (maxJ!=columns[0]->size())
201 message+=fullFileName;
202 message+=
"\" has lines with a different number of columns";
203 G4Exception(
"G4MicroElecCrossSectionDataSet_new::LoadData",
"em0005",
208 G4DataVector::size_type j(0);
217 argEnergies->push_back(columns[0]->
operator[] (j)*GetUnitEnergies());
218 argData->push_back(columns[i]->
operator[] (j)*GetUnitData());
219 argLogEnergies->push_back(log_columns[0]->
operator[] (j) + std::log10(GetUnitEnergies()));
220 argLogData->push_back(log_columns[i]->
operator[] (j) + std::log10(GetUnitData()));
224 AddComponent(
new G4EMDataSet(i-1, argEnergies, argData, argLogEnergies, argLogData, GetAlgorithm()->Clone(), GetUnitEnergies(), GetUnitData()));
234 delete log_columns[i];
248 G4String fullFileName(FullFileName(argFileName));
249 std::ifstream in(fullFileName, std::ifstream::binary|std::ifstream::in);
254 message+=fullFileName;
255 message+=
"\" not found";
256 G4Exception(
"G4MicroElecCrossSectionDataSet_new::LoadData",
"em0003",
261 std::vector<G4DataVector *> columns;
263 std::stringstream *stream(
new std::stringstream);
284 while (!stream->eof())
288 while (i>=columns.size())
293 columns[i]->push_back(value);
299 stream=
new std::stringstream;
324 if (space && (!first))
334 catch(
const std::ios::failure &e)
342 std::vector<G4DataVector *>::size_type maxI(columns.size());
347 message+=fullFileName;
348 message+=
"\" should have at least two columns";
349 G4Exception(
"G4MicroElecCrossSectionDataSet_new::LoadData",
"em0005",
354 std::vector<G4DataVector*>::size_type i(1);
357 G4DataVector::size_type maxJ(columns[i]->size());
360 if (maxJ!=columns[0]->size())
363 message+=fullFileName;
364 message+=
"\" has lines with a different number of columns.";
365 G4Exception(
"G4MicroElecCrossSectionDataSet_new::LoadData",
"em0005",
370 G4DataVector::size_type j(0);
377 argEnergies->push_back(columns[0]->
operator[] (j)*GetUnitEnergies());
378 argData->push_back(columns[i]->
operator[] (j)*GetUnitData());
382 AddComponent(
new G4EMDataSet(i-1, argEnergies, argData, GetAlgorithm()->Clone(), GetUnitEnergies(), GetUnitData()));
406 G4Exception(
"G4MicroElecCrossSectionDataSet_new::SaveData",
"em0005",
412 G4String fullFileName(FullFileName(argFileName));
413 std::ofstream out(fullFileName);
418 message+=fullFileName;
420 G4Exception(
"G4MicroElecCrossSectionDataSet_new::SaveData",
"em0005",
427 G4DataVector::const_iterator * iData(
new G4DataVector::const_iterator[n]);
437 while (iEnergies!=iEnergiesEnd)
441 out.setf(std::ofstream::left);
442 out << ((*iEnergies)/GetUnitEnergies());
451 out.setf(std::ofstream::left);
452 out << ((*(iData[k]))/GetUnitData());
470G4String G4MicroElecCrossSectionDataSet_new::FullFileName(
const G4String& argFileName)
const
473 char *path = std::getenv(
"G4LEDATA");
476 G4Exception(
"G4MicroElecCrossSectionDataSet_new::Initialise",
"em0006",
FatalException,
"G4LEDATA environment variable not set.");
482 std::ostringstream fullFileName;
483 fullFileName << path <<
"/microelec/" << argFileName <<
".dat";
484 return G4String(fullFileName.str().c_str());
495 std::vector<G4VEMDataSet *>::const_iterator i(components.begin());
496 std::vector<G4VEMDataSet *>::const_iterator end(components.end());
500 value+=(*i)->FindValue(argEnergy);
511 return components.at(shell)->FindValue(argEnergy);
521 G4cout <<
"The data set has " << n <<
" components" <<
G4endl;
539 G4int argComponentId)
549 std::ostringstream message;
550 message <<
"Component " << argComponentId <<
" not found";
552 G4Exception(
"G4MicroElecCrossSectionDataSet_new::SetEnergiesData",
"em0005",
563 G4int argComponentId)
573 std::ostringstream message;
574 message <<
"Component " << argComponentId <<
" not found";
576 G4Exception(
"G4MicroElecCrossSectionDataSet_new::SetLogEnergiesData",
"em0005",
583void G4MicroElecCrossSectionDataSet_new::CleanUpComponents()
585 while (!components.empty())
587 if (components.back())
delete components.back();
588 components.pop_back();
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