CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Block.h
Go to the documentation of this file.
1 #ifndef Block_h
2 #define Block_h
3 
4 #include <memory>
5 #include <vector>
6 
8 
9 namespace l1t {
10  enum block_t { MP7 = 0, CTP7 };
11 
12  class BlockHeader {
13  public:
14  BlockHeader(unsigned int id, unsigned int size, unsigned int capID=0, block_t type=MP7) : id_(id), size_(size), capID_(capID), type_(type) {};
15  // Create a MP7 block header: everything is contained in the raw uint32
16  BlockHeader(const uint32_t *data) : id_((data[0] >> ID_shift) & ID_mask), size_((data[0] >> size_shift) & size_mask), capID_((data[0] >> capID_shift) & capID_mask), type_(MP7) {};
17  // Create a CTP7 block header: size is contained in the general CTP7 header
18  BlockHeader(const uint32_t *data, unsigned int size) : id_((data[0] >> CTP7_shift) & CTP7_mask), size_(size), capID_(0), type_(CTP7) {};
19 
20  bool operator<(const BlockHeader& o) const { return getID() < o.getID(); };
21 
22  unsigned int getID() const { return id_; };
23  unsigned int getSize() const { return size_; };
24  unsigned int getCapID() const { return capID_; };
25  block_t getType() const { return type_; };
26 
27  uint32_t raw(block_t type=MP7) const;
28 
29  private:
30  static const unsigned int CTP7_shift = 0;
31  static const unsigned int CTP7_mask = 0xffff;
32  static const unsigned int ID_shift = 24;
33  static const unsigned int ID_mask = 0xff;
34  static const unsigned int size_shift = 16;
35  static const unsigned int size_mask = 0xff;
36  static const unsigned int capID_shift = 8;
37  static const unsigned int capID_mask = 0xff;
38 
39  unsigned int id_;
40  unsigned int size_;
41  unsigned int capID_;
43  };
44 
45  class Block {
46  public:
47  Block(const BlockHeader& h, const uint32_t * payload_start, const uint32_t * payload_end) :
48  header_(h), payload_(payload_start, payload_end) {};
49  Block(unsigned int id, const std::vector<uint32_t>& payload, unsigned int capID=0, block_t type=MP7) :
50  header_(id, payload.size(), capID, type), payload_(payload) {};
51 
52  bool operator<(const Block& o) const { return header() < o.header(); };
53 
54  inline unsigned int getSize() const { return payload_.size() + 1; };
55 
56  BlockHeader header() const { return header_; };
57  std::vector<uint32_t> payload() const { return payload_; };
58 
59  void amc(const amc::Header& h) { amc_ = h; };
60  amc::Header amc() const { return amc_; };
61 
62  private:
65  std::vector<uint32_t> payload_;
66  };
67 
68  typedef std::vector<Block> Blocks;
69 
70  class Payload {
71  public:
72  Payload(const uint32_t * data, const uint32_t * end) : data_(data), end_(end), algo_(0), infra_(0) {};
73 
74  virtual unsigned getAlgorithmFWVersion() const { return algo_; };
75  virtual unsigned getInfrastructureFWVersion() const { return infra_; };
76  virtual unsigned getHeaderSize() const = 0;
77  // Read header from data_ and advance data_ to point behind the
78  // header. Called by getBlock(), which also checks that data_ !=
79  // end_ before calling (assumes size of one 32 bit word).
80  virtual BlockHeader getHeader() = 0;
81  std::auto_ptr<Block> getBlock();
82  protected:
83  const uint32_t * data_;
84  const uint32_t * end_;
85 
86  unsigned algo_;
87  unsigned infra_;
88  };
89 
90  class MP7Payload : public Payload {
91  public:
92  MP7Payload(const uint32_t * data, const uint32_t * end, bool legacy_mc=false);
93  virtual unsigned getHeaderSize() const override { return 1; };
94  virtual BlockHeader getHeader() override;
95  };
96 
97  class CTP7Payload : public Payload {
98  public:
99  CTP7Payload(const uint32_t * data, const uint32_t * end);
100  virtual unsigned getHeaderSize() const override { return 2; };
101  virtual BlockHeader getHeader() override;
102  private:
103  // FIXME check values
104  static const unsigned int size_mask = 0xff;
105  static const unsigned int size_shift = 16;
106 
107  unsigned size_;
108  };
109 }
110 
111 #endif
virtual unsigned getHeaderSize() const override
Definition: Block.h:93
uint32_t raw(block_t type=MP7) const
Definition: Block.cc:11
type
Definition: HCALResponse.h:21
static const unsigned int capID_mask
Definition: Block.h:37
static const unsigned int size_shift
Definition: Block.h:105
virtual BlockHeader getHeader() override
Definition: Block.cc:82
amc::Header amc() const
Definition: Block.h:60
std::vector< uint32_t > payload_
Definition: Block.h:65
static const unsigned int CTP7_mask
Definition: Block.h:31
MP7Payload(const uint32_t *data, const uint32_t *end, bool legacy_mc=false)
Definition: Block.cc:51
Block(const BlockHeader &h, const uint32_t *payload_start, const uint32_t *payload_end)
Definition: Block.h:47
std::auto_ptr< Block > getBlock()
Definition: Block.cc:22
BlockHeader(unsigned int id, unsigned int size, unsigned int capID=0, block_t type=MP7)
Definition: Block.h:14
unsigned int getID() const
Definition: Block.h:22
Definition: Block.h:10
BlockHeader header() const
Definition: Block.h:56
block_t getType() const
Definition: Block.h:25
static const unsigned int ID_shift
Definition: Block.h:32
block_t type_
Definition: Block.h:42
const uint32_t * end_
Definition: Block.h:84
std::vector< uint32_t > payload() const
Definition: Block.h:57
static const unsigned int ID_mask
Definition: Block.h:33
BlockHeader(const uint32_t *data)
Definition: Block.h:16
unsigned size_
Definition: Block.h:107
virtual BlockHeader getHeader()=0
Block(unsigned int id, const std::vector< uint32_t > &payload, unsigned int capID=0, block_t type=MP7)
Definition: Block.h:49
virtual unsigned getInfrastructureFWVersion() const
Definition: Block.h:75
block_t
Definition: Block.h:10
virtual unsigned getAlgorithmFWVersion() const
Definition: Block.h:74
CTP7Payload(const uint32_t *data, const uint32_t *end)
Definition: Block.cc:74
std::vector< Block > Blocks
Definition: Block.h:68
virtual unsigned getHeaderSize() const =0
BlockHeader header_
Definition: Block.h:60
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
static const unsigned int size_mask
Definition: Block.h:35
#define end
Definition: vmac.h:37
unsigned infra_
Definition: Block.h:87
unsigned int size_
Definition: Block.h:40
unsigned int capID_
Definition: Block.h:41
const uint32_t * data_
Definition: Block.h:83
amc::Header amc_
Definition: Block.h:64
unsigned int getCapID() const
Definition: Block.h:24
virtual BlockHeader getHeader() override
Definition: Block.cc:67
static const unsigned int size_mask
Definition: Block.h:104
static const unsigned int CTP7_shift
Definition: Block.h:30
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
unsigned int id_
Definition: Block.h:39
virtual unsigned getHeaderSize() const override
Definition: Block.h:100
bool operator<(const BlockHeader &o) const
Definition: Block.h:20
unsigned int getSize() const
Definition: Block.h:23
static const unsigned int capID_shift
Definition: Block.h:36
BlockHeader(const uint32_t *data, unsigned int size)
Definition: Block.h:18
static const unsigned int size_shift
Definition: Block.h:34
void amc(const amc::Header &h)
Definition: Block.h:59
unsigned int getSize() const
Definition: Block.h:54
tuple size
Write out results.
unsigned algo_
Definition: Block.h:86
Payload(const uint32_t *data, const uint32_t *end)
Definition: Block.h:72
bool operator<(const Block &o) const
Definition: Block.h:52