7 #include "CLHEP/Random/RandGaussZiggurat.h"
19 const std::string
prefix{
"PixelDigitization/Bichsel_"};
20 const std::string
suffix{
".dat"};
23 return prefix + particleTypeString + nColString +
suffix;
31 std::string errmsg =
"getBichselDataFromFile: File " + fullFilename +
" could not be opened.";
32 throw std::runtime_error(errmsg);
38 const auto & [logBetaGamma, logCollisionEnergy, logCrossSection] =
parseThreeDoubles(thisLine);
39 iData.
addEntry(logBetaGamma, logCollisionEnergy, logCrossSection);
46 std::tuple<double, double, double>
48 std::tuple<double, double, double>
result{0., 0.,0.};
52 static const std::regex threeDoublesRx(
"^([-+.0-9eE]+)\\s+([-+.0-9eE]+)\\s+([-+.0-9eE]+)$");
54 bool foundDoubles=std::regex_match(
line, x3, threeDoublesRx);
59 result = {std::stod(x3[1]), std::stod(x3[2]), std::stod(x3[3])};
60 }
catch (std::logic_error &
e){
61 const std::string
msg(
"parseThreeDoubles: error in parsing a number in "+
line);
62 throw(std::runtime_error(
msg));
65 const std::string
msg(
"parseThreeDoubles: error in parsing the line " +
line);
66 throw(std::runtime_error(
msg));
74 std::pair<int, int>
output{-1, -1};
77 int index_up =
vec.size() - 1;
80 }
else if (
item ==
vec[index_low]) {
84 }
else if (
item ==
vec[index_up]) {
89 while ((index_up - index_low) != 1) {
90 int index_middle =
int(1.0 * (index_up + index_low) / 2.);
91 if (
item <
vec[index_middle]) index_up = index_middle;
92 else if (
item >
vec[index_middle]) index_low = index_middle;
94 output.first = index_middle;
95 output.second = index_middle;
106 const double & thrand1 = CLHEP::RandGaussZiggurat::shoot(pEngine);
107 const double & thrand2 = CLHEP::RandGaussZiggurat::shoot(pEngine);
108 return t.value +
t.sigma * thrand1 +
t.noise * thrand2;