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