CMS 3D CMS Logo

HcalDCCHeader.h
Go to the documentation of this file.
1 /* -*- C++ -*- */
2 #ifndef HcalDCCHeader_H
3 #define HcalDCCHeader_H
4 
5 #include <iostream>
6 #include <cstdint>
8 class HcalHTRData;
9 
19 public:
20  static const int SPIGOT_COUNT;
21 
22  HcalDCCHeader();
23 
25  unsigned int getTotalLengthBytes() const;
26 
28 
29  inline bool thereIsASecondCDFHeaderWord() const { return ((commondataformat0 >> 3) & 0x0001); }
31  inline short getCDFversionNumber() const { return ((commondataformat0 >> 4) & 0x0F); }
33  inline int getSourceId() const { return (commondataformat0 >> 8) & 0xFFF; }
35  inline int getBunchId() const { return (commondataformat0 >> 20) & 0xFFF; }
37  inline unsigned long getDCCEventNumber() const { return (commondataformat1 & 0x00FFFFFF); }
39  inline unsigned short getCDFEventType() const { return ((commondataformat1 >> 24) & 0x0F); }
41  inline unsigned short BOEshouldBe5Always() const { return ((commondataformat1 >> 28) & 0x0F); }
42 
44 
45  inline bool thereIsAThirdCDFHeaderWord() const { return ((commondataformat2 >> 3) & 0x0001); }
47  inline unsigned int getOrbitNumber() const { return (((commondataformat3 & 0xF) << 28) + (commondataformat2 >> 4)); }
49  inline unsigned int getSlink64ReservedBits() const { return ((commondataformat3 >> 4) & 0x00FFFFFF); }
51  inline short BOEshouldBeZeroAlways() const { return ((commondataformat3 >> 28) & 0x0F); }
52 
54  inline bool isCalibType() const { return (0 != getCalibType()); }
56  return HcalCalibrationEventType((commondataformat3 >> 24) & 0x0000000F);
57  }
58 
60  inline short getDCCDataFormatVersion() const { return (dcch0 & 0xFF); }
61  inline int getAcceptTimeTTS() const { return ((dcch0 >> 8) & 0x0000000F); }
62  inline int getByte1Zeroes() const { return ((dcch0 >> 12) & 0x00000003); }
63  inline int getHTRStatusBits() const { return ((dcch0 >> 14) & 0x00007FFF); }
64  inline int getByte3Zeroes() const { return ((dcch0 >> 29) & 0x00000007); }
65  inline int getDCCStatus() const { return (dcch1 & 0x000003FF); }
66  inline int getByte567Zeroes() const { return (dcch1 & 0xFF00FC00); }
67 
69  inline bool getSpigotErrorFlag(int nspigot) const { return ((dcch0 >> (14 + nspigot)) & 0x0001); }
70 
72  inline bool SawTTS_OFW() const { return ((getDCCStatus() >> 0) & 0x00000001); }
73  inline bool SawTTS_BSY() const { return ((getDCCStatus() >> 1) & 0x00000001); }
74  inline bool SawTTS_SYN() const { return ((getDCCStatus() >> 2) & 0x00000001); }
75  inline bool SawL1A_EvN_MxMx() const { return ((getDCCStatus() >> 3) & 0x00000001); }
76  inline bool SawL1A_BcN_MxMx() const { return ((getDCCStatus() >> 4) & 0x00000001); }
77  inline bool SawCT_EvN_MxMx() const { return ((getDCCStatus() >> 5) & 0x00000001); }
78  inline bool SawCT_BcN_MxMx() const { return ((getDCCStatus() >> 6) & 0x00000001); }
79  inline bool SawOrbitLengthErr() const { return ((getDCCStatus() >> 7) & 0x00000001); }
80  inline bool SawTTC_SingErr() const { return ((getDCCStatus() >> 8) & 0x00000001); }
81  inline bool SawTTC_DoubErr() const { return ((getDCCStatus() >> 9) & 0x00000001); }
82 
84  inline int getSpigotSummary(int nspigot) const { return spigotInfo[nspigot]; }
85 
90  int getSpigotData(int nspigot, HcalHTRData& decodeTool, int validSize) const;
91 
95  void getSpigotData(int nspigot, HcalHTRData& decodeTool) const;
96 
98  inline unsigned int getSpigotDataLength(int nspigot) const {
99  return (nspigot >= 15) ? (0) : (spigotInfo[nspigot] & 0x3ff);
100  }
101 
103  inline bool getSpigotEnabled(unsigned int nspigot) const {
104  return (nspigot >= 15) ? (false) : (spigotInfo[nspigot] & 0x8000);
105  }
107  inline bool getSpigotPresent(unsigned int nspigot) const {
108  return (nspigot >= 15) ? (false) : (spigotInfo[nspigot] & 0x4000);
109  }
111  inline bool getBxMismatchWithDCC(unsigned int nspigot) const {
112  return (nspigot >= 15) ? (false) : (spigotInfo[nspigot] & 0x2000);
113  }
115  inline bool getSpigotValid(unsigned int nspigot) const {
116  return (nspigot >= 15) ? (false) : (spigotInfo[nspigot] & 0x1000);
117  }
119  inline bool getSpigotDataTruncated(unsigned int nspigot) const {
120  return (nspigot >= 15) ? (false) : (spigotInfo[nspigot] & 0x0800);
121  }
123  inline bool getSpigotCRCError(unsigned int nspigot) const {
124  return (nspigot >= 15) ? (false) : (spigotInfo[nspigot] & 0x0400);
125  }
127  inline unsigned char getSpigotErrorBits(unsigned int nspigot) const {
128  return (nspigot >= 15) ? (0) : ((unsigned char)(spigotInfo[nspigot] >> 24));
129  }
131  inline unsigned char getLRBErrorBits(unsigned int nspigot) const {
132  return (nspigot >= 15) ? (0) : ((unsigned char)(spigotInfo[nspigot] >> 16));
133  }
134 
135  /* (for packing only) */
142  void copySpigotData(unsigned int spigot_id,
143  const HcalHTRData& data,
144  bool valid = true,
145  unsigned char LRB_error_word = 0);
146 
148  void clear();
150  void setHeader(int sourceid, int bcn, int l1aN, int orbN);
151 
152 private:
153  // CURRENTLY VALID FOR LITTLE-ENDIAN (LINUX/x86) ONLY
158  uint32_t dcch0;
159  uint32_t dcch1;
160  uint32_t spigotInfo[18]; //The last three of these 32bit words should always be zero!
161 };
162 
163 std::ostream& operator<<(std::ostream&, const HcalDCCHeader& head);
164 
165 #endif
bool getSpigotErrorFlag(int nspigot) const
Definition: HcalDCCHeader.h:69
HcalCalibrationEventType getCalibType() const
Definition: HcalDCCHeader.h:55
int getSpigotData(int nspigot, HcalHTRData &decodeTool, int validSize) const
bool SawTTS_BSY() const
Definition: HcalDCCHeader.h:73
uint32_t spigotInfo[18]
bool thereIsAThirdCDFHeaderWord() const
Definition: HcalDCCHeader.h:45
short getCDFversionNumber() const
Definition: HcalDCCHeader.h:31
std::ostream & operator<<(std::ostream &, const HcalDCCHeader &head)
bool SawTTC_SingErr() const
Definition: HcalDCCHeader.h:80
HcalCalibrationEventType
uint32_t dcch0
bool SawCT_EvN_MxMx() const
Definition: HcalDCCHeader.h:77
int getByte3Zeroes() const
Definition: HcalDCCHeader.h:64
unsigned int getOrbitNumber() const
Definition: HcalDCCHeader.h:47
int getBunchId() const
Definition: HcalDCCHeader.h:35
unsigned short getCDFEventType() const
Definition: HcalDCCHeader.h:39
void copySpigotData(unsigned int spigot_id, const HcalHTRData &data, bool valid=true, unsigned char LRB_error_word=0)
Add the given HcalHTRData as the given spigot&#39;s data. This should be done in increasing spigot order!...
bool thereIsASecondCDFHeaderWord() const
Definition: HcalDCCHeader.h:29
uint32_t commondataformat0
bool SawTTS_OFW() const
Definition: HcalDCCHeader.h:72
bool SawOrbitLengthErr() const
Definition: HcalDCCHeader.h:79
unsigned char getLRBErrorBits(unsigned int nspigot) const
Access the Link Receiver Board error bits (decoding tbd)
int getSourceId() const
Definition: HcalDCCHeader.h:33
bool SawTTC_DoubErr() const
Definition: HcalDCCHeader.h:81
uint32_t commondataformat3
bool SawCT_BcN_MxMx() const
Definition: HcalDCCHeader.h:78
void setHeader(int sourceid, int bcn, int l1aN, int orbN)
unsigned char getSpigotErrorBits(unsigned int nspigot) const
Access the HTR error bits (decoding tbd)
bool isCalibType() const
Definition: HcalDCCHeader.h:54
uint32_t dcch1
bool SawTTS_SYN() const
Definition: HcalDCCHeader.h:74
short getDCCDataFormatVersion() const
Definition: HcalDCCHeader.h:60
unsigned short BOEshouldBe5Always() const
Definition: HcalDCCHeader.h:41
int getSpigotSummary(int nspigot) const
Definition: HcalDCCHeader.h:84
bool getSpigotCRCError(unsigned int nspigot) const
Read the "CRC-Mismatch" bit for this spigot.
int getAcceptTimeTTS() const
Definition: HcalDCCHeader.h:61
unsigned long getDCCEventNumber() const
Definition: HcalDCCHeader.h:37
uint32_t commondataformat2
bool getSpigotValid(unsigned int nspigot) const
Read the "VALID" bit for this spigot; TTC EvN matched HTR EvN.
bool SawL1A_BcN_MxMx() const
Definition: HcalDCCHeader.h:76
static const int SPIGOT_COUNT
Definition: HcalDCCHeader.h:20
uint32_t commondataformat1
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
bool getSpigotPresent(unsigned int nspigot) const
Read the "PRESENT" bit for this spigot.
bool getBxMismatchWithDCC(unsigned int nspigot) const
Read the "BxID FAILS TO MATCH WITH DCC" bit for this spigot.
int getDCCStatus() const
Definition: HcalDCCHeader.h:65
unsigned int getTotalLengthBytes() const
int getByte1Zeroes() const
Definition: HcalDCCHeader.h:62
unsigned int getSlink64ReservedBits() const
Definition: HcalDCCHeader.h:49
int getHTRStatusBits() const
Definition: HcalDCCHeader.h:63
int getByte567Zeroes() const
Definition: HcalDCCHeader.h:66
short BOEshouldBeZeroAlways() const
Definition: HcalDCCHeader.h:51
unsigned int getSpigotDataLength(int nspigot) const
Definition: HcalDCCHeader.h:98
bool SawL1A_EvN_MxMx() const
Definition: HcalDCCHeader.h:75
bool getSpigotEnabled(unsigned int nspigot) const
Read the "ENABLED" bit for this spigot.
bool getSpigotDataTruncated(unsigned int nspigot) const
Read the "TRUNCATED" bit for this spigot; LRB truncated data (took too long)