69 algorithm(argAlgorithm), unitEnergies(argUnitEnergies), unitData(argUnitData)
89 std::ifstream in(fullFileName, std::ifstream::binary|std::ifstream::in);
94 message+=fullFileName;
95 message+=
"\" not found";
101 std::vector<G4DataVector *> columns;
102 std::vector<G4DataVector *> log_columns;
104 std::stringstream *stream(
new std::stringstream);
125 while (!stream->eof())
129 while (i>=columns.size())
135 columns[i]->push_back(value);
149 if (value <=0.) value = 1e-300;
150 log_columns[i]->push_back(std::log10(value));
156 stream=
new std::stringstream;
181 if (space && (!first))
191 catch(
const std::ios::failure &e)
199 std::vector<G4DataVector *>::size_type maxI(columns.size());
204 message+=fullFileName;
205 message+=
"\" should have at least two columns";
211 std::vector<G4DataVector*>::size_type i(1);
214 G4DataVector::size_type maxJ(columns[i]->size());
216 if (maxJ!=columns[0]->size())
219 message+=fullFileName;
220 message+=
"\" has lines with a different number of columns";
226 G4DataVector::size_type j(0);
236 argData->push_back(columns[i]->
operator[] (j)*
GetUnitData());
237 argLogEnergies->push_back(log_columns[0]->
operator[] (j) + std::log10(
GetUnitEnergies()));
238 argLogData->push_back(log_columns[i]->
operator[] (j) + std::log10(
GetUnitData()));
252 delete log_columns[i];
264 std::ifstream in(fullFileName, std::ifstream::binary|std::ifstream::in);
269 message+=fullFileName;
270 message+=
"\" not found";
271 G4Exception(
"G4CrossSectionDataSet::LoadNonLogData",
276 std::vector<G4DataVector *> columns;
278 std::stringstream *stream(
new std::stringstream);
299 while (!stream->eof())
303 while (i>=columns.size())
308 columns[i]->push_back(value);
314 stream=
new std::stringstream;
339 if (space && (!first))
349 catch(
const std::ios::failure &e)
357 std::vector<G4DataVector *>::size_type maxI(columns.size());
362 message+=fullFileName;
363 message+=
"\" should have at least two columns";
364 G4Exception(
"G4CrossSectionDataSet::LoadNonLogData",
369 std::vector<G4DataVector*>::size_type i(1);
372 G4DataVector::size_type maxJ(columns[i]->size());
374 if (maxJ!=columns[0]->size())
377 message+=fullFileName;
378 message+=
"\" has lines with a different number of columns";
379 G4Exception(
"G4CrossSectionDataSet::LoadNonLogData",
384 G4DataVector::size_type j(0);
392 argData->push_back(columns[i]->
operator[] (j)*
GetUnitData());
424 std::ofstream out(fullFileName);
429 message+=fullFileName;
438 G4DataVector::const_iterator * iData(
new G4DataVector::const_iterator[n]);
448 while (iEnergies!=iEnergiesEnd)
482 char* path = getenv(
"G4LEDATA");
490 std::ostringstream fullFileName;
492 fullFileName << path <<
"/" << argFileName <<
".dat";
494 return G4String(fullFileName.str().c_str());
503 std::vector<G4VEMDataSet *>::const_iterator i(
components.begin());
504 std::vector<G4VEMDataSet *>::const_iterator end(
components.end());
508 value+=(*i)->FindValue(argEnergy);
520 G4cout <<
"The data set has " << n <<
" components" <<
G4endl;
536 G4int argComponentId)
546 std::ostringstream message;
547 message <<
"component " << argComponentId <<
" not found";
549 G4Exception(
"G4CrossSectionDataSet::SetEnergiesData",
558 G4int argComponentId)
568 std::ostringstream message;
569 message <<
"component " << argComponentId <<
" not found";
571 G4Exception(
"G4CrossSectionDataSet::SetLogEnergiesData",
virtual void SetEnergiesData(G4DataVector *x, G4DataVector *data, G4int component=0)=0
virtual const G4DataVector & GetEnergies(G4int componentId) const
virtual const G4DataVector & GetData(G4int componentId) const =0
virtual G4bool SaveData(const G4String &argFileName) const
G4VDataSetAlgorithm * algorithm
virtual ~G4CrossSectionDataSet()
void CleanUpComponents(void)
std::vector< G4VEMDataSet * > components
virtual size_t NumberOfComponents(void) const
virtual void SetEnergiesData(G4DataVector *x, G4DataVector *values, G4int componentId)
virtual G4bool LoadNonLogData(const G4String &argFileName)
G4String FullFileName(const G4String &argFileName) const
virtual void PrintData(void) const
G4GLOB_DLL std::ostream G4cout
virtual G4double FindValue(G4double e, G4int componentId=0) const
const G4VDataSetAlgorithm * GetAlgorithm() const
virtual void SetLogEnergiesData(G4DataVector *x, G4DataVector *data, G4DataVector *Log_x, G4DataVector *Log_data, G4int component=0)=0
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
virtual void PrintData(void) const =0
G4double GetUnitEnergies() const
virtual const G4VEMDataSet * GetComponent(G4int componentId) const
virtual void AddComponent(G4VEMDataSet *dataSet)
virtual void SetLogEnergiesData(G4DataVector *x, G4DataVector *values, G4DataVector *log_x, G4DataVector *log_values, G4int componentId)
virtual G4bool LoadData(const G4String &argFileName)
G4double GetUnitData() const