CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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) {
24  std::string res;
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 }
bool fillVariable(const std::string &columnName, T &outputVariable) const
Definition: OMDSReader.h:274
const QueryResults singleAttribute(const T &data) const
Definition: OMDSReader.h:259
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)
tuple key
prepare the HTCondor submission files and eventually submit them
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
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119
unsigned transform(const HcalDetId &id, unsigned transformCode)