Skip to content

Commit 5413b72

Browse files
pillotaphecetche
authored andcommitted
add protections
1 parent aab7571 commit 5413b72

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

Detectors/MUON/MCH/PreClustering/src/PreClusterFinder.cxx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,23 @@ void PreClusterFinder::loadDigit(const Digit& digit)
125125
{
126126
/// fill the Mapping::MpDE structure with fired pad
127127

128-
int deIndex = mDEIndices[digit.getDetID()];
129-
assert(deIndex >= 0 && deIndex < SNDEs);
128+
int deIndex = mDEIndices.at(digit.getDetID());
130129

131130
DetectionElement& de(*(mDEs[deIndex]));
132131

132+
if (digit.getPadID() < 0 || digit.getPadID() >= de.mapping->nPads[0] + de.mapping->nPads[1]) {
133+
throw out_of_range("invalid pad index");
134+
}
135+
133136
uint16_t iPad = digit.getPadID();
134137
int iPlane = (iPad < de.mapping->nPads[0]) ? 0 : 1;
135138

139+
// check that the pad is not already fired
140+
if (de.mapping->pads[iPad].useMe) {
141+
LOG(error) << "multiple digits on the same pad (DE " << digit.getDetID() << ", pad " << iPad << ")";
142+
return;
143+
}
144+
136145
// register this digit
137146
uint16_t iDigit = de.nFiredPads[0] + de.nFiredPads[1];
138147
if (iDigit >= de.digits.size()) {

0 commit comments

Comments
 (0)