CMS 3D CMS Logo

OnlineDBqueryHelper.cc
Go to the documentation of this file.
1 #include "OnlineDBqueryHelper.h"
2 
3 std::map<std::string, std::string> l1t::OnlineDBqueryHelper::fetch(const std::vector<std::string> &queryColumns,
4  const std::string &table,
5  const std::string &key,
6  l1t::OMDSReader &m_omdsReader) {
7  if (queryColumns.empty() || table.length() == 0)
8  return std::map<std::string, std::string>();
9 
10  l1t::OMDSReader::QueryResults queryResult =
11  m_omdsReader.basicQuery(queryColumns, "CMS_TRG_L1_CONF", table, table + ".ID", m_omdsReader.singleAttribute(key));
12 
13  if (queryResult.queryFailed() || queryResult.numberRows() != 1)
14  throw std::runtime_error(std::string("Cannot get ") + table + ".{" +
15  std::accumulate(std::next(queryColumns.begin()),
16  queryColumns.end(),
17  std::string(queryColumns[0]),
18  [](const std::string &a, const std::string &b) { return a + "," + b; }) +
19  "} for ID = " + key);
20 
21  std::vector<std::string> retval(queryColumns.size());
22 
23  std::transform(queryColumns.begin(), queryColumns.end(), retval.begin(), [queryResult](const std::string &a) {
25  if (!queryResult.fillVariable(a, res))
26  res = "";
27  return res;
28  });
29 
30  std::map<std::string, std::string> retvalMap;
31  for (unsigned int i = 0; i < queryColumns.size(); i++)
32  retvalMap.insert(make_pair(queryColumns[i], retval[i]));
33 
34  return retvalMap;
35 }
l1t::OMDSReader::QueryResults
Definition: OMDSReader.h:49
mps_fire.i
i
Definition: mps_fire.py:428
l1t::OMDSReader
Definition: OMDSReader.h:42
l1t::OnlineDBqueryHelper::fetch
static std::map< std::string, std::string > fetch(const std::vector< std::string > &queryColumns, const std::string &table, const std::string &key, l1t::OMDSReader &m_omdsReader)
Definition: OnlineDBqueryHelper.cc:3
l1t::OMDSReader::singleAttribute
const QueryResults singleAttribute(const T &data) const
Definition: OMDSReader.h:259
l1t::OMDSReader::QueryResults::fillVariable
bool fillVariable(const std::string &columnName, T &outputVariable) const
Definition: OMDSReader.h:274
HcalDetIdTransform::transform
unsigned transform(const HcalDetId &id, unsigned transformCode)
Definition: HcalDetIdTransform.cc:7
b
double b
Definition: hdecay.h:118
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
OnlineDBqueryHelper.h
a
double a
Definition: hdecay.h:119
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
res
Definition: Electron.h:6
l1t::OMDSReader::QueryResults::queryFailed
bool queryFailed() const
Definition: OMDSReader.h:59
TableParser.table
table
Definition: TableParser.py:111
crabWrapper.key
key
Definition: crabWrapper.py:19
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31