Go to the documentation of this file.00001
00002 #ifndef CastorCTDCHeader_H
00003 #define CastorCTDCHeader_H
00004
00005 #include <iostream>
00006 class CastorCORData;
00007 class CastorMergerData;
00008
00019 class CastorCTDCHeader {
00020 public:
00021 static const int SPIGOT_COUNT;
00022
00023 CastorCTDCHeader();
00024
00026 unsigned int getTotalLengthBytes() const;
00027
00029
00030 inline bool thereIsASecondCDFHeaderWord() const {return ((commondataformat0>>3) & 0x0001); }
00032 inline short getCDFversionNumber() const {return ((commondataformat0>>4) & 0x0F); }
00034 inline int getSourceId() const { return (commondataformat0>>8)&0xFFF; }
00036 inline int getBunchId() const { return (commondataformat0>>20)&0xFFF; }
00038 inline unsigned long getDCCEventNumber() const { return (commondataformat1 & 0x00FFFFFF); }
00040 inline unsigned short getCDFEventType() const { return ( (commondataformat1>>24) & 0x0F ); }
00042 inline unsigned short BOEshouldBe5Always() const { return ( (commondataformat1>>28) & 0x0F ); }
00043
00045
00046 inline bool thereIsAThirdCDFHeaderWord() const {return ((commondataformat2>>3) & 0x0001); }
00048 inline unsigned int getOrbitNumber() const { return (commondataformat2>>4); }
00050 inline unsigned int getSlink64ReservedBits() const { return ( (commondataformat3>>4)&0x00FFFFFF ); }
00052 inline short BOEshouldBeZeroAlways() const { return ( (commondataformat3>>28) & 0x0F); }
00053
00055 inline short getDCCDataFormatVersion() const { return (ctdch0 & 0xFF); }
00056 inline int getAcceptTimeTTS() const { return ((ctdch0>>8)& 0x0000000F); }
00057 inline int getByte1Zeroes() const { return ((ctdch0>>12)& 0x00000003); }
00058 inline int getHTRStatusBits () const { return ((ctdch0>>14)& 0x00007FFF); }
00059 inline int getByte3Zeroes() const { return ((ctdch0>>29)& 0x00000007); }
00060 inline int getDCCStatus() const {return (ctdch1 & 0x000003FF);}
00061 inline int getByte567Zeroes() const { return (ctdch1 & 0xFF00FC00); }
00062
00064 inline bool getSpigotErrorFlag(int nspigot) const {
00065 return (( ctdch0>>(14+nspigot) )&0x0001); }
00066
00068 inline bool SawTTS_OFW() const { return ((getDCCStatus()>>0) & 0x00000001);}
00069 inline bool SawTTS_BSY() const { return ((getDCCStatus()>>1) & 0x00000001);}
00070 inline bool SawTTS_SYN() const { return ((getDCCStatus()>>2) & 0x00000001);}
00071 inline bool SawL1A_EvN_MxMx() const { return ((getDCCStatus()>>3) & 0x00000001);}
00072 inline bool SawL1A_BcN_MxMx() const { return ((getDCCStatus()>>4) & 0x00000001);}
00073 inline bool SawCT_EvN_MxMx() const { return ((getDCCStatus()>>5) & 0x00000001);}
00074 inline bool SawCT_BcN_MxMx() const { return ((getDCCStatus()>>6) & 0x00000001);}
00075 inline bool SawOrbitLengthErr() const { return ((getDCCStatus()>>7) & 0x00000001);}
00076 inline bool SawTTC_SingErr() const { return ((getDCCStatus()>>8) & 0x00000001);}
00077 inline bool SawTTC_DoubErr() const { return ((getDCCStatus()>>9) & 0x00000001);}
00078
00080 inline int getSpigotSummary(int nspigot) const { return spigotInfo[nspigot]; }
00081
00086 int getSpigotData(int nspigot, CastorCORData& decodeTool, int validSize) const;
00087
00089 inline unsigned int getSpigotDataLength(int nspigot) const { return (nspigot>=3)?(0):(spigotInfo[nspigot]&0x3ff); }
00090
00092 inline bool getSpigotEnabled(unsigned int nspigot) const { return (nspigot>=3)?(false):(spigotInfo[nspigot]&0x8000); }
00094 inline bool getSpigotPresent(unsigned int nspigot) const { return (nspigot>=3)?(false):(spigotInfo[nspigot]&0x4000); }
00096 inline bool getBxMismatchWithDCC(unsigned int nspigot) const { return (nspigot>=3)?(false):(spigotInfo[nspigot]&0x2000); }
00098 inline bool getSpigotValid(unsigned int nspigot) const { return (nspigot>=3)?(false):(spigotInfo[nspigot]&0x1000); }
00100 inline bool getSpigotDataTruncated(unsigned int nspigot) const { return (nspigot>=3)?(false):(spigotInfo[nspigot]&0x0800); }
00102 inline bool getSpigotCRCError(unsigned int nspigot) const { return (nspigot>=3)?(false):(spigotInfo[nspigot]&0x0400); }
00104 inline unsigned char getSpigotErrorBits(unsigned int nspigot) const { return (nspigot>=3)?(0):((unsigned char)(spigotInfo[nspigot]>>24)); }
00106 inline unsigned char getLRBErrorBits(unsigned int nspigot) const { return (nspigot>=3)?(0):((unsigned char)(spigotInfo[nspigot]>>16)); }
00107
00108
00115 void copySpigotData(unsigned int spigot_id, const CastorCORData& data, bool valid=true, unsigned char LRB_error_word=0);
00116
00117 void copyMergerData(const CastorMergerData& data, bool valid) ;
00118
00120 void clear();
00122 void setHeader(int sourceid, int bcn, int l1aN, int orbN);
00123
00124 private:
00125
00126 unsigned int commondataformat0;
00127 unsigned int commondataformat1;
00128 unsigned int commondataformat2;
00129 unsigned int commondataformat3;
00130 unsigned int ctdch0;
00131 unsigned int ctdch1;
00132 unsigned int spigotInfo[4];
00133
00134 };
00135
00136 std::ostream& operator<<(std::ostream&, const CastorCTDCHeader& head);
00137
00138 #endif