File indexing completed on 2024-04-06 12:10:44
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef EventFilter_HGCalRawToDigi_HGCalUnpacker_h
0012 #define EventFilter_HGCalRawToDigi_HGCalUnpacker_h
0013
0014 #include "DataFormats/HGCalDigi/interface/HGCROCChannelDataFrame.h"
0015 #include "DataFormats/HGCalDigi/interface/HGCalElectronicsId.h"
0016
0017 #include <cstdint>
0018 #include <functional>
0019 #include <vector>
0020
0021 struct HGCalUnpackerConfig {
0022 uint32_t sLinkBOE{0x0};
0023 uint32_t captureBlockReserved{0x3f};
0024 uint32_t econdHeaderMarker{0x154};
0025 uint32_t sLinkCaptureBlockMax{10};
0026 uint32_t captureBlockECONDMax{12};
0027 uint32_t econdERXMax{12};
0028 uint32_t erxChannelMax{37};
0029 uint32_t payloadLengthMax{469};
0030 uint32_t channelMax{7000000};
0031 uint32_t commonModeMax{4000000};
0032 };
0033
0034
0035 template <class D>
0036 class HGCalUnpacker {
0037 public:
0038 enum SLinkHeaderShift {
0039 kSLinkBOEShift = 24,
0040 };
0041 enum SLinkHeaderMask {
0042 kSLinkBOEMask = 0b11111111,
0043 };
0044 enum CaptureBlockHeaderShift {
0045 kCaptureBlockReservedShift = 26,
0046 };
0047 enum CaptureBlockMask {
0048 kCaptureBlockReservedMask = 0b111111,
0049 kCaptureBlockECONDStatusMask = 0b111,
0050 };
0051 enum ECONDHeaderShift {
0052 kHeaderShift = 23,
0053 kPayloadLengthShift = 14,
0054 kPassThroughShift = 13,
0055 kHTShift = 10,
0056 kEBOShift = 8,
0057 kMatchShift = 7,
0058 kTruncatedShift = 6,
0059 };
0060 enum ECONDHeaderMask {
0061 kHeaderMask = 0b111111111,
0062 kPayloadLengthMask = 0b111111111,
0063 kPassThroughMask = 0b1,
0064 kHTMask = 0b11,
0065 kEBOMask = 0b11,
0066 kMatchMask = 0b1,
0067 kTruncatedMask = 0b1,
0068 };
0069 enum ERXHeaderShift {
0070 kFormatShift = 25,
0071 kCommonmode0Shift = 15,
0072 kCommonmode1Shift = 5,
0073 };
0074 enum ERXHeaderMask {
0075 kFormatMask = 0b1,
0076 kCommonmode0Mask = 0b1111111111,
0077 kCommonmode1Mask = 0b1111111111,
0078 };
0079
0080 explicit HGCalUnpacker(HGCalUnpackerConfig config);
0081
0082
0083
0084
0085
0086 void parseSLink(const std::vector<uint32_t>& inputArray,
0087 const std::function<uint16_t(uint16_t sLink, uint8_t captureBlock, uint8_t econd)>& enabledERXMapping,
0088 const std::function<D(HGCalElectronicsId elecID)>& logicalMapping);
0089
0090
0091
0092
0093 void parseCaptureBlock(
0094 const std::vector<uint32_t>& inputArray,
0095 const std::function<uint16_t(uint16_t sLink, uint8_t captureBlock, uint8_t econd)>& enabledERXMapping,
0096 const std::function<D(HGCalElectronicsId elecID)>& logicalMapping);
0097
0098
0099
0100
0101 void parseECOND(const std::vector<uint32_t>& inputArray,
0102 const std::function<uint16_t(uint16_t sLink, uint8_t captureBlock, uint8_t econd)>& enabledERXMapping,
0103 const std::function<D(HGCalElectronicsId elecID)>& logicalMapping);
0104
0105
0106 const std::vector<HGCROCChannelDataFrame<D> >& channelData() const { return channelData_; }
0107
0108 const std::vector<uint32_t>& commonModeIndex() const { return commonModeIndex_; }
0109
0110 const std::vector<uint16_t>& commonModeData() const { return commonModeData_; }
0111 const std::vector<uint32_t>& badECOND() const { return badECOND_; }
0112
0113 private:
0114 const uint32_t erxBodyLeftShift_[16] = {2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
0115 const uint32_t erxBodyRightShift_[16] = {0, 8, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
0116 const uint32_t erxBodyMask_[16] = {0b00111111111111111111110000000000,
0117 0b00000000000011111111110000000000,
0118 0b00111111111111111111110000000000,
0119 0b00000000000011111111111111111111,
0120 0b00111111111111111111111111111111,
0121 0b00111111111111111111111111111111,
0122 0b00111111111111111111111111111111,
0123 0b00111111111111111111111111111111,
0124 0b11111111111111111111111111111111,
0125 0b11111111111111111111111111111111,
0126 0b11111111111111111111111111111111,
0127 0b11111111111111111111111111111111,
0128 0b11111111111111111111111111111111,
0129 0b11111111111111111111111111111111,
0130 0b11111111111111111111111111111111,
0131 0b11111111111111111111111111111111};
0132 const uint32_t erxBodyBits_[16] = {24, 16, 24, 24, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32};
0133 HGCalUnpackerConfig config_;
0134 size_t channelDataSize_{0};
0135 size_t commonModeDataSize_{0};
0136 std::vector<HGCROCChannelDataFrame<D> > channelData_;
0137 std::vector<uint32_t> commonModeIndex_;
0138 std::vector<uint16_t> commonModeData_;
0139 std::vector<uint32_t> badECOND_;
0140 };
0141
0142 #endif