Skip to content

Commit

Permalink
Merge pull request cms-sw#30564 from dildick/from-CMSSW_11_2_X_2020-0…
Browse files Browse the repository at this point in the history
…7-06-1100-gem-csc-trigger-bugfix

Fix out-of-bound issue in call to LUT in GEM-CSC trigger
  • Loading branch information
cmsbuild authored Jul 9, 2020
2 parents 4a3eb91 + d08b6a0 commit e74fe08
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
2 changes: 2 additions & 0 deletions L1Trigger/CSCTriggerPrimitives/interface/CSCGEMMotherboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ class CSCGEMMotherboard : public CSCUpgradeMotherboard {

/** Chamber id (trigger-type labels). */
unsigned gemId;
int maxPads() const;
int maxRolls() const;

const GEMGeometry* gem_g;
bool gemGeometryAvailable;
Expand Down
33 changes: 25 additions & 8 deletions L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,28 @@ CSCCorrelatedLCTDigi CSCGEMMotherboard::constructLCTsGEM(const CSCALCTDigi& alct
p = CSCPart::ME1A;
}

// min pad number is always 0
// max pad number is 191 or 383, depending on the station
assert(gem2.pad(1) >= 0);
assert(gem2.pad(2) >= 0);
assert(gem2.pad(1) < maxPads());
assert(gem2.pad(2) < maxPads());

const auto& mymap1 = getLUT()->get_gem_pad_to_csc_hs(theParity, p);
// GEM pad number is counting from 1
// keyStrip from mymap: for ME1b 0-127 and for ME1a 0-95
// keyStrip for CLCT: for ME1b 0-127 and for ME1a 128-223
keyStrip = mymap1[gem2.pad(2) - 1];
if (p == CSCPart::ME1A and keyStrip <= CSCConstants::MAX_HALF_STRIP_ME1B)
keyStrip = mymap1.at(gem2.pad(2));
if (p == CSCPart::ME1A and keyStrip <= CSCConstants::MAX_HALF_STRIP_ME1B) {
keyStrip += CSCConstants::MAX_HALF_STRIP_ME1B + 1;
}
keyWG = alct.getKeyWG();

if ((not doesWiregroupCrossStrip(keyWG, keyStrip)) and p == CSCPart::ME1B and keyWG <= 15) {
//try ME1A as strip and WG do not cross
p = CSCPart::ME1A;
const auto& mymap2 = getLUT()->get_gem_pad_to_csc_hs(theParity, p);
keyStrip = mymap2[gem2.pad(2) - 1] + CSCConstants::MAX_HALF_STRIP_ME1B + 1;
keyStrip = mymap2.at(gem2.pad(2)) + CSCConstants::MAX_HALF_STRIP_ME1B + 1;
}

pattern = promoteALCTGEMpattern_ ? 10 : 0;
Expand All @@ -169,13 +177,18 @@ CSCCorrelatedLCTDigi CSCGEMMotherboard::constructLCTsGEM(const CSCALCTDigi& alct
thisLCT.setType(CSCCorrelatedLCTDigi::ALCT2GEM);
valid = true;
} else if (clct.isValid() and gem2.isValid() and not alct.isValid()) {
// min roll number is always 1
// max roll number is 8 or 16, depending on the station
assert(gem2.roll() >= GEMDetId::minRollId);
assert(gem2.roll() <= maxRolls());

const auto& mymap2 = getLUT()->get_gem_roll_to_csc_wg(theParity);
pattern = encodePattern(clct.getPattern());
quality = promoteCLCTGEMquality_ ? 15 : 11;
bx = gem2.bx(1) + CSCConstants::LCT_CENTRAL_BX;
keyStrip = clct.getKeyStrip();
// choose the corresponding wire-group in the middle of the partition
keyWG = mymap2[gem2.roll() - 1];
keyWG = mymap2.at(gem2.roll() - 1);
bend = clct.getBend();
thisLCT.setCLCT(clct);
thisLCT.setGEM1(gem2.first());
Expand Down Expand Up @@ -222,7 +235,7 @@ bool CSCGEMMotherboard::isPadInOverlap(int roll) const {
// overlap region are WGs 10-15
if ((i < 10) or (i > 15))
continue;
if ((mymap[i].first <= roll) and (roll <= mymap[i].second))
if ((mymap.at(i).first <= roll) and (roll <= mymap.at(i).second))
return true;
}
return false;
Expand All @@ -241,8 +254,8 @@ int CSCGEMMotherboard::getRoll(const GEMPadDigiId& p) const { return GEMDetId(p.
int CSCGEMMotherboard::getRoll(const GEMCoPadDigiId& p) const { return p.second.roll(); }

std::pair<int, int> CSCGEMMotherboard::getRolls(const CSCALCTDigi& alct) const {
return std::make_pair((getLUT()->get_csc_wg_to_gem_roll(theParity))[alct.getKeyWG()].first,
(getLUT()->get_csc_wg_to_gem_roll(theParity))[alct.getKeyWG()].second);
const auto& mymap(getLUT()->get_csc_wg_to_gem_roll(theParity));
return mymap.at(alct.getKeyWG());
}

float CSCGEMMotherboard::getPad(const GEMPadDigi& p) const { return p.pad(); }
Expand All @@ -258,14 +271,18 @@ float CSCGEMMotherboard::getPad(const CSCCLCTDigi& clct, enum CSCPart part) cons
//ME1A part, convert halfstrip from 128-223 to 0-95
if (part == CSCPart::ME1A and keyStrip > CSCConstants::MAX_HALF_STRIP_ME1B)
keyStrip = keyStrip - CSCConstants::MAX_HALF_STRIP_ME1B - 1;
return 0.5 * (mymap[keyStrip].first + mymap[keyStrip].second);
return 0.5 * (mymap.at(keyStrip).first + mymap.at(keyStrip).second);
}

void CSCGEMMotherboard::setupGeometry() {
CSCUpgradeMotherboard::setupGeometry();
generator_->setGEMGeometry(gem_g);
}

int CSCGEMMotherboard::maxPads() const { return gem_g->superChamber(gemId)->chamber(1)->etaPartition(1)->npads(); }

int CSCGEMMotherboard::maxRolls() const { return gem_g->superChamber(gemId)->chamber(1)->nEtaPartitions(); }

void CSCGEMMotherboard::printGEMTriggerPads(int bx_start, int bx_stop, enum CSCPart part) {
LogTrace("CSCGEMMotherboard") << "------------------------------------------------------------------------"
<< std::endl;
Expand Down

0 comments on commit e74fe08

Please sign in to comment.