CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Static Private Attributes
l1t::MTF7Payload Class Reference

#include <Block.h>

Inheritance diagram for l1t::MTF7Payload:
l1t::Payload

Public Member Functions

std::unique_ptr< BlockgetBlock () override
 
BlockHeader getHeader () override
 
unsigned getHeaderSize () const override
 
 MTF7Payload (const uint32_t *data, const uint32_t *end)
 
- Public Member Functions inherited from l1t::Payload
virtual unsigned getAlgorithmFWVersion () const
 
virtual unsigned getInfrastructureFWVersion () const
 
 Payload (const uint32_t *data, const uint32_t *end)
 
virtual ~Payload ()
 

Private Member Functions

int count (unsigned int pattern, unsigned int length) const
 
bool valid (unsigned int pattern) const
 

Static Private Attributes

static const std::vector< unsigned int > block_patterns_
 
static constexpr unsigned counter_size = 4
 
static constexpr unsigned header_size = 12
 
static constexpr unsigned max_block_length_ = 3
 
static constexpr unsigned trailer_size = 8
 

Additional Inherited Members

- Protected Attributes inherited from l1t::Payload
unsigned algo_
 
const uint32_t * data_
 
const uint32_t * end_
 
unsigned infra_
 

Detailed Description

Definition at line 101 of file Block.h.

Constructor & Destructor Documentation

l1t::MTF7Payload::MTF7Payload ( const uint32_t *  data,
const uint32_t *  end 
)

Definition at line 125 of file Block.cc.

References l1t::Payload::algo_, counter_size, data, l1t::Payload::data_, end, l1t::Payload::end_, header_size, mps_fire::i, trailer_size, and globals_cff::x1.

125  : Payload(data, end)
126  {
127  const uint16_t * data16 = reinterpret_cast<const uint16_t*>(data);
128  const uint16_t * end16 = reinterpret_cast<const uint16_t*>(end);
129 
130  if (end16 - data16 < header_size + counter_size + trailer_size) {
131  edm::LogError("L1T") << "MTF7 payload smaller than allowed!";
132  data_ = end_;
133  } else if ( // Check bits for EMTF Event Record Header
134  ((data16[0] >> 12) != 0x9) || ((data16[1] >> 12) != 0x9) ||
135  ((data16[2] >> 12) != 0x9) || ((data16[3] >> 12) != 0x9) ||
136  ((data16[4] >> 12) != 0xA) || ((data16[5] >> 12) != 0xA) ||
137  ((data16[6] >> 12) != 0xA) || ((data16[7] >> 12) != 0xA) ||
138  ((data16[8] >> 15) != 0x1) || ((data16[9] >> 15) != 0x0) ||
139  ((data16[10] >> 15) != 0x0) || ((data16[11] >> 15) != 0x0)) {
140  edm::LogError("L1T") << "MTF7 payload has invalid header!";
141  data_ = end_;
142  } else if ( // Check bits for EMTF MPC Link Errors
143  ((data16[12] >> 15) != 0) || ((data16[13] >> 15) != 1) ||
144  ((data16[14] >> 15) != 0) || ((data16[15] >> 15) != 0)) {
145  edm::LogError("L1T") << "MTF7 payload has invalid counter block!";
146  data_ = end_;
147  }
148 
149  // Check bits for EMTF Event Record Trailer, get firmware version
150  algo_ = 0; // Firmware version
151  for (int i = 4; i < 1590; i++) { // Start after Counters block, up to 108 ME / 84 RPC / 3 SP blocks per BX, 8 BX
152  if ( ((data16[4*i+0] >> 12) == 0xF) && ((data16[4*i+1] >> 12) == 0xF) &&
153  ((data16[4*i+2] >> 12) == 0xF) && ((data16[4*i+3] >> 12) == 0xF) &&
154  ((data16[4*i+4] >> 12) == 0xE) && ((data16[4*i+5] >> 12) == 0xE) &&
155  ((data16[4*i+6] >> 12) == 0xE) && ((data16[4*i+7] >> 12) == 0xE) ) { // Indicators for the Trailer block
156  algo_ = (((data16[4*i+2] >> 4) & 0x3F) << 9); // Year (6 bits)
157  algo_ |= (((data16[4*i+2] >> 0) & 0x0F) << 5); // Month (4 bits)
158  algo_ |= (((data16[4*i+4] >> 0) & 0x1F) << 0); // Day (5 bits)
159  break;
160  }
161  }
162  if (algo_ == 0) {
163  edm::LogError("L1T") << "MTF7 payload has no valid EMTF firmware version!";
164  data_ = end_;
165  }
166  }
static constexpr unsigned header_size
Definition: Block.h:110
const uint32_t * end_
Definition: Block.h:88
static constexpr unsigned counter_size
Definition: Block.h:111
#define end
Definition: vmac.h:39
const uint32_t * data_
Definition: Block.h:87
static constexpr unsigned trailer_size
Definition: Block.h:112
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
unsigned algo_
Definition: Block.h:90
Payload(const uint32_t *data, const uint32_t *end)
Definition: Block.h:76

