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