diff --git a/Alignment/CommonAlignment/python/tools/trackselectionRefitting.py b/Alignment/CommonAlignment/python/tools/trackselectionRefitting.py index 064c6d9418fb1..948f56d12aee0 100644 --- a/Alignment/CommonAlignment/python/tools/trackselectionRefitting.py +++ b/Alignment/CommonAlignment/python/tools/trackselectionRefitting.py @@ -147,7 +147,8 @@ def getSequence(process, collection, if collection in ("ALCARECOTkAlMinBias", "generalTracks", "ALCARECOTkAlMinBiasHI", "hiGeneralTracks", - "ALCARECOTkAlJetHT", "ALCARECOTkAlDiMuonVertexTracks"): + "ALCARECOTkAlJetHT", "ALCARECOTkAlDiMuonVertexTracks", + "hltMergedTracks"): options["TrackSelector"]["Alignment"].update({ "ptMin": 1.0, "pMin": 8., diff --git a/RecoTracker/FinalTrackSelectors/plugins/TrackerTrackHitFilter.cc b/RecoTracker/FinalTrackSelectors/plugins/TrackerTrackHitFilter.cc index 92e9f5e0f832f..c6341cd9d19a2 100644 --- a/RecoTracker/FinalTrackSelectors/plugins/TrackerTrackHitFilter.cc +++ b/RecoTracker/FinalTrackSelectors/plugins/TrackerTrackHitFilter.cc @@ -2,6 +2,7 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Utilities/interface/TypeDemangler.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -801,6 +802,7 @@ namespace reco { //check that hit is in a det belonging to a subdet where we decided to apply a S/N cut const std::type_info &type = typeid(*therechit); const SiStripCluster *cluster; + std::optional stereo_cluster; if (type == typeid(SiStripRecHit2D)) { const SiStripRecHit2D *hit = dynamic_cast(therechit); if (hit != nullptr) @@ -821,26 +823,64 @@ namespace reco { << "(detID=" << id.rawId() << ")\n "; keepthishit = false; } - } - //the following two cases should not happen anymore since CMSSW > 2_0_X because of hit splitting in stereo modules - //const SiStripMatchedRecHit2D* matchedhit = dynamic_cast(therechit); - //const ProjectedSiStripRecHit2D* unmatchedhit = dynamic_cast(therechit); - else { + } else if (type == typeid(SiStripMatchedRecHit2D)) { + const SiStripMatchedRecHit2D *hit = dynamic_cast(therechit); + if (hit != nullptr) { + cluster = &(hit->monoCluster()); + stereo_cluster = &(hit->stereoCluster()); + } else { + edm::LogError("TrackerTrackHitFilter") + << "TrackerTrackHitFilter::checkStoN : Unknown valid tracker hit in subdet " << id.subdetId() + << "(detID=" << id.rawId() << ")\n "; + keepthishit = false; + } + } else if (type == typeid(ProjectedSiStripRecHit2D)) { + const ProjectedSiStripRecHit2D *hit = dynamic_cast(therechit); + if (hit != nullptr) + cluster = &*(hit->cluster()); + else { + edm::LogError("TrackerTrackHitFilter") + << "TrackerTrackHitFilter::checkStoN : Unknown valid tracker hit in subdet " << id.subdetId() + << "(detID=" << id.rawId() << ")\n "; + keepthishit = false; + } + } else { throw cms::Exception("Unknown RecHit Type") - << "RecHit of type " << type.name() << " not supported. (use c++filt to demangle the name)"; + << "RecHit of type " << edm::typeDemangle(type.name()) << " not supported."; } if (keepthishit) { - siStripClusterInfo_->setCluster(*cluster, id.rawId()); - if ((subdetStoNlowcut_[subdet_cnt - 1] > 0) && - (siStripClusterInfo_->signalOverNoise() < subdetStoNlowcut_[subdet_cnt - 1])) + double sToNlowCut = subdetStoNlowcut_[subdet_cnt - 1]; + double sToNhighCut = subdetStoNhighcut_[subdet_cnt - 1]; + + float sOverN{-1.f}; + + if UNLIKELY (stereo_cluster.has_value()) { + const auto &matched = dynamic_cast(therechit); + if (!matched) { + throw cms::Exception("LogicError") + << "expected a SiStripMatchedRecHit2D but could not cast!" << std::endl; + } + siStripClusterInfo_->setCluster(*cluster, matched->monoId()); + sOverN = siStripClusterInfo_->signalOverNoise(); + // if it's matched rechit, use the average of stereo and mono clusters + siStripClusterInfo_->setCluster(**stereo_cluster, matched->stereoId()); + sOverN += siStripClusterInfo_->signalOverNoise(); + sOverN *= 0.5f; + } else { + siStripClusterInfo_->setCluster(*cluster, id.rawId()); + sOverN = siStripClusterInfo_->signalOverNoise(); + } + + if ((sToNlowCut > 0) && (sOverN < sToNlowCut)) { keepthishit = false; - if ((subdetStoNhighcut_[subdet_cnt - 1] > 0) && - (siStripClusterInfo_->signalOverNoise() > subdetStoNhighcut_[subdet_cnt - 1])) + } + + if ((sToNhighCut > 0) && (sOverN > sToNhighCut)) { keepthishit = false; + } //if(!keepthishit)std::cout<<"Hit rejected because of bad S/N: "<signalOverNoise()<2