File indexing completed on 2024-04-06 12:10:42
0001
0002 #ifndef HcalHTRData_H
0003 #define HcalHTRData_H
0004
0005 #include <cstdint>
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 class HcalHTRData {
0017 public:
0018 static const int CHANNELS_PER_SPIGOT = 24;
0019 static const int MAXIMUM_SAMPLES_PER_CHANNEL = 20;
0020 static const int FORMAT_VERSION_COMPACT_DATA = 6;
0021
0022 HcalHTRData();
0023 ~HcalHTRData() {
0024 if (m_ownData != nullptr)
0025 delete[] m_ownData;
0026 }
0027 HcalHTRData(int version_to_create);
0028 HcalHTRData(const unsigned short* data, int length);
0029 HcalHTRData(const HcalHTRData&);
0030
0031 HcalHTRData& operator=(const HcalHTRData&);
0032 void allocate(int version_to_create = 0);
0033 void adoptData(const unsigned short* data, int length);
0034
0035
0036 inline int getFormatVersion() const { return m_formatVersion; }
0037
0038
0039 inline const unsigned short* getRawData() const { return m_rawConst; }
0040
0041
0042 inline const int getRawLength() const { return m_rawLength; }
0043
0044
0045
0046
0047 bool check() const;
0048
0049 bool isEmptyEvent() const;
0050 bool isOverflowWarning() const;
0051 bool isBusy() const;
0052
0053
0054
0055
0056
0057
0058
0059
0060 void dataPointers(const unsigned short** daq_first,
0061 const unsigned short** daq_last,
0062 const unsigned short** tp_first,
0063 const unsigned short** tp_last) const;
0064
0065
0066
0067
0068
0069
0070
0071
0072 void unpack(unsigned char* daq_lengths,
0073 unsigned short* daq_samples,
0074 unsigned char* tp_lengths,
0075 unsigned short* tp_samples) const;
0076
0077
0078
0079
0080
0081
0082
0083
0084 bool unpackHistogram(int fiber, int fiberchan, int capid, unsigned short* histogram) const;
0085
0086
0087
0088 static bool unpack_per_channel_header(unsigned short, int& flav, int& error_flags, int& capid0, int& channelid);
0089
0090
0091
0092 static bool is_channel_header(unsigned short value) { return (value & 0x8000) != 0; }
0093
0094
0095
0096
0097
0098
0099
0100 void pack(unsigned char* daq_lengths,
0101 unsigned short* daq_samples,
0102 unsigned char* tp_lengths,
0103 unsigned short* tp_samples,
0104 bool do_capid = false);
0105
0106 void packHeaderTrailer(int L1Anumber,
0107 int bcn,
0108 int submodule,
0109 int orbitn,
0110 int pipeline,
0111 int ndd,
0112 int nps,
0113 int firmwareRev = 0,
0114 int firmwareFlav = 0);
0115
0116
0117 void packUnsuppressed(const bool* mp);
0118
0119
0120 inline unsigned int getL1ANumber() const { return (m_rawConst[0] & 0xFF) + (m_rawConst[1] << 8); }
0121
0122 inline unsigned int getBunchNumber() const { return (m_rawConst[4] & 0xFFF); }
0123
0124 unsigned int getOrbitNumber() const;
0125
0126 unsigned int getSubmodule() const;
0127
0128
0129 unsigned int htrSlot() const;
0130
0131
0132 unsigned int htrTopBottom() const;
0133
0134
0135 unsigned int readoutVMECrateId() const;
0136
0137 bool isCalibrationStream() const;
0138
0139 bool isUnsuppressed() const;
0140
0141 bool wasMarkAndPassZS(int fiber, int fiberchan) const;
0142
0143 bool wasMarkAndPassZSTP(int slb, int slbchan) const;
0144
0145 uint32_t zsBunchMask() const;
0146
0147
0148 bool isPatternRAMEvent() const;
0149
0150
0151 bool isHistogramEvent() const;
0152
0153
0154 void getHistogramFibers(int& a, int& b) const;
0155
0156 unsigned int getPipelineLength() const;
0157
0158 unsigned int getFirmwareRevision() const;
0159
0160 int getFirmwareFlavor() const;
0161
0162 inline unsigned int getErrorsWord() const { return m_rawConst[2] & 0xFFFF; }
0163
0164 int getNPrecisionWords() const;
0165
0166 int getNDD() const;
0167
0168
0169 int getNTP() const;
0170
0171 int getNPS() const;
0172
0173
0174 inline unsigned int getDLLunlock() const { return (m_rawConst[5] >> 1) & 0x3; }
0175
0176
0177 inline unsigned int getTTCready() const { return m_rawConst[5] & 0x1; }
0178
0179
0180 inline unsigned int getFibOrbMsgBCN(int fiber) const {
0181 return (m_formatVersion == -1 || fiber < 1 || fiber > 8) ? (0)
0182 : (m_rawConst[m_rawLength - 12 + (fiber - 1)] & 0xFFF);
0183 }
0184
0185
0186 inline unsigned int getFib1OrbMsgBCN() const {
0187 return (m_formatVersion == -1) ? (0) : (m_rawConst[m_rawLength - 12] & 0xFFF);
0188 }
0189 inline unsigned int getFib2OrbMsgBCN() const {
0190 return (m_formatVersion == -1) ? (0) : (m_rawConst[m_rawLength - 11] & 0xFFF);
0191 }
0192
0193 inline unsigned int getFib3OrbMsgBCN() const {
0194 return (m_formatVersion == -1) ? (0) : (m_rawConst[m_rawLength - 10] & 0xFFF);
0195 }
0196
0197 inline unsigned int getFib4OrbMsgBCN() const {
0198 return (m_formatVersion == -1) ? (0) : (m_rawConst[m_rawLength - 9] & 0xFFF);
0199 }
0200
0201 inline unsigned int getFib5OrbMsgBCN() const {
0202 return (m_formatVersion == -1) ? (0) : (m_rawConst[m_rawLength - 8] & 0xFFF);
0203 }
0204
0205 inline unsigned int getFib6OrbMsgBCN() const {
0206 return (m_formatVersion == -1) ? (0) : (m_rawConst[m_rawLength - 7] & 0xFFF);
0207 }
0208
0209 inline unsigned int getFib7OrbMsgBCN() const {
0210 return (m_formatVersion == -1) ? (0) : (m_rawConst[m_rawLength - 6] & 0xFFF);
0211 }
0212
0213 inline unsigned int getFib8OrbMsgBCN() const {
0214 return (m_formatVersion == -1) ? (0) : (m_rawConst[m_rawLength - 5] & 0xFFF);
0215 }
0216
0217
0218 inline unsigned int getExtHdr1() const { return (m_rawConst[0]); }
0219 inline unsigned int getExtHdr2() const { return (m_rawConst[1]); }
0220 inline unsigned int getExtHdr3() const { return (m_rawConst[2]); }
0221 inline unsigned int getExtHdr4() const { return (m_rawConst[3]); }
0222 inline unsigned int getExtHdr5() const { return (m_rawConst[4]); }
0223 inline unsigned int getExtHdr6() const { return (m_rawConst[5]); }
0224 inline unsigned int getExtHdr7() const { return (m_rawConst[6]); }
0225 inline unsigned int getExtHdr8() const { return (m_rawConst[7]); }
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239 bool wasHistogramError(int ifiber) const;
0240
0241 protected:
0242 void determineSectionLengths(int& tpWords, int& daqWords, int& headerWords, int& trailerWords) const;
0243 void determineStaticLengths(int& headerWords, int& trailerWords) const;
0244 int m_formatVersion;
0245 int m_rawLength;
0246 const unsigned short* m_rawConst;
0247 unsigned short* m_ownData;
0248 };
0249
0250 #endif