1 #ifndef EventFilter_SiStripRawToDigi_SiStripFEDBufferComponents_H
2 #define EventFilter_SiStripRawToDigi_SiStripFEDBufferComponents_H
4 #include "boost/cstdint.hpp"
110 uint8_t
internalFEDChannelNum(
const uint8_t internalFEUnitNum,
const uint8_t internalFEUnitChannelNum);
111 void printHex(
const void* pointer,
const size_t length, std::ostream& os);
156 uint32_t
l1ID()
const;
157 uint16_t
bxID()
const;
163 void print(std::ostream& os)
const;
165 const uint8_t*
data()
const;
186 uint16_t
crc()
const;
202 void print(std::ostream& os)
const;
204 const uint8_t*
data()
const;
234 void print(std::ostream& os)
const;
236 operator uint16_t ()
const;
244 const bool trackerHeaderMonitorDataReadyFlagSet =
false,
245 const bool slinkFullFlagSet =
false);
248 void setBit(
const uint8_t num,
const bool bitSet);
275 bool feEnabled(
const uint8_t internalFEUnitNum)
const;
277 bool feOverflow(
const uint8_t internalFEUnitNum)
const;
280 void print(std::ostream& os)
const;
283 const uint8_t*
data()
const;
299 const uint8_t address = 0x00,
const uint8_t addressErrorRegister = 0x00,
300 const uint8_t feEnableRegister = 0xFF,
const uint8_t feOverflowRegister = 0x00,
331 void print(std::ostream& os)
const;
333 operator uint32_t ()
const;
355 const bool backpressure =
false,
const bool slinkFull =
false,
356 const bool slinkDown =
false,
const bool internalFreeze =
false,
357 const bool trackerHeaderMonitorDataReady =
false,
const bool ttcReady =
true);
360 void setBit(
const uint8_t num,
const bool bitSet);
397 bool checkChannelStatusBits(
const uint8_t internalFEUnitNum,
const uint8_t internalFEUnitChannelNum)
const;
400 bool checkStatusBits(
const uint8_t internalFEUnitNum,
const uint8_t internalFEUnitChannelNum,
const uint8_t apvNum)
const;
401 virtual bool checkStatusBits(
const uint8_t internalFEDChannelNum,
const uint8_t apvNum)
const = 0;
402 virtual void print(std::ostream& os)
const = 0;
405 virtual const uint8_t*
data()
const = 0;
409 virtual void setFEUnitLength(
const uint8_t internalFEUnitNum,
const uint16_t length) = 0;
420 virtual bool checkStatusBits(
const uint8_t internalFEDChannelNum,
const uint8_t apvNum)
const;
421 virtual void print(std::ostream& os)
const;
424 virtual const uint8_t*
data()
const;
433 virtual void setFEUnitLength(
const uint8_t internalFEUnitNum,
const uint16_t length);
447 virtual bool checkStatusBits(
const uint8_t internalFEDChannelNum,
const uint8_t apvNum)
const;
448 virtual void print(std::ostream& os)
const;
455 uint16_t
feUnitLength(
const uint8_t internalFEUnitNum)
const;
456 bool fePresent(
const uint8_t internalFEUnitNum)
const;
464 bool unlocked(
const uint8_t internalFEDChannelNum)
const;
465 bool unlocked(
const uint8_t internalFEUnitNum,
const uint8_t internalFEUnitChannelNum)
const;
467 bool outOfSync(
const uint8_t internalFEDChannelNum)
const;
468 bool outOfSync(
const uint8_t internalFEUnitNum,
const uint8_t internalFEUnitChannelNum)
const;
470 bool apvError(
const uint8_t internalFEDChannelNum,
const uint8_t apvNum)
const;
471 bool apvError(
const uint8_t internalFEUnitNum,
const uint8_t internalFEUnitChannelNum,
const uint8_t apvNum)
const;
473 bool apvAddressError(
const uint8_t internalFEDChannelNum,
const uint8_t apvNum)
const;
474 bool apvAddressError(
const uint8_t internalFEUnitNum,
const uint8_t internalFEUnitChannelNum,
const uint8_t apvNum)
const;
477 virtual const uint8_t*
data()
const;
483 virtual void setFEUnitLength(
const uint8_t internalFEUnitNum,
const uint16_t length);
485 const std::vector<uint8_t>& feMajorityAddresses = std::vector<uint8_t>(
FEUNITS_PER_FED,0),
488 const uint32_t daqRegister = 0,
const uint32_t daqRegister2 = 0);
490 bool getBit(
const uint8_t internalFEDChannelNum,
const uint8_t bit)
const;
493 const uint8_t*
feWord(
const uint8_t internalFEUnitNum)
const;
494 uint8_t*
feWord(
const uint8_t internalFEUnitNum);
495 void setBit(
const uint8_t internalFEDChannelNum,
const uint8_t bit,
const bool value);
502 bool apvErrorFromBit(
const uint8_t internalFEDChannelNum,
const uint8_t apvNum)
const;
506 void setUnlocked(
const uint8_t internalFEDChannelNum,
const bool value);
507 void setOutOfSync(
const uint8_t internalFEDChannelNum,
const bool value);
508 void setAPVAddressError(
const uint8_t internalFEDChannelNum,
const uint8_t apvNum,
const bool value);
509 void setAPVError(
const uint8_t internalFEDChannelNum,
const uint8_t apvNum,
const bool value);
521 FEDChannel(
const uint8_t*
const data,
const size_t offset);
523 const uint8_t*
data()
const;
525 uint16_t
cmMedian(
const uint8_t apvIndex)
const;
539 FEDBufferBase(
const uint8_t* fedBuffer,
const size_t fedBufferSize,
const bool allowUnrecognizedFormat =
false);
542 void dump(std::ostream& os)
const;
545 virtual void print(std::ostream& os)
const;
572 bool feEnabled(
const uint8_t internalFEUnitNum)
const;
574 bool feOverflow(
const uint8_t internalFEUnitNum)
const;
579 bool channelGood(
const uint8_t internalFEUnitNum,
const uint8_t internalChannelNum)
const;
582 const FEDChannel&
channel(
const uint8_t internalFEUnitNum,
const uint8_t internalChannelNum)
const;
613 FEDBufferBase(
const uint8_t* fedBuffer,
const size_t fedBufferSize,
const bool allowUnrecognizedFormat,
const bool fillChannelVector);
616 void init(
const uint8_t* fedBuffer,
const size_t fedBufferSize,
const bool allowUnrecognizedFormat);
656 return ( (32 * (readout_order%4)) +
657 (8 * static_cast<uint16_t>(static_cast<float>(readout_order)/4.0)) -
658 (31 * static_cast<uint16_t>(static_cast<float>(readout_order)/16.0))
664 return ( 4*((static_cast<uint16_t>((static_cast<float>(physical_order)/8.0)))%4) +
665 static_cast<uint16_t>(static_cast<float>(physical_order)/32.0) +
666 16*(physical_order%8)
673 : wordSwapped_(
false)
717 return statusRegister;
785 : data_(fedStatusRegister) { }
791 {
return ( (0x1<<num) & (
data_) ); }
819 return getBit(8+internalFEUnitNum);
826 {
setBit(0,bitSet);
return *
this; }
829 {
setBit(1,bitSet);
return *
this; }
850 const bool trackerHeaderMonitorDataReadyFlagSet,
const bool slinkFullFlagSet)
862 : data_(backendStatusRegister) { }
871 {
return ( (0x1<<num) & (
data_) ); }
892 {
setBit(1,bitSet);
return *
this; }
895 {
setBit(2,bitSet);
return *
this; }
898 {
setBit(3,bitSet);
return *
this; }
901 {
setBit(4,bitSet);
return *
this; }
904 {
setBit(6,bitSet);
return *
this; }
907 {
setBit(7,bitSet);
return *
this; }
990 switch (headerType) {
996 return std::auto_ptr<FEDFEHeader>();
1002 switch (headerType) {
1008 return std::auto_ptr<FEDFEHeader>();
1014 switch (headerType) {
1020 return std::auto_ptr<FEDFEHeader>();
1045 const uint8_t apvNum,
const bool apvGood)
1057 return feWord(internalFEUnitNum)[9];
1077 return ( (
feWord(internalFEUnitNum)[15]<<8) | (
feWord(internalFEUnitNum)[14]) );
1136 return !
getBit(internalFEDChannelNum,5);
1141 return !
getBit(internalFEDChannelNum,4);
1152 return !
getBit(internalFEDChannelNum,0+2*(1-apvNum));
1157 return !
getBit(internalFEDChannelNum,1+2*apvNum);
1164 return ( pFEWord[bitInFeWord/8] & (0x1 << (bitInFeWord%8)) );
1169 return ( startOfWord[0] | (startOfWord[1]<<8) | (startOfWord[2]<<16) | (startOfWord[3]<<24) );
1174 memcpy(startOfWord,&value,4);
1179 return header_+internalFEUnitNum*2*8;
1190 setBit(internalFEDChannelNum,5,!value);
1195 setBit(internalFEDChannelNum,4,!value);
1200 setBit(internalFEDChannelNum,1+2*apvNum,!value);
1211 setBit(internalFEDChannelNum,0+2*(1-apvNum),!value);
1223 return ( (
header_[7] & 0xF0) >> 4 );
1248 return ( (
header_[0] & 0xF0) >> 4 );
1280 return ( (
trailer_[7] & 0xF0) >> 4 );
1315 return ( (
trailer_[0] & 0xF0) >> 4);
1596 #endif //ndef EventFilter_SiStripRawToDigi_FEDBufferComponents_H
static uint8_t physicalOrderForStripInChannel(const uint8_t readoutOrderStripIndexInChannel)
bool checkNoUnexpectedSourceID() const
FEDBackendStatusRegister & setFEFPGABufferState(const FEDBufferState state)
FEDBackendStatusRegister & setQDRMemoryState(const FEDBufferState state)
FEDBackendStatusRegister & setL1ABXFIFOState(const FEDBufferState state)
uint16_t sourceID() const
bool checkNoExtraHeadersOrTrailers() const
virtual bool doChecks() const
bool feDataMissingFlag(const uint8_t internalFEUnitNum) const
bool qdrMemoryPartialFullFlag() const
bool checkSourceIDs() const
void printFlags(std::ostream &os) const
void setBit(const uint8_t num, const bool bitSet)
uint8_t nFEUnitsEnabled() const
bool ttcReadyFlag() const
bool checkReadoutMode() const
bool getBit(const uint8_t num) const
void setQDRMemoryEmptyFlag(const bool bitSet)
uint32_t daqEventLengthIn64bitWords() const
virtual std::string checkSummary() const
uint8_t apveAddress() const
FEDStatusRegister & setTrackerHeaderMonitorDataReadyFlag(const bool bitSet)
FEDBackendStatusRegister & setFrameAddressFIFOState(const FEDBufferState state)
uint32_t daqEventLengthInBytes() const
const uint8_t * getPointerToByteAfterEndOfPayload() const
FEDDAQTrailer daqTrailer() const
static const uint8_t PACKET_CODE_SCOPE
FEDBackendStatusRegister & setTrackerHeaderFIFOState(const FEDBufferState state)
bool slinkDownFlag() const
bool l1aBxFIFOPartialFullFlag() const
void print(std::ostream &os) const
bool checkHeaderType() const
bool doDAQHeaderAndTrailerChecks() const
uint8_t eoeNibble() const
FEDDAQTrailer & setSLinkCRCErrorBit(const bool bitSet)
FEDDAQTrailer & setTTSBits(const FEDTTSBits ttsBits)
bool trackerHeaderMonitorDataReadyFlag() const
FEDReadoutMode readoutMode() const
FEDDataType fedDataTypeFromString(const std::string &dataTypeString)
bool getBit(const uint8_t num) const
FEDStatusRegister(const uint16_t fedStatusRegister)
FEDStatusRegister & setSLinkFullFlag(const bool bitSet)
uint8_t internalFEDChannelNum(const uint8_t internalFEUnitNum, const uint8_t internalFEUnitChannelNum)
void print(std::ostream &os) const
bool checkNoFEOverflows() const
const uint8_t * getPointerToDataAfterTrackerSpecialHeader() const
FEDDAQTrailer & setSLinkTransmissionErrorBit(const bool bitSet)
FEDHeaderType fedHeaderTypeFromString(const std::string &headerTypeString)
void printFlags(std::ostream &os) const
uint32_t eventLengthIn64BitWords() const
uint16_t calculateFEDBufferCRC(const uint8_t *buffer, const size_t lengthInBytes)
bool backpressureFlag() const
FEDChannel(const uint8_t *const data, const size_t offset, const uint16_t length)
std::ostream & operator<<(std::ostream &os, const FEDBufferFormat &value)
bool slinkCRCError() const
FEDBufferFormat fedBufferFormatFromString(const std::string &bufferFormatString)
void setBit(const uint8_t num, const bool bitSet)
FEDDAQEventType daqEventType() const
const uint8_t * orderedBuffer_
void dumpOriginalBuffer(std::ostream &os) const
FEDTTSBits daqTTSState() const
bool checkNoSlinkCRCError() const
bool checkNoSLinkTransmissionError() const
FEDReadoutMode fedReadoutModeFromString(const std::string &readoutModeString)
FEDBufferState qdrMemoryState() const
static uint8_t readoutOrderForStripInChannel(const uint8_t physicalOrderStripIndexInChannel)
FEDBufferState frameAddressFIFOState() const
FEDBackendStatusRegister(const uint32_t backendStatusRegister)
uint16_t cmMedian(const uint8_t apvIndex) const
FEDDAQTrailer daqTrailer_
bool slinkFullFlag() const
const uint8_t * data() const
static const uint8_t PACKET_CODE_ZERO_SUPPRESSED
uint8_t ttsNibble() const
FEDBackendStatusRegister & setTotalLengthFIFOState(const FEDBufferState state)
bool qdrMemoryEmptyFlag() const
FEDDAQTrailer & setEventLengthIn64BitWords(const uint32_t eventLengthIn64BitWords)
FEDDAQTrailer & setEventStatusNibble(const uint8_t eventStatusNibble)
bool majorityAddressErrorForFEUnit(const uint8_t internalFEUnitNum) const
FEDBackendStatusRegister & setTTCReadyFlag(const bool bitSet)
FEDDAQTrailer & setCRC(const uint16_t crc)
FEDStatusRegister & setL1ABXFIFOBufferState(const FEDBufferState state)
static const uint16_t FEUNITS_PER_FED
FEDBufferState qdrMemoryState() const
void print(std::ostream &os) const
FEDDataType dataType() const
void setQDRMemoryFullFlag(const bool bitSet)
bool feEnabled(const uint8_t internalFEUnitNum) const
FEDBufferState trackerHeaderFIFOState() const
void dump(std::ostream &os) const
void setL1ABXFIFOFullFlag(const bool bitSet)
static const uint8_t BUFFER_FORMAT_CODE_NEW
FEDBufferBase(const uint8_t *fedBuffer, const size_t fedBufferSize, const bool allowUnrecognizedFormat=false)
bool qdrMemoryFullFlag() const
bool internalFreezeFlag() const
FEDHeaderType headerType() const
const uint8_t * originalBuffer_
bool checkAPVEAddressValid() const
void printFlagsForBuffer(const FEDBufferState bufferState, const std::string name, std::ostream &os) const
static const uint8_t APV_MAX_ADDRESS
void setL1ABXFIFOPartialFullFlag(const bool bitSet)
FEDBufferState l1aBxFIFOState() const
bool slinkTransmissionError() const
FEDTTSBits ttsBits() const
static const uint8_t INVALID
const FEDChannel & channel(const uint8_t internalFEDChannelNum) const
FEDDAQEventType fedDAQEventTypeFromString(const std::string &daqEventTypeString)
std::vector< FEDChannel > channels_
FEDBufferState getBufferState(const uint8_t bufferPosition) const
FEDDAQTrailer & setBadSourceIDBit(const bool bitSet)
bool l1aBxFIFOFullFlag() const
bool l1aBxFIFOEmptyFlag() const
static const uint8_t PACKET_CODE_PROC_RAW
static const uint16_t APVS_PER_FED
void printHex(const void *pointer, const size_t length, std::ostream &os)
bool checkBufferFormat() const
static uint8_t physicalOrderForStripInAPV(const uint8_t readoutOrderStripIndexInAPV)
static const uint16_t FEDCH_PER_FEUNIT
Constants and enumerated types for FED/FEC systems.
bool trackerHeaderMonitorDataReadyFlag() const
FEDBackendStatusRegister & setTrackerHeaderMonitorDataReadyFlag(const bool bitSet)
const uint8_t * data() const
TrackerSpecialHeader trackerSpecialHeader() const
size_t bufferSize() const
FEDBackendStatusRegister & setSLinkFullFlag(const bool bitSet)
FEDBufferState feFPGABufferState() const
uint8_t packetCode() const
uint32_t daqLvl1ID() const
void setBufferSate(const uint8_t bufferPosition, const FEDBufferState state)
void init(const uint8_t *fedBuffer, const size_t fedBufferSize, const bool allowUnrecognizedFormat)
FEDBufferState l1aBxFIFOState() const
TrackerSpecialHeader specialHeader_
virtual void print(std::ostream &os) const
char data[epos_bytes_allocation]
bool doTrackerSpecialHeaderChecks() const
static const uint16_t FEDCH_PER_FED
static const uint16_t STRIPS_PER_APV
FEDBufferState totalLengthFIFOState() const
bool checkLengthFromTrailer() const
virtual bool channelGood(const uint8_t internalFEDChannelNum) const
bool slinkFullFlag() const
FEDBackendStatusRegister & setFEEventLengthFIFOState(const FEDBufferState state)
static const uint8_t BUFFER_FORMAT_CODE_OLD
uint8_t eventStatusNibble() const
volatile std::atomic< bool > shutdown_flag false
static const uint16_t SCOPE_MODE_MAX_SCOPE_LENGTH
static uint8_t readoutOrderForStripInAPV(const uint8_t physicalOrderStripIndexInAPV)
uint16_t daqSourceID() const
FEDStatusRegister & setQDRMemoryBufferState(const FEDBufferState state)
FEDBackendStatusRegister & setInternalFreezeFlag(const bool bitSet)
void setL1ABXFIFOEmptyFlag(const bool bitSet)
FEDDAQHeader daqHeader() const
FEDBackendStatusRegister & setBackpressureFlag(const bool bitSet)
bool checkMajorityAddresses() const
static const uint8_t PACKET_CODE_VIRGIN_RAW
bool feOverflow(const uint8_t internalFEUnitNum) const
uint32_t eventLengthInBytes() const
FEDBufferState feEventLengthFIFOState() const
FEDStatusRegister fedStatusRegister() const
void setQDRMemoryPartialFullFlag(const bool bitSet)
FEDBackendStatusRegister & setSLinkDownFlag(const bool bitSet)
FEDBufferFormat bufferFormat() const