68 algorithm(argAlgorithm), unitEnergies(argUnitEnergies), unitData(argUnitData)
88 std::ifstream in(fullFileName, std::ifstream::binary|std::ifstream::in);
93 message+=fullFileName;
94 message+=
"\" not found";
100 std::vector<G4DataVector *> columns;
101 std::vector<G4DataVector *> log_columns;
103 std::stringstream *stream(
new std::stringstream);
124 while (!stream->eof())
128 while (i>=columns.size())
134 columns[i]->push_back(value);
148 if (value <=0.) value = 1e-300;
149 log_columns[i]->push_back(std::log10(value));
155 stream=
new std::stringstream;
173 if (comment) {
break; }
174 if (space && (!first)) { (*stream) <<
' '; }
182 catch(
const std::ios::failure &e)
190 std::vector<G4DataVector *>::size_type maxI(columns.size());
195 message+=fullFileName;
196 message+=
"\" should have at least two columns";
202 std::vector<G4DataVector*>::size_type i(1);
205 G4DataVector::size_type maxJ(columns[i]->size());
207 if (maxJ!=columns[0]->size())
210 message+=fullFileName;
211 message+=
"\" has lines with a different number of columns";
217 G4DataVector::size_type j(0);
227 argData->push_back(columns[i]->
operator[] (j)*
GetUnitData());
228 argLogEnergies->push_back(log_columns[0]->
operator[] (j) + std::log10(
GetUnitEnergies()));
229 argLogData->push_back(log_columns[i]->
operator[] (j) + std::log10(
GetUnitData()));
243 delete log_columns[i];
256 std::ifstream in(fullFileName, std::ifstream::binary|std::ifstream::in);
261 message+=fullFileName;
262 message+=
"\" not found";
263 G4Exception(
"G4CrossSectionDataSet::LoadNonLogData",
268 std::vector<G4DataVector *> columns;
270 std::stringstream *stream(
new std::stringstream);
291 while (!stream->eof())
295 while (i>=columns.size())
300 columns[i]->push_back(value);
306 stream=
new std::stringstream;
324 if (comment) {
break; }
325 if (space && (!first)) { (*stream) <<
' '; }
333 catch(
const std::ios::failure &e)
341 std::vector<G4DataVector *>::size_type maxI(columns.size());
346 message+=fullFileName;
347 message+=
"\" should have at least two columns";
348 G4Exception(
"G4CrossSectionDataSet::LoadNonLogData",
353 std::vector<G4DataVector*>::size_type i(1);
356 G4DataVector::size_type maxJ(columns[i]->size());
358 if (maxJ!=columns[0]->size())
361 message+=fullFileName;
362 message+=
"\" has lines with a different number of columns";
363 G4Exception(
"G4CrossSectionDataSet::LoadNonLogData",
368 G4DataVector::size_type j(0);
376 argData->push_back(columns[i]->
operator[] (j)*
GetUnitData());
409 std::ofstream out(fullFileName);
414 message+=fullFileName;
423 G4DataVector::const_iterator * iData(
new G4DataVector::const_iterator[
n]);
433 while (iEnergies!=iEnergiesEnd)
437 out.setf(std::ofstream::left);
447 out.setf(std::ofstream::left);
468 char* path = std::getenv(
"G4LEDATA");
476 std::ostringstream fullFileName;
478 fullFileName << path <<
"/" << argFileName <<
".dat";
480 return G4String(fullFileName.str().c_str());
490 std::vector<G4VEMDataSet *>::const_iterator i(
components.begin());
491 std::vector<G4VEMDataSet *>::const_iterator end(
components.end());
495 value+=(*i)->FindValue(argEnergy);
508 G4cout <<
"The data set has " <<
n <<
" components" <<
G4endl;
525 G4int argComponentId)
535 std::ostringstream message;
536 message <<
"component " << argComponentId <<
" not found";
538 G4Exception(
"G4CrossSectionDataSet::SetEnergiesData",
548 G4int argComponentId)
558 std::ostringstream message;
559 message <<
"component " << argComponentId <<
" not found";
561 G4Exception(
"G4CrossSectionDataSet::SetLogEnergiesData",
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4GLOB_DLL std::ostream G4cout
virtual G4bool LoadData(const G4String &argFileName)
virtual G4bool LoadNonLogData(const G4String &argFileName)
virtual void SetEnergiesData(G4DataVector *x, G4DataVector *values, G4int componentId)
virtual const G4VEMDataSet * GetComponent(G4int componentId) const
G4VDataSetAlgorithm * algorithm
virtual G4bool SaveData(const G4String &argFileName) const
G4double GetUnitEnergies() const
virtual void SetLogEnergiesData(G4DataVector *x, G4DataVector *values, G4DataVector *log_x, G4DataVector *log_values, G4int componentId)
G4double GetUnitData() const
virtual ~G4CrossSectionDataSet()
virtual const G4DataVector & GetEnergies(G4int componentId) const
virtual G4double FindValue(G4double e, G4int componentId=0) const
std::vector< G4VEMDataSet * > components
G4String FullFileName(const G4String &argFileName) const
const G4VDataSetAlgorithm * GetAlgorithm() const
void CleanUpComponents(void)
virtual void AddComponent(G4VEMDataSet *dataSet)
virtual void PrintData(void) const
virtual size_t NumberOfComponents(void) 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