CMS 3D CMS Logo

Block.h
Go to the documentation of this file.
1 #ifndef EventFilter_L1TRawToDigi_Block_h
2 #define EventFilter_L1TRawToDigi_Block_h
3 
4 #include <memory>
5 #include <vector>
6 
9 
10 namespace l1t {
11  enum block_t { MP7 = 0, CTP7, MTF7 };
12  namespace mtf7 {
13  enum mtf7_block_t {
14  // The "0b" prefix indicates binary; the block header id is stored in decimal.
15  // Bits are the left-most bit (D15) of every 16-bit word in the format document.
16  // Bottom-to-top in the document maps to left-to-right in each of the bit pattern.
17  EvHd = 0b000111111111,
18  CnBlk = 0b0010,
19  ME = 0b0011,
20  RPC = 0b0100,
21  GEM = 0b0111,
22  // FIXME, not currently defined... guess? JS - 01.07.20
23  ME0 = 0b0110,
24  SPOut = 0b01100101,
25  EvTr = 0b11111111
26  };
27  }
28 
29  class BlockHeader {
30  public:
31  BlockHeader(unsigned int id, unsigned int size, unsigned int capID = 0, unsigned int flags = 0, block_t type = MP7)
32  : id_(id), size_(size), capID_(capID), flags_(flags), type_(type){};
33  // Create a MP7 block header: everything is contained in the raw uint32
34  BlockHeader(const uint32_t* data)
35  : id_((data[0] >> ID_shift) & ID_mask),
36  size_((data[0] >> size_shift) & size_mask),
37  capID_((data[0] >> capID_shift) & capID_mask),
38  flags_((data[0] >> flags_shift) & flags_mask),
39  type_(MP7){};
40 
41  bool operator<(const BlockHeader& o) const { return getID() < o.getID(); };
42 
43  unsigned int getID() const { return id_; };
44  unsigned int getSize() const { return size_; };
45  unsigned int getCapID() const { return capID_; };
46  unsigned int getFlags() const { return flags_; };
47  block_t getType() const { return type_; };
48 
49  uint32_t raw() const;
50 
51  private:
52  static constexpr unsigned CTP7_shift = 0;
53  static constexpr unsigned CTP7_mask = 0xffff;
54  static constexpr unsigned ID_shift = 24;
55  static constexpr unsigned ID_mask = 0xff;
56  static constexpr unsigned size_shift = 16;
57  static constexpr unsigned size_mask = 0xff;
58  static constexpr unsigned capID_shift = 8;
59  static constexpr unsigned capID_mask = 0xff;
60  static constexpr unsigned flags_shift = 0;
61  static constexpr unsigned flags_mask = 0xff;
62 
63  unsigned int id_;
64  unsigned int size_;
65  unsigned int capID_;
66  unsigned int flags_;
68  };
69 
70  class Block {
71  public:
72  Block(const BlockHeader& h, const uint32_t* payload_start, const uint32_t* payload_end)
73  : header_(h), payload_(payload_start, payload_end){};
74  Block(unsigned int id,
75  const std::vector<uint32_t>& payload,
76  unsigned int capID = 0,
77  unsigned int flags = 0,
78  block_t type = MP7)
79  : header_(id, payload.size(), capID, flags, type), payload_(payload){};
80 
81  bool operator<(const Block& o) const { return header() < o.header(); };
82 
83  inline unsigned int getSize() const { return payload_.size() + 1; };
84 
85  BlockHeader header() const { return header_; };
86  const std::vector<uint32_t>& payload() const { return payload_; };
87 
88  void amc(const amc::Header& h) { amc_ = h; };
89  amc::Header amc() const { return amc_; };
90 
91  BxBlocks getBxBlocks(unsigned int payloadWordsPerBx, bool bxHeader) const;
92 
93  private:
96  std::vector<uint32_t> payload_;
97  };
98 
99  typedef std::vector<Block> Blocks;
100 
101  class Payload {
102  public:
103  Payload(const uint32_t* data, const uint32_t* end) : data_(data), end_(end), algo_(0), infra_(0){};
104  virtual ~Payload(){};
105  virtual unsigned getAlgorithmFWVersion() const { return algo_; };
106  virtual unsigned getInfrastructureFWVersion() const { return infra_; };
107  virtual unsigned getHeaderSize() const = 0;
108  // Read header from data_ and advance data_ to point behind the
109  // header. Called by getBlock(), which also checks that data_ !=
110  // end_ before calling (assumes size of one 32 bit word).
111  virtual BlockHeader getHeader() = 0;
112  virtual std::unique_ptr<Block> getBlock();
113 
114  protected:
115  const uint32_t* data_;
116  const uint32_t* end_;
117 
118  unsigned algo_;
119  unsigned infra_;
120  };
121 
122  class MP7Payload : public Payload {
123  public:
124  MP7Payload(const uint32_t* data, const uint32_t* end, bool legacy_mc = false);
125  unsigned getHeaderSize() const override { return 1; };
126  BlockHeader getHeader() override;
127  };
128 
129  class MTF7Payload : public Payload {
130  public:
131  MTF7Payload(const uint32_t* data, const uint32_t* end);
132  // Unused methods - we override getBlock() instead
133  unsigned getHeaderSize() const override { return 0; };
134  BlockHeader getHeader() override { return BlockHeader(nullptr); };
135  std::unique_ptr<Block> getBlock() override;
136 
137  private:
138  // sizes in 16 bit words
139  static constexpr unsigned header_size = 12;
140  static constexpr unsigned counter_size = 4;
141  static constexpr unsigned trailer_size = 8;
142 
144  static constexpr unsigned DAQ_PAYLOAD_OFFSET = 4;
146  static constexpr unsigned MAX_BX_PER_PAYLOAD = 8;
148  static constexpr unsigned ME_MAX_PER_BX = 108;
150  static constexpr unsigned RPC_MAX_PER_BX = 84;
152  static constexpr unsigned GE11_MAX_PER_BX = 112;
154  static constexpr unsigned GE21_MAX_PER_BX = 0;
156  static constexpr unsigned ME0_MAX_PER_BX = 0;
158  static constexpr unsigned SP_MAX_PER_BX = 6;
160  static constexpr unsigned PAYLOAD_MAX_SIZE =
163  (trailer_size / 4);
164 
165  static constexpr unsigned max_block_length_ = 3;
166  static const std::vector<unsigned int> block_patterns_;
167 
168  int count(unsigned int pattern, unsigned int length) const;
169  bool valid(unsigned int pattern) const;
170  };
171 
172  class CTP7Payload : public Payload {
173  public:
174  CTP7Payload(const uint32_t* data, const uint32_t* end, amc::Header amcHeader);
175  unsigned getHeaderSize() const override { return 2; };
176  BlockHeader getHeader() override;
177  std::unique_ptr<Block> getBlock() override;
178 
179  private:
180  // FIXME check values
181  static constexpr unsigned size_mask = 0xff;
182  static constexpr unsigned size_shift = 16;
183 
184  unsigned size_;
185  unsigned capId_;
186  unsigned bx_per_l1a_;
187  unsigned calo_bxid_;
189  };
190 } // namespace l1t
191 
192 #endif
l1t::mtf7::RPC
RPC Data Record : block->header().getID() = 4.
Definition: Block.h:20
l1t::Blocks
std::vector< Block > Blocks
Definition: Block.h:99
l1t::mtf7::ME0
ME0 Data Record : block->header().getID() = 6.
Definition: Block.h:23
l1t::Payload
Definition: Block.h:101
l1t::BlockHeader::flags_shift
static constexpr unsigned flags_shift
Definition: Block.h:60
l1t::MTF7Payload::getHeaderSize
unsigned getHeaderSize() const override
Definition: Block.h:133
l1t::Block::amc
void amc(const amc::Header &h)
Definition: Block.h:88
l1t::Payload::getInfrastructureFWVersion
virtual unsigned getInfrastructureFWVersion() const
Definition: Block.h:106
l1t::BlockHeader::type_
block_t type_
Definition: Block.h:67
l1t::BlockHeader::BlockHeader
BlockHeader(const uint32_t *data)
Definition: Block.h:34
l1t::MTF7Payload::MTF7Payload
MTF7Payload(const uint32_t *data, const uint32_t *end)
Definition: Block.cc:111
l1t::MTF7Payload::ME0_MAX_PER_BX
static constexpr unsigned ME0_MAX_PER_BX
TODO: Maximum number of ME0 words per MTF7 payload per bx: ?? ME0 links, ?? layers,...
Definition: Block.h:156
l1t::MTF7Payload::PAYLOAD_MAX_SIZE
static constexpr unsigned PAYLOAD_MAX_SIZE
Maximum number of 64-bit words in the EMTF payload.
Definition: Block.h:160
l1t::mtf7::mtf7_block_t
mtf7_block_t
Definition: Block.h:13
amc::Header
Definition: AMCSpec.h:59
l1t::BlockHeader::flags_
unsigned int flags_
Definition: Block.h:66
l1t::MP7Payload::MP7Payload
MP7Payload(const uint32_t *data, const uint32_t *end, bool legacy_mc=false)
Definition: Block.cc:91
l1t::mtf7::CnBlk
Block of Counters : block->header().getID() = 2.
Definition: Block.h:18
l1t::MTF7Payload::GE21_MAX_PER_BX
static constexpr unsigned GE21_MAX_PER_BX
TODO: Maximum number of GE2/1 words per MTF7 payload per bx: ?? GE2/1 links, 2 layers,...
Definition: Block.h:154
l1t::CTP7
Definition: Block.h:11
l1t::CTP7Payload::getHeaderSize
unsigned getHeaderSize() const override
Definition: Block.h:175
l1t::MTF7Payload::trailer_size
static constexpr unsigned trailer_size
Definition: Block.h:141
l1t::Payload::end_
const uint32_t * end_
Definition: Block.h:116
l1t::MTF7Payload::block_patterns_
static const std::vector< unsigned int > block_patterns_
bit patterns of the first bits (of 16bit words)
Definition: Block.h:166
l1t::Payload::getBlock
virtual std::unique_ptr< Block > getBlock()
Definition: Block.cc:64
l1t::Payload::Payload
Payload(const uint32_t *data, const uint32_t *end)
Definition: Block.h:103
l1t::CTP7Payload::getHeader
BlockHeader getHeader() override
Definition: Block.cc:222
l1t::MTF7Payload::counter_size
static constexpr unsigned counter_size
Definition: Block.h:140
l1t::Block::amc
amc::Header amc() const
Definition: Block.h:89
l1t::CTP7Payload::getBlock
std::unique_ptr< Block > getBlock() override
Definition: Block.cc:233
l1t::CTP7Payload::bx_per_l1a_
unsigned bx_per_l1a_
Definition: Block.h:186
l1t::MTF7Payload
Definition: Block.h:129
l1t::BlockHeader::capID_mask
static constexpr unsigned capID_mask
Definition: Block.h:59
l1t::CTP7Payload::calo_bxid_
unsigned calo_bxid_
Definition: Block.h:187
h
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
l1t::Payload::~Payload
virtual ~Payload()
Definition: Block.h:104
l1t::CTP7Payload::size_mask
static constexpr unsigned size_mask
Definition: Block.h:181
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:42
l1t::Block::Block
Block(const BlockHeader &h, const uint32_t *payload_start, const uint32_t *payload_end)
Definition: Block.h:72
l1t::BlockHeader::flags_mask
static constexpr unsigned flags_mask
Definition: Block.h:61
l1t::Payload::infra_
unsigned infra_
Definition: Block.h:119
l1t::Payload::getHeader
virtual BlockHeader getHeader()=0
l1t::BlockHeader::ID_mask
static constexpr unsigned ID_mask
Definition: Block.h:55
l1t::MTF7Payload::ME_MAX_PER_BX
static constexpr unsigned ME_MAX_PER_BX
Maximum number of CSC words per MTF7 payload per bx: 9 links/sectors, 6 stations, 2 LCTs.
Definition: Block.h:148
l1t::Block::header_
BlockHeader header_
Definition: Block.h:94
l1t::Payload::getHeaderSize
virtual unsigned getHeaderSize() const =0
l1t::BlockHeader::CTP7_mask
static constexpr unsigned CTP7_mask
Definition: Block.h:53
mps_fire.end
end
Definition: mps_fire.py:242
l1t::CTP7Payload
Definition: Block.h:172
l1t::MTF7Payload::DAQ_PAYLOAD_OFFSET
static constexpr unsigned DAQ_PAYLOAD_OFFSET
Start of the EMTF DAQ payload, in number of 64-bit words.
Definition: Block.h:144
l1t::BlockHeader::operator<
bool operator<(const BlockHeader &o) const
Definition: Block.h:41
l1t::MTF7Payload::count
int count(unsigned int pattern, unsigned int length) const
Definition: Block.cc:154
l1t::CTP7Payload::amcHeader_
amc::Header amcHeader_
Definition: Block.h:188
h
l1t::MP7Payload
Definition: Block.h:122
l1t::mtf7::GEM
GEM Data Record : block->header().getID() = 7.
Definition: Block.h:21
l1t::BlockHeader::getFlags
unsigned int getFlags() const
Definition: Block.h:46
l1t::MTF7Payload::getBlock
std::unique_ptr< Block > getBlock() override
Definition: Block.cc:173
l1t::MP7
Definition: Block.h:11
l1t::MTF7Payload::max_block_length_
static constexpr unsigned max_block_length_
maximum of the block length (64bits)
Definition: Block.h:165
l1t
delete x;
Definition: CaloConfig.h:22
type
type
Definition: SiPixelVCal_PayloadInspector.cc:39
l1t::MP7Payload::getHeader
BlockHeader getHeader() override
Definition: Block.cc:105
l1t::BlockHeader::raw
uint32_t raw() const
Definition: Block.cc:23
l1t::BlockHeader
Definition: Block.h:29
l1t::MP7Payload::getHeaderSize
unsigned getHeaderSize() const override
Definition: Block.h:125
topSingleLeptonDQM_PU_cfi.pattern
pattern
Definition: topSingleLeptonDQM_PU_cfi.py:39
l1t::BlockHeader::getSize
unsigned int getSize() const
Definition: Block.h:44
l1t::BlockHeader::id_
unsigned int id_
Definition: Block.h:63
l1t::MTF7Payload::valid
bool valid(unsigned int pattern) const
Definition: Block.cc:165
l1t::MTF7Payload::MAX_BX_PER_PAYLOAD
static constexpr unsigned MAX_BX_PER_PAYLOAD
Maximum number of BX per MTF7 payload.
Definition: Block.h:146
l1t::MTF7
Definition: Block.h:11
l1t::BlockHeader::ID_shift
static constexpr unsigned ID_shift
Definition: Block.h:54
l1t::Block::payload
const std::vector< uint32_t > & payload() const
Definition: Block.h:86
l1t::MTF7Payload::RPC_MAX_PER_BX
static constexpr unsigned RPC_MAX_PER_BX
Maximum number of RPC words per MTF7 payload per bx: 7 links/sectors, 6 stations, 2 segments.
Definition: Block.h:150
l1t::BlockHeader::BlockHeader
BlockHeader(unsigned int id, unsigned int size, unsigned int capID=0, unsigned int flags=0, block_t type=MP7)
Definition: Block.h:31
l1t::CTP7Payload::size_shift
static constexpr unsigned size_shift
Definition: Block.h:182
l1t::Block::Block
Block(unsigned int id, const std::vector< uint32_t > &payload, unsigned int capID=0, unsigned int flags=0, block_t type=MP7)
Definition: Block.h:74
BxBlock.h
l1t::Block::getBxBlocks
BxBlocks getBxBlocks(unsigned int payloadWordsPerBx, bool bxHeader) const
Definition: Block.cc:40
l1t::BlockHeader::getCapID
unsigned int getCapID() const
Definition: Block.h:45
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
l1t::BlockHeader::size_
unsigned int size_
Definition: Block.h:64
l1t::BlockHeader::size_mask
static constexpr unsigned size_mask
Definition: Block.h:57
ME
Definition: ME.h:11
l1t::MTF7Payload::header_size
static constexpr unsigned header_size
Definition: Block.h:139
l1t::MTF7Payload::getHeader
BlockHeader getHeader() override
Definition: Block.h:134
l1t::BlockHeader::getType
block_t getType() const
Definition: Block.h:47
l1t::BlockHeader::capID_
unsigned int capID_
Definition: Block.h:65
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
l1t::Payload::data_
const uint32_t * data_
Definition: Block.h:115
l1t::BlockHeader::capID_shift
static constexpr unsigned capID_shift
Definition: Block.h:58
AMCSpec.h
l1t::MTF7Payload::GE11_MAX_PER_BX
static constexpr unsigned GE11_MAX_PER_BX
Maximum number of GE1/1 words per MTF7 payload per bx: 7 GE1/1 links, 2 layers, 8 clusters.
Definition: Block.h:152
l1t::CTP7Payload::size_
unsigned size_
Definition: Block.h:184
l1t::mtf7::SPOut
SP Output Data Record : block->header().getID() = 101.
Definition: Block.h:24
l1t::Block::amc_
amc::Header amc_
Definition: Block.h:95
l1t::Block::payload_
std::vector< uint32_t > payload_
Definition: Block.h:96
l1t::BlockHeader::size_shift
static constexpr unsigned size_shift
Definition: Block.h:56
HLT_FULL_cff.flags
flags
Definition: HLT_FULL_cff.py:13168
l1t::CTP7Payload::CTP7Payload
CTP7Payload(const uint32_t *data, const uint32_t *end, amc::Header amcHeader)
Definition: Block.cc:205
l1t::Block
Definition: Block.h:70
l1t::BlockHeader::getID
unsigned int getID() const
Definition: Block.h:43
l1t::block_t
block_t
Definition: Block.h:11
l1t::Block::getSize
unsigned int getSize() const
Definition: Block.h:83
l1t::CTP7Payload::capId_
unsigned capId_
Definition: Block.h:185
l1t::mtf7::EvHd
Event Record Header : block->header().getID() = 511.
Definition: Block.h:17
l1t::BlockHeader::CTP7_shift
static constexpr unsigned CTP7_shift
Definition: Block.h:52
l1t::Block::header
BlockHeader header() const
Definition: Block.h:85
l1t::Block::operator<
bool operator<(const Block &o) const
Definition: Block.h:81
l1t::MTF7Payload::SP_MAX_PER_BX
static constexpr unsigned SP_MAX_PER_BX
Maximum number of SPz words per MTF7 payload per bx: 3 tracks, 2 words per track.
Definition: Block.h:158
l1t::mtf7::EvTr
Event Record Trailer : block->header().getID() = 255.
Definition: Block.h:25
l1t::Payload::algo_
unsigned algo_
Definition: Block.h:118
l1t::Payload::getAlgorithmFWVersion
virtual unsigned getAlgorithmFWVersion() const
Definition: Block.h:105
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
l1t::BxBlocks
std::vector< BxBlock > BxBlocks
Definition: BxBlock.h:79