diff --git a/L1Trigger/DTTriggerPhase2/src/MPQualityEnhancerFilter.cc b/L1Trigger/DTTriggerPhase2/src/MPQualityEnhancerFilter.cc index 0a76fa7cffa6f..2802ca13a0cbb 100644 --- a/L1Trigger/DTTriggerPhase2/src/MPQualityEnhancerFilter.cc +++ b/L1Trigger/DTTriggerPhase2/src/MPQualityEnhancerFilter.cc @@ -120,9 +120,13 @@ void MPQualityEnhancerFilter::filterCousins(std::vector &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; diff --git a/L1Trigger/DTTriggerPhase2/src/MuonPathAssociator.cc b/L1Trigger/DTTriggerPhase2/src/MuonPathAssociator.cc index 7c4e3560aeb9a..dddc6e3f229c1 100644 --- a/L1Trigger/DTTriggerPhase2/src/MuonPathAssociator.cc +++ b/L1Trigger/DTTriggerPhase2/src/MuonPathAssociator.cc @@ -375,7 +375,7 @@ void MuonPathAssociator::correlateMPaths(edm::Handle 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; @@ -390,6 +390,8 @@ void MuonPathAssociator::correlateMPaths(edm::Handle 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 = @@ -398,27 +400,47 @@ void MuonPathAssociator::correlateMPaths(edm::Handle 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++; } } } @@ -587,7 +609,7 @@ void MuonPathAssociator::correlateMPaths(edm::Handle 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; @@ -602,6 +624,8 @@ void MuonPathAssociator::correlateMPaths(edm::Handle 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 = @@ -612,24 +636,45 @@ void MuonPathAssociator::correlateMPaths(edm::Handle 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++; } } } @@ -939,7 +984,8 @@ void MuonPathAssociator::correlateMPaths(edm::Handle 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); } }