CMS 3D CMS Logo

L1RCTChannelMaskOnlineProd.cc
Go to the documentation of this file.
1 
2 // -*- C++ -*-
3 //
4 // Package: L1RCTParametersOnlineProd
5 // Class: L1RCTParametersOnlineProd
6 //
14 //
15 // Original Author: Werner Man-Li Sun
16 // Created: Tue Sep 16 22:43:22 CEST 2008
17 //
18 //
19 
20 // system include files
21 #include <iostream>
22 
23 // user include files
25 
28 
29 // #include "FWCore/Framework/interface/HCTypeTagTemplate.h"
30 // #include "FWCore/Framework/interface/EventSetup.h"
31 
32 //
33 // class declaration
34 //
35 
36 class L1RCTChannelMaskOnlineProd : public L1ConfigOnlineProdBase<L1RCTChannelMaskRcd, L1RCTChannelMask> {
37 public:
41 
42  std::unique_ptr<L1RCTChannelMask> newObject(const std::string& objectKey) override;
43 
44 private:
45  // ----------member data ---------------------------
46 };
47 
48 //
49 // constants, enums and typedefs
50 //
51 
52 //
53 // static data member definitions
54 //
55 
56 //
57 // constructors and destructor
58 //
59 
60 std::unique_ptr<L1RCTChannelMask> L1RCTChannelMaskOnlineProd::newObject(const std::string& objectKey) {
61  std::cout << " Current key is " << objectKey << std::endl;
62 
63  std::string rctSchema = "CMS_RCT";
64 
65  std::vector<std::string> dc_maskStrings;
66  dc_maskStrings.push_back("HCAL_MASK_CR00_EVEN");
67  dc_maskStrings.push_back("HCAL_MASK_CR00_ODD");
68  dc_maskStrings.push_back("HCAL_MASK_CR01_EVEN");
69  dc_maskStrings.push_back("HCAL_MASK_CR01_ODD");
70  dc_maskStrings.push_back("HCAL_MASK_CR02_EVEN");
71  dc_maskStrings.push_back("HCAL_MASK_CR02_ODD");
72  dc_maskStrings.push_back("HCAL_MASK_CR03_EVEN");
73  dc_maskStrings.push_back("HCAL_MASK_CR03_ODD");
74  dc_maskStrings.push_back("HCAL_MASK_CR04_EVEN");
75  dc_maskStrings.push_back("HCAL_MASK_CR04_ODD");
76  dc_maskStrings.push_back("HCAL_MASK_CR05_EVEN");
77  dc_maskStrings.push_back("HCAL_MASK_CR05_ODD");
78  dc_maskStrings.push_back("HCAL_MASK_CR06_EVEN");
79  dc_maskStrings.push_back("HCAL_MASK_CR06_ODD");
80  dc_maskStrings.push_back("HCAL_MASK_CR07_EVEN");
81  dc_maskStrings.push_back("HCAL_MASK_CR07_ODD");
82  dc_maskStrings.push_back("HCAL_MASK_CR08_EVEN");
83  dc_maskStrings.push_back("HCAL_MASK_CR08_ODD");
84  dc_maskStrings.push_back("HCAL_MASK_CR09_EVEN");
85  dc_maskStrings.push_back("HCAL_MASK_CR09_ODD");
86  dc_maskStrings.push_back("HCAL_MASK_CR10_EVEN");
87  dc_maskStrings.push_back("HCAL_MASK_CR10_ODD");
88  dc_maskStrings.push_back("HCAL_MASK_CR11_EVEN");
89  dc_maskStrings.push_back("HCAL_MASK_CR11_ODD");
90  dc_maskStrings.push_back("HCAL_MASK_CR12_EVEN");
91  dc_maskStrings.push_back("HCAL_MASK_CR12_ODD");
92  dc_maskStrings.push_back("HCAL_MASK_CR13_EVEN");
93  dc_maskStrings.push_back("HCAL_MASK_CR13_ODD");
94  dc_maskStrings.push_back("HCAL_MASK_CR14_EVEN");
95  dc_maskStrings.push_back("HCAL_MASK_CR14_ODD");
96  dc_maskStrings.push_back("HCAL_MASK_CR15_EVEN");
97  dc_maskStrings.push_back("HCAL_MASK_CR15_ODD");
98  dc_maskStrings.push_back("HCAL_MASK_CR16_EVEN");
99  dc_maskStrings.push_back("HCAL_MASK_CR16_ODD");
100  dc_maskStrings.push_back("HCAL_MASK_CR17_EVEN");
101  dc_maskStrings.push_back("HCAL_MASK_CR17_ODD");
102  dc_maskStrings.push_back("ECAL_MASK_CR00_EVEN");
103  dc_maskStrings.push_back("ECAL_MASK_CR00_ODD");
104  dc_maskStrings.push_back("ECAL_MASK_CR01_EVEN");
105  dc_maskStrings.push_back("ECAL_MASK_CR01_ODD");
106  dc_maskStrings.push_back("ECAL_MASK_CR02_EVEN");
107  dc_maskStrings.push_back("ECAL_MASK_CR02_ODD");
108  dc_maskStrings.push_back("ECAL_MASK_CR03_EVEN");
109  dc_maskStrings.push_back("ECAL_MASK_CR03_ODD");
110  dc_maskStrings.push_back("ECAL_MASK_CR04_EVEN");
111  dc_maskStrings.push_back("ECAL_MASK_CR04_ODD");
112  dc_maskStrings.push_back("ECAL_MASK_CR05_EVEN");
113  dc_maskStrings.push_back("ECAL_MASK_CR05_ODD");
114  dc_maskStrings.push_back("ECAL_MASK_CR06_EVEN");
115  dc_maskStrings.push_back("ECAL_MASK_CR06_ODD");
116  dc_maskStrings.push_back("ECAL_MASK_CR07_EVEN");
117  dc_maskStrings.push_back("ECAL_MASK_CR07_ODD");
118  dc_maskStrings.push_back("ECAL_MASK_CR08_EVEN");
119  dc_maskStrings.push_back("ECAL_MASK_CR08_ODD");
120  dc_maskStrings.push_back("ECAL_MASK_CR09_EVEN");
121  dc_maskStrings.push_back("ECAL_MASK_CR09_ODD");
122  dc_maskStrings.push_back("ECAL_MASK_CR10_EVEN");
123  dc_maskStrings.push_back("ECAL_MASK_CR10_ODD");
124  dc_maskStrings.push_back("ECAL_MASK_CR11_EVEN");
125  dc_maskStrings.push_back("ECAL_MASK_CR11_ODD");
126  dc_maskStrings.push_back("ECAL_MASK_CR12_EVEN");
127  dc_maskStrings.push_back("ECAL_MASK_CR12_ODD");
128  dc_maskStrings.push_back("ECAL_MASK_CR13_EVEN");
129  dc_maskStrings.push_back("ECAL_MASK_CR13_ODD");
130  dc_maskStrings.push_back("ECAL_MASK_CR14_EVEN");
131  dc_maskStrings.push_back("ECAL_MASK_CR14_ODD");
132  dc_maskStrings.push_back("ECAL_MASK_CR15_EVEN");
133  dc_maskStrings.push_back("ECAL_MASK_CR15_ODD");
134  dc_maskStrings.push_back("ECAL_MASK_CR16_EVEN");
135  dc_maskStrings.push_back("ECAL_MASK_CR16_ODD");
136  dc_maskStrings.push_back("ECAL_MASK_CR17_EVEN");
137  dc_maskStrings.push_back("ECAL_MASK_CR17_ODD");
138 
139  l1t::OMDSReader::QueryResults dcMaskResults =
140  m_omdsReader.basicQuery(dc_maskStrings,
141  rctSchema,
142  "RCT_DEADCHANNEL_SUMMARY",
143  "RCT_DEADCHANNEL_SUMMARY.ID",
144  m_omdsReader.basicQuery("DC_SUM_ID",
145  rctSchema,
146  "RCT_RUN_SETTINGS_KEY",
147  "RCT_RUN_SETTINGS_KEY.ID",
148  m_omdsReader.singleAttribute(objectKey)));
149 
150  if (dcMaskResults.queryFailed() || dcMaskResults.numberRows() != 1) // check query successful
151  {
152  edm::LogError("L1-O2O") << "Problem with L1RCTChannelMask key.";
153 
154  std::cout << " Returened rows " << dcMaskResults.numberRows() << std::endl;
155  return std::unique_ptr<L1RCTChannelMask>();
156  }
157 
159 
160  long long hcal_temp = 0LL;
161  int ecal_temp = 0;
162  for (int i = 0; i < 36; i++) {
163  dcMaskResults.fillVariable(dc_maskStrings.at(i), hcal_temp);
164  for (int j = 0; j < 32; j++)
165  if (j < 28)
166  m->hcalMask[i / 2][i % 2][j] = ((hcal_temp >> j) & 1) == 1;
167  else
168  m->hfMask[i / 2][i % 2][j - 28] = ((hcal_temp >> j) & 1) == 1;
169  }
170  for (int i = 36; i < 72; i++) {
171  dcMaskResults.fillVariable(dc_maskStrings.at(i), ecal_temp);
172  for (int j = 0; j < 28; j++) {
173  int k = i - 36;
174  m->ecalMask[k / 2][k % 2][j] = ((ecal_temp >> j) & 1) == 1;
175  }
176  }
177 
178  // FIND dummy cards from TSC key in crate conf
179 
180  std::vector<std::string> cardMaskStrings;
181  cardMaskStrings.push_back("RC0");
182  cardMaskStrings.push_back("RC1");
183  cardMaskStrings.push_back("RC2");
184  cardMaskStrings.push_back("RC3");
185  cardMaskStrings.push_back("RC4");
186  cardMaskStrings.push_back("RC5");
187  cardMaskStrings.push_back("RC6");
188  cardMaskStrings.push_back("JSC");
189 
190  std::vector<std::string> crateIDStrings;
191  crateIDStrings.push_back("RCT_CRATE_0");
192  crateIDStrings.push_back("RCT_CRATE_1");
193  crateIDStrings.push_back("RCT_CRATE_2");
194  crateIDStrings.push_back("RCT_CRATE_3");
195  crateIDStrings.push_back("RCT_CRATE_4");
196  crateIDStrings.push_back("RCT_CRATE_5");
197  crateIDStrings.push_back("RCT_CRATE_6");
198  crateIDStrings.push_back("RCT_CRATE_7");
199  crateIDStrings.push_back("RCT_CRATE_8");
200  crateIDStrings.push_back("RCT_CRATE_9");
201  crateIDStrings.push_back("RCT_CRATE_10");
202  crateIDStrings.push_back("RCT_CRATE_11");
203  crateIDStrings.push_back("RCT_CRATE_12");
204  crateIDStrings.push_back("RCT_CRATE_13");
205  crateIDStrings.push_back("RCT_CRATE_14");
206  crateIDStrings.push_back("RCT_CRATE_15");
207  crateIDStrings.push_back("RCT_CRATE_16");
208  crateIDStrings.push_back("RCT_CRATE_17");
209 
210  l1t::OMDSReader::QueryResults crate_conf = m_omdsReader.basicQuery("CRATE_CONF",
211  rctSchema,
212  "RCT_RUN_SETTINGS_KEY",
213  "RCT_RUN_SETTINGS_KEY.ID",
214  m_omdsReader.singleAttribute(objectKey));
215 
216  int crateNum = 0;
217  for (std::vector<std::string>::iterator crate = crateIDStrings.begin(); crate != crateIDStrings.end(); ++crate) {
218  // std::cout << "crate conf " << *crate <<std::endl;
220  cardMaskStrings,
221  rctSchema,
222  "CRATE_CONF_DUMMY",
223  "CRATE_CONF_DUMMY.CRATE_CONF",
224  m_omdsReader.basicQuery(*crate, rctSchema, "RCT_CRATE_CONF", "RCT_CRATE_CONF.RCT_KEY", crate_conf));
225  bool extantCard[8];
226  int cardNum = 0;
227  for (std::vector<std::string>::iterator card = cardMaskStrings.begin(); card != cardMaskStrings.end(); ++card) {
228  cardConfResults.fillVariable(*card, extantCard[cardNum]);
229 
230  if (!extantCard[cardNum]) {
231  switch (cardNum) {
232  case 6:
233 
234  for (int k = 0; k < 4; k++) {
235  m->ecalMask[crateNum][0][(cardNum / 2) * 8 + k] |= !extantCard[cardNum];
236  m->ecalMask[crateNum][1][(cardNum / 2) * 8 + k] |= !extantCard[cardNum];
237  m->hcalMask[crateNum][0][(cardNum / 2) * 8 + k] |= !extantCard[cardNum];
238  m->hcalMask[crateNum][1][(cardNum / 2) * 8 + k] |= !extantCard[cardNum];
239  }
240  break;
241  case 7:
242 
243  for (int k = 0; k < 4; k++) {
244  m->hfMask[crateNum][0][k] |= !extantCard[cardNum];
245  m->hfMask[crateNum][1][k] |= !extantCard[cardNum];
246  }
247  break;
248  default:
249 
250  for (int k = 0; k < 8; k++) {
251  m->hcalMask[crateNum][cardNum % 2][(cardNum / 2) * 8 + k] |= !extantCard[cardNum];
252  m->ecalMask[crateNum][cardNum % 2][(cardNum / 2) * 8 + k] |= !extantCard[cardNum];
253  }
254  }
255  }
256  cardNum++;
257  }
258  crateNum++;
259  }
260  /*
261  std::cout << "check fill" <<std::endl;
262  for(int i = 0; i< 18; i++)
263  for(int j =0; j< 2; j++){
264  for(int k =0; k<28; k++){
265  if(m->ecalMask[i][j][k])
266  std::cout << "ecal masked channel: crate " << i << " phi " << j <<" ieta " <<k <<std::endl;
267  if(m->hcalMask[i][j][k])
268  std::cout << "hcal masked channel: crate " << i << " phi " << j <<" ieta " <<k <<std::endl;
269  }
270  for(int k =0; k<4;k++)
271  if(m->hfMask[i][j][k])
272  std::cout << "hf masked channel: crate " << i << " phi " << j <<" ieta " <<k <<std::endl;
273  }
274 
275  */
276  //~~~~~~~~~ Instantiate new L1RCTChannelMask object. ~~~~~~~~~
277 
278  return std::unique_ptr<L1RCTChannelMask>(m);
279 }
280 
281 //
282 // member functions
283 //
284 
285 //define this as a plug-in
const QueryResults singleAttribute(const T &data) const
Definition: OMDSReader.h:259
Log< level::Error, false > LogError
const QueryResults basicQuery(const std::vector< std::string > &columnNames, const std::string &schemaName, const std::string &tableName, const std::string &conditionLHS="", const QueryResults conditionRHS=QueryResults(), const std::string &conditionRHSName="")
Definition: OMDSReader.cc:75
bool fillVariable(const std::string &columnName, T &outputVariable) const
Definition: OMDSReader.h:274
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
L1RCTChannelMaskOnlineProd(const edm::ParameterSet &iConfig)
std::unique_ptr< L1RCTChannelMask > newObject(const std::string &objectKey) override