CMS 3D CMS Logo

AMC13Event.h
Go to the documentation of this file.
1 #ifndef EventFilter_GEMRawToDigi_AMC13Event_h
2 #define EventFilter_GEMRawToDigi_AMC13Event_h
3 #include <vector>
4 #include "AMCdata.h"
5 
6 namespace gem {
7 
8  union CDFHeader {
10  struct {
11  uint64_t fov : 8; // not used
12  uint64_t sourceId : 12; // FED number assigned by CDAQ
13  uint64_t bxId : 12; // Bunch crossing 0...3563
14  uint64_t lv1Id : 24; // Level 1 ID (hardware event number)
15  uint64_t eventType : 4; // Event Type (1 for normal, 2 for calibration)
16  uint64_t cb5 : 4; // 0x5
17  };
18  };
19  union AMC13Header {
21  struct {
22  uint64_t cb0 : 4; // 0x0
23  uint64_t orbitN : 32; // Orbit Number
24  uint64_t reserved0 : 16; // reserved
25  uint64_t nAMC : 4; // Number of AMCs following (0 to 12)
26  uint64_t calType : 4; // Calibration event type
27  uint64_t uFov : 4; // Format version: 0x1
28  };
29  };
30  union AMC13Trailer {
32  struct {
33  uint64_t bxIdT : 12; // bx id
34  uint64_t lv1IdT : 8; // level 1 id
35  uint64_t blkN : 8; // block number
36  uint64_t crc32 : 36; // Overall CRC (first 34 bits)
37  };
38  };
39  union CDFTrailer {
41  struct {
42  uint64_t tts : 8; // tts (first 4 bits)
43  uint64_t evtStat : 4; // event status
44  uint64_t crcCDF : 20; // CDF crc (first 16 bits)
45  uint64_t evtLength : 24; // event length
46  uint64_t cbA : 8; // 0xA (first 4 bits)
47  };
48  };
49 
50  class AMC13Event
51  {
52 
53  public:
55  ~AMC13Event() {amcHeaders_.clear(); amcs_.clear();}
56 
57  void setCDFHeader(uint64_t word) { cdfh_ = word;}
58  void setCDFHeader(uint8_t Evt_ty, uint32_t LV1_id, uint16_t BX_id, uint16_t Source_id);
59  uint64_t getCDFHeader() const { return cdfh_;}
60 
61  void setAMC13Header(uint64_t word) { amc13h_ = word;}
62  void setAMC13Header(uint8_t CalTyp, uint8_t nAMC, uint32_t OrN);
63  uint64_t getAMC13Header() const { return amc13h_;}
64 
65  void setAMC13Trailer(uint64_t word) { amc13t_ = word;}
66  void setAMC13Trailer(uint8_t Blk_NoT, uint8_t LV1_idT, uint16_t BX_idT);
67  uint64_t getAMC13Trailer() const { return amc13t_;}
68 
69  void setCDFTrailer(uint64_t word) { cdft_ = word;}
70  void setCDFTrailer(uint32_t EvtLength);
71  uint64_t getCDFTrailer() const { return cdft_;}
72 
73  uint16_t bxId() const {return CDFHeader{cdfh_}.bxId;}
74  uint32_t lv1Id() const {return CDFHeader{cdfh_}.lv1Id;}
75  uint16_t sourceId() const {return CDFHeader{cdfh_}.sourceId;}
76 
77  uint8_t nAMC() const {return AMC13Header{amc13h_}.nAMC;}
78 
79  const std::vector<uint64_t> * getAMCheaders() const {return &amcHeaders_;}
80  void addAMCheader(uint64_t word);
81  void addAMCheader(uint32_t AMC_size, uint8_t Blk_No, uint8_t AMC_No, uint16_t BoardID);
82 
83  const std::vector<AMCdata> * getAMCpayloads() const {return &amcs_;}
84  void addAMCpayload(const AMCdata& a) {amcs_.push_back(a);}
85 
86  private:
87  uint64_t cdfh_; // CDFHeader
88  uint64_t amc13h_; // AMC13Header
89  uint64_t amc13t_; // AMC13Trailer
90  uint64_t cdft_; // CDFTrailer
91 
92  // AMC headers
93  std::vector<uint64_t> amcHeaders_;
94  // AMCs payload
95  std::vector<AMCdata> amcs_;
96 
97  };
98 }
99 #endif
void addAMCpayload(const AMCdata &a)
Definition: AMC13Event.h:84
uint64_t amc13h_
Definition: AMC13Event.h:88
uint64_t word
Definition: AMC13Event.h:9
uint64_t cdft_
Definition: AMC13Event.h:90
uint64_t bxId
Definition: AMC13Event.h:13
uint32_t lv1Id() const
Definition: AMC13Event.h:74
void setAMC13Trailer(uint64_t word)
Definition: AMC13Event.h:65
void setCDFTrailer(uint64_t word)
Definition: AMC13Event.h:69
std::vector< uint64_t > amcHeaders_
Definition: AMC13Event.h:93
uint64_t eventType
Definition: AMC13Event.h:15
uint64_t cdfh_
Definition: AMC13Event.h:87
uint16_t sourceId() const
Definition: AMC13Event.h:75
uint64_t getAMC13Trailer() const
Definition: AMC13Event.h:67
Definition: AMC13Event.h:6
std::vector< AMCdata > amcs_
Definition: AMC13Event.h:95
void setCDFHeader(uint64_t word)
Definition: AMC13Event.h:57
const std::vector< uint64_t > * getAMCheaders() const
Definition: AMC13Event.h:79
uint64_t sourceId
Definition: AMC13Event.h:12
uint16_t bxId() const
Definition: AMC13Event.h:73
uint64_t word
Definition: AMC13Event.h:20
uint64_t nAMC
Definition: AMC13Event.h:25
unsigned long long uint64_t
Definition: Time.h:15
void setAMC13Header(uint64_t word)
Definition: AMC13Event.h:61
uint64_t cb5
Definition: AMC13Event.h:16
uint64_t getCDFTrailer() const
Definition: AMC13Event.h:71
uint64_t amc13t_
Definition: AMC13Event.h:89
uint64_t fov
Definition: AMC13Event.h:11
double a
Definition: hdecay.h:121
const std::vector< AMCdata > * getAMCpayloads() const
Definition: AMC13Event.h:83
uint64_t getCDFHeader() const
Definition: AMC13Event.h:59
uint64_t lv1Id
Definition: AMC13Event.h:14
uint64_t getAMC13Header() const
Definition: AMC13Event.h:63
uint64_t word
Definition: AMC13Event.h:40
uint8_t nAMC() const
Definition: AMC13Event.h:77