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

virtual std::unique_ptr< BlockgetBlock () override
 
virtual BlockHeader getHeader () override
 
virtual 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)
 

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 const unsigned int counter_size = 4
 
static const unsigned int header_size = 12
 
static const unsigned int max_block_length_ = 3
 
static const unsigned int 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 95 of file Block.cc.

References counter_size, data, l1t::Payload::data_, end, l1t::Payload::end_, header_size, and trailer_size.

95  : Payload(data, end)
96  {
97  const uint16_t * data16 = reinterpret_cast<const uint16_t*>(data);
98  const uint16_t * end16 = reinterpret_cast<const uint16_t*>(end);
99 
100  if (end16 - data16 < header_size + counter_size + trailer_size) {
101  edm::LogError("L1T") << "MTF7 payload smaller than allowed!";
102  data_ = end_;
103  } else if (
104  ((data16[0] >> 12) != 0x9) || ((data16[1] >> 12) != 0x9) ||
105  ((data16[2] >> 12) != 0x9) || ((data16[3] >> 12) != 0x9) ||
106  ((data16[4] >> 12) != 0xA) || ((data16[5] >> 12) != 0xA) ||
107  ((data16[6] >> 12) != 0xA) || ((data16[7] >> 12) != 0xA) ||
108  ((data16[8] >> 9) != 0b1000000) || ((data16[9] >> 11) != 0) ||
109  ((data16[10] >> 11) != 0) || ((data16[11] >> 11) != 0)) {
110  edm::LogError("L1T") << "MTF7 payload has invalid header!";
111  data_ = end_;
112  } else if (
113  ((data16[12] >> 15) != 0) || ((data16[13] >> 15) != 1) ||
114  ((data16[14] >> 15) != 0) || ((data16[15] >> 15) != 0)) {
115  edm::LogError("L1T") << "MTF7 payload has invalid counter block!";
116  data_ = end_;
117  } else if (
118  false) {
119  // TODO: check trailer
120  }
121  }
static const unsigned int trailer_size
Definition: Block.h:112
const uint32_t * end_
Definition: Block.h:88
static const unsigned int counter_size
Definition: Block.h:111
#define end
Definition: vmac.h:37
const uint32_t * data_
Definition: Block.h:87
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
static const unsigned int header_size
Definition: Block.h:110
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 124 of file Block.cc.

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

Referenced by getBlock().

125  {
126  unsigned int mask = 0;
127  for (; length > 0; length--)
128  mask = (mask << 4) | 0xf;
129 
130  int count = 0;
131  for (const auto& p: block_patterns_)
132  count += (p & mask) == pattern;
133  return count;
134  }
int count(unsigned int pattern, unsigned int length) const
Definition: Block.cc:124
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 147 of file Block.cc.

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

148  {
149  if (end_ - data_ < 2)
150  return std::auto_ptr<Block>(0);
151 
152  const uint16_t * data16 = reinterpret_cast<const uint16_t*>(data_);
153  const uint16_t * end16 = reinterpret_cast<const uint16_t*>(end_);
154 
155  // Read in blocks equivalent to 64 bit words, trying to match the
156  // pattern of first bits to what is deemed valid.
157  std::vector<uint32_t> payload;
158  unsigned int pattern = 0;
159  unsigned int i = 0;
160  for (; i < max_block_length_ and data16 + (i + 1) * 4 <= end16; ++i) {
161  for (int j = 0; j < 4; ++j) {
162  auto n = i * 4 + j;
163  pattern |= (data16[n] >> 15) << n;
164  payload.push_back(data16[n]);
165  }
166 
167  if (count(pattern, i + 1) == 1 and valid(pattern))
168  break;
169  }
170 
171  if (not valid(pattern)) {
172  edm::LogWarning("L1T") << "MTF7 block with unrecognized id 0x" << std::hex << pattern;
173  return std::auto_ptr<Block>(0);
174  }
175 
176  data_ += (i + 1) * 2;
177  return std::unique_ptr<Block>(new Block(pattern, payload, 0, MTF7));
178  }
int count(unsigned int pattern, unsigned int length) const
Definition: Block.cc:124
const uint32_t * end_
Definition: Block.h:88
payload
payload postfix for testing
bool valid(unsigned int pattern) const
Definition: Block.cc:137
const uint32_t * data_
Definition: Block.h:87
static const unsigned int max_block_length_
Definition: Block.h:116
virtual BlockHeader l1t::MTF7Payload::getHeader ( )
inlineoverridevirtual

Implements l1t::Payload.

Definition at line 106 of file Block.h.

References l1t::BlockHeader::BlockHeader().

106 { return BlockHeader(0); };
virtual 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 137 of file Block.cc.

References block_patterns_, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by getBlock().

138  {
139  for (const auto& p: block_patterns_) {
140  if (p == pattern)
141  return true;
142  }
143  return false;
144  }
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().

const unsigned int l1t::MTF7Payload::counter_size = 4
staticprivate

Definition at line 111 of file Block.h.

Referenced by MTF7Payload().

const unsigned int l1t::MTF7Payload::header_size = 12
staticprivate

Definition at line 110 of file Block.h.

Referenced by MTF7Payload().

const unsigned int l1t::MTF7Payload::max_block_length_ = 3
staticprivate

Definition at line 116 of file Block.h.

Referenced by getBlock().

const unsigned int l1t::MTF7Payload::trailer_size = 8
staticprivate

Definition at line 112 of file Block.h.

Referenced by MTF7Payload().