Skip to content

Commit

Permalink
Fix primos filter and added back good confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimeleonh committed Sep 15, 2022
1 parent cfba562 commit 95379ec
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 33 deletions.
10 changes: 7 additions & 3 deletions L1Trigger/DTTriggerPhase2/src/MPQualityEnhancerFilter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,13 @@ void MPQualityEnhancerFilter::filterCousins(std::vector<metaPrimitive> &inMPaths
bestI = i;
}
}
if (areCousins(inMPaths[i], inMPaths[i + 1]) != 0) {
primo_index++;
} else { //areCousing==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) {
outMPaths.push_back(inMPaths[bestI]);
bestI = -1;
Expand Down
106 changes: 76 additions & 30 deletions L1Trigger/DTTriggerPhase2/src/MuonPathAssociator.cc
Original file line number Diff line number Diff line change
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 @@ -398,27 +400,47 @@ void MuonPathAssociator::correlateMPaths(edm::Handle<DTDigiCollection> dtdigis,
if (std::abs(x_inSL3 - x_wire) > std::abs(x_inSL3 - x_wire_left)) {
x_wire = x_wire_left; //choose the closest laterality
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;

best_wire = (*digiIt).wire();
best_tdc = (*digiIt).time();
best_layer = dtLId.layer();
best_lat = lat;
matched_digis++;
// 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;

best_wire = (*digiIt).wire();
best_tdc = (*digiIt).time();
best_layer = dtLId.layer();
best_lat = lat;
matched_digis++;
} else if (dtLId.layer() == best_layer) { // same layer than stored, just substituting the hit, no matched_digis++;
best_wire = (*digiIt).wire();
best_tdc = (*digiIt).time();
best_layer = dtLId.layer();
best_lat = lat;
}
} 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
else if (dtLId.layer() != next_layer)
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 +609,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 +624,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 +636,45 @@ 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;

best_wire = (*digiIt).wire();
best_tdc = (*digiIt).time();
best_layer = dtLId.layer();
best_lat = lat;
matched_digis++;
// 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;

best_wire = (*digiIt).wire();
best_tdc = (*digiIt).time();
best_layer = dtLId.layer();
best_lat = lat;
matched_digis++;
} else if (dtLId.layer() == best_layer) { // same layer than stored, just substituting the hit, no matched_digis++;
best_wire = (*digiIt).wire();
best_tdc = (*digiIt).time();
best_layer = dtLId.layer();
best_lat = lat;
}
} 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
else if (dtLId.layer() != next_layer)
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 +984,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 95379ec

Please sign in to comment.