Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:22:23

0001 /**
0002  * \class L1GtPatternLine
0003  * 
0004  * 
0005  * Description: see header file.  
0006  *
0007  * Implementation:
0008  *    <TODO: enter implementation details>
0009  *   
0010  * \author: Thomas Themel - HEPHY Vienna
0011  * 
0012  *
0013  */
0014 
0015 // this class header
0016 #include "L1Trigger/GlobalTriggerAnalyzer/interface/L1GtPatternLine.h"
0017 
0018 // system include files
0019 #include <sstream>
0020 #include <iostream>
0021 
0022 // user include files
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   // add three values for each column - the full 32bit value,
0028   // one for the lower 16 bits and one for the higher 16 bits.
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 }