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
18  TTS_BUSY=0x4,
19  TTS_READY=0x8,
20  TTS_ERROR=0x12,
23  };
24 
25  //to make enums printable
26  inline std::ostream& operator<<(std::ostream& os, const FEDTTSBits& value);
27 
28  //see http://cmsdoc.cern.ch/cms/TRIDAS/horizontal/RUWG/DAQ_IF_guide/DAQ_IF_guide.html
30  {
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  const uint32_t eventLengthIn64BitWords);
64  void setCRC(const uint16_t crc);
65  void setSLinkTransmissionErrorBit(const bool bitSet);
66  void setBadSourceIDBit(const bool bitSet);
67  void setSLinkCRCErrorBit(const bool bitSet);
68  void setEventStatusNibble(const uint8_t eventStatusNibble);
69  void setTTSBits(const FEDTTSBits ttsBits);
70  FEDDAQTrailer(const uint32_t eventLengthIn64BitWords,
71  const uint16_t crc = 0,
72  const FEDTTSBits ttsBits = TTS_READY,
73  const bool slinkTransmissionError = false,
74  const bool badFEDID = false,
75  const bool slinkCRCError = false,
76  const uint8_t eventStatusNibble = 0);
77  private:
78  uint8_t trailer_[8];
79 
80  }; // end of FEDDAQTrailer class
81 
82 
83  //FEDDAQTrailer methods definintions {
84 
85  //FEDDAQTrailer
86 
87  inline FEDDAQTrailer::FEDDAQTrailer(const uint8_t* trailer)
88  { memcpy(trailer_,trailer,8); }
89 
90  inline uint8_t FEDDAQTrailer::eoeNibble() const
91  { return ( (trailer_[7] & 0xF0) >> 4 ); }
92 
94  { return ( trailer_[4] | (trailer_[5]<<8) | (trailer_[6]<<16) ); }
95 
96  inline uint32_t FEDDAQTrailer::eventLengthInBytes() const
97  { return eventLengthIn64BitWords()*8; }
98 
99  inline uint16_t FEDDAQTrailer::crc() const
100  { return ( trailer_[2] | (trailer_[3]<<8) ); }
101 
102  inline bool FEDDAQTrailer::cBit() const
103  { return (trailer_[1] & 0x80); }
104 
105  inline bool FEDDAQTrailer::fBit() const
106  { return (trailer_[1] & 0x40); }
107 
108  inline uint8_t FEDDAQTrailer::eventStatusNibble() const
109  { return (trailer_[1] & 0x0F); }
110 
111  inline uint8_t FEDDAQTrailer::ttsNibble() const
112  { return ( (trailer_[0] & 0xF0) >> 4); }
113 
114  inline bool FEDDAQTrailer::tBit() const
115  { return (trailer_[0] & 0x08); }
116 
117  inline bool FEDDAQTrailer::rBit() const
118  { return (trailer_[0] & 0x04); }
119 
120  inline void FEDDAQTrailer::print(std::ostream& os) const
121  { printHex(trailer_,8,os); }
122 
123  inline const uint8_t* FEDDAQTrailer::data() const
124  { return trailer_; }
125 
126  // End of method definitions }
127 
128 } // end of Phase2Tracker namespace
129 
130 #endif // } end def EventFilter_Phase2TrackerRawToDigi_Phase2TrackerFEDDAQHeader_H
131 
132 
void setSLinkCRCErrorBit(const bool bitSet)
std::ostream & operator<<(std::ostream &os, const FEDDAQEventType &value)
static const uint8_t INVALID
Definition: utils.h:32
void print(std::ostream &os) const
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:60
void setBadSourceIDBit(const bool bitSet)