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

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, GetRecoTauVFromDQM_MC_cff::next, l1t::OMDSReader::QueryResults::numberRows(), l1t::OMDSReader::QueryResults::queryFailed(), l1t::OMDSReader::singleAttribute(), AlCaHLTBitMon_QueryRunRegistry::string, and create_public_lumi_plots::transform.

Referenced by L1TMuonEndcapObjectKeysOnlineProd::fillObjectKeys(), L1TMuonGlobalParamsOnlineProd::newObject(), L1TMuonEndCapParamsOnlineProd::newObject(), L1TMuonBarrelParamsOnlineProd::newObject(), L1TCaloParamsOnlineProd::newObject(), and L1TGlobalPrescalesVetosOnlineProd::newObject().

8  {
9  if( queryColumns.size() == 0 || table.length() == 0 )
10  return std::map<std::string,std::string>();
11 
12  l1t::OMDSReader::QueryResults queryResult =
13  m_omdsReader.basicQuery( queryColumns,
14  "CMS_TRG_L1_CONF",
15  table,
16  table + ".ID",
17  m_omdsReader.singleAttribute(key)
18  ) ;
19 
20  if( queryResult.queryFailed() || queryResult.numberRows() != 1 )
21  throw std::runtime_error( std::string("Cannot get ") +
22  table +
23  ".{" +
24  std::accumulate( std::next( queryColumns.begin() ),
25  queryColumns.end(),
26  std::string( queryColumns[0] ),
27  [] (const std::string &a, const std::string &b) { return a + "," + b; }
28  ) +
29  "} for ID = " +
30  key
31  );
32 
33  std::vector<std::string> retval( queryColumns.size() );
34 
35  std::transform( queryColumns.begin(),
36  queryColumns.end(),
37  retval.begin(),
38  [ queryResult ] ( const std::string &a )
39  {
41  if( !queryResult.fillVariable(a, res) ) res = "";
42  return res;
43  }
44  );
45 
46  std::map<std::string,std::string> retvalMap;
47  for(unsigned int i=0; i<queryColumns.size(); i++)
48  retvalMap.insert( make_pair( queryColumns[i], retval[i] ) );
49 
50  return retvalMap;
51  }
bool fillVariable(const std::string &columnName, T &outputVariable) const
Definition: OMDSReader.h:311
const QueryResults singleAttribute(const T &data) const
Definition: OMDSReader.h:295
Definition: Electron.h:4
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:86
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121