CMS 3D CMS Logo

SiStripFEDBufferComponents.h
Go to the documentation of this file.
1 #ifndef EventFilter_SiStripRawToDigi_SiStripFEDBufferComponents_H
2 #define EventFilter_SiStripRawToDigi_SiStripFEDBufferComponents_H
3 
4 #include "boost/cstdint.hpp"
5 #include <ostream>
6 #include <memory>
7 #include <cstring>
10 
11 namespace sistrip {
12 
13  //
14  // Constants
15  //
16 
17  static const uint8_t INVALID=0xFF;
18 
19  static const uint8_t APV_MAX_ADDRESS=192;
20 
21  static const uint16_t SCOPE_MODE_MAX_SCOPE_LENGTH=1022;
22 
27  };
28  //these are the values which appear in the buffer.
29  static const uint8_t BUFFER_FORMAT_CODE_OLD = 0xED;
30  static const uint8_t BUFFER_FORMAT_CODE_NEW = 0xC5;
31 
32  //enum values are values which appear in buffer. DO NOT CHANGE!
36  HEADER_TYPE_NONE=4 //spy channel
37  };
38 
39  //enum values are values which appear in buffer. DO NOT CHANGE!
56  };
57 
70  };
71 
72  static const uint8_t PACKET_CODE_SCOPE = 0xE1;
73  static const uint8_t PACKET_CODE_VIRGIN_RAW = 0xE6;
74  static const uint8_t PACKET_CODE_VIRGIN_RAW10 = 0x86;
75  static const uint8_t PACKET_CODE_VIRGIN_RAW8_BOTBOT = 0xC6; //FIXME need to implement this!
76  static const uint8_t PACKET_CODE_VIRGIN_RAW8_TOPBOT = 0xA6;
77  static const uint8_t PACKET_CODE_PROC_RAW = 0xF2;
78  static const uint8_t PACKET_CODE_PROC_RAW10 = 0x92; //FIXME need to implement this!
79  static const uint8_t PACKET_CODE_PROC_RAW8_BOTBOT = 0xCA;
80  static const uint8_t PACKET_CODE_PROC_RAW8_TOPBOT = 0xB2;
81  static const uint8_t PACKET_CODE_ZERO_SUPPRESSED = 0xEA;
82  static const uint8_t PACKET_CODE_ZERO_SUPPRESSED10 = 0x8A;
83  static const uint8_t PACKET_CODE_ZERO_SUPPRESSED8_BOTBOT = 0xCA;
84  static const uint8_t PACKET_CODE_ZERO_SUPPRESSED8_TOPBOT = 0xAA;
85 
86  //enum values are values which appear in buffer. DO NOT CHANGE!
87  //see http://cmsdoc.cern.ch/cms/TRIDAS/horizontal/RUWG/DAQ_IF_guide/DAQ_IF_guide.html
96  };
97 
98  //enum values are values which appear in buffer. DO NOT CHANGE!
99  //see http://cmsdoc.cern.ch/cms/TRIDAS/horizontal/RUWG/DAQ_IF_guide/DAQ_IF_guide.html
103  TTS_BUSY=0x4,
105  TTS_ERROR=0x12,
107  TTS_INVALID=INVALID };
108 
109  //enum values are values which appear in buffer. DO NOT CHANGE!
114  };
115 
116  //enum values are values which appear in buffer. DO NOT CHANGE!
129  };
130 
131  //
132  // Global function declarations
133  //
134 
135  //used by these classes
136  uint8_t internalFEDChannelNum(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum);
137  void printHex(const void* pointer, const size_t length, std::ostream& os);
138  //calculate the CRC for a FED buffer
139  uint16_t calculateFEDBufferCRC(const uint8_t* buffer, const size_t lengthInBytes);
140  //to make enums printable
141  std::ostream& operator<<(std::ostream& os, const FEDBufferFormat& value);
142  std::ostream& operator<<(std::ostream& os, const FEDHeaderType& value);
143  std::ostream& operator<<(std::ostream& os, const FEDLegacyReadoutMode& value);
144  std::ostream& operator<<(std::ostream& os, const FEDReadoutMode& value);
145  std::ostream& operator<<(std::ostream& os, const FEDDAQEventType& value);
146  std::ostream& operator<<(std::ostream& os, const FEDTTSBits& value);
147  std::ostream& operator<<(std::ostream& os, const FEDBufferState& value);
148  std::ostream& operator<<(std::ostream& os, const FEDChannelStatus& value);
149  //convert name of an element of enum to enum value (useful for getting values from config)
150  FEDBufferFormat fedBufferFormatFromString(const std::string& bufferFormatString);
151  FEDHeaderType fedHeaderTypeFromString(const std::string& headerTypeString);
152  FEDReadoutMode fedReadoutModeFromString(const std::string& readoutModeString);
153  uint8_t packetCodeFromString(const std::string& packetCodeString, FEDReadoutMode mode);
154  FEDDAQEventType fedDAQEventTypeFromString(const std::string& daqEventTypeString);
155 
156  //
157  // Class definitions
158  //
159 
160  //handles conversion between order of data in buffer in VR/PR modes (readout order) and strip order (physical order)
162  {
163  public:
164  //convert strip/sample index in channel (ie 0-255) between physical and readout order
165  static uint8_t physicalOrderForStripInChannel(const uint8_t readoutOrderStripIndexInChannel);
166  static uint8_t readoutOrderForStripInChannel(const uint8_t physicalOrderStripIndexInChannel);
167  //convert strip/sample index in APV (ie 0-127) between physical and readout order
168  static uint8_t physicalOrderForStripInAPV(const uint8_t readoutOrderStripIndexInAPV);
169  static uint8_t readoutOrderForStripInAPV(const uint8_t physicalOrderStripIndexInAPV);
170  };
171 
172  //see http://cmsdoc.cern.ch/cms/TRIDAS/horizontal/RUWG/DAQ_IF_guide/DAQ_IF_guide.html
174  {
175  public:
177  explicit FEDDAQHeader(const uint8_t* header);
178  //0x5 in first fragment
179  uint8_t boeNibble() const;
180  uint8_t eventTypeNibble() const;
181  FEDDAQEventType eventType() const;
182  uint32_t l1ID() const;
183  uint16_t bxID() const;
184  uint16_t sourceID() const;
185  uint8_t version() const;
186  //0 if current header word is last, 1 otherwise
187  bool hBit() const;
188  bool lastHeader() const;
189  void print(std::ostream& os) const;
190  //used by digi2Raw
191  const uint8_t* data() const;
192  FEDDAQHeader& setEventType(const FEDDAQEventType evtType);
193  FEDDAQHeader& setL1ID(const uint32_t l1ID);
194  FEDDAQHeader& setBXID(const uint16_t bxID);
195  FEDDAQHeader& setSourceID(const uint16_t sourceID);
196  FEDDAQHeader(const uint32_t l1ID, const uint16_t bxID, const uint16_t sourceID,
197  const FEDDAQEventType evtType = DAQ_EVENT_TYPE_PHYSICS);
198  private:
199  uint8_t header_[8];
200  };
201 
202  //see http://cmsdoc.cern.ch/cms/TRIDAS/horizontal/RUWG/DAQ_IF_guide/DAQ_IF_guide.html
204  {
205  public:
207  explicit FEDDAQTrailer(const uint8_t* trailer);
208  //0xA in first fragment
209  uint8_t eoeNibble() const;
210  uint32_t eventLengthIn64BitWords() const;
211  uint32_t eventLengthInBytes() const;
212  uint16_t crc() const;
213  //set to 1 if FRL detects a transmission error over S-link
214  bool cBit() const;
215  bool slinkTransmissionError() const { return cBit(); }
216  //set to 1 if the FED ID is not the one expected by the FRL
217  bool fBit() const;
218  bool badSourceID() const { return fBit(); }
219  uint8_t eventStatusNibble() const;
220  uint8_t ttsNibble() const;
221  FEDTTSBits ttsBits() const;
222  //0 if the current trailer is the last, 1 otherwise
223  bool tBit() const;
224  bool lastTrailer() const { return !tBit(); }
225  //set to 1 if the S-link sender card detects a CRC error (the CRC it computes is put in the CRC field)
226  bool rBit() const;
227  bool slinkCRCError() const { return rBit(); }
228  void print(std::ostream& os) const;
229  //used by digi2Raw
230  const uint8_t* data() const;
231  FEDDAQTrailer& setEventLengthIn64BitWords(const uint32_t eventLengthIn64BitWords);
232  FEDDAQTrailer& setCRC(const uint16_t crc);
233  FEDDAQTrailer& setSLinkTransmissionErrorBit(const bool bitSet);
234  FEDDAQTrailer& setBadSourceIDBit(const bool bitSet);
235  FEDDAQTrailer& setSLinkCRCErrorBit(const bool bitSet);
236  FEDDAQTrailer& setEventStatusNibble(const uint8_t eventStatusNibble);
237  FEDDAQTrailer& setTTSBits(const FEDTTSBits ttsBits);
238  FEDDAQTrailer(const uint32_t eventLengthIn64BitWords, const uint16_t crc = 0, const FEDTTSBits ttsBits = TTS_READY,
239  const bool slinkTransmissionError = false, const bool badFEDID = false, const bool slinkCRCError = false,
240  const uint8_t eventStatusNibble = 0);
241  private:
242  uint8_t trailer_[8];
243  };
244 
246  {
247  public:
248  FEDStatusRegister(const uint16_t fedStatusRegister);
249  bool slinkFullFlag() const;
250  bool trackerHeaderMonitorDataReadyFlag() const;
251  bool qdrMemoryFullFlag() const;
252  bool qdrMemoryPartialFullFlag() const;
253  bool qdrMemoryEmptyFlag() const;
254  bool l1aBxFIFOFullFlag() const;
255  bool l1aBxFIFOPartialFullFlag() const;
256  bool l1aBxFIFOEmptyFlag() const;
257  FEDBufferState qdrMemoryState() const;
258  FEDBufferState l1aBxFIFOState() const;
259  bool feDataMissingFlag(const uint8_t internalFEUnitNum) const;
260  void print(std::ostream& os) const;
261  void printFlags(std::ostream& os) const;
262  operator uint16_t () const;
263  //used by digi2Raw
264  FEDStatusRegister& setSLinkFullFlag(const bool bitSet);
265  FEDStatusRegister& setTrackerHeaderMonitorDataReadyFlag(const bool bitSet);
266  FEDStatusRegister& setQDRMemoryBufferState(const FEDBufferState state);
267  FEDStatusRegister& setL1ABXFIFOBufferState(const FEDBufferState state);
268  FEDStatusRegister(const FEDBufferState qdrMemoryBufferState = BUFFER_STATE_UNSET,
269  const FEDBufferState l1aBxFIFOBufferState = BUFFER_STATE_UNSET,
270  const bool trackerHeaderMonitorDataReadyFlagSet = false,
271  const bool slinkFullFlagSet = false);
272  private:
273  bool getBit(const uint8_t num) const;
274  void setBit(const uint8_t num, const bool bitSet);
275  void setQDRMemoryFullFlag(const bool bitSet);
276  void setQDRMemoryPartialFullFlag(const bool bitSet);
277  void setQDRMemoryEmptyFlag(const bool bitSet);
278  void setL1ABXFIFOFullFlag(const bool bitSet);
279  void setL1ABXFIFOPartialFullFlag(const bool bitSet);
280  void setL1ABXFIFOEmptyFlag(const bool bitSet);
281  uint16_t data_;
282  };
283 
285  {
286  public:
288  //construct with a pointer to the data. The data will be coppied and swapped if necessary.
289  explicit TrackerSpecialHeader(const uint8_t* headerPointer);
290  uint8_t bufferFormatByte() const;
291  FEDBufferFormat bufferFormat() const;
292  uint8_t headerTypeNibble() const;
293  FEDHeaderType headerType() const;
294  uint8_t trackerEventTypeNibble() const;
295  FEDReadoutMode readoutMode() const;
296  FEDLegacyReadoutMode legacyReadoutMode() const;
297  uint8_t apveAddress() const;
298  uint8_t apvAddressErrorRegister() const;
299  bool majorityAddressErrorForFEUnit(const uint8_t internalFEUnitNum) const;
300  uint8_t feEnableRegister() const;
301  bool feEnabled(const uint8_t internalFEUnitNum) const;
302  uint8_t feOverflowRegister() const;
303  bool feOverflow(const uint8_t internalFEUnitNum) const;
304  uint16_t fedStatusRegisterWord() const;
305  FEDStatusRegister fedStatusRegister() const;
306  void print(std::ostream& os) const;
307  //used by digi2Raw
308  //returns ordered buffer (ie this may need to be swapped to get original order)
309  const uint8_t* data() const;
310  bool wasSwapped() const;
311  TrackerSpecialHeader& setBufferFormat(const FEDBufferFormat newBufferFormat);
312  TrackerSpecialHeader& setHeaderType(const FEDHeaderType headerType);
313  TrackerSpecialHeader& setReadoutMode(const FEDReadoutMode readoutMode);
314  TrackerSpecialHeader& setAPVEAddress(const uint8_t address);
315  TrackerSpecialHeader& setAPVEAddressErrorRegister(const uint8_t addressErrorRegister);
316  TrackerSpecialHeader& setAPVAddressErrorForFEUnit(const uint8_t internalFEUnitNum, const bool error);
317  TrackerSpecialHeader& setFEEnableRegister(const uint8_t feEnableRegister);
318  TrackerSpecialHeader& setFEEnableForFEUnit(const uint8_t internalFEUnitNum, const bool enabled);
319  TrackerSpecialHeader& setFEOverflowRegister(const uint8_t feOverflowRegister);
320  TrackerSpecialHeader& setFEOverflowForFEUnit(const uint8_t internalFEUnitNum, const bool overflow);
321  TrackerSpecialHeader& setFEDStatusRegister(const FEDStatusRegister fedStatusRegister);
322  TrackerSpecialHeader(const FEDBufferFormat bufferFormat, const FEDReadoutMode readoutMode, const FEDHeaderType headerType,
323  const uint8_t address = 0x00, const uint8_t addressErrorRegister = 0x00,
324  const uint8_t feEnableRegister = 0xFF, const uint8_t feOverflowRegister = 0x00,
325  const FEDStatusRegister fedStatusRegister = FEDStatusRegister());
326  private:
327  void setBufferFormatByte(const FEDBufferFormat newBufferFormat);
328  void setHeaderTypeNibble(const uint8_t value);
329  void setReadoutModeBits(const uint8_t value);
330  enum byteIndicies { FEDSTATUS=0, FEOVERFLOW=2, FEENABLE=3, ADDRESSERROR=4, APVEADDRESS=5, BUFFERTYPE=6, BUFFERFORMAT=7 };
331  //copy of header, 32 bit word swapped if needed
332  uint8_t specialHeader_[8];
333  //was the header word swapped wrt order in buffer?
335  };
336 
338  {
339  public:
340  FEDBackendStatusRegister(const uint32_t backendStatusRegister);
341  bool internalFreezeFlag() const;
342  bool slinkDownFlag() const;
343  bool slinkFullFlag() const;
344  bool backpressureFlag() const;
345  bool ttcReadyFlag() const;
346  bool trackerHeaderMonitorDataReadyFlag() const;
347  FEDBufferState qdrMemoryState() const;
348  FEDBufferState frameAddressFIFOState() const;
349  FEDBufferState totalLengthFIFOState() const;
350  FEDBufferState trackerHeaderFIFOState() const;
351  FEDBufferState l1aBxFIFOState() const;
352  FEDBufferState feEventLengthFIFOState() const;
353  FEDBufferState feFPGABufferState() const;
354  void print(std::ostream& os) const;
355  void printFlags(std::ostream& os) const;
356  operator uint32_t () const;
357  //used by digi2Raw
358  FEDBackendStatusRegister& setInternalFreezeFlag(const bool bitSet);
359  FEDBackendStatusRegister& setSLinkDownFlag(const bool bitSet);
360  FEDBackendStatusRegister& setSLinkFullFlag(const bool bitSet);
361  FEDBackendStatusRegister& setBackpressureFlag(const bool bitSet);
362  FEDBackendStatusRegister& setTTCReadyFlag(const bool bitSet);
363  FEDBackendStatusRegister& setTrackerHeaderMonitorDataReadyFlag(const bool bitSet);
364  FEDBackendStatusRegister& setQDRMemoryState(const FEDBufferState state);
365  FEDBackendStatusRegister& setFrameAddressFIFOState(const FEDBufferState state);
366  FEDBackendStatusRegister& setTotalLengthFIFOState(const FEDBufferState state);
367  FEDBackendStatusRegister& setTrackerHeaderFIFOState(const FEDBufferState state);
368  FEDBackendStatusRegister& setL1ABXFIFOState(const FEDBufferState state);
369  FEDBackendStatusRegister& setFEEventLengthFIFOState(const FEDBufferState state);
370  FEDBackendStatusRegister& setFEFPGABufferState(const FEDBufferState state);
371  FEDBackendStatusRegister(const FEDBufferState qdrMemoryBufferState = BUFFER_STATE_UNSET,
372  const FEDBufferState frameAddressFIFOBufferState = BUFFER_STATE_UNSET,
373  const FEDBufferState totalLengthFIFOBufferState = BUFFER_STATE_UNSET,
374  const FEDBufferState trackerHeaderFIFOBufferState = BUFFER_STATE_UNSET,
375  const FEDBufferState l1aBxFIFOBufferState = BUFFER_STATE_UNSET,
376  const FEDBufferState feEventLengthFIFOBufferState = BUFFER_STATE_UNSET,
377  const FEDBufferState feFPGABufferState = BUFFER_STATE_UNSET,
378  const bool backpressure = false, const bool slinkFull = false,
379  const bool slinkDown = false, const bool internalFreeze = false,
380  const bool trackerHeaderMonitorDataReady = false, const bool ttcReady = true);
381  private:
382  bool getBit(const uint8_t num) const;
383  void setBit(const uint8_t num, const bool bitSet);
384  //get the state of the buffer in position 'bufferPosition'
385  FEDBufferState getBufferState(const uint8_t bufferPosition) const;
386  //set the state of the buffer in position 'bufferPosition' to state 'state'
387  void setBufferSate(const uint8_t bufferPosition, const FEDBufferState state);
388  void printFlagsForBuffer(const FEDBufferState bufferState, const std::string name, std::ostream& os) const;
389  //constants marking order of flags in buffer
390  //eg. bit offset for L1A/BX FIFO Partial full flag is STATE_OFFSET_PARTIAL_FULL+BUFFER_POSITION_L1ABX_FIFO
391  // bit offset for total length FIFO empty flag is STATE_OFFSET_EMPTY+BUFFER_POSITION_TOTAL_LENGTH_FIFO
392  //see BE FPGA technical description
393  enum bufferPositions { BUFFER_POSITION_QDR_MEMORY=0,
394  BUFFER_POSITION_FRAME_ADDRESS_FIFO=1,
395  BUFFER_POSITION_TOTAL_LENGTH_FIFO=2,
396  BUFFER_POSITION_TRACKER_HEADER_FIFO=3,
397  BUFFER_POSITION_L1ABX_FIFO=4,
398  BUFFER_POSITION_FE_EVENT_LENGTH_FIFO=5,
399  BUFFER_POSITION_FE_FPGA_BUFFER=6 };
400  enum stateOffsets { STATE_OFFSET_FULL=8,
401  STATE_OFFSET_PARTIAL_FULL=16,
402  STATE_OFFSET_EMPTY=24 };
403  uint32_t data_;
404  };
405 
407  {
408  public:
409  //factory function: allocates new FEDFEHeader derrivative of appropriate type
410  static std::unique_ptr<FEDFEHeader> newFEHeader(const FEDHeaderType headerType, const uint8_t* headerBuffer);
411  //used by digi2Raw
412  static std::unique_ptr<FEDFEHeader> newFEHeader(const FEDHeaderType headerType);
413  //create a buffer to use with digi2Raw
414  static std::unique_ptr<FEDFEHeader> newFEFakeHeader(const FEDHeaderType headerType);
415  virtual ~FEDFEHeader();
416  //the length of the header
417  virtual size_t lengthInBytes() const = 0;
418  //check that there are no errors indicated in which ever error bits are available in the header
419  //check bits for both APVs on a channel
420  bool checkChannelStatusBits(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum) const;
421  virtual bool checkChannelStatusBits(const uint8_t internalFEDChannelNum) const = 0;
422  //check bits for one APV
423  bool checkStatusBits(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum, const uint8_t apvNum) const;
424  virtual bool checkStatusBits(const uint8_t internalFEDChannelNum, const uint8_t apvNum) const = 0;
425  virtual void print(std::ostream& os) const = 0;
426  virtual FEDFEHeader* clone() const = 0;
427  //used by digi2Raw
428  virtual const uint8_t* data() const = 0;
429  virtual void setChannelStatus(const uint8_t internalFEDChannelNum, const FEDChannelStatus status) = 0;
430  virtual void setFEUnitMajorityAddress(const uint8_t internalFEUnitNum, const uint8_t address) = 0;
431  virtual void setBEStatusRegister(const FEDBackendStatusRegister beStatusRegister) = 0;
432  virtual void setDAQRegister(const uint32_t daqRegister) = 0;
433  virtual void setDAQRegister2(const uint32_t daqRegister2) = 0;
434  virtual void set32BitReservedRegister(const uint8_t internalFEUnitNum, const uint32_t reservedRegister) = 0;
435  virtual void setFEUnitLength(const uint8_t internalFEUnitNum, const uint16_t length) = 0;
436  void setChannelStatus(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum, const FEDChannelStatus status);
437  };
438 
439  class FEDAPVErrorHeader final : public FEDFEHeader
440  {
441  public:
442  explicit FEDAPVErrorHeader(const uint8_t* headerBuffer);
443  ~FEDAPVErrorHeader() override;
444  size_t lengthInBytes() const override;
445  bool checkChannelStatusBits(const uint8_t internalFEDChannelNum) const override;
446  bool checkStatusBits(const uint8_t internalFEDChannelNum, const uint8_t apvNum) const override;
447  void print(std::ostream& os) const override;
448  FEDAPVErrorHeader* clone() const override;
449  //used by digi2Raw
450  const uint8_t* data() const override;
451  FEDAPVErrorHeader& setAPVStatusBit(const uint8_t internalFEDChannelNum, const uint8_t apvNum, const bool apvGood);
452  FEDAPVErrorHeader& setAPVStatusBit(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum, const uint8_t apvNum, const bool apvGood);
453  FEDAPVErrorHeader(const std::vector<bool>& apvsGood = std::vector<bool>(APVS_PER_FED,true));
454  //Information which is not present in APVError mode is allowed to be set here so that the methods can be called on the base class without caring
455  //if the values need to be set.
456  void setChannelStatus(const uint8_t internalFEDChannelNum, const FEDChannelStatus status) override;
457  void setFEUnitMajorityAddress(const uint8_t internalFEUnitNum, const uint8_t address) override;
458  void setBEStatusRegister(const FEDBackendStatusRegister beStatusRegister) override;
459  void setDAQRegister(const uint32_t daqRegister) override;
460  void setDAQRegister2(const uint32_t daqRegister2) override;
461  void set32BitReservedRegister(const uint8_t internalFEUnitNum, const uint32_t reservedRegister) override;
462  void setFEUnitLength(const uint8_t internalFEUnitNum, const uint16_t length) override;
463  private:
464  static const size_t APV_ERROR_HEADER_SIZE_IN_64BIT_WORDS = 3;
465  static const size_t APV_ERROR_HEADER_SIZE_IN_BYTES = APV_ERROR_HEADER_SIZE_IN_64BIT_WORDS*8;
466  uint8_t header_[APV_ERROR_HEADER_SIZE_IN_BYTES];
467  };
468 
469  class FEDFullDebugHeader final : public FEDFEHeader
470  {
471  public:
472  explicit FEDFullDebugHeader(const uint8_t* headerBuffer);
473  ~FEDFullDebugHeader() override;
474  size_t lengthInBytes() const override;
475  bool checkChannelStatusBits(const uint8_t internalFEDChannelNum) const override;
476  bool checkStatusBits(const uint8_t internalFEDChannelNum, const uint8_t apvNum) const override;
477  void print(std::ostream& os) const override;
478  FEDFullDebugHeader* clone() const override;
479 
480  uint8_t feUnitMajorityAddress(const uint8_t internalFEUnitNum) const;
481  FEDBackendStatusRegister beStatusRegister() const;
482  uint32_t daqRegister() const;
483  uint32_t daqRegister2() const;
484  uint16_t feUnitLength(const uint8_t internalFEUnitNum) const;
485  bool fePresent(const uint8_t internalFEUnitNum) const;
486 
487  FEDChannelStatus getChannelStatus(const uint8_t internalFEDChannelNum) const;
488  FEDChannelStatus getChannelStatus(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum) const;
489 
490  //These methods return true if there was an error of the appropriate type (ie if the error bit is 0).
491  //They return false if the error could not occur due to a more general error.
492  //was channel unlocked
493  bool unlocked(const uint8_t internalFEDChannelNum) const;
494  bool unlocked(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum) const;
495  //was channel out of sync if it was unlocked
496  bool outOfSync(const uint8_t internalFEDChannelNum) const;
497  bool outOfSync(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum) const;
498  //was there an internal APV error if it was in sync
499  bool apvError(const uint8_t internalFEDChannelNum, const uint8_t apvNum) const;
500  bool apvError(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum, const uint8_t apvNum) const;
501  //was the APV address wrong if it was in sync (does not depend on APV internal error bit)
502  bool apvAddressError(const uint8_t internalFEDChannelNum, const uint8_t apvNum) const;
503  bool apvAddressError(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum, const uint8_t apvNum) const;
504 
505  //used by digi2Raw
506  const uint8_t* data() const override;
507  void setChannelStatus(const uint8_t internalFEDChannelNum, const FEDChannelStatus status) override;
508  void setFEUnitMajorityAddress(const uint8_t internalFEUnitNum, const uint8_t address) override;
509  void setBEStatusRegister(const FEDBackendStatusRegister beStatusRegister) override;
510  void setDAQRegister(const uint32_t daqRegister) override;
511  void setDAQRegister2(const uint32_t daqRegister2) override;
512  void set32BitReservedRegister(const uint8_t internalFEUnitNum, const uint32_t reservedRegister) override;
513  void setFEUnitLength(const uint8_t internalFEUnitNum, const uint16_t length) override;
514  static uint32_t get32BitWordFrom(const uint8_t* startOfWord);
515  const uint8_t* feWord(const uint8_t internalFEUnitNum) const;
516  uint8_t* feWord(const uint8_t internalFEUnitNum);
517  FEDFullDebugHeader(const std::vector<uint16_t>& feUnitLengths = std::vector<uint16_t>(FEUNITS_PER_FED,0),
518  const std::vector<uint8_t>& feMajorityAddresses = std::vector<uint8_t>(FEUNITS_PER_FED,0),
519  const std::vector<FEDChannelStatus>& channelStatus = std::vector<FEDChannelStatus>(FEDCH_PER_FED,CHANNEL_STATUS_NO_PROBLEMS),
520  const FEDBackendStatusRegister beStatusRegister = FEDBackendStatusRegister(),
521  const uint32_t daqRegister = 0, const uint32_t daqRegister2 = 0);
522  private:
523  bool getBit(const uint8_t internalFEDChannelNum, const uint8_t bit) const;
524  static void set32BitWordAt(uint8_t* startOfWord, const uint32_t value);
525  void setBit(const uint8_t internalFEDChannelNum, const uint8_t bit, const bool value);
526 
527  //These methods return true if there was an error of the appropriate type (ie if the error bit is 0).
528  //They ignore any previous errors which make the status bits meaningless and return the value of the bit anyway.
529  //In general, the methods above which only return an error for the likely cause are more useful.
530  bool unlockedFromBit(const uint8_t internalFEDChannelNum) const;
531  bool outOfSyncFromBit(const uint8_t internalFEDChannelNum) const;
532  bool apvErrorFromBit(const uint8_t internalFEDChannelNum, const uint8_t apvNum) const;
533  bool apvAddressErrorFromBit(const uint8_t internalFEDChannelNum, const uint8_t apvNum) const;
534 
535  //following methods set the bits to 1 (no error) if value is false
536  void setUnlocked(const uint8_t internalFEDChannelNum, const bool value);
537  void setOutOfSync(const uint8_t internalFEDChannelNum, const bool value);
538  void setAPVAddressError(const uint8_t internalFEDChannelNum, const uint8_t apvNum, const bool value);
539  void setAPVError(const uint8_t internalFEDChannelNum, const uint8_t apvNum, const bool value);
540  static const size_t FULL_DEBUG_HEADER_SIZE_IN_64BIT_WORDS = FEUNITS_PER_FED*2;
541  static const size_t FULL_DEBUG_HEADER_SIZE_IN_BYTES = FULL_DEBUG_HEADER_SIZE_IN_64BIT_WORDS*8;
542  uint8_t header_[FULL_DEBUG_HEADER_SIZE_IN_BYTES];
543  };
544 
545  //holds information about position of a channel in the buffer for use by unpacker
547  {
548  public:
549  FEDChannel(const uint8_t*const data, const size_t offset, const uint16_t length);
550  //gets length from first 2 bytes (assuming normal FED channel)
551  FEDChannel(const uint8_t*const data, const size_t offset);
552  uint16_t length() const;
553  const uint8_t* data() const;
554  size_t offset() const;
555  uint16_t cmMedian(const uint8_t apvIndex) const;
556  //third byte of channel data for normal FED channels
557  uint8_t packetCode() const;
558  private:
559  friend class FEDBuffer;
560  const uint8_t* data_;
561  size_t offset_;
562  uint16_t length_;
563  };
564 
565  //base class for sistrip FED buffers which have a DAQ header/trailer and tracker special header
567  {
568  public:
569  FEDBufferBase(const uint8_t* fedBuffer, const size_t fedBufferSize, const bool allowUnrecognizedFormat = false);
570  virtual ~FEDBufferBase();
571  //dump buffer to stream
572  void dump(std::ostream& os) const;
573  //dump original buffer before word swapping
574  void dumpOriginalBuffer(std::ostream& os) const;
575  virtual void print(std::ostream& os) const;
576  //calculate the CRC from the buffer
577  uint16_t calcCRC() const;
578 
579  //methods to get parts of the buffer
580  FEDDAQHeader daqHeader() const;
581  FEDDAQTrailer daqTrailer() const;
582  size_t bufferSize() const;
583  TrackerSpecialHeader trackerSpecialHeader() const;
584  //methods to get info from DAQ header
585  FEDDAQEventType daqEventType() const;
586  uint32_t daqLvl1ID() const;
587  uint16_t daqBXID() const;
588  uint16_t daqSourceID() const;
589  uint16_t sourceID() const;
590  //methods to get info from DAQ trailer
591  uint32_t daqEventLengthIn64bitWords() const;
592  uint32_t daqEventLengthInBytes() const;
593  uint16_t daqCRC() const;
594  FEDTTSBits daqTTSState() const;
595  //methods to get info from the tracker special header
596  FEDBufferFormat bufferFormat() const;
597  FEDHeaderType headerType() const;
598  FEDLegacyReadoutMode legacyReadoutMode() const;
599  FEDReadoutMode readoutMode() const;
600  uint8_t packetCode(bool legacy=false, const uint8_t internalFEDChannelNum=0) const;
601  uint8_t apveAddress() const;
602  bool majorityAddressErrorForFEUnit(const uint8_t internalFEUnitNum) const;
603  bool feEnabled(const uint8_t internalFEUnitNum) const;
604  uint8_t nFEUnitsEnabled() const;
605  bool feOverflow(const uint8_t internalFEUnitNum) const;
606  FEDStatusRegister fedStatusRegister() const;
607 
608  //check that channel has no errors
609  virtual bool channelGood(const uint8_t internalFEDChannelNum) const;
610  bool channelGood(const uint8_t internalFEUnitNum, const uint8_t internalChannelNum) const;
611  //return channel object for channel
612  const FEDChannel& channel(const uint8_t internalFEDChannelNum) const;
613  const FEDChannel& channel(const uint8_t internalFEUnitNum, const uint8_t internalChannelNum) const;
614 
615  //summary checks
616  //check that tracker special header is valid (does not check for FE unit errors indicated in special header)
617  bool doTrackerSpecialHeaderChecks() const;
618  //check for errors in DAQ heaqder and trailer (not including bad CRC)
619  bool doDAQHeaderAndTrailerChecks() const;
620  //do both
621  virtual bool doChecks() const;
622  //print the result of all detailed checks
623  virtual std::string checkSummary() const;
624 
625  //detailed checks
626  bool checkCRC() const;
627  bool checkMajorityAddresses() const;
628  //methods to check tracker special header
629  bool checkBufferFormat() const;
630  bool checkHeaderType() const;
631  bool checkReadoutMode() const;
632  bool checkAPVEAddressValid() const;
633  bool checkNoFEOverflows() const;
634  //methods to check daq header and trailer
635  bool checkNoSlinkCRCError() const;
636  bool checkNoSLinkTransmissionError() const;
637  bool checkSourceIDs() const;
638  bool checkNoUnexpectedSourceID() const;
639  bool checkNoExtraHeadersOrTrailers() const;
640  bool checkLengthFromTrailer() const;
641  protected:
642  const uint8_t* getPointerToDataAfterTrackerSpecialHeader() const;
643  const uint8_t* getPointerToByteAfterEndOfPayload() const;
644  FEDBufferBase(const uint8_t* fedBuffer, const size_t fedBufferSize, const bool allowUnrecognizedFormat, const bool fillChannelVector);
645  std::vector<FEDChannel> channels_;
646  private:
647  void init(const uint8_t* fedBuffer, const size_t fedBufferSize, const bool allowUnrecognizedFormat);
648  const uint8_t* originalBuffer_;
649  const uint8_t* orderedBuffer_;
650  const size_t bufferSize_;
654  };
655 
656  //
657  // Inline function definitions
658  //
659 
660  inline std::ostream& operator << (std::ostream& os, const FEDBufferBase& obj) { obj.print(os); os << obj.checkSummary(); return os; }
661 
662  inline uint8_t internalFEDChannelNum(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum)
663  {
664  return (internalFEUnitNum*FEDCH_PER_FEUNIT + internalFEUnitChannelNum);
665  }
666 
667  inline std::ostream& operator << (std::ostream& os, const FEDDAQHeader& obj) { obj.print(os); return os; }
668  inline std::ostream& operator << (std::ostream& os, const FEDDAQTrailer& obj) { obj.print(os); return os; }
669  inline std::ostream& operator << (std::ostream& os, const TrackerSpecialHeader& obj) { obj.print(os); return os; }
670  inline std::ostream& operator << (std::ostream& os, const FEDStatusRegister& obj) { obj.print(os); return os; }
671  inline std::ostream& operator << (std::ostream& os, const FEDFEHeader& obj) { obj.print(os); return os; }
672 
673  //FEDStripOrdering
674 
675  inline uint8_t FEDStripOrdering::physicalOrderForStripInChannel(const uint8_t readoutOrderStripIndexInChannel)
676  {
677  return physicalOrderForStripInAPV(readoutOrderStripIndexInChannel/2) + (readoutOrderStripIndexInChannel%2)*STRIPS_PER_APV;
678  }
679 
680  inline uint8_t FEDStripOrdering::readoutOrderForStripInChannel(const uint8_t physicalOrderStripIndexInChannel)
681  {
682  return ( readoutOrderForStripInAPV(physicalOrderStripIndexInChannel%128)*2 + (physicalOrderStripIndexInChannel/128) );
683  }
684 
685  inline uint8_t FEDStripOrdering::physicalOrderForStripInAPV(const uint8_t readout_order)
686  {
687  return ( (32 * (readout_order%4)) +
688  (8 * static_cast<uint16_t>(static_cast<float>(readout_order)/4.0)) -
689  (31 * static_cast<uint16_t>(static_cast<float>(readout_order)/16.0))
690  );
691  }
692 
693  inline uint8_t FEDStripOrdering::readoutOrderForStripInAPV(const uint8_t physical_order)
694  {
695  return ( 4*((static_cast<uint16_t>((static_cast<float>(physical_order)/8.0)))%4) +
696  static_cast<uint16_t>(static_cast<float>(physical_order)/32.0) +
697  16*(physical_order%8)
698  );
699  }
700 
701  //TrackerSpecialHeader
702 
704  : wordSwapped_(false)
705  {
706  }
707 
709  { return specialHeader_[BUFFERFORMAT]; }
710 
712  { return ( (specialHeader_[BUFFERTYPE] & 0xF0) >> 4 ); }
713 
715  { return (specialHeader_[BUFFERTYPE] & 0x0F); }
716 
717  inline uint8_t TrackerSpecialHeader::apveAddress() const
718  { return specialHeader_[APVEADDRESS]; }
719 
721  { return specialHeader_[ADDRESSERROR]; }
722 
723  inline bool TrackerSpecialHeader::majorityAddressErrorForFEUnit(const uint8_t internalFEUnitNum) const
724  {
725  return ( !(readoutMode() == READOUT_MODE_SCOPE) && !( (0x1<<internalFEUnitNum) & apvAddressErrorRegister() ) );
726  }
727 
729  { return specialHeader_[FEENABLE]; }
730 
731  inline bool TrackerSpecialHeader::feEnabled(const uint8_t internalFEUnitNum) const
732  {
733  return ( (0x1<<internalFEUnitNum) & feEnableRegister() );
734  }
735 
737  { return specialHeader_[FEOVERFLOW]; }
738 
739  inline bool TrackerSpecialHeader::feOverflow(const uint8_t internalFEUnitNum) const
740  {
741  return ( (0x1<<internalFEUnitNum) & feOverflowRegister() );
742  }
743 
745  {
746  //get 16 bits
747  uint16_t statusRegister = ( (specialHeader_[(FEDSTATUS+1)]<<8) | specialHeader_[FEDSTATUS]);
748  return statusRegister;
749  }
750 
753 
754  inline void TrackerSpecialHeader::print(std::ostream& os) const
755  { printHex(specialHeader_,8,os); }
756 
757  inline const uint8_t* TrackerSpecialHeader::data() const
758  {
759  return specialHeader_;
760  }
761 
763  {
764  return wordSwapped_;
765  }
766 
768  {
769  specialHeader_[BUFFERTYPE] = ( (specialHeader_[BUFFERTYPE] & 0x0F) | ((value<<4) & 0xF0) );
770  }
771 
773  {
774  specialHeader_[BUFFERTYPE] = ( (specialHeader_[BUFFERTYPE] & (~0x0F)) | (value & 0x0F) );
775  }
776 
778  {
779  specialHeader_[APVEADDRESS] = address;
780  return *this;
781  }
782 
784  {
785  specialHeader_[ADDRESSERROR] = addressErrorRegister;
786  return *this;
787  }
788 
790  {
792  return *this;
793  }
794 
796  {
798  return *this;
799  }
800 
802  {
803  specialHeader_[FEDSTATUS] = (static_cast<uint16_t>(fedStatusRegister) & 0x00FF);
804  specialHeader_[FEDSTATUS+1] = ( (static_cast<uint16_t>(fedStatusRegister) & 0xFF00) >> 8);
805  return *this;
806  }
807 
808  //FEDStatusRegister
809 
811  : data_(fedStatusRegister) { }
812 
813  inline FEDStatusRegister::operator uint16_t () const
814  { return data_; }
815 
816  inline bool FEDStatusRegister::getBit(const uint8_t num) const
817  { return ( (0x1<<num) & (data_) ); }
818 
820  { return getBit(0); }
821 
823  { return getBit(1); }
824 
826  { return getBit(2); }
827 
829  { return getBit(3); }
830 
832  { return getBit(4); }
833 
835  { return getBit(5); }
836 
838  { return getBit(6); }
839 
841  { return getBit(7); }
842 
843  inline bool FEDStatusRegister::feDataMissingFlag(const uint8_t internalFEUnitNum) const
844  {
845  return getBit(8+internalFEUnitNum);
846  }
847 
848  inline void FEDStatusRegister::print(std::ostream& os) const
849  { printHex(&data_,2,os); }
850 
852  { setBit(0,bitSet); return *this; }
853 
855  { setBit(1,bitSet); return *this; }
856 
857  inline void FEDStatusRegister::setQDRMemoryFullFlag(const bool bitSet)
858  { setBit(2,bitSet); }
859 
860  inline void FEDStatusRegister::setQDRMemoryPartialFullFlag(const bool bitSet)
861  { setBit(3,bitSet); }
862 
863  inline void FEDStatusRegister::setQDRMemoryEmptyFlag(const bool bitSet)
864  { setBit(4,bitSet); }
865 
866  inline void FEDStatusRegister::setL1ABXFIFOFullFlag(const bool bitSet)
867  { setBit(5,bitSet); }
868 
869  inline void FEDStatusRegister::setL1ABXFIFOPartialFullFlag(const bool bitSet)
870  { setBit(6,bitSet); }
871 
872  inline void FEDStatusRegister::setL1ABXFIFOEmptyFlag(const bool bitSet)
873  { setBit(7,bitSet); }
874 
875  inline FEDStatusRegister::FEDStatusRegister(const FEDBufferState qdrMemoryBufferState, const FEDBufferState l1aBxFIFOBufferState,
876  const bool trackerHeaderMonitorDataReadyFlagSet, const bool slinkFullFlagSet)
877  : data_(0x0000)
878  {
879  setSLinkFullFlag(slinkFullFlagSet);
880  setTrackerHeaderMonitorDataReadyFlag(trackerHeaderMonitorDataReadyFlagSet);
881  setQDRMemoryBufferState(qdrMemoryBufferState);
882  setL1ABXFIFOBufferState(l1aBxFIFOBufferState);
883  }
884 
885  //FEDBackendStatusRegister
886 
887  inline FEDBackendStatusRegister::FEDBackendStatusRegister(const uint32_t backendStatusRegister)
888  : data_(backendStatusRegister) { }
889 
890  inline FEDBackendStatusRegister::operator uint32_t () const
891  { return data_; }
892 
893  inline void FEDBackendStatusRegister::print(std::ostream& os) const
894  { printHex(&data_,4,os); }
895 
896  inline bool FEDBackendStatusRegister::getBit(const uint8_t num) const
897  { return ( (0x1<<num) & (data_) ); }
898 
900  { return getBit(1); }
901 
903  { return getBit(2); }
904 
906  { return getBit(3); }
907 
909  { return getBit(4); }
910 
912  { return getBit(6); }
913 
915  { return getBit(7); }
916 
918  { setBit(1,bitSet); return *this; }
919 
921  { setBit(2,bitSet); return *this; }
922 
924  { setBit(3,bitSet); return *this; }
925 
927  { setBit(4,bitSet); return *this; }
928 
930  { setBit(6,bitSet); return *this; }
931 
933  { setBit(7,bitSet); return *this; }
934 
936  {
938  }
939 
941  {
943  }
944 
946  {
948  }
949 
951  {
953  }
954 
956  {
958  }
959 
961  {
963  }
964 
966  {
968  }
969 
971  {
973  return *this;
974  }
975 
977  {
979  return *this;
980  }
981 
983  {
985  return *this;
986  }
987 
989  {
991  return *this;
992  }
993 
995  {
997  return *this;
998  }
999 
1001  {
1003  return *this;
1004  }
1005 
1007  {
1009  return *this;
1010  }
1011 
1012  //FEDFEHeader
1013 
1014  inline std::unique_ptr<FEDFEHeader> FEDFEHeader::newFEHeader(const FEDHeaderType headerType, const uint8_t* headerBuffer)
1015  {
1016  switch (headerType) {
1018  return std::unique_ptr<FEDFEHeader>(new FEDFullDebugHeader(headerBuffer));
1019  case HEADER_TYPE_APV_ERROR:
1020  return std::unique_ptr<FEDFEHeader>(new FEDAPVErrorHeader(headerBuffer));
1021  default:
1022  return std::unique_ptr<FEDFEHeader>();
1023  }
1024  }
1025 
1026  inline std::unique_ptr<FEDFEHeader> FEDFEHeader::newFEHeader(const FEDHeaderType headerType)
1027  {
1028  switch (headerType) {
1030  return std::unique_ptr<FEDFEHeader>(new FEDFullDebugHeader());
1031  case HEADER_TYPE_APV_ERROR:
1032  return std::unique_ptr<FEDFEHeader>(new FEDAPVErrorHeader());
1033  default:
1034  return std::unique_ptr<FEDFEHeader>();
1035  }
1036  }
1037 
1038  inline std::unique_ptr<FEDFEHeader> FEDFEHeader::newFEFakeHeader(const FEDHeaderType headerType)
1039  {
1040  switch (headerType) {
1042  return std::unique_ptr<FEDFEHeader>(new FEDFullDebugHeader);
1043  case HEADER_TYPE_APV_ERROR:
1044  return std::unique_ptr<FEDFEHeader>(new FEDAPVErrorHeader);
1045  default:
1046  return std::unique_ptr<FEDFEHeader>();
1047  }
1048  }
1049 
1050  inline bool FEDFEHeader::checkChannelStatusBits(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum) const
1051  {
1052  return checkChannelStatusBits(internalFEDChannelNum(internalFEUnitNum,internalFEUnitChannelNum));
1053  }
1054 
1055  inline bool FEDFEHeader::checkStatusBits(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum, const uint8_t apvNum) const
1056  {
1057  return checkStatusBits(internalFEDChannelNum(internalFEUnitNum,internalFEUnitChannelNum),apvNum);
1058  }
1059 
1060  inline void FEDFEHeader::setChannelStatus(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum, const FEDChannelStatus status)
1061  {
1062  this->setChannelStatus(internalFEDChannelNum(internalFEUnitNum,internalFEUnitChannelNum),status);
1063  }
1064 
1065  inline FEDAPVErrorHeader::FEDAPVErrorHeader(const uint8_t* headerBuffer)
1066  {
1067  memcpy(header_,headerBuffer,APV_ERROR_HEADER_SIZE_IN_BYTES);
1068  }
1069 
1070  inline FEDAPVErrorHeader& FEDAPVErrorHeader::setAPVStatusBit(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum,
1071  const uint8_t apvNum, const bool apvGood)
1072  {
1073  return setAPVStatusBit(internalFEDChannelNum(internalFEUnitNum,internalFEUnitChannelNum),apvNum,apvGood);
1074  }
1075 
1076  inline FEDFullDebugHeader::FEDFullDebugHeader(const uint8_t* headerBuffer)
1077  {
1078  memcpy(header_,headerBuffer,FULL_DEBUG_HEADER_SIZE_IN_BYTES);
1079  }
1080 
1081  inline uint8_t FEDFullDebugHeader::feUnitMajorityAddress(const uint8_t internalFEUnitNum) const
1082  {
1083  return feWord(internalFEUnitNum)[9];
1084  }
1085 
1087  {
1088  return FEDBackendStatusRegister(get32BitWordFrom(feWord(0)+10));
1089  }
1090 
1091  inline uint32_t FEDFullDebugHeader::daqRegister() const
1092  {
1093  return get32BitWordFrom(feWord(7)+10);
1094  }
1095 
1096  inline uint32_t FEDFullDebugHeader::daqRegister2() const
1097  {
1098  return get32BitWordFrom(feWord(6)+10);
1099  }
1100 
1101  inline uint16_t FEDFullDebugHeader::feUnitLength(const uint8_t internalFEUnitNum) const
1102  {
1103  return ( (feWord(internalFEUnitNum)[15]<<8) | (feWord(internalFEUnitNum)[14]) );
1104  }
1105 
1106  inline bool FEDFullDebugHeader::fePresent(const uint8_t internalFEUnitNum) const
1107  {
1108  return (feUnitLength(internalFEUnitNum) != 0);
1109  }
1110 
1111  inline bool FEDFullDebugHeader::unlocked(const uint8_t internalFEDChannelNum) const
1112  {
1113  return unlockedFromBit(internalFEDChannelNum);
1114  }
1115 
1116  inline bool FEDFullDebugHeader::unlocked(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum) const
1117  {
1118  return unlocked(internalFEDChannelNum(internalFEUnitNum,internalFEUnitChannelNum));
1119  }
1120 
1121  inline bool FEDFullDebugHeader::outOfSync(const uint8_t internalFEDChannelNum) const
1122  {
1123  return ( !unlocked(internalFEDChannelNum) && outOfSyncFromBit(internalFEDChannelNum) );
1124  }
1125 
1126  inline bool FEDFullDebugHeader::outOfSync(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum) const
1127  {
1128  return outOfSync(internalFEDChannelNum(internalFEUnitNum,internalFEUnitChannelNum));
1129  }
1130 
1131  inline bool FEDFullDebugHeader::apvError(const uint8_t internalFEDChannelNum, const uint8_t apvNum) const
1132  {
1133  return ( !unlockedFromBit(internalFEDChannelNum) &&
1134  !outOfSyncFromBit(internalFEDChannelNum) &&
1135  apvErrorFromBit(internalFEDChannelNum,apvNum) );
1136  }
1137 
1138  inline bool FEDFullDebugHeader::apvError(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum, const uint8_t apvNum) const
1139  {
1140  return apvError(internalFEDChannelNum(internalFEUnitNum,internalFEUnitChannelNum),apvNum);
1141  }
1142 
1143  inline bool FEDFullDebugHeader::apvAddressError(const uint8_t internalFEDChannelNum, const uint8_t apvNum) const
1144  {
1145  return ( !unlockedFromBit(internalFEDChannelNum) &&
1146  !outOfSyncFromBit(internalFEDChannelNum) &&
1147  apvAddressErrorFromBit(internalFEDChannelNum,apvNum) );
1148  }
1149 
1150  inline bool FEDFullDebugHeader::apvAddressError(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum, const uint8_t apvNum) const
1151  {
1152  return apvAddressError(internalFEDChannelNum(internalFEUnitNum,internalFEUnitChannelNum),apvNum);
1153  }
1154 
1155  inline FEDChannelStatus FEDFullDebugHeader::getChannelStatus(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum) const
1156  {
1157  return getChannelStatus(internalFEDChannelNum(internalFEUnitNum,internalFEUnitChannelNum));
1158  }
1159 
1161  {
1162  return !getBit(internalFEDChannelNum,5);
1163  }
1164 
1166  {
1167  return !getBit(internalFEDChannelNum,4);
1168  }
1169 
1170  inline bool FEDFullDebugHeader::apvErrorFromBit(const uint8_t internalFEDChannelNum, const uint8_t apvNum) const
1171  {
1172  //Discovered March 2012: two bits inverted in firmware. Decided
1173  //to update documentation but keep firmware identical for
1174  //backward compatibility. So status bit order is actually:
1175  //apvErr1 - apvAddrErr0 - apvErr0 - apvAddrErr1 - OOS - unlocked.
1176  //Before, it was: return !getBit(internalFEDChannelNum,0+2*apvNum);
1177 
1178  return !getBit(internalFEDChannelNum,0+2*(1-apvNum));
1179  }
1180 
1181  inline bool FEDFullDebugHeader::apvAddressErrorFromBit(const uint8_t internalFEDChannelNum, const uint8_t apvNum) const
1182  {
1183  return !getBit(internalFEDChannelNum,1+2*apvNum);
1184  }
1185 
1186  inline bool FEDFullDebugHeader::getBit(const uint8_t internalFEDChannelNum, const uint8_t bit) const
1187  {
1188  const uint8_t* pFEWord = feWord(internalFEDChannelNum / FEDCH_PER_FEUNIT);
1189  const uint8_t bitInFeWord = ((FEDCH_PER_FEUNIT-1) - (internalFEDChannelNum%FEDCH_PER_FEUNIT)) * 6 + bit;
1190  return ( pFEWord[bitInFeWord/8] & (0x1 << (bitInFeWord%8)) );
1191  }
1192 
1193  inline uint32_t FEDFullDebugHeader::get32BitWordFrom(const uint8_t* startOfWord)
1194  {
1195  return ( startOfWord[0] | (startOfWord[1]<<8) | (startOfWord[2]<<16) | (startOfWord[3]<<24) );
1196  }
1197 
1198  inline void FEDFullDebugHeader::set32BitWordAt(uint8_t* startOfWord, const uint32_t value)
1199  {
1200  memcpy(startOfWord,&value,4);
1201  }
1202 
1203  inline const uint8_t* FEDFullDebugHeader::feWord(const uint8_t internalFEUnitNum) const
1204  {
1205  return header_+internalFEUnitNum*2*8;
1206  }
1207 
1208  //re-use const method
1209  inline uint8_t* FEDFullDebugHeader::feWord(const uint8_t internalFEUnitNum)
1210  {
1211  return const_cast<uint8_t*>(static_cast<const FEDFullDebugHeader*>(this)->feWord(internalFEUnitNum));
1212  }
1213 
1214  inline void FEDFullDebugHeader::setUnlocked(const uint8_t internalFEDChannelNum, const bool value)
1215  {
1216  setBit(internalFEDChannelNum,5,!value);
1217  }
1218 
1219  inline void FEDFullDebugHeader::setOutOfSync(const uint8_t internalFEDChannelNum, const bool value)
1220  {
1221  setBit(internalFEDChannelNum,4,!value);
1222  }
1223 
1224  inline void FEDFullDebugHeader::setAPVAddressError(const uint8_t internalFEDChannelNum, const uint8_t apvNum, const bool value)
1225  {
1226  setBit(internalFEDChannelNum,1+2*apvNum,!value);
1227  }
1228 
1229  inline void FEDFullDebugHeader::setAPVError(const uint8_t internalFEDChannelNum, const uint8_t apvNum, const bool value)
1230  {
1231  //Discovered March 2012: two bits inverted in firmware. Decided
1232  //to update documentation but keep firmware identical for
1233  //backward compatibility. So status bit order is actually:
1234  //apvErr1 - apvAddrErr0 - apvErr0 - apvAddrErr1 - OOS - unlocked.
1235  //Before, it was: return !getBit(internalFEDChannelNum,0+2*apvNum);
1236 
1237  setBit(internalFEDChannelNum,0+2*(1-apvNum),!value);
1238  }
1239 
1240  //FEDDAQHeader
1241 
1242  inline FEDDAQHeader::FEDDAQHeader(const uint8_t* header)
1243  {
1244  memcpy(header_,header,8);
1245  }
1246 
1247  inline uint8_t FEDDAQHeader::boeNibble() const
1248  {
1249  return ( (header_[7] & 0xF0) >> 4 );
1250  }
1251 
1252  inline uint8_t FEDDAQHeader::eventTypeNibble() const
1253  {
1254  return (header_[7] & 0x0F);
1255  }
1256 
1257  inline uint32_t FEDDAQHeader::l1ID() const
1258  {
1259  return ( header_[4] | (header_[5]<<8) | (header_[6]<<16) );
1260  }
1261 
1262  inline uint16_t FEDDAQHeader::bxID() const
1263  {
1264  return ( (header_[3]<<4) | ((header_[2]&0xF0)>>4) );
1265  }
1266 
1267  inline uint16_t FEDDAQHeader::sourceID() const
1268  {
1269  return ( ((header_[2]&0x0F)<<8) | header_[1] );
1270  }
1271 
1272  inline uint8_t FEDDAQHeader::version() const
1273  {
1274  return ( (header_[0] & 0xF0) >> 4 );
1275  }
1276 
1277  inline bool FEDDAQHeader::hBit() const
1278  {
1279  return (header_[0] & 0x8);
1280  }
1281 
1282  inline bool FEDDAQHeader::lastHeader() const
1283  {
1284  return !hBit();
1285  }
1286 
1287  inline const uint8_t* FEDDAQHeader::data() const
1288  {
1289  return header_;
1290  }
1291 
1292  inline void FEDDAQHeader::print(std::ostream& os) const
1293  {
1294  printHex(header_,8,os);
1295  }
1296 
1297  //FEDDAQTrailer
1298 
1299  inline FEDDAQTrailer::FEDDAQTrailer(const uint8_t* trailer)
1300  {
1301  memcpy(trailer_,trailer,8);
1302  }
1303 
1304  inline uint8_t FEDDAQTrailer::eoeNibble() const
1305  {
1306  return ( (trailer_[7] & 0xF0) >> 4 );
1307  }
1308 
1310  {
1311  return ( trailer_[4] | (trailer_[5]<<8) | (trailer_[6]<<16) );
1312  }
1313 
1314  inline uint32_t FEDDAQTrailer::eventLengthInBytes() const
1315  {
1316  return eventLengthIn64BitWords()*8;
1317  }
1318 
1319  inline uint16_t FEDDAQTrailer::crc() const
1320  {
1321  return ( trailer_[2] | (trailer_[3]<<8) );
1322  }
1323 
1324  inline bool FEDDAQTrailer::cBit() const
1325  {
1326  return (trailer_[1] & 0x80);
1327  }
1328 
1329  inline bool FEDDAQTrailer::fBit() const
1330  {
1331  return (trailer_[1] & 0x40);
1332  }
1333 
1334  inline uint8_t FEDDAQTrailer::eventStatusNibble() const
1335  {
1336  return (trailer_[1] & 0x0F);
1337  }
1338 
1339  inline uint8_t FEDDAQTrailer::ttsNibble() const
1340  {
1341  return ( (trailer_[0] & 0xF0) >> 4);
1342  }
1343 
1344  inline bool FEDDAQTrailer::tBit() const
1345  {
1346  return (trailer_[0] & 0x08);
1347  }
1348 
1349  inline bool FEDDAQTrailer::rBit() const
1350  {
1351  return (trailer_[0] & 0x04);
1352  }
1353 
1354  inline void FEDDAQTrailer::print(std::ostream& os) const
1355  {
1356  printHex(trailer_,8,os);
1357  }
1358 
1359  inline const uint8_t* FEDDAQTrailer::data() const
1360  {
1361  return trailer_;
1362  }
1363 
1364  //FEDBufferBase
1365 
1366  inline void FEDBufferBase::dump(std::ostream& os) const
1367  {
1368  printHex(orderedBuffer_,bufferSize_,os);
1369  }
1370 
1371  inline void FEDBufferBase::dumpOriginalBuffer(std::ostream& os) const
1372  {
1373  printHex(originalBuffer_,bufferSize_,os);
1374  }
1375 
1376  inline uint16_t FEDBufferBase::calcCRC() const
1377  {
1378  return calculateFEDBufferCRC(orderedBuffer_,bufferSize_);
1379  }
1380 
1382  {
1383  return daqHeader_;
1384  }
1385 
1387  {
1388  return daqTrailer_;
1389  }
1390 
1391  inline size_t FEDBufferBase::bufferSize() const
1392  {
1393  return bufferSize_;
1394  }
1395 
1397  {
1398  return specialHeader_;
1399  }
1400 
1402  {
1403  return daqHeader_.eventType();
1404  }
1405 
1406  inline uint32_t FEDBufferBase::daqLvl1ID() const
1407  {
1408  return daqHeader_.l1ID();
1409  }
1410 
1411  inline uint16_t FEDBufferBase::daqBXID() const
1412  {
1413  return daqHeader_.bxID();
1414  }
1415 
1416  inline uint16_t FEDBufferBase::daqSourceID() const
1417  {
1418  return daqHeader_.sourceID();
1419  }
1420 
1422  {
1423  return daqTrailer_.eventLengthIn64BitWords();
1424  }
1425 
1427  {
1428  return daqTrailer_.eventLengthInBytes();
1429  }
1430 
1431  inline uint16_t FEDBufferBase::daqCRC() const
1432  {
1433  return daqTrailer_.crc();
1434  }
1435 
1437  {
1438  return daqTrailer_.ttsBits();
1439  }
1440 
1442  {
1443  return specialHeader_.bufferFormat();
1444  }
1445 
1447  {
1448  return specialHeader_.headerType();
1449  }
1450 
1452  {
1453  return specialHeader_.legacyReadoutMode();
1454  }
1455 
1457  {
1458  return specialHeader_.readoutMode();
1459  }
1460 
1461  inline uint8_t FEDBufferBase::packetCode(bool legacy, const uint8_t internalFEDChannelNum) const
1462  {
1463  if (legacy) {
1464  FEDLegacyReadoutMode mode = legacyReadoutMode();
1465  switch(mode) {
1467  return PACKET_CODE_SCOPE;
1470  return PACKET_CODE_VIRGIN_RAW;
1473  return PACKET_CODE_PROC_RAW;
1482  default:
1483  return 0;
1484  }
1485  } else {
1486  FEDReadoutMode mode = readoutMode();
1487  switch(mode) {
1488  case READOUT_MODE_SCOPE:
1489  return PACKET_CODE_SCOPE;
1491  return channel(internalFEDChannelNum).packetCode();
1492  case READOUT_MODE_PROC_RAW:
1493  return PACKET_CODE_PROC_RAW;
1495  return channel(internalFEDChannelNum).packetCode();
1505  case READOUT_MODE_SPY:
1506  case READOUT_MODE_INVALID:
1507  default:
1508  return 0;
1509  }
1510  }
1511  }
1512 
1513  inline uint8_t FEDBufferBase::apveAddress() const
1514  {
1515  return specialHeader_.apveAddress();
1516  }
1517 
1518  inline bool FEDBufferBase::majorityAddressErrorForFEUnit(const uint8_t internalFEUnitNum) const
1519  {
1520  return (specialHeader_.majorityAddressErrorForFEUnit(internalFEUnitNum) && (specialHeader_.apveAddress() != 0x00));
1521  }
1522 
1523  inline bool FEDBufferBase::feEnabled(const uint8_t internalFEUnitNum) const
1524  {
1525  return specialHeader_.feEnabled(internalFEUnitNum);
1526  }
1527 
1528  inline bool FEDBufferBase::feOverflow(const uint8_t internalFEUnitNum) const
1529  {
1530  return specialHeader_.feOverflow(internalFEUnitNum);
1531  }
1532 
1534  {
1535  return specialHeader_.fedStatusRegister();
1536  }
1537 
1538  inline bool FEDBufferBase::channelGood(const uint8_t internalFEUnitNum, const uint8_t internalChannelNum) const
1539  {
1540  return channelGood(internalFEDChannelNum(internalFEUnitNum,internalChannelNum));
1541  }
1542 
1543  inline const FEDChannel& FEDBufferBase::channel(const uint8_t internalFEDChannelNum) const
1544  {
1545  return channels_[internalFEDChannelNum];
1546  }
1547 
1548  inline const FEDChannel& FEDBufferBase::channel(const uint8_t internalFEUnitNum, const uint8_t internalChannelNum) const
1549  {
1550  return channel(internalFEDChannelNum(internalFEUnitNum,internalChannelNum));
1551  }
1552 
1554  {
1555  return ( checkBufferFormat() &&
1556  checkHeaderType() &&
1557  checkReadoutMode() &&
1558  //checkAPVEAddressValid() &&
1559  checkNoFEOverflows() );
1560  }
1561 
1563  {
1564  return ( checkNoSLinkTransmissionError() &&
1565  checkSourceIDs() &&
1566  checkNoUnexpectedSourceID() &&
1567  checkNoExtraHeadersOrTrailers() &&
1568  checkLengthFromTrailer() );
1569  }
1570 
1571  inline bool FEDBufferBase::checkCRC() const
1572  {
1573  return ( checkNoSlinkCRCError() && (calcCRC()==daqCRC()) );
1574  }
1575 
1577  {
1578  return (bufferFormat() != BUFFER_FORMAT_INVALID);
1579  }
1580 
1582  {
1583  return (headerType() != HEADER_TYPE_INVALID);
1584  }
1585 
1587  {
1588  return (readoutMode() != READOUT_MODE_INVALID);
1589  }
1590 
1592  {
1593  return (apveAddress() <= APV_MAX_ADDRESS);
1594  }
1595 
1597  {
1598  return !specialHeader_.feOverflowRegister();
1599  }
1600 
1602  {
1603  return !daqTrailer_.slinkCRCError();
1604  }
1605 
1607  {
1608  return !daqTrailer_.slinkTransmissionError();
1609  }
1610 
1612  {
1613  return !daqTrailer_.badSourceID();
1614  }
1615 
1617  {
1618  return ( (daqHeader_.boeNibble() == 0x5) && (daqTrailer_.eoeNibble() == 0xA) );
1619  }
1620 
1622  {
1623  return (bufferSize() == daqEventLengthInBytes());
1624  }
1625 
1627  {
1628  return orderedBuffer_+16;
1629  }
1630 
1632  {
1633  return orderedBuffer_+bufferSize_-8;
1634  }
1635 
1636  //FEDChannel
1637 
1638  inline FEDChannel::FEDChannel(const uint8_t*const data, const size_t offset)
1639  : data_(data),
1640  offset_(offset)
1641  {
1642  length_ = ( data_[(offset_)^7] + (data_[(offset_+1)^7] << 8) );
1643  }
1644 
1645  inline FEDChannel::FEDChannel(const uint8_t*const data, const size_t offset, const uint16_t length)
1646  : data_(data),
1647  offset_(offset),
1648  length_(length)
1649  {
1650  }
1651 
1652  inline uint16_t FEDChannel::length() const
1653  {
1654  return length_;
1655  }
1656 
1657  inline uint8_t FEDChannel::packetCode() const
1658  {
1659  return data_[(offset_+2)^7];
1660  }
1661 
1662  inline const uint8_t* FEDChannel::data() const
1663  {
1664  return data_;
1665  }
1666 
1667  inline size_t FEDChannel::offset() const
1668  {
1669  return offset_;
1670  }
1671 
1672 }
1673 
1674 #endif //ndef EventFilter_SiStripRawToDigi_FEDBufferComponents_H
static uint8_t physicalOrderForStripInChannel(const uint8_t readoutOrderStripIndexInChannel)
FEDBackendStatusRegister & setFEFPGABufferState(const FEDBufferState state)
FEDBackendStatusRegister & setQDRMemoryState(const FEDBufferState state)
FEDBackendStatusRegister & setL1ABXFIFOState(const FEDBufferState state)
bool getBit(const uint8_t internalFEDChannelNum, const uint8_t bit) const
static const uint8_t PACKET_CODE_ZERO_SUPPRESSED8_BOTBOT
bool feDataMissingFlag(const uint8_t internalFEUnitNum) const
void setBit(const uint8_t num, const bool bitSet)
bool fePresent(const uint8_t internalFEUnitNum) const
void setOutOfSync(const uint8_t internalFEDChannelNum, const bool value)
bool getBit(const uint8_t num) const
void setQDRMemoryEmptyFlag(const bool bitSet)
uint32_t daqEventLengthIn64bitWords() const
bool feEnabled(const uint8_t internalFEUnitNum) const
virtual std::string checkSummary() const
FEDStatusRegister & setTrackerHeaderMonitorDataReadyFlag(const bool bitSet)
FEDBackendStatusRegister & setFrameAddressFIFOState(const FEDBufferState state)
TrackerSpecialHeader & setFEOverflowRegister(const uint8_t feOverflowRegister)
bool unlockedFromBit(const uint8_t internalFEDChannelNum) const
const uint8_t * getPointerToByteAfterEndOfPayload() const
FEDDAQTrailer daqTrailer() const
static const uint8_t PACKET_CODE_SCOPE
bool unlocked(const uint8_t internalFEDChannelNum) const
FEDBackendStatusRegister & setTrackerHeaderFIFOState(const FEDBufferState state)
FEDFullDebugHeader(const uint8_t *headerBuffer)
void print(std::ostream &os) const
static std::unique_ptr< FEDFEHeader > newFEHeader(const FEDHeaderType headerType, const uint8_t *headerBuffer)
static const uint8_t PACKET_CODE_PROC_RAW10
const uint8_t * feWord(const uint8_t internalFEUnitNum) const
FEDBackendStatusRegister beStatusRegister() const
FEDReadoutMode readoutMode() const
bool getBit(const uint8_t num) const
FEDStatusRegister(const uint16_t fedStatusRegister)
static uint32_t get32BitWordFrom(const uint8_t *startOfWord)
int init
Definition: HydjetWrapper.h:67
void setAPVError(const uint8_t internalFEDChannelNum, const uint8_t apvNum, const bool value)
FEDStatusRegister & setSLinkFullFlag(const bool bitSet)
uint8_t internalFEDChannelNum(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum)
FEDStatusRegister fedStatusRegister() const
virtual void print(std::ostream &os) const =0
void print(std::ostream &os) const
TrackerSpecialHeader & setAPVEAddress(const uint8_t address)
const uint8_t * getPointerToDataAfterTrackerSpecialHeader() const
FEDHeaderType fedHeaderTypeFromString(const std::string &headerTypeString)
uint16_t calculateFEDBufferCRC(const uint8_t *buffer, const size_t lengthInBytes)
FEDChannel(const uint8_t *const data, const size_t offset, const uint16_t length)
uint8_t packetCodeFromString(const std::string &packetCodeString, FEDReadoutMode mode)
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
std::ostream & operator<<(std::ostream &os, const FEDBufferFormat &value)
bool apvError(const uint8_t internalFEDChannelNum, const uint8_t apvNum) const
FEDAPVErrorHeader(const uint8_t *headerBuffer)
const uint8_t * data() const
FEDBufferFormat fedBufferFormatFromString(const std::string &bufferFormatString)
void setBit(const uint8_t num, const bool bitSet)
sistrip classes
FEDDAQEventType daqEventType() const
void dumpOriginalBuffer(std::ostream &os) const
FEDReadoutMode fedReadoutModeFromString(const std::string &readoutModeString)
bool feOverflow(const uint8_t internalFEUnitNum) const
static const uint8_t PACKET_CODE_ZERO_SUPPRESSED8_TOPBOT
static uint8_t readoutOrderForStripInChannel(const uint8_t physicalOrderStripIndexInChannel)
static const uint8_t PACKET_CODE_ZERO_SUPPRESSED10
FEDBackendStatusRegister(const uint32_t backendStatusRegister)
static const uint8_t PACKET_CODE_VIRGIN_RAW10
bool checkStatusBits(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum, const uint8_t apvNum) const
const uint8_t * data() const
static const uint8_t PACKET_CODE_ZERO_SUPPRESSED
FEDBackendStatusRegister & setTotalLengthFIFOState(const FEDBufferState state)
bool majorityAddressErrorForFEUnit(const uint8_t internalFEUnitNum) const
void setUnlocked(const uint8_t internalFEDChannelNum, const bool value)
FEDBackendStatusRegister & setTTCReadyFlag(const bool bitSet)
TrackerSpecialHeader & setAPVEAddressErrorRegister(const uint8_t addressErrorRegister)
TrackerSpecialHeader & setFEDStatusRegister(const FEDStatusRegister fedStatusRegister)
bool apvErrorFromBit(const uint8_t internalFEDChannelNum, const uint8_t apvNum) const
FEDStatusRegister & setL1ABXFIFOBufferState(const FEDBufferState state)
FEDAPVErrorHeader & setAPVStatusBit(const uint8_t internalFEDChannelNum, const uint8_t apvNum, const bool apvGood)
static const uint16_t FEUNITS_PER_FED
FEDLegacyReadoutMode legacyReadoutMode() const
void setQDRMemoryFullFlag(const bool bitSet)
bool feEnabled(const uint8_t internalFEUnitNum) const
virtual void setChannelStatus(const uint8_t internalFEDChannelNum, const FEDChannelStatus status)=0
void dump(std::ostream &os) const
void setL1ABXFIFOFullFlag(const bool bitSet)
static const uint8_t BUFFER_FORMAT_CODE_NEW
FEDHeaderType headerType() const
void setAPVAddressError(const uint8_t internalFEDChannelNum, const uint8_t apvNum, const bool value)
static const uint8_t APV_MAX_ADDRESS
uint8_t packetCode(bool legacy=false, const uint8_t internalFEDChannelNum=0) const
Definition: value.py:1
void setL1ABXFIFOPartialFullFlag(const bool bitSet)
void setHeaderTypeNibble(const uint8_t value)
static const uint8_t INVALID
const FEDChannel & channel(const uint8_t internalFEDChannelNum) const
static const uint8_t PACKET_CODE_VIRGIN_RAW8_TOPBOT
FEDDAQEventType fedDAQEventTypeFromString(const std::string &daqEventTypeString)
bool outOfSync(const uint8_t internalFEDChannelNum) const
std::vector< FEDChannel > channels_
void setBit(int &_bitArray, unsigned _iBit)
FEDBufferState getBufferState(const uint8_t bufferPosition) const
bool checkChannelStatusBits(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum) const
void print(std::ostream &os) const
static const uint8_t PACKET_CODE_PROC_RAW
static const uint16_t APVS_PER_FED
static const uint8_t PACKET_CODE_VIRGIN_RAW8_BOTBOT
void printHex(const void *pointer, const size_t length, std::ostream &os)
static uint8_t physicalOrderForStripInAPV(const uint8_t readoutOrderStripIndexInAPV)
static const uint16_t FEDCH_PER_FEUNIT
Constants and enumerated types for FED/FEC systems.
FEDBackendStatusRegister & setTrackerHeaderMonitorDataReadyFlag(const bool bitSet)
void setReadoutModeBits(const uint8_t value)
bool apvAddressError(const uint8_t internalFEDChannelNum, const uint8_t apvNum) const
const uint8_t * data() const
TrackerSpecialHeader trackerSpecialHeader() const
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
FEDBackendStatusRegister & setSLinkFullFlag(const bool bitSet)
void print(std::ostream &os) const
uint16_t feUnitLength(const uint8_t internalFEUnitNum) const
void setBufferSate(const uint8_t bufferPosition, const FEDBufferState state)
uint8_t feUnitMajorityAddress(const uint8_t internalFEUnitNum) const
static std::unique_ptr< FEDFEHeader > newFEFakeHeader(const FEDHeaderType headerType)
TrackerSpecialHeader specialHeader_
void calcCRC(long, int &)
Definition: DTCRC.cc:3
FEDChannelStatus getChannelStatus(const uint8_t internalFEDChannelNum) const
virtual void print(std::ostream &os) const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
static const uint16_t FEDCH_PER_FED
static const uint16_t STRIPS_PER_APV
virtual bool channelGood(const uint8_t internalFEDChannelNum) const
FEDBackendStatusRegister & setFEEventLengthFIFOState(const FEDBufferState state)
static const uint8_t PACKET_CODE_PROC_RAW8_BOTBOT
bool majorityAddressErrorForFEUnit(const uint8_t internalFEUnitNum) const
bool apvAddressErrorFromBit(const uint8_t internalFEDChannelNum, const uint8_t apvNum) const
static const uint8_t BUFFER_FORMAT_CODE_OLD
static const uint16_t SCOPE_MODE_MAX_SCOPE_LENGTH
static uint8_t readoutOrderForStripInAPV(const uint8_t physicalOrderStripIndexInAPV)
FEDStatusRegister & setQDRMemoryBufferState(const FEDBufferState state)
static void set32BitWordAt(uint8_t *startOfWord, const uint32_t value)
FEDBackendStatusRegister & setInternalFreezeFlag(const bool bitSet)
static const uint8_t PACKET_CODE_PROC_RAW8_TOPBOT
void setL1ABXFIFOEmptyFlag(const bool bitSet)
bool getBit(int &_bitArray, unsigned _iBit)
FEDBackendStatusRegister & setBackpressureFlag(const bool bitSet)
static const uint8_t PACKET_CODE_VIRGIN_RAW
bool outOfSyncFromBit(const uint8_t internalFEDChannelNum) const
bool feOverflow(const uint8_t internalFEUnitNum) const
FEDStatusRegister fedStatusRegister() const
void setQDRMemoryPartialFullFlag(const bool bitSet)
FEDBackendStatusRegister & setSLinkDownFlag(const bool bitSet)
FEDBufferFormat bufferFormat() const
TrackerSpecialHeader & setFEEnableRegister(const uint8_t feEnableRegister)