43 algorithm(argAlgorithm), unitEnergies(argUnitEnergies), unitData(argUnitData)
62 G4String fullFileName(FullFileName(argFileName));
68 message+=fullFileName;
69 message+=
"\" not found";
70 G4Exception(
"G4MicroElecCrossSectionDataSet::LoadData",
"em0003",
75 std::vector<G4DataVector *> columns;
76 std::vector<G4DataVector *> log_columns;
78 std::stringstream *stream(
new std::stringstream);
99 while (!stream->eof())
103 while (i>=columns.size())
109 columns[i]->push_back(value);
123 if (value <=0.) value = 1e-300;
124 log_columns[i]->push_back(std::log10(value));
130 stream=
new std::stringstream;
155 if (space && (!first))
165 catch(
const std::ios::failure &e)
173 std::vector<G4DataVector *>::size_type maxI(columns.size());
178 message+=fullFileName;
179 message+=
"\" should have at least two columns";
180 G4Exception(
"G4MicroElecCrossSectionDataSet::LoadData",
"em0005",
185 std::vector<G4DataVector*>::size_type i(1);
188 G4DataVector::size_type maxJ(columns[i]->size());
190 if (maxJ!=columns[0]->size())
193 message+=fullFileName;
194 message+=
"\" has lines with a different number of columns";
195 G4Exception(
"G4MicroElecCrossSectionDataSet::LoadData",
"em0005",
200 G4DataVector::size_type j(0);
209 argEnergies->push_back(columns[0]->
operator[] (j)*GetUnitEnergies());
210 argData->push_back(columns[i]->
operator[] (j)*GetUnitData());
211 argLogEnergies->push_back(log_columns[0]->
operator[] (j) + std::log10(GetUnitEnergies()));
212 argLogData->push_back(log_columns[i]->
operator[] (j) + std::log10(GetUnitData()));
216 AddComponent(
new G4EMDataSet(i-1, argEnergies, argData, argLogEnergies, argLogData, GetAlgorithm()->Clone(), GetUnitEnergies(), GetUnitData()));
226 delete log_columns[i];
237 G4String fullFileName(FullFileName(argFileName));
243 message+=fullFileName;
244 message+=
"\" not found";
245 G4Exception(
"G4MicroElecCrossSectionDataSet::LoadData",
"em0003",
250 std::vector<G4DataVector *> columns;
252 std::stringstream *stream(
new std::stringstream);
273 while (!stream->eof())
277 while (i>=columns.size())
282 columns[i]->push_back(value);
288 stream=
new std::stringstream;
313 if (space && (!first))
323 catch(
const std::ios::failure &e)
331 std::vector<G4DataVector *>::size_type maxI(columns.size());
336 message+=fullFileName;
337 message+=
"\" should have at least two columns";
338 G4Exception(
"G4MicroElecCrossSectionDataSet::LoadData",
"em0005",
343 std::vector<G4DataVector*>::size_type i(1);
346 G4DataVector::size_type maxJ(columns[i]->size());
348 if (maxJ!=columns[0]->size())
351 message+=fullFileName;
352 message+=
"\" has lines with a different number of columns.";
353 G4Exception(
"G4MicroElecCrossSectionDataSet::LoadData",
"em0005",
358 G4DataVector::size_type j(0);
365 argEnergies->push_back(columns[0]->
operator[] (j)*GetUnitEnergies());
366 argData->push_back(columns[i]->
operator[] (j)*GetUnitData());
370 AddComponent(
new G4EMDataSet(i-1, argEnergies, argData, GetAlgorithm()->Clone(), GetUnitEnergies(), GetUnitData()));
392 G4Exception(
"G4MicroElecCrossSectionDataSet::SaveData",
"em0005",
398 G4String fullFileName(FullFileName(argFileName));
399 std::ofstream out(fullFileName);
404 message+=fullFileName;
406 G4Exception(
"G4MicroElecCrossSectionDataSet::SaveData",
"em0005",
413 G4DataVector::const_iterator * iData(
new G4DataVector::const_iterator[n]);
423 while (iEnergies!=iEnergiesEnd)
428 out << ((*iEnergies)/GetUnitEnergies());
438 out << ((*(iData[k]))/GetUnitData());
455 G4String G4MicroElecCrossSectionDataSet::FullFileName(
const G4String& argFileName)
const
457 char* path = getenv(
"G4LEDATA");
460 G4Exception(
"G4MicroElecCrossSectionDataSet::FullFileName",
"em0006",
466 std::ostringstream fullFileName;
468 fullFileName << path <<
"/" << argFileName <<
".dat";
470 return G4String(fullFileName.str().c_str());
479 std::vector<G4VEMDataSet *>::const_iterator i(components.begin());
480 std::vector<G4VEMDataSet *>::const_iterator end(components.end());
484 value+=(*i)->FindValue(argEnergy);
496 G4cout <<
"The data set has " << n <<
" components" <<
G4endl;
512 G4int argComponentId)
522 std::ostringstream message;
523 message <<
"Component " << argComponentId <<
" not found";
525 G4Exception(
"G4MicroElecCrossSectionDataSet::SetEnergiesData",
"em0005",
535 G4int argComponentId)
545 std::ostringstream message;
546 message <<
"Component " << argComponentId <<
" not found";
548 G4Exception(
"G4MicroElecCrossSectionDataSet::SetLogEnergiesData",
"em0005",
554 void G4MicroElecCrossSectionDataSet::CleanUpComponents()
556 while (!components.empty())
558 if (components.back())
delete components.back();
559 components.pop_back();
virtual const G4VEMDataSet * GetComponent(G4int componentId) const
virtual void SetEnergiesData(G4DataVector *x, G4DataVector *data, G4int component=0)=0
virtual void SetEnergiesData(G4DataVector *x, G4DataVector *values, G4int componentId)
virtual G4bool LoadNonLogData(const G4String &argFileName)
virtual G4bool SaveData(const G4String &argFileName) const
virtual const G4DataVector & GetData(G4int componentId) const =0
G4MicroElecCrossSectionDataSet(G4VDataSetAlgorithm *algo, G4double xUnit=CLHEP::MeV, G4double dataUnit=CLHEP::barn)
virtual void SetLogEnergiesData(G4DataVector *x, G4DataVector *values, G4DataVector *log_x, G4DataVector *log_values, G4int componentId)
virtual void AddComponent(G4VEMDataSet *dataSet)
G4GLOB_DLL std::ostream G4cout
virtual size_t NumberOfComponents(void) const
virtual void SetLogEnergiesData(G4DataVector *x, G4DataVector *data, G4DataVector *Log_x, G4DataVector *Log_data, G4int component=0)=0
virtual G4double FindValue(G4double e, G4int componentId=0) const
virtual G4bool LoadData(const G4String &argFileName)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
virtual ~G4MicroElecCrossSectionDataSet()
virtual void PrintData(void) const =0
virtual const G4DataVector & GetEnergies(G4int componentId) const
const XML_Char int const XML_Char * value
virtual void PrintData(void) const