File indexing completed on 2024-04-06 12:10:41
0001
0002 #ifndef HcalDCCHeader_H
0003 #define HcalDCCHeader_H
0004
0005 #include <iostream>
0006 #include <cstdint>
0007 #include "DataFormats/HcalDigi/interface/HcalCalibrationEventTypes.h"
0008 class HcalHTRData;
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 class HcalDCCHeader {
0019 public:
0020 static const int SPIGOT_COUNT;
0021
0022 HcalDCCHeader();
0023
0024
0025 unsigned int getTotalLengthBytes() const;
0026
0027
0028
0029 inline bool thereIsASecondCDFHeaderWord() const { return ((commondataformat0 >> 3) & 0x0001); }
0030
0031 inline short getCDFversionNumber() const { return ((commondataformat0 >> 4) & 0x0F); }
0032
0033 inline int getSourceId() const { return (commondataformat0 >> 8) & 0xFFF; }
0034
0035 inline int getBunchId() const { return (commondataformat0 >> 20) & 0xFFF; }
0036
0037 inline unsigned long getDCCEventNumber() const { return (commondataformat1 & 0x00FFFFFF); }
0038
0039 inline unsigned short getCDFEventType() const { return ((commondataformat1 >> 24) & 0x0F); }
0040
0041 inline unsigned short BOEshouldBe5Always() const { return ((commondataformat1 >> 28) & 0x0F); }
0042
0043
0044
0045 inline bool thereIsAThirdCDFHeaderWord() const { return ((commondataformat2 >> 3) & 0x0001); }
0046
0047 inline unsigned int getOrbitNumber() const { return (((commondataformat3 & 0xF) << 28) + (commondataformat2 >> 4)); }
0048
0049 inline unsigned int getSlink64ReservedBits() const { return ((commondataformat3 >> 4) & 0x00FFFFFF); }
0050
0051 inline short BOEshouldBeZeroAlways() const { return ((commondataformat3 >> 28) & 0x0F); }
0052
0053
0054 inline bool isCalibType() const { return (0 != getCalibType()); }
0055 inline HcalCalibrationEventType getCalibType() const {
0056 return HcalCalibrationEventType((commondataformat3 >> 24) & 0x0000000F);
0057 }
0058
0059
0060 inline short getDCCDataFormatVersion() const { return (dcch0 & 0xFF); }
0061 inline int getAcceptTimeTTS() const { return ((dcch0 >> 8) & 0x0000000F); }
0062 inline int getByte1Zeroes() const { return ((dcch0 >> 12) & 0x00000003); }
0063 inline int getHTRStatusBits() const { return ((dcch0 >> 14) & 0x00007FFF); }
0064 inline int getByte3Zeroes() const { return ((dcch0 >> 29) & 0x00000007); }
0065 inline int getDCCStatus() const { return (dcch1 & 0x000003FF); }
0066 inline int getByte567Zeroes() const { return (dcch1 & 0xFF00FC00); }
0067
0068
0069 inline bool getSpigotErrorFlag(int nspigot) const { return ((dcch0 >> (14 + nspigot)) & 0x0001); }
0070
0071
0072 inline bool SawTTS_OFW() const { return ((getDCCStatus() >> 0) & 0x00000001); }
0073 inline bool SawTTS_BSY() const { return ((getDCCStatus() >> 1) & 0x00000001); }
0074 inline bool SawTTS_SYN() const { return ((getDCCStatus() >> 2) & 0x00000001); }
0075 inline bool SawL1A_EvN_MxMx() const { return ((getDCCStatus() >> 3) & 0x00000001); }
0076 inline bool SawL1A_BcN_MxMx() const { return ((getDCCStatus() >> 4) & 0x00000001); }
0077 inline bool SawCT_EvN_MxMx() const { return ((getDCCStatus() >> 5) & 0x00000001); }
0078 inline bool SawCT_BcN_MxMx() const { return ((getDCCStatus() >> 6) & 0x00000001); }
0079 inline bool SawOrbitLengthErr() const { return ((getDCCStatus() >> 7) & 0x00000001); }
0080 inline bool SawTTC_SingErr() const { return ((getDCCStatus() >> 8) & 0x00000001); }
0081 inline bool SawTTC_DoubErr() const { return ((getDCCStatus() >> 9) & 0x00000001); }
0082
0083
0084 inline int getSpigotSummary(int nspigot) const { return spigotInfo[nspigot]; }
0085
0086
0087
0088
0089
0090 int getSpigotData(int nspigot, HcalHTRData& decodeTool, int validSize) const;
0091
0092
0093
0094
0095 void getSpigotData(int nspigot, HcalHTRData& decodeTool) const;
0096
0097
0098 inline unsigned int getSpigotDataLength(int nspigot) const {
0099 return (nspigot >= 15) ? (0) : (spigotInfo[nspigot] & 0x3ff);
0100 }
0101
0102
0103 inline bool getSpigotEnabled(unsigned int nspigot) const {
0104 return (nspigot >= 15) ? (false) : (spigotInfo[nspigot] & 0x8000);
0105 }
0106
0107 inline bool getSpigotPresent(unsigned int nspigot) const {
0108 return (nspigot >= 15) ? (false) : (spigotInfo[nspigot] & 0x4000);
0109 }
0110
0111 inline bool getBxMismatchWithDCC(unsigned int nspigot) const {
0112 return (nspigot >= 15) ? (false) : (spigotInfo[nspigot] & 0x2000);
0113 }
0114
0115 inline bool getSpigotValid(unsigned int nspigot) const {
0116 return (nspigot >= 15) ? (false) : (spigotInfo[nspigot] & 0x1000);
0117 }
0118
0119 inline bool getSpigotDataTruncated(unsigned int nspigot) const {
0120 return (nspigot >= 15) ? (false) : (spigotInfo[nspigot] & 0x0800);
0121 }
0122
0123 inline bool getSpigotCRCError(unsigned int nspigot) const {
0124 return (nspigot >= 15) ? (false) : (spigotInfo[nspigot] & 0x0400);
0125 }
0126
0127 inline unsigned char getSpigotErrorBits(unsigned int nspigot) const {
0128 return (nspigot >= 15) ? (0) : ((unsigned char)(spigotInfo[nspigot] >> 24));
0129 }
0130
0131 inline unsigned char getLRBErrorBits(unsigned int nspigot) const {
0132 return (nspigot >= 15) ? (0) : ((unsigned char)(spigotInfo[nspigot] >> 16));
0133 }
0134
0135
0136
0137
0138
0139
0140
0141
0142 void copySpigotData(unsigned int spigot_id,
0143 const HcalHTRData& data,
0144 bool valid = true,
0145 unsigned char LRB_error_word = 0);
0146
0147
0148 void clear();
0149
0150 void setHeader(int sourceid, int bcn, int l1aN, int orbN);
0151
0152 private:
0153
0154 uint32_t commondataformat0;
0155 uint32_t commondataformat1;
0156 uint32_t commondataformat2;
0157 uint32_t commondataformat3;
0158 uint32_t dcch0;
0159 uint32_t dcch1;
0160 uint32_t spigotInfo[18];
0161 };
0162
0163 std::ostream& operator<<(std::ostream&, const HcalDCCHeader& head);
0164
0165 #endif