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 
13  class BlockHeader {
14  public:
15  BlockHeader(unsigned int id, unsigned int size, unsigned int capID = 0, unsigned int flags = 0, block_t type = MP7)
16  : id_(id), size_(size), capID_(capID), flags_(flags), type_(type){};
17  // Create a MP7 block header: everything is contained in the raw uint32
18  BlockHeader(const uint32_t* data)
19  : id_((data[0] >> ID_shift) & ID_mask),
20  size_((data[0] >> size_shift) & size_mask),
21  capID_((data[0] >> capID_shift) & capID_mask),
22  flags_((data[0] >> flags_shift) & flags_mask),
23  type_(MP7){};
24 
25  bool operator<(const BlockHeader& o) const { return getID() < o.getID(); };
26 
27  unsigned int getID() const { return id_; };
28  unsigned int getSize() const { return size_; };
29  unsigned int getCapID() const { return capID_; };
30  unsigned int getFlags() const { return flags_; };
31  block_t getType() const { return type_; };
32 
33  uint32_t raw() const;
34 
35  private:
36  static constexpr unsigned CTP7_shift = 0;
37  static constexpr unsigned CTP7_mask = 0xffff;
38  static constexpr unsigned ID_shift = 24;
39  static constexpr unsigned ID_mask = 0xff;
40  static constexpr unsigned size_shift = 16;
41  static constexpr unsigned size_mask = 0xff;
42  static constexpr unsigned capID_shift = 8;
43  static constexpr unsigned capID_mask = 0xff;
44  static constexpr unsigned flags_shift = 0;
45  static constexpr unsigned flags_mask = 0xff;
46 
47  unsigned int id_;
48  unsigned int size_;
49  unsigned int capID_;
50  unsigned int flags_;
52  };
53 
54  class Block {
55  public:
56  Block(const BlockHeader& h, const uint32_t* payload_start, const uint32_t* payload_end)
57  : header_(h), payload_(payload_start, payload_end){};
58  Block(unsigned int id,
59  const std::vector<uint32_t>& payload,
60  unsigned int capID = 0,
61  unsigned int flags = 0,
62  block_t type = MP7)
63  : header_(id, payload.size(), capID, flags, type), payload_(payload){};
64 
65  bool operator<(const Block& o) const { return header() < o.header(); };
66 
67  inline unsigned int getSize() const { return payload_.size() + 1; };
68 
69  BlockHeader header() const { return header_; };
70  const std::vector<uint32_t>& payload() const { return payload_; };
71 
72  void amc(const amc::Header& h) { amc_ = h; };
73  amc::Header amc() const { return amc_; };
74 
75  BxBlocks getBxBlocks(unsigned int payloadWordsPerBx, bool bxHeader) const;
76 
77  private:
80  std::vector<uint32_t> payload_;
81  };
82 
83  typedef std::vector<Block> Blocks;
84 
85  class Payload {
86  public:
87  Payload(const uint32_t* data, const uint32_t* end) : data_(data), end_(end), algo_(0), infra_(0){};
88  virtual ~Payload(){};
89  virtual unsigned getAlgorithmFWVersion() const { return algo_; };
90  virtual unsigned getInfrastructureFWVersion() const { return infra_; };
91  virtual unsigned getHeaderSize() const = 0;
92  // Read header from data_ and advance data_ to point behind the
93  // header. Called by getBlock(), which also checks that data_ !=
94  // end_ before calling (assumes size of one 32 bit word).
95  virtual BlockHeader getHeader() = 0;
96  virtual std::unique_ptr<Block> getBlock();
97 
98  protected:
99  const uint32_t* data_;
100  const uint32_t* end_;
101 
102  unsigned algo_;
103  unsigned infra_;
104  };
105 
106  class MP7Payload : public Payload {
107  public:
108  MP7Payload(const uint32_t* data, const uint32_t* end, bool legacy_mc = false);
109  unsigned getHeaderSize() const override { return 1; };
110  BlockHeader getHeader() override;
111  };
112 
113  class MTF7Payload : public Payload {
114  public:
115  MTF7Payload(const uint32_t* data, const uint32_t* end);
116  // Unused methods - we override getBlock() instead
117  unsigned getHeaderSize() const override { return 0; };
118  BlockHeader getHeader() override { return BlockHeader(nullptr); };
119  std::unique_ptr<Block> getBlock() override;
120 
121  private:
122  // sizes in 16 bit words
123  static constexpr unsigned header_size = 12;
124  static constexpr unsigned counter_size = 4;
125  static constexpr unsigned trailer_size = 8;
126 
127  // maximum of the block length (64bits) and bit patterns of the
128  // first bits (of 16bit words)
129  static constexpr unsigned max_block_length_ = 3;
130  static const std::vector<unsigned int> block_patterns_;
131 
132  int count(unsigned int pattern, unsigned int length) const;
133  bool valid(unsigned int pattern) const;
134  };
135 
136  class CTP7Payload : public Payload {
137  public:
138  CTP7Payload(const uint32_t* data, const uint32_t* end, amc::Header amcHeader);
139  unsigned getHeaderSize() const override { return 2; };
140  BlockHeader getHeader() override;
141  std::unique_ptr<Block> getBlock() override;
142 
143  private:
144  // FIXME check values
145  static constexpr unsigned size_mask = 0xff;
146  static constexpr unsigned size_shift = 16;
147 
148  unsigned size_;
149  unsigned capId_;
150  unsigned bx_per_l1a_;
151  unsigned calo_bxid_;
153  };
154 } // namespace l1t
155 
156 #endif
l1t::Blocks
std::vector< Block > Blocks
Definition: Block.h:83
l1t::Payload
Definition: Block.h:85
l1t::BlockHeader::flags_shift
static constexpr unsigned flags_shift
Definition: Block.h:44
l1t::MTF7Payload::getHeaderSize
unsigned getHeaderSize() const override
Definition: Block.h:117
l1t::Block::amc
void amc(const amc::Header &h)
Definition: Block.h:72
l1t::Payload::getInfrastructureFWVersion
virtual unsigned getInfrastructureFWVersion() const
Definition: Block.h:90
l1t::BlockHeader::type_
block_t type_
Definition: Block.h:51
l1t::BlockHeader::BlockHeader
BlockHeader(const uint32_t *data)
Definition: Block.h:18
l1t::MTF7Payload::MTF7Payload
MTF7Payload(const uint32_t *data, const uint32_t *end)
Definition: Block.cc:113
amc::Header
Definition: AMCSpec.h:59
l1t::BlockHeader::flags_
unsigned int flags_
Definition: Block.h:50
l1t::MP7Payload::MP7Payload
MP7Payload(const uint32_t *data, const uint32_t *end, bool legacy_mc=false)
Definition: Block.cc:93
h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition: L1TUtmAlgorithmRcd.h:4
l1t::CTP7
Definition: Block.h:11
l1t::CTP7Payload::getHeaderSize
unsigned getHeaderSize() const override
Definition: Block.h:139
l1t::MTF7Payload::trailer_size
static constexpr unsigned trailer_size
Definition: Block.h:125
l1t::Payload::end_
const uint32_t * end_
Definition: Block.h:100
l1t::MTF7Payload::block_patterns_
static const std::vector< unsigned int > block_patterns_
Definition: Block.h:130
l1t::Payload::getBlock
virtual std::unique_ptr< Block > getBlock()
Definition: Block.cc:66
l1t::Payload::Payload
Payload(const uint32_t *data, const uint32_t *end)
Definition: Block.h:87
l1t::CTP7Payload::getHeader
BlockHeader getHeader() override
Definition: Block.cc:222
l1t::MTF7Payload::counter_size
static constexpr unsigned counter_size
Definition: Block.h:124
l1t::Block::amc
amc::Header amc() const
Definition: Block.h:73
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:150
l1t::MTF7Payload
Definition: Block.h:113
l1t::BlockHeader::capID_mask
static constexpr unsigned capID_mask
Definition: Block.h:43
l1t::CTP7Payload::calo_bxid_
unsigned calo_bxid_
Definition: Block.h:151
l1t::Payload::~Payload
virtual ~Payload()
Definition: Block.h:88
l1t::CTP7Payload::size_mask
static constexpr unsigned size_mask
Definition: Block.h:145
end
#define end
Definition: vmac.h:39
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:36
l1t::Block::Block
Block(const BlockHeader &h, const uint32_t *payload_start, const uint32_t *payload_end)
Definition: Block.h:56
l1t::BlockHeader::flags_mask
static constexpr unsigned flags_mask
Definition: Block.h:45
l1t::Payload::infra_
unsigned infra_
Definition: Block.h:103
l1t::Payload::getHeader
virtual BlockHeader getHeader()=0
l1t::BlockHeader::ID_mask
static constexpr unsigned ID_mask
Definition: Block.h:39
l1t::Block::header_
BlockHeader header_
Definition: Block.h:78
l1t::Payload::getHeaderSize
virtual unsigned getHeaderSize() const =0
l1t::BlockHeader::CTP7_mask
static constexpr unsigned CTP7_mask
Definition: Block.h:37
l1t::CTP7Payload
Definition: Block.h:136
l1t::BlockHeader::operator<
bool operator<(const BlockHeader &o) const
Definition: Block.h:25
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:152
h
l1t::MP7Payload
Definition: Block.h:106
l1t::BlockHeader::getFlags
unsigned int getFlags() const
Definition: Block.h:30
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_
Definition: Block.h:129
l1t
delete x;
Definition: CaloConfig.h:22
l1t::MP7Payload::getHeader
BlockHeader getHeader() override
Definition: Block.cc:107
l1t::BlockHeader::raw
uint32_t raw() const
Definition: Block.cc:25
l1t::BlockHeader
Definition: Block.h:13
l1t::MP7Payload::getHeaderSize
unsigned getHeaderSize() const override
Definition: Block.h:109
topSingleLeptonDQM_PU_cfi.pattern
pattern
Definition: topSingleLeptonDQM_PU_cfi.py:39
l1t::BlockHeader::getSize
unsigned int getSize() const
Definition: Block.h:28
l1t::BlockHeader::id_
unsigned int id_
Definition: Block.h:47
l1t::MTF7Payload::valid
bool valid(unsigned int pattern) const
Definition: Block.cc:165
l1t::MTF7
Definition: Block.h:11
l1t::BlockHeader::ID_shift
static constexpr unsigned ID_shift
Definition: Block.h:38
l1t::Block::payload
const std::vector< uint32_t > & payload() const
Definition: Block.h:70
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:15
l1t::CTP7Payload::size_shift
static constexpr unsigned size_shift
Definition: Block.h:146
type
type
Definition: HCALResponse.h:21
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:58
BxBlock.h
l1t::Block::getBxBlocks
BxBlocks getBxBlocks(unsigned int payloadWordsPerBx, bool bxHeader) const
Definition: Block.cc:42
l1t::BlockHeader::getCapID
unsigned int getCapID() const
Definition: Block.h:29
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
l1t::BlockHeader::size_
unsigned int size_
Definition: Block.h:48
l1t::BlockHeader::size_mask
static constexpr unsigned size_mask
Definition: Block.h:41
l1t::MTF7Payload::header_size
static constexpr unsigned header_size
Definition: Block.h:123
l1t::MTF7Payload::getHeader
BlockHeader getHeader() override
Definition: Block.h:118
l1t::BlockHeader::getType
block_t getType() const
Definition: Block.h:31
l1t::BlockHeader::capID_
unsigned int capID_
Definition: Block.h:49
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
l1t::Payload::data_
const uint32_t * data_
Definition: Block.h:99
l1t::BlockHeader::capID_shift
static constexpr unsigned capID_shift
Definition: Block.h:42
AMCSpec.h
l1t::CTP7Payload::size_
unsigned size_
Definition: Block.h:148
l1t::Block::amc_
amc::Header amc_
Definition: Block.h:79
l1t::Block::payload_
std::vector< uint32_t > payload_
Definition: Block.h:80
l1t::BlockHeader::size_shift
static constexpr unsigned size_shift
Definition: Block.h:40
l1t::CTP7Payload::CTP7Payload
CTP7Payload(const uint32_t *data, const uint32_t *end, amc::Header amcHeader)
Definition: Block.cc:205
l1t::Block
Definition: Block.h:54
l1t::BlockHeader::getID
unsigned int getID() const
Definition: Block.h:27
l1t::block_t
block_t
Definition: Block.h:11
l1t::Block::getSize
unsigned int getSize() const
Definition: Block.h:67
l1t::CTP7Payload::capId_
unsigned capId_
Definition: Block.h:149
l1t::BlockHeader::CTP7_shift
static constexpr unsigned CTP7_shift
Definition: Block.h:36
HLT_2018_cff.flags
flags
Definition: HLT_2018_cff.py:11758
l1t::Block::header
BlockHeader header() const
Definition: Block.h:69
l1t::Block::operator<
bool operator<(const Block &o) const
Definition: Block.h:65
l1t::Payload::algo_
unsigned algo_
Definition: Block.h:102
l1t::Payload::getAlgorithmFWVersion
virtual unsigned getAlgorithmFWVersion() const
Definition: Block.h:89
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
l1t::BxBlocks
std::vector< BxBlock > BxBlocks
Definition: BxBlock.h:79