CMS 3D CMS Logo

L1GtPatternWriter.cc
Go to the documentation of this file.
1 
15 // this class header
17 
18 // system include files
19 #include <iostream>
20 #include <iomanip>
21 #include <algorithm>
22 
23 // user include files
27 
29  const std::string& header,
30  const std::string& footer,
31  const std::vector<std::string>& columns,
32  const std::vector<uint32_t>& lengths,
33  const std::vector<uint32_t>& defaults,
34  const std::vector<int>& bx,
35  bool debug)
36  : m_dest(destination),
37  m_header(header),
38  m_footer(footer),
39  m_columns(columns),
40  m_lengths(lengths),
41  m_defaults(defaults),
42  m_bx(bx),
43  m_debug(debug),
44  m_lineNo(0)
45 
46 {
47  m_dest << m_header;
48 }
49 
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 }
73 
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 }
106 
108  if (m_dest) {
109  m_dest << m_footer;
110  }
111 }
112 
114 
115 uint32_t L1GtPatternWriter::mask(uint32_t length) {
116  if (length < 32) {
117  return ~((~0U) << length);
118  } else {
119  return ~0U;
120  }
121 }
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
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
L1GtPatternLine
Definition: L1GtPatternLine.h:28
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
L1GtPatternMap::end
LineMap::const_iterator end() const
Definition: L1GtPatternMap.cc:26
l1GtPatternGenerator_cfi.defaults
defaults
Definition: l1GtPatternGenerator_cfi.py:93
L1GtPatternWriter::~L1GtPatternWriter
virtual ~L1GtPatternWriter()
Definition: L1GtPatternWriter.cc:113
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
L1GtPatternMap.h
HLTMuonOfflineAnalyzer_cff.destination
destination
Definition: HLTMuonOfflineAnalyzer_cff.py:50
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)
Definition: L1GtPatternWriter.cc:28
L1GtPatternWriter::m_lengths
std::vector< uint32_t > m_lengths
Definition: L1GtPatternWriter.h:71
L1GtPatternMap
Definition: L1GtPatternMap.h:22
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:71
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
mps_splice.line
line
Definition: mps_splice.py:76
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
L1GtPatternWriter.h
L1GtPatternWriter::m_header
std::string m_header
Definition: L1GtPatternWriter.h:68
L1GtPatternWriter::m_lineNo
uint32_t m_lineNo
Definition: L1GtPatternWriter.h:76
L1GtPatternWriter::writePatterns
void writePatterns(const L1GtPatternMap &patterns)
Definition: L1GtPatternWriter.cc:50