Commit c666bf92 authored by Peter Berta's avatar Peter Berta
Browse files

Merge branch 'cherry-pick-205ba705-22.0-mc20' into '22.0-mc20'

Sweeping !48643 from master to 22.0-mc20.
MuonTruthAlgs: Fix out-of-bounds vectors writes.Closes ATLASRECTS-6706

See merge request atlas/athena!48651
parents 942320d0 8e5d4524
......@@ -237,7 +237,9 @@ void MuonTruthAssociationAlg::count_chamber_layers(const xAOD::IParticle* truthP
if (m_idHelperSvc->isMdt(id)) {
for (unsigned int i = 0; i < mdtTruth.size(); i++) {
if (id == mdtTruth[i]) {
increment_unsigned(nprecHitsPerChamberLayer[chIndex]);
if (chIndex >= 0) {
increment_unsigned(nprecHitsPerChamberLayer.at(chIndex));
}
break;
}
}
......@@ -246,9 +248,13 @@ void MuonTruthAssociationAlg::count_chamber_layers(const xAOD::IParticle* truthP
if (id != cscTruth[i]) continue;
if (measPhi) {
Muon::MuonStationIndex::PhiIndex index = m_idHelperSvc->phiIndex(id);
increment_unsigned(nphiHitsPerChamberLayer[index]);
if (index >= 0) {
increment_unsigned(nphiHitsPerChamberLayer.at(index));
}
} else {
increment_unsigned(nprecHitsPerChamberLayer[chIndex]);
if (chIndex >= 0) {
increment_unsigned(nprecHitsPerChamberLayer.at(chIndex));
}
}
break;
}
......@@ -256,10 +262,12 @@ void MuonTruthAssociationAlg::count_chamber_layers(const xAOD::IParticle* truthP
for (unsigned int i = 0; i < rpcTruth.size(); i++) {
if (id != rpcTruth[i]) { continue; }
int index = m_idHelperSvc->phiIndex(id);
if (measPhi) {
increment_unsigned(nphiHitsPerChamberLayer[index]);
} else {
increment_unsigned(ntrigEtaHitsPerChamberLayer[index]);
if (index >= 0) {
if (measPhi) {
increment_unsigned(nphiHitsPerChamberLayer.at(index));
} else {
increment_unsigned(ntrigEtaHitsPerChamberLayer.at(index));
}
}
break;
}
......@@ -267,10 +275,12 @@ void MuonTruthAssociationAlg::count_chamber_layers(const xAOD::IParticle* truthP
for (unsigned int i = 0; i < tgcTruth.size(); i++) {
if (id != tgcTruth[i]) { continue; }
int index = m_idHelperSvc->phiIndex(id);
if (measPhi) {
increment_unsigned(nphiHitsPerChamberLayer[index]);
} else {
increment_unsigned(ntrigEtaHitsPerChamberLayer[index]);
if (index >= 0) {
if (measPhi) {
increment_unsigned(nphiHitsPerChamberLayer.at(index));
} else {
increment_unsigned(ntrigEtaHitsPerChamberLayer.at(index));
}
}
break;
}
......@@ -304,4 +314,4 @@ void MuonTruthAssociationAlg::clear_dummys(const std::vector<unsigned long long>
}
}
}
}
\ No newline at end of file
}
......@@ -495,24 +495,34 @@ namespace Muon {
if (m_idHelperSvc->issTgc(id)) {
int index = m_idHelperSvc->phiIndex(id);
if (measPhi)
++nphiHitsPerChamberLayer[index];
else
++ntrigEtaHitsPerChamberLayer[index];
if (index >= 0) {
if (measPhi)
++nphiHitsPerChamberLayer.at(index);
else
++ntrigEtaHitsPerChamberLayer.at(index);
}
} else if (m_idHelperSvc->isMM(id)) {
++nprecHitsPerChamberLayer[chIndex];
if (chIndex >= 0) {
++nprecHitsPerChamberLayer.at(chIndex);
}
} else if (m_idHelperSvc->isTrigger(id)) {
int index = m_idHelperSvc->phiIndex(id);
if (measPhi)
++nphiHitsPerChamberLayer[index];
else
++ntrigEtaHitsPerChamberLayer[index];
if (index >= 0) {
if (measPhi)
++nphiHitsPerChamberLayer.at(index);
else
++ntrigEtaHitsPerChamberLayer.at(index);
}
} else {
if (measPhi) {
Muon::MuonStationIndex::PhiIndex index = m_idHelperSvc->phiIndex(id);
++nphiHitsPerChamberLayer[index];
if (index >= 0) {
++nphiHitsPerChamberLayer.at(index);
}
} else {
++nprecHitsPerChamberLayer[chIndex];
if (chIndex >= 0) {
++nprecHitsPerChamberLayer.at(chIndex);
}
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment