20#include "BDSException.hh"
21#include "BDSScorerConversionLoader.hh"
23#include "G4DataVector.hh"
24#include "G4PhysicsFreeVector.hh"
25#include "G4PhysicsVector.hh"
38#include "src-external/gzstream/gzstream.h"
57 bool validFile = file.rdbuf()->is_open();
59 bool validFile = file.is_open();
62 {
throw BDSException(__METHOD_NAME__,
"Invalid file name or no such file named \"" + fileName +
"\"");}
64 {G4cout <<
"Scorer conversion factors - loading \"" << fileName <<
"\"" << G4endl;}
70 G4DataVector conversionFactor;
72 while (std::getline(file, line))
76 std::regex comment(
"^\\#.*");
79 if (std::all_of(line.begin(), line.end(), isspace))
81 else if (std::regex_search(line, comment))
84 std::stringstream liness(line);
85 std::vector<G4double> numbers;
87 while (liness >> number)
88 {numbers.push_back(number);}
90 if (numbers.size() != 2)
93 throw BDSException(__METHOD_NAME__,
"Incomplete line " + std::to_string(lineNumber));
96 energy.emplace_back(numbers[0]);
97 conversionFactor.emplace_back(numbers[1]);
104 G4PhysicsFreeVector* results =
new G4PhysicsFreeVector(energy, conversionFactor);
General exception with possible name of object and message.
Loader for scoring conversion tables as function of energy.
G4PhysicsVector * Load(const G4String &fileName, G4bool silent=false)
Load the file.