Skip to content

Commit

Permalink
Data members for Run-3 variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Dildick committed May 13, 2021
1 parent ece6f8e commit cd66349
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 243 deletions.
50 changes: 25 additions & 25 deletions DataFormats/CSCDigi/interface/CSCCLCTDigi.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ class CSCCLCTDigi {
public:
typedef std::vector<std::vector<uint16_t>> ComparatorContainer;

enum CLCTKeyStripMasks { kEighthStripMask = 0x1, kQuartStripMask = 0x1, kHalfStripMask = 0x1f };
enum CLCTKeyStripShifts { kEighthStripShift = 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 };
// for data vs emulator studies
enum CLCTBXMask { kBXDataMask = 0x3 };
Expand Down Expand Up @@ -59,22 +54,22 @@ class CSCCLCTDigi {
void setQuality(const uint16_t quality) { quality_ = quality; }

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

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

/// return pattern
uint16_t getRun3Pattern() const;
uint16_t getRun3Pattern() const { return run3_pattern_; }

/// set pattern
void setRun3Pattern(const uint16_t pattern);
void setRun3Pattern(const uint16_t pattern) { run3_pattern_ = pattern; }

/// return the slope
uint16_t getSlope() const;
uint16_t getSlope() const { return run3_slope_; }

/// set the slope
void setSlope(const uint16_t slope);
void setSlope(const uint16_t slope) { run3_slope_ = slope; }

/// slope in number of half-strips/layer
/// negative means left-bending
Expand All @@ -96,22 +91,22 @@ class CSCCLCTDigi {
void setBend(const uint16_t bend) { bend_ = bend; }

/// return halfstrip that goes from 0 to 31 in a (D)CFEB
uint16_t getStrip() const;
uint16_t getStrip() const { return strip_; }

/// set strip
void setStrip(const uint16_t strip) { strip_ = strip; }

/// set single quart strip bit
void setQuartStrip(const bool quartStrip);
void setQuartStrip(const bool quartStrip) { run3_quart_strip_bit_ = quartStrip; }

/// get single quart strip bit
bool getQuartStrip() const;
bool getQuartStrip() const { return run3_quart_strip_bit_; }

/// set single eighth strip bit
void setEighthStrip(const bool eighthStrip);
void setEighthStrip(const bool eighthStrip) { run3_eighth_strip_bit_ = eighthStrip; }

/// get single eighth strip bit
bool getEighthStrip() const;
bool getEighthStrip() const { return run3_eighth_strip_bit_; }

/// return Key CFEB ID
uint16_t getCFEB() const { return cfeb_; }
Expand Down Expand Up @@ -197,29 +192,34 @@ 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
// 4-bit bending value. There will be 16 bending values * 2 (left/right)
// Run-1/2 pattern number.
// For Run-3 CLCTs, please use run3_pattern_. For some backward
// compatibility the trigger emulator translates run3_pattern_
// approximately into pattern_ with a lookup table
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
// actually the half-strip number
uint16_t strip_;
// There are up to 7 (D)CFEBs in a chamber
uint16_t cfeb_;
uint16_t bx_;
uint16_t trknmb_;
uint16_t fullbx_;

// 1/4-strip bit set by CCLUT
bool run3_quart_strip_bit_;
// 1/8-strip bit set by CCLUT
bool run3_eighth_strip_bit_;
// In Run-3, the CLCT digi has 3-bit pattern ID, 0 through 4
uint16_t run3_pattern_;
// 4-bit bending value. There will be 16 bending values * 2 (left/right)
uint16_t run3_slope_;

// new in Run-3: 12-bit comparator code
// set by default to -1 for Run-1 and Run-2 CLCTs
int16_t compCode_;
Expand Down
58 changes: 27 additions & 31 deletions DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigi.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@

class CSCCorrelatedLCTDigi {
public:
enum LCTKeyStripMasks { kEighthStripMask = 0x1, kQuartStripMask = 0x1, kHalfStripMask = 0xff };
enum LCTKeyStripShifts { kEighthStripShift = 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 };
// for data vs emulator studies
enum LCTBXMask { kBXDataMask = 0x1 };
Expand Down Expand Up @@ -64,16 +59,16 @@ class CSCCorrelatedLCTDigi {
uint16_t getStrip(uint16_t n = 2) const;

/// set single quart strip bit
void setQuartStrip(const bool quartStrip);
void setQuartStrip(const bool quartStrip) { run3_quart_strip_bit_ = quartStrip; }

/// get single quart strip bit
bool getQuartStrip() const;
bool getQuartStrip() const { return run3_quart_strip_bit_; }

/// set single eighth strip bit
void setEighthStrip(const bool eighthStrip);
void setEighthStrip(const bool eighthStrip) { run3_eighth_strip_bit_ = eighthStrip; }

/// get single eighth strip bit
bool getEighthStrip() const;
bool getEighthStrip() const { return run3_eighth_strip_bit_; }

/*
Strips are numbered starting from 1 in CMSSW
Expand All @@ -94,15 +89,14 @@ class CSCCorrelatedLCTDigi {
*/
float getFractionalStrip(uint16_t n = 2) const;

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

/// return pattern
uint16_t getRun3Pattern() const;
/// return the Run-3 pattern ID
uint16_t getRun3Pattern() const { return run3_pattern_; }

/// return the slope
uint16_t getSlope() const;
uint16_t getSlope() const { return run3_slope_; }

/// slope in number of half-strips/layer
/// negative means left-bending
Expand Down Expand Up @@ -166,13 +160,13 @@ class CSCCorrelatedLCTDigi {
void setStrip(const uint16_t s) { strip = s; }

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

/// set pattern
void setRun3Pattern(const uint16_t pattern);
/// set Run-3 pattern
void setRun3Pattern(const uint16_t pattern) { run3_pattern_ = pattern; }

/// set the slope
void setSlope(const uint16_t slope);
void setSlope(const uint16_t slope) { run3_slope_ = slope; }

/// set bend
void setBend(const uint16_t b) { bend = b; }
Expand Down Expand Up @@ -223,9 +217,6 @@ 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 All @@ -241,13 +232,12 @@ class CSCCorrelatedLCTDigi {
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
// actually the 8-bit half-strip number
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)
// Run-1/2 pattern number.
// For Run-3 CLCTs, please use run3_pattern_. For some backward
// compatibility the trigger emulator translates run3_pattern_
// approximately into pattern_ with a lookup table
uint16_t pattern;
// Common definition for left/right bending in Run-1, Run-2 and Run-3.
// 0: right; 1: left
Expand All @@ -261,11 +251,17 @@ class CSCCorrelatedLCTDigi {
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;

// 1/4-strip bit set by CCLUT
bool run3_quart_strip_bit_;
// 1/8-strip bit set by CCLUT
bool run3_eighth_strip_bit_;
// In Run-3, the CLCT digi has 3-bit pattern ID, 0 through 4
uint16_t run3_pattern_;
// 4-bit bending value. There will be 16 bending values * 2 (left/right)
uint16_t run3_slope_;

/// SIMULATION ONLY ////
int type_;

Expand Down
21 changes: 8 additions & 13 deletions DataFormats/CSCDigi/interface/CSCShowerDigi.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,36 @@ class CSCShowerDigi {
public:
// Run-3 definitions as provided in DN-20-033
enum Run3Shower { kInvalid = 0, kLoose = 1, kNominal = 2, kTight = 3 };
enum BitMask { kInTimeMask = 0x2, kOutTimeMask = 0x2 };
enum BitShift { kInTimeShift = 0, kOutTimeShift = 2 };

/// Constructors
CSCShowerDigi(const uint16_t inTimeBits, const uint16_t outTimeBits, const uint16_t cscID);
/// default
CSCShowerDigi();

/// clear this Shower
void clear() { bits_ = 0; }
void clear();

/// data
bool isValid() const;

bool isLooseInTime() const;
bool isNominalInTime() const;
bool isTightInTime() const;
bool isLooseOutTime() const;
bool isNominalOutTime() const;
bool isTightOutTime() const;
bool isLooseOutOfTime() const;
bool isNominalOutOfTime() const;
bool isTightOutOfTime() const;

uint16_t bits() const { return bits_; }
uint16_t bitsInTime() const;
uint16_t bitsOutTime() const;
uint16_t bitsInTime() const { return bitsInTime_; }
uint16_t bitsOutOfTime() const { return bitsOutOfTime_; }

uint16_t getCSCID() const { return cscID_; }

/// set cscID
void setCSCID(const uint16_t c) { cscID_ = c; }

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 bits_;
uint16_t bitsInTime_;
uint16_t bitsOutOfTime_;
// 4-bit CSC chamber identifier
uint16_t cscID_;
};
Expand Down
68 changes: 0 additions & 68 deletions DataFormats/CSCDigi/src/CSCCLCTDigi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,36 +85,6 @@ void CSCCLCTDigi::clear() {
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);
}

// slope in number of half-strips/layer
float CSCCLCTDigi::getFractionalSlope() const {
if (isRun3()) {
Expand Down Expand Up @@ -154,32 +124,6 @@ float CSCCLCTDigi::getFractionalStrip(const uint16_t n) const {
}
}

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

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

bool CSCCLCTDigi::getEighthStrip() const {
if (!isRun3())
return false;
return getDataWord(strip_, kEighthStripShift, kEighthStripMask);
}

void CSCCLCTDigi::setQuartStrip(const bool quartStrip) {
if (!isRun3())
return;
setDataWord(quartStrip, strip_, kQuartStripShift, kQuartStripMask);
}

void CSCCLCTDigi::setEighthStrip(const bool eighthStrip) {
if (!isRun3())
return;
setDataWord(eighthStrip, strip_, kEighthStripShift, kEighthStripMask);
}

void CSCCLCTDigi::setRun3(const bool isRun3) { version_ = isRun3 ? Version::Run3 : Version::Legacy; }

bool CSCCLCTDigi::operator>(const CSCCLCTDigi& rhs) const {
Expand Down Expand Up @@ -263,18 +207,6 @@ 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
Loading

0 comments on commit cd66349

Please sign in to comment.