Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:16

0001 #include "CondTools/L1Trigger/interface/L1ConfigOnlineProdBase.h"
0002 #include "CondFormats/L1TObjects/interface/L1GctChannelMask.h"
0003 #include "CondFormats/DataRecord/interface/L1GctChannelMaskRcd.h"
0004 
0005 class L1GctChannelMaskOnlineProd : public L1ConfigOnlineProdBase<L1GctChannelMaskRcd, L1GctChannelMask> {
0006 public:
0007   L1GctChannelMaskOnlineProd(const edm::ParameterSet& iConfig)
0008       : L1ConfigOnlineProdBase<L1GctChannelMaskRcd, L1GctChannelMask>(iConfig) {}
0009   ~L1GctChannelMaskOnlineProd() override {}
0010 
0011   std::unique_ptr<L1GctChannelMask> newObject(const std::string& objectKey) override;
0012 
0013 private:
0014 };
0015 
0016 std::unique_ptr<L1GctChannelMask> L1GctChannelMaskOnlineProd::newObject(const std::string& objectKey) {
0017   // get EM mask data
0018   l1t::OMDSReader::QueryResults emMaskResults = m_omdsReader.basicQuery(
0019       "GCT_EM_MASK", "CMS_GCT", "GCT_MASKS", "GCT_MASKS.CONFIG_KEY", m_omdsReader.singleAttribute(objectKey));
0020 
0021   if (emMaskResults.queryFailed()) {  // check if query was successful
0022     edm::LogError("L1-O2O") << "Problem with L1GctChannelMask EM mask for key " << objectKey;
0023     return std::unique_ptr<L1GctChannelMask>();
0024   }
0025 
0026   int emMask = -1;
0027   emMaskResults.fillVariable(emMask);
0028 
0029   // get region masks
0030   l1t::OMDSReader::QueryResults rgnMaskKeyResults = m_omdsReader.basicQuery(
0031       "GCT_RGN_MASK_KEY", "CMS_GCT", "GCT_MASKS", "GCT_MASKS.CONFIG_KEY", m_omdsReader.singleAttribute(objectKey));
0032 
0033   if (rgnMaskKeyResults.queryFailed()) {  // check if query was successful
0034     edm::LogError("L1-O2O") << "Problem with L1GctChannelMask region mask for key " << objectKey;
0035     return std::unique_ptr<L1GctChannelMask>();
0036   }
0037 
0038   std::string rgnKey;
0039   rgnMaskKeyResults.fillVariable(rgnKey);
0040 
0041   std::vector<std::string> rgnMaskCols;
0042   rgnMaskCols.push_back("RCT_CRATE_0_RGN_MASK");
0043   rgnMaskCols.push_back("RCT_CRATE_1_RGN_MASK");
0044   rgnMaskCols.push_back("RCT_CRATE_2_RGN_MASK");
0045   rgnMaskCols.push_back("RCT_CRATE_3_RGN_MASK");
0046   rgnMaskCols.push_back("RCT_CRATE_4_RGN_MASK");
0047   rgnMaskCols.push_back("RCT_CRATE_5_RGN_MASK");
0048   rgnMaskCols.push_back("RCT_CRATE_6_RGN_MASK");
0049   rgnMaskCols.push_back("RCT_CRATE_7_RGN_MASK");
0050   rgnMaskCols.push_back("RCT_CRATE_8_RGN_MASK");
0051   rgnMaskCols.push_back("RCT_CRATE_9_RGN_MASK");
0052   rgnMaskCols.push_back("RCT_CRATE_10_RGN_MASK");
0053   rgnMaskCols.push_back("RCT_CRATE_11_RGN_MASK");
0054   rgnMaskCols.push_back("RCT_CRATE_12_RGN_MASK");
0055   rgnMaskCols.push_back("RCT_CRATE_13_RGN_MASK");
0056   rgnMaskCols.push_back("RCT_CRATE_14_RGN_MASK");
0057   rgnMaskCols.push_back("RCT_CRATE_15_RGN_MASK");
0058   rgnMaskCols.push_back("RCT_CRATE_16_RGN_MASK");
0059   rgnMaskCols.push_back("RCT_CRATE_17_RGN_MASK");
0060 
0061   l1t::OMDSReader::QueryResults rgnMaskResults = m_omdsReader.basicQuery(
0062       rgnMaskCols, "CMS_GCT", "GCT_RGN_MASKS", "GCT_RGN_MASKS.CONFIG_KEY", m_omdsReader.singleAttribute(rgnKey));
0063 
0064   // get energy sum masks
0065   l1t::OMDSReader::QueryResults esumMaskKeyResults = m_omdsReader.basicQuery(
0066       "GCT_ESUM_MASK_KEY", "CMS_GCT", "GCT_MASKS", "GCT_MASKS.CONFIG_KEY", m_omdsReader.singleAttribute(objectKey));
0067 
0068   if (esumMaskKeyResults.queryFailed()) {  // check if query was successful
0069     edm::LogError("L1-O2O") << "Problem with L1GctChannelMask energy sum mask for key " << objectKey;
0070     return std::unique_ptr<L1GctChannelMask>();
0071   }
0072 
0073   std::string esumKey;
0074   esumMaskKeyResults.fillVariable(esumKey);
0075 
0076   std::vector<std::string> esumMaskCols;
0077   esumMaskCols.push_back("GCT_TET_MASK");
0078   esumMaskCols.push_back("GCT_MET_MASK");
0079   esumMaskCols.push_back("GCT_HT_MASK");
0080   esumMaskCols.push_back("GCT_MHT_MASK");
0081 
0082   l1t::OMDSReader::QueryResults esumMaskResults = m_omdsReader.basicQuery(
0083       esumMaskCols, "CMS_GCT", "GCT_ESUM_MASKS", "GCT_ESUM_MASKS.CONFIG_KEY", m_omdsReader.singleAttribute(esumKey));
0084 
0085   // create masks object
0086   auto masks = std::make_unique<L1GctChannelMask>();
0087 
0088   // set EM masks
0089   for (int i = 0; i < 18; i++) {
0090     if ((emMask & (1 << i)) != 0)
0091       masks->maskEmCrate(i);  // mask crate if emMask bit i is set
0092   }
0093 
0094   // set region masks
0095   for (unsigned irct = 0; irct < 18; irct++) {
0096     std::stringstream rgnCol;
0097     rgnCol << "RCT_CRATE_" << std::dec << irct << "_RGN_MASK";
0098     int mask;
0099     rgnMaskResults.fillVariable(rgnCol.str(), mask);
0100     if (mask != 0) {
0101       for (unsigned irgn = 0; irgn < 22; ++irgn) {
0102         if ((mask & (1 << irgn)) != 0) {
0103           edm::LogError("L1-O2O") << "Masked region, but no O2O code!";
0104         }
0105       }
0106     }
0107   }
0108 
0109   // set esum masks
0110   int tetMask, metMask, htMask, mhtMask;
0111   esumMaskResults.fillVariable("GCT_TET_MASK", tetMask);
0112   esumMaskResults.fillVariable("GCT_MET_MASK", metMask);
0113   esumMaskResults.fillVariable("GCT_HT_MASK", htMask);
0114   esumMaskResults.fillVariable("GCT_MHT_MASK", mhtMask);
0115 
0116   for (int ieta = 0; ieta < 22; ieta++) {
0117     if ((tetMask & (1 << ieta)) != 0)
0118       masks->maskTotalEt(ieta);
0119     if ((metMask & (1 << ieta)) != 0)
0120       masks->maskMissingEt(ieta);
0121     if ((htMask & (1 << ieta)) != 0)
0122       masks->maskTotalHt(ieta);
0123     if ((mhtMask & (1 << ieta)) != 0)
0124       masks->maskMissingHt(ieta);
0125   }
0126 
0127   return masks;
0128 }
0129 
0130 DEFINE_FWK_EVENTSETUP_MODULE(L1GctChannelMaskOnlineProd);