Go to the documentation of this file.00001
00017
00018 #include "L1TriggerConfig/L1GtConfigProducers/interface/L1GtPrescaleFactorsTechTrigConfigOnlineProd.h"
00019
00020
00021 #include <vector>
00022
00023 #include "boost/lexical_cast.hpp"
00024
00025
00026 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00027
00028
00029 L1GtPrescaleFactorsTechTrigConfigOnlineProd::L1GtPrescaleFactorsTechTrigConfigOnlineProd(
00030 const edm::ParameterSet& parSet) :
00031 L1ConfigOnlineProdBase<L1GtPrescaleFactorsTechTrigRcd, L1GtPrescaleFactors> (parSet),
00032 m_isDebugEnabled(edm::isDebugEnabled()) {
00033
00034
00035
00036 }
00037
00038
00039 L1GtPrescaleFactorsTechTrigConfigOnlineProd::~L1GtPrescaleFactorsTechTrigConfigOnlineProd() {
00040
00041
00042
00043 }
00044
00045
00046
00047 boost::shared_ptr<L1GtPrescaleFactors> L1GtPrescaleFactorsTechTrigConfigOnlineProd::newObject(
00048 const std::string& objectKey) {
00049
00050
00051 m_isDebugEnabled = edm::isDebugEnabled();
00052
00053
00054 boost::shared_ptr<L1GtPrescaleFactors> pL1GtPrescaleFactors =
00055 boost::shared_ptr<L1GtPrescaleFactors>(new L1GtPrescaleFactors());
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 const std::string gtSchema = "CMS_GT";
00067
00068
00069
00070
00071 std::vector<std::string> columnsView;
00072 columnsView.push_back("PRESCALE_INDEX");
00073 columnsView.push_back("PRESCALE_FACTORS_TT_FK");
00074
00075 l1t::OMDSReader::QueryResults resultsView = m_omdsReader.basicQueryView(
00076 columnsView, gtSchema, "GT_RUN_SETTINGS_PRESC_VIEW",
00077 "GT_RUN_SETTINGS_PRESC_VIEW.ID", m_omdsReader.singleAttribute(
00078 objectKey));
00079
00080
00081 if (resultsView.queryFailed()) {
00082 edm::LogError("L1-O2O")
00083 << "Problem to get content of GT_RUN_SETTINGS_PRESC_VIEW "
00084 << "for GT_RUN_SETTINGS_PRESC_VIEW.ID: " << objectKey;
00085 return pL1GtPrescaleFactors;
00086 }
00087
00088
00089
00090 std::string objectKeyPrescaleFactorsSet = "WRONG_KEY_INITIAL";
00091 short prescaleFactorsSetIndex = 9999;
00092
00093 int resultsViewRows = resultsView.numberRows();
00094 if (m_isDebugEnabled) {
00095 LogTrace("L1GtPrescaleFactorsTechTrigConfigOnlineProd") << "\nFound "
00096 << resultsViewRows << " prescale factors sets for \n "
00097 << "GT_RUN_SETTINGS_PRESC_VIEW.ID = " << objectKey << "\n"
00098 << std::endl;
00099 }
00100
00101
00102 std::vector<std::vector<int> > pFactors;
00103 pFactors.reserve(resultsViewRows);
00104
00105 int countSet = -1;
00106
00107 for (int iRow = 0; iRow < resultsViewRows; ++iRow) {
00108
00109 for (std::vector<std::string>::const_iterator constIt =
00110 columnsView.begin(); constIt != columnsView.end(); ++constIt) {
00111
00112 if ((*constIt) == "PRESCALE_INDEX") {
00113 resultsView.fillVariableFromRow(*constIt, iRow,
00114 prescaleFactorsSetIndex);
00115 } else if ((*constIt) == "PRESCALE_FACTORS_TT_FK") {
00116 resultsView.fillVariableFromRow(*constIt, iRow,
00117 objectKeyPrescaleFactorsSet);
00118 } else {
00119
00120 LogTrace("L1GtPrescaleFactorsTechTrigConfigOnlineProd")
00121 << "\nUnknown field " << (*constIt)
00122 << " requested for columns in GT_RUN_SETTINGS_PRESC_VIEW"
00123 << std::endl;
00124
00125 }
00126 }
00127
00128 if (m_isDebugEnabled) {
00129 LogTrace("L1GtPrescaleFactorsTechTrigConfigOnlineProd")
00130 << "\nFound prescale factors set: \n index = "
00131 << prescaleFactorsSetIndex
00132 << "\n PRESCALE_FACTORS_TT_FK = "
00133 << objectKeyPrescaleFactorsSet << "\n" << std::endl;
00134 }
00135
00136
00137
00138
00139
00140
00141
00142
00143 const std::vector<std::string>& columns = m_omdsReader.columnNames(
00144 gtSchema, "GT_FDL_PRESCALE_FACTORS_TT");
00145
00146 if (m_isDebugEnabled) {
00147 LogTrace("L1GtPrescaleFactorsTechTrigConfigOnlineProd")
00148 << "\nColumn names for GT_FDL_PRESCALE_FACTORS_TT"
00149 << std::endl;
00150
00151 for (std::vector<std::string>::const_iterator iter =
00152 columns.begin(); iter != columns.end(); iter++) {
00153 LogTrace("L1GtPrescaleFactorsTechTrigConfigOnlineProd")
00154 << (*iter) << std::endl;
00155
00156 }
00157 }
00158
00159 l1t::OMDSReader::QueryResults results = m_omdsReader.basicQuery(
00160 columns, gtSchema, "GT_FDL_PRESCALE_FACTORS_TT",
00161 "GT_FDL_PRESCALE_FACTORS_TT.ID",
00162 m_omdsReader.singleAttribute(objectKeyPrescaleFactorsSet));
00163
00164
00165 if (results.queryFailed()) {
00166 edm::LogError("L1-O2O")
00167 << "Problem with L1GtPrescaleFactorsTechTrigRcd key:"
00168 << objectKeyPrescaleFactorsSet;
00169 return pL1GtPrescaleFactors;
00170 }
00171
00172
00173
00174
00175
00176 countSet++;
00177 if (prescaleFactorsSetIndex != countSet) {
00178 edm::LogError("L1-O2O")
00179 << "L1GtPrescaleFactorsTechTrig has unordered sets PRESCALE_INDEX in DB for\n"
00180 << " GT_RUN_SETTINGS_PRESC_VIEW.ID = " << objectKey << "\n"
00181 << std::endl;
00182 return pL1GtPrescaleFactors;
00183
00184 }
00185
00186
00187
00188 int pfSetSize = columns.size() - 1;
00189 std::vector<int> pfSet(pfSetSize, 0);
00190
00191 for (int i = 0; i < pfSetSize; i++) {
00192 results.fillVariable(columns[i + 1], pfSet[i]);
00193 }
00194
00195 pFactors.push_back(pfSet);
00196
00197 }
00198
00199
00200
00201 pL1GtPrescaleFactors->setGtPrescaleFactors(pFactors);
00202
00203 if (m_isDebugEnabled) {
00204 std::ostringstream myCoutStream;
00205 pL1GtPrescaleFactors->print(myCoutStream);
00206 LogTrace("L1GtPrescaleFactorsTechTrigConfigOnlineProd")
00207 << "\nThe following L1GtPrescaleFactorsTechTrigRcd record was read from OMDS: \n"
00208 << myCoutStream.str() << "\n" << std::endl;
00209 }
00210
00211 return pL1GtPrescaleFactors;
00212 }
00213
00214 DEFINE_FWK_EVENTSETUP_MODULE( L1GtPrescaleFactorsTechTrigConfigOnlineProd);