Go to the documentation of this file.00001
00017
00018 #include "L1Trigger/GlobalTriggerAnalyzer/interface/L1GtPatternLine.h"
00019
00020
00021 #include <sstream>
00022 #include <iostream>
00023
00024
00025 #include "FWCore/Utilities/interface/Exception.h"
00026
00027 void L1GtPatternLine::push(const std::string& prefix, uint32_t value) {
00028 std::string colName = nextName(prefix);
00029
00030
00031 m_columns[colName] = value;
00032 m_columns[colName + "_h"] = value >> 16;
00033 m_columns[colName + "_l"] = value & 0xFFFF;
00034 }
00035
00036 void L1GtPatternLine::set(const std::string& name, uint32_t value) {
00037 ColumnMap::iterator it = m_columns.find(name);
00038 if(it == m_columns.end()) {
00039 throw cms::Exception(__func__) << "Can't set field "
00040 << name << " to " << std::hex << value
00041 << ": not found";
00042 }
00043
00044 it->second = value;
00045 m_columns[name + "_h"] = value >> 16;
00046 m_columns[name + "_l"] = value & 0xFFFF;
00047 }
00048
00049 void L1GtPatternLine::print(std::ostream& out) const {
00050 out << "BEGIN Columns: " << std::endl ;
00051 for(L1GtPatternLine::ColumnMap::const_iterator it = m_columns.begin();
00052 it != m_columns.end() ; ++it) {
00053 out << it->first << ": " << std::hex << it->second << std::endl;
00054 }
00055 out << "END Columns." << std::endl ;
00056 }
00057
00058 bool L1GtPatternLine::has(const std::string& colname) const {
00059 return m_columns.find(colname) != m_columns.end();
00060 }
00061
00062 std::string L1GtPatternLine::nextName(const std::string& prefix) {
00063 int i = 1 ;
00064 std::string result;
00065 do
00066 {
00067 result = name(prefix, i++);
00068 } while(has(result));
00069
00070 return result;
00071 }
00072
00073 std::string L1GtPatternLine::name(const std::string& prefix, unsigned int i) const {
00074 std::ostringstream ss;
00075 ss << prefix << i;
00076 return ss.str();
00077 }
00078
00079 uint32_t L1GtPatternLine::get(const std::string& name) const {
00080 ColumnMap::const_iterator it = m_columns.find(name);
00081 if(it != m_columns.end()) {
00082 return it->second;
00083 }
00084 return 0;
00085 }