43 algorithm(argAlgorithm), unitEnergies(argUnitEnergies), unitData(argUnitData)
60 G4String fullFileName(FullFileName(argFileName));
61 std::ifstream in(fullFileName, std::ifstream::binary|std::ifstream::in);
66 message+=fullFileName;
67 message+=
"\" not found";
68 G4Exception(
"G4MicroElecCrossSectionDataSet::LoadData",
"em0003",
73 std::vector<G4DataVector *> columns;
74 std::vector<G4DataVector *> log_columns;
76 std::stringstream *stream(
new std::stringstream);
97 while (!stream->eof())
101 while (i>=columns.size())
107 columns[i]->push_back(value);
120 if (value <=0.) value = 1e-300;
121 log_columns[i]->push_back(std::log10(value));
126 stream=
new std::stringstream;
141 if (comment) {
break; }
142 if (space && (!first)) { (*stream) <<
' '; }
149 catch(
const std::ios::failure &e)
157 std::size_t maxI(columns.size());
162 message+=fullFileName;
163 message+=
"\" should have at least two columns";
164 G4Exception(
"G4MicroElecCrossSectionDataSet::LoadData",
"em0005",
172 std::size_t maxJ(columns[i]->size());
174 if (maxJ!=columns[0]->size())
177 message+=fullFileName;
178 message+=
"\" has lines with a different number of columns";
179 G4Exception(
"G4MicroElecCrossSectionDataSet::LoadData",
"em0005",
193 argEnergies->push_back(columns[0]->
operator[] (j)*GetUnitEnergies());
194 argData->push_back(columns[i]->
operator[] (j)*GetUnitData());
195 argLogEnergies->push_back(log_columns[0]->
operator[] (j) + std::log10(GetUnitEnergies()));
196 argLogData->push_back(log_columns[i]->
operator[] (j) + std::log10(GetUnitData()));
201 GetAlgorithm()->Clone(), GetUnitEnergies(), GetUnitData()));
211 delete log_columns[i];
223 G4String fullFileName(FullFileName(argFileName));
224 std::ifstream in(fullFileName, std::ifstream::binary|std::ifstream::in);
229 message+=fullFileName;
230 message+=
"\" not found";
231 G4Exception(
"G4MicroElecCrossSectionDataSet::LoadData",
"em0003",
236 std::vector<G4DataVector *> columns;
238 std::stringstream *stream(
new std::stringstream);
259 while (!stream->eof())
263 while (i>=columns.size())
268 columns[i]->push_back(value);
274 stream=
new std::stringstream;
292 if (comment) {
break; }
293 if (space && (!first)) { (*stream) <<
' '; }
301 catch(
const std::ios::failure &e)
309 std::size_t maxI(columns.size());
314 message+=fullFileName;
315 message+=
"\" should have at least two columns";
316 G4Exception(
"G4MicroElecCrossSectionDataSet::LoadData",
"em0005",
324 std::size_t maxJ(columns[i]->size());
326 if (maxJ!=columns[0]->size())
329 message+=fullFileName;
330 message+=
"\" has lines with a different number of columns.";
331 G4Exception(
"G4MicroElecCrossSectionDataSet::LoadData",
"em0005",
343 argEnergies->push_back(columns[0]->
operator[] (j)*GetUnitEnergies());
344 argData->push_back(columns[i]->
operator[] (j)*GetUnitData());
370 G4Exception(
"G4MicroElecCrossSectionDataSet::SaveData",
"em0005",
376 G4String fullFileName(FullFileName(argFileName));
377 std::ofstream out(fullFileName);
382 message+=fullFileName;
384 G4Exception(
"G4MicroElecCrossSectionDataSet::SaveData",
"em0005",
391 G4DataVector::const_iterator * iData(
new G4DataVector::const_iterator[n]);
401 while (iEnergies!=iEnergiesEnd)
405 out.setf(std::ofstream::left);
406 out << ((*iEnergies)/GetUnitEnergies());
415 out.setf(std::ofstream::left);
416 out << ((*(iData[k]))/GetUnitData());
431G4String G4MicroElecCrossSectionDataSet::FullFileName(
const G4String& argFileName)
const
436 G4Exception(
"G4MicroElecCrossSectionDataSet::FullFileName",
"em0006",
442 std::ostringstream fullFileName;
444 fullFileName << path <<
"/" << argFileName <<
".dat";
446 return G4String(fullFileName.str().c_str());
456 std::vector<G4VEMDataSet *>::const_iterator i(components.begin());
457 std::vector<G4VEMDataSet *>::const_iterator end(components.end());
461 value+=(*i)->FindValue(argEnergy);
474 G4cout <<
"The data set has " << n <<
" components" <<
G4endl;
491 G4int argComponentId)
501 std::ostringstream message;
502 message <<
"Component " << argComponentId <<
" not found";
504 G4Exception(
"G4MicroElecCrossSectionDataSet::SetEnergiesData",
"em0005",
515 G4int argComponentId)
525 std::ostringstream message;
526 message <<
"Component " << argComponentId <<
" not found";
528 G4Exception(
"G4MicroElecCrossSectionDataSet::SetLogEnergiesData",
"em0005",
535void G4MicroElecCrossSectionDataSet::CleanUpComponents()
537 while (!components.empty())
539 if (components.back())
delete components.back();
540 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
G4bool LoadData(const G4String &argFileName) override
~G4MicroElecCrossSectionDataSet()
void PrintData(void) const override
G4bool LoadNonLogData(const G4String &argFileName) override
void SetEnergiesData(G4DataVector *x, G4DataVector *values, G4int componentId) override
G4bool SaveData(const G4String &argFileName) const override
G4double FindValue(G4double e, G4int componentId=0) const override
size_t NumberOfComponents(void) const override
void SetLogEnergiesData(G4DataVector *x, G4DataVector *values, G4DataVector *log_x, G4DataVector *log_values, G4int componentId) override
const G4DataVector & GetEnergies(G4int componentId) const override
G4MicroElecCrossSectionDataSet(G4VDataSetAlgorithm *algo, G4double xUnit=CLHEP::MeV, G4double dataUnit=CLHEP::barn)
void AddComponent(G4VEMDataSet *dataSet) override
const G4VEMDataSet * GetComponent(G4int componentId) const 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