CMS 3D CMS Logo

L1GctChannelMaskOnlineProd.cc
Go to the documentation of this file.
4 
5 class L1GctChannelMaskOnlineProd : public L1ConfigOnlineProdBase<L1GctChannelMaskRcd, L1GctChannelMask> {
6 public:
10 
11  std::unique_ptr<L1GctChannelMask> newObject(const std::string& objectKey) override;
12 
13 private:
14 };
15 
16 std::unique_ptr<L1GctChannelMask> L1GctChannelMaskOnlineProd::newObject(const std::string& objectKey) {
17  // get EM mask data
19  "GCT_EM_MASK", "CMS_GCT", "GCT_MASKS", "GCT_MASKS.CONFIG_KEY", m_omdsReader.singleAttribute(objectKey));
20 
21  if (emMaskResults.queryFailed()) { // check if query was successful
22  edm::LogError("L1-O2O") << "Problem with L1GctChannelMask EM mask for key " << objectKey;
23  return std::unique_ptr<L1GctChannelMask>();
24  }
25 
26  int emMask = -1;
27  emMaskResults.fillVariable(emMask);
28 
29  // get region masks
31  "GCT_RGN_MASK_KEY", "CMS_GCT", "GCT_MASKS", "GCT_MASKS.CONFIG_KEY", m_omdsReader.singleAttribute(objectKey));
32 
33  if (rgnMaskKeyResults.queryFailed()) { // check if query was successful
34  edm::LogError("L1-O2O") << "Problem with L1GctChannelMask region mask for key " << objectKey;
35  return std::unique_ptr<L1GctChannelMask>();
36  }
37 
38  std::string rgnKey;
39  rgnMaskKeyResults.fillVariable(rgnKey);
40 
41  std::vector<std::string> rgnMaskCols;
42  rgnMaskCols.push_back("RCT_CRATE_0_RGN_MASK");
43  rgnMaskCols.push_back("RCT_CRATE_1_RGN_MASK");
44  rgnMaskCols.push_back("RCT_CRATE_2_RGN_MASK");
45  rgnMaskCols.push_back("RCT_CRATE_3_RGN_MASK");
46  rgnMaskCols.push_back("RCT_CRATE_4_RGN_MASK");
47  rgnMaskCols.push_back("RCT_CRATE_5_RGN_MASK");
48  rgnMaskCols.push_back("RCT_CRATE_6_RGN_MASK");
49  rgnMaskCols.push_back("RCT_CRATE_7_RGN_MASK");
50  rgnMaskCols.push_back("RCT_CRATE_8_RGN_MASK");
51  rgnMaskCols.push_back("RCT_CRATE_9_RGN_MASK");
52  rgnMaskCols.push_back("RCT_CRATE_10_RGN_MASK");
53  rgnMaskCols.push_back("RCT_CRATE_11_RGN_MASK");
54  rgnMaskCols.push_back("RCT_CRATE_12_RGN_MASK");
55  rgnMaskCols.push_back("RCT_CRATE_13_RGN_MASK");
56  rgnMaskCols.push_back("RCT_CRATE_14_RGN_MASK");
57  rgnMaskCols.push_back("RCT_CRATE_15_RGN_MASK");
58  rgnMaskCols.push_back("RCT_CRATE_16_RGN_MASK");
59  rgnMaskCols.push_back("RCT_CRATE_17_RGN_MASK");
60 
62  rgnMaskCols, "CMS_GCT", "GCT_RGN_MASKS", "GCT_RGN_MASKS.CONFIG_KEY", m_omdsReader.singleAttribute(rgnKey));
63 
64  // get energy sum masks
66  "GCT_ESUM_MASK_KEY", "CMS_GCT", "GCT_MASKS", "GCT_MASKS.CONFIG_KEY", m_omdsReader.singleAttribute(objectKey));
67 
68  if (esumMaskKeyResults.queryFailed()) { // check if query was successful
69  edm::LogError("L1-O2O") << "Problem with L1GctChannelMask energy sum mask for key " << objectKey;
70  return std::unique_ptr<L1GctChannelMask>();
71  }
72 
73  std::string esumKey;
74  esumMaskKeyResults.fillVariable(esumKey);
75 
76  std::vector<std::string> esumMaskCols;
77  esumMaskCols.push_back("GCT_TET_MASK");
78  esumMaskCols.push_back("GCT_MET_MASK");
79  esumMaskCols.push_back("GCT_HT_MASK");
80  esumMaskCols.push_back("GCT_MHT_MASK");
81 
83  esumMaskCols, "CMS_GCT", "GCT_ESUM_MASKS", "GCT_ESUM_MASKS.CONFIG_KEY", m_omdsReader.singleAttribute(esumKey));
84 
85  // create masks object
86  auto masks = std::make_unique<L1GctChannelMask>();
87 
88  // set EM masks
89  for (int i = 0; i < 18; i++) {
90  if ((emMask & (1 << i)) != 0)
91  masks->maskEmCrate(i); // mask crate if emMask bit i is set
92  }
93 
94  // set region masks
95  for (unsigned irct = 0; irct < 18; irct++) {
96  std::stringstream rgnCol;
97  rgnCol << "RCT_CRATE_" << std::dec << irct << "_RGN_MASK";
98  int mask;
99  rgnMaskResults.fillVariable(rgnCol.str(), mask);
100  if (mask != 0) {
101  for (unsigned irgn = 0; irgn < 22; ++irgn) {
102  if ((mask & (1 << irgn)) != 0) {
103  edm::LogError("L1-O2O") << "Masked region, but no O2O code!";
104  }
105  }
106  }
107  }
108 
109  // set esum masks
110  int tetMask, metMask, htMask, mhtMask;
111  esumMaskResults.fillVariable("GCT_TET_MASK", tetMask);
112  esumMaskResults.fillVariable("GCT_MET_MASK", metMask);
113  esumMaskResults.fillVariable("GCT_HT_MASK", htMask);
114  esumMaskResults.fillVariable("GCT_MHT_MASK", mhtMask);
115 
116  for (int ieta = 0; ieta < 22; ieta++) {
117  if ((tetMask & (1 << ieta)) != 0)
118  masks->maskTotalEt(ieta);
119  if ((metMask & (1 << ieta)) != 0)
120  masks->maskMissingEt(ieta);
121  if ((htMask & (1 << ieta)) != 0)
122  masks->maskTotalHt(ieta);
123  if ((mhtMask & (1 << ieta)) != 0)
124  masks->maskMissingHt(ieta);
125  }
126 
127  return masks;
128 }
129 
const QueryResults singleAttribute(const T &data) const
Definition: OMDSReader.h:259
Log< level::Error, false > LogError
constexpr uint32_t mask
Definition: gpuClustering.h:24
L1GctChannelMaskOnlineProd(const edm::ParameterSet &iConfig)
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
std::unique_ptr< L1GctChannelMask > newObject(const std::string &objectKey) override