Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:31:06

0001 #include "CondTools/L1Trigger/interface/L1ConfigOnlineProdBase.h"
0002 #include "CondFormats/L1TObjects/interface/L1GctJetFinderParams.h"
0003 #include "CondFormats/DataRecord/interface/L1GctJetFinderParamsRcd.h"
0004 
0005 class L1GctJetFinderParamsOnlineProd : public L1ConfigOnlineProdBase<L1GctJetFinderParamsRcd, L1GctJetFinderParams> {
0006 public:
0007   L1GctJetFinderParamsOnlineProd(const edm::ParameterSet& iConfig)
0008       : L1ConfigOnlineProdBase<L1GctJetFinderParamsRcd, L1GctJetFinderParams>(iConfig) {}
0009   ~L1GctJetFinderParamsOnlineProd() override {}
0010 
0011   std::unique_ptr<L1GctJetFinderParams> newObject(const std::string& objectKey) override;
0012 
0013 private:
0014 };
0015 
0016 std::unique_ptr<L1GctJetFinderParams> L1GctJetFinderParamsOnlineProd::newObject(const std::string& objectKey) {
0017   // Execute SQL queries to get data from OMDS (using key) and make C++ object
0018   // Example: SELECT A_PARAMETER FROM CMS_XXX.XXX_CONF WHERE XXX_CONF.XXX_KEY = objectKey
0019 
0020   // get parameters
0021   std::vector<std::string> columns;
0022   columns.push_back("GCT_RGN_ET_LSB");
0023   columns.push_back("GCT_HT_LSB");
0024   columns.push_back("GCT_CJET_SEED_ET_THRESHOLD");
0025   columns.push_back("GCT_TJET_SEED_ET_THRESHOLD");
0026   columns.push_back("GCT_FJET_SEED_ET_THRESHOLD");
0027   columns.push_back("GCT_HT_JET_ET_THRESHOLD");
0028   columns.push_back("GCT_MHT_JET_ET_THRESHOLD");
0029   columns.push_back("GCT_TAU_ISO_ET_THRESHOLD");
0030   columns.push_back("GCT_CEN_JET_ETA_MAX");
0031   columns.push_back("GCT_JET_CORR_KEY");
0032 
0033   l1t::OMDSReader::QueryResults results = m_omdsReader.basicQuery(
0034       columns, "CMS_GCT", "GCT_PHYS_PARAMS", "GCT_PHYS_PARAMS.CONFIG_KEY", m_omdsReader.singleAttribute(objectKey));
0035 
0036   if (results.queryFailed())  // check if query was successful
0037   {
0038     edm::LogError("L1-O2O") << "Problem with L1GctJetFinderParams key.";
0039     return std::unique_ptr<L1GctJetFinderParams>();
0040   }
0041 
0042   // fill values
0043   double rgnEtLsb = 0.;
0044   double htLsb = 0.;
0045   double cJetSeed = 0.;
0046   double tJetSeed = 0.;
0047   double fJetSeed = 0.;
0048   double tauIsoEtThresh = 0.;
0049   double htJetEtThresh = 0.;
0050   double mhtJetEtThresh = 0.;
0051   short int etaBoundary = 7;
0052   int corrType = 0;
0053   std::vector<std::vector<double> > jetCorrCoeffs;
0054   std::vector<std::vector<double> > tauCorrCoeffs;
0055   bool convertToEnergy = false;              // Not in OMDS
0056   std::vector<double> energyConvCoeffs(11);  // Not in OMDS
0057   std::string jetCorrKey;
0058 
0059   results.fillVariable("GCT_RGN_ET_LSB", rgnEtLsb);
0060   results.fillVariable("GCT_HT_LSB", htLsb);
0061   results.fillVariable("GCT_CJET_SEED_ET_THRESHOLD", cJetSeed);
0062   results.fillVariable("GCT_TJET_SEED_ET_THRESHOLD", tJetSeed);
0063   results.fillVariable("GCT_FJET_SEED_ET_THRESHOLD", fJetSeed);
0064   results.fillVariable("GCT_TAU_ISO_ET_THRESHOLD", tauIsoEtThresh);
0065   results.fillVariable("GCT_HT_JET_ET_THRESHOLD", htJetEtThresh);
0066   results.fillVariable("GCT_MHT_JET_ET_THRESHOLD", mhtJetEtThresh);
0067   results.fillVariable("GCT_CEN_JET_ETA_MAX", etaBoundary);
0068   results.fillVariable("GCT_JET_CORR_KEY", jetCorrKey);
0069 
0070   edm::LogInfo("L1-O2O") << "L1 jet corrections key : " << jetCorrKey << std::endl;
0071 
0072   // get jet corr coefficients
0073   std::vector<std::string> jetCorrColumns;
0074   jetCorrColumns.push_back("GCT_JETCORR_TYPE");
0075   jetCorrColumns.push_back("GCT_JETCORR_NETA_10");
0076   jetCorrColumns.push_back("GCT_JETCORR_NETA_9");
0077   jetCorrColumns.push_back("GCT_JETCORR_NETA_8");
0078   jetCorrColumns.push_back("GCT_JETCORR_NETA_7");
0079   jetCorrColumns.push_back("GCT_JETCORR_NETA_6");
0080   jetCorrColumns.push_back("GCT_JETCORR_NETA_5");
0081   jetCorrColumns.push_back("GCT_JETCORR_NETA_4");
0082   jetCorrColumns.push_back("GCT_JETCORR_NETA_3");
0083   jetCorrColumns.push_back("GCT_JETCORR_NETA_2");
0084   jetCorrColumns.push_back("GCT_JETCORR_NETA_1");
0085   jetCorrColumns.push_back("GCT_JETCORR_NETA_0");
0086   jetCorrColumns.push_back("GCT_JETCORR_PETA_0");
0087   jetCorrColumns.push_back("GCT_JETCORR_PETA_1");
0088   jetCorrColumns.push_back("GCT_JETCORR_PETA_2");
0089   jetCorrColumns.push_back("GCT_JETCORR_PETA_3");
0090   jetCorrColumns.push_back("GCT_JETCORR_PETA_4");
0091   jetCorrColumns.push_back("GCT_JETCORR_PETA_5");
0092   jetCorrColumns.push_back("GCT_JETCORR_PETA_6");
0093   jetCorrColumns.push_back("GCT_JETCORR_PETA_7");
0094   jetCorrColumns.push_back("GCT_JETCORR_PETA_8");
0095   jetCorrColumns.push_back("GCT_JETCORR_PETA_9");
0096   jetCorrColumns.push_back("GCT_JETCORR_PETA_10");
0097 
0098   l1t::OMDSReader::QueryResults jetCorrResults = m_omdsReader.basicQuery(jetCorrColumns,
0099                                                                          "CMS_GCT",
0100                                                                          "GCT_JET_CORRECTIONS",
0101                                                                          "GCT_JET_CORRECTIONS.CONFIG_KEY",
0102                                                                          m_omdsReader.singleAttribute(jetCorrKey));
0103 
0104   if (jetCorrResults.queryFailed())  // check if query was successful
0105   {
0106     edm::LogError("L1-O2O") << "Problem getting L1 jet corrections";
0107     return std::unique_ptr<L1GctJetFinderParams>();
0108   }
0109 
0110   // fill jet corr type
0111   jetCorrResults.fillVariable("GCT_JETCORR_TYPE", corrType);
0112 
0113   edm::LogInfo("L1-O2O") << "L1 jet corrections type : " << corrType << std::endl;
0114 
0115   // get coefficients
0116   for (unsigned i = 0; i < L1GctJetFinderParams::NUMBER_ETA_VALUES; ++i) {
0117     // get corr key for eta value
0118     std::stringstream etaCol;
0119     etaCol << "GCT_JETCORR_NETA_" << std::dec << i;
0120     std::string etaKey;
0121     jetCorrResults.fillVariable(etaCol.str(), etaKey);
0122 
0123     std::vector<std::string> coeffColumns;
0124     coeffColumns.push_back("GCT_JETCORR_C0");
0125     coeffColumns.push_back("GCT_JETCORR_C1");
0126     coeffColumns.push_back("GCT_JETCORR_C2");
0127     coeffColumns.push_back("GCT_JETCORR_C3");
0128     coeffColumns.push_back("GCT_JETCORR_C4");
0129     coeffColumns.push_back("GCT_JETCORR_C5");
0130     coeffColumns.push_back("GCT_JETCORR_C6");
0131     coeffColumns.push_back("GCT_JETCORR_C7");
0132     coeffColumns.push_back("GCT_JETCORR_C8");
0133     coeffColumns.push_back("GCT_JETCORR_C9");
0134     coeffColumns.push_back("GCT_JETCORR_C10");
0135     coeffColumns.push_back("GCT_JETCORR_C11");
0136     coeffColumns.push_back("GCT_JETCORR_C12");
0137     coeffColumns.push_back("GCT_JETCORR_C13");
0138     coeffColumns.push_back("GCT_JETCORR_C14");
0139     coeffColumns.push_back("GCT_JETCORR_C15");
0140     coeffColumns.push_back("GCT_JETCORR_C16");
0141     coeffColumns.push_back("GCT_JETCORR_C17");
0142     coeffColumns.push_back("GCT_JETCORR_C18");
0143     coeffColumns.push_back("GCT_JETCORR_C19");
0144 
0145     l1t::OMDSReader::QueryResults jetCorrResults = m_omdsReader.basicQuery(
0146         coeffColumns, "CMS_GCT", "GCT_JET_COEFFS", "GCT_JET_COEFFS.CONFIG_KEY", m_omdsReader.singleAttribute(etaKey));
0147 
0148     if (results.queryFailed())  // check if query was successful
0149     {
0150       edm::LogError("L1-O2O") << "Problem getting L1 jet correction coefficients";
0151       return std::unique_ptr<L1GctJetFinderParams>();
0152     }
0153 
0154     // fill coeffs - TODO
0155     std::vector<double> coeffs;
0156 
0157     unsigned nCoeffs = 0;
0158     if (corrType == 0)
0159       nCoeffs = 0;
0160     else if (corrType == 2)
0161       nCoeffs = 8;  // ORCA style
0162     else if (corrType == 3)
0163       nCoeffs = 4;  // Simple
0164     else if (corrType == 4)
0165       nCoeffs = 15;  // piecewise-cubic
0166     else if (corrType == 5)
0167       nCoeffs = 6;  // PF
0168     else {
0169       edm::LogError("L1-O2O") << "Unsupported jet correction type : " << corrType;
0170       return std::unique_ptr<L1GctJetFinderParams>();
0171     }
0172 
0173     for (unsigned j = 0; j < nCoeffs; ++j) {
0174       std::stringstream coeffCol;
0175       coeffCol << "GCT_JETCORR_C" << std::dec << j;
0176       // int coeff;
0177       double coeff;
0178       jetCorrResults.fillVariable(coeffCol.str(), coeff);
0179 
0180       coeffs.push_back(coeff);
0181     }
0182 
0183     jetCorrCoeffs.push_back(coeffs);
0184 
0185     // copy to tau coeffs
0186     if (i < L1GctJetFinderParams::N_CENTRAL_ETA_VALUES)
0187       tauCorrCoeffs.push_back(coeffs);
0188   }
0189 
0190   return std::make_unique<L1GctJetFinderParams>(rgnEtLsb,
0191                                                 htLsb,
0192                                                 cJetSeed,
0193                                                 fJetSeed,
0194                                                 tJetSeed,
0195                                                 tauIsoEtThresh,
0196                                                 htJetEtThresh,
0197                                                 mhtJetEtThresh,
0198                                                 etaBoundary,
0199                                                 corrType,
0200                                                 jetCorrCoeffs,
0201                                                 tauCorrCoeffs,
0202                                                 convertToEnergy,
0203                                                 energyConvCoeffs
0204 
0205   );
0206 }
0207 
0208 DEFINE_FWK_EVENTSETUP_MODULE(L1GctJetFinderParamsOnlineProd);