44 algorithm(argAlgorithm), unitEnergies(argUnitEnergies), unitData(argUnitData)
63 G4String fullFileName(FullFileName(argFileName));
64 std::ifstream in(fullFileName, std::ifstream::binary|std::ifstream::in);
69 message+=fullFileName;
70 message+=
"\" not found";
71 G4Exception(
"G4MicroElecCrossSectionDataSet::LoadData",
"em0003",
76 std::vector<G4DataVector *> columns;
77 std::vector<G4DataVector *> log_columns;
79 std::stringstream *stream(
new std::stringstream);
100 while (!stream->eof())
104 while (i>=columns.size())
110 columns[i]->push_back(value);
124 if (value <=0.) value = 1e-300;
125 log_columns[i]->push_back(std::log10(value));
131 stream=
new std::stringstream;
149 if (comment) {
break; }
150 if (space && (!first)) { (*stream) <<
' '; }
158 catch(
const std::ios::failure &e)
166 std::vector<G4DataVector *>::size_type maxI(columns.size());
171 message+=fullFileName;
172 message+=
"\" should have at least two columns";
173 G4Exception(
"G4MicroElecCrossSectionDataSet::LoadData",
"em0005",
178 std::vector<G4DataVector*>::size_type i(1);
181 G4DataVector::size_type maxJ(columns[i]->size());
183 if (maxJ!=columns[0]->size())
186 message+=fullFileName;
187 message+=
"\" has lines with a different number of columns";
188 G4Exception(
"G4MicroElecCrossSectionDataSet::LoadData",
"em0005",
193 G4DataVector::size_type j(0);
202 argEnergies->push_back(columns[0]->
operator[] (j)*GetUnitEnergies());
203 argData->push_back(columns[i]->
operator[] (j)*GetUnitData());
204 argLogEnergies->push_back(log_columns[0]->
operator[] (j) + std::log10(GetUnitEnergies()));
205 argLogData->push_back(log_columns[i]->
operator[] (j) + std::log10(GetUnitData()));
209 AddComponent(
new G4EMDataSet(i-1, argEnergies, argData, argLogEnergies, argLogData, GetAlgorithm()->Clone(), GetUnitEnergies(), GetUnitData()));
219 delete log_columns[i];
230 G4String fullFileName(FullFileName(argFileName));
231 std::ifstream in(fullFileName, std::ifstream::binary|std::ifstream::in);
236 message+=fullFileName;
237 message+=
"\" not found";
238 G4Exception(
"G4MicroElecCrossSectionDataSet::LoadData",
"em0003",
243 std::vector<G4DataVector *> columns;
245 std::stringstream *stream(
new std::stringstream);
266 while (!stream->eof())
270 while (i>=columns.size())
275 columns[i]->push_back(value);
281 stream=
new std::stringstream;
299 if (comment) {
break; }
300 if (space && (!first)) { (*stream) <<
' '; }
308 catch(
const std::ios::failure &e)
316 std::vector<G4DataVector *>::size_type maxI(columns.size());
321 message+=fullFileName;
322 message+=
"\" should have at least two columns";
323 G4Exception(
"G4MicroElecCrossSectionDataSet::LoadData",
"em0005",
328 std::vector<G4DataVector*>::size_type i(1);
331 G4DataVector::size_type maxJ(columns[i]->size());
333 if (maxJ!=columns[0]->size())
336 message+=fullFileName;
337 message+=
"\" has lines with a different number of columns.";
338 G4Exception(
"G4MicroElecCrossSectionDataSet::LoadData",
"em0005",
343 G4DataVector::size_type j(0);
350 argEnergies->push_back(columns[0]->
operator[] (j)*GetUnitEnergies());
351 argData->push_back(columns[i]->
operator[] (j)*GetUnitData());
355 AddComponent(
new G4EMDataSet(i-1, argEnergies, argData, GetAlgorithm()->Clone(), GetUnitEnergies(), GetUnitData()));
377 G4Exception(
"G4MicroElecCrossSectionDataSet::SaveData",
"em0005",
383 G4String fullFileName(FullFileName(argFileName));
384 std::ofstream out(fullFileName);
389 message+=fullFileName;
391 G4Exception(
"G4MicroElecCrossSectionDataSet::SaveData",
"em0005",
398 G4DataVector::const_iterator * iData(
new G4DataVector::const_iterator[n]);
408 while (iEnergies!=iEnergiesEnd)
413 out << ((*iEnergies)/GetUnitEnergies());
423 out << ((*(iData[k]))/GetUnitData());
440 G4String G4MicroElecCrossSectionDataSet::FullFileName(
const G4String& argFileName)
const
442 char* path = getenv(
"G4LEDATA");
445 G4Exception(
"G4MicroElecCrossSectionDataSet::FullFileName",
"em0006",
451 std::ostringstream fullFileName;
453 fullFileName << path <<
"/" << argFileName <<
".dat";
455 return G4String(fullFileName.str().c_str());
464 std::vector<G4VEMDataSet *>::const_iterator i(components.begin());
465 std::vector<G4VEMDataSet *>::const_iterator end(components.end());
469 value+=(*i)->FindValue(argEnergy);
481 G4cout <<
"The data set has " << n <<
" components" <<
G4endl;
497 G4int argComponentId)
507 std::ostringstream message;
508 message <<
"Component " << argComponentId <<
" not found";
510 G4Exception(
"G4MicroElecCrossSectionDataSet::SetEnergiesData",
"em0005",
520 G4int argComponentId)
530 std::ostringstream message;
531 message <<
"Component " << argComponentId <<
" not found";
533 G4Exception(
"G4MicroElecCrossSectionDataSet::SetLogEnergiesData",
"em0005",
539 void G4MicroElecCrossSectionDataSet::CleanUpComponents()
541 while (!components.empty())
543 if (components.back())
delete components.back();
544 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
const XML_Char int const XML_Char * value
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
virtual void PrintData(void) const