35 const std::string
prefix{
"PixelDigitization/Bichsel_"};
37 const std::string
suffix{
".dat"};
41 const std::string nColString= (nCols == 1) ?
"" :
"_" +
std::to_string(nCols) +
"steps";
43 return prefix + particleTypeString + nColString +
suffix;
57 std::string errmsg =
"getBichselDataFromFile: File " + fullFilename +
" could not be opened.";
59 throw std::runtime_error(errmsg);
71 const auto & [logBetaGamma, logCollisionEnergy, logCrossSection] =
parseThreeDoubles(thisLine);
73 iData.
addEntry(logBetaGamma, logCollisionEnergy, logCrossSection);
85 std::tuple<double, double, double>
89 std::tuple<double, double, double>
result{0., 0.,0.};
93 static const std::regex threeDoublesRx(
"^([-+.0-9eE]+)\\s+([-+.0-9eE]+)\\s+([-+.0-9eE]+)$");
97 bool foundDoubles=std::regex_match(
line, x3, threeDoublesRx);
107 result = {std::stod(x3[1]), std::stod(x3[2]), std::stod(x3[3])};
109 }
catch (std::logic_error &
e){
111 const std::string
msg(
"parseThreeDoubles: error in parsing a number in "+
line);
113 throw(std::runtime_error(
msg));
119 const std::string
msg(
"parseThreeDoubles: error in parsing the line " +
line);
121 throw(std::runtime_error(
msg));
135 std::pair<int, int>
output{-1, -1};
141 int index_up =
vec.size() - 1;
149 }
else if (
item ==
vec[index_low]) {
153 output.second = index_low;
157 }
else if (
item ==
vec[index_up]) {
169 while ((index_up - index_low) != 1) {
171 int index_middle =
int(1.0 * (index_up + index_low) / 2.);
173 if (
item <
vec[index_middle]) index_up = index_middle;
175 else if (
item >
vec[index_middle]) index_low = index_middle;
179 output.first = index_middle;
181 output.second = index_middle;