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