Skip to content

Commit

Permalink
Merge pull request #38941 from kakwok/HMT_emulation_12_5_X
Browse files Browse the repository at this point in the history
Update muon shower (HMT) emulator
  • Loading branch information
cmsbuild committed Sep 1, 2022
2 parents e3a73ac + e27b5f3 commit 9ad28c4
Show file tree
Hide file tree
Showing 29 changed files with 621 additions and 208 deletions.
27 changes: 26 additions & 1 deletion DataFormats/CSCDigi/interface/CSCShowerDigi.h
Expand Up @@ -10,9 +10,24 @@ class CSCShowerDigi {
public:
// Run-3 definitions as provided in DN-20-033
enum Run3Shower { kInvalid = 0, kLoose = 1, kNominal = 2, kTight = 3 };
// Shower types. and showers from OTMB/TMB are assigned with kLCTShower
enum ShowerType {
kInvalidShower = 0,
kALCTShower = 1,
kCLCTShower = 2,
kLCTShower = 3,
kEMTFShower = 4,
kGMTShower = 5
};

/// Constructors
CSCShowerDigi(const uint16_t inTimeBits, const uint16_t outTimeBits, const uint16_t cscID);
CSCShowerDigi(const uint16_t inTimeBits,
const uint16_t outTimeBits,
const uint16_t cscID,
const uint16_t bx = 0,
const uint16_t showerType = 4,
const uint16_t wireNHits = 0,
const uint16_t compNHits = 0);
/// default
CSCShowerDigi();

Expand All @@ -28,20 +43,30 @@ class CSCShowerDigi {
bool isLooseOutOfTime() const;
bool isNominalOutOfTime() const;
bool isTightOutOfTime() const;
bool isValidShowerType() const;

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

uint16_t getBX() const { return bx_; }
uint16_t getCSCID() const { return cscID_; }
uint16_t getShowerType() const { return showerType_; }
uint16_t getWireNHits() const { return wireNHits_; }
uint16_t getComparatorNHits() const { return comparatorNHits_; }

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

private:
uint16_t bitsInTime_;
uint16_t bitsOutOfTime_;
// 4-bit CSC chamber identifier
uint16_t cscID_;
uint16_t bx_;
uint16_t showerType_;
uint16_t wireNHits_;
uint16_t comparatorNHits_;
};

std::ostream& operator<<(std::ostream& o, const CSCShowerDigi& digi);
Expand Down
61 changes: 56 additions & 5 deletions DataFormats/CSCDigi/src/CSCShowerDigi.cc
Expand Up @@ -6,21 +6,39 @@
using namespace std;

/// Constructors
CSCShowerDigi::CSCShowerDigi(const uint16_t bitsInTime, const uint16_t bitsOutOfTime, const uint16_t cscID)
: bitsInTime_(bitsInTime), bitsOutOfTime_(bitsOutOfTime), cscID_(cscID) {}
CSCShowerDigi::CSCShowerDigi(const uint16_t bitsInTime,
const uint16_t bitsOutOfTime,
const uint16_t cscID,
const uint16_t bx,
const uint16_t showerType,
const uint16_t wireNHits,
const uint16_t compNHits)
: bitsInTime_(bitsInTime),
bitsOutOfTime_(bitsOutOfTime),
cscID_(cscID),
bx_(bx),
showerType_(showerType),
wireNHits_(wireNHits),
comparatorNHits_(compNHits) {}

/// Default
CSCShowerDigi::CSCShowerDigi() : bitsInTime_(0), bitsOutOfTime_(0), cscID_(0) {}
CSCShowerDigi::CSCShowerDigi()
: bitsInTime_(0), bitsOutOfTime_(0), cscID_(0), bx_(0), showerType_(0), wireNHits_(0), comparatorNHits_(0) {}

void CSCShowerDigi::clear() {
bitsInTime_ = 0;
bitsOutOfTime_ = 0;
cscID_ = 0;
bx_ = 0;
showerType_ = 0;
wireNHits_ = 0;
comparatorNHits_ = 0;
}

bool CSCShowerDigi::isValid() const {
// any loose shower is valid
return isLooseInTime() or isLooseOutOfTime();
// isLooseOutofTime() is removed as out-of-time shower is not used for Run3
return isLooseInTime() and isValidShowerType();
}

bool CSCShowerDigi::isLooseInTime() const { return bitsInTime() >= kLoose; }
Expand All @@ -35,6 +53,39 @@ bool CSCShowerDigi::isNominalOutOfTime() const { return bitsOutOfTime() >= kNomi

bool CSCShowerDigi::isTightOutOfTime() const { return bitsOutOfTime() >= kTight; }

bool CSCShowerDigi::isValidShowerType() const { return showerType_ > kInvalidShower; }

std::ostream& operator<<(std::ostream& o, const CSCShowerDigi& digi) {
return o << "CSC Shower: in-time bits " << digi.bitsInTime() << ", out-of-time bits " << digi.bitsOutOfTime();
unsigned int showerType = digi.getShowerType();
std::string compHitsStr(", comparatorHits ");
compHitsStr += std::to_string(digi.getComparatorNHits());
std::string wireHitsStr(", wireHits ");
wireHitsStr += std::to_string(digi.getWireNHits());
std::string showerStr;
switch (showerType) {
case 0:
showerStr = "Invalid ShowerType";
break;
case 1:
showerStr = "AnodeShower";
break;
case 2:
showerStr = "CathodeShower";
break;
case 3:
showerStr = "MatchedShower";
break;
case 4:
showerStr = "EMTFShower";
break;
case 5:
showerStr = "GMTShower";
break;
default:
showerStr = "UnknownShowerType";
}

return o << showerStr << ": bx " << digi.getBX() << ", in-time bits " << digi.bitsInTime() << ", out-of-time bits "
<< digi.bitsOutOfTime() << ((showerType == 1 or showerType == 3) ? wireHitsStr : "")
<< ((showerType == 2 or showerType == 3) ? compHitsStr : "") << ";";
}
3 changes: 2 additions & 1 deletion DataFormats/CSCDigi/src/classes_def.xml
Expand Up @@ -39,7 +39,8 @@
<class name="CSCALCTPreTriggerDigi" ClassVersion="10">
<version ClassVersion="10" checksum="2925979693"/>
</class>
<class name="CSCShowerDigi" ClassVersion="11">
<class name="CSCShowerDigi" ClassVersion="12">
<version ClassVersion="12" checksum="2873709471"/>
<version ClassVersion="11" checksum="3092485146"/>
<version ClassVersion="10" checksum="3566030124"/>
</class>
Expand Down
5 changes: 4 additions & 1 deletion EventFilter/CSCRawToDigi/interface/CSCALCTHeader.h
Expand Up @@ -168,7 +168,10 @@ class CSCALCTHeader {
// {
if ((!theALCTs.empty()) && (theALCTs.size() == unsigned(header2007.lctBins * 2))) {
for (unsigned bx = 0; bx < header2007.lctBins; bx++) {
results.push_back(CSCShowerDigi(theALCTs[bx * 2].reserved & 0x3, 0, bx));
//CSCID is set to be 0
//ALCTshower, showerType_= 1, wireNHits and ComparatorNHits are not available in data
results.push_back(
CSCShowerDigi(theALCTs[bx * 2].reserved & 0x3, 0, 0, bx, CSCShowerDigi::ShowerType::kALCTShower, 0, 0));
}
return results;
} else
Expand Down
1 change: 1 addition & 0 deletions EventFilter/CSCRawToDigi/interface/CSCTMBHeader.h
Expand Up @@ -54,6 +54,7 @@ class CSCTMBHeader {

uint16_t sizeInBytes() const { return theHeaderFormat->sizeInWords() * 2; }

uint16_t L1AMatchTime() const { return theHeaderFormat->L1AMatchTime(); }
/// will throw if the cast fails
CSCTMBHeader2007 tmbHeader2007() const;
CSCTMBHeader2007_rev0x50c3 tmbHeader2007_rev0x50c3() const;
Expand Down
1 change: 1 addition & 0 deletions EventFilter/CSCRawToDigi/interface/CSCTMBHeader2006.h
Expand Up @@ -26,6 +26,7 @@ struct CSCTMBHeader2006 : public CSCVTMBHeaderFormat {
uint16_t syncErrorCLCT() const override { return (bits.clct0_sync_err | bits.clct1_sync_err); }
uint16_t syncErrorMPC0() const override { return bits.MPC_Muon0_SyncErr_; }
uint16_t syncErrorMPC1() const override { return bits.MPC_Muon1_SyncErr_; }
uint16_t L1AMatchTime() const override { return bits.pop_l1a_match_win; }

/// == Run 3 CSC-GEM Trigger Format
uint16_t clct0_ComparatorCode() const override { return 0; }
Expand Down
1 change: 1 addition & 0 deletions EventFilter/CSCRawToDigi/interface/CSCTMBHeader2007.h
Expand Up @@ -26,6 +26,7 @@ struct CSCTMBHeader2007 : public CSCVTMBHeaderFormat {
uint16_t syncErrorCLCT() const override { return (bits.clct0_sync_err | bits.clct1_sync_err); }
uint16_t syncErrorMPC0() const override { return bits.MPC_Muon0_SyncErr_; }
uint16_t syncErrorMPC1() const override { return bits.MPC_Muon1_SyncErr_; }
uint16_t L1AMatchTime() const override { return bits.pop_l1a_match_win; }

/// == Run 3 CSC-GEM Trigger Format
uint16_t clct0_ComparatorCode() const override { return 0; }
Expand Down
Expand Up @@ -26,6 +26,7 @@ struct CSCTMBHeader2007_rev0x50c3 : public CSCVTMBHeaderFormat {
uint16_t syncErrorCLCT() const override { return bits.clct_sync_err; }
uint16_t syncErrorMPC0() const override { return bits.MPC_Muon0_SyncErr_; }
uint16_t syncErrorMPC1() const override { return bits.MPC_Muon1_SyncErr_; }
uint16_t L1AMatchTime() const override { return bits.pop_l1a_match_win; }

/// == Run 3 CSC-GEM Trigger Format
uint16_t clct0_ComparatorCode() const override { return 0; }
Expand Down
1 change: 1 addition & 0 deletions EventFilter/CSCRawToDigi/interface/CSCTMBHeader2013.h
Expand Up @@ -26,6 +26,7 @@ struct CSCTMBHeader2013 : public CSCVTMBHeaderFormat {
uint16_t syncErrorCLCT() const override { return bits.clct_sync_err; }
uint16_t syncErrorMPC0() const override { return bits.MPC_Muon0_SyncErr_; }
uint16_t syncErrorMPC1() const override { return bits.MPC_Muon1_SyncErr_; }
uint16_t L1AMatchTime() const override { return bits.pop_l1a_match_win; }

/// == Run 3 CSC-GEM Trigger Format
uint16_t clct0_ComparatorCode() const override { return 0; }
Expand Down
Expand Up @@ -26,6 +26,7 @@ struct CSCTMBHeader2020_CCLUT : public CSCVTMBHeaderFormat {
uint16_t syncErrorCLCT() const override { return bits.clct_sync_err; }
uint16_t syncErrorMPC0() const override { return 0; }
uint16_t syncErrorMPC1() const override { return 0; }
uint16_t L1AMatchTime() const override { return bits.pop_l1a_match_win; }

// == Run 3 CSC-GEM Trigger Format
uint16_t clct0_ComparatorCode() const override { return bits.clct0_comparator_code; }
Expand Down
1 change: 1 addition & 0 deletions EventFilter/CSCRawToDigi/interface/CSCTMBHeader2020_GEM.h
Expand Up @@ -26,6 +26,7 @@ struct CSCTMBHeader2020_GEM : public CSCVTMBHeaderFormat {
uint16_t syncErrorCLCT() const override { return bits.clct_sync_err; }
uint16_t syncErrorMPC0() const override { return 0; }
uint16_t syncErrorMPC1() const override { return 0; }
uint16_t L1AMatchTime() const override { return bits.pop_l1a_match_win; }

// == Run 3 CSC-GEM Trigger Format
uint16_t clct0_ComparatorCode() const override { return bits.clct0_comparator_code; }
Expand Down
1 change: 1 addition & 0 deletions EventFilter/CSCRawToDigi/interface/CSCTMBHeader2020_Run2.h
Expand Up @@ -26,6 +26,7 @@ struct CSCTMBHeader2020_Run2 : public CSCVTMBHeaderFormat {
uint16_t syncErrorCLCT() const override { return bits.clct_sync_err; }
uint16_t syncErrorMPC0() const override { return bits.MPC_Muon0_SyncErr_; }
uint16_t syncErrorMPC1() const override { return bits.MPC_Muon1_SyncErr_; }
uint16_t L1AMatchTime() const override { return bits.pop_l1a_match_win; }

// == Run 3 CSC-GEM Trigger Format
uint16_t clct0_ComparatorCode() const override { return 0; }
Expand Down
1 change: 1 addition & 0 deletions EventFilter/CSCRawToDigi/interface/CSCTMBHeader2020_TMB.h
Expand Up @@ -26,6 +26,7 @@ struct CSCTMBHeader2020_TMB : public CSCVTMBHeaderFormat {
uint16_t syncErrorCLCT() const override { return bits.clct_sync_err; }
uint16_t syncErrorMPC0() const override { return 0; }
uint16_t syncErrorMPC1() const override { return 0; }
uint16_t L1AMatchTime() const override { return bits.pop_l1a_match_win; }

// == Run 3 CSC-GEM Trigger Format
uint16_t clct0_ComparatorCode() const override { return 0; }
Expand Down
1 change: 1 addition & 0 deletions EventFilter/CSCRawToDigi/interface/CSCVTMBHeaderFormat.h
Expand Up @@ -30,6 +30,7 @@ class CSCVTMBHeaderFormat {
virtual uint16_t syncErrorCLCT() const = 0;
virtual uint16_t syncErrorMPC0() const = 0;
virtual uint16_t syncErrorMPC1() const = 0;
virtual uint16_t L1AMatchTime() const = 0;

/// == Run 3 CSC-GEM Trigger Format
virtual uint16_t clct0_ComparatorCode() const = 0;
Expand Down
5 changes: 3 additions & 2 deletions EventFilter/CSCRawToDigi/src/CSCALCTHeader.cc
Expand Up @@ -229,8 +229,9 @@ void CSCALCTHeader::addShower(const std::vector<CSCShowerDigi> &digis) {
if (bx < (int)header2007.lctBins) {
const CSCShowerDigi &digi = digis[bx];
int i = bx * 2;
theALCTs[i].reserved = digi.bitsInTime() & 0x3;
theALCTs[i + 1].reserved = digi.bitsInTime() & 0x3;
unsigned hmt_bits = digi.isValid() ? digi.bitsInTime() : 0;
theALCTs[i].reserved = hmt_bits & 0x3;
theALCTs[i + 1].reserved = hmt_bits & 0x3;
}
}
}
Expand Down
68 changes: 60 additions & 8 deletions EventFilter/CSCRawToDigi/src/CSCTMBHeader2020_CCLUT.cc
Expand Up @@ -161,20 +161,42 @@ std::vector<CSCCorrelatedLCTDigi> CSCTMBHeader2020_CCLUT::CorrelatedLCTDigis(uin

CSCShowerDigi CSCTMBHeader2020_CCLUT::showerDigi(uint32_t idlayer) const {
unsigned hmt_bits = bits.MPC_Muon_HMT_bit0 | (bits.MPC_Muon_HMT_high << 1); // HighMultiplicityTrigger bits
uint16_t cscid = 0; // ??? What is 4-bits CSC Id in CSshowerDigi
CSCShowerDigi result(hmt_bits & 0x3, (hmt_bits >> 2) & 0x3, cscid); // 2-bits intime, 2-bits out of time
uint16_t cscid = bits.cscID; // ??? What is 4-bits CSC Id in CSshowerDigi
//L1A_TMB_WINDOW is not included in below formula
//correct version: CSCConstants::LCT_CENTRAL_BX - bits.pop_l1a_match_win + L1A_TMB_WINDOW/2;
// same for anode HMT and cathode HMT
uint16_t bx = CSCConstants::LCT_CENTRAL_BX - bits.pop_l1a_match_win;
//LCTshower with showerType = 3. comparatorNHits from hmt_nhits() and wireNHit is not available
CSCShowerDigi result(hmt_bits & 0x3,
(hmt_bits >> 2) & 0x3,
cscid,
bx,
CSCShowerDigi::ShowerType::kLCTShower,
0,
hmt_nhits()); // 2-bits intime, 2-bits out of time
return result;
}

CSCShowerDigi CSCTMBHeader2020_CCLUT::anodeShowerDigi(uint32_t idlayer) const {
uint16_t cscid = 0;
CSCShowerDigi result(bits.anode_hmt & 0x3, 0, cscid); // 2-bits intime, no out of time
uint16_t cscid = bits.cscID;
uint16_t bx = CSCConstants::LCT_CENTRAL_BX - bits.pop_l1a_match_win;
//ALCT shower with showerType = 1. nhits_ is not available from unpack data
CSCShowerDigi result(
bits.anode_hmt & 0x3, 0, cscid, bx, CSCShowerDigi::ShowerType::kALCTShower, 0, 0); // 2-bits intime, no out of time
return result;
}

CSCShowerDigi CSCTMBHeader2020_CCLUT::cathodeShowerDigi(uint32_t idlayer) const {
uint16_t cscid = 0;
CSCShowerDigi result(bits.cathode_hmt & 0x3, 0, cscid); // 2-bits intime, no out of time
uint16_t cscid = bits.cscID;
uint16_t bx = CSCConstants::LCT_CENTRAL_BX - bits.pop_l1a_match_win - bits.hmt_match_win + 3;
//CLCT shower with showerType = 2.
CSCShowerDigi result(bits.cathode_hmt & 0x3,
0,
cscid,
bx,
CSCShowerDigi::ShowerType::kCLCTShower,
0,
hmt_nhits()); // 2-bits intime, no out of time
return result;
}

Expand Down Expand Up @@ -271,19 +293,47 @@ void CSCTMBHeader2020_CCLUT::addCorrelatedLCT1(const CSCCorrelatedLCTDigi& digi)
}

void CSCTMBHeader2020_CCLUT::addShower(const CSCShowerDigi& digi) {
uint16_t hmt_bits = (digi.bitsInTime() & 0x3) + ((digi.bitsOutOfTime() & 0x3) << 2);
uint16_t hmt_bits = digi.isValid() ? (digi.bitsInTime() & 0x3) + ((digi.bitsOutOfTime() & 0x3) << 2)
//if not valid LCT shower, then in-time bits must be 0. keep out-of-time HMT:
: ((digi.bitsOutOfTime() & 0x3) << 2);
bits.MPC_Muon_HMT_bit0 = hmt_bits & 0x1;
bits.MPC_Muon_HMT_high = (hmt_bits >> 1) & 0x7;
//to keep pop_l1a_match_win
if (digi.isValid())
bits.pop_l1a_match_win = CSCConstants::LCT_CENTRAL_BX - digi.getBX();
else
bits.pop_l1a_match_win = 3; //default value
}

void CSCTMBHeader2020_CCLUT::addAnodeShower(const CSCShowerDigi& digi) {
uint16_t hmt_bits = digi.bitsInTime() & 0x3;
if (not digi.isValid())
hmt_bits = 0;
bits.anode_hmt = hmt_bits;
if (not(bits.MPC_Muon_HMT_bit0 or bits.MPC_Muon_HMT_high) and digi.isValid())
bits.pop_l1a_match_win = CSCConstants::LCT_CENTRAL_BX - digi.getBX();
else if (not(digi.isValid()))
bits.pop_l1a_match_win = 3; //default value
}

void CSCTMBHeader2020_CCLUT::addCathodeShower(const CSCShowerDigi& digi) {
uint16_t hmt_bits = digi.bitsInTime() & 0x3;
if (not digi.isValid())
hmt_bits = 0;
bits.cathode_hmt = hmt_bits;
bits.hmt_nhits_bit0 = digi.getComparatorNHits() & 0x1;
bits.hmt_nhits_bit1 = (digi.getComparatorNHits() >> 1) & 0x1;
bits.hmt_nhits_bits_high = (digi.getComparatorNHits() >> 2) & 0x1F;
if (bits.MPC_Muon_HMT_bit0 or bits.MPC_Muon_HMT_high or bits.anode_hmt) {
//matched HMT is found, then pop_l1a_match_win is assigned
bits.hmt_match_win = CSCConstants::LCT_CENTRAL_BX - bits.pop_l1a_match_win + 3 - digi.getBX();
} else if (digi.isValid()) {
bits.pop_l1a_match_win = 3; //default value
bits.hmt_match_win = CSCConstants::LCT_CENTRAL_BX - digi.getBX();
} else {
bits.pop_l1a_match_win = 3; //default value
bits.hmt_match_win = 0; //no HMT case
}
}

void CSCTMBHeader2020_CCLUT::print(std::ostream& os) const {
Expand All @@ -298,6 +348,8 @@ void CSCTMBHeader2020_CCLUT::print(std::ostream& os) const {
<< std::hex << (bits.activeCFEBs | (bits.activeCFEBs_2 << 5)) << ", readCFEBs = 0x" << std::hex
<< (bits.readCFEBs | (bits.readCFEBs_2 << 5)) << std::dec << "\n";
os << "bxnPreTrigger = " << bits.bxnPreTrigger << "\n";
os << "ALCT location in CLCT window " << bits.matchWin << " L1A location in TMB window " << bits.pop_l1a_match_win
<< " ALCT in cathde HMT window " << bits.hmt_match_win << "\n";
os << "tmbMatch = " << bits.tmbMatch << " alctOnly = " << bits.alctOnly << " clctOnly = " << bits.clctOnly << "\n";

os << "readoutCounter: " << std::dec << bits.readoutCounter << ", buf_q_ovf: " << bits.stackOvf
Expand Down Expand Up @@ -341,5 +393,5 @@ void CSCTMBHeader2020_CCLUT::print(std::ostream& os) const {

os << " clct_5bit_pattern_id = " << (bits.MPC_Muon_clct_pattern_low | (bits.MPC_Muon_clct_pattern_bit5 << 4))
<< " HMT = " << (bits.MPC_Muon_HMT_bit0 | (bits.MPC_Muon_HMT_high << 1)) << ", alctHMT = " << bits.anode_hmt
<< ", clctHMT = " << bits.cathode_hmt << "\n";
<< ", clctHMT = " << bits.cathode_hmt << " cathode nhits " << hmt_nhits() << "\n";
}

0 comments on commit 9ad28c4

Please sign in to comment.