CMS 3D CMS Logo

L1GtPrescaleFactorsAlgoTrigConfigOnlineProd.cc
Go to the documentation of this file.
1 
15 // this class header
17 
18 // system include files
19 #include <vector>
20 
21 #include "boost/lexical_cast.hpp"
22 
23 // user include files
25 
26 // constructor
29  m_isDebugEnabled(edm::isDebugEnabled()) {
30  // empty
31 }
32 
33 // destructor
35  // empty
36 }
37 
38 // public methods
39 
40 std::unique_ptr<L1GtPrescaleFactors> L1GtPrescaleFactorsAlgoTrigConfigOnlineProd::newObject(
41  const std::string& objectKey) {
42  // FIXME seems to not work anymore in constructor...
44 
45  auto pL1GtPrescaleFactors = std::make_unique<L1GtPrescaleFactors>();
46 
47  // Procedure:
48  // objectKey received as input is GT_RUN_SETTINGS_FK
49  //
50  // get from GT_RUN_SETTINGS_PRESC_VIEW the PRESCALE_FACTORS_ALGO_FK and the index PRESCALE_INDEX
51  // for the GT_RUN_SETTINGS_FK
52  //
53  // get the prescale factors for key PRESCALE_FACTORS_ALGO_FK
54  // from GT_FDL_PRESCALE_FACTORS_ALGO table
55 
56  const std::string gtSchema = "CMS_GT";
57 
58  // select * from CMS_GT.GT_RUN_SETTINGS_PRESC_VIEW
59  // where GT_RUN_SETTINGS_PRESC_VIEW.ID = objectKey
60 
61  std::vector<std::string> columnsView;
62  columnsView.push_back("PRESCALE_INDEX");
63  columnsView.push_back("PRESCALE_FACTORS_ALGO_FK");
64 
66  gtSchema,
67  "GT_RUN_SETTINGS_PRESC_VIEW",
68  "GT_RUN_SETTINGS_PRESC_VIEW.ID",
69  m_omdsReader.singleAttribute(objectKey));
70 
71  // check if query was successful
72  if (resultsView.queryFailed()) {
73  edm::LogError("L1-O2O") << "Problem to get content of GT_RUN_SETTINGS_PRESC_VIEW "
74  << "for GT_RUN_SETTINGS_PRESC_VIEW.ID: " << objectKey;
75  return pL1GtPrescaleFactors;
76  }
77 
78  // retrieve PRESCALE_INDEX and PRESCALE_FACTORS_ALGO_FK for GT_RUN_SETTINGS_FK
79 
80  std::string objectKeyPrescaleFactorsSet = "WRONG_KEY_INITIAL";
81  short prescaleFactorsSetIndex = 9999;
82 
83  int resultsViewRows = resultsView.numberRows();
84  if (m_isDebugEnabled) {
85  LogTrace("L1GtPrescaleFactorsAlgoTrigConfigOnlineProd")
86  << "\nFound " << resultsViewRows << " prescale factors sets for \n "
87  << "GT_RUN_SETTINGS_PRESC_VIEW.ID = " << objectKey << "\n"
88  << std::endl;
89  }
90 
91  // vector to be filled (resultsViewRows prescale factors sets)
92  std::vector<std::vector<int> > pFactors;
93  pFactors.reserve(resultsViewRows);
94 
95  int countSet = -1;
96 
97  for (int iRow = 0; iRow < resultsViewRows; ++iRow) {
98  for (std::vector<std::string>::const_iterator constIt = columnsView.begin(); constIt != columnsView.end();
99  ++constIt) {
100  if ((*constIt) == "PRESCALE_INDEX") {
101  resultsView.fillVariableFromRow(*constIt, iRow, prescaleFactorsSetIndex);
102  } else if ((*constIt) == "PRESCALE_FACTORS_ALGO_FK") {
103  resultsView.fillVariableFromRow(*constIt, iRow, objectKeyPrescaleFactorsSet);
104  } else {
105  LogTrace("L1GtPrescaleFactorsAlgoTrigConfigOnlineProd")
106  << "\nUnknown field " << (*constIt) << " requested for columns in GT_RUN_SETTINGS_PRESC_VIEW" << std::endl;
107  }
108  }
109 
110  if (m_isDebugEnabled) {
111  LogTrace("L1GtPrescaleFactorsAlgoTrigConfigOnlineProd")
112  << "\nFound prescale factors set: \n index = " << prescaleFactorsSetIndex
113  << "\n PRESCALE_FACTORS_ALGO_FK = " << objectKeyPrescaleFactorsSet << "\n"
114  << std::endl;
115  }
116 
117  // retrive now the prescale factors for PRESCALE_FACTORS_ALGO_FK
118 
119  // SQL query:
120  //
121  // select * from CMS_GT.GT_FDL_PRESCALE_FACTORS_ALGO
122  // WHERE GT_FDL_PRESCALE_FACTORS_ALGO.ID = objectKeyPrescaleFactorsSet
123  const std::vector<std::string>& columns = m_omdsReader.columnNames(gtSchema, "GT_FDL_PRESCALE_FACTORS_ALGO");
124 
125  if (m_isDebugEnabled) {
126  LogTrace("L1GtPrescaleFactorsAlgoTrigConfigOnlineProd")
127  << "\nColumn names for GT_FDL_PRESCALE_FACTORS_ALGO" << std::endl;
128 
129  for (std::vector<std::string>::const_iterator iter = columns.begin(); iter != columns.end(); iter++) {
130  LogTrace("L1GtPrescaleFactorsAlgoTrigConfigOnlineProd") << (*iter) << std::endl;
131  }
132  }
133 
136  gtSchema,
137  "GT_FDL_PRESCALE_FACTORS_ALGO",
138  "GT_FDL_PRESCALE_FACTORS_ALGO.ID",
139  m_omdsReader.singleAttribute(objectKeyPrescaleFactorsSet));
140 
141  // check if query was successful
142  if (results.queryFailed()) {
143  edm::LogError("L1-O2O") << "Problem with L1GtPrescaleFactorsAlgoTrigRcd key:" << objectKeyPrescaleFactorsSet;
144  return pL1GtPrescaleFactors;
145  }
146 
147  // check if set indices are ordered, starting from 0 (initial value for countSet is -1)
148  countSet++;
149  if (prescaleFactorsSetIndex != countSet) {
150  edm::LogError("L1-O2O") << "L1GtPrescaleFactorsAlgoTrig has unordered sets PRESCALE_INDEX in DB for\n"
151  << " GT_RUN_SETTINGS_PRESC_VIEW.ID = " << objectKey << "\n"
152  << std::endl;
153  return pL1GtPrescaleFactors;
154  }
155 
156  // fill one set of prescale factors
157  int pfSetSize = columns.size() - 1; // table ID is also in columns
158  std::vector<int> pfSet(pfSetSize, 0);
159 
160  for (int i = 0; i < pfSetSize; i++) {
161  results.fillVariable(columns[i + 1], pfSet[i]);
162  }
163 
164  pFactors.push_back(pfSet);
165  }
166 
167  // fill the record
168 
169  pL1GtPrescaleFactors->setGtPrescaleFactors(pFactors);
170 
171  if (m_isDebugEnabled) {
172  std::ostringstream myCoutStream;
173  pL1GtPrescaleFactors->print(myCoutStream);
174  LogTrace("L1GtPrescaleFactorsAlgoTrigConfigOnlineProd")
175  << "\nThe following L1GtPrescaleFactorsAlgoTrigRcd record was read from OMDS: \n"
176  << myCoutStream.str() << "\n"
177  << std::endl;
178  }
179 
180  return pL1GtPrescaleFactors;
181 }
182 
l1t::OMDSReader::QueryResults
Definition: OMDSReader.h:49
mps_fire.i
i
Definition: mps_fire.py:428
L1GtPrescaleFactors
Definition: L1GtPrescaleFactors.h:32
L1GtPrescaleFactorsAlgoTrigConfigOnlineProd::m_isDebugEnabled
bool m_isDebugEnabled
Definition: L1GtPrescaleFactorsAlgoTrigConfigOnlineProd.h:45
MessageLogger.h
L1ConfigOnlineProdBase< L1GtPrescaleFactorsAlgoTrigRcd, L1GtPrescaleFactors >::m_omdsReader
l1t::OMDSReader m_omdsReader
Definition: L1ConfigOnlineProdBase.h:65
edm
HLT enums.
Definition: AlignableModifier.h:19
L1GtPrescaleFactorsAlgoTrigConfigOnlineProd::~L1GtPrescaleFactorsAlgoTrigConfigOnlineProd
~L1GtPrescaleFactorsAlgoTrigConfigOnlineProd() override
destructor
Definition: L1GtPrescaleFactorsAlgoTrigConfigOnlineProd.cc:34
bookConverter.results
results
Definition: bookConverter.py:144
l1t::OMDSReader::singleAttribute
const QueryResults singleAttribute(const T &data) const
Definition: OMDSReader.h:259
L1ConfigOnlineProdBase
Definition: L1ConfigOnlineProdBase.h:52
l1t::OMDSReader::QueryResults::fillVariableFromRow
bool fillVariableFromRow(const std::string &columnName, int rowNumber, T &outputVariable) const
Definition: OMDSReader.h:279
l1t::OMDSReader::columnNames
std::vector< std::string > columnNames(const std::string &schemaName, const std::string &tableName)
Definition: OMDSReader.cc:138
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
L1GtPrescaleFactorsAlgoTrigConfigOnlineProd::L1GtPrescaleFactorsAlgoTrigConfigOnlineProd
L1GtPrescaleFactorsAlgoTrigConfigOnlineProd(const edm::ParameterSet &)
constructor
Definition: L1GtPrescaleFactorsAlgoTrigConfigOnlineProd.cc:27
edm::ParameterSet
Definition: ParameterSet.h:47
L1GtPrescaleFactorsAlgoTrigConfigOnlineProd::newObject
std::unique_ptr< L1GtPrescaleFactors > newObject(const std::string &objectKey) override
public methods
Definition: L1GtPrescaleFactorsAlgoTrigConfigOnlineProd.cc:40
L1GtPrescaleFactorsAlgoTrigConfigOnlineProd
Definition: L1GtPrescaleFactorsAlgoTrigConfigOnlineProd.h:32
l1t::OMDSReader::QueryResults::numberRows
int numberRows() const
Definition: OMDSReader.h:60
l1t::OMDSReader::basicQuery
const QueryResults basicQuery(const std::vector< std::string > &columnNames, const std::string &schemaName, const std::string &tableName, const std::string &conditionLHS="", const QueryResults conditionRHS=QueryResults(), const std::string &conditionRHSName="")
Definition: OMDSReader.cc:75
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
mps_check.columns
columns
Definition: mps_check.py:244
l1t::OMDSReader::QueryResults::queryFailed
bool queryFailed() const
Definition: OMDSReader.h:59
edm::isDebugEnabled
bool isDebugEnabled()
Definition: MessageLogger.cc:12
l1t::OMDSReader::basicQueryView
const QueryResults basicQueryView(const std::vector< std::string > &columnNames, const std::string &schemaName, const std::string &viewName, const std::string &conditionLHS="", const QueryResults conditionRHS=QueryResults(), const std::string &conditionRHSName="")
Definition: OMDSReader.cc:158
L1GtPrescaleFactorsAlgoTrigConfigOnlineProd.h
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
L1GtPrescaleFactorsAlgoTrigRcd
Definition: L1GtPrescaleFactorsAlgoTrigRcd.h:38