Skip to content

Commit

Permalink
Throw an exception for an invalid mkFit layer index
Browse files Browse the repository at this point in the history
  • Loading branch information
makortel committed Sep 25, 2019
1 parent 5389310 commit 19fbaf4
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions RecoTracker/MkFit/plugins/MkFitOutputConverter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,17 @@ std::vector<const DetLayer *> MkFitOutputConverter::createDetLayers(const mkfit:
auto isPlusSide = [&ttopo](const DetId& detid) {
return ttopo.side(detid) == static_cast<unsigned>(TrackerDetSide::PosEndcap);
};
constexpr int isMono = 0;
constexpr int isStereo = 1;
auto setDet = [&lnc, &dets, &isPlusSide](
const int subdet, const int layer, const int isStereo, const DetId& detId, const DetLayer* lay) {
const int index = lnc.convertLayerNumber(subdet, layer, false, isStereo, isPlusSide(detId));
if (index < 0 or static_cast<unsigned>(index) >= dets.size()) {
throw cms::Exception("LogicError") << "Invalid mkFit layer index " << index << " for DetId " << detId.rawId()
<< " subdet " << subdet << " layer " << layer << " isStereo " << isStereo;
}
dets[index] = lay;
};
constexpr int monoLayer = 0;
constexpr int stereoLayer = 1;
for (const DetLayer* lay : tracker.allLayers()) {
const auto& comp = lay->basicComponents();
if (UNLIKELY(comp.empty())) {
Expand All @@ -205,10 +214,10 @@ std::vector<const DetLayer *> MkFitOutputConverter::createDetLayers(const mkfit:
const auto layer = ttopo.layer(detId);

// TODO: mono/stereo structure is still hardcoded for phase0/1 strip tracker
dets[lnc.convertLayerNumber(subdet, layer, false, isMono, isPlusSide(detId))] = lay;
setDet(subdet, layer, monoLayer, detId, lay);
if (((subdet == StripSubdetector::TIB or subdet == StripSubdetector::TOB) and (layer == 1 or layer == 2)) or
subdet == StripSubdetector::TID or subdet == StripSubdetector::TEC) {
dets[lnc.convertLayerNumber(subdet, layer, false, isStereo, isPlusSide(detId))] = lay;
setDet(subdet, layer, stereoLayer, detId, lay);
}
}

Expand Down

0 comments on commit 19fbaf4

Please sign in to comment.