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