CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
AMC13Spec.h
Go to the documentation of this file.
1 #ifndef EventFilter_L1TRawToDigi_AMC13_SPEC__h
2 #define EventFilter_L1TRawToDigi_AMC13_SPEC__h
3 
4 #include <memory>
5 #include <vector>
6 #include <cstdint>
7 
8 #include "AMCSpec.h"
9 
10 namespace edm {
11  class Event;
12 }
13 
14 namespace amc13 {
15  class Header {
16  public:
17  Header() : data_(0){};
18  Header(const uint64_t *data) : data_(data[0]){};
19  Header(unsigned int namc, unsigned int orbit);
20 
21  inline uint64_t raw() const { return data_; };
22  bool check() const;
23 
24  inline unsigned int getFormatVersion() const { return (data_ >> uFOV_shift) & uFOV_mask; };
25  inline unsigned int getNumberOfAMCs() const { return (data_ >> nAMC_shift) & nAMC_mask; };
26  inline unsigned int getOrbitNumber() const { return (data_ >> OrN_shift) & OrN_mask; };
27 
28  private:
29  static const unsigned int uFOV_shift = 60;
30  static const unsigned int uFOV_mask = 0xf;
31  static const unsigned int nAMC_shift = 52;
32  static const unsigned int nAMC_mask = 0xf;
33  static const unsigned int OrN_shift = 4;
34  static const unsigned int OrN_mask = 0xffffffff;
35 
36  static const unsigned int fov = 1;
37  static const unsigned int max_amc = 12;
38 
40  };
41 
42  class Trailer {
43  public:
44  Trailer(const uint64_t *data) : data_(data[0]){};
45  Trailer(unsigned int blk, unsigned int lv1, unsigned int bx);
46 
47  inline unsigned int getCRC() const { return (data_ >> CRC_shift) & CRC_mask; };
48  inline unsigned int getBlock() const { return (data_ >> BlkNo_shift) & BlkNo_mask; };
49  inline unsigned int getLV1ID() const { return (data_ >> LV1_shift) & LV1_mask; };
50  inline unsigned int getBX() const { return (data_ >> BX_shift) & BX_mask; };
51 
52  uint64_t raw() const { return data_; };
53  bool check(unsigned int crc, unsigned int block, unsigned int lv1_id, unsigned int bx) const;
54  static void writeCRC(const uint64_t *start, uint64_t *end);
55 
56  private:
57  static const unsigned int CRC_shift = 32;
58  static const unsigned int CRC_mask = 0xffffffff;
59  static const unsigned int BlkNo_shift = 20;
60  static const unsigned int BlkNo_mask = 0xff;
61  static const unsigned int LV1_shift = 12;
62  static const unsigned int LV1_mask = 0xff;
63  static const unsigned int BX_shift = 0;
64  static const unsigned int BX_mask = 0xfff;
65 
67  };
68 
69  class Packet {
70  public:
71  Packet(){};
72 
73  unsigned int blocks() const;
74  unsigned int size() const;
75 
76  void add(unsigned int amc_no,
77  unsigned int board,
78  unsigned int lv1id,
79  unsigned int orbit,
80  unsigned int bx,
81  const std::vector<uint64_t> &load,
82  unsigned int user = 0);
83  bool parse(const uint64_t *start,
84  const uint64_t *data,
85  unsigned int size,
86  unsigned int lv1,
87  unsigned int bx,
88  bool legacy_mc = false,
89  bool mtf7_mode = false);
90  bool write(const edm::Event &ev, unsigned char *ptr, unsigned int skip, unsigned int size) const;
91 
92  inline std::vector<amc::Packet> payload() const { return payload_; };
93 
94  private:
96  std::vector<amc::Packet> payload_;
97  };
98 } // namespace amc13
99 
100 #endif
std::vector< amc::Packet > payload() const
Definition: AMC13Spec.h:92
Header header_
Definition: AMC13Spec.h:92
Header(const uint64_t *data)
Definition: AMC13Spec.h:18
static const unsigned int OrN_shift
Definition: AMC13Spec.h:33
static const unsigned int LV1_mask
Definition: AMC13Spec.h:62
static void writeCRC(const uint64_t *start, uint64_t *end)
Definition: AMC13Spec.cc:40
static const unsigned int fov
Definition: AMC13Spec.h:36
unsigned int size() const
Definition: AMC13Spec.cc:186
uint64_t raw() const
Definition: AMC13Spec.h:52
unsigned int getCRC() const
Definition: AMC13Spec.h:47
unsigned int blocks() const
Definition: AMC13Spec.cc:177
static const unsigned int nAMC_mask
Definition: AMC13Spec.h:32
bool check(unsigned int crc, unsigned int block, unsigned int lv1_id, unsigned int bx) const
Definition: AMC13Spec.cc:26
static const unsigned int CRC_mask
Definition: AMC13Spec.h:58
static const unsigned int BlkNo_mask
Definition: AMC13Spec.h:60
static const unsigned int BX_mask
Definition: AMC13Spec.h:64
void add(unsigned int amc_no, unsigned int board, unsigned int lv1id, unsigned int orbit, unsigned int bx, const std::vector< uint64_t > &load, unsigned int user=0)
Definition: AMC13Spec.cc:47
bool write(const edm::Event &ev, unsigned char *ptr, unsigned int skip, unsigned int size) const
Definition: AMC13Spec.cc:202
uint64_t data_
Definition: AMC13Spec.h:39
Trailer(const uint64_t *data)
Definition: AMC13Spec.h:44
std::vector< amc::Packet > payload_
Definition: AMC13Spec.h:96
unsigned int getBX() const
Definition: AMC13Spec.h:50
unsigned int getBlock() const
Definition: AMC13Spec.h:48
uint64_t data_
Definition: AMC13Spec.h:66
static const unsigned int uFOV_shift
Definition: AMC13Spec.h:29
static const unsigned int BX_shift
Definition: AMC13Spec.h:63
def load
Definition: svgfig.py:547
static const unsigned int uFOV_mask
Definition: AMC13Spec.h:30
unsigned int getLV1ID() const
Definition: AMC13Spec.h:49
uint64_t raw() const
Definition: AMC13Spec.h:21
unsigned int getOrbitNumber() const
Definition: AMC13Spec.h:26
static const unsigned int max_amc
Definition: AMC13Spec.h:37
unsigned long long uint64_t
Definition: Time.h:13
bool parse(const uint64_t *start, const uint64_t *data, unsigned int size, unsigned int lv1, unsigned int bx, bool legacy_mc=false, bool mtf7_mode=false)
Definition: AMC13Spec.cc:60
static const unsigned int nAMC_shift
Definition: AMC13Spec.h:31
static const unsigned int LV1_shift
Definition: AMC13Spec.h:61
static const unsigned int BlkNo_shift
Definition: AMC13Spec.h:59
unsigned int getNumberOfAMCs() const
Definition: AMC13Spec.h:25
unsigned int getFormatVersion() const
Definition: AMC13Spec.h:24
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
string end
Definition: dataset.py:937
static const unsigned int CRC_shift
Definition: AMC13Spec.h:57
bool check() const
Definition: AMC13Spec.cc:19
static const unsigned int OrN_mask
Definition: AMC13Spec.h:34