45{
46 std::ostringstream ss;
47 ss << dirpath << "/" << filename;
48 std::ifstream infile(ss.str(), std::ios::in);
49
50 if (nxsections < 1 || length <= 0 || nxsections > nmax) {
52 ed << " Wrong data size: nsections=" << nxsections << " length="
53 << length << " nmax=" << nmax;
54 G4Exception(
"G4MatUtils::BuildExtendedVector(..)",
"mat004",
56 return nullptr;
57 }
58
59
60 if (!infile.is_open()) {
62 ed << " Fail to open file: <" << ss.str() << ">";
63 G4Exception(
"G4MatUtils::BuildExtendedVector(..)",
"mat004",
65 return nullptr;
66 }
67
68 auto vtot = new G4PhysicsFreeVector(false);
69 G4ExtendedPhysicsVector* v = new G4ExtendedPhysicsVector(vtot, nxsections);
71
74 auto nn = (std::size_t)length;
75
76 for (std::size_t i=0; i<
nn; ++i) {
77 sum = 0.0;
78 infile >> e;
79 e *= unitE;
80 for (
G4int j=0; j<nxsections; ++j) {
81 infile >> yy;
82 yy *= unitS;
83 sum += yy;
84 y[j] = yy;
85 }
86 vtot->PutValues(i, e, sum);
88 }
89 return v;
90}
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
void SetDataLength(G4int dlength)
void PutPartialXSData(const std::size_t idx, const G4double *y)