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
23  };
24 
25  //to make enums printable
26  inline std::ostream& operator<<(std::ostream& os, const FEDDAQEventType& value);
27 
28  //see http://cmsdoc.cern.ch/cms/TRIDAS/horizontal/RUWG/DAQ_IF_guide/DAQ_IF_guide.html
30  {
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, const uint16_t bxID,
58  const uint16_t sourceID,
59  const FEDDAQEventType evtType = DAQ_EVENT_TYPE_PHYSICS);
60  private:
61  uint8_t header_[8];
62  }; // end of FEDDAQHeader class
63 
64 
65  //FEDDAQHeader
66 
67  inline FEDDAQHeader::FEDDAQHeader(const uint8_t* header)
68  { memcpy(header_,header,8); }
69 
70  inline uint8_t FEDDAQHeader::boeNibble() const
71  { return ( (header_[7] & 0xF0) >> 4 ); }
72 
73  inline uint8_t FEDDAQHeader::eventTypeNibble() const
74  { return (header_[7] & 0x0F); }
75 
76  inline uint32_t FEDDAQHeader::l1ID() const
77  { return ( header_[4] | (header_[5]<<8) | (header_[6]<<16) ); }
78 
79  inline uint16_t FEDDAQHeader::bxID() const
80  { return ( (header_[3]<<4) | ((header_[2]&0xF0)>>4) ); }
81 
82  inline uint16_t FEDDAQHeader::sourceID() const
83  { return ( ((header_[2]&0x0F)<<8) | header_[1] ); }
84 
85  inline uint8_t FEDDAQHeader::version() const
86  { return ( (header_[0] & 0xF0) >> 4 ); }
87 
88  inline bool FEDDAQHeader::hBit() const
89  { return (header_[0] & 0x8); }
90 
91  inline bool FEDDAQHeader::lastHeader() const
92  { return !hBit(); }
93 
94  inline const uint8_t* FEDDAQHeader::data() const
95  { return header_; }
96 
97  inline void FEDDAQHeader::print(std::ostream& os) const
98  { printHex(header_,8,os); }
99 
100 } // end of Phase2Tracker namespace
101 
102 #endif // } end def EventFilter_Phase2TrackerRawToDigi_Phase2TrackerFEDDAQHeader_H
103 
104 
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)
void print(std::ostream &os) const
Definition: value.py:1
FEDDAQEventType eventType() const
void setEventType(const FEDDAQEventType evtType)
void printHex(const void *pointer, const size_t lengthInBytes, std::ostream &os)
Definition: utils.h:60
void setL1ID(const uint32_t l1ID)