File indexing completed on 2024-04-06 12:22:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include "L1TriggerConfig/L1GtConfigProducers/interface/L1GtPrescaleFactorsTechTrigConfigOnlineProd.h"
0017
0018
0019 #include <vector>
0020
0021
0022 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0023
0024
0025 L1GtPrescaleFactorsTechTrigConfigOnlineProd::L1GtPrescaleFactorsTechTrigConfigOnlineProd(const edm::ParameterSet& parSet)
0026 : L1ConfigOnlineProdBase<L1GtPrescaleFactorsTechTrigRcd, L1GtPrescaleFactors>(parSet),
0027 m_isDebugEnabled(edm::isDebugEnabled()) {
0028
0029 }
0030
0031
0032 L1GtPrescaleFactorsTechTrigConfigOnlineProd::~L1GtPrescaleFactorsTechTrigConfigOnlineProd() {
0033
0034 }
0035
0036
0037
0038 std::unique_ptr<L1GtPrescaleFactors> L1GtPrescaleFactorsTechTrigConfigOnlineProd::newObject(
0039 const std::string& objectKey) {
0040
0041 m_isDebugEnabled = edm::isDebugEnabled();
0042
0043 auto pL1GtPrescaleFactors = std::make_unique<L1GtPrescaleFactors>();
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054 const std::string gtSchema = "CMS_GT";
0055
0056
0057
0058
0059 std::vector<std::string> columnsView;
0060 columnsView.push_back("PRESCALE_INDEX");
0061 columnsView.push_back("PRESCALE_FACTORS_TT_FK");
0062
0063 l1t::OMDSReader::QueryResults resultsView = m_omdsReader.basicQueryView(columnsView,
0064 gtSchema,
0065 "GT_RUN_SETTINGS_PRESC_VIEW",
0066 "GT_RUN_SETTINGS_PRESC_VIEW.ID",
0067 m_omdsReader.singleAttribute(objectKey));
0068
0069
0070 if (resultsView.queryFailed()) {
0071 edm::LogError("L1-O2O") << "Problem to get content of GT_RUN_SETTINGS_PRESC_VIEW "
0072 << "for GT_RUN_SETTINGS_PRESC_VIEW.ID: " << objectKey;
0073 return pL1GtPrescaleFactors;
0074 }
0075
0076
0077
0078 std::string objectKeyPrescaleFactorsSet = "WRONG_KEY_INITIAL";
0079 short prescaleFactorsSetIndex = 9999;
0080
0081 int resultsViewRows = resultsView.numberRows();
0082 if (m_isDebugEnabled) {
0083 LogTrace("L1GtPrescaleFactorsTechTrigConfigOnlineProd")
0084 << "\nFound " << resultsViewRows << " prescale factors sets for \n "
0085 << "GT_RUN_SETTINGS_PRESC_VIEW.ID = " << objectKey << "\n"
0086 << std::endl;
0087 }
0088
0089
0090 std::vector<std::vector<int> > pFactors;
0091 pFactors.reserve(resultsViewRows);
0092
0093 int countSet = -1;
0094
0095 for (int iRow = 0; iRow < resultsViewRows; ++iRow) {
0096 for (std::vector<std::string>::const_iterator constIt = columnsView.begin(); constIt != columnsView.end();
0097 ++constIt) {
0098 if ((*constIt) == "PRESCALE_INDEX") {
0099 resultsView.fillVariableFromRow(*constIt, iRow, prescaleFactorsSetIndex);
0100 } else if ((*constIt) == "PRESCALE_FACTORS_TT_FK") {
0101 resultsView.fillVariableFromRow(*constIt, iRow, objectKeyPrescaleFactorsSet);
0102 } else {
0103 LogTrace("L1GtPrescaleFactorsTechTrigConfigOnlineProd")
0104 << "\nUnknown field " << (*constIt) << " requested for columns in GT_RUN_SETTINGS_PRESC_VIEW" << std::endl;
0105 }
0106 }
0107
0108 if (m_isDebugEnabled) {
0109 LogTrace("L1GtPrescaleFactorsTechTrigConfigOnlineProd")
0110 << "\nFound prescale factors set: \n index = " << prescaleFactorsSetIndex
0111 << "\n PRESCALE_FACTORS_TT_FK = " << objectKeyPrescaleFactorsSet << "\n"
0112 << std::endl;
0113 }
0114
0115
0116
0117
0118
0119
0120
0121 const std::vector<std::string>& columns = m_omdsReader.columnNames(gtSchema, "GT_FDL_PRESCALE_FACTORS_TT");
0122
0123 if (m_isDebugEnabled) {
0124 LogTrace("L1GtPrescaleFactorsTechTrigConfigOnlineProd")
0125 << "\nColumn names for GT_FDL_PRESCALE_FACTORS_TT" << std::endl;
0126
0127 for (std::vector<std::string>::const_iterator iter = columns.begin(); iter != columns.end(); iter++) {
0128 LogTrace("L1GtPrescaleFactorsTechTrigConfigOnlineProd") << (*iter) << std::endl;
0129 }
0130 }
0131
0132 l1t::OMDSReader::QueryResults results =
0133 m_omdsReader.basicQuery(columns,
0134 gtSchema,
0135 "GT_FDL_PRESCALE_FACTORS_TT",
0136 "GT_FDL_PRESCALE_FACTORS_TT.ID",
0137 m_omdsReader.singleAttribute(objectKeyPrescaleFactorsSet));
0138
0139
0140 if (results.queryFailed()) {
0141 edm::LogError("L1-O2O") << "Problem with L1GtPrescaleFactorsTechTrigRcd key:" << objectKeyPrescaleFactorsSet;
0142 return pL1GtPrescaleFactors;
0143 }
0144
0145
0146 countSet++;
0147 if (prescaleFactorsSetIndex != countSet) {
0148 edm::LogError("L1-O2O") << "L1GtPrescaleFactorsTechTrig has unordered sets PRESCALE_INDEX in DB for\n"
0149 << " GT_RUN_SETTINGS_PRESC_VIEW.ID = " << objectKey << "\n"
0150 << std::endl;
0151 return pL1GtPrescaleFactors;
0152 }
0153
0154
0155 int pfSetSize = columns.size() - 1;
0156 std::vector<int> pfSet(pfSetSize, 0);
0157
0158 for (int i = 0; i < pfSetSize; i++) {
0159 results.fillVariable(columns[i + 1], pfSet[i]);
0160 }
0161
0162 pFactors.push_back(pfSet);
0163 }
0164
0165
0166
0167 pL1GtPrescaleFactors->setGtPrescaleFactors(pFactors);
0168
0169 if (m_isDebugEnabled) {
0170 std::ostringstream myCoutStream;
0171 pL1GtPrescaleFactors->print(myCoutStream);
0172 LogTrace("L1GtPrescaleFactorsTechTrigConfigOnlineProd")
0173 << "\nThe following L1GtPrescaleFactorsTechTrigRcd record was read from OMDS: \n"
0174 << myCoutStream.str() << "\n"
0175 << std::endl;
0176 }
0177
0178 return pL1GtPrescaleFactors;
0179 }
0180
0181 DEFINE_FWK_EVENTSETUP_MODULE(L1GtPrescaleFactorsTechTrigConfigOnlineProd);