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
Phase2Tracker::FEDDAQTrailer::setEventLengthIn64BitWords
void setEventLengthIn64BitWords(const uint32_t eventLengthIn64BitWords)
Definition: Phase2TrackerFEDDAQTrailer.cc:79
Phase2Tracker::TTS_BUSY
Definition: Phase2TrackerFEDDAQTrailer.h:19
Phase2Tracker::TTS_READY
Definition: Phase2TrackerFEDDAQTrailer.h:20
Phase2Tracker::FEDDAQTrailer::slinkTransmissionError
bool slinkTransmissionError() const
Definition: Phase2TrackerFEDDAQTrailer.h:43
Phase2Tracker::FEDDAQTrailer::print
void print(std::ostream &os) const
Definition: Phase2TrackerFEDDAQTrailer.h:110
Phase2Tracker::FEDDAQTrailer::ttsBits
FEDTTSBits ttsBits() const
Definition: Phase2TrackerFEDDAQTrailer.cc:43
Phase2Tracker::FEDDAQTrailer
Definition: Phase2TrackerFEDDAQTrailer.h:30
Phase2Tracker::FEDDAQTrailer::eventStatusNibble
uint8_t eventStatusNibble() const
Definition: Phase2TrackerFEDDAQTrailer.h:102
Phase2Tracker::FEDDAQTrailer::setBadSourceIDBit
void setBadSourceIDBit(const bool bitSet)
Definition: Phase2TrackerFEDDAQTrailer.cc:97
utils.h
Phase2Tracker::operator<<
std::ostream & operator<<(std::ostream &os, const FEDDAQEventType &value)
Definition: Phase2TrackerFEDDAQHeader.cc:7
Phase2Tracker::FEDDAQTrailer::eoeNibble
uint8_t eoeNibble() const
Definition: Phase2TrackerFEDDAQTrailer.h:88
Phase2Tracker::FEDDAQTrailer::eventLengthIn64BitWords
uint32_t eventLengthIn64BitWords() const
Definition: Phase2TrackerFEDDAQTrailer.h:90
Phase2Tracker::TTS_WARN_OVERFLOW
Definition: Phase2TrackerFEDDAQTrailer.h:17
Phase2Tracker::FEDDAQTrailer::rBit
bool rBit() const
Definition: Phase2TrackerFEDDAQTrailer.h:108
Phase2Tracker::FEDDAQTrailer::setSLinkCRCErrorBit
void setSLinkCRCErrorBit(const bool bitSet)
Definition: Phase2TrackerFEDDAQTrailer.cc:104
Phase2Tracker::FEDDAQTrailer::crc
uint16_t crc() const
Definition: Phase2TrackerFEDDAQTrailer.h:96
Phase2Tracker::FEDDAQTrailer::trailer_
uint8_t trailer_[8]
Definition: Phase2TrackerFEDDAQTrailer.h:78
Phase2Tracker::INVALID
static const uint8_t INVALID
Definition: utils.h:32
Phase2Tracker::TTS_INVALID
Definition: Phase2TrackerFEDDAQTrailer.h:23
Phase2Tracker::TTS_OUT_OF_SYNC
Definition: Phase2TrackerFEDDAQTrailer.h:18
Phase2Tracker::FEDDAQTrailer::lastTrailer
bool lastTrailer() const
Definition: Phase2TrackerFEDDAQTrailer.h:52
Phase2Tracker::FEDDAQTrailer::setCRC
void setCRC(const uint16_t crc)
Definition: Phase2TrackerFEDDAQTrailer.cc:85
Phase2Tracker::FEDDAQTrailer::tBit
bool tBit() const
Definition: Phase2TrackerFEDDAQTrailer.h:106
Phase2Tracker::FEDDAQTrailer::eventLengthInBytes
uint32_t eventLengthInBytes() const
Definition: Phase2TrackerFEDDAQTrailer.h:94
Phase2Tracker::FEDDAQTrailer::data
const uint8_t * data() const
Definition: Phase2TrackerFEDDAQTrailer.h:112
value
Definition: value.py:1
Phase2Tracker::FEDDAQTrailer::fBit
bool fBit() const
Definition: Phase2TrackerFEDDAQTrailer.h:100
Phase2Tracker::FEDDAQTrailer::ttsNibble
uint8_t ttsNibble() const
Definition: Phase2TrackerFEDDAQTrailer.h:104
Phase2Tracker::FEDDAQTrailer::setEventStatusNibble
void setEventStatusNibble(const uint8_t eventStatusNibble)
Definition: Phase2TrackerFEDDAQTrailer.cc:111
Phase2Tracker::TTS_ERROR
Definition: Phase2TrackerFEDDAQTrailer.h:21
Phase2Tracker::TTS_DISCONNECTED0
Definition: Phase2TrackerFEDDAQTrailer.h:16
Phase2Tracker::TTS_DISCONNECTED1
Definition: Phase2TrackerFEDDAQTrailer.h:22
Phase2Tracker::FEDTTSBits
FEDTTSBits
Definition: Phase2TrackerFEDDAQTrailer.h:15
Phase2Tracker::printHex
void printHex(const void *pointer, const size_t lengthInBytes, std::ostream &os)
Definition: utils.h:58
Phase2Tracker::FEDDAQTrailer::setTTSBits
void setTTSBits(const FEDTTSBits ttsBits)
Definition: Phase2TrackerFEDDAQTrailer.cc:115
Phase2Tracker::FEDDAQTrailer::setSLinkTransmissionErrorBit
void setSLinkTransmissionErrorBit(const bool bitSet)
Definition: Phase2TrackerFEDDAQTrailer.cc:90
Phase2Tracker::FEDDAQTrailer::cBit
bool cBit() const
Definition: Phase2TrackerFEDDAQTrailer.h:98
Phase2Tracker::FEDDAQTrailer::badSourceID
bool badSourceID() const
Definition: Phase2TrackerFEDDAQTrailer.h:46
Phase2Tracker::FEDDAQTrailer::slinkCRCError
bool slinkCRCError() const
Definition: Phase2TrackerFEDDAQTrailer.h:56
Phase2Tracker
Definition: Phase2TrackerFEDBuffer.h:12
Phase2Tracker::FEDDAQTrailer::FEDDAQTrailer
FEDDAQTrailer()
Definition: Phase2TrackerFEDDAQTrailer.h:32