CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 <stdint.h>
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, unsigned int board, unsigned int lv1id, unsigned int orbit, unsigned int bx, const std::vector<uint64_t>& load);
77  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);
78  bool write(const edm::Event& ev, unsigned char * ptr, unsigned int skip, unsigned int size) const;
79 
80  inline std::vector<amc::Packet> payload() const { return payload_; };
81 
82  private:
84  std::vector<amc::Packet> payload_;
85  };
86 }
87 
88 #endif
std::vector< amc::Packet > payload() const
Definition: AMC13Spec.h:80
Header header_
Definition: AMC13Spec.h:80
Header(const uint64_t *data)
Definition: AMC13Spec.h:18
static const unsigned int OrN_shift
Definition: AMC13Spec.h:33
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
static const unsigned int LV1_mask
Definition: AMC13Spec.h:62
static void writeCRC(const uint64_t *start, uint64_t *end)
Definition: AMC13Spec.cc:52
static const unsigned int fov
Definition: AMC13Spec.h:36
unsigned int size() const
Definition: AMC13Spec.cc:200
uint64_t raw() const
Definition: AMC13Spec.h:52
unsigned int getCRC() const
Definition: AMC13Spec.h:47
unsigned int blocks() const
Definition: AMC13Spec.cc:189
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:36
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
bool ev
bool write(const edm::Event &ev, unsigned char *ptr, unsigned int skip, unsigned int size) const
Definition: AMC13Spec.cc:218
uint64_t data_
Definition: AMC13Spec.h:39
Trailer(const uint64_t *data)
Definition: AMC13Spec.h:44
std::vector< amc::Packet > payload_
Definition: AMC13Spec.h:84
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:546
static const unsigned int uFOV_mask
Definition: AMC13Spec.h:30
#define end
Definition: vmac.h:37
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:15
void add(unsigned int amc_no, unsigned int board, unsigned int lv1id, unsigned int orbit, unsigned int bx, const std::vector< uint64_t > &load)
Definition: AMC13Spec.cc:61
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:70
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:82
static const unsigned int CRC_shift
Definition: AMC13Spec.h:57
bool check() const
Definition: AMC13Spec.cc:22
static const unsigned int OrN_mask
Definition: AMC13Spec.h:34