diff --git a/DataFormats/CSCDigi/interface/CSCALCTDigi.h b/DataFormats/CSCDigi/interface/CSCALCTDigi.h index 582666e841f52..1a2c12e23e8b9 100644 --- a/DataFormats/CSCDigi/interface/CSCALCTDigi.h +++ b/DataFormats/CSCDigi/interface/CSCALCTDigi.h @@ -11,17 +11,22 @@ #include #include +#include class CSCALCTDigi { public: + enum class Version { Legacy = 0, Run3 }; + /// Constructors - CSCALCTDigi(const int valid, - const int quality, - const int accel, - const int patternb, - const int keywire, - const int bx, - const int trknmb = 0); + CSCALCTDigi(const uint16_t valid, + const uint16_t quality, + const uint16_t accel, + const uint16_t patternb, + const uint16_t keywire, + const uint16_t bx, + const uint16_t trknmb = 0, + const uint16_t hmt = 0, + const Version version = Version::Legacy); /// default CSCALCTDigi(); @@ -32,53 +37,59 @@ class CSCALCTDigi { bool isValid() const { return valid_; } /// set valid - void setValid(const int valid) { valid_ = valid; } + void setValid(const uint16_t valid) { valid_ = valid; } /// return quality of a pattern - int getQuality() const { return quality_; } + uint16_t getQuality() const { return quality_; } /// set quality - void setQuality(const int quality) { quality_ = quality; } + void setQuality(const uint16_t quality) { quality_ = quality; } /// return Accelerator bit /// 1-Accelerator pattern, 0-CollisionA or CollisionB pattern - int getAccelerator() const { return accel_; } + uint16_t getAccelerator() const { return accel_; } /// set accelerator bit - void setAccelerator(const int accelerator) { accel_ = accelerator; } + void setAccelerator(const uint16_t accelerator) { accel_ = accelerator; } /// return Collision Pattern B bit /// 1-CollisionB pattern (accel_ = 0), /// 0-CollisionA pattern (accel_ = 0) - int getCollisionB() const { return patternb_; } + uint16_t getCollisionB() const { return patternb_; } /// set Collision Pattern B bit - void setCollisionB(const int collision) { patternb_ = collision; } + void setCollisionB(const uint16_t collision) { patternb_ = collision; } /// return key wire group - int getKeyWG() const { return keywire_; } + uint16_t getKeyWG() const { return keywire_; } /// set key wire group - void setKeyWG(const int keyWG) { keywire_ = keyWG; } + void setKeyWG(const uint16_t keyWG) { keywire_ = keyWG; } /// return BX - five low bits of BXN counter tagged by the ALCT - int getBX() const { return bx_; } + uint16_t getBX() const { return bx_; } /// set BX - void setBX(const int BX) { bx_ = BX; } + void setBX(const uint16_t BX) { bx_ = BX; } /// return track number (1,2) - int getTrknmb() const { return trknmb_; } + uint16_t getTrknmb() const { return trknmb_; } /// Set track number (1,2) after sorting ALCTs. void setTrknmb(const uint16_t number) { trknmb_ = number; } /// return 12-bit full BX. - int getFullBX() const { return fullbx_; } + uint16_t getFullBX() const { return fullbx_; } /// Set 12-bit full BX. void setFullBX(const uint16_t fullbx) { fullbx_ = fullbx; } + /// return the high multiplicity bits + uint16_t getHMT() const; + + /// set the high multiplicity bits + void setHMT(const uint16_t hmt); + /// True if the first ALCT has a larger quality, or if it has the same /// quality but a larger wire group. bool operator>(const CSCALCTDigi&) const; @@ -93,7 +104,12 @@ class CSCALCTDigi { void print() const; /// set wiregroup number - void setWireGroup(unsigned int wiregroup) { keywire_ = wiregroup; } + void setWireGroup(uint16_t wiregroup) { keywire_ = wiregroup; } + + /// Distinguish Run-1/2 from Run-3 + bool isRun3() const { return version_ == Version::Run3; } + + void setRun3(const bool isRun3); private: uint16_t valid_; @@ -104,6 +120,12 @@ class CSCALCTDigi { uint16_t bx_; uint16_t trknmb_; uint16_t fullbx_; + /// Run-3 introduces high-multiplicity bits for CSCs. + /// Note: In DN-20-016, 3 bits are allocated for HMT in the + /// ALCT board. These bits are copied into the ALCT digi in CMSSW + uint16_t hmt_; + + Version version_; }; std::ostream& operator<<(std::ostream& o, const CSCALCTDigi& digi); diff --git a/DataFormats/CSCDigi/interface/CSCCLCTDigi.h b/DataFormats/CSCDigi/interface/CSCCLCTDigi.h index 17fe645865086..57733e2c900fb 100644 --- a/DataFormats/CSCDigi/interface/CSCCLCTDigi.h +++ b/DataFormats/CSCDigi/interface/CSCCLCTDigi.h @@ -12,6 +12,7 @@ #include #include #include +#include class CSCCLCTDigi { public: @@ -19,19 +20,21 @@ class CSCCLCTDigi { enum CLCTKeyStripMasks { kEightStripMask = 0x1, kQuartStripMask = 0x1, kHalfStripMask = 0x1f }; enum CLCTKeyStripShifts { kEightStripShift = 6, kQuartStripShift = 5, kHalfStripShift = 0 }; + enum class Version { Legacy = 0, Run3 }; /// Constructors - CSCCLCTDigi(const int valid, - const int quality, - const int pattern, - const int striptype, - const int bend, - const int strip, - const int cfeb, - const int bx, - const int trknmb = 0, - const int fullbx = 0, - const int compCode = -1); + CSCCLCTDigi(const uint16_t valid, + const uint16_t quality, + const uint16_t pattern, + const uint16_t striptype, + const uint16_t bend, + const uint16_t strip, + const uint16_t cfeb, + const uint16_t bx, + const uint16_t trknmb = 0, + const uint16_t fullbx = 0, + const int16_t compCode = -1, + const Version version = Version::Legacy); /// default CSCCLCTDigi(); @@ -42,37 +45,37 @@ class CSCCLCTDigi { bool isValid() const { return valid_; } /// set valid - void setValid(const int valid) { valid_ = valid; } + void setValid(const uint16_t valid) { valid_ = valid; } /// return quality of a pattern (number of layers hit!) - int getQuality() const { return quality_; } + uint16_t getQuality() const { return quality_; } /// set quality - void setQuality(const int quality) { quality_ = quality; } + void setQuality(const uint16_t quality) { quality_ = quality; } /// return pattern - int getPattern() const { return pattern_; } + uint16_t getPattern() const { return pattern_; } /// set pattern - void setPattern(const int pattern) { pattern_ = pattern; } + void setPattern(const uint16_t pattern) { pattern_ = pattern; } /// return striptype - int getStripType() const { return striptype_; } + uint16_t getStripType() const { return striptype_; } /// set stripType - void setStripType(const int stripType) { striptype_ = stripType; } + void setStripType(const uint16_t stripType) { striptype_ = stripType; } /// return bend - int getBend() const { return bend_; } + uint16_t getBend() const { return bend_; } /// set bend - void setBend(const int bend) { bend_ = bend; } + void setBend(const uint16_t bend) { bend_ = bend; } /// return halfstrip that goes from 0 to 31 in a (D)CFEB - int getStrip() const; + uint16_t getStrip() const; /// set strip - void setStrip(const int strip) { strip_ = strip; } + void setStrip(const uint16_t strip) { strip_ = strip; } /// set single quart strip bit void setQuartStrip(const bool quartStrip); @@ -87,19 +90,19 @@ class CSCCLCTDigi { bool getEightStrip() const; /// return Key CFEB ID - int getCFEB() const { return cfeb_; } + uint16_t getCFEB() const { return cfeb_; } /// set Key CFEB ID - void setCFEB(const int cfeb) { cfeb_ = cfeb; } + void setCFEB(const uint16_t cfeb) { cfeb_ = cfeb; } /// return BX - int getBX() const { return bx_; } + uint16_t getBX() const { return bx_; } /// set bx - void setBX(const int bx) { bx_ = bx; } + void setBX(const uint16_t bx) { bx_ = bx; } /// return track number (1,2) - int getTrknmb() const { return trknmb_; } + uint16_t getTrknmb() const { return trknmb_; } /// Convert strip_ and cfeb_ to keyStrip. Each CFEB has up to 16 strips /// (32 halfstrips). There are 5 cfebs. The "strip_" variable is one @@ -107,19 +110,19 @@ class CSCCLCTDigi { /// Halfstrip = (cfeb*32 + strip). /// This function can also return the quartstrip or eightstrip /// when the comparator code has been set - int getKeyStrip(int n = 2) const; + uint16_t getKeyStrip(uint16_t n = 2) const; /// Set track number (1,2) after sorting CLCTs. void setTrknmb(const uint16_t number) { trknmb_ = number; } /// return 12-bit full BX. - int getFullBX() const { return fullbx_; } + uint16_t getFullBX() const { return fullbx_; } /// Set 12-bit full BX. void setFullBX(const uint16_t fullbx) { fullbx_ = fullbx; } // 12-bit comparator code - int getCompCode() const { return compCode_; } + int16_t getCompCode() const { return (isRun3() ? compCode_ : -1); } void setCompCode(const int16_t code) { compCode_ = code; } @@ -142,13 +145,27 @@ class CSCCLCTDigi { /// Print content of digi. void print() const; + /// Distinguish Run-1/2 from Run-3 + bool isRun3() const { return version_ == Version::Run3; } + + void setRun3(bool isRun3); + private: uint16_t valid_; uint16_t quality_; + // In Run-3, the 4-bit pattern number is reinterpreted as the + // 4-bit bending value. There will be 16 bending values * 2 (left/right) uint16_t pattern_; uint16_t striptype_; // not used since mid-2008 + // Common definition for left/right bending in Run-1, Run-2 and Run-3. + // 0: right; 1: left uint16_t bend_; + // In Run-3, the strip number receives two additional bits + // strip[4:0] -> 1/2 strip value + // strip[5] -> 1/4 strip bit + // strip[6] -> 1/8 strip bit uint16_t strip_; + // There are up to 7 (D)CFEBs in a chamber uint16_t cfeb_; uint16_t bx_; uint16_t trknmb_; @@ -159,6 +176,8 @@ class CSCCLCTDigi { int16_t compCode_; // which hits are in this CLCT? ComparatorContainer hits_; + + Version version_; }; std::ostream& operator<<(std::ostream& o, const CSCCLCTDigi& digi); diff --git a/DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigi.h b/DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigi.h index 3776a35acd78d..0a9a04a1c45c7 100644 --- a/DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigi.h +++ b/DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigi.h @@ -11,6 +11,7 @@ #include #include +#include #include "DataFormats/CSCDigi/interface/CSCALCTDigi.h" #include "DataFormats/CSCDigi/interface/CSCCLCTDigi.h" #include "DataFormats/GEMDigi/interface/GEMPadDigi.h" @@ -19,39 +20,43 @@ class CSCCorrelatedLCTDigi { public: enum LCTKeyStripMasks { kEightStripMask = 0x1, kQuartStripMask = 0x1, kHalfStripMask = 0xff }; enum LCTKeyStripShifts { kEightStripShift = 9, kQuartStripShift = 8, kHalfStripShift = 0 }; + enum class Version { Legacy = 0, Run3 }; /// Constructors - CSCCorrelatedLCTDigi(const int trknmb, - const int valid, - const int quality, - const int keywire, - const int strip, - const int pattern, - const int bend, - const int bx, - const int mpclink = 0, + CSCCorrelatedLCTDigi(const uint16_t trknmb, + const uint16_t valid, + const uint16_t quality, + const uint16_t keywire, + const uint16_t strip, + const uint16_t pattern, + const uint16_t bend, + const uint16_t bx, + const uint16_t mpclink = 0, const uint16_t bx0 = 0, const uint16_t syncErr = 0, - const uint16_t cscID = 0); - CSCCorrelatedLCTDigi(); /// default + const uint16_t cscID = 0, + const uint16_t hmt = 0, + const Version version = Version::Legacy); + /// default + CSCCorrelatedLCTDigi(); /// clear this LCT void clear(); /// return track number - int getTrknmb() const { return trknmb; } + uint16_t getTrknmb() const { return trknmb; } /// return valid pattern bit bool isValid() const { return valid; } /// return the Quality - int getQuality() const { return quality; } + uint16_t getQuality() const { return quality; } /// return the key wire group. counts from 0. - int getKeyWG() const { return keywire; } + uint16_t getKeyWG() const { return keywire; } /// return the key halfstrip from 0,159 - int getStrip(int n = 2) const; + uint16_t getStrip(uint16_t n = 2) const; /// set single quart strip bit void setQuartStrip(const bool quartStrip); @@ -66,30 +71,38 @@ class CSCCorrelatedLCTDigi { bool getEightStrip() const; /// return the fractional strip. counts from 0.25 - float getFractionalStrip(int n = 2) const; + float getFractionalStrip(uint16_t n = 2) const; - /// return pattern - int getPattern() const { return pattern; } + /// Legacy: return pattern ID + /// Run-3: return the bending angle value + uint16_t getPattern() const { return pattern; } - /// return bend - int getBend() const { return bend; } + /// return left/right bending + uint16_t getBend() const { return bend; } /// return BX - int getBX() const { return bx; } + uint16_t getBX() const { return bx; } /// return CLCT pattern number (in use again Feb 2011) - int getCLCTPattern() const { return (pattern & 0xF); } + /// This function should not be used for Run-3 + uint16_t getCLCTPattern() const; /// return strip type (obsolete since mid-2008) - int getStripType() const { return ((pattern & 0x8) >> 3); } + uint16_t getStripType() const { return ((pattern & 0x8) >> 3); } /// return MPC link number, 0 means not sorted, 1-3 give MPC sorting rank - int getMPCLink() const { return mpclink; } + uint16_t getMPCLink() const { return mpclink; } uint16_t getCSCID() const { return cscID; } uint16_t getBX0() const { return bx0; } uint16_t getSyncErr() const { return syncErr; } + /// Run-3 introduces high-multiplicity bits for CSCs. + /// The allocation is different for ME1/1 and non-ME1/1 + /// chambers. Both LCTs in a chamber are needed for the complete + /// high-multiplicity trigger information + uint16_t getHMT() const; + /// Set track number (1,2) after sorting LCTs. void setTrknmb(const uint16_t number) { trknmb = number; } @@ -104,34 +117,42 @@ class CSCCorrelatedLCTDigi { bool operator!=(const CSCCorrelatedLCTDigi& rhs) const { return !(this->operator==(rhs)); } /// set wiregroup number - void setWireGroup(unsigned int wiregroup) { keywire = wiregroup; } + void setWireGroup(const uint16_t wiregroup) { keywire = wiregroup; } /// set quality code - void setQuality(unsigned int q) { quality = q; } + void setQuality(const uint16_t q) { quality = q; } /// set valid - void setValid(unsigned int v) { valid = v; } + void setValid(const uint16_t v) { valid = v; } /// set strip - void setStrip(unsigned int s) { strip = s; } + void setStrip(const uint16_t s) { strip = s; } /// set pattern - void setPattern(unsigned int p) { pattern = p; } + void setPattern(const uint16_t p) { pattern = p; } /// set bend - void setBend(unsigned int b) { bend = b; } + void setBend(const uint16_t b) { bend = b; } /// set bx - void setBX(unsigned int b) { bx = b; } + void setBX(const uint16_t b) { bx = b; } /// set bx0 - void setBX0(unsigned int b) { bx0 = b; } + void setBX0(const uint16_t b) { bx0 = b; } /// set syncErr - void setSyncErr(unsigned int s) { syncErr = s; } + void setSyncErr(const uint16_t s) { syncErr = s; } /// set cscID - void setCSCID(unsigned int c) { cscID = c; } + void setCSCID(const uint16_t c) { cscID = c; } + + /// set high-multiplicity bits + void setHMT(const uint16_t h); + + /// Distinguish Run-1/2 from Run-3 + bool isRun3() const { return version_ == Version::Run3; } + + void setRun3(const bool isRun3); /// SIMULATION ONLY //// enum Type { @@ -146,6 +167,7 @@ class CSCCorrelatedLCTDigi { }; int getType() const { return type_; } + void setType(int type) { type_ = type; } void setALCT(const CSCALCTDigi& alct) { alct_ = alct; } @@ -158,18 +180,45 @@ class CSCCorrelatedLCTDigi { const GEMPadDigi& getGEM2() const { return gem2_; } private: + // Note: The Run-3 data format is substantially different than the + // Run-1/2 data format. Some explanation is provided below. For + // more information, please check "DN-20-016". + + // Run-1, Run-2 and Run-3 trknmb is either 1 or 2. uint16_t trknmb; + // In Run-3, the valid will be encoded as a quality + // value "000" or "00". uint16_t valid; + // In Run-3, the LCT quality number will be 2 or 3 bits + // For ME1/1 chambers: 3 bits + // For non-ME1/1 chambers: 2 bits uint16_t quality; + // 7-bit key wire uint16_t keywire; + // In Run-3, the strip number receives two additional bits + // strip[7:0] -> 1/2 strip value + // strip[8] -> 1/4 strip bit + // strip[9] -> 1/8 strip bit uint16_t strip; + // In Run-3, the 4-bit pattern number is reinterpreted as the + // 4-bit bending value. There will be 16 bending values * 2 (left/right) uint16_t pattern; + // Common definition for left/right bending in Run-1, Run-2 and Run-3. + // 0: right; 1: left uint16_t bend; uint16_t bx; uint16_t mpclink; uint16_t bx0; + // The synchronization bit is actually not used by MPC or EMTF uint16_t syncErr; + // 4-bit CSC chamber identifier uint16_t cscID; + // In Run-3, LCT data will be carrying the high-multiplicity bits + // for chamber. These bits may indicate the observation of "exotic" events + // Depending on the chamber type 2 or 3 bits will be repurposed + // in the 32-bit LCT data word from the synchronization bit and + // quality bits. + uint16_t hmt; /// SIMULATION ONLY //// int type_; @@ -178,6 +227,8 @@ class CSCCorrelatedLCTDigi { CSCCLCTDigi clct_; GEMPadDigi gem1_; GEMPadDigi gem2_; + + Version version_; }; std::ostream& operator<<(std::ostream& o, const CSCCorrelatedLCTDigi& digi); diff --git a/DataFormats/CSCDigi/src/CSCALCTDigi.cc b/DataFormats/CSCDigi/src/CSCALCTDigi.cc index 8453042e7d909..bbea930ebd28c 100644 --- a/DataFormats/CSCDigi/src/CSCALCTDigi.cc +++ b/DataFormats/CSCDigi/src/CSCALCTDigi.cc @@ -14,25 +14,29 @@ using namespace std; /// Constructors -CSCALCTDigi::CSCALCTDigi(const int valid, - const int quality, - const int accel, - const int patternb, - const int keywire, - const int bx, - const int trknmb) { - valid_ = valid; - quality_ = quality; - accel_ = accel; - patternb_ = patternb; - keywire_ = keywire; - bx_ = bx; - trknmb_ = trknmb; -} +CSCALCTDigi::CSCALCTDigi(const uint16_t valid, + const uint16_t quality, + const uint16_t accel, + const uint16_t patternb, + const uint16_t keywire, + const uint16_t bx, + const uint16_t trknmb, + const uint16_t hmt, + const Version version) + : valid_(valid), + quality_(quality), + accel_(accel), + patternb_(patternb), + keywire_(keywire), + bx_(bx), + trknmb_(trknmb), + hmt_(hmt), + version_(version) {} /// Default CSCALCTDigi::CSCALCTDigi() { clear(); // set contents to zero + version_ = Version::Legacy; } /// Clears this ALCT. @@ -45,8 +49,15 @@ void CSCALCTDigi::clear() { bx_ = 0; trknmb_ = 0; fullbx_ = 0; + hmt_ = 0; } +uint16_t CSCALCTDigi::getHMT() const { return (isRun3() ? hmt_ : std::numeric_limits::max()); } + +void CSCALCTDigi::setHMT(const uint16_t h) { hmt_ = isRun3() ? h : std::numeric_limits::max(); } + +void CSCALCTDigi::setRun3(const bool isRun3) { version_ = isRun3 ? Version::Run3 : Version::Legacy; } + bool CSCALCTDigi::operator>(const CSCALCTDigi& rhs) const { bool returnValue = false; @@ -61,8 +72,8 @@ bool CSCALCTDigi::operator>(const CSCALCTDigi& rhs) const { // The > operator then checks the quality of ALCTs. // If two qualities are equal, the ALCT furthest from the beam axis // (lowest eta, highest wire group number) is selected. - int quality1 = getQuality(); - int quality2 = rhs.getQuality(); + uint16_t quality1 = getQuality(); + uint16_t quality2 = rhs.getQuality(); if (quality1 > quality2) { returnValue = true; } else if (quality1 == quality2 && getKeyWG() > rhs.getKeyWG()) { @@ -75,7 +86,8 @@ bool CSCALCTDigi::operator==(const CSCALCTDigi& rhs) const { // Exact equality. bool returnValue = false; if (isValid() == rhs.isValid() && getQuality() == rhs.getQuality() && getAccelerator() == rhs.getAccelerator() && - getCollisionB() == rhs.getCollisionB() && getKeyWG() == rhs.getKeyWG() && getBX() == rhs.getBX()) { + getCollisionB() == rhs.getCollisionB() && getKeyWG() == rhs.getKeyWG() && getBX() == rhs.getBX() && + getHMT() == rhs.getHMT()) { returnValue = true; } return returnValue; @@ -96,7 +108,8 @@ void CSCALCTDigi::print() const { << " Quality = " << setw(2) << getQuality() << " Accel. = " << setw(1) << getAccelerator() << " PatternB = " << setw(1) << getCollisionB() << " Key wire group = " << setw(3) << getKeyWG() << " BX = " << setw(2) << getBX() - << " Full BX= " << std::setw(1) << getFullBX(); + << " Full BX = " << std::setw(1) << getFullBX() << " HMT = " << std::setw(1) + << getHMT(); } else { edm::LogVerbatim("CSCDigi") << "Not a valid Anode LCT."; } @@ -105,5 +118,5 @@ void CSCALCTDigi::print() const { std::ostream& operator<<(std::ostream& o, const CSCALCTDigi& digi) { return o << "CSC ALCT #" << digi.getTrknmb() << ": Valid = " << digi.isValid() << " Quality = " << digi.getQuality() << " Accel. = " << digi.getAccelerator() << " PatternB = " << digi.getCollisionB() - << " Key wire group = " << digi.getKeyWG() << " BX = " << digi.getBX(); + << " Key wire group = " << digi.getKeyWG() << " BX = " << digi.getBX() << " HMT = " << digi.getHMT(); } diff --git a/DataFormats/CSCDigi/src/CSCCLCTDigi.cc b/DataFormats/CSCDigi/src/CSCCLCTDigi.cc index 5921da0e8e6fb..c0330d799b955 100644 --- a/DataFormats/CSCDigi/src/CSCCLCTDigi.cc +++ b/DataFormats/CSCDigi/src/CSCCLCTDigi.cc @@ -14,17 +14,18 @@ enum Pattern_Info { NUM_LAYERS = 6, CLCT_PATTERN_WIDTH = 11 }; /// Constructors -CSCCLCTDigi::CSCCLCTDigi(const int valid, - const int quality, - const int pattern, - const int striptype, - const int bend, - const int strip, - const int cfeb, - const int bx, - const int trknmb, - const int fullbx, - const int compCode) +CSCCLCTDigi::CSCCLCTDigi(const uint16_t valid, + const uint16_t quality, + const uint16_t pattern, + const uint16_t striptype, + const uint16_t bend, + const uint16_t strip, + const uint16_t cfeb, + const uint16_t bx, + const uint16_t trknmb, + const uint16_t fullbx, + const int16_t compCode, + const Version version) : valid_(valid), quality_(quality), pattern_(pattern), @@ -35,7 +36,8 @@ CSCCLCTDigi::CSCCLCTDigi(const int valid, bx_(bx), trknmb_(trknmb), fullbx_(fullbx), - compCode_(compCode) { + compCode_(compCode), + version_(version) { hits_.resize(NUM_LAYERS); for (auto& p : hits_) { p.resize(CLCT_PATTERN_WIDTH); @@ -54,7 +56,8 @@ CSCCLCTDigi::CSCCLCTDigi() bx_(0), trknmb_(0), fullbx_(0), - compCode_(-1) { + compCode_(-1), + version_(Version::Legacy) { hits_.resize(NUM_LAYERS); for (auto& p : hits_) { p.resize(CLCT_PATTERN_WIDTH); @@ -81,7 +84,7 @@ void CSCCLCTDigi::clear() { } } -int CSCCLCTDigi::getKeyStrip(int n) const { +uint16_t CSCCLCTDigi::getKeyStrip(const uint16_t n) const { // 10-bit case for strip data word if (compCode_ != -1 and n == 8) { return getKeyStrip(4) * 2 + getEightStrip(); @@ -96,7 +99,7 @@ int CSCCLCTDigi::getKeyStrip(int n) const { } } -int CSCCLCTDigi::getStrip() const { return strip_ & kHalfStripMask; } +uint16_t CSCCLCTDigi::getStrip() const { return strip_ & kHalfStripMask; } bool CSCCLCTDigi::getQuartStrip() const { return (strip_ >> kQuartStripShift) & kQuartStripMask; } @@ -118,30 +121,48 @@ void CSCCLCTDigi::setEightStrip(const bool eightStrip) { strip_ |= eightStrip << kEightStripShift; } +void CSCCLCTDigi::setRun3(const bool isRun3) { version_ = isRun3 ? Version::Run3 : Version::Legacy; } + bool CSCCLCTDigi::operator>(const CSCCLCTDigi& rhs) const { // Several versions of CLCT sorting criteria were used before 2008. // They are available in CMSSW versions prior to 3_1_0; here we only keep // the latest one, used in TMB-07 firmware (w/o distrips). bool returnValue = false; - int quality1 = getQuality(); - int quality2 = rhs.getQuality(); - // The bend-direction bit pid[0] is ignored (left and right bends have - // equal quality). - int pattern1 = getPattern() & 14; - int pattern2 = rhs.getPattern() & 14; - - // Better-quality CLCTs are preferred. - // If two qualities are equal, larger pattern id (i.e., straighter pattern) - // is preferred; left- and right-bend patterns are considered to be of - // the same quality. - // If both qualities and pattern id's are the same, lower keystrip - // is preferred. - if ((quality1 > quality2) || (quality1 == quality2 && pattern1 > pattern2) || - (quality1 == quality2 && pattern1 == pattern2 && getKeyStrip() < rhs.getKeyStrip())) { - returnValue = true; + uint16_t quality1 = getQuality(); + uint16_t quality2 = rhs.getQuality(); + + // Run-3 case + if (version_ == Version::Run3) { + // Better-quality CLCTs are preferred. + // If two qualities are equal, smaller bending is preferred; + // left- and right-bend patterns are considered to be of + // the same quality. This corresponds to "pattern" being smaller!!! + // If both qualities and pattern id's are the same, lower keystrip + // is preferred. + if ((quality1 > quality2) || (quality1 == quality2 && getPattern() < rhs.getPattern()) || + (quality1 == quality2 && getPattern() == rhs.getPattern() && getKeyStrip() < rhs.getKeyStrip())) { + returnValue = true; + } + } + // Legacy case: + else { + // The bend-direction bit pid[0] is ignored (left and right bends have + // equal quality). + uint16_t pattern1 = getPattern() & 14; + uint16_t pattern2 = rhs.getPattern() & 14; + + // Better-quality CLCTs are preferred. + // If two qualities are equal, larger pattern id (i.e., straighter pattern) + // is preferred; left- and right-bend patterns are considered to be of + // the same quality. + // If both qualities and pattern id's are the same, lower keystrip + // is preferred. + if ((quality1 > quality2) || (quality1 == quality2 && pattern1 > pattern2) || + (quality1 == quality2 && pattern1 == pattern2 && getKeyStrip() < rhs.getKeyStrip())) { + returnValue = true; + } } - return returnValue; } diff --git a/DataFormats/CSCDigi/src/CSCCorrelatedLCTDigi.cc b/DataFormats/CSCDigi/src/CSCCorrelatedLCTDigi.cc index af26d5fcdc1bd..bd0b2afddadc8 100644 --- a/DataFormats/CSCDigi/src/CSCCorrelatedLCTDigi.cc +++ b/DataFormats/CSCDigi/src/CSCCorrelatedLCTDigi.cc @@ -11,18 +11,20 @@ #include /// Constructors -CSCCorrelatedLCTDigi::CSCCorrelatedLCTDigi(const int itrknmb, - const int ivalid, - const int iquality, - const int ikeywire, - const int istrip, - const int ipattern, - const int ibend, - const int ibx, - const int impclink, +CSCCorrelatedLCTDigi::CSCCorrelatedLCTDigi(const uint16_t itrknmb, + const uint16_t ivalid, + const uint16_t iquality, + const uint16_t ikeywire, + const uint16_t istrip, + const uint16_t ipattern, + const uint16_t ibend, + const uint16_t ibx, + const uint16_t impclink, const uint16_t ibx0, const uint16_t isyncErr, - const uint16_t icscID) + const uint16_t icscID, + const uint16_t ihmt, + const Version version) : trknmb(itrknmb), valid(ivalid), quality(iquality), @@ -34,11 +36,14 @@ CSCCorrelatedLCTDigi::CSCCorrelatedLCTDigi(const int itrknmb, mpclink(impclink), bx0(ibx0), syncErr(isyncErr), - cscID(icscID) {} + cscID(icscID), + hmt(ihmt), + version_(version) {} /// Default CSCCorrelatedLCTDigi::CSCCorrelatedLCTDigi() { clear(); // set contents to zero + version_ = Version::Legacy; } /// Clears this LCT. @@ -55,9 +60,10 @@ void CSCCorrelatedLCTDigi::clear() { bx0 = 0; syncErr = 0; cscID = 0; + hmt = 0; } -int CSCCorrelatedLCTDigi::getStrip(int n) const { +uint16_t CSCCorrelatedLCTDigi::getStrip(const uint16_t n) const { // all 10 bits if (n == 8) { return 2 * getStrip(4) + getEightStrip(); @@ -93,7 +99,7 @@ bool CSCCorrelatedLCTDigi::getQuartStrip() const { return (strip >> kQuartStripS bool CSCCorrelatedLCTDigi::getEightStrip() const { return (strip >> kEightStripShift) & kEightStripMask; } /// return the fractional strip -float CSCCorrelatedLCTDigi::getFractionalStrip(int n) const { +float CSCCorrelatedLCTDigi::getFractionalStrip(const uint16_t n) const { if (n == 8) { return 0.125f * (getStrip() + 1) - 0.0625f; } else if (n == 4) { @@ -103,11 +109,21 @@ float CSCCorrelatedLCTDigi::getFractionalStrip(int n) const { } } +uint16_t CSCCorrelatedLCTDigi::getCLCTPattern() const { + return (isRun3() ? std::numeric_limits::max() : (pattern & 0xF)); +} + +uint16_t CSCCorrelatedLCTDigi::getHMT() const { return (isRun3() ? hmt : std::numeric_limits::max()); } + +void CSCCorrelatedLCTDigi::setHMT(const uint16_t h) { hmt = isRun3() ? h : std::numeric_limits::max(); } + +void CSCCorrelatedLCTDigi::setRun3(const bool isRun3) { version_ = isRun3 ? Version::Run3 : Version::Legacy; } + /// Comparison bool CSCCorrelatedLCTDigi::operator==(const CSCCorrelatedLCTDigi& rhs) const { return ((trknmb == rhs.trknmb) && (quality == rhs.quality) && (keywire == rhs.keywire) && (strip == rhs.strip) && (pattern == rhs.pattern) && (bend == rhs.bend) && (bx == rhs.bx) && (valid == rhs.valid) && - (mpclink == rhs.mpclink)); + (mpclink == rhs.mpclink) && (hmt == rhs.hmt)); } /// Debug @@ -117,7 +133,7 @@ void CSCCorrelatedLCTDigi::print() const { << " Quality = " << getQuality() << " Key Wire = " << getKeyWG() << " Strip = " << getStrip() << " Pattern = " << getPattern() << " Bend = " << ((getBend() == 0) ? 'L' : 'R') << " BX = " << getBX() - << " MPC Link = " << getMPCLink(); + << " MPC Link = " << getMPCLink() << " HMT Bit = " << getHMT(); } else { edm::LogVerbatim("CSCDigi") << "Not a valid correlated LCT."; } @@ -129,5 +145,5 @@ std::ostream& operator<<(std::ostream& o, const CSCCorrelatedLCTDigi& digi) { << " cathode info: Strip = " << digi.getStrip() << " Pattern = " << digi.getPattern() << " Bend = " << ((digi.getBend() == 0) ? 'L' : 'R') << "\n" << " anode info: Key wire = " << digi.getKeyWG() << " BX = " << digi.getBX() << " bx0 = " << digi.getBX0() - << " syncErr = " << digi.getSyncErr() << "\n"; + << " syncErr = " << digi.getSyncErr() << " HMT Bit = " << digi.getHMT() << "\n"; } diff --git a/DataFormats/CSCDigi/src/classes_def.xml b/DataFormats/CSCDigi/src/classes_def.xml index 702346151aeba..e0817b8f2b6db 100644 --- a/DataFormats/CSCDigi/src/classes_def.xml +++ b/DataFormats/CSCDigi/src/classes_def.xml @@ -11,24 +11,27 @@ - + + - + - - + + + - - + + + diff --git a/DataFormats/L1CSCTrackFinder/src/classes_def.xml b/DataFormats/L1CSCTrackFinder/src/classes_def.xml index 85152d4bac697..969b0f82291b7 100644 --- a/DataFormats/L1CSCTrackFinder/src/classes_def.xml +++ b/DataFormats/L1CSCTrackFinder/src/classes_def.xml @@ -13,7 +13,8 @@ - + + diff --git a/EventFilter/CSCRawToDigi/src/CSCDigiToRaw.cc b/EventFilter/CSCRawToDigi/src/CSCDigiToRaw.cc index 8f6fd49bea064..987a7fb9e5399 100644 --- a/EventFilter/CSCRawToDigi/src/CSCDigiToRaw.cc +++ b/EventFilter/CSCRawToDigi/src/CSCDigiToRaw.cc @@ -270,7 +270,7 @@ void CSCDigiToRaw::add(const CSCCLCTDigiCollection& clctDigis, FindEventDataInfo if (me11a && fedInfo.formatVersion_ == 2013) { std::vector shiftedDigis((*j).second.first, (*j).second.second); for (std::vector::iterator iC = shiftedDigis.begin(); iC != shiftedDigis.end(); ++iC) { - if (iC->getCFEB() >= 0 && iC->getCFEB() < 3) { //sanity check, mostly + if (iC->getCFEB() < 3) { //sanity check, mostly (*iC) = CSCCLCTDigi(iC->isValid(), iC->getQuality(), iC->getPattern(), @@ -302,7 +302,7 @@ void CSCDigiToRaw::add(const CSCCorrelatedLCTDigiCollection& corrLCTDigis, FindE if (me11a && fedInfo.formatVersion_ == 2013) { std::vector shiftedDigis((*j).second.first, (*j).second.second); for (std::vector::iterator iC = shiftedDigis.begin(); iC != shiftedDigis.end(); ++iC) { - if (iC->getStrip() >= 0 && iC->getStrip() < 96) { //sanity check, mostly + if (iC->getStrip() < 96) { //sanity check, mostly (*iC) = CSCCorrelatedLCTDigi(iC->getTrknmb(), iC->isValid(), iC->getQuality(),