44 algorithm(argAlgorithm), unitEnergies(argUnitEnergies), unitData(argUnitData)
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::vector<G4DataVector *>::size_type maxI(columns.size());
182 message+=fullFileName;
183 message+=
"\" should have at least two columns";
184 G4Exception(
"G4MicroElecCrossSectionDataSet_new::LoadData",
"em0005",
189 std::vector<G4DataVector*>::size_type i(1);
192 G4DataVector::size_type 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",
204 G4DataVector::size_type j(0);
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()));
230 delete log_columns[i];
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::vector<G4DataVector *>::size_type maxI(columns.size());
341 message+=fullFileName;
342 message+=
"\" should have at least two columns";
343 G4Exception(
"G4MicroElecCrossSectionDataSet_new::LoadData",
"em0005",
348 std::vector<G4DataVector*>::size_type i(1);
351 G4DataVector::size_type 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",
364 G4DataVector::size_type j(0);
372 argData->push_back(columns[i]->
operator[] (j)*
GetUnitData());
399 G4Exception(
"G4MicroElecCrossSectionDataSet_new::SaveData",
"em0005",
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);
444 out.setf(std::ofstream::left);
466 char *path = std::getenv(
"G4LEDATA");
469 G4Exception(
"G4MicroElecCrossSectionDataSet_new::Initialise",
"em0006",
FatalException,
"G4LEDATA environment variable not set.");
475 std::ostringstream fullFileName;
476 fullFileName << path <<
"/microelec/" << argFileName <<
".dat";
477 return G4String(fullFileName.str().c_str());
487 std::vector<G4VEMDataSet *>::const_iterator i(
components.begin());
488 std::vector<G4VEMDataSet *>::const_iterator end(
components.end());
492 value+=(*i)->FindValue(argEnergy);
503 return components.at(shell)->FindValue(argEnergy);
512 G4cout <<
"The data set has " <<
n <<
" components" <<
G4endl;
529 G4int argComponentId)
539 std::ostringstream message;
540 message <<
"Component " << argComponentId <<
" not found";
542 G4Exception(
"G4MicroElecCrossSectionDataSet_new::SetEnergiesData",
"em0005",
553 G4int argComponentId)
563 std::ostringstream message;
564 message <<
"Component " << argComponentId <<
" not found";
566 G4Exception(
"G4MicroElecCrossSectionDataSet_new::SetLogEnergiesData",
"em0005",
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4GLOB_DLL std::ostream G4cout
~G4MicroElecCrossSectionDataSet_new() override
G4String FullFileName(const G4String &argFileName) const
const G4DataVector & GetEnergies(G4int componentId) const override
G4double FindShellValue(G4double argEnergy, G4int shell) const
G4double GetUnitEnergies() 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
std::vector< G4VEMDataSet * > components
G4double FindValue(G4double e, G4int componentId=0) const override
G4VDataSetAlgorithm * algorithm
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
const G4VDataSetAlgorithm * GetAlgorithm() const
G4double GetUnitData() const
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