CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AMCSpec.h
Go to the documentation of this file.
1 #ifndef AMC_SPEC__h
2 #define AMC_SPEC__h
3 
4 #include <memory>
5 #include <vector>
6 #include <stdint.h>
7 
8 namespace edm {
9  class Event;
10 }
11 
12 namespace amc {
13  static const unsigned int split_block_size = 0x1000;
14 
15  class Header {
16  public:
17  Header() : data_(0) {};
18  Header(const uint64_t *data) : data_(data[0]) {};
19  // size is the total size of the AMC payload, not just of the
20  // block
21  Header(unsigned int amc_no, unsigned int board_id, unsigned int size, unsigned int block=0);
22 
23  operator uint64_t() const { return data_; };
24 
25  inline uint64_t raw() const { return data_; };
26 
27  unsigned int getBlocks() const;
28  unsigned int getBlockSize() const;
29 
30  inline unsigned int getAMCNumber() const { return (data_ >> AmcNo_shift) & AmcNo_mask; };
31  inline unsigned int getBoardID() const { return (data_ >> BoardID_shift) & BoardID_mask; };
32  inline unsigned int getSize() const { return (data_ >> Size_shift) & Size_mask; };
33  inline unsigned int getMore() const { return (data_ >> More_bit_shift) & 1; };
34  inline unsigned int getSegmented() const { return (data_ >> Segmented_bit_shift) & 1; };
35 
36  private:
37  static const unsigned int Size_shift = 32;
38  static const unsigned int Size_mask = 0xffffff;
39  static const unsigned int BlkNo_shift = 20;
40  static const unsigned int BlkNo_mask = 0xff;
41  static const unsigned int AmcNo_shift = 16;
42  static const unsigned int AmcNo_mask = 0xf;
43  static const unsigned int BoardID_shift = 0;
44  static const unsigned int BoardID_mask = 0xffff;
45 
46  static const unsigned int Length_bit_shift = 62;
47  static const unsigned int More_bit_shift = 61;
48  static const unsigned int Segmented_bit_shift = 60;
49  static const unsigned int Enabled_bit_shift = 59;
50  static const unsigned int Present_bit_shift = 58;
51  static const unsigned int Valid_bit_shift = 57;
52  static const unsigned int CRC_bit_shift = 56;
53 
55  };
56 
57  class Packet {
58  public:
59  Packet(const uint64_t* d) : header_(d) {};
60  Packet(unsigned int amc, unsigned int board, const std::vector<uint64_t>& load);
61 
62  void addPayload(const uint64_t*, unsigned int);
63 
64  std::vector<uint64_t> block(unsigned int id) const;
65  std::unique_ptr<uint64_t[]> data();
66  Header header(unsigned int block=0) const { return header_; };
67 
68  inline unsigned int blocks() const { return header_.getBlocks(); };
69  inline unsigned int size() const { return header_.getSize(); };
70 
71  private:
73  std::vector<uint64_t> payload_;
74  };
75 }
76 
77 namespace amc13 {
78  class Header {
79  public:
80  Header() : data_(0) {};
81  Header(const uint64_t *data) : data_(data[0]) {};
82  Header(unsigned int namc, unsigned int orbit);
83 
84  bool valid();
85 
86  inline uint64_t raw() const { return data_; };
87 
88  inline unsigned int getFormatVersion() const { return (data_ >> uFOV_shift) & uFOV_mask; };
89  inline unsigned int getNumberOfAMCs() const { return (data_ >> nAMC_shift) & nAMC_mask; };
90  inline unsigned int getOrbitNumber() const { return (data_ >> OrN_shift) & OrN_mask; };
91 
92  private:
93  static const unsigned int uFOV_shift = 60;
94  static const unsigned int uFOV_mask = 0xf;
95  static const unsigned int nAMC_shift = 52;
96  static const unsigned int nAMC_mask = 0xf;
97  static const unsigned int OrN_shift = 4;
98  static const unsigned int OrN_mask = 0xffffffff;
99 
100  static const unsigned int fov = 1;
101  static const unsigned int max_amc = 12;
102 
104  };
105 
106  class Trailer {
107  public:
108  Trailer(const uint64_t *data) : data_(data[0]) {};
109  Trailer(unsigned int crc, unsigned int blk, unsigned int lv1, unsigned int bx);
110 
111  inline unsigned int getCRC() const { return (data_ >> CRC_shift) & CRC_mask; };
112  inline unsigned int getBlock() const { return (data_ >> BlkNo_shift) & BlkNo_mask; };
113  inline unsigned int getLV1ID() const { return (data_ >> LV1_shift) & LV1_mask; };
114  inline unsigned int getBX() const { return (data_ >> BX_shift) & BX_mask; };
115 
116  uint64_t raw() const { return data_; };
117 
118  private:
119  static const unsigned int CRC_shift = 32;
120  static const unsigned int CRC_mask = 0xffffffff;
121  static const unsigned int BlkNo_shift = 20;
122  static const unsigned int BlkNo_mask = 0xff;
123  static const unsigned int LV1_shift = 12;
124  static const unsigned int LV1_mask = 0xff;
125  static const unsigned int BX_shift = 0;
126  static const unsigned int BX_mask = 0xfff;
127 
129  };
130 
131  class Packet {
132  public:
133  Packet() {};
134 
135  unsigned int blocks() const;
136  unsigned int size() const;
137 
138  void add(unsigned int amc_no, unsigned int board, const std::vector<uint64_t>& load);
139  bool parse(const uint64_t*, unsigned int);
140  bool write(const edm::Event& ev, unsigned char * ptr, unsigned int size) const;
141 
142  inline std::vector<amc::Packet> payload() const { return payload_; };
143 
144  private:
145  Header header_;
146  std::vector<amc::Packet> payload_;
147  };
148 }
149 
150 #endif
std::vector< amc::Packet > payload() const
Definition: AMCSpec.h:142
Header header_
Definition: AMCSpec.h:142
static const unsigned int AmcNo_mask
Definition: AMCSpec.h:42
Header(const uint64_t *data)
Definition: AMCSpec.h:81
static const unsigned int OrN_shift
Definition: AMCSpec.h:97
unsigned int getBlockSize() const
Definition: AMCSpec.cc:64
static const unsigned int BoardID_shift
Definition: AMCSpec.h:43
unsigned int getAMCNumber() const
Definition: AMCSpec.h:30
static const unsigned int LV1_mask
Definition: AMCSpec.h:124
static const unsigned int Size_shift
Definition: AMCSpec.h:37
static const unsigned int fov
Definition: AMCSpec.h:100
unsigned int size() const
Definition: AMCSpec.cc:270
uint64_t raw() const
Definition: AMCSpec.h:116
unsigned int getCRC() const
Definition: AMCSpec.h:111
unsigned int blocks() const
Definition: AMCSpec.cc:259
static const unsigned int Size_mask
Definition: AMCSpec.h:38
static const unsigned int nAMC_mask
Definition: AMCSpec.h:96
static const unsigned int CRC_mask
Definition: AMCSpec.h:120
static const unsigned int BlkNo_mask
Definition: AMCSpec.h:122
unsigned int getBlocks() const
Definition: AMCSpec.cc:52
static const unsigned int BX_mask
Definition: AMCSpec.h:126
std::vector< uint64_t > block(unsigned int id) const
Definition: AMCSpec.cc:87
bool ev
bool valid()
Definition: AMCSpec.cc:118
uint64_t data_
Definition: AMCSpec.h:103
Trailer(const uint64_t *data)
Definition: AMCSpec.h:108
static const unsigned int CRC_bit_shift
Definition: AMCSpec.h:52
void addPayload(const uint64_t *, unsigned int)
Definition: AMCSpec.cc:81
static const unsigned int BlkNo_mask
Definition: AMCSpec.h:40
std::vector< amc::Packet > payload_
Definition: AMCSpec.h:146
unsigned int getBX() const
Definition: AMCSpec.h:114
unsigned int getBlock() const
Definition: AMCSpec.h:112
uint64_t data_
Definition: AMCSpec.h:128
static const unsigned int Length_bit_shift
Definition: AMCSpec.h:46
static const unsigned int uFOV_shift
Definition: AMCSpec.h:93
double amc
Definition: hdecay.h:20
unsigned int getSegmented() const
Definition: AMCSpec.h:34
static const unsigned int BX_shift
Definition: AMCSpec.h:125
def load
Definition: svgfig.py:546
bool write(const edm::Event &ev, unsigned char *ptr, unsigned int size) const
Definition: AMCSpec.cc:288
static const unsigned int uFOV_mask
Definition: AMCSpec.h:94
static const unsigned int AmcNo_shift
Definition: AMCSpec.h:41
static const unsigned int split_block_size
Definition: AMCSpec.h:13
static const unsigned int More_bit_shift
Definition: AMCSpec.h:47
unsigned int getLV1ID() const
Definition: AMCSpec.h:113
uint64_t raw() const
Definition: AMCSpec.h:86
Header header(unsigned int block=0) const
Definition: AMCSpec.h:66
uint64_t data_
Definition: AMCSpec.h:54
static const unsigned int BoardID_mask
Definition: AMCSpec.h:44
static const unsigned int Enabled_bit_shift
Definition: AMCSpec.h:49
unsigned int size() const
Definition: AMCSpec.h:69
static const unsigned int Present_bit_shift
Definition: AMCSpec.h:50
unsigned int getOrbitNumber() const
Definition: AMCSpec.h:90
static const unsigned int max_amc
Definition: AMCSpec.h:101
unsigned long long uint64_t
Definition: Time.h:15
static const unsigned int Segmented_bit_shift
Definition: AMCSpec.h:48
unsigned int getSize() const
Definition: AMCSpec.h:32
static const unsigned int nAMC_shift
Definition: AMCSpec.h:95
unsigned int getMore() const
Definition: AMCSpec.h:33
static const unsigned int LV1_shift
Definition: AMCSpec.h:123
static const unsigned int BlkNo_shift
Definition: AMCSpec.h:121
Header header_
Definition: AMCSpec.h:69
unsigned int getNumberOfAMCs() const
Definition: AMCSpec.h:89
unsigned int getFormatVersion() const
Definition: AMCSpec.h:88
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::unique_ptr< uint64_t[]> data()
Definition: AMCSpec.cc:99
bool parse(const uint64_t *, unsigned int)
Definition: AMCSpec.cc:142
static const unsigned int BlkNo_shift
Definition: AMCSpec.h:39
unsigned int getBoardID() const
Definition: AMCSpec.h:31
static const unsigned int CRC_shift
Definition: AMCSpec.h:119
Packet(const uint64_t *d)
Definition: AMCSpec.h:59
uint64_t raw() const
Definition: AMCSpec.h:25
Header(const uint64_t *data)
Definition: AMCSpec.h:18
void add(unsigned int amc_no, unsigned int board, const std::vector< uint64_t > &load)
Definition: AMCSpec.cc:133
unsigned int blocks() const
Definition: AMCSpec.h:68
tuple size
Write out results.
static const unsigned int Valid_bit_shift
Definition: AMCSpec.h:51
static const unsigned int OrN_mask
Definition: AMCSpec.h:98
std::vector< uint64_t > payload_
Definition: AMCSpec.h:73