Member Function Documentation

int l1t::MTF7Payload::count ( unsigned int  pattern,
unsigned int  length 
) const
private

Definition at line 169 of file Block.cc.

References block_patterns_, RecoTauDiscriminantConfiguration::mask, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by getBlock().

170  {
171  unsigned int mask = 0;
172  for (; length > 0; length--)
173  mask = (mask << 4) | 0xf;
174 
175  int count = 0;
176  for (const auto& p: block_patterns_)
177  count += (p & mask) == pattern;
178  return count;
179  }
int count(unsigned int pattern, unsigned int length) const
Definition: Block.cc:169
static const std::vector< unsigned int > block_patterns_
Definition: Block.h:117
std::unique_ptr< Block > l1t::MTF7Payload::getBlock ( )
overridevirtual

Reimplemented from l1t::Payload.

Definition at line 192 of file Block.cc.

References count(), l1t::Payload::data_, l1t::Payload::end_, mps_fire::i, max_block_length_, l1t::MTF7, gen::n, listBenchmarks::pattern, jets_cff::payload, and valid().

193  {
194  if (end_ - data_ < 2)
195  return std::unique_ptr<Block>();
196 
197  const uint16_t * data16 = reinterpret_cast<const uint16_t*>(data_);
198  const uint16_t * end16 = reinterpret_cast<const uint16_t*>(end_);
199 
200  // Read in blocks equivalent to 64 bit words, trying to match the
201  // pattern of first bits to what is deemed valid.
202  std::vector<uint32_t> payload;
203  unsigned int pattern = 0;
204  unsigned int i = 0;
205  for (; i < max_block_length_ and data16 + (i + 1) * 4 <= end16; ++i) {
206  for (int j = 0; j < 4; ++j) {
207  auto n = i * 4 + j;
208  pattern |= (data16[n] >> 15) << n;
209  payload.push_back(data16[n]);
210  }
211 
212  if (count(pattern, i + 1) == 1 and valid(pattern))
213  break;
214  }
215 
216  if (not valid(pattern)) {
217  edm::LogWarning("L1T") << "MTF7 block with unrecognized id 0x" << std::hex << pattern;
218  return std::unique_ptr<Block>();
219  }
220 
221  data_ += (i + 1) * 2;
222  return std::make_unique<Block>(pattern, payload, 0, MTF7);
223  }
static constexpr unsigned max_block_length_
Definition: Block.h:116
int count(unsigned int pattern, unsigned int length) const
Definition: Block.cc:169
const uint32_t * end_
Definition: Block.h:88
bool valid(unsigned int pattern) const
Definition: Block.cc:182
const uint32_t * data_
Definition: Block.h:87
BlockHeader l1t::MTF7Payload::getHeader ( )
inlineoverridevirtual

Implements l1t::Payload.

Definition at line 106 of file Block.h.

References l1t::BlockHeader::BlockHeader().

106 { return BlockHeader(nullptr); };
unsigned l1t::MTF7Payload::getHeaderSize ( ) const
inlineoverridevirtual

Implements l1t::Payload.

Definition at line 105 of file Block.h.

105 { return 0; };
bool l1t::MTF7Payload::valid ( unsigned int  pattern) const
private

Definition at line 182 of file Block.cc.

References block_patterns_, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by getBlock().

183  {
184  for (const auto& p: block_patterns_) {
185  if (p == pattern)
186  return true;
187  }
188  return false;
189  }
static const std::vector< unsigned int > block_patterns_
Definition: Block.h:117

Member Data Documentation

const std::vector< unsigned int > l1t::MTF7Payload::block_patterns_
staticprivate
Initial value:
=
{
0b000111111111,
0b0010,
0b0011,
0b0100,
0b01100101,
0b11111111
}

Definition at line 117 of file Block.h.

Referenced by count(), and valid().

constexpr unsigned l1t::MTF7Payload::counter_size = 4
staticprivate

Definition at line 111 of file Block.h.

Referenced by MTF7Payload().

constexpr unsigned l1t::MTF7Payload::header_size = 12
staticprivate

Definition at line 110 of file Block.h.

Referenced by MTF7Payload().

constexpr unsigned l1t::MTF7Payload::max_block_length_ = 3
staticprivate

Definition at line 116 of file Block.h.

Referenced by getBlock().

constexpr unsigned l1t::MTF7Payload::trailer_size = 8
staticprivate

Definition at line 112 of file Block.h.

Referenced by MTF7Payload().