CMS 3D CMS Logo

List of all members | Static Public Member Functions
l1t::OnlineDBqueryHelper Class Reference

#include <OnlineDBqueryHelper.h>

Static Public Member Functions

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)
 

Detailed Description

Definition at line 16 of file OnlineDBqueryHelper.h.

Member Function Documentation

◆ fetch()

std::map< std::string, std::string > l1t::OnlineDBqueryHelper::fetch ( const std::vector< std::string > &  queryColumns,
const std::string &  table,
const std::string &  key,
l1t::OMDSReader m_omdsReader 
)
static

Definition at line 3 of file OnlineDBqueryHelper.cc.

References a, b, l1t::OMDSReader::basicQuery(), l1t::OMDSReader::QueryResults::fillVariable(), mps_fire::i, crabWrapper::key, GetRecoTauVFromDQM_MC_cff::next, l1t::OMDSReader::QueryResults::numberRows(), l1t::OMDSReader::QueryResults::queryFailed(), l1t::OMDSReader::singleAttribute(), AlCaHLTBitMon_QueryRunRegistry::string, TableParser::table, and HcalDetIdTransform::transform().

Referenced by L1TMuonOverlapObjectKeysOnlineProd::fillObjectKeys(), L1TMuonEndCapObjectKeysOnlineProd::fillObjectKeys(), L1TMuonEndCapParamsOnlineProd::newObject(), L1TMuonGlobalParamsOnlineProd::newObject(), L1TMuonBarrelParamsOnlineProd::newObject(), L1TMuonOverlapFwVersionOnlineProd::newObject(), L1TCaloParamsOnlineProd::newObject(), and L1TGlobalPrescalesVetosOnlineProd::newObject().

6  {
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 }
const QueryResults singleAttribute(const T &data) const
Definition: OMDSReader.h:259
Definition: Electron.h:6
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
bool fillVariable(const std::string &columnName, T &outputVariable) const
Definition: OMDSReader.h:274
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
unsigned transform(const HcalDetId &id, unsigned transformCode)