Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:14:24

0001 // -*- C++ -*-
0002 //
0003 // Package:    L1TriggerConfig
0004 // Class:      RCTObjectKeysOnlineProd
0005 //
0006 /**\class RCTObjectKeysOnlineProd RCTObjectKeysOnlineProd.h L1TriggerConfig/RCTConfigProducers/src/RCTObjectKeysOnlineProd.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Werner Man-Li Sun
0015 //         Created:  Fri Aug 22 19:51:36 CEST 2008
0016 //
0017 //
0018 
0019 // system include files
0020 #include <iostream>
0021 
0022 // user include files
0023 #include "CondTools/L1Trigger/interface/L1ObjectKeysOnlineProdBase.h"
0024 
0025 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0026 
0027 //
0028 // class declaration
0029 //
0030 
0031 class RCTObjectKeysOnlineProd : public L1ObjectKeysOnlineProdBase {
0032 public:
0033   RCTObjectKeysOnlineProd(const edm::ParameterSet&);
0034   ~RCTObjectKeysOnlineProd() override;
0035 
0036   void fillObjectKeys(FillType pL1TriggerKey) override;
0037 
0038 private:
0039   // ----------member data ---------------------------
0040 };
0041 
0042 //
0043 // constants, enums and typedefs
0044 //
0045 
0046 //
0047 // static data member definitions
0048 //
0049 
0050 //
0051 // constructors and destructor
0052 //
0053 RCTObjectKeysOnlineProd::RCTObjectKeysOnlineProd(const edm::ParameterSet& iConfig)
0054     : L1ObjectKeysOnlineProdBase(iConfig) {}
0055 
0056 RCTObjectKeysOnlineProd::~RCTObjectKeysOnlineProd() {
0057   // do anything here that needs to be done at desctruction time
0058   // (e.g. close files, deallocate resources etc.)
0059 }
0060 
0061 //
0062 // member functions
0063 //
0064 
0065 // ------------ method called to produce the data  ------------
0066 void RCTObjectKeysOnlineProd::fillObjectKeys(FillType pL1TriggerKey) {
0067   std::string rctKey = pL1TriggerKey->subsystemKey(L1TriggerKey::kRCT);
0068 
0069   if (!rctKey.empty()) {
0070     std::string paremKey, scaleKey, ecalScaleKey, hcalScaleKey;
0071     // SELECT RCT_PARAMETER FROM RCT_CONF WHERE RCT_CONF.RCT_KEY = rctKey
0072     l1t::OMDSReader::QueryResults paremKeyResults = m_omdsReader.basicQuery(
0073         "RCT_PARAMETER", "CMS_RCT", "RCT_CONF", "RCT_CONF.RCT_KEY", m_omdsReader.singleAttribute(rctKey));
0074 
0075     if (paremKeyResults.queryFailed() || paremKeyResults.numberRows() != 1)  // check query successful
0076     {
0077       edm::LogError("L1-O2O") << "Problem with RCT Parameter key.";
0078       return;
0079     }
0080 
0081     l1t::OMDSReader::QueryResults scaleKeyResults =
0082         m_omdsReader.basicQuery("L1T_SCALE_CALO_ET_THRESHOLD_ID",
0083                                 "CMS_RCT",
0084                                 "PAREM_CONF",
0085                                 "PAREM_CONF.PAREM_KEY",
0086                                 paremKeyResults);  // not null no need to check
0087 
0088     l1t::OMDSReader::QueryResults ecalKeyResults = m_omdsReader.basicQuery(
0089         "ECAL_CONF", "CMS_RCT", "RCT_CONF", "RCT_CONF.RCT_KEY", m_omdsReader.singleAttribute(rctKey));
0090 
0091     if (ecalKeyResults.queryFailed() || ecalKeyResults.numberRows() > 1)  // check query successful)
0092     {
0093       edm::LogError("L1-O2O") << "Problem with rct_conf.ecal_conf.";
0094       return;
0095     }
0096     std::string ecalKey;
0097     if (!ecalKeyResults.fillVariable(ecalKey))
0098       ecalScaleKey = "NULL";
0099     else {  // fill variable not null
0100 
0101       if (ecalKey == "NULL")
0102         ecalScaleKey = "NULL";
0103       else if (ecalKey == "IDENTITY")
0104         ecalScaleKey = "IDENTITY";
0105       else {  // not identity or null
0106 
0107         l1t::OMDSReader::QueryResults ecalScaleKeyResults = m_omdsReader.basicQuery(
0108             "ECAL_LUT_CONFIG_ID", "CMS_RCT", "ECAL_SCALE_KEY", "ECAL_SCALE_KEY.ECAL_TAG", ecalKeyResults);
0109 
0110         if (ecalScaleKeyResults.queryFailed() || ecalScaleKeyResults.numberRows() > 1)  // check query successful)
0111         {
0112           std::cout << " nrows " << ecalScaleKeyResults.numberRows() << std::endl;
0113           edm::LogError("L1-O2O") << "bad results from lut_config_id.";
0114           return;
0115         }
0116         int ecalScaleTemp = -1;
0117 
0118         ecalScaleKeyResults.fillVariable(ecalScaleTemp);
0119 
0120         std::stringstream ss;
0121         ss << ecalScaleTemp;
0122         ecalScaleKey = ss.str();
0123       }
0124     }
0125 
0126     l1t::OMDSReader::QueryResults hcalKeyResults = m_omdsReader.basicQuery(
0127         "HCAL_CONF", "CMS_RCT", "RCT_CONF", "RCT_CONF.RCT_KEY", m_omdsReader.singleAttribute(rctKey));
0128 
0129     if (hcalKeyResults.queryFailed() || hcalKeyResults.numberRows() > 1)  // check query successful)
0130     {
0131       edm::LogError("L1-O2O") << "Problem with rct_conf.hcal_conf.";
0132       return;
0133     }
0134     std::string hcalKey;
0135     if (!hcalKeyResults.fillVariable(hcalScaleKey))
0136       hcalScaleKey = "NULL";
0137 
0138     paremKeyResults.fillVariable(paremKey);
0139     scaleKeyResults.fillVariable(scaleKey);
0140 
0141     pL1TriggerKey->add("L1RCTParametersRcd", "L1RCTParameters", paremKey);
0142     pL1TriggerKey->add("L1EmEtScaleRcd", "L1CaloEtScale", scaleKey);
0143     pL1TriggerKey->add("L1CaloEcalScaleRcd", "L1CaloEcalScale", ecalScaleKey);
0144     pL1TriggerKey->add("L1CaloHcalScaleRcd", "L1CaloHcalScale", hcalScaleKey);
0145   }
0146 }
0147 
0148 //define this as a plug-in
0149 DEFINE_FWK_EVENTSETUP_MODULE(RCTObjectKeysOnlineProd);