CMS 3D CMS Logo

List of all members | Public Member Functions | Static Protected Member Functions | Private Attributes
L1GtPatternWriter Class Reference

#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< uint32_t > &lengths, const std::vector< 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 uint32_t mask (uint32_t length)
 

Private Attributes

std::vector< int > m_bx
 
std::vector< std::string > m_columns
 
bool m_debug
 
std::vector< uint32_t > m_defaults
 
std::ostream & m_dest
 
std::string m_footer
 
std::string m_header
 
std::vector< uint32_t > m_lengths
 
uint32_t m_lineNo
 

Detailed Description

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>

Author
: Thomas Themel - HEPHY Vienna

Description: see header file.

Implementation: <TODO: enter implementation details>

Author
: Thomas Themel - HEPHY Vienna

Definition at line 28 of file L1GtPatternWriter.h.

Constructor & Destructor Documentation

◆ L1GtPatternWriter()

L1GtPatternWriter::L1GtPatternWriter ( std::ostream &  destination,
const std::string &  header,
const std::string &  footer,
const std::vector< std::string > &  columns,
const std::vector< uint32_t > &  lengths,
const std::vector< uint32_t > &  defaultValues,
const std::vector< int > &  bx,
bool  debug = false 
)

Construct a new pattern writer.

Parameters
destinationoutput stream to write to
headerstring to be written before pattern lines
footerstring to be written after pattern lines
columnsvector of column names for each pattern line
lengthvector of column lengths (in bits!) for each pattern line
defaultsvector of default values (written if the pattern data does not contain entries for the column). Indexed like columns.
bxvector of bunch crossing numbers to print (empty for 'all')
debugset to true to enable extensive debug logging

Definition at line 28 of file L1GtPatternWriter.cc.

38  m_footer(footer),
42  m_bx(bx),
43  m_debug(debug),
44  m_lineNo(0)
45 
46 {
47  m_dest << m_header;
48 }

References m_dest, and m_header.

◆ ~L1GtPatternWriter()

L1GtPatternWriter::~L1GtPatternWriter ( )
virtual

Definition at line 113 of file L1GtPatternWriter.cc.

113 { close(); }

References close().

Member Function Documentation

◆ close()

void L1GtPatternWriter::close ( void  )

Close the output stream

Definition at line 107 of file L1GtPatternWriter.cc.

107  {
108  if (m_dest) {
109  m_dest << m_footer;
110  }
111 }

References m_dest, and m_footer.

Referenced by esMonitoring.AsyncLineReaderMixin::handle_close(), esMonitoring.FDJsonServer::handle_close(), and ~L1GtPatternWriter().

◆ mask()

uint32_t L1GtPatternWriter::mask ( uint32_t  length)
staticprotected

Returns an and-mask to truncate an uint32_t to a specified length.

Definition at line 115 of file L1GtPatternWriter.cc.

115  {
116  if (length < 32) {
117  return ~((~0U) << length);
118  } else {
119  return ~0U;
120  }
121 }

References mitigatedMETSequence_cff::U.

Referenced by writePatternLine().

◆ writePatternLine()

void L1GtPatternWriter::writePatternLine ( const L1GtPatternLine line)
virtual

Format a single line.

Definition at line 74 of file L1GtPatternWriter.cc.

74  {
75  m_dest << std::setfill('0');
76  // open each line with a line number
77  // the line number is in decimal, while everything else is hex.
78  m_dest << std::dec << std::setw(4) << m_lineNo << ' ' << std::hex;
79 
80  for (uint32_t i = 0; i < m_columns.size(); ++i) {
81  // space beween fields
82  if (i)
83  m_dest << ' ';
84 
85  // retrieve column value
86  uint32_t value;
87  if (line.has(m_columns[i])) {
88  // value comes from data
89  value = line.get(m_columns[i]);
90  } else if (m_defaults.size() > i) {
91  // value was specified as a config default.
92  value = m_defaults[i];
93  } else {
94  // no default specified, set to 0
95  value = 0;
96  }
97  uint32_t digits = (m_lengths[i] + 3) / 4;
98 
99  // write to file with configured length (truncating value if neccessary)
100  m_dest << std::setw(digits) << (value & mask(m_lengths[i]));
101  }
102 
103  // next line
104  m_dest << std::endl;
105 }

References TauDecayModes::dec, mps_fire::i, mps_splice::line, m_columns, m_defaults, m_dest, m_lengths, m_lineNo, mask(), and relativeConstraints::value.

Referenced by writePatterns().

◆ writePatterns()

void L1GtPatternWriter::writePatterns ( const L1GtPatternMap patterns)

Write the lines from a pattern map to the output stream.

Definition at line 50 of file L1GtPatternWriter.cc.

50  {
51  for (L1GtPatternMap::LineMap::const_iterator it = patterns.begin(); it != patterns.end(); ++it) {
52  int event = it->first.first;
53  int bx = it->first.second;
54 
55  if (edm::isDebugEnabled() && m_debug) {
56  std::stringstream dump;
57  patterns.print(dump);
58  LogTrace("L1GtPatternGenerator") << dump.str();
59  }
60 
61  if (m_bx.empty() || std::find(m_bx.begin(), m_bx.end(), bx) != m_bx.end()) {
62  if (m_debug) {
63  m_dest << "# Event " << std::dec << event << ", bx " << bx << std::endl;
64  }
65  writePatternLine(it->second);
66  ++m_lineNo;
67  } else {
68  LogTrace("L1GtPatternGenerator") << "Skipping event " << it->first.first << " bx " << it->first.second
69  << " because of bx filter";
70  }
71  }
72 }

References L1GtPatternMap::begin(), l1GtPatternGenerator_cfi::bx, TauDecayModes::dec, FrontierConditions_GlobalTag_cff::dump, L1GtPatternMap::end(), spr::find(), edm::isDebugEnabled(), LogTrace, m_bx, m_debug, m_dest, m_lineNo, L1GtPatternMap::print(), and writePatternLine().

Member Data Documentation

◆ m_bx

std::vector<int> L1GtPatternWriter::m_bx
private

Definition at line 73 of file L1GtPatternWriter.h.

Referenced by writePatterns().

◆ m_columns

std::vector<std::string> L1GtPatternWriter::m_columns
private

Definition at line 70 of file L1GtPatternWriter.h.

Referenced by writePatternLine().

◆ m_debug

bool L1GtPatternWriter::m_debug
private

Definition at line 74 of file L1GtPatternWriter.h.

Referenced by writePatterns().

◆ m_defaults

std::vector<uint32_t> L1GtPatternWriter::m_defaults
private

Definition at line 72 of file L1GtPatternWriter.h.

Referenced by writePatternLine().

◆ m_dest

std::ostream& L1GtPatternWriter::m_dest
private

Definition at line 67 of file L1GtPatternWriter.h.

Referenced by close(), L1GtPatternWriter(), writePatternLine(), and writePatterns().

◆ m_footer

std::string L1GtPatternWriter::m_footer
private

Definition at line 69 of file L1GtPatternWriter.h.

Referenced by close().

◆ m_header

std::string L1GtPatternWriter::m_header
private

Definition at line 68 of file L1GtPatternWriter.h.

Referenced by L1GtPatternWriter().

◆ m_lengths

std::vector<uint32_t> L1GtPatternWriter::m_lengths
private

Definition at line 71 of file L1GtPatternWriter.h.

Referenced by writePatternLine().

◆ m_lineNo

uint32_t L1GtPatternWriter::m_lineNo
private

Definition at line 76 of file L1GtPatternWriter.h.

Referenced by writePatternLine(), and writePatterns().

mps_fire.i
i
Definition: mps_fire.py:428
L1GtPatternMap::print
void print(std::ostream &out) const
Definition: L1GtPatternMap.cc:31
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
L1GtPatternWriter::close
void close()
Definition: L1GtPatternWriter.cc:107
L1GtPatternWriter::m_debug
bool m_debug
Definition: L1GtPatternWriter.h:74
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
L1GtPatternMap::begin
LineMap::const_iterator begin() const
Definition: L1GtPatternMap.cc:25
L1GtPatternWriter::m_dest
std::ostream & m_dest
Definition: L1GtPatternWriter.h:67
debug
#define debug
Definition: HDRShower.cc:19
L1GtPatternWriter::m_footer
std::string m_footer
Definition: L1GtPatternWriter.h:69
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
L1GtPatternMap::end
LineMap::const_iterator end() const
Definition: L1GtPatternMap.cc:26
l1GtPatternGenerator_cfi.defaults
defaults
Definition: l1GtPatternGenerator_cfi.py:93
L1GtPatternWriter::m_columns
std::vector< std::string > m_columns
Definition: L1GtPatternWriter.h:70
FrontierConditions_GlobalTag_cff.dump
dump
Definition: FrontierConditions_GlobalTag_cff.py:12
value
Definition: value.py:1
l1GtPatternGenerator_cfi.lengths
lengths
Definition: l1GtPatternGenerator_cfi.py:92
L1GtPatternWriter::writePatternLine
virtual void writePatternLine(const L1GtPatternLine &line)
Definition: L1GtPatternWriter.cc:74
HLTMuonOfflineAnalyzer_cff.destination
destination
Definition: HLTMuonOfflineAnalyzer_cff.py:50
L1GtPatternWriter::m_lengths
std::vector< uint32_t > m_lengths
Definition: L1GtPatternWriter.h:71
L1GtPatternWriter::m_defaults
std::vector< uint32_t > m_defaults
Definition: L1GtPatternWriter.h:72
relativeConstraints.value
value
Definition: relativeConstraints.py:53
mps_check.columns
columns
Definition: mps_check.py:244
L1GtPatternWriter::mask
static uint32_t mask(uint32_t length)
Definition: L1GtPatternWriter.cc:115
L1GtPatternWriter::m_bx
std::vector< int > m_bx
Definition: L1GtPatternWriter.h:73
RecoTauValidation_cfi.header
header
Definition: RecoTauValidation_cfi.py:292
edm::isDebugEnabled
bool isDebugEnabled()
Definition: MessageLogger.cc:12
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
mps_splice.line
line
Definition: mps_splice.py:76
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
L1GtPatternWriter::m_header
std::string m_header
Definition: L1GtPatternWriter.h:68
L1GtPatternWriter::m_lineNo
uint32_t m_lineNo
Definition: L1GtPatternWriter.h:76