File indexing completed on 2024-04-06 12:03:59
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "DataFormats/CSCDigi/interface/CSCCLCTDigi.h"
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011 #include <iomanip>
0012 #include <iostream>
0013
0014 enum Pattern_Info { NUM_LAYERS = 6, CLCT_PATTERN_WIDTH = 11 };
0015
0016 namespace {
0017 CSCCLCTDigi::ComparatorContainer makeEmptyContainer() {
0018 CSCCLCTDigi::ComparatorContainer ret;
0019 ret.resize(NUM_LAYERS);
0020 for (auto& p : ret) {
0021 p.resize(CLCT_PATTERN_WIDTH);
0022 }
0023 return ret;
0024 }
0025 }
0026
0027 CSCCLCTDigi::ComparatorContainer const& CSCCLCTDigi::emptyContainer() {
0028 static ComparatorContainer const s_container = makeEmptyContainer();
0029 return s_container;
0030 }
0031
0032
0033 CSCCLCTDigi::CSCCLCTDigi(const uint16_t valid,
0034 const uint16_t quality,
0035 const uint16_t pattern,
0036 const uint16_t striptype,
0037 const uint16_t bend,
0038 const uint16_t strip,
0039 const uint16_t cfeb,
0040 const uint16_t bx,
0041 const uint16_t trknmb,
0042 const uint16_t fullbx,
0043 const int16_t compCode,
0044 const Version version,
0045 const bool run3_quart_strip_bit,
0046 const bool run3_eighth_strip_bit,
0047 const uint16_t run3_pattern,
0048 const uint16_t run3_slope)
0049 : valid_(valid),
0050 quality_(quality),
0051 pattern_(pattern),
0052 striptype_(striptype),
0053 bend_(bend),
0054 strip_(strip),
0055 cfeb_(cfeb),
0056 bx_(bx),
0057 trknmb_(trknmb),
0058 fullbx_(fullbx),
0059 compCode_(compCode),
0060 run3_quart_strip_bit_(run3_quart_strip_bit),
0061 run3_eighth_strip_bit_(run3_eighth_strip_bit),
0062 run3_pattern_(run3_pattern),
0063 run3_slope_(run3_slope),
0064 hits_(),
0065 version_(version) {}
0066
0067
0068 CSCCLCTDigi::CSCCLCTDigi() {
0069 clear();
0070 }
0071
0072
0073 void CSCCLCTDigi::clear() {
0074 valid_ = 0;
0075 quality_ = 0;
0076 pattern_ = 0;
0077 striptype_ = 0;
0078 bend_ = 0;
0079 strip_ = 0;
0080 cfeb_ = 0;
0081 bx_ = 0;
0082 trknmb_ = 0;
0083 fullbx_ = 0;
0084
0085 compCode_ = -1;
0086 run3_quart_strip_bit_ = false;
0087 run3_eighth_strip_bit_ = false;
0088 run3_pattern_ = 0;
0089 run3_slope_ = 0;
0090 version_ = Version::Legacy;
0091 hits_.clear();
0092 }
0093
0094
0095 float CSCCLCTDigi::getFractionalSlope() const {
0096 if (isRun3()) {
0097
0098 float slope[17] = {
0099 0.0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1.0, 1.125, 1.25, 1.375, 1.5, 1.625, 1.75, 2.0, 2.5};
0100 return (2 * getBend() - 1) * slope[getSlope()];
0101 } else {
0102 int slope[11] = {0, 0, -8, 8, -6, 6, -4, 4, -2, 2, 0};
0103 return float(slope[getPattern()] / 5.);
0104 }
0105 }
0106
0107 uint16_t CSCCLCTDigi::getKeyStrip(const uint16_t n) const {
0108
0109 if (compCode_ != -1 and n == 8) {
0110 return getKeyStrip(4) * 2 + getEighthStripBit();
0111 }
0112
0113 else if (compCode_ != -1 and n == 4) {
0114 return getKeyStrip(2) * 2 + getQuartStripBit();
0115 }
0116
0117 else {
0118 return cfeb_ * 32 + getStrip();
0119 }
0120 }
0121
0122
0123 float CSCCLCTDigi::getFractionalStrip(const uint16_t n) const {
0124 if (compCode_ != -1 and n == 8) {
0125 return 0.125f * (getKeyStrip(n) + 0.5);
0126 } else if (compCode_ != -1 and n == 4) {
0127 return 0.25f * (getKeyStrip(n) + 0.5);
0128 } else {
0129 return 0.5f * (getKeyStrip(n) + 0.5);
0130 }
0131 }
0132
0133 void CSCCLCTDigi::setRun3(const bool isRun3) { version_ = isRun3 ? Version::Run3 : Version::Legacy; }
0134
0135 bool CSCCLCTDigi::operator>(const CSCCLCTDigi& rhs) const {
0136
0137
0138
0139 bool returnValue = false;
0140
0141 uint16_t quality1 = getQuality();
0142 uint16_t quality2 = rhs.getQuality();
0143
0144
0145 if (version_ == Version::Run3) {
0146
0147
0148
0149
0150
0151
0152 if ((quality1 > quality2) || (quality1 == quality2 && getPattern() < rhs.getPattern()) ||
0153 (quality1 == quality2 && getPattern() == rhs.getPattern() && getKeyStrip() < rhs.getKeyStrip())) {
0154 returnValue = true;
0155 }
0156 }
0157
0158 else {
0159
0160
0161 uint16_t pattern1 = getPattern() & 14;
0162 uint16_t pattern2 = rhs.getPattern() & 14;
0163
0164
0165
0166
0167
0168
0169
0170 if ((quality1 > quality2) || (quality1 == quality2 && pattern1 > pattern2) ||
0171 (quality1 == quality2 && pattern1 == pattern2 && getKeyStrip() < rhs.getKeyStrip())) {
0172 returnValue = true;
0173 }
0174 }
0175 return returnValue;
0176 }
0177
0178 bool CSCCLCTDigi::operator==(const CSCCLCTDigi& rhs) const {
0179
0180 bool returnValue = false;
0181 if (isValid() == rhs.isValid() && getQuality() == rhs.getQuality() && getPattern() == rhs.getPattern() &&
0182 getKeyStrip() == rhs.getKeyStrip() && getStripType() == rhs.getStripType() && getBend() == rhs.getBend() &&
0183 getBX() == rhs.getBX() && getCompCode() == rhs.getCompCode()) {
0184 returnValue = true;
0185 }
0186 return returnValue;
0187 }
0188
0189 bool CSCCLCTDigi::operator!=(const CSCCLCTDigi& rhs) const {
0190
0191 bool returnValue = true;
0192 if ((*this) == rhs)
0193 returnValue = false;
0194 return returnValue;
0195 }
0196
0197
0198 void CSCCLCTDigi::print() const {
0199 if (isValid()) {
0200 char stripType = (getStripType() == 0) ? 'D' : 'H';
0201 char bend = (getBend() == 0) ? 'L' : 'R';
0202
0203 edm::LogVerbatim("CSCDigi") << " CSC CLCT #" << std::setw(1) << getTrknmb() << ": Valid = " << std::setw(1)
0204 << isValid() << " Key Strip = " << std::setw(3) << getKeyStrip()
0205 << " Strip = " << std::setw(2) << getStrip() << " Quality = " << std::setw(1)
0206 << getQuality() << " Pattern = " << std::setw(1) << getPattern()
0207 << " Bend = " << std::setw(1) << bend << " Strip type = " << std::setw(1) << stripType
0208 << " CFEB ID = " << std::setw(1) << getCFEB() << " BX = " << std::setw(1) << getBX()
0209 << " Full BX= " << std::setw(1) << getFullBX() << " Comp Code= " << std::setw(1)
0210 << getCompCode();
0211 } else {
0212 edm::LogVerbatim("CSCDigi") << "Not a valid Cathode LCT.";
0213 }
0214 }
0215
0216 std::ostream& operator<<(std::ostream& o, const CSCCLCTDigi& digi) {
0217 if (digi.isRun3())
0218 return o << "CSC CLCT #" << digi.getTrknmb() << ": Valid = " << digi.isValid() << " BX = " << digi.getBX()
0219 << " Run-2 Pattern = " << digi.getPattern() << " Run-3 Pattern = " << digi.getRun3Pattern()
0220 << " Quality = " << digi.getQuality() << " Comp Code " << digi.getCompCode()
0221 << " Bend = " << digi.getBend() << "\n"
0222 << " Slope = " << digi.getSlope() << " CFEB = " << digi.getCFEB() << " Strip = " << digi.getStrip()
0223 << " KeyHalfStrip = " << digi.getKeyStrip() << " KeyQuartStrip = " << digi.getKeyStrip(4)
0224 << " KeyEighthStrip = " << digi.getKeyStrip(8);
0225 else
0226 return o << "CSC CLCT #" << digi.getTrknmb() << ": Valid = " << digi.isValid() << " BX = " << digi.getBX()
0227 << " Pattern = " << digi.getPattern() << " Quality = " << digi.getQuality() << " Bend = " << digi.getBend()
0228 << " CFEB = " << digi.getCFEB() << " HalfStrip = " << digi.getStrip()
0229 << " KeyHalfStrip = " << digi.getKeyStrip();
0230 }