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";
95 G4Exception(
"G4DNACrossSectionDataSet::LoadData",
"em0003",
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";
197 G4Exception(
"G4DNACrossSectionDataSet::LoadData",
"em0005",
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";
212 G4Exception(
"G4DNACrossSectionDataSet::LoadData",
"em0005",
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];
255 std::ifstream in(fullFileName, std::ifstream::binary|std::ifstream::in);
260 message+=fullFileName;
261 message+=
"\" not found";
262 G4Exception(
"G4DNACrossSectionDataSet::LoadData",
"em0003",
267 std::vector<G4DataVector *> columns;
269 std::stringstream *stream(
new std::stringstream);
290 while (!stream->eof())
294 while (i>=columns.size())
299 columns[i]->push_back(value);
305 stream=
new std::stringstream;
323 if (comment) {
break; }
324 if (space && (!first)) { (*stream) <<
' '; }
332 catch(
const std::ios::failure &e)
340 std::vector<G4DataVector *>::size_type maxI(columns.size());
345 message+=fullFileName;
346 message+=
"\" should have at least two columns";
347 G4Exception(
"G4DNACrossSectionDataSet::LoadData",
"em0005",
352 std::vector<G4DataVector*>::size_type i(1);
355 G4DataVector::size_type maxJ(columns[i]->size());
357 if (maxJ!=columns[0]->size())
360 message+=fullFileName;
361 message+=
"\" has lines with a different number of columns.";
362 G4Exception(
"G4DNACrossSectionDataSet::LoadData",
"em0005",
367 G4DataVector::size_type j(0);
375 argData->push_back(columns[i]->
operator[] (j)*
GetUnitData());
401 G4Exception(
"G4DNACrossSectionDataSet::SaveData",
"em0005",
408 std::ofstream out(fullFileName);
413 message+=fullFileName;
415 G4Exception(
"G4DNACrossSectionDataSet::SaveData",
"em0005",
422 G4DataVector::const_iterator * iData(
new G4DataVector::const_iterator[
n]);
432 while (iEnergies!=iEnergiesEnd)
436 out.setf(std::ofstream::left);
446 out.setf(std::ofstream::left);
466 char* path = std::getenv(
"G4LEDATA");
469 G4Exception(
"G4DNACrossSectionDataSet::FullFileName",
"em0006",
475 std::ostringstream fullFileName;
477 fullFileName << path <<
"/" << argFileName <<
".dat";
479 return G4String(fullFileName.str().c_str());
488 std::vector<G4VEMDataSet *>::const_iterator i(
components.begin());
489 std::vector<G4VEMDataSet *>::const_iterator end(
components.end());
493 value+=(*i)->FindValue(argEnergy);
505 G4cout <<
"The data set has " <<
n <<
" components" <<
G4endl;
521 G4int argComponentId)
531 std::ostringstream message;
532 message <<
"Component " << argComponentId <<
" not found";
534 G4Exception(
"G4DNACrossSectionDataSet::SetEnergiesData",
"em0005",
544 G4int argComponentId)
554 std::ostringstream message;
555 message <<
"Component " << argComponentId <<
" not found";
557 G4Exception(
"G4DNACrossSectionDataSet::SetLogEnergiesData",
"em0005",
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4GLOB_DLL std::ostream G4cout
virtual G4double FindValue(G4double e, G4int componentId=0) const
G4double GetUnitData() const
G4VDataSetAlgorithm * algorithm
virtual size_t NumberOfComponents(void) const
G4double GetUnitEnergies() const
virtual const G4DataVector & GetEnergies(G4int componentId) const
G4DNACrossSectionDataSet()
const G4VDataSetAlgorithm * GetAlgorithm() const
virtual const G4VEMDataSet * GetComponent(G4int componentId) const
void CleanUpComponents(void)
virtual G4bool LoadNonLogData(const G4String &argFileName)
virtual void SetEnergiesData(G4DataVector *x, G4DataVector *values, G4int componentId)
virtual G4bool LoadData(const G4String &argFileName)
virtual void SetLogEnergiesData(G4DataVector *x, G4DataVector *values, G4DataVector *log_x, G4DataVector *log_values, G4int componentId)
G4String FullFileName(const G4String &argFileName) const
virtual G4bool SaveData(const G4String &argFileName) const
virtual ~G4DNACrossSectionDataSet()
std::vector< G4VEMDataSet * > components
virtual void PrintData(void) const
virtual void AddComponent(G4VEMDataSet *dataSet)
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