File indexing completed on 2024-04-06 12:20:03
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include "L1Trigger/GlobalTriggerAnalyzer/interface/L1GtPatternLine.h"
0017
0018
0019 #include <sstream>
0020 #include <iostream>
0021
0022
0023 #include "FWCore/Utilities/interface/Exception.h"
0024
0025 void L1GtPatternLine::push(const std::string& prefix, uint32_t value) {
0026 std::string colName = nextName(prefix);
0027
0028
0029 m_columns[colName] = value;
0030 m_columns[colName + "_h"] = value >> 16;
0031 m_columns[colName + "_l"] = value & 0xFFFF;
0032 }
0033
0034 void L1GtPatternLine::set(const std::string& name, uint32_t value) {
0035 ColumnMap::iterator it = m_columns.find(name);
0036 if (it == m_columns.end()) {
0037 throw cms::Exception(__func__) << "Can't set field " << name << " to " << std::hex << value << ": not found";
0038 }
0039
0040 it->second = value;
0041 m_columns[name + "_h"] = value >> 16;
0042 m_columns[name + "_l"] = value & 0xFFFF;
0043 }
0044
0045 void L1GtPatternLine::print(std::ostream& out) const {
0046 out << "BEGIN Columns: " << std::endl;
0047 for (L1GtPatternLine::ColumnMap::const_iterator it = m_columns.begin(); it != m_columns.end(); ++it) {
0048 out << it->first << ": " << std::hex << it->second << std::endl;
0049 }
0050 out << "END Columns." << std::endl;
0051 }
0052
0053 bool L1GtPatternLine::has(const std::string& colname) const { return m_columns.find(colname) != m_columns.end(); }
0054
0055 std::string L1GtPatternLine::nextName(const std::string& prefix) {
0056 int i = 1;
0057 std::string result;
0058 do {
0059 result = name(prefix, i++);
0060 } while (has(result));
0061
0062 return result;
0063 }
0064
0065 std::string L1GtPatternLine::name(const std::string& prefix, unsigned int i) const {
0066 std::ostringstream ss;
0067 ss << prefix << i;
0068 return ss.str();
0069 }
0070
0071 uint32_t L1GtPatternLine::get(const std::string& name) const {
0072 ColumnMap::const_iterator it = m_columns.find(name);
0073 if (it != m_columns.end()) {
0074 return it->second;
0075 }
0076 return 0;
0077 }