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;
140 unsigned int binInZ = int(apvBaseline.index()) / (nPUBins *
baseline_nBins_);
141 unsigned int binInPU = int(apvBaseline.index() - binInZ * (nPUBins)*baseline_nBins_) /
baseline_nBins_;
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);
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
T getUntrackedParameter(std::string const &, T const &) const
SiStripApvSimulationParameters::LayerParameters makeLayerParameters(const std::string &apvBaselinesFileName, const std::vector< float > &rzBinEdges) const
std::vector< edm::FileInPath > baselineFiles_TID_
static const IOVSyncValue & endOfTime()
~SiStripApvSimulationParametersESSource() override
SiStripApvSimulationParametersESSource(const edm::ParameterSet &conf)
std::vector< float > rBinEdgesTID_
std::unique_ptr< SiStripApvSimulationParameters > produce(const SiStripApvSimulationParametersRcd &record)
std::vector< edm::FileInPath > baselineFiles_TEC_
static const IOVSyncValue & beginOfTime()
std::vector< float > puBinEdges_
std::vector< edm::FileInPath > baselineFiles_TOB_
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
std::vector< edm::FileInPath > baselineFiles_TIB_
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &iov, edm::ValidityInterval &iValidity) override
unsigned int baseline_nBins_
std::vector< float > rBinEdgesTEC_
std::vector< float > zBinEdges_