Skip to content

Commit

Permalink
Merge pull request #39412 from jaimeleonh/AM_12_5_primosfix
Browse files Browse the repository at this point in the history
[12_5_X] L1 DT AM - heap-buffer-overflow fix + slight logic improvement in confirmed TPs
  • Loading branch information
cmsbuild authored Oct 7, 2022
2 parents 33927c0 + 572ce96 commit 64b3862
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 23 deletions.
6 changes: 5 additions & 1 deletion L1Trigger/DTTriggerPhase2/src/MPQualityEnhancerFilter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ void MPQualityEnhancerFilter::filterCousins(std::vector<metaPrimitive> &inMPaths
bestI = i;
}
}
if (areCousins(inMPaths[i], inMPaths[i + 1]) != 0) {
bool add_paths = (i == (int)(inMPaths.size() - 1));
if (!add_paths) {
add_paths = areCousins(inMPaths[i], inMPaths[i + 1]) == 0;
}
if (!add_paths) {
primo_index++;
} else { //areCousing==0
if (oneof4) {
Expand Down
77 changes: 55 additions & 22 deletions L1Trigger/DTTriggerPhase2/src/MuonPathAssociator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void MuonPathAssociator::correlateMPaths(edm::Handle<DTDigiCollection> dtdigis,
int sl1 = 0;
int sl3 = 0;
for (auto SL1metaPrimitive = SL1metaPrimitives.begin(); SL1metaPrimitive != SL1metaPrimitives.end();
++SL1metaPrimitive, sl1++, sl3 = -1) {
++SL1metaPrimitive, sl1++, sl3 = 0) {
if (clean_chi2_correlation_)
at_least_one_correlation = false;
for (auto SL3metaPrimitive = SL3metaPrimitives.begin(); SL3metaPrimitive != SL3metaPrimitives.end();
Expand Down Expand Up @@ -375,7 +375,7 @@ void MuonPathAssociator::correlateMPaths(edm::Handle<DTDigiCollection> dtdigis,
for (const auto &dtLayerId_It : *dtdigis) {
const DTLayerId dtLId = dtLayerId_It.first;
// creating a new DTSuperLayerId object to compare with the required SL id
const DTSuperLayerId dtSLId(dtLId.wheel(), dtLId.station(), dtLId.sector(), 3);
const DTSuperLayerId dtSLId(dtLId.wheel(), dtLId.station(), dtLId.sector(), dtLId.superLayer());
if (dtSLId.rawId() != sl3Id.rawId())
continue;
double l_shift = 0;
Expand All @@ -390,6 +390,8 @@ void MuonPathAssociator::correlateMPaths(edm::Handle<DTDigiCollection> dtdigis,
double x_inSL3 = SL1metaPrimitive->x - SL1metaPrimitive->tanPhi * (VERT_PHI1_PHI3 + l_shift);
for (auto digiIt = (dtLayerId_It.second).first; digiIt != (dtLayerId_It.second).second; ++digiIt) {
DTWireId wireId(dtLId, (*digiIt).wire());
if ((*digiIt).time() < SL1metaPrimitive->t0)
continue;
double x_wire =
shiftinfo_[wireId.rawId()] + ((*digiIt).time() - SL1metaPrimitive->t0) * DRIFT_SPEED / 10.;
double x_wire_left =
Expand All @@ -400,25 +402,39 @@ void MuonPathAssociator::correlateMPaths(edm::Handle<DTDigiCollection> dtdigis,
lat = 0;
}
if (std::abs(x_inSL3 - x_wire) < minx) {
min2x = minx;
minx = std::abs(x_inSL3 - x_wire);
next_wire = best_wire;
next_tdc = best_tdc;
next_layer = best_layer;
next_lat = best_lat;

// different layer than the stored in best, hit added, matched_digis++;. This approach in somewhat
// buggy, as we could have stored as best LayerX -> LayerY -> LayerX, and this should
// count only as 2 hits. However, as we confirm with at least 2 hits, having 2 or more
// makes no difference
if (dtLId.layer() != best_layer) {
minx = std::abs(x_inSL3 - x_wire);
next_wire = best_wire;
next_tdc = best_tdc;
next_layer = best_layer;
next_lat = best_lat;
matched_digis++;
}
best_wire = (*digiIt).wire();
best_tdc = (*digiIt).time();
best_layer = dtLId.layer();
best_lat = lat;
matched_digis++;

} else if ((std::abs(x_inSL3 - x_wire) >= minx) && (std::abs(x_inSL3 - x_wire) < min2x)) {
// same layer than the stored in best, no hit added
if (dtLId.layer() == best_layer)
continue;
// different layer than the stored in next, hit added. This approach in somewhat
// buggy, as we could have stored as next LayerX -> LayerY -> LayerX, and this should
// count only as 2 hits. However, as we confirm with at least 2 hits, having 2 or more
// makes no difference
matched_digis++;
// whether the layer is the same for this hit and the stored in next, we substitute
// the one stored and modify the min distance
min2x = std::abs(x_inSL3 - x_wire);
next_wire = (*digiIt).wire();
next_tdc = (*digiIt).time();
next_layer = dtLId.layer();
next_lat = lat;
matched_digis++;
}
}
}
Expand Down Expand Up @@ -587,7 +603,7 @@ void MuonPathAssociator::correlateMPaths(edm::Handle<DTDigiCollection> dtdigis,
for (const auto &dtLayerId_It : *dtdigis) {
const DTLayerId dtLId = dtLayerId_It.first;
// creating a new DTSuperLayerId object to compare with the required SL id
const DTSuperLayerId dtSLId(dtLId.wheel(), dtLId.station(), dtLId.sector(), 1);
const DTSuperLayerId dtSLId(dtLId.wheel(), dtLId.station(), dtLId.sector(), dtLId.superLayer());
if (dtSLId.rawId() != sl1Id.rawId())
continue;
double l_shift = 0;
Expand All @@ -602,6 +618,8 @@ void MuonPathAssociator::correlateMPaths(edm::Handle<DTDigiCollection> dtdigis,
double x_inSL1 = SL3metaPrimitive->x + SL3metaPrimitive->tanPhi * (VERT_PHI1_PHI3 - l_shift);
for (auto digiIt = (dtLayerId_It.second).first; digiIt != (dtLayerId_It.second).second; ++digiIt) {
DTWireId wireId(dtLId, (*digiIt).wire());
if ((*digiIt).time() < SL3metaPrimitive->t0)
continue;
double x_wire =
shiftinfo_[wireId.rawId()] + ((*digiIt).time() - SL3metaPrimitive->t0) * DRIFT_SPEED / 10.;
double x_wire_left =
Expand All @@ -612,24 +630,38 @@ void MuonPathAssociator::correlateMPaths(edm::Handle<DTDigiCollection> dtdigis,
lat = 0;
}
if (std::abs(x_inSL1 - x_wire) < minx) {
minx = std::abs(x_inSL1 - x_wire);
next_wire = best_wire;
next_tdc = best_tdc;
next_layer = best_layer;
next_lat = best_lat;

// different layer than the stored in best, hit added, matched_digis++;. This approach in somewhat
// buggy, as we could have stored as best LayerX -> LayerY -> LayerX, and this should
// count only as 2 hits. However, as we confirm with at least 2 hits, having 2 or more
// makes no difference
if (dtLId.layer() != best_layer) {
minx = std::abs(x_inSL1 - x_wire);
next_wire = best_wire;
next_tdc = best_tdc;
next_layer = best_layer;
next_lat = best_lat;
matched_digis++;
}
best_wire = (*digiIt).wire();
best_tdc = (*digiIt).time();
best_layer = dtLId.layer();
best_lat = lat;
matched_digis++;
} else if ((std::abs(x_inSL1 - x_wire) >= minx) && (std::abs(x_inSL1 - x_wire) < min2x)) {
minx = std::abs(x_inSL1 - x_wire);
// same layer than the stored in best, no hit added
if (dtLId.layer() == best_layer)
continue;
// different layer than the stored in next, hit added. This approach in somewhat
// buggy, as we could have stored as next LayerX -> LayerY -> LayerX, and this should
// count only as 2 hits. However, as we confirm with at least 2 hits, having 2 or more
// makes no difference
matched_digis++;
// whether the layer is the same for this hit and the stored in next, we substitute
// the one stored and modify the min distance
min2x = std::abs(x_inSL1 - x_wire);
next_wire = (*digiIt).wire();
next_tdc = (*digiIt).time();
next_layer = dtLId.layer();
next_lat = lat;
matched_digis++;
}
}
}
Expand Down Expand Up @@ -939,7 +971,8 @@ void MuonPathAssociator::correlateMPaths(edm::Handle<DTDigiCollection> dtdigis,
for (auto metaprimitiveIt = inMPaths.begin(); metaprimitiveIt != inMPaths.end(); ++metaprimitiveIt)
if (metaprimitiveIt->rawId == sl2Id.rawId()) {
SL2metaPrimitives.push_back(*metaprimitiveIt);
printmPC(*metaprimitiveIt);
if (debug_)
printmPC(*metaprimitiveIt);
outMPaths.push_back(*metaprimitiveIt);
}
}
Expand Down

0 comments on commit 64b3862

Please sign in to comment.