File indexing completed on 2024-04-06 12:10:20
0001
0002 #ifndef CastorCTDCHeader_H
0003 #define CastorCTDCHeader_H
0004
0005 #include <iostream>
0006 class CastorCORData;
0007 class CastorMergerData;
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 class CastorCTDCHeader {
0018 public:
0019 static const int SPIGOT_COUNT;
0020
0021 CastorCTDCHeader();
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 (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 short getDCCDataFormatVersion() const { return (ctdch0 & 0xFF); }
0054 inline int getAcceptTimeTTS() const { return ((ctdch0 >> 8) & 0x0000000F); }
0055 inline int getByte1Zeroes() const { return ((ctdch0 >> 12) & 0x00000003); }
0056 inline int getHTRStatusBits() const { return ((ctdch0 >> 14) & 0x00007FFF); }
0057 inline int getByte3Zeroes() const { return ((ctdch0 >> 29) & 0x00000007); }
0058 inline int getDCCStatus() const { return (ctdch1 & 0x000003FF); }
0059 inline int getByte567Zeroes() const { return (ctdch1 & 0xFF00FC00); }
0060
0061
0062 inline bool getSpigotErrorFlag(int nspigot) const { return ((ctdch0 >> (14 + nspigot)) & 0x0001); }
0063
0064
0065 inline bool SawTTS_OFW() const { return ((getDCCStatus() >> 0) & 0x00000001); }
0066 inline bool SawTTS_BSY() const { return ((getDCCStatus() >> 1) & 0x00000001); }
0067 inline bool SawTTS_SYN() const { return ((getDCCStatus() >> 2) & 0x00000001); }
0068 inline bool SawL1A_EvN_MxMx() const { return ((getDCCStatus() >> 3) & 0x00000001); }
0069 inline bool SawL1A_BcN_MxMx() const { return ((getDCCStatus() >> 4) & 0x00000001); }
0070 inline bool SawCT_EvN_MxMx() const { return ((getDCCStatus() >> 5) & 0x00000001); }
0071 inline bool SawCT_BcN_MxMx() const { return ((getDCCStatus() >> 6) & 0x00000001); }
0072 inline bool SawOrbitLengthErr() const { return ((getDCCStatus() >> 7) & 0x00000001); }
0073 inline bool SawTTC_SingErr() const { return ((getDCCStatus() >> 8) & 0x00000001); }
0074 inline bool SawTTC_DoubErr() const { return ((getDCCStatus() >> 9) & 0x00000001); }
0075
0076
0077 inline int getSpigotSummary(int nspigot) const { return spigotInfo[nspigot]; }
0078
0079
0080
0081
0082
0083 int getSpigotData(int nspigot, CastorCORData& decodeTool, int validSize) const;
0084
0085
0086 inline unsigned int getSpigotDataLength(int nspigot) const {
0087 return (nspigot >= 3) ? (0) : (spigotInfo[nspigot] & 0x3ff);
0088 }
0089
0090
0091 inline bool getSpigotEnabled(unsigned int nspigot) const {
0092 return (nspigot >= 3) ? (false) : (spigotInfo[nspigot] & 0x8000);
0093 }
0094
0095 inline bool getSpigotPresent(unsigned int nspigot) const {
0096 return (nspigot >= 3) ? (false) : (spigotInfo[nspigot] & 0x4000);
0097 }
0098
0099 inline bool getBxMismatchWithDCC(unsigned int nspigot) const {
0100 return (nspigot >= 3) ? (false) : (spigotInfo[nspigot] & 0x2000);
0101 }
0102
0103 inline bool getSpigotValid(unsigned int nspigot) const {
0104 return (nspigot >= 3) ? (false) : (spigotInfo[nspigot] & 0x1000);
0105 }
0106
0107 inline bool getSpigotDataTruncated(unsigned int nspigot) const {
0108 return (nspigot >= 3) ? (false) : (spigotInfo[nspigot] & 0x0800);
0109 }
0110
0111 inline bool getSpigotCRCError(unsigned int nspigot) const {
0112 return (nspigot >= 3) ? (false) : (spigotInfo[nspigot] & 0x0400);
0113 }
0114
0115 inline unsigned char getSpigotErrorBits(unsigned int nspigot) const {
0116 return (nspigot >= 3) ? (0) : ((unsigned char)(spigotInfo[nspigot] >> 24));
0117 }
0118
0119 inline unsigned char getLRBErrorBits(unsigned int nspigot) const {
0120 return (nspigot >= 3) ? (0) : ((unsigned char)(spigotInfo[nspigot] >> 16));
0121 }
0122
0123
0124
0125
0126
0127
0128
0129
0130 void copySpigotData(unsigned int spigot_id,
0131 const CastorCORData& data,
0132 bool valid = true,
0133 unsigned char LRB_error_word = 0);
0134
0135 void copyMergerData(const CastorMergerData& data, bool valid);
0136
0137
0138 void clear();
0139
0140 void setHeader(int sourceid, int bcn, int l1aN, int orbN);
0141
0142 private:
0143
0144 unsigned int commondataformat0;
0145 unsigned int commondataformat1;
0146 unsigned int commondataformat2;
0147 unsigned int commondataformat3;
0148 unsigned int ctdch0;
0149 unsigned int ctdch1;
0150 unsigned int spigotInfo[4];
0151 };
0152
0153 std::ostream& operator<<(std::ostream&, const CastorCTDCHeader& head);
0154
0155 #endif