diff --git a/L1Trigger/CSCTriggerPrimitives/interface/CSCGEMMotherboard.h b/L1Trigger/CSCTriggerPrimitives/interface/CSCGEMMotherboard.h index 3da30e9482edd..ddb6766caa07a 100644 --- a/L1Trigger/CSCTriggerPrimitives/interface/CSCGEMMotherboard.h +++ b/L1Trigger/CSCTriggerPrimitives/interface/CSCGEMMotherboard.h @@ -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; diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboard.cc b/L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboard.cc index 8d9133834a2dd..04d36d84c2c46 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboard.cc +++ b/L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboard.cc @@ -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; @@ -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()); @@ -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; @@ -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 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(); } @@ -258,7 +271,7 @@ 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() { @@ -266,6 +279,10 @@ void CSCGEMMotherboard::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;