File indexing completed on 2024-04-06 11:58:22
0001
0002 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0003 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0004 #include "FWCore/ParameterSet/interface/FileInPath.h"
0005 #include "FWCore/Framework/interface/SourceFactory.h"
0006 #include "FWCore/Framework/interface/ModuleFactory.h"
0007 #include "FWCore/Framework/interface/ESProducer.h"
0008 #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
0009
0010 #include "CondFormats/DataRecord/interface/CSCL1TPLookupTableCCLUTRcd.h"
0011 #include "CondFormats/DataRecord/interface/CSCL1TPLookupTableME11ILTRcd.h"
0012 #include "CondFormats/DataRecord/interface/CSCL1TPLookupTableME21ILTRcd.h"
0013 #include "CondFormats/CSCObjects/interface/CSCL1TPLookupTableCCLUT.h"
0014 #include "CondFormats/CSCObjects/interface/CSCL1TPLookupTableME11ILT.h"
0015 #include "CondFormats/CSCObjects/interface/CSCL1TPLookupTableME21ILT.h"
0016
0017
0018 #include <fstream>
0019 #include <string>
0020 #include <vector>
0021 #include <unordered_map>
0022
0023 class CSCL1TPLookupTableEP : public edm::ESProducer, public edm::EventSetupRecordIntervalFinder {
0024 public:
0025 CSCL1TPLookupTableEP(const edm::ParameterSet&);
0026 ~CSCL1TPLookupTableEP() override {}
0027
0028 std::unique_ptr<CSCL1TPLookupTableCCLUT> produceCCLUT(const CSCL1TPLookupTableCCLUTRcd&);
0029 std::unique_ptr<CSCL1TPLookupTableME11ILT> produceME11ILT(const CSCL1TPLookupTableME11ILTRcd&);
0030 std::unique_ptr<CSCL1TPLookupTableME21ILT> produceME21ILT(const CSCL1TPLookupTableME21ILTRcd&);
0031
0032 protected:
0033 void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
0034 const edm::IOVSyncValue&,
0035 edm::ValidityInterval&) override;
0036
0037 private:
0038 std::vector<unsigned> load(std::string fileName) const;
0039 const edm::ParameterSet pset_;
0040 };
0041
0042 CSCL1TPLookupTableEP::CSCL1TPLookupTableEP(const edm::ParameterSet& pset) : pset_(pset) {
0043 setWhatProduced(this, &CSCL1TPLookupTableEP::produceCCLUT);
0044 setWhatProduced(this, &CSCL1TPLookupTableEP::produceME11ILT);
0045 setWhatProduced(this, &CSCL1TPLookupTableEP::produceME21ILT);
0046 findingRecord<CSCL1TPLookupTableCCLUTRcd>();
0047 findingRecord<CSCL1TPLookupTableME11ILTRcd>();
0048 findingRecord<CSCL1TPLookupTableME21ILTRcd>();
0049 }
0050
0051 void CSCL1TPLookupTableEP::setIntervalFor(const edm::eventsetup::EventSetupRecordKey& iKey,
0052 const edm::IOVSyncValue& iosv,
0053 edm::ValidityInterval& oValidity) {
0054 edm::ValidityInterval infinity(iosv.beginOfTime(), iosv.endOfTime());
0055 oValidity = infinity;
0056 }
0057
0058 std::unique_ptr<CSCL1TPLookupTableCCLUT> CSCL1TPLookupTableEP::produceCCLUT(const CSCL1TPLookupTableCCLUTRcd&) {
0059
0060 std::unique_ptr<CSCL1TPLookupTableCCLUT> lut = std::make_unique<CSCL1TPLookupTableCCLUT>();
0061
0062
0063 std::vector<std::string> positionLUTFiles_ = pset_.getParameter<std::vector<std::string>>("positionLUTFiles");
0064 std::vector<std::string> slopeLUTFiles_ = pset_.getParameter<std::vector<std::string>>("slopeLUTFiles");
0065
0066 std::unordered_map<unsigned, std::vector<unsigned>> cclutPosition;
0067 std::unordered_map<unsigned, std::vector<unsigned>> cclutSlope;
0068
0069
0070 for (int i = 0; i < 5; ++i) {
0071 cclutPosition[i] = load(positionLUTFiles_[i]);
0072 cclutSlope[i] = load(slopeLUTFiles_[i]);
0073 }
0074
0075
0076 lut->set_cclutPosition(std::move(cclutPosition));
0077 lut->set_cclutSlope(std::move(cclutSlope));
0078
0079 return lut;
0080 }
0081
0082 std::unique_ptr<CSCL1TPLookupTableME11ILT> CSCL1TPLookupTableEP::produceME11ILT(const CSCL1TPLookupTableME11ILTRcd&) {
0083
0084 std::unique_ptr<CSCL1TPLookupTableME11ILT> lut = std::make_unique<CSCL1TPLookupTableME11ILT>();
0085
0086
0087 std::vector<std::string> padToEsME11aFiles_ = pset_.getParameter<std::vector<std::string>>("padToEsME11aFiles");
0088 std::vector<std::string> padToEsME11bFiles_ = pset_.getParameter<std::vector<std::string>>("padToEsME11bFiles");
0089
0090 std::vector<std::string> rollToMaxWgME11Files_ = pset_.getParameter<std::vector<std::string>>("rollToMaxWgME11Files");
0091 std::vector<std::string> rollToMinWgME11Files_ = pset_.getParameter<std::vector<std::string>>("rollToMinWgME11Files");
0092
0093 std::vector<std::string> gemCscSlopeCosiFiles_ = pset_.getParameter<std::vector<std::string>>("gemCscSlopeCosiFiles");
0094 std::vector<std::string> gemCscSlopeCosiCorrectionFiles_ =
0095 pset_.getParameter<std::vector<std::string>>("gemCscSlopeCosiCorrectionFiles");
0096 std::vector<std::string> gemCscSlopeCorrectionFiles_ =
0097 pset_.getParameter<std::vector<std::string>>("gemCscSlopeCorrectionFiles");
0098
0099 std::vector<std::string> esDiffToSlopeME11aFiles_ =
0100 pset_.getParameter<std::vector<std::string>>("esDiffToSlopeME11aFiles");
0101 std::vector<std::string> esDiffToSlopeME11bFiles_ =
0102 pset_.getParameter<std::vector<std::string>>("esDiffToSlopeME11bFiles");
0103
0104
0105 auto GEM_pad_CSC_es_ME11a_even_ = load(padToEsME11aFiles_[0]);
0106 auto GEM_pad_CSC_es_ME11a_odd_ = load(padToEsME11aFiles_[1]);
0107 auto GEM_pad_CSC_es_ME11b_even_ = load(padToEsME11bFiles_[0]);
0108 auto GEM_pad_CSC_es_ME11b_odd_ = load(padToEsME11bFiles_[1]);
0109
0110 auto GEM_roll_CSC_min_wg_ME11_even_ = load(rollToMinWgME11Files_[0]);
0111 auto GEM_roll_CSC_min_wg_ME11_odd_ = load(rollToMinWgME11Files_[1]);
0112 auto GEM_roll_CSC_max_wg_ME11_even_ = load(rollToMaxWgME11Files_[0]);
0113 auto GEM_roll_CSC_max_wg_ME11_odd_ = load(rollToMaxWgME11Files_[1]);
0114
0115 auto CSC_slope_cosi_2to1_L1_ME11a_even_ = load(gemCscSlopeCosiFiles_[0]);
0116 auto CSC_slope_cosi_2to1_L1_ME11a_odd_ = load(gemCscSlopeCosiFiles_[1]);
0117 auto CSC_slope_cosi_3to1_L1_ME11a_even_ = load(gemCscSlopeCosiFiles_[2]);
0118 auto CSC_slope_cosi_3to1_L1_ME11a_odd_ = load(gemCscSlopeCosiFiles_[3]);
0119
0120 auto CSC_slope_cosi_2to1_L1_ME11b_even_ = load(gemCscSlopeCosiFiles_[4]);
0121 auto CSC_slope_cosi_2to1_L1_ME11b_odd_ = load(gemCscSlopeCosiFiles_[5]);
0122 auto CSC_slope_cosi_3to1_L1_ME11b_even_ = load(gemCscSlopeCosiFiles_[6]);
0123 auto CSC_slope_cosi_3to1_L1_ME11b_odd_ = load(gemCscSlopeCosiFiles_[7]);
0124
0125 auto CSC_slope_cosi_corr_L1_ME11a_even_ = load(gemCscSlopeCosiCorrectionFiles_[0]);
0126 auto CSC_slope_cosi_corr_L1_ME11b_even_ = load(gemCscSlopeCosiCorrectionFiles_[1]);
0127 auto CSC_slope_cosi_corr_L1_ME11a_odd_ = load(gemCscSlopeCosiCorrectionFiles_[3]);
0128 auto CSC_slope_cosi_corr_L1_ME11b_odd_ = load(gemCscSlopeCosiCorrectionFiles_[4]);
0129
0130 auto CSC_slope_corr_L1_ME11a_even_ = load(gemCscSlopeCorrectionFiles_[0]);
0131 auto CSC_slope_corr_L1_ME11b_even_ = load(gemCscSlopeCorrectionFiles_[1]);
0132 auto CSC_slope_corr_L1_ME11a_odd_ = load(gemCscSlopeCorrectionFiles_[3]);
0133 auto CSC_slope_corr_L1_ME11b_odd_ = load(gemCscSlopeCorrectionFiles_[4]);
0134 auto CSC_slope_corr_L2_ME11a_even_ = load(gemCscSlopeCorrectionFiles_[6]);
0135 auto CSC_slope_corr_L2_ME11b_even_ = load(gemCscSlopeCorrectionFiles_[7]);
0136 auto CSC_slope_corr_L2_ME11a_odd_ = load(gemCscSlopeCorrectionFiles_[9]);
0137 auto CSC_slope_corr_L2_ME11b_odd_ = load(gemCscSlopeCorrectionFiles_[10]);
0138
0139 auto es_diff_slope_L1_ME11a_even_ = load(esDiffToSlopeME11aFiles_[0]);
0140 auto es_diff_slope_L1_ME11a_odd_ = load(esDiffToSlopeME11aFiles_[1]);
0141 auto es_diff_slope_L2_ME11a_even_ = load(esDiffToSlopeME11aFiles_[2]);
0142 auto es_diff_slope_L2_ME11a_odd_ = load(esDiffToSlopeME11aFiles_[3]);
0143
0144 auto es_diff_slope_L1_ME11b_even_ = load(esDiffToSlopeME11bFiles_[0]);
0145 auto es_diff_slope_L1_ME11b_odd_ = load(esDiffToSlopeME11bFiles_[1]);
0146 auto es_diff_slope_L2_ME11b_even_ = load(esDiffToSlopeME11bFiles_[2]);
0147 auto es_diff_slope_L2_ME11b_odd_ = load(esDiffToSlopeME11bFiles_[3]);
0148
0149
0150 lut->set_GEM_pad_CSC_es_ME11b_even(std::move(GEM_pad_CSC_es_ME11b_even_));
0151 lut->set_GEM_pad_CSC_es_ME11a_even(std::move(GEM_pad_CSC_es_ME11a_even_));
0152 lut->set_GEM_pad_CSC_es_ME11b_odd(std::move(GEM_pad_CSC_es_ME11b_odd_));
0153 lut->set_GEM_pad_CSC_es_ME11a_odd(std::move(GEM_pad_CSC_es_ME11a_odd_));
0154
0155 lut->set_GEM_roll_CSC_min_wg_ME11_even(std::move(GEM_roll_CSC_min_wg_ME11_even_));
0156 lut->set_GEM_roll_CSC_min_wg_ME11_odd(std::move(GEM_roll_CSC_min_wg_ME11_odd_));
0157 lut->set_GEM_roll_CSC_max_wg_ME11_even(std::move(GEM_roll_CSC_max_wg_ME11_even_));
0158 lut->set_GEM_roll_CSC_max_wg_ME11_odd(std::move(GEM_roll_CSC_max_wg_ME11_odd_));
0159
0160
0161 lut->set_CSC_slope_cosi_2to1_L1_ME11a_even(std::move(CSC_slope_cosi_2to1_L1_ME11a_even_));
0162 lut->set_CSC_slope_cosi_2to1_L1_ME11a_odd(std::move(CSC_slope_cosi_2to1_L1_ME11a_odd_));
0163 lut->set_CSC_slope_cosi_3to1_L1_ME11a_even(std::move(CSC_slope_cosi_3to1_L1_ME11a_even_));
0164 lut->set_CSC_slope_cosi_3to1_L1_ME11a_odd(std::move(CSC_slope_cosi_3to1_L1_ME11a_odd_));
0165
0166 lut->set_CSC_slope_cosi_2to1_L1_ME11b_even(std::move(CSC_slope_cosi_2to1_L1_ME11b_even_));
0167 lut->set_CSC_slope_cosi_2to1_L1_ME11b_odd(std::move(CSC_slope_cosi_2to1_L1_ME11b_odd_));
0168 lut->set_CSC_slope_cosi_3to1_L1_ME11b_even(std::move(CSC_slope_cosi_3to1_L1_ME11b_even_));
0169 lut->set_CSC_slope_cosi_3to1_L1_ME11b_odd(std::move(CSC_slope_cosi_3to1_L1_ME11b_odd_));
0170
0171 lut->set_CSC_slope_corr_L1_ME11a_even(std::move(CSC_slope_corr_L1_ME11a_even_));
0172 lut->set_CSC_slope_corr_L1_ME11a_odd(std::move(CSC_slope_corr_L1_ME11a_odd_));
0173 lut->set_CSC_slope_corr_L1_ME11b_even(std::move(CSC_slope_corr_L1_ME11b_even_));
0174 lut->set_CSC_slope_corr_L1_ME11b_odd(std::move(CSC_slope_corr_L1_ME11b_odd_));
0175 lut->set_CSC_slope_corr_L2_ME11a_even(std::move(CSC_slope_corr_L2_ME11a_even_));
0176 lut->set_CSC_slope_corr_L2_ME11a_odd(std::move(CSC_slope_corr_L2_ME11a_odd_));
0177 lut->set_CSC_slope_corr_L2_ME11b_even(std::move(CSC_slope_corr_L2_ME11b_even_));
0178 lut->set_CSC_slope_corr_L2_ME11b_odd(std::move(CSC_slope_corr_L2_ME11b_odd_));
0179
0180
0181 lut->set_es_diff_slope_L1_ME11a_even(std::move(es_diff_slope_L1_ME11a_even_));
0182 lut->set_es_diff_slope_L1_ME11a_odd(std::move(es_diff_slope_L1_ME11a_odd_));
0183 lut->set_es_diff_slope_L2_ME11a_even(std::move(es_diff_slope_L2_ME11a_even_));
0184 lut->set_es_diff_slope_L2_ME11a_odd(std::move(es_diff_slope_L2_ME11a_odd_));
0185
0186 lut->set_es_diff_slope_L1_ME11b_even(std::move(es_diff_slope_L1_ME11b_even_));
0187 lut->set_es_diff_slope_L1_ME11b_odd(std::move(es_diff_slope_L1_ME11b_odd_));
0188 lut->set_es_diff_slope_L2_ME11b_even(std::move(es_diff_slope_L2_ME11b_even_));
0189 lut->set_es_diff_slope_L2_ME11b_odd(std::move(es_diff_slope_L2_ME11b_odd_));
0190
0191 return lut;
0192 }
0193
0194 std::unique_ptr<CSCL1TPLookupTableME21ILT> CSCL1TPLookupTableEP::produceME21ILT(const CSCL1TPLookupTableME21ILTRcd&) {
0195
0196 std::unique_ptr<CSCL1TPLookupTableME21ILT> lut = std::make_unique<CSCL1TPLookupTableME21ILT>();
0197
0198
0199 std::vector<std::string> padToEsME21Files_ = pset_.getParameter<std::vector<std::string>>("padToEsME21Files");
0200
0201 std::vector<std::string> rollToMaxWgME21Files_ = pset_.getParameter<std::vector<std::string>>("rollToMaxWgME21Files");
0202 std::vector<std::string> rollToMinWgME21Files_ = pset_.getParameter<std::vector<std::string>>("rollToMinWgME21Files");
0203
0204 std::vector<std::string> gemCscSlopeCosiFiles_ = pset_.getParameter<std::vector<std::string>>("gemCscSlopeCosiFiles");
0205 std::vector<std::string> gemCscSlopeCosiCorrectionFiles_ =
0206 pset_.getParameter<std::vector<std::string>>("gemCscSlopeCosiCorrectionFiles");
0207 std::vector<std::string> gemCscSlopeCorrectionFiles_ =
0208 pset_.getParameter<std::vector<std::string>>("gemCscSlopeCorrectionFiles");
0209
0210 std::vector<std::string> esDiffToSlopeME21Files_ =
0211 pset_.getParameter<std::vector<std::string>>("esDiffToSlopeME21Files");
0212
0213
0214 auto GEM_pad_CSC_es_ME21_even_ = load(padToEsME21Files_[0]);
0215 auto GEM_pad_CSC_es_ME21_odd_ = load(padToEsME21Files_[1]);
0216
0217 auto GEM_roll_L1_CSC_min_wg_ME21_even_ = load(rollToMinWgME21Files_[0]);
0218 auto GEM_roll_L1_CSC_min_wg_ME21_odd_ = load(rollToMinWgME21Files_[1]);
0219 auto GEM_roll_L2_CSC_min_wg_ME21_even_ = load(rollToMinWgME21Files_[2]);
0220 auto GEM_roll_L2_CSC_min_wg_ME21_odd_ = load(rollToMinWgME21Files_[3]);
0221
0222 auto GEM_roll_L1_CSC_max_wg_ME21_even_ = load(rollToMaxWgME21Files_[0]);
0223 auto GEM_roll_L1_CSC_max_wg_ME21_odd_ = load(rollToMaxWgME21Files_[1]);
0224 auto GEM_roll_L2_CSC_max_wg_ME21_even_ = load(rollToMaxWgME21Files_[2]);
0225 auto GEM_roll_L2_CSC_max_wg_ME21_odd_ = load(rollToMaxWgME21Files_[3]);
0226
0227 auto es_diff_slope_L1_ME21_even_ = load(esDiffToSlopeME21Files_[0]);
0228 auto es_diff_slope_L1_ME21_odd_ = load(esDiffToSlopeME21Files_[1]);
0229 auto es_diff_slope_L2_ME21_even_ = load(esDiffToSlopeME21Files_[2]);
0230 auto es_diff_slope_L2_ME21_odd_ = load(esDiffToSlopeME21Files_[3]);
0231
0232 auto CSC_slope_cosi_2to1_L1_ME21_even_ = load(gemCscSlopeCosiFiles_[8]);
0233 auto CSC_slope_cosi_2to1_L1_ME21_odd_ = load(gemCscSlopeCosiFiles_[9]);
0234 auto CSC_slope_cosi_3to1_L1_ME21_even_ = load(gemCscSlopeCosiFiles_[10]);
0235 auto CSC_slope_cosi_3to1_L1_ME21_odd_ = load(gemCscSlopeCosiFiles_[11]);
0236
0237 auto CSC_slope_cosi_corr_L1_ME21_even_ = load(gemCscSlopeCosiCorrectionFiles_[2]);
0238 auto CSC_slope_cosi_corr_L1_ME21_odd_ = load(gemCscSlopeCosiCorrectionFiles_[5]);
0239
0240 auto CSC_slope_corr_L1_ME21_even_ = load(gemCscSlopeCorrectionFiles_[2]);
0241 auto CSC_slope_corr_L1_ME21_odd_ = load(gemCscSlopeCorrectionFiles_[5]);
0242 auto CSC_slope_corr_L2_ME21_even_ = load(gemCscSlopeCorrectionFiles_[8]);
0243 auto CSC_slope_corr_L2_ME21_odd_ = load(gemCscSlopeCorrectionFiles_[11]);
0244
0245
0246 lut->set_GEM_pad_CSC_es_ME21_even(std::move(GEM_pad_CSC_es_ME21_even_));
0247 lut->set_GEM_pad_CSC_es_ME21_odd(std::move(GEM_pad_CSC_es_ME21_odd_));
0248
0249 lut->set_GEM_roll_L1_CSC_min_wg_ME21_even(std::move(GEM_roll_L1_CSC_min_wg_ME21_even_));
0250 lut->set_GEM_roll_L1_CSC_max_wg_ME21_even(std::move(GEM_roll_L1_CSC_max_wg_ME21_even_));
0251 lut->set_GEM_roll_L1_CSC_min_wg_ME21_odd(std::move(GEM_roll_L1_CSC_min_wg_ME21_odd_));
0252 lut->set_GEM_roll_L1_CSC_max_wg_ME21_odd(std::move(GEM_roll_L1_CSC_max_wg_ME21_odd_));
0253
0254 lut->set_GEM_roll_L2_CSC_min_wg_ME21_even(std::move(GEM_roll_L2_CSC_min_wg_ME21_even_));
0255 lut->set_GEM_roll_L2_CSC_max_wg_ME21_even(std::move(GEM_roll_L2_CSC_max_wg_ME21_even_));
0256 lut->set_GEM_roll_L2_CSC_min_wg_ME21_odd(std::move(GEM_roll_L2_CSC_min_wg_ME21_odd_));
0257 lut->set_GEM_roll_L2_CSC_max_wg_ME21_odd(std::move(GEM_roll_L2_CSC_max_wg_ME21_odd_));
0258
0259 lut->set_es_diff_slope_L1_ME21_even(std::move(es_diff_slope_L1_ME21_even_));
0260 lut->set_es_diff_slope_L1_ME21_odd(std::move(es_diff_slope_L1_ME21_odd_));
0261 lut->set_es_diff_slope_L2_ME21_even(std::move(es_diff_slope_L2_ME21_even_));
0262 lut->set_es_diff_slope_L2_ME21_odd(std::move(es_diff_slope_L2_ME21_odd_));
0263
0264 lut->set_CSC_slope_cosi_2to1_L1_ME21_even(std::move(CSC_slope_cosi_2to1_L1_ME21_even_));
0265 lut->set_CSC_slope_cosi_2to1_L1_ME21_odd(std::move(CSC_slope_cosi_2to1_L1_ME21_odd_));
0266 lut->set_CSC_slope_cosi_3to1_L1_ME21_even(std::move(CSC_slope_cosi_3to1_L1_ME21_even_));
0267 lut->set_CSC_slope_cosi_3to1_L1_ME21_odd(std::move(CSC_slope_cosi_3to1_L1_ME21_odd_));
0268
0269 lut->set_CSC_slope_corr_L1_ME21_even(std::move(CSC_slope_corr_L1_ME21_even_));
0270 lut->set_CSC_slope_corr_L1_ME21_odd(std::move(CSC_slope_corr_L1_ME21_odd_));
0271 lut->set_CSC_slope_corr_L2_ME21_even(std::move(CSC_slope_corr_L2_ME21_even_));
0272 lut->set_CSC_slope_corr_L2_ME21_odd(std::move(CSC_slope_corr_L2_ME21_odd_));
0273
0274 return lut;
0275 }
0276
0277 std::vector<unsigned> CSCL1TPLookupTableEP::load(std::string fileName) const {
0278 std::vector<unsigned> returnV;
0279 std::ifstream fstream;
0280 fstream.open(edm::FileInPath(fileName.c_str()).fullPath());
0281
0282 if (!fstream.good()) {
0283 fstream.close();
0284 return returnV;
0285 }
0286
0287 std::string line;
0288
0289 while (std::getline(fstream, line)) {
0290
0291 line.erase(std::find(line.begin(), line.end(), '#'), line.end());
0292 std::istringstream lineStream(line);
0293 std::pair<unsigned, unsigned> entry;
0294 while (lineStream >> entry.first >> entry.second) {
0295 returnV.push_back(entry.second);
0296 }
0297 }
0298 return returnV;
0299 }
0300
0301 DEFINE_FWK_EVENTSETUP_SOURCE(CSCL1TPLookupTableEP);