8 #include <boost/range/adaptor/indexed.hpp>
35 const std::vector<float>& rzBinEdges)
const;
39 : baseline_nBins_(conf.getUntrackedParameter<unsigned
int>(
"apvBaselines_nBinsPerBaseline")),
40 baseline_min_(conf.getUntrackedParameter<double>(
"apvBaselines_minBaseline")),
41 baseline_max_(conf.getUntrackedParameter<double>(
"apvBaselines_maxBaseline")) {
43 findingRecord<SiStripApvSimulationParametersRcd>();
93 const std::string& apvBaselinesFileName,
const std::vector<float>& rzBinEdges)
const {
95 unsigned int nZBins = rzBinEdges.size();
99 throw cms::Exception(
"MissingInput") <<
"The parameters for the APV simulation are not correctly configured\n";
101 std::vector<float> baselineBinEdges{};
104 baselineBinEdges.push_back(
baseline_min_ +
i * baseline_binWidth);
111 std::vector<double> theAPVBaselines;
112 std::ifstream apvBaselineFile(apvBaselinesFileName.c_str());
113 if (!apvBaselineFile.good()) {
114 throw cms::Exception(
"FileError") <<
"Problem opening APV baselines file: " << apvBaselinesFileName;
117 while (std::getline(apvBaselineFile,
line)) {
119 std::istringstream lStr{
line};
121 while (lStr >>
value) {
122 theAPVBaselines.push_back(
value);
126 if (theAPVBaselines.empty()) {
128 <<
"Problem reading from APV baselines file " << apvBaselinesFileName <<
": no values read in";
132 throw cms::Exception(
"WrongAPVBaselines") <<
"Problem reading from APV baselines file " << apvBaselinesFileName
133 <<
": number of baselines read different to that expected i.e. nZBins * "
134 "nPUBins * apvBaselines_nBinsPerBaseline_";
138 for (
auto const& apvBaseline : theAPVBaselines | boost::adaptors::indexed(0)) {
139 unsigned int binInCurrentHistogram = apvBaseline.index() %
baseline_nBins_ + 1;
143 layerParams.setBinContent(binInCurrentHistogram, binInPU + 1, binInZ + 1, apvBaseline.value());
151 auto apvSimParams = std::make_unique<SiStripApvSimulationParameters>(
155 throw cms::Exception(
"SiStripApvSimulationParameters") <<
"Could not add parameters for TIB layer " << (
i + 1);
157 LogDebug(
"SiStripApvSimulationParameters") <<
"Added parameters for TIB layer " << (
i + 1);
162 throw cms::Exception(
"SiStripApvSimulationParameters") <<
"Could not add parameters for TOB layer " << (
i + 1);
164 LogDebug(
"SiStripApvSimulationParameters") <<
"Added parameters for TOB layer " << (
i + 1);
169 throw cms::Exception(
"SiStripApvSimulationParameters") <<
"Could not add parameters for TID wheel " << (
i + 1);
171 LogDebug(
"SiStripApvSimulationParameters") <<
"Added parameters for TID wheel " << (
i + 1);
176 throw cms::Exception(
"SiStripApvSimulationParameters") <<
"Could not add parameters for TEC wheel " << (
i + 1);
178 LogDebug(
"SiStripApvSimulationParameters") <<
"Added parameters for TEC wheel " << (
i + 1);