CMS 3D CMS Logo

Phase2TrackerFEDDAQHeader.h
Go to the documentation of this file.
1 #ifndef EventFilter_Phase2TrackerRawToDigi_Phase2TrackerFEDDAQHeader_H // {
2 #define EventFilter_Phase2TrackerRawToDigi_Phase2TrackerFEDDAQHeader_H
3 
4 #include <cstring>
6 
7 namespace Phase2Tracker {
8 
9  //
10  // Constants
11  //
12 
13  //enum values are values which appear in buffer. DO NOT CHANGE!
14  //see http://cmsdoc.cern.ch/cms/TRIDAS/horizontal/RUWG/DAQ_IF_guide/DAQ_IF_guide.html
24  };
25 
26  //to make enums printable
27  inline std::ostream& operator<<(std::ostream& os, const FEDDAQEventType& value);
28 
29  //see http://cmsdoc.cern.ch/cms/TRIDAS/horizontal/RUWG/DAQ_IF_guide/DAQ_IF_guide.html
30  class FEDDAQHeader {
31  public:
33  explicit FEDDAQHeader(const uint8_t* header);
34 
35  // getters
36  //0x5 in first fragment
37  uint8_t boeNibble() const;
38  uint8_t eventTypeNibble() const;
39  FEDDAQEventType eventType() const;
40  uint32_t l1ID() const;
41  uint16_t bxID() const;
42  uint16_t sourceID() const;
43  uint8_t version() const;
44  //0 if current header word is last, 1 otherwise
45  bool hBit() const;
46  bool lastHeader() const;
47  void print(std::ostream& os) const;
48 
49  //used by digi2Raw
50  const uint8_t* data() const;
51 
52  // setters
53  void setEventType(const FEDDAQEventType evtType);
54  void setL1ID(const uint32_t l1ID);
55  void setBXID(const uint16_t bxID);
56  void setSourceID(const uint16_t sourceID);
57  FEDDAQHeader(const uint32_t l1ID,
58  const uint16_t bxID,
59  const uint16_t sourceID,
60  const FEDDAQEventType evtType = DAQ_EVENT_TYPE_PHYSICS);
61 
62  private:
63  uint8_t header_[8];
64  }; // end of FEDDAQHeader class
65 
66  //FEDDAQHeader
67 
68  inline FEDDAQHeader::FEDDAQHeader(const uint8_t* header) { memcpy(header_, header, 8); }
69 
70  inline uint8_t FEDDAQHeader::boeNibble() const { return ((header_[7] & 0xF0) >> 4); }
71 
72  inline uint8_t FEDDAQHeader::eventTypeNibble() const { return (header_[7] & 0x0F); }
73 
74  inline uint32_t FEDDAQHeader::l1ID() const { return (header_[4] | (header_[5] << 8) | (header_[6] << 16)); }
75 
76  inline uint16_t FEDDAQHeader::bxID() const { return ((header_[3] << 4) | ((header_[2] & 0xF0) >> 4)); }
77 
78  inline uint16_t FEDDAQHeader::sourceID() const { return (((header_[2] & 0x0F) << 8) | header_[1]); }
79 
80  inline uint8_t FEDDAQHeader::version() const { return ((header_[0] & 0xF0) >> 4); }
81 
82  inline bool FEDDAQHeader::hBit() const { return (header_[0] & 0x8); }
83 
84  inline bool FEDDAQHeader::lastHeader() const { return !hBit(); }
85 
86  inline const uint8_t* FEDDAQHeader::data() const { return header_; }
87 
88  inline void FEDDAQHeader::print(std::ostream& os) const { printHex(header_, 8, os); }
89 
90 } // namespace Phase2Tracker
91 
92 #endif // } end def EventFilter_Phase2TrackerRawToDigi_Phase2TrackerFEDDAQHeader_H
void print(std::ostream &os) const
std::ostream & operator<<(std::ostream &os, const FEDDAQEventType &value)
void setBXID(const uint16_t bxID)
static const uint8_t INVALID
Definition: utils.h:32
void setSourceID(const uint16_t sourceID)
Definition: value.py:1
void setEventType(const FEDDAQEventType evtType)
void printHex(const void *pointer, const size_t lengthInBytes, std::ostream &os)
Definition: utils.h:58
void setL1ID(const uint32_t l1ID)