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