Skip to content

Commit

Permalink
Implement Run-3 CSC stub formats
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Dildick committed Mar 14, 2020
1 parent a57bc8e commit 9b9ae26
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 39 deletions.
57 changes: 43 additions & 14 deletions DataFormats/CSCDigi/interface/CSCCLCTDigi.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef CSCDigi_CSCCLCTDigi_h
#define CSCDigi_CSCCLCTDigi_h
#ifndef DataFormats_CSCDigi_CSCCLCTDigi_h
#define DataFormats_CSCDigi_CSCCLCTDigi_h

/**\class CSCCLCTDigi
*
Expand All @@ -11,9 +11,15 @@

#include <cstdint>
#include <iosfwd>
#include <vector>

class CSCCLCTDigi {
public:
typedef std::vector<std::vector<uint16_t>> ComparatorContainer;

enum CLCTKeyStripMasks { kEightStripMask = 0x1, kQuartStripMask = 0x1, kHalfStripMask = 0x1f };
enum CLCTKeyStripShifts { kEightStripShift = 6, kQuartStripShift = 5, kHalfStripShift = 0 };

/// Constructors
CSCCLCTDigi(const int valid,
const int quality,
Expand All @@ -24,7 +30,8 @@ class CSCCLCTDigi {
const int cfeb,
const int bx,
const int trknmb = 0,
const int fullbx = 0);
const int fullbx = 0,
const int compCode = -1);
/// default
CSCCLCTDigi();

Expand Down Expand Up @@ -61,12 +68,24 @@ class CSCCLCTDigi {
/// set bend
void setBend(const int bend) { bend_ = bend; }

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

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

/// set single quart strip bit
void setQuartStrip(const bool quartStrip);

/// get single quart strip bit
bool getQuartStrip() const;

/// set single eight strip bit
void setEightStrip(const bool eightStrip);

/// get single eight strip bit
bool getEightStrip() const;

/// return Key CFEB ID
int getCFEB() const { return cfeb_; }

Expand All @@ -85,16 +104,10 @@ class CSCCLCTDigi {
/// Convert strip_ and cfeb_ to keyStrip. Each CFEB has up to 16 strips
/// (32 halfstrips). There are 5 cfebs. The "strip_" variable is one
/// of 32 halfstrips on the keylayer of a single CFEB, so that
/// Distrip = (cfeb*32 + strip)/4.
/// Halfstrip = (cfeb*32 + strip).
/// Always return halfstrip number since this is what is stored in
/// the correlated LCT digi. For distrip patterns, the convention is
/// the same as for persistent strip numbers: low halfstrip of a distrip.
/// SV, June 15th, 2006.
int getKeyStrip() const {
int keyStrip = cfeb_ * 32 + strip_;
return keyStrip;
}
/// This function can also return the quartstrip or eightstrip
/// when the comparator code has been set
int getKeyStrip(int n = 2) const;

/// Set track number (1,2) after sorting CLCTs.
void setTrknmb(const uint16_t number) { trknmb_ = number; }
Expand All @@ -105,6 +118,16 @@ class CSCCLCTDigi {
/// Set 12-bit full BX.
void setFullBX(const uint16_t fullbx) { fullbx_ = fullbx; }

// 12-bit comparator code
int getCompCode() const { return compCode_; }

void setCompCode(const int16_t code) { compCode_ = code; }

// comparator hits in this CLCT
ComparatorContainer getHits() const { return hits_; }

void setHits(const ComparatorContainer& hits) { hits_ = hits; }

/// True if the left-hand side has a larger "quality". Full definition
/// of "quality" depends on quality word itself, pattern type, and strip
/// number.
Expand All @@ -130,6 +153,12 @@ class CSCCLCTDigi {
uint16_t bx_;
uint16_t trknmb_;
uint16_t fullbx_;

// new in Run-3: 12-bit comparator code
// set by default to -1 for Run-1 and Run-2 CLCTs
int16_t compCode_;
// which hits are in this CLCT?
ComparatorContainer hits_;
};

std::ostream& operator<<(std::ostream& o, const CSCCLCTDigi& digi);
Expand Down
27 changes: 21 additions & 6 deletions DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigi.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef CSCDigi_CSCCorrelatedLCTDigi_h
#define CSCDigi_CSCCorrelatedLCTDigi_h
#ifndef DataFormats_CSCDigi_CSCCorrelatedLCTDigi_h
#define DataFormats_CSCDigi_CSCCorrelatedLCTDigi_h

/**\class CSCCorrelatedLCTDigi
*
* Digi for Correlated LCT trigger primitives.
* Digi for Correlated LCT trigger primitives.
*
*
* \author L. Gray, UF
Expand All @@ -17,6 +17,9 @@

class CSCCorrelatedLCTDigi {
public:
enum LCTKeyStripMasks { kEightStripMask = 0x1, kQuartStripMask = 0x1, kHalfStripMask = 0xff };
enum LCTKeyStripShifts { kEightStripShift = 9, kQuartStripShift = 8, kHalfStripShift = 0 };

/// Constructors
CSCCorrelatedLCTDigi(const int trknmb,
const int valid,
Expand All @@ -41,17 +44,29 @@ class CSCCorrelatedLCTDigi {
/// return valid pattern bit
bool isValid() const { return valid; }

/// return the 4 bit Correlated LCT Quality
/// return the Quality
int getQuality() const { return quality; }

/// return the key wire group. counts from 0.
int getKeyWG() const { return keywire; }

/// return the key halfstrip from 0,159
int getStrip() const { return strip; }
int getStrip(int n = 2) const;

/// set single quart strip bit
void setQuartStrip(const bool quartStrip);

/// get single quart strip bit
bool getQuartStrip() const;

/// set single eight strip bit
void setEightStrip(const bool eightStrip);

/// get single eight strip bit
bool getEightStrip() const;

/// return the fractional strip. counts from 0.25
float getFractionalStrip() const;
float getFractionalStrip(int n = 2) const;

/// return pattern
int getPattern() const { return pattern; }
Expand Down
95 changes: 78 additions & 17 deletions DataFormats/CSCDigi/src/CSCCLCTDigi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
#include <iomanip>
#include <iostream>

enum Pattern_Info {
NUM_LAYERS = 6,
CLCT_PATTERN_WIDTH = 11
};

/// Constructors
CSCCLCTDigi::CSCCLCTDigi(const int valid,
const int quality,
Expand All @@ -21,7 +26,8 @@ CSCCLCTDigi::CSCCLCTDigi(const int valid,
const int cfeb,
const int bx,
const int trknmb,
const int fullbx)
const int fullbx,
const int compCode)
: valid_(valid),
quality_(quality),
pattern_(pattern),
Expand All @@ -31,23 +37,31 @@ CSCCLCTDigi::CSCCLCTDigi(const int valid,
cfeb_(cfeb),
bx_(bx),
trknmb_(trknmb),
//fullbx_(0)
fullbx_(fullbx) {
//valid_ = valid;
//quality_ = quality;
//pattern_ = pattern;
//striptype_ = striptype;
//bend_ = bend;
//strip_ = strip;
//cfeb_ = cfeb;
//bx_ = bx;
//trknmb_ = trknmb;
fullbx_(fullbx),
compCode_(compCode) {
hits_.resize(NUM_LAYERS);
for (auto& p : hits_) {
p.resize(CLCT_PATTERN_WIDTH);
}
}

/// Default
CSCCLCTDigi::CSCCLCTDigi()
: valid_(0), quality_(0), pattern_(0), striptype_(0), bend_(0), strip_(0), cfeb_(0), bx_(0), trknmb_(0), fullbx_(0) {
// clear(); // set contents to zero
: valid_(0),
quality_(0),
pattern_(0),
striptype_(0),
bend_(0),
strip_(0),
cfeb_(0),
bx_(0),
trknmb_(0),
fullbx_(0),
compCode_(-1) {
hits_.resize(NUM_LAYERS);
for (auto& p : hits_) {
p.resize(CLCT_PATTERN_WIDTH);
}
}

/// Clears this CLCT.
Expand All @@ -62,6 +76,52 @@ void CSCCLCTDigi::clear() {
bx_ = 0;
trknmb_ = 0;
fullbx_ = 0;
compCode_ = -1;
hits_.clear();
hits_.resize(NUM_LAYERS);
for (auto& p : hits_) {
p.resize(CLCT_PATTERN_WIDTH);
}
}

int CSCCLCTDigi::getKeyStrip(int n) const {
// 10-bit case for strip data word
if (compCode_ != -1 and n == 8) {
return getKeyStrip(4) * 2 + getEightStrip();
}
// 9-bit case for strip data word
else if (compCode_ != -1 and n == 4) {
return getKeyStrip(2) * 2 + getQuartStrip();
}
// 8-bit case for strip data word (all other cases)
else {
return cfeb_ * 32 + getStrip();
}
}

int CSCCLCTDigi::getStrip() const
{
return strip_ & kHalfStripMask;
}

bool CSCCLCTDigi::getQuartStrip() const { return (strip_ >> kQuartStripShift) & kQuartStripMask; }

bool CSCCLCTDigi::getEightStrip() const { return (strip_ >> kEightStripShift) & kEightStripMask; }

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

// set the new value
strip_ |= quartStrip << kQuartStripShift;
}

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

// set the new value
strip_ |= eightStrip << kEightStripShift;
}

bool CSCCLCTDigi::operator>(const CSCCLCTDigi& rhs) const {
Expand Down Expand Up @@ -96,7 +156,7 @@ bool CSCCLCTDigi::operator==(const CSCCLCTDigi& rhs) const {
bool returnValue = false;
if (isValid() == rhs.isValid() && getQuality() == rhs.getQuality() && getPattern() == rhs.getPattern() &&
getKeyStrip() == rhs.getKeyStrip() && getStripType() == rhs.getStripType() && getBend() == getBend() &&
getBX() == rhs.getBX()) {
getBX() == rhs.getBX() && getCompCode() == rhs.getCompCode()) {
returnValue = true;
}
return returnValue;
Expand All @@ -122,7 +182,8 @@ void CSCCLCTDigi::print() const {
<< getQuality() << " Pattern = " << std::setw(1) << getPattern()
<< " Bend = " << std::setw(1) << bend << " Strip type = " << std::setw(1) << stripType
<< " CFEB ID = " << std::setw(1) << getCFEB() << " BX = " << std::setw(1) << getBX()
<< " Full BX= " << std::setw(1) << getFullBX();
<< " Full BX= " << std::setw(1) << getFullBX() << " Comp Code= " << std::setw(1)
<< getCompCode();
} else {
edm::LogVerbatim("CSCDigi") << "Not a valid Cathode LCT.";
}
Expand All @@ -132,5 +193,5 @@ 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()
<< " Bend = " << digi.getBend() << " Strip = " << digi.getStrip() << " KeyStrip = " << digi.getKeyStrip()
<< " CFEB = " << digi.getCFEB() << " BX = " << digi.getBX();
<< " CFEB = " << digi.getCFEB() << " BX = " << digi.getBX() << " Comp Code " << digi.getCompCode();
}
45 changes: 44 additions & 1 deletion DataFormats/CSCDigi/src/CSCCorrelatedLCTDigi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,51 @@ void CSCCorrelatedLCTDigi::clear() {
cscID = 0;
}

int CSCCorrelatedLCTDigi::getStrip(int n) const {
// all 10 bits
if (n == 8) {
return 2 * getStrip(4) + getEightStrip();
}
// lowest 9 bits
else if (n == 4) {
return 2 * getStrip(2) + getQuartStrip();
}
// lowest 8 bits
else {
return strip & kHalfStripMask;
}
}

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

// set the new value
strip |= quartStrip << kQuartStripShift;
}

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

// set the new value
strip |= eightStrip << kEightStripShift;
}

bool CSCCorrelatedLCTDigi::getQuartStrip() const { return (strip >> kQuartStripShift) & kQuartStripMask; }

bool CSCCorrelatedLCTDigi::getEightStrip() const { return (strip >> kEightStripShift) & kEightStripMask; }

/// return the fractional strip
float CSCCorrelatedLCTDigi::getFractionalStrip() const { return 0.5f * (getStrip() + 1) - 0.25f; }
float CSCCorrelatedLCTDigi::getFractionalStrip(int n) const {
if (n == 8) {
return 0.125f * (getStrip() + 1) - 0.0625f;
} else if (n == 4) {
return 0.25f * (getStrip() + 1) - 0.125f;
} else {
return 0.5f * (getStrip() + 1) - 0.25f;
}
}

/// Comparison
bool CSCCorrelatedLCTDigi::operator==(const CSCCorrelatedLCTDigi& rhs) const {
Expand Down
4 changes: 3 additions & 1 deletion DataFormats/CSCDigi/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
<version ClassVersion="10" checksum="967689346"/>
<version ClassVersion="11" checksum="56593764"/>
</class>
<class name="CSCCLCTDigi" ClassVersion="10">
<class name="CSCCLCTDigi" ClassVersion="11">
<version ClassVersion="10" checksum="3910057547"/>
<version ClassVersion="11" checksum="511203876"/>
</class>
<ioread sourceClass="CSCCLCTDigi" targetClass="CSCCLCTDigi" version="[-10]" target="compCode_" source=""> <![CDATA[ compCode_ = -1; ]]> </ioread>
<class name="CSCCLCTPreTriggerDigi" ClassVersion="10">
<version ClassVersion="10" checksum="1207676078"/>
</class>
Expand Down

0 comments on commit 9b9ae26

Please sign in to comment.