69 algorithm(argAlgorithm), unitEnergies(argUnitEnergies), unitData(argUnitData)
88 G4String fullFileName(FullFileName(argFileName));
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);
235 argEnergies->push_back(columns[0]->
operator[] (j)*GetUnitEnergies());
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()));
242 AddComponent(
new G4EMDataSet(i-1, argEnergies, argData, argLogEnergies, argLogData, GetAlgorithm()->Clone(), GetUnitEnergies(), GetUnitData()));
252 delete log_columns[i];
263 G4String fullFileName(FullFileName(argFileName));
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);
391 argEnergies->push_back(columns[0]->
operator[] (j)*GetUnitEnergies());
392 argData->push_back(columns[i]->
operator[] (j)*GetUnitData());
396 AddComponent(
new G4EMDataSet(i-1, argEnergies, argData, GetAlgorithm()->Clone(), GetUnitEnergies(), GetUnitData()));
423 G4String fullFileName(FullFileName(argFileName));
424 std::ofstream out(fullFileName);
429 message+=fullFileName;
438 G4DataVector::const_iterator * iData(
new G4DataVector::const_iterator[n]);
448 while (iEnergies!=iEnergiesEnd)
453 out << ((*iEnergies)/GetUnitEnergies());
463 out << ((*(iData[k]))/GetUnitData());
480 G4String G4CrossSectionDataSet::FullFileName(
const G4String& argFileName)
const
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",
576 void G4CrossSectionDataSet::CleanUpComponents()
578 while (!components.empty())
580 if (components.back())
delete components.back();
581 components.pop_back();
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
virtual ~G4CrossSectionDataSet()
virtual size_t NumberOfComponents(void) const
virtual void SetEnergiesData(G4DataVector *x, G4DataVector *values, G4int componentId)
virtual G4bool LoadNonLogData(const G4String &argFileName)
virtual void PrintData(void) const
G4CrossSectionDataSet(G4VDataSetAlgorithm *algo, G4double xUnit=CLHEP::MeV, G4double dataUnit=CLHEP::barn)
G4GLOB_DLL std::ostream G4cout
virtual G4double FindValue(G4double e, G4int componentId=0) 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
virtual const G4VEMDataSet * GetComponent(G4int componentId) const
virtual void AddComponent(G4VEMDataSet *dataSet)
const XML_Char int const XML_Char * value
virtual void SetLogEnergiesData(G4DataVector *x, G4DataVector *values, G4DataVector *log_x, G4DataVector *log_values, G4int componentId)
virtual G4bool LoadData(const G4String &argFileName)