CMS 3D CMS Logo

CastorCTDCHeader.h
Go to the documentation of this file.
1 /* -*- C++ -*- */
2 #ifndef CastorCTDCHeader_H
3 #define CastorCTDCHeader_H
4 
5 #include <iostream>
6 class CastorCORData;
7 class CastorMergerData;
8 
18 public:
19  static const int SPIGOT_COUNT;
20 
22 
24  unsigned int getTotalLengthBytes() const;
25 
27 
28  inline bool thereIsASecondCDFHeaderWord() const { return ((commondataformat0 >> 3) & 0x0001); }
30  inline short getCDFversionNumber() const { return ((commondataformat0 >> 4) & 0x0F); }
32  inline int getSourceId() const { return (commondataformat0 >> 8) & 0xFFF; }
34  inline int getBunchId() const { return (commondataformat0 >> 20) & 0xFFF; }
36  inline unsigned long getDCCEventNumber() const { return (commondataformat1 & 0x00FFFFFF); }
38  inline unsigned short getCDFEventType() const { return ((commondataformat1 >> 24) & 0x0F); }
40  inline unsigned short BOEshouldBe5Always() const { return ((commondataformat1 >> 28) & 0x0F); }
41 
43 
44  inline bool thereIsAThirdCDFHeaderWord() const { return ((commondataformat2 >> 3) & 0x0001); }
46  inline unsigned int getOrbitNumber() const { return (commondataformat2 >> 4); }
48  inline unsigned int getSlink64ReservedBits() const { return ((commondataformat3 >> 4) & 0x00FFFFFF); }
50  inline short BOEshouldBeZeroAlways() const { return ((commondataformat3 >> 28) & 0x0F); }
51 
53  inline short getDCCDataFormatVersion() const { return (ctdch0 & 0xFF); }
54  inline int getAcceptTimeTTS() const { return ((ctdch0 >> 8) & 0x0000000F); }
55  inline int getByte1Zeroes() const { return ((ctdch0 >> 12) & 0x00000003); }
56  inline int getHTRStatusBits() const { return ((ctdch0 >> 14) & 0x00007FFF); }
57  inline int getByte3Zeroes() const { return ((ctdch0 >> 29) & 0x00000007); }
58  inline int getDCCStatus() const { return (ctdch1 & 0x000003FF); }
59  inline int getByte567Zeroes() const { return (ctdch1 & 0xFF00FC00); }
60 
62  inline bool getSpigotErrorFlag(int nspigot) const { return ((ctdch0 >> (14 + nspigot)) & 0x0001); }
63 
65  inline bool SawTTS_OFW() const { return ((getDCCStatus() >> 0) & 0x00000001); }
66  inline bool SawTTS_BSY() const { return ((getDCCStatus() >> 1) & 0x00000001); }
67  inline bool SawTTS_SYN() const { return ((getDCCStatus() >> 2) & 0x00000001); }
68  inline bool SawL1A_EvN_MxMx() const { return ((getDCCStatus() >> 3) & 0x00000001); }
69  inline bool SawL1A_BcN_MxMx() const { return ((getDCCStatus() >> 4) & 0x00000001); }
70  inline bool SawCT_EvN_MxMx() const { return ((getDCCStatus() >> 5) & 0x00000001); }
71  inline bool SawCT_BcN_MxMx() const { return ((getDCCStatus() >> 6) & 0x00000001); }
72  inline bool SawOrbitLengthErr() const { return ((getDCCStatus() >> 7) & 0x00000001); }
73  inline bool SawTTC_SingErr() const { return ((getDCCStatus() >> 8) & 0x00000001); }
74  inline bool SawTTC_DoubErr() const { return ((getDCCStatus() >> 9) & 0x00000001); }
75 
77  inline int getSpigotSummary(int nspigot) const { return spigotInfo[nspigot]; }
78 
83  int getSpigotData(int nspigot, CastorCORData& decodeTool, int validSize) const;
84 
86  inline unsigned int getSpigotDataLength(int nspigot) const {
87  return (nspigot >= 3) ? (0) : (spigotInfo[nspigot] & 0x3ff);
88  }
89 
91  inline bool getSpigotEnabled(unsigned int nspigot) const {
92  return (nspigot >= 3) ? (false) : (spigotInfo[nspigot] & 0x8000);
93  }
95  inline bool getSpigotPresent(unsigned int nspigot) const {
96  return (nspigot >= 3) ? (false) : (spigotInfo[nspigot] & 0x4000);
97  }
99  inline bool getBxMismatchWithDCC(unsigned int nspigot) const {
100  return (nspigot >= 3) ? (false) : (spigotInfo[nspigot] & 0x2000);
101  }
103  inline bool getSpigotValid(unsigned int nspigot) const {
104  return (nspigot >= 3) ? (false) : (spigotInfo[nspigot] & 0x1000);
105  }
107  inline bool getSpigotDataTruncated(unsigned int nspigot) const {
108  return (nspigot >= 3) ? (false) : (spigotInfo[nspigot] & 0x0800);
109  }
111  inline bool getSpigotCRCError(unsigned int nspigot) const {
112  return (nspigot >= 3) ? (false) : (spigotInfo[nspigot] & 0x0400);
113  }
115  inline unsigned char getSpigotErrorBits(unsigned int nspigot) const {
116  return (nspigot >= 3) ? (0) : ((unsigned char)(spigotInfo[nspigot] >> 24));
117  }
119  inline unsigned char getLRBErrorBits(unsigned int nspigot) const {
120  return (nspigot >= 3) ? (0) : ((unsigned char)(spigotInfo[nspigot] >> 16));
121  }
122 
123  /* (for packing only) */
130  void copySpigotData(unsigned int spigot_id,
131  const CastorCORData& data,
132  bool valid = true,
133  unsigned char LRB_error_word = 0);
134 
135  void copyMergerData(const CastorMergerData& data, bool valid);
136 
138  void clear();
140  void setHeader(int sourceid, int bcn, int l1aN, int orbN);
141 
142 private:
143  // CURRENTLY VALID FOR LITTLE-ENDIAN (LINUX/x86) ONLY
144  unsigned int commondataformat0;
145  unsigned int commondataformat1;
146  unsigned int commondataformat2;
147  unsigned int commondataformat3;
148  unsigned int ctdch0;
149  unsigned int ctdch1;
150  unsigned int spigotInfo[4]; //The last of these 32bit words should be "end header pattern"
151 };
152 
153 std::ostream& operator<<(std::ostream&, const CastorCTDCHeader& head);
154 
155 #endif
bool SawTTC_SingErr() const
int getSpigotSummary(int nspigot) const
int getHTRStatusBits() const
bool getSpigotEnabled(unsigned int nspigot) const
Read the "ENABLED" bit for this spigot.
bool SawTTC_DoubErr() const
void setHeader(int sourceid, int bcn, int l1aN, int orbN)
bool SawTTS_SYN() const
bool thereIsASecondCDFHeaderWord() const
bool getSpigotDataTruncated(unsigned int nspigot) const
Read the "TRUNCATED" bit for this spigot; LRB truncated data (took too long)
unsigned short getCDFEventType() const
static const int SPIGOT_COUNT
unsigned int getTotalLengthBytes() const
std::ostream & operator<<(std::ostream &, const CastorCTDCHeader &head)
unsigned int commondataformat0
int getSpigotData(int nspigot, CastorCORData &decodeTool, int validSize) const
void copySpigotData(unsigned int spigot_id, const CastorCORData &data, bool valid=true, unsigned char LRB_error_word=0)
Add the given CastorCORData as the given spigot&#39;s data. This should be done in increasing spigot orde...
int getByte3Zeroes() const
unsigned int commondataformat3
unsigned char getSpigotErrorBits(unsigned int nspigot) const
Access the HTR error bits (decoding tbd)
int getAcceptTimeTTS() const
bool SawOrbitLengthErr() const
short BOEshouldBeZeroAlways() const
void copyMergerData(const CastorMergerData &data, bool valid)
unsigned int spigotInfo[4]
unsigned int commondataformat2
unsigned short BOEshouldBe5Always() const
short getCDFversionNumber() const
unsigned int getSpigotDataLength(int nspigot) const
bool SawL1A_BcN_MxMx() const
unsigned int commondataformat1
bool thereIsAThirdCDFHeaderWord() const
bool getSpigotValid(unsigned int nspigot) const
Read the "VALID" bit for this spigot; TTC EvN matched HTR EvN.
unsigned int getOrbitNumber() const
int getDCCStatus() const
bool getBxMismatchWithDCC(unsigned int nspigot) const
Read the "BxID FAILS TO MATCH WITH DCC" bit for this spigot.
unsigned int getSlink64ReservedBits() const
int getByte1Zeroes() const
int getByte567Zeroes() const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
int getBunchId() const
unsigned int ctdch1
bool SawL1A_EvN_MxMx() const
unsigned char getLRBErrorBits(unsigned int nspigot) const
Access the Link Receiver Board error bits (decoding tbd)
short getDCCDataFormatVersion() const
bool SawTTS_OFW() const
bool SawTTS_BSY() const
bool getSpigotErrorFlag(int nspigot) const
unsigned long getDCCEventNumber() const
bool SawCT_EvN_MxMx() const
int getSourceId() const
bool getSpigotCRCError(unsigned int nspigot) const
Read the "CRC-Mismatch" bit for this spigot.
unsigned int ctdch0
bool getSpigotPresent(unsigned int nspigot) const
Read the "PRESENT" bit for this spigot.
bool SawCT_BcN_MxMx() const