#include <L1GtPatternWriter.h>
Public Member Functions | |
void | close () |
L1GtPatternWriter (std::ostream &destination, const std::string &header, const std::string &footer, const std::vector< std::string > &columns, const std::vector< boost::uint32_t > &lengths, const std::vector< boost::uint32_t > &defaultValues, const std::vector< int > &bx, bool debug=false) | |
virtual void | writePatternLine (const L1GtPatternLine &line) |
void | writePatterns (const L1GtPatternMap &patterns) |
virtual | ~L1GtPatternWriter () |
Static Protected Member Functions | |
static boost::uint32_t | mask (boost::uint32_t length) |
Private Attributes | |
std::vector< int > | m_bx |
std::vector< std::string > | m_columns |
bool | m_debug |
std::vector< boost::uint32_t > | m_defaults |
std::ostream & | m_dest |
std::string | m_footer |
std::string | m_header |
std::vector< boost::uint32_t > | m_lengths |
boost::uint32_t | m_lineNo |
The L1GtPatternWriter object is responsible for the actual formatting of the content of one or more L1GtPatternMaps into a text file.
Description: Formats L1GtPatternMaps into text files.
Implementation: <TODO: enter implementation details>
$Date$ $Revision$
Description: see header file.
Implementation: <TODO: enter implementation details>
$Date$ $Revision$
Definition at line 30 of file L1GtPatternWriter.h.
L1GtPatternWriter::L1GtPatternWriter | ( | std::ostream & | destination, |
const std::string & | header, | ||
const std::string & | footer, | ||
const std::vector< std::string > & | columns, | ||
const std::vector< boost::uint32_t > & | lengths, | ||
const std::vector< boost::uint32_t > & | defaultValues, | ||
const std::vector< int > & | bx, | ||
bool | debug = false |
||
) |
Construct a new pattern writer.
destination | output stream to write to |
header | string to be written before pattern lines |
footer | string to be written after pattern lines |
columns | vector of column names for each pattern line |
length | vector of column lengths (in bits!) for each pattern line |
defaults | vector of default values (written if the pattern data does not contain entries for the column). Indexed like columns. |
bx | vector of bunch crossing numbers to print (empty for 'all') |
debug | set to true to enable extensive debug logging |
Definition at line 30 of file L1GtPatternWriter.cc.
L1GtPatternWriter::~L1GtPatternWriter | ( | ) | [virtual] |
void L1GtPatternWriter::close | ( | void | ) |
Close the output stream
Definition at line 103 of file L1GtPatternWriter.cc.
References m_dest, and m_footer.
Referenced by ~L1GtPatternWriter().
static boost::uint32_t L1GtPatternWriter::mask | ( | boost::uint32_t | length | ) | [static, protected] |
Returns an and-mask to truncate an boost::uint32_t to a specified length.
Referenced by writePatternLine().
void L1GtPatternWriter::writePatternLine | ( | const L1GtPatternLine & | line | ) | [virtual] |
Format a single line.
Definition at line 71 of file L1GtPatternWriter.cc.
References L1GtPatternLine::get(), L1GtPatternLine::has(), i, m_columns, m_defaults, m_dest, m_lengths, m_lineNo, mask(), and relativeConstraints::value.
Referenced by writePatterns().
{ m_dest << std::setfill('0'); // open each line with a line number // the line number is in decimal, while everything else is hex. m_dest << std::dec << std::setw(4) << m_lineNo << ' ' << std::hex ; for(uint32_t i = 0 ; i < m_columns.size() ; ++i) { // space beween fields if(i) m_dest << ' '; // retrieve column value uint32_t value; if(line.has(m_columns[i])) { // value comes from data value = line.get(m_columns[i]); } else if(m_defaults.size() > i) { // value was specified as a config default. value = m_defaults[i]; } else { // no default specified, set to 0 value = 0; } uint32_t digits = (m_lengths[i]+3)/4; // write to file with configured length (truncating value if neccessary) m_dest << std::setw(digits) << (value & mask(m_lengths[i])); } // next line m_dest << std::endl; }
void L1GtPatternWriter::writePatterns | ( | const L1GtPatternMap & | patterns | ) |
Write the lines from a pattern map to the output stream.
Definition at line 48 of file L1GtPatternWriter.cc.
References L1GtPatternMap::begin(), hcal_timing_source_file_cfg::dump, L1GtPatternMap::end(), spr::find(), edm::isDebugEnabled(), LogTrace, m_bx, m_debug, m_dest, m_lineNo, L1GtPatternMap::print(), and writePatternLine().
{ for(L1GtPatternMap::LineMap::const_iterator it = patterns.begin(); it != patterns.end() ; ++it) { int event = it->first.first; int bx = it->first.second; if(edm::isDebugEnabled() && m_debug) { std::stringstream dump; patterns.print(dump); LogTrace("L1GtPatternGenerator") << dump.str(); } if(m_bx.empty() || std::find(m_bx.begin(), m_bx.end(), bx) != m_bx.end()) { if(m_debug) { m_dest << "# Event " << std::dec << event << ", bx " << bx << std::endl; } writePatternLine(it->second); ++m_lineNo; } else { LogTrace("L1GtPatternGenerator") << "Skipping event " << it->first.first << " bx " << it->first.second << " because of bx filter"; } } }
std::vector<int> L1GtPatternWriter::m_bx [private] |
Definition at line 73 of file L1GtPatternWriter.h.
Referenced by writePatterns().
std::vector<std::string> L1GtPatternWriter::m_columns [private] |
Definition at line 70 of file L1GtPatternWriter.h.
Referenced by writePatternLine().
bool L1GtPatternWriter::m_debug [private] |
Definition at line 74 of file L1GtPatternWriter.h.
Referenced by writePatterns().
std::vector<boost::uint32_t> L1GtPatternWriter::m_defaults [private] |
Definition at line 72 of file L1GtPatternWriter.h.
Referenced by writePatternLine().
std::ostream& L1GtPatternWriter::m_dest [private] |
Definition at line 67 of file L1GtPatternWriter.h.
Referenced by close(), L1GtPatternWriter(), writePatternLine(), and writePatterns().
std::string L1GtPatternWriter::m_footer [private] |
Definition at line 69 of file L1GtPatternWriter.h.
Referenced by close().
std::string L1GtPatternWriter::m_header [private] |
Definition at line 68 of file L1GtPatternWriter.h.
Referenced by L1GtPatternWriter().
std::vector<boost::uint32_t> L1GtPatternWriter::m_lengths [private] |
Definition at line 71 of file L1GtPatternWriter.h.
Referenced by writePatternLine().
boost::uint32_t L1GtPatternWriter::m_lineNo [private] |
Definition at line 76 of file L1GtPatternWriter.h.
Referenced by writePatternLine(), and writePatterns().