CMS 3D CMS Logo

Phase2TrackerFEDDAQTrailer.h
Go to the documentation of this file.
1 #ifndef EventFilter_Phase2TrackerRawToDigi_Phase2TrackerFEDDAQTrailer_H // {
2 #define EventFilter_Phase2TrackerRawToDigi_Phase2TrackerFEDDAQTrailer_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
15  enum FEDTTSBits {
19  TTS_BUSY = 0x4,
20  TTS_READY = 0x8,
21  TTS_ERROR = 0x12,
24  };
25 
26  //to make enums printable
27  inline std::ostream& operator<<(std::ostream& os, const FEDTTSBits& value);
28 
29  //see http://cmsdoc.cern.ch/cms/TRIDAS/horizontal/RUWG/DAQ_IF_guide/DAQ_IF_guide.html
30  class FEDDAQTrailer {
31  public:
33  explicit FEDDAQTrailer(const uint8_t* trailer);
34 
35  // getters
36  //0xA in first fragment
37  uint8_t eoeNibble() const;
38  uint32_t eventLengthIn64BitWords() const;
39  uint32_t eventLengthInBytes() const;
40  uint16_t crc() const;
41  //set to 1 if FRL detects a transmission error over S-link
42  bool cBit() const;
43  bool slinkTransmissionError() const { return cBit(); }
44  //set to 1 if the FED ID is not the one expected by the FRL
45  bool fBit() const;
46  bool badSourceID() const { return fBit(); }
47  uint8_t eventStatusNibble() const;
48  uint8_t ttsNibble() const;
49  FEDTTSBits ttsBits() const;
50  //0 if the current trailer is the last, 1 otherwise
51  bool tBit() const;
52  bool lastTrailer() const { return !tBit(); }
53  //set to 1 if the S-link sender card detects a CRC error
54  // (the CRC it computes is put in the CRC field)
55  bool rBit() const;
56  bool slinkCRCError() const { return rBit(); }
57  void print(std::ostream& os) const;
58  //used by digi2Raw
59  const uint8_t* data() const;
60 
61  // setters
63  void setCRC(const uint16_t crc);
64  void setSLinkTransmissionErrorBit(const bool bitSet);
65  void setBadSourceIDBit(const bool bitSet);
66  void setSLinkCRCErrorBit(const bool bitSet);
67  void setEventStatusNibble(const uint8_t eventStatusNibble);
68  void setTTSBits(const FEDTTSBits ttsBits);
70  const uint16_t crc = 0,
72  const bool slinkTransmissionError = false,
73  const bool badFEDID = false,
74  const bool slinkCRCError = false,
75  const uint8_t eventStatusNibble = 0);
76 
77  private:
78  uint8_t trailer_[8];
79 
80  }; // end of FEDDAQTrailer class
81 
82  //FEDDAQTrailer methods definintions {
83 
84  //FEDDAQTrailer
85 
86  inline FEDDAQTrailer::FEDDAQTrailer(const uint8_t* trailer) { memcpy(trailer_, trailer, 8); }
87 
88  inline uint8_t FEDDAQTrailer::eoeNibble() const { return ((trailer_[7] & 0xF0) >> 4); }
89 
90  inline uint32_t FEDDAQTrailer::eventLengthIn64BitWords() const {
91  return (trailer_[4] | (trailer_[5] << 8) | (trailer_[6] << 16));
92  }
93 
94  inline uint32_t FEDDAQTrailer::eventLengthInBytes() const { return eventLengthIn64BitWords() * 8; }
95 
96  inline uint16_t FEDDAQTrailer::crc() const { return (trailer_[2] | (trailer_[3] << 8)); }
97 
98  inline bool FEDDAQTrailer::cBit() const { return (trailer_[1] & 0x80); }
99 
100  inline bool FEDDAQTrailer::fBit() const { return (trailer_[1] & 0x40); }
101 
102  inline uint8_t FEDDAQTrailer::eventStatusNibble() const { return (trailer_[1] & 0x0F); }
103 
104  inline uint8_t FEDDAQTrailer::ttsNibble() const { return ((trailer_[0] & 0xF0) >> 4); }
105 
106  inline bool FEDDAQTrailer::tBit() const { return (trailer_[0] & 0x08); }
107 
108  inline bool FEDDAQTrailer::rBit() const { return (trailer_[0] & 0x04); }
109 
110  inline void FEDDAQTrailer::print(std::ostream& os) const { printHex(trailer_, 8, os); }
111 
112  inline const uint8_t* FEDDAQTrailer::data() const { return trailer_; }
113 
114  // End of method definitions }
115 
116 } // namespace Phase2Tracker
117 
118 #endif // } end def EventFilter_Phase2TrackerRawToDigi_Phase2TrackerFEDDAQHeader_H
void setSLinkCRCErrorBit(const bool bitSet)
std::ostream & operator<<(std::ostream &os, const FEDDAQEventType &value)
static const uint8_t INVALID
Definition: utils.h:32
void setSLinkTransmissionErrorBit(const bool bitSet)
Definition: value.py:1
void setEventStatusNibble(const uint8_t eventStatusNibble)
void setTTSBits(const FEDTTSBits ttsBits)
void setEventLengthIn64BitWords(const uint32_t eventLengthIn64BitWords)
void printHex(const void *pointer, const size_t lengthInBytes, std::ostream &os)
Definition: utils.h:58
void print(std::ostream &os) const
void setBadSourceIDBit(const bool bitSet)