CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CSCL1TPLookupTableEP.cc
Go to the documentation of this file.
1 // system include files
9 
16 
17 // user include files
18 #include <fstream>
19 #include <string>
20 #include <vector>
21 #include <unordered_map>
22 
24 public:
26  ~CSCL1TPLookupTableEP() override {}
27 
28  std::unique_ptr<CSCL1TPLookupTableCCLUT> produceCCLUT(const CSCL1TPLookupTableCCLUTRcd&);
29  std::unique_ptr<CSCL1TPLookupTableME11ILT> produceME11ILT(const CSCL1TPLookupTableME11ILTRcd&);
30  std::unique_ptr<CSCL1TPLookupTableME21ILT> produceME21ILT(const CSCL1TPLookupTableME21ILTRcd&);
31 
32 protected:
34  const edm::IOVSyncValue&,
35  edm::ValidityInterval&) override;
36 
37 private:
38  std::vector<unsigned> load(std::string fileName) const;
40 };
41 
46  findingRecord<CSCL1TPLookupTableCCLUTRcd>();
47  findingRecord<CSCL1TPLookupTableME11ILTRcd>();
48  findingRecord<CSCL1TPLookupTableME21ILTRcd>();
49 }
50 
52  const edm::IOVSyncValue& iosv,
53  edm::ValidityInterval& oValidity) {
55  oValidity = infinity;
56 }
57 
58 std::unique_ptr<CSCL1TPLookupTableCCLUT> CSCL1TPLookupTableEP::produceCCLUT(const CSCL1TPLookupTableCCLUTRcd&) {
59  // make the LUT object
60  std::unique_ptr<CSCL1TPLookupTableCCLUT> lut = std::make_unique<CSCL1TPLookupTableCCLUT>();
61 
62  // get the text files
63  std::vector<std::string> positionLUTFiles_ = pset_.getParameter<std::vector<std::string>>("positionLUTFiles");
64  std::vector<std::string> slopeLUTFiles_ = pset_.getParameter<std::vector<std::string>>("slopeLUTFiles");
65 
66  std::unordered_map<unsigned, std::vector<unsigned>> cclutPosition;
67  std::unordered_map<unsigned, std::vector<unsigned>> cclutSlope;
68 
69  // read the text files and extract the data
70  for (int i = 0; i < 5; ++i) {
71  cclutPosition[i] = load(positionLUTFiles_[i]);
72  cclutSlope[i] = load(slopeLUTFiles_[i]);
73  }
74 
75  // set the data in the LUT object
76  lut->set_cclutPosition(std::move(cclutPosition));
77  lut->set_cclutSlope(std::move(cclutSlope));
78 
79  return lut;
80 }
81 
82 std::unique_ptr<CSCL1TPLookupTableME11ILT> CSCL1TPLookupTableEP::produceME11ILT(const CSCL1TPLookupTableME11ILTRcd&) {
83  // make the LUT object
84  std::unique_ptr<CSCL1TPLookupTableME11ILT> lut = std::make_unique<CSCL1TPLookupTableME11ILT>();
85 
86  // get the text files
87  std::vector<std::string> padToHsME1aFiles_ = pset_.getParameter<std::vector<std::string>>("padToHsME1aFiles");
88  std::vector<std::string> padToHsME1bFiles_ = pset_.getParameter<std::vector<std::string>>("padToHsME1bFiles");
89 
90  std::vector<std::string> padToEsME1aFiles_ = pset_.getParameter<std::vector<std::string>>("padToEsME1aFiles");
91  std::vector<std::string> padToEsME1bFiles_ = pset_.getParameter<std::vector<std::string>>("padToEsME1bFiles");
92 
93  std::vector<std::string> rollToMaxWgME11Files_ = pset_.getParameter<std::vector<std::string>>("rollToMaxWgME11Files");
94  std::vector<std::string> rollToMinWgME11Files_ = pset_.getParameter<std::vector<std::string>>("rollToMinWgME11Files");
95 
96  std::vector<std::string> gemCscSlopeCosiFiles_ = pset_.getParameter<std::vector<std::string>>("gemCscSlopeCosiFiles");
97  std::vector<std::string> gemCscSlopeCosiCorrectionFiles_ =
98  pset_.getParameter<std::vector<std::string>>("gemCscSlopeCosiCorrectionFiles");
99  std::vector<std::string> gemCscSlopeCorrectionFiles_ =
100  pset_.getParameter<std::vector<std::string>>("gemCscSlopeCorrectionFiles");
101 
102  std::vector<std::string> esDiffToSlopeME1aFiles_ =
103  pset_.getParameter<std::vector<std::string>>("esDiffToSlopeME1aFiles");
104  std::vector<std::string> esDiffToSlopeME1bFiles_ =
105  pset_.getParameter<std::vector<std::string>>("esDiffToSlopeME1bFiles");
106 
107  // read the text files and extract the data
108  auto GEM_pad_CSC_hs_ME1a_even_ = load(padToHsME1aFiles_[0]);
109  auto GEM_pad_CSC_hs_ME1a_odd_ = load(padToHsME1aFiles_[1]);
110  auto GEM_pad_CSC_hs_ME1b_even_ = load(padToHsME1bFiles_[0]);
111  auto GEM_pad_CSC_hs_ME1b_odd_ = load(padToHsME1bFiles_[1]);
112 
113  auto GEM_pad_CSC_es_ME1a_even_ = load(padToEsME1aFiles_[0]);
114  auto GEM_pad_CSC_es_ME1a_odd_ = load(padToEsME1aFiles_[1]);
115  auto GEM_pad_CSC_es_ME1b_even_ = load(padToEsME1bFiles_[0]);
116  auto GEM_pad_CSC_es_ME1b_odd_ = load(padToEsME1bFiles_[1]);
117 
118  auto GEM_roll_L1_CSC_min_wg_ME11_even_ = load(rollToMinWgME11Files_[0]);
119  auto GEM_roll_L1_CSC_min_wg_ME11_odd_ = load(rollToMinWgME11Files_[1]);
120  auto GEM_roll_L2_CSC_min_wg_ME11_even_ = load(rollToMinWgME11Files_[2]);
121  auto GEM_roll_L2_CSC_min_wg_ME11_odd_ = load(rollToMinWgME11Files_[3]);
122 
123  auto GEM_roll_L1_CSC_max_wg_ME11_even_ = load(rollToMaxWgME11Files_[0]);
124  auto GEM_roll_L1_CSC_max_wg_ME11_odd_ = load(rollToMaxWgME11Files_[1]);
125  auto GEM_roll_L2_CSC_max_wg_ME11_even_ = load(rollToMaxWgME11Files_[2]);
126  auto GEM_roll_L2_CSC_max_wg_ME11_odd_ = load(rollToMaxWgME11Files_[3]);
127 
128  auto CSC_slope_cosi_2to1_L1_ME11_even_ = load(gemCscSlopeCosiFiles_[0]);
129  auto CSC_slope_cosi_2to1_L1_ME11_odd_ = load(gemCscSlopeCosiFiles_[1]);
130  auto CSC_slope_cosi_3to1_L1_ME11_even_ = load(gemCscSlopeCosiFiles_[2]);
131  auto CSC_slope_cosi_3to1_L1_ME11_odd_ = load(gemCscSlopeCosiFiles_[3]);
132 
133  auto CSC_slope_cosi_corr_L1_ME11_even_ = load(gemCscSlopeCosiCorrectionFiles_[0]);
134  auto CSC_slope_cosi_corr_L2_ME11_even_ = load(gemCscSlopeCosiCorrectionFiles_[1]);
135  auto CSC_slope_cosi_corr_L1_ME11_odd_ = load(gemCscSlopeCosiCorrectionFiles_[2]);
136  auto CSC_slope_cosi_corr_L2_ME11_odd_ = load(gemCscSlopeCosiCorrectionFiles_[3]);
137 
138  auto CSC_slope_corr_L1_ME11_even_ = load(gemCscSlopeCorrectionFiles_[0]);
139  auto CSC_slope_corr_L2_ME11_even_ = load(gemCscSlopeCorrectionFiles_[1]);
140  auto CSC_slope_corr_L1_ME11_odd_ = load(gemCscSlopeCorrectionFiles_[2]);
141  auto CSC_slope_corr_L2_ME11_odd_ = load(gemCscSlopeCorrectionFiles_[3]);
142 
143  auto es_diff_slope_L1_ME1a_even_ = load(esDiffToSlopeME1aFiles_[0]);
144  auto es_diff_slope_L1_ME1a_odd_ = load(esDiffToSlopeME1aFiles_[1]);
145  auto es_diff_slope_L2_ME1a_even_ = load(esDiffToSlopeME1aFiles_[2]);
146  auto es_diff_slope_L2_ME1a_odd_ = load(esDiffToSlopeME1aFiles_[3]);
147 
148  auto es_diff_slope_L1_ME1b_even_ = load(esDiffToSlopeME1bFiles_[0]);
149  auto es_diff_slope_L1_ME1b_odd_ = load(esDiffToSlopeME1bFiles_[1]);
150  auto es_diff_slope_L2_ME1b_even_ = load(esDiffToSlopeME1bFiles_[2]);
151  auto es_diff_slope_L2_ME1b_odd_ = load(esDiffToSlopeME1bFiles_[3]);
152 
153  // set the data in the LUT object
154  lut->set_GEM_pad_CSC_hs_ME1b_even(std::move(GEM_pad_CSC_hs_ME1b_even_));
155  lut->set_GEM_pad_CSC_hs_ME1a_even(std::move(GEM_pad_CSC_hs_ME1a_even_));
156  lut->set_GEM_pad_CSC_hs_ME1b_odd(std::move(GEM_pad_CSC_hs_ME1b_odd_));
157  lut->set_GEM_pad_CSC_hs_ME1a_odd(std::move(GEM_pad_CSC_hs_ME1a_odd_));
158 
159  lut->set_GEM_pad_CSC_es_ME1b_even(std::move(GEM_pad_CSC_es_ME1b_even_));
160  lut->set_GEM_pad_CSC_es_ME1a_even(std::move(GEM_pad_CSC_es_ME1a_even_));
161  lut->set_GEM_pad_CSC_es_ME1b_odd(std::move(GEM_pad_CSC_es_ME1b_odd_));
162  lut->set_GEM_pad_CSC_es_ME1a_odd(std::move(GEM_pad_CSC_es_ME1a_odd_));
163 
164  lut->set_GEM_roll_L1_CSC_min_wg_ME11_even(std::move(GEM_roll_L1_CSC_min_wg_ME11_even_));
165  lut->set_GEM_roll_L1_CSC_max_wg_ME11_even(std::move(GEM_roll_L1_CSC_max_wg_ME11_even_));
166  lut->set_GEM_roll_L1_CSC_min_wg_ME11_odd(std::move(GEM_roll_L1_CSC_min_wg_ME11_odd_));
167  lut->set_GEM_roll_L1_CSC_max_wg_ME11_odd(std::move(GEM_roll_L1_CSC_max_wg_ME11_odd_));
168 
169  lut->set_GEM_roll_L2_CSC_min_wg_ME11_even(std::move(GEM_roll_L2_CSC_min_wg_ME11_even_));
170  lut->set_GEM_roll_L2_CSC_max_wg_ME11_even(std::move(GEM_roll_L2_CSC_max_wg_ME11_even_));
171  lut->set_GEM_roll_L2_CSC_min_wg_ME11_odd(std::move(GEM_roll_L2_CSC_min_wg_ME11_odd_));
172  lut->set_GEM_roll_L2_CSC_max_wg_ME11_odd(std::move(GEM_roll_L2_CSC_max_wg_ME11_odd_));
173 
174  // GEM-CSC trigger: slope correction
175  lut->set_CSC_slope_cosi_2to1_L1_ME11_even(std::move(CSC_slope_cosi_2to1_L1_ME11_even_));
176  lut->set_CSC_slope_cosi_2to1_L1_ME11_odd(std::move(CSC_slope_cosi_2to1_L1_ME11_odd_));
177  lut->set_CSC_slope_cosi_3to1_L1_ME11_even(std::move(CSC_slope_cosi_3to1_L1_ME11_even_));
178  lut->set_CSC_slope_cosi_3to1_L1_ME11_odd(std::move(CSC_slope_cosi_3to1_L1_ME11_odd_));
179 
180  lut->set_CSC_slope_cosi_corr_L1_ME11_even(std::move(CSC_slope_cosi_corr_L1_ME11_even_));
181  lut->set_CSC_slope_cosi_corr_L1_ME11_odd(std::move(CSC_slope_cosi_corr_L1_ME11_odd_));
182  lut->set_CSC_slope_cosi_corr_L2_ME11_even(std::move(CSC_slope_cosi_corr_L2_ME11_even_));
183  lut->set_CSC_slope_cosi_corr_L2_ME11_odd(std::move(CSC_slope_cosi_corr_L2_ME11_odd_));
184 
185  lut->set_CSC_slope_corr_L1_ME11_even(std::move(CSC_slope_corr_L1_ME11_even_));
186  lut->set_CSC_slope_corr_L1_ME11_odd(std::move(CSC_slope_corr_L1_ME11_odd_));
187  lut->set_CSC_slope_corr_L2_ME11_even(std::move(CSC_slope_corr_L2_ME11_even_));
188  lut->set_CSC_slope_corr_L2_ME11_odd(std::move(CSC_slope_corr_L2_ME11_odd_));
189 
190  // GEM-CSC trigger: 1/8-strip difference to slope
191  lut->set_es_diff_slope_L1_ME1a_even(std::move(es_diff_slope_L1_ME1a_even_));
192  lut->set_es_diff_slope_L2_ME1a_even(std::move(es_diff_slope_L2_ME1a_even_));
193  lut->set_es_diff_slope_L1_ME1a_odd(std::move(es_diff_slope_L1_ME1a_odd_));
194  lut->set_es_diff_slope_L2_ME1a_odd(std::move(es_diff_slope_L2_ME1a_odd_));
195 
196  lut->set_es_diff_slope_L1_ME1b_even(std::move(es_diff_slope_L1_ME1b_even_));
197  lut->set_es_diff_slope_L2_ME1b_even(std::move(es_diff_slope_L2_ME1b_even_));
198  lut->set_es_diff_slope_L1_ME1b_odd(std::move(es_diff_slope_L1_ME1b_odd_));
199  lut->set_es_diff_slope_L2_ME1b_odd(std::move(es_diff_slope_L2_ME1b_odd_));
200 
201  return lut;
202 }
203 
204 std::unique_ptr<CSCL1TPLookupTableME21ILT> CSCL1TPLookupTableEP::produceME21ILT(const CSCL1TPLookupTableME21ILTRcd&) {
205  // make the LUT object
206  std::unique_ptr<CSCL1TPLookupTableME21ILT> lut = std::make_unique<CSCL1TPLookupTableME21ILT>();
207 
208  // get the text files
209  std::vector<std::string> padToHsME21Files_ = pset_.getParameter<std::vector<std::string>>("padToHsME21Files");
210  std::vector<std::string> padToEsME21Files_ = pset_.getParameter<std::vector<std::string>>("padToEsME21Files");
211 
212  std::vector<std::string> rollToMaxWgME21Files_ = pset_.getParameter<std::vector<std::string>>("rollToMaxWgME21Files");
213  std::vector<std::string> rollToMinWgME21Files_ = pset_.getParameter<std::vector<std::string>>("rollToMinWgME21Files");
214 
215  std::vector<std::string> esDiffToSlopeME21Files_ =
216  pset_.getParameter<std::vector<std::string>>("esDiffToSlopeME21Files");
217 
218  // read the text files and extract the data
219  auto GEM_pad_CSC_hs_ME21_even_ = load(padToHsME21Files_[0]);
220  auto GEM_pad_CSC_hs_ME21_odd_ = load(padToHsME21Files_[1]);
221 
222  auto GEM_pad_CSC_es_ME21_even_ = load(padToEsME21Files_[0]);
223  auto GEM_pad_CSC_es_ME21_odd_ = load(padToEsME21Files_[1]);
224 
225  auto GEM_roll_L1_CSC_min_wg_ME21_even_ = load(rollToMinWgME21Files_[0]);
226  auto GEM_roll_L1_CSC_min_wg_ME21_odd_ = load(rollToMinWgME21Files_[1]);
227  auto GEM_roll_L2_CSC_min_wg_ME21_even_ = load(rollToMinWgME21Files_[2]);
228  auto GEM_roll_L2_CSC_min_wg_ME21_odd_ = load(rollToMinWgME21Files_[3]);
229 
230  auto GEM_roll_L1_CSC_max_wg_ME21_even_ = load(rollToMaxWgME21Files_[0]);
231  auto GEM_roll_L1_CSC_max_wg_ME21_odd_ = load(rollToMaxWgME21Files_[1]);
232  auto GEM_roll_L2_CSC_max_wg_ME21_even_ = load(rollToMaxWgME21Files_[2]);
233  auto GEM_roll_L2_CSC_max_wg_ME21_odd_ = load(rollToMaxWgME21Files_[3]);
234 
235  auto es_diff_slope_L1_ME21_even_ = load(esDiffToSlopeME21Files_[0]);
236  auto es_diff_slope_L1_ME21_odd_ = load(esDiffToSlopeME21Files_[1]);
237  auto es_diff_slope_L2_ME21_even_ = load(esDiffToSlopeME21Files_[2]);
238  auto es_diff_slope_L2_ME21_odd_ = load(esDiffToSlopeME21Files_[3]);
239 
240  // set the data in the LUT object
241  lut->set_GEM_pad_CSC_hs_ME21_even(std::move(GEM_pad_CSC_hs_ME21_even_));
242  lut->set_GEM_pad_CSC_hs_ME21_odd(std::move(GEM_pad_CSC_hs_ME21_odd_));
243 
244  lut->set_GEM_pad_CSC_es_ME21_even(std::move(GEM_pad_CSC_es_ME21_even_));
245  lut->set_GEM_pad_CSC_es_ME21_odd(std::move(GEM_pad_CSC_es_ME21_odd_));
246 
247  lut->set_GEM_roll_L1_CSC_min_wg_ME21_even(std::move(GEM_roll_L1_CSC_min_wg_ME21_even_));
248  lut->set_GEM_roll_L1_CSC_max_wg_ME21_even(std::move(GEM_roll_L1_CSC_max_wg_ME21_even_));
249  lut->set_GEM_roll_L1_CSC_min_wg_ME21_odd(std::move(GEM_roll_L1_CSC_min_wg_ME21_odd_));
250  lut->set_GEM_roll_L1_CSC_max_wg_ME21_odd(std::move(GEM_roll_L1_CSC_max_wg_ME21_odd_));
251 
252  lut->set_GEM_roll_L2_CSC_min_wg_ME21_even(std::move(GEM_roll_L2_CSC_min_wg_ME21_even_));
253  lut->set_GEM_roll_L2_CSC_max_wg_ME21_even(std::move(GEM_roll_L2_CSC_max_wg_ME21_even_));
254  lut->set_GEM_roll_L2_CSC_min_wg_ME21_odd(std::move(GEM_roll_L2_CSC_min_wg_ME21_odd_));
255  lut->set_GEM_roll_L2_CSC_max_wg_ME21_odd(std::move(GEM_roll_L2_CSC_max_wg_ME21_odd_));
256 
257  lut->set_es_diff_slope_L1_ME21_even(std::move(es_diff_slope_L1_ME21_even_));
258  lut->set_es_diff_slope_L2_ME21_even(std::move(es_diff_slope_L2_ME21_even_));
259  lut->set_es_diff_slope_L1_ME21_odd(std::move(es_diff_slope_L1_ME21_odd_));
260  lut->set_es_diff_slope_L2_ME21_odd(std::move(es_diff_slope_L2_ME21_odd_));
261 
262  return lut;
263 }
264 
265 std::vector<unsigned> CSCL1TPLookupTableEP::load(std::string fileName) const {
266  std::vector<unsigned> returnV;
267  std::ifstream fstream;
268  fstream.open(edm::FileInPath(fileName.c_str()).fullPath());
269  // empty file, return empty lut
270  if (!fstream.good()) {
271  fstream.close();
272  return returnV;
273  }
274 
276 
277  while (std::getline(fstream, line)) {
278  //ignore comments
279  line.erase(std::find(line.begin(), line.end(), '#'), line.end());
280  std::istringstream lineStream(line);
281  std::pair<unsigned, unsigned> entry;
282  while (lineStream >> entry.first >> entry.second) {
283  returnV.push_back(entry.second);
284  }
285  }
286  return returnV;
287 }
288 
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
const edm::ParameterSet pset_
std::unique_ptr< CSCL1TPLookupTableCCLUT > produceCCLUT(const CSCL1TPLookupTableCCLUTRcd &)
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
def move
Definition: eostools.py:511
std::unique_ptr< CSCL1TPLookupTableME21ILT > produceME21ILT(const CSCL1TPLookupTableME21ILTRcd &)
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
const double infinity
CSCL1TPLookupTableEP(const edm::ParameterSet &)
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:91
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::unique_ptr< CSCL1TPLookupTableME11ILT > produceME11ILT(const CSCL1TPLookupTableME11ILTRcd &)
list entry
Definition: mps_splice.py:68
std::vector< unsigned > load(std::string fileName) const