From 8e3de6568ee2a4d2b6141d8463689274fd12e0a0 Mon Sep 17 00:00:00 2001 From: mmusich Date: Tue, 29 Oct 2024 16:59:12 +0100 Subject: [PATCH 1/3] Introduce AlignmentGoodIdMuonSelector --- .../plugins/AlignmentGoodIdMuonSelector.cc | 127 ++++++++++++++++++ .../plugins/BuildFile.xml | 5 + 2 files changed, 132 insertions(+) create mode 100644 Alignment/CommonAlignmentProducer/plugins/AlignmentGoodIdMuonSelector.cc diff --git a/Alignment/CommonAlignmentProducer/plugins/AlignmentGoodIdMuonSelector.cc b/Alignment/CommonAlignmentProducer/plugins/AlignmentGoodIdMuonSelector.cc new file mode 100644 index 0000000000000..9f517fae07b58 --- /dev/null +++ b/Alignment/CommonAlignmentProducer/plugins/AlignmentGoodIdMuonSelector.cc @@ -0,0 +1,127 @@ +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "DataFormats/Common/interface/Handle.h" +#include "DataFormats/MuonReco/interface/Muon.h" +#include "DataFormats/MuonReco/interface/MuonFwd.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/global/EDFilter.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" + +class AlignmentGoodIdMuonSelector : public edm::global::EDFilter<> { +public: + explicit AlignmentGoodIdMuonSelector(const edm::ParameterSet&); + ~AlignmentGoodIdMuonSelector() override = default; + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +private: + bool filter(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; + + const edm::EDGetTokenT muonToken_; + const double maxEta_; + const double maxChi2_; + const int minMuonHits_; + const int minMatches_; + const bool requireGlobal_; + const bool requireTracker_; + const bool filterEvents_; // flag to control event filtering behavior + + // Secondary selection parameters (e.g., for Phase 2) + const bool useSecondarySelection_; + const double secondaryEtaLow_; + const double secondaryEtaHigh_; + const int secondaryMinMatches_; + const bool requireTrackerForSecondary_; +}; + +void AlignmentGoodIdMuonSelector::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("src", edm::InputTag("muons"))->setComment("Input muon collection"); + desc.add("maxEta", 2.5)->setComment("|eta| cut"); + desc.add("maxChi2", 20.)->setComment("max chi2 of the global tags"); + desc.add("minMuonHits", 0.)->setComment("minimum number of valid muon hits"); + desc.add("minMatches", 1.)->setComment("minimum number of matches"); + desc.add("requireGlobal", true)->setComment("is global muons"); + desc.add("requireTracker", true)->setComment("is tracker muon"); + desc.add("useSecondarySelection", false)->setComment("secondary selection"); + desc.add("secondaryEtaLow", 2.3)->setComment("min eta cut (secondary)"); + desc.add("secondaryEtaHigh", 3.0)->setComment("max eta cut (secondary)"); + desc.add("secondaryMinMatches", 0.)->setComment("minimum number of matches (secondary)"); + desc.add("secondaryRequireTracker", true)->setComment("is tracker muon (secondary)"); + desc.add("filter", true)->setComment("retain event only if non empty collection"); + descriptions.addWithDefaultLabel(desc); +} + +AlignmentGoodIdMuonSelector::AlignmentGoodIdMuonSelector(const edm::ParameterSet& iConfig) + : muonToken_(consumes(iConfig.getParameter("src"))), + maxEta_(iConfig.getParameter("maxEta")), + maxChi2_(iConfig.getParameter("maxChi2")), + minMuonHits_(iConfig.getParameter("minMuonHits")), + minMatches_(iConfig.getParameter("minMatches")), + requireGlobal_(iConfig.getParameter("requireGlobal")), + requireTracker_(iConfig.getParameter("requireTracker")), + filterEvents_(iConfig.getParameter("filter")), + + // Secondary selection + useSecondarySelection_(iConfig.getParameter("useSecondarySelection")), + secondaryEtaLow_(iConfig.getParameter("secondaryEtaLow")), + secondaryEtaHigh_(iConfig.getParameter("secondaryEtaHigh")), + secondaryMinMatches_(iConfig.getParameter("secondaryMinMatches")), + requireTrackerForSecondary_(iConfig.getParameter("secondaryRequireTracker")) { + produces(); +} + +bool AlignmentGoodIdMuonSelector::filter(edm::StreamID, edm::Event& iEvent, const edm::EventSetup&) const { + edm::Handle muons; + iEvent.getByToken(muonToken_, muons); + + auto selectedMuons = std::make_unique(); + + for (const auto& muon : *muons) { + bool passPrimarySelection = true; + + // Check if globalTrack() is valid before using it + if (requireGlobal_) { + if (!muon.isGlobalMuon() || muon.globalTrack().isNull()) { + passPrimarySelection = false; + } else { + // Only access properties if the global track is valid + if (muon.globalTrack()->hitPattern().numberOfValidMuonHits() <= minMuonHits_) + passPrimarySelection = false; + if (muon.globalTrack()->normalizedChi2() >= maxChi2_) + passPrimarySelection = false; + } + } + + if (requireTracker_ && !muon.isTrackerMuon()) + passPrimarySelection = false; + if (muon.numberOfMatches() <= minMatches_) + passPrimarySelection = false; + if (std::abs(muon.eta()) >= maxEta_) + passPrimarySelection = false; + + bool passSecondarySelection = false; + if (useSecondarySelection_) { + if (std::abs(muon.eta()) > secondaryEtaLow_ && std::abs(muon.eta()) < secondaryEtaHigh_ && + muon.numberOfMatches() >= secondaryMinMatches_ && (!requireTrackerForSecondary_ || muon.isTrackerMuon())) { + passSecondarySelection = true; + } + } + + if (passPrimarySelection || passSecondarySelection) { + selectedMuons->push_back(muon); + } + } + + const bool passEvent = !selectedMuons->empty(); + iEvent.put(std::move(selectedMuons)); + + // Decide if the event should pass based on filterEvents_ flag + return filterEvents_ ? passEvent : true; +} + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(AlignmentGoodIdMuonSelector); diff --git a/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml b/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml index b2b0cbf78dc05..85514a6481a94 100644 --- a/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml +++ b/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml @@ -57,3 +57,8 @@ + + + + + From 2d97abd56f34981d62e260bcc10725662379cd41 Mon Sep 17 00:00:00 2001 From: mmusich Date: Thu, 31 Oct 2024 13:37:39 +0100 Subject: [PATCH 2/3] Introduce AlignmentRelCombIsoMuonSelector --- .../AlignmentRelCombIsoMuonSelector.cc | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 Alignment/CommonAlignmentProducer/plugins/AlignmentRelCombIsoMuonSelector.cc diff --git a/Alignment/CommonAlignmentProducer/plugins/AlignmentRelCombIsoMuonSelector.cc b/Alignment/CommonAlignmentProducer/plugins/AlignmentRelCombIsoMuonSelector.cc new file mode 100644 index 0000000000000..90d5beb69099e --- /dev/null +++ b/Alignment/CommonAlignmentProducer/plugins/AlignmentRelCombIsoMuonSelector.cc @@ -0,0 +1,75 @@ +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "DataFormats/Common/interface/Handle.h" +#include "DataFormats/MuonReco/interface/Muon.h" +#include "DataFormats/MuonReco/interface/MuonFwd.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/global/EDFilter.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" + +class AlignmentRelCombIsoMuonSelector : public edm::global::EDFilter<> { +public: + explicit AlignmentRelCombIsoMuonSelector(const edm::ParameterSet&); + ~AlignmentRelCombIsoMuonSelector() override = default; + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +private: + bool filter(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; + + edm::EDGetTokenT muonToken_; + const double relCombIsoCut_; + const bool useTrackerOnlyIsolation_; // New flag for tracker-only isolation + const bool filterEvents_; +}; + +void AlignmentRelCombIsoMuonSelector::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("src", edm::InputTag("muons"))->setComment("Input muon collection"); + desc.add("relCombIsoCut", 0.15)->setComment("cut on the relative combined isolation"); + desc.add("useTrackerOnlyIsolation", false)->setComment("use only tracker isolation"); + desc.add("filter", true); + descriptions.addWithDefaultLabel(desc); +} + +AlignmentRelCombIsoMuonSelector::AlignmentRelCombIsoMuonSelector(const edm::ParameterSet& iConfig) + : muonToken_(consumes(iConfig.getParameter("src"))), + relCombIsoCut_(iConfig.getParameter("relCombIsoCut")), + useTrackerOnlyIsolation_(iConfig.getParameter("useTrackerOnlyIsolation")), + filterEvents_(iConfig.getParameter("filter")) { + produces(); +} + +bool AlignmentRelCombIsoMuonSelector::filter(edm::StreamID, edm::Event& iEvent, const edm::EventSetup&) const { + edm::Handle muons; + iEvent.getByToken(muonToken_, muons); + + auto selectedMuons = std::make_unique(); + + for (const auto& muon : *muons) { + double relCombIso; + if (useTrackerOnlyIsolation_) { + // Tracker-only isolation + relCombIso = muon.isolationR03().sumPt / muon.pt(); + } else { + // Full combined isolation + relCombIso = (muon.isolationR03().sumPt + muon.isolationR03().emEt + muon.isolationR03().hadEt) / muon.pt(); + } + + if (relCombIso < relCombIsoCut_) { + selectedMuons->push_back(muon); + } + } + + const bool passEvent = !selectedMuons->empty(); + iEvent.put(std::move(selectedMuons)); + + // Apply the filter flag logic + return filterEvents_ ? passEvent : true; +} + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(AlignmentRelCombIsoMuonSelector); From b9162110d7fe81501c9afe833e8241a951d013d5 Mon Sep 17 00:00:00 2001 From: mmusich Date: Thu, 31 Oct 2024 15:11:42 +0100 Subject: [PATCH 3/3] TkAlMuonSelectors_cfi: replace MuonSelector that express the structure of the selection in C++ code - replace in 4 ALCARECO producers separated configuration with a common block: TkAlGoodIdMuonSelector+TkAlRelCombIsoMuonSelector --- .../python/ALCARECOTkAlDiMuonAndVertex_cff.py | 8 +-- .../python/ALCARECOTkAlMuonIsolated_cff.py | 14 ++--- .../python/ALCARECOTkAlUpsilonMuMu_cff.py | 6 +- .../python/ALCARECOTkAlZMuMuPA_cff.py | 4 +- .../python/ALCARECOTkAlZMuMu_cff.py | 15 ++--- .../python/TkAlMuonSelectors_cfi.py | 59 ++++++++++++------- .../ALCARECOSiPixelCalSingleMuonTight_cff.py | 11 +--- 7 files changed, 61 insertions(+), 56 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/python/ALCARECOTkAlDiMuonAndVertex_cff.py b/Alignment/CommonAlignmentProducer/python/ALCARECOTkAlDiMuonAndVertex_cff.py index e1485c4fc2cab..0563367fe87df 100644 --- a/Alignment/CommonAlignmentProducer/python/ALCARECOTkAlDiMuonAndVertex_cff.py +++ b/Alignment/CommonAlignmentProducer/python/ALCARECOTkAlDiMuonAndVertex_cff.py @@ -3,13 +3,12 @@ ################################################################## # Exact same configuration as TkAlZMuMu: extract mumu pairs ################################################################# +from Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi import * import Alignment.CommonAlignmentProducer.ALCARECOTkAlZMuMu_cff as confALCARECOTkAlZMuMu ALCARECOTkAlDiMuonHLT = confALCARECOTkAlZMuMu.ALCARECOTkAlZMuMuHLT.clone() ALCARECOTkAlDiMuonDCSFilter = confALCARECOTkAlZMuMu.ALCARECOTkAlZMuMuDCSFilter.clone() -ALCARECOTkAlDiMuonGoodMuons = confALCARECOTkAlZMuMu.ALCARECOTkAlZMuMuGoodMuons.clone() -ALCARECOTkAlDiMuonRelCombIsoMuons = confALCARECOTkAlZMuMu.ALCARECOTkAlZMuMuRelCombIsoMuons.clone(src = 'ALCARECOTkAlDiMuonGoodMuons') ALCARECOTkAlDiMuon = confALCARECOTkAlZMuMu.ALCARECOTkAlZMuMu.clone() -ALCARECOTkAlDiMuon.GlobalSelector.muonSource = 'ALCARECOTkAlDiMuonRelCombIsoMuons' +ALCARECOTkAlDiMuon.GlobalSelector.muonSource = 'TkAlRelCombIsoMuonSelector' ################################################################## # Tracks from the selected vertex @@ -31,8 +30,7 @@ ################################################################# seqALCARECOTkAlDiMuonAndVertex = cms.Sequence(ALCARECOTkAlDiMuonHLT+ ALCARECOTkAlDiMuonDCSFilter+ - ALCARECOTkAlDiMuonGoodMuons+ - ALCARECOTkAlDiMuonRelCombIsoMuons+ + seqALCARECOTkAlRelCombIsoMuons+ ALCARECOTkAlDiMuon+ ALCARECOTkAlDiMuonVertexTracks+ TkAlDiMuonAndVertexGenMuonSelector) diff --git a/Alignment/CommonAlignmentProducer/python/ALCARECOTkAlMuonIsolated_cff.py b/Alignment/CommonAlignmentProducer/python/ALCARECOTkAlMuonIsolated_cff.py index 4393f1431a1d1..e4aa7cdbe9e7a 100644 --- a/Alignment/CommonAlignmentProducer/python/ALCARECOTkAlMuonIsolated_cff.py +++ b/Alignment/CommonAlignmentProducer/python/ALCARECOTkAlMuonIsolated_cff.py @@ -21,11 +21,7 @@ DebugOn = cms.untracked.bool(False) ) -import Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi -ALCARECOTkAlMuonIsolatedGoodMuons = Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi.TkAlGoodIdMuonSelector.clone() -ALCARECOTkAlMuonIsolatedRelCombIsoMuons = Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi.TkAlRelCombIsoMuonSelector.clone( - src = 'ALCARECOTkAlMuonIsolatedGoodMuons' -) +from Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi import * import Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi ALCARECOTkAlMuonIsolated = Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi.AlignmentTrackSelector.clone( @@ -37,7 +33,7 @@ nHitMin = 0 ) -ALCARECOTkAlMuonIsolated.GlobalSelector.muonSource = 'ALCARECOTkAlMuonIsolatedRelCombIsoMuons' +ALCARECOTkAlMuonIsolated.GlobalSelector.muonSource = 'TkAlRelCombIsoMuonSelector' # Isolation is shifted to the muon preselection, and then applied intrinsically if applyGlobalMuonFilter = True ALCARECOTkAlMuonIsolated.GlobalSelector.applyIsolationtest = False ALCARECOTkAlMuonIsolated.GlobalSelector.minJetDeltaR = 0.1 @@ -47,8 +43,10 @@ ALCARECOTkAlMuonIsolated.TwoBodyDecaySelector.applyChargeFilter = False ALCARECOTkAlMuonIsolated.TwoBodyDecaySelector.applyAcoplanarityFilter = False -seqALCARECOTkAlMuonIsolated = cms.Sequence(ALCARECOTkAlMuonIsolatedHLT+ALCARECOTkAlMuonIsolatedDCSFilter+ALCARECOTkAlMuonIsolatedGoodMuons+ALCARECOTkAlMuonIsolatedRelCombIsoMuons+ALCARECOTkAlMuonIsolated) - +seqALCARECOTkAlMuonIsolated = cms.Sequence(ALCARECOTkAlMuonIsolatedHLT+ + ALCARECOTkAlMuonIsolatedDCSFilter+ + seqALCARECOTkAlRelCombIsoMuons+ + ALCARECOTkAlMuonIsolated) ## customizations for the pp_on_AA eras from Configuration.Eras.Modifier_pp_on_XeXe_2017_cff import pp_on_XeXe_2017 diff --git a/Alignment/CommonAlignmentProducer/python/ALCARECOTkAlUpsilonMuMu_cff.py b/Alignment/CommonAlignmentProducer/python/ALCARECOTkAlUpsilonMuMu_cff.py index 9bb702e7f42cc..173e86124bbc3 100644 --- a/Alignment/CommonAlignmentProducer/python/ALCARECOTkAlUpsilonMuMu_cff.py +++ b/Alignment/CommonAlignmentProducer/python/ALCARECOTkAlUpsilonMuMu_cff.py @@ -23,11 +23,7 @@ import Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi ALCARECOTkAlUpsilonMuMuGoodMuons = Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi.TkAlGoodIdMuonSelector.clone() -ALCARECOTkAlUpsilonMuMuRelCombIsoMuons = Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi.TkAlRelCombIsoMuonSelector.clone( - src = 'ALCARECOTkAlUpsilonMuMuGoodMuons', - cut = '(isolationR03().sumPt + isolationR03().emEt + isolationR03().hadEt)/pt < 0.3' - -) +ALCARECOTkAlUpsilonMuMuRelCombIsoMuons = Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi.TkAlRelCombIsoMuonSelector.clone(src = 'ALCARECOTkAlUpsilonMuMuGoodMuons') import Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi ALCARECOTkAlUpsilonMuMu = Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi.AlignmentTrackSelector.clone() diff --git a/Alignment/CommonAlignmentProducer/python/ALCARECOTkAlZMuMuPA_cff.py b/Alignment/CommonAlignmentProducer/python/ALCARECOTkAlZMuMuPA_cff.py index 2f81e70a76848..87189ff5ebdb2 100644 --- a/Alignment/CommonAlignmentProducer/python/ALCARECOTkAlZMuMuPA_cff.py +++ b/Alignment/CommonAlignmentProducer/python/ALCARECOTkAlZMuMuPA_cff.py @@ -9,7 +9,7 @@ ALCARECOTkAlZMuMuPADCSFilter = ALCARECOTkAlZMuMuDCSFilter.clone() -ALCARECOTkAlZMuMuPAGoodMuons = ALCARECOTkAlZMuMuGoodMuons.clone() +ALCARECOTkAlZMuMuPAGoodMuons = TkAlGoodIdMuonSelector.clone() ALCARECOTkAlZMuMuPA = ALCARECOTkAlZMuMu.clone( src = 'generalTracks' @@ -18,6 +18,6 @@ seqALCARECOTkAlZMuMuPA = cms.Sequence(ALCARECOTkAlZMuMuPAHLT +ALCARECOTkAlZMuMuPADCSFilter - +ALCARECOTkAlZMuMuPAGoodMuons + +TkAlGoodIdMuonSelector +ALCARECOTkAlZMuMuPA ) diff --git a/Alignment/CommonAlignmentProducer/python/ALCARECOTkAlZMuMu_cff.py b/Alignment/CommonAlignmentProducer/python/ALCARECOTkAlZMuMu_cff.py index c421902c2e144..8be81d15c61c0 100644 --- a/Alignment/CommonAlignmentProducer/python/ALCARECOTkAlZMuMu_cff.py +++ b/Alignment/CommonAlignmentProducer/python/ALCARECOTkAlZMuMu_cff.py @@ -21,11 +21,8 @@ DebugOn = cms.untracked.bool(False) ) -import Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi -ALCARECOTkAlZMuMuGoodMuons = Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi.TkAlGoodIdMuonSelector.clone() -ALCARECOTkAlZMuMuRelCombIsoMuons = Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi.TkAlRelCombIsoMuonSelector.clone( - src = 'ALCARECOTkAlZMuMuGoodMuons' -) +## standard muon selection +from Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi import * import Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi ALCARECOTkAlZMuMu = Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi.AlignmentTrackSelector.clone() @@ -37,7 +34,7 @@ ALCARECOTkAlZMuMu.etaMax = 3.5 ALCARECOTkAlZMuMu.nHitMin = 0 -ALCARECOTkAlZMuMu.GlobalSelector.muonSource = 'ALCARECOTkAlZMuMuRelCombIsoMuons' +ALCARECOTkAlZMuMu.GlobalSelector.muonSource = 'TkAlRelCombIsoMuonSelector' # Isolation is shifted to the muon preselection, and then applied intrinsically if applyGlobalMuonFilter = True ALCARECOTkAlZMuMu.GlobalSelector.applyIsolationtest = False ALCARECOTkAlZMuMu.GlobalSelector.applyGlobalMuonFilter = True @@ -58,7 +55,11 @@ filter = cms.bool(False), throwOnMissing = cms.untracked.bool(False)) -seqALCARECOTkAlZMuMu = cms.Sequence(ALCARECOTkAlZMuMuHLT+ALCARECOTkAlZMuMuDCSFilter+ALCARECOTkAlZMuMuGoodMuons+ALCARECOTkAlZMuMuRelCombIsoMuons+ALCARECOTkAlZMuMu+TkAlZMuMuGenMuonSelector) +seqALCARECOTkAlZMuMu = cms.Sequence(ALCARECOTkAlZMuMuHLT+ + ALCARECOTkAlZMuMuDCSFilter+ + seqALCARECOTkAlRelCombIsoMuons+ + ALCARECOTkAlZMuMu+ + TkAlZMuMuGenMuonSelector) ## customizations for the pp_on_AA eras from Configuration.Eras.Modifier_pp_on_XeXe_2017_cff import pp_on_XeXe_2017 diff --git a/Alignment/CommonAlignmentProducer/python/TkAlMuonSelectors_cfi.py b/Alignment/CommonAlignmentProducer/python/TkAlMuonSelectors_cfi.py index 1999a479cb05b..c1d340a9b9f00 100644 --- a/Alignment/CommonAlignmentProducer/python/TkAlMuonSelectors_cfi.py +++ b/Alignment/CommonAlignmentProducer/python/TkAlMuonSelectors_cfi.py @@ -1,31 +1,48 @@ import FWCore.ParameterSet.Config as cms -TkAlGoodIdMuonSelector = cms.EDFilter("MuonSelector", - src = cms.InputTag('muons'), - cut = cms.string('isGlobalMuon &' - 'isTrackerMuon &' - 'numberOfMatches > 1 &' - 'globalTrack.hitPattern.numberOfValidMuonHits > 0 &' - 'abs(eta) < 2.5 &' - 'globalTrack.normalizedChi2 < 20.'), - filter = cms.bool(True) -) - -TkAlRelCombIsoMuonSelector = cms.EDFilter("MuonSelector", - src = cms.InputTag(''), - cut = cms.string('(isolationR03().sumPt + isolationR03().emEt + isolationR03().hadEt)/pt < 0.15'), - filter = cms.bool(True) -) +# original selection: +# 'isGlobalMuon & isTrackerMuon & numberOfMatches > 1 & globalTrack.hitPattern.numberOfValidMuonHits > 0 +# & abs(eta) < 2.5 & globalTrack.normalizedChi2 < 20.' + +from Alignment.CommonAlignmentProducer.alignmentGoodIdMuonSelector_cfi import alignmentGoodIdMuonSelector +TkAlGoodIdMuonSelector = alignmentGoodIdMuonSelector.clone(src = 'muons', + requireGlobal = True, + requireTracker = True, + minMatches = 1, + minMuonHits = 0, + maxEta = 2.5, + maxChi2 = 20, + filter = True) +# original selection: +# '(isolationR03().sumPt + isolationR03().emEt + isolationR03().hadEt)/pt < 0.15' + +from Alignment.CommonAlignmentProducer.alignmentRelCombIsoMuonSelector_cfi import alignmentRelCombIsoMuonSelector +TkAlRelCombIsoMuonSelector = alignmentRelCombIsoMuonSelector.clone(src = cms.InputTag('TkAlGoodIdMuonSelector'), + filter = True, + relCombIsoCut = 0.15, + useTrackerOnlyIsolation = False) + +# Define a common sequence to be imported in ALCARECOs +seqALCARECOTkAlRelCombIsoMuons = cms.Sequence(TkAlGoodIdMuonSelector+TkAlRelCombIsoMuonSelector) ## FIXME: these are needed for ALCARECO production in CMSSW_14_0_X ## to avoid loosing in efficiency. To be reviewed after muon reco is fixed +# original selection: +# '(isGlobalMuon & isTrackerMuon & numberOfMatches > 1 & globalTrack.hitPattern.numberOfValidMuonHits > 0 +# & abs(eta) < 2.5 & globalTrack.normalizedChi2 < 20.) || (abs(eta) > 2.3 & abs(eta) < 3.0 & numberOfMatches >= 0 & isTrackerMuon)' + from Configuration.Eras.Modifier_phase2_common_cff import phase2_common phase2_common.toModify(TkAlGoodIdMuonSelector, - cut = '(abs(eta) < 2.5 & isGlobalMuon & isTrackerMuon & numberOfMatches > 1 & globalTrack.hitPattern.numberOfValidMuonHits > 0 & globalTrack.normalizedChi2 < 20.) ||' # regular selection - '(abs(eta) > 2.3 & abs(eta) < 3.0 & numberOfMatches >= 0 & isTrackerMuon)' # to recover GE0 tracks - ) + useSecondarySelection = True, # to recover tracks passing through GE0 + secondaryEtaLow = 2.3, + secondaryEtaHigh = 3, + secondaryMinMatches = 0, + secondaryRequireTracker = True) + +# original selection: +# '(isolationR03().sumPt)/pt < 0.1' phase2_common.toModify(TkAlRelCombIsoMuonSelector, - cut = '(isolationR03().sumPt)/pt < 0.1' # only tracker isolation - ) + relCombIsoCut = 0.10, + useTrackerOnlyIsolation = True) # only tracker isolation diff --git a/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonTight_cff.py b/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonTight_cff.py index 88e76099e8a53..f911d45491772 100644 --- a/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonTight_cff.py +++ b/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonTight_cff.py @@ -24,11 +24,7 @@ ################################################################## # Isolated muons Track selector ################################################################## -import Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi -ALCARECOSiPixelCalSingleMuonTightGoodMuons = Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi.TkAlGoodIdMuonSelector.clone() -ALCARECOSiPixelCalSingleMuonTightRelCombIsoMuons = Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi.TkAlRelCombIsoMuonSelector.clone( - src = 'ALCARECOSiPixelCalSingleMuonTightGoodMuons' -) +from Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi import * ################################################################## # Basic Track selection @@ -46,7 +42,7 @@ ################################################################## # Muon selection ################################################################## -ALCARECOSiPixelCalSingleMuonTight.GlobalSelector.muonSource = 'ALCARECOSiPixelCalSingleMuonTightRelCombIsoMuons' +ALCARECOSiPixelCalSingleMuonTight.GlobalSelector.muonSource = 'TkAlRelCombIsoMuonSelector' # Isolation is shifted to the muon preselection, and then applied intrinsically if applyGlobalMuonFilter = True ALCARECOSiPixelCalSingleMuonTight.GlobalSelector.applyIsolationtest = False ALCARECOSiPixelCalSingleMuonTight.GlobalSelector.minJetDeltaR = 0.1 @@ -91,8 +87,7 @@ seqALCARECOSiPixelCalSingleMuonTight = cms.Sequence(offlineBeamSpot+ ALCARECOSiPixelCalSingleMuonTightHLTFilter+ ALCARECOSiPixelCalSingleMuonTightDCSFilter+ - ALCARECOSiPixelCalSingleMuonTightGoodMuons+ - ALCARECOSiPixelCalSingleMuonTightRelCombIsoMuons+ + seqALCARECOTkAlRelCombIsoMuons+ ALCARECOSiPixelCalSingleMuonTight+ trackDistances + ALCARECOSiPixelCalSingleMuonTightOffTrackClusters)