File indexing completed on 2024-04-06 12:04:27
0001 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctInternHtMiss.h"
0002
0003
0004
0005
0006 L1GctInternHtMiss::L1GctInternHtMiss() : type_(nulltype), capBlock_(0), capIndex_(0), bx_(0), data_(0) {}
0007
0008
0009 L1GctInternHtMiss::~L1GctInternHtMiss() {}
0010
0011
0012 L1GctInternHtMiss L1GctInternHtMiss::unpackerMissHtx(const uint16_t capBlock,
0013 const uint16_t capIndex,
0014 const int16_t bx,
0015 const uint32_t data) {
0016 return L1GctInternHtMiss(miss_htx, capBlock, capIndex, bx, data & kSingleComponentRawMask);
0017 }
0018
0019
0020 L1GctInternHtMiss L1GctInternHtMiss::unpackerMissHty(const uint16_t capBlock,
0021 const uint16_t capIndex,
0022 const int16_t bx,
0023 const uint32_t data) {
0024 return L1GctInternHtMiss(miss_hty, capBlock, capIndex, bx, data & kSingleComponentRawMask);
0025 }
0026
0027
0028 L1GctInternHtMiss L1GctInternHtMiss::unpackerMissHtxHty(const uint16_t capBlock,
0029 const uint16_t capIndex,
0030 const int16_t bx,
0031 const uint32_t data) {
0032 return L1GctInternHtMiss(miss_htx_and_hty, capBlock, capIndex, bx, data & kDoubleComponentRawMask);
0033 }
0034
0035
0036 L1GctInternHtMiss L1GctInternHtMiss::emulatorJetMissHt(const int htx,
0037 const int hty,
0038 const bool overFlow,
0039 const int16_t bx) {
0040 int32_t xdata = (htx & kJetFinderComponentHtMask);
0041 int32_t ydata = (hty & kJetFinderComponentHtMask) << kDoubleComponentHtyShift;
0042 int32_t odata = 0;
0043 if (overFlow || (htx >= kJetFinderComponentHtMask / 2) || (htx < -kJetFinderComponentHtMask / 2) ||
0044 (hty >= kJetFinderComponentHtMask / 2) || (hty < -kJetFinderComponentHtMask / 2))
0045 odata = kDoubleComponentOflowMask;
0046 return L1GctInternHtMiss(jf_miss_htx_and_hty, 0, 0, bx, xdata | ydata | odata);
0047 }
0048
0049
0050 L1GctInternHtMiss L1GctInternHtMiss::emulatorMissHtxHty(const int htx,
0051 const int hty,
0052 const bool overFlow,
0053 const int16_t bx) {
0054 int32_t xdata = (htx & kDoubleComponentHtMask);
0055 int32_t ydata = (hty & kDoubleComponentHtMask) << kDoubleComponentHtyShift;
0056 int32_t odata = 0;
0057 if (overFlow || (htx >= kDoubleComponentHtMask / 2) || (htx < -kDoubleComponentHtMask / 2) ||
0058 (hty >= kDoubleComponentHtMask / 2) || (hty < -kDoubleComponentHtMask / 2))
0059 odata = kDoubleComponentOflowMask;
0060 return L1GctInternHtMiss(miss_htx_and_hty, 0, 0, bx, xdata | ydata | odata);
0061 }
0062
0063
0064 L1GctInternHtMiss L1GctInternHtMiss::emulatorMissHtx(const int htx, const bool overFlow, const int16_t bx) {
0065 int32_t xdata = (htx & kSingleComponentHtMask);
0066 int32_t odata = 0;
0067 if (overFlow || (htx >= kSingleComponentHtMask / 2) || (htx < -kSingleComponentHtMask / 2))
0068 odata = kSingleComponentOflowMask;
0069 return L1GctInternHtMiss(miss_htx, 0, 0, bx, xdata | odata);
0070 }
0071
0072
0073 L1GctInternHtMiss L1GctInternHtMiss::emulatorMissHty(const int hty, const bool overFlow, const int16_t bx) {
0074 int32_t ydata = (hty & kSingleComponentHtMask);
0075 int32_t odata = 0;
0076 if (overFlow || (hty >= kSingleComponentHtMask / 2) || (hty < -kSingleComponentHtMask / 2))
0077 odata = kSingleComponentOflowMask;
0078 return L1GctInternHtMiss(miss_hty, 0, 0, bx, ydata | odata);
0079 }
0080
0081
0082 int16_t L1GctInternHtMiss::htx() const {
0083 if (type() == miss_htx) {
0084 return static_cast<int16_t>(raw() & kSingleComponentHtMask);
0085 }
0086 if (type() == miss_htx_and_hty) {
0087 return convert14BitTwosCompTo16Bit(raw() & kDoubleComponentHtMask);
0088 }
0089 return 0;
0090 }
0091
0092
0093 int16_t L1GctInternHtMiss::hty() const {
0094 if (type() == miss_hty) {
0095 return static_cast<int16_t>(raw() & kSingleComponentHtMask);
0096 }
0097 if (type() == miss_htx_and_hty) {
0098 return convert14BitTwosCompTo16Bit((raw() >> kDoubleComponentHtyShift) & kDoubleComponentHtMask);
0099 }
0100 return 0;
0101 }
0102
0103
0104 bool L1GctInternHtMiss::overflow() const {
0105 if (type() == miss_htx || type() == miss_hty) {
0106 return (raw() & kSingleComponentOflowMask) != 0;
0107 }
0108 if (type() == miss_htx_and_hty) {
0109 return (raw() & kDoubleComponentOflowMask) != 0;
0110 }
0111 return false;
0112 }
0113
0114
0115
0116 L1GctInternHtMiss::L1GctInternHtMiss(const L1GctInternHtMissType type,
0117 const uint16_t capBlock,
0118 const uint16_t capIndex,
0119 const int16_t bx,
0120 const uint32_t data)
0121 : type_(type), capBlock_(capBlock), capIndex_(capIndex), bx_(bx), data_(data) {}
0122
0123 int16_t L1GctInternHtMiss::convert14BitTwosCompTo16Bit(const uint16_t data) const {
0124
0125 if ((data & 0x2000) != 0) {
0126 return static_cast<int16_t>(data | 0xe000);
0127 }
0128
0129
0130 return static_cast<int16_t>(data & 0x1fff);
0131 }
0132
0133
0134
0135 std::ostream& operator<<(std::ostream& os, const L1GctInternHtMiss& rhs) {
0136 os << " L1GctInternHtMiss: htx=";
0137 if (rhs.isThereHtx()) {
0138 os << rhs.htx();
0139 } else {
0140 os << "n/a";
0141 }
0142 os << ", hty=";
0143 if (rhs.isThereHty()) {
0144 os << rhs.hty();
0145 } else {
0146 os << "n/a";
0147 }
0148 if (rhs.overflow()) {
0149 os << "; overflow set";
0150 }
0151 os << "; cap block=0x" << std::hex << rhs.capBlock() << std::dec << ", index=" << rhs.capIndex()
0152 << ", BX=" << rhs.bx();
0153 return os;
0154 }