Skip to content

Commit

Permalink
Merge pull request #31086 from dildick/from-CMSSW_11_2_X_2020-08-06-1…
Browse files Browse the repository at this point in the history
…100-CCLUT-quality-control

CCLUT quality control and preliminary quality definition for GEM-CSC stubs (CCLUT-6)
  • Loading branch information
cmsbuild committed Aug 26, 2020
2 parents 1afb3dd + f570d2f commit 4c90098
Show file tree
Hide file tree
Showing 29 changed files with 1,132 additions and 710 deletions.
42 changes: 38 additions & 4 deletions DataFormats/CSCDigi/interface/CSCCLCTDigi.h
Expand Up @@ -20,6 +20,9 @@ class CSCCLCTDigi {

enum CLCTKeyStripMasks { kEightStripMask = 0x1, kQuartStripMask = 0x1, kHalfStripMask = 0x1f };
enum CLCTKeyStripShifts { kEightStripShift = 6, kQuartStripShift = 5, kHalfStripShift = 0 };
// temporary to facilitate CCLUT-EMTF/OMTF integration studies
enum CLCTPatternMasks { kRun3SlopeMask = 0xf, kRun3PatternMask = 0x7, kLegacyPatternMask = 0xf };
enum CLCTPatternShifts { kRun3SlopeShift = 7, kRun3PatternShift = 4, kLegacyPatternShift = 0 };
enum class Version { Legacy = 0, Run3 };

/// Constructors
Expand Down Expand Up @@ -54,18 +57,30 @@ class CSCCLCTDigi {
void setQuality(const uint16_t quality) { quality_ = quality; }

/// return pattern
uint16_t getPattern() const { return pattern_; }
uint16_t getPattern() const;

/// set pattern
void setPattern(const uint16_t pattern) { pattern_ = pattern; }
void setPattern(const uint16_t pattern);

/// return pattern
uint16_t getRun3Pattern() const;

/// set pattern
void setRun3Pattern(const uint16_t pattern);

/// return the slope
uint16_t getSlope() const;

/// set the slope
void setSlope(const uint16_t slope);

/// return striptype
uint16_t getStripType() const { return striptype_; }

/// set stripType
void setStripType(const uint16_t stripType) { striptype_ = stripType; }

/// return bend
/// return bend (left or right)
uint16_t getBend() const { return bend_; }

/// set bend
Expand Down Expand Up @@ -112,7 +127,23 @@ class CSCCLCTDigi {
/// when the comparator code has been set
uint16_t getKeyStrip(const uint16_t n = 2) const;

/// return the fractional strip
/*
Strips are numbered starting from 1 in CMSSW
Half-strips, quarter-strips and eighth-strips are numbered starting from 0
The table below shows the correct numbering
---------------------------------------------------------------------------------
strip | 1 | 2 |
---------------------------------------------------------------------------------
1/2-strip | 0 | 1 | 2 | 3 |
---------------------------------------------------------------------------------
1/4-strip | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
---------------------------------------------------------------------------------
1/8-strip | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
---------------------------------------------------------------------------------
Note: the CSC geometry also has a strip offset of +/- 0.25 strips. When comparing the
CLCT/LCT position with the true muon position, take the offset into account!
*/
float getFractionalStrip(const uint16_t n = 2) const;

/// Set track number (1,2) after sorting CLCTs.
Expand Down Expand Up @@ -154,6 +185,9 @@ class CSCCLCTDigi {
void setRun3(bool isRun3);

private:
void setDataWord(const uint16_t newWord, uint16_t& word, const unsigned shift, const unsigned mask);
uint16_t getDataWord(const uint16_t word, const unsigned shift, const unsigned mask) const;

uint16_t valid_;
uint16_t quality_;
// In Run-3, the 4-bit pattern number is reinterpreted as the
Expand Down
40 changes: 37 additions & 3 deletions DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigi.h
Expand Up @@ -20,6 +20,9 @@ class CSCCorrelatedLCTDigi {
public:
enum LCTKeyStripMasks { kEightStripMask = 0x1, kQuartStripMask = 0x1, kHalfStripMask = 0xff };
enum LCTKeyStripShifts { kEightStripShift = 9, kQuartStripShift = 8, kHalfStripShift = 0 };
// temporary to facilitate CCLUT-EMTF/OMTF integration studies
enum LCTPatternMasks { kRun3SlopeMask = 0xf, kRun3PatternMask = 0x7, kLegacyPatternMask = 0xf };
enum LCTPatternShifts { kRun3SlopeShift = 7, kRun3PatternShift = 4, kLegacyPatternShift = 0 };
enum class Version { Legacy = 0, Run3 };

/// Constructors
Expand Down Expand Up @@ -70,12 +73,34 @@ class CSCCorrelatedLCTDigi {
/// get single eight strip bit
bool getEightStrip() const;

/// return the fractional strip. counts from 0.25
/*
Strips are numbered starting from 1 in CMSSW
Half-strips, quarter-strips and eighth-strips are numbered starting from 0
The table below shows the correct numbering
---------------------------------------------------------------------------------
strip | 1 | 2 |
---------------------------------------------------------------------------------
1/2-strip | 0 | 1 | 2 | 3 |
---------------------------------------------------------------------------------
1/4-strip | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
---------------------------------------------------------------------------------
1/8-strip | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
---------------------------------------------------------------------------------
Note: the CSC geometry also has a strip offset of +/- 0.25 strips. When comparing the
CLCT/LCT position with the true muon position, take the offset into account!
*/
float getFractionalStrip(uint16_t n = 2) const;

/// Legacy: return pattern ID
/// Run-3: return the bending angle value
uint16_t getPattern() const { return pattern; }
uint16_t getPattern() const;

/// return pattern
uint16_t getRun3Pattern() const;

/// return the slope
uint16_t getSlope() const;

/// return left/right bending
uint16_t getBend() const { return bend; }
Expand Down Expand Up @@ -129,7 +154,13 @@ class CSCCorrelatedLCTDigi {
void setStrip(const uint16_t s) { strip = s; }

/// set pattern
void setPattern(const uint16_t p) { pattern = p; }
void setPattern(const uint16_t p);

/// set pattern
void setRun3Pattern(const uint16_t pattern);

/// set the slope
void setSlope(const uint16_t slope);

/// set bend
void setBend(const uint16_t b) { bend = b; }
Expand Down Expand Up @@ -180,6 +211,9 @@ class CSCCorrelatedLCTDigi {
const GEMPadDigi& getGEM2() const { return gem2_; }

private:
void setDataWord(const uint16_t newWord, uint16_t& word, const unsigned shift, const unsigned mask);
uint16_t getDataWord(const uint16_t word, const unsigned shift, const unsigned mask) const;

// 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".
Expand Down
81 changes: 64 additions & 17 deletions DataFormats/CSCDigi/src/CSCCLCTDigi.cc
Expand Up @@ -82,6 +82,37 @@ void CSCCLCTDigi::clear() {
for (auto& p : hits_) {
p.resize(CLCT_PATTERN_WIDTH);
}
setSlope(0);
}

uint16_t CSCCLCTDigi::getPattern() const { return getDataWord(pattern_, kLegacyPatternShift, kLegacyPatternMask); }

void CSCCLCTDigi::setPattern(const uint16_t pattern) {
setDataWord(pattern, pattern_, kLegacyPatternShift, kLegacyPatternMask);
}

uint16_t CSCCLCTDigi::getRun3Pattern() const {
if (!isRun3())
return 0;
return getDataWord(pattern_, kRun3PatternShift, kRun3PatternMask);
}

void CSCCLCTDigi::setRun3Pattern(const uint16_t pattern) {
if (!isRun3())
return;
setDataWord(pattern, pattern_, kRun3PatternShift, kRun3PatternMask);
}

uint16_t CSCCLCTDigi::getSlope() const {
if (!isRun3())
return 0;
return getDataWord(pattern_, kRun3SlopeShift, kRun3SlopeMask);
}

void CSCCLCTDigi::setSlope(const uint16_t slope) {
if (!isRun3())
return;
setDataWord(slope, pattern_, kRun3SlopeShift, kRun3SlopeMask);
}

uint16_t CSCCLCTDigi::getKeyStrip(const uint16_t n) const {
Expand All @@ -99,37 +130,41 @@ uint16_t CSCCLCTDigi::getKeyStrip(const uint16_t n) const {
}
}

/// return the fractional strip
/// return the fractional strip (middle of the strip)
float CSCCLCTDigi::getFractionalStrip(const uint16_t n) const {
if (n == 8) {
return 0.125f * (getKeyStrip(n) + 1) - 0.0625f;
return 0.125f * (getKeyStrip(n) + 0.5);
} else if (n == 4) {
return 0.25f * (getKeyStrip(n) + 1) - 0.125f;
return 0.25f * (getKeyStrip(n) + 0.5);
} else {
return 0.5f * (getKeyStrip(n) + 1) - 0.25f;
return 0.5f * (getKeyStrip(n) + 0.5);
}
}

uint16_t CSCCLCTDigi::getStrip() const { return strip_ & kHalfStripMask; }
uint16_t CSCCLCTDigi::getStrip() const { return getDataWord(strip_, kHalfStripShift, kHalfStripMask); }

bool CSCCLCTDigi::getQuartStrip() const { return (strip_ >> kQuartStripShift) & kQuartStripMask; }
bool CSCCLCTDigi::getQuartStrip() const {
if (!isRun3())
return false;
return getDataWord(strip_, kQuartStripShift, kQuartStripMask);
}

bool CSCCLCTDigi::getEightStrip() const { return (strip_ >> kEightStripShift) & kEightStripMask; }
bool CSCCLCTDigi::getEightStrip() const {
if (!isRun3())
return false;
return getDataWord(strip_, kEightStripShift, kEightStripMask);
}

void CSCCLCTDigi::setQuartStrip(const bool quartStrip) {
// clear the old value
strip_ &= ~(kQuartStripMask << kQuartStripShift);

// set the new value
strip_ |= quartStrip << kQuartStripShift;
if (!isRun3())
return;
setDataWord(quartStrip, strip_, kQuartStripShift, kQuartStripMask);
}

void CSCCLCTDigi::setEightStrip(const bool eightStrip) {
// clear the old value
strip_ &= ~(kEightStripMask << kEightStripShift);

// set the new value
strip_ |= eightStrip << kEightStripShift;
if (!isRun3())
return;
setDataWord(eightStrip, strip_, kEightStripShift, kEightStripMask);
}

void CSCCLCTDigi::setRun3(const bool isRun3) { version_ = isRun3 ? Version::Run3 : Version::Legacy; }
Expand Down Expand Up @@ -215,6 +250,18 @@ void CSCCLCTDigi::print() const {
}
}

void CSCCLCTDigi::setDataWord(const uint16_t newWord, uint16_t& word, const unsigned shift, const unsigned mask) {
// clear the old value
word &= ~(mask << shift);

// set the new value
word |= newWord << shift;
}

uint16_t CSCCLCTDigi::getDataWord(const uint16_t word, const unsigned shift, const unsigned mask) const {
return (word >> shift) & mask;
}

std::ostream& operator<<(std::ostream& o, const CSCCLCTDigi& digi) {
return o << "CSC CLCT #" << digi.getTrknmb() << ": Valid = " << digi.isValid() << " Quality = " << digi.getQuality()
<< " Pattern = " << digi.getPattern() << " StripType = " << digi.getStripType()
Expand Down

0 comments on commit 4c90098

Please sign in to comment.