CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1GtPatternLine.cc
Go to the documentation of this file.
1 
17 // this class header
19 
20 // system include files
21 #include <sstream>
22 #include <iostream>
23 
24 // user include files
26 
27 void L1GtPatternLine::push(const std::string& prefix, uint32_t value) {
28  std::string colName = nextName(prefix);
29  // add three values for each column - the full 32bit value,
30  // one for the lower 16 bits and one for the higher 16 bits.
31  m_columns[colName] = value;
32  m_columns[colName + "_h"] = value >> 16;
33  m_columns[colName + "_l"] = value & 0xFFFF;
34 }
35 
36 void L1GtPatternLine::set(const std::string& name, uint32_t value) {
37  ColumnMap::iterator it = m_columns.find(name);
38  if(it == m_columns.end()) {
39  throw cms::Exception(__func__) << "Can't set field "
40  << name << " to " << std::hex << value
41  << ": not found";
42  }
43 
44  it->second = value;
45  m_columns[name + "_h"] = value >> 16;
46  m_columns[name + "_l"] = value & 0xFFFF;
47 }
48 
49 void L1GtPatternLine::print(std::ostream& out) const {
50  out << "BEGIN Columns: " << std::endl ;
51  for(L1GtPatternLine::ColumnMap::const_iterator it = m_columns.begin();
52  it != m_columns.end() ; ++it) {
53  out << it->first << ": " << std::hex << it->second << std::endl;
54  }
55  out << "END Columns." << std::endl ;
56 }
57 
58 bool L1GtPatternLine::has(const std::string& colname) const {
59  return m_columns.find(colname) != m_columns.end();
60 }
61 
63  int i = 1 ;
65  do
66  {
67  result = name(prefix, i++);
68  } while(has(result));
69 
70  return result;
71 }
72 
73 std::string L1GtPatternLine::name(const std::string& prefix, unsigned int i) const {
74  std::ostringstream ss;
75  ss << prefix << i;
76  return ss.str();
77 }
78 
79 uint32_t L1GtPatternLine::get(const std::string& name) const {
80  ColumnMap::const_iterator it = m_columns.find(name);
81  if(it != m_columns.end()) {
82  return it->second;
83  }
84  return 0;
85 }
int i
Definition: DBlmapReader.cc:9
boost::uint32_t get(const std::string &name) const
void print(std::ostream &out) const
std::string nextName(const std::string &prefix)
bool has(const std::string &colname) const
tuple result
Definition: query.py:137
void set(const std::string &name, boost::uint32_t value)
tuple out
Definition: dbtoconf.py:99
void push(const std::string &prefix, boost::uint32_t value)
std::string name(const std::string &prefix, unsigned int i) const
ColumnMap m_columns