Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-11 04:36:59

0001 /**\class CSCCorrelatedLCTDigi
0002  *
0003  * Digi for Correlated LCT trigger primitives.
0004  *
0005  *
0006  * \author L.Gray, UF
0007  */
0008 
0009 #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigi.h"
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011 #include <iostream>
0012 
0013 /// Constructors
0014 CSCCorrelatedLCTDigi::CSCCorrelatedLCTDigi(const uint16_t itrknmb,
0015                                            const uint16_t ivalid,
0016                                            const uint16_t iquality,
0017                                            const uint16_t ikeywire,
0018                                            const uint16_t istrip,
0019                                            const uint16_t ipattern,
0020                                            const uint16_t ibend,
0021                                            const uint16_t ibx,
0022                                            const uint16_t impclink,
0023                                            const uint16_t ibx0,
0024                                            const uint16_t isyncErr,
0025                                            const uint16_t icscID,
0026                                            const Version version,
0027                                            const bool run3_quart_strip_bit,
0028                                            const bool run3_eighth_strip_bit,
0029                                            const uint16_t run3_pattern,
0030                                            const uint16_t run3_slope,
0031                                            const int type)
0032     : trknmb(itrknmb),
0033       valid(ivalid),
0034       quality(iquality),
0035       keywire(ikeywire),
0036       strip(istrip),
0037       pattern(ipattern),
0038       bend(ibend),
0039       bx(ibx),
0040       mpclink(impclink),
0041       bx0(ibx0),
0042       syncErr(isyncErr),
0043       cscID(icscID),
0044       hmt(0),
0045       run3_quart_strip_bit_(run3_quart_strip_bit),
0046       run3_eighth_strip_bit_(run3_eighth_strip_bit),
0047       run3_pattern_(run3_pattern),
0048       run3_slope_(run3_slope),
0049       type_(type),
0050       version_(version) {}
0051 
0052 /// Default
0053 CSCCorrelatedLCTDigi::CSCCorrelatedLCTDigi() {
0054   clear();  // set contents to zero
0055 }
0056 
0057 /// Clears this LCT.
0058 void CSCCorrelatedLCTDigi::clear() {
0059   trknmb = 0;
0060   valid = 0;
0061   quality = 0;
0062   keywire = 0;
0063   strip = 0;
0064   pattern = 0;
0065   bend = 0;
0066   bx = 0;
0067   mpclink = 0;
0068   bx0 = 0;
0069   syncErr = 0;
0070   cscID = 0;
0071   hmt = 0;
0072   version_ = Version::Legacy;
0073   // Run-3 variables
0074   run3_quart_strip_bit_ = false;
0075   run3_eighth_strip_bit_ = false;
0076   run3_pattern_ = 0;
0077   run3_slope_ = 0;
0078   // clear the components
0079   type_ = 1;
0080   alct_.clear();
0081   clct_.clear();
0082   gem1_ = GEMPadDigi();
0083   gem2_ = GEMPadDigi();
0084 }
0085 
0086 uint16_t CSCCorrelatedLCTDigi::getStrip(const uint16_t n) const {
0087   // all 10 bits
0088   if (n == 8) {
0089     return 2 * getStrip(4) + getEighthStripBit();
0090   }
0091   // lowest 9 bits
0092   else if (n == 4) {
0093     return 2 * getStrip(2) + getQuartStripBit();
0094   }
0095   // lowest 8 bits
0096   else {
0097     return strip;
0098   }
0099 }
0100 
0101 // slope in number of half-strips/layer
0102 float CSCCorrelatedLCTDigi::getFractionalSlope() const {
0103   if (isRun3()) {
0104     // 4-bit slope
0105     float slope[17] = {
0106         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};
0107     return (2 * getBend() - 1) * slope[getSlope()];
0108   } else {
0109     int slope[11] = {0, 0, -8, 8, -6, 6, -4, 4, -2, 2, 0};
0110     return float(slope[getPattern()] / 5.);
0111   }
0112 }
0113 
0114 /// return the fractional strip
0115 float CSCCorrelatedLCTDigi::getFractionalStrip(const uint16_t n) const {
0116   if (n == 8) {
0117     return 0.125f * (getStrip(n) + 0.5);
0118   } else if (n == 4) {
0119     return 0.25f * (getStrip(n) + 0.5);
0120   } else {
0121     return 0.5f * (getStrip(n) + 0.5);
0122   }
0123 }
0124 
0125 uint16_t CSCCorrelatedLCTDigi::getCLCTPattern() const {
0126   return (isRun3() ? std::numeric_limits<uint16_t>::max() : (pattern & 0xF));
0127 }
0128 
0129 uint16_t CSCCorrelatedLCTDigi::getHMT() const { return (isRun3() ? hmt : std::numeric_limits<uint16_t>::max()); }
0130 
0131 void CSCCorrelatedLCTDigi::setHMT(const uint16_t h) { hmt = isRun3() ? h : std::numeric_limits<uint16_t>::max(); }
0132 
0133 void CSCCorrelatedLCTDigi::setRun3(const bool isRun3) { version_ = isRun3 ? Version::Run3 : Version::Legacy; }
0134 
0135 /// Comparison
0136 bool CSCCorrelatedLCTDigi::operator==(const CSCCorrelatedLCTDigi& rhs) const {
0137   return ((trknmb == rhs.trknmb) && (quality == rhs.quality) && (keywire == rhs.keywire) && (strip == rhs.strip) &&
0138           (pattern == rhs.pattern) && (bend == rhs.bend) && (bx == rhs.bx) && (valid == rhs.valid) &&
0139           (mpclink == rhs.mpclink));
0140 }
0141 
0142 /// Debug
0143 void CSCCorrelatedLCTDigi::print() const {
0144   if (isValid()) {
0145     edm::LogVerbatim("CSCDigi") << "CSC LCT #" << getTrknmb() << ": Valid = " << isValid()
0146                                 << " Quality = " << getQuality() << " Key Wire = " << getKeyWG()
0147                                 << " Strip = " << getStrip() << " Pattern = " << getPattern()
0148                                 << " Bend = " << ((getBend() == 0) ? 'L' : 'R') << " BX = " << getBX()
0149                                 << " MPC Link = " << getMPCLink() << " Type (SIM) = " << getType();
0150   } else {
0151     edm::LogVerbatim("CSCDigi") << "Not a valid correlated LCT.";
0152   }
0153 }
0154 
0155 std::ostream& operator<<(std::ostream& o, const CSCCorrelatedLCTDigi& digi) {
0156   // do not print out CSCID and sync error. They are not used anyway in the firmware, or the emulation
0157   if (digi.isRun3())
0158     return o << "CSC LCT #" << digi.getTrknmb() << ": Valid = " << digi.isValid() << " BX = " << digi.getBX()
0159              << " Run-2 Pattern = " << digi.getPattern() << " Run-3 Pattern = " << digi.getRun3Pattern()
0160              << " Quality = " << digi.getQuality() << " Bend = " << digi.getBend() << " Slope = " << digi.getSlope()
0161              << "\n"
0162              << " KeyHalfStrip = " << digi.getStrip() << " KeyQuartStrip = " << digi.getStrip(4)
0163              << " KeyEighthStrip = " << digi.getStrip(8) << " KeyWireGroup = " << digi.getKeyWG()
0164              << " Type (SIM) = " << digi.getType() << " MPC Link = " << digi.getMPCLink();
0165   else
0166     return o << "CSC LCT #" << digi.getTrknmb() << ": Valid = " << digi.isValid() << " BX = " << digi.getBX()
0167              << " Pattern = " << digi.getPattern() << " Quality = " << digi.getQuality() << " Bend = " << digi.getBend()
0168              << "\n"
0169              << " KeyHalfStrip = " << digi.getStrip() << " KeyWireGroup = " << digi.getKeyWG()
0170              << " Type (SIM) = " << digi.getType() << " MPC Link = " << digi.getMPCLink();
0171 }