Skip to content

Commit 2181e6a

Browse files
authored
Merge branch 'master' into CMSSW_14_1_X_CaloParams_2024_v0_0
2 parents 83ebe1b + 92333e3 commit 2181e6a

File tree

1,014 files changed

+77850
-10685
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,014 files changed

+77850
-10685
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
#include "FWCore/Framework/interface/Event.h"
2+
#include "FWCore/Framework/interface/EventSetup.h"
3+
#include "DataFormats/Common/interface/Handle.h"
4+
#include "DataFormats/MuonReco/interface/Muon.h"
5+
#include "DataFormats/MuonReco/interface/MuonFwd.h"
6+
#include "FWCore/Framework/interface/Frameworkfwd.h"
7+
#include "FWCore/Framework/interface/global/EDFilter.h"
8+
#include "FWCore/ParameterSet/interface/ParameterSet.h"
9+
#include "FWCore/MessageLogger/interface/MessageLogger.h"
10+
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
11+
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
12+
13+
class AlignmentGoodIdMuonSelector : public edm::global::EDFilter<> {
14+
public:
15+
explicit AlignmentGoodIdMuonSelector(const edm::ParameterSet&);
16+
~AlignmentGoodIdMuonSelector() override = default;
17+
18+
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
19+
20+
private:
21+
bool filter(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
22+
23+
const edm::EDGetTokenT<reco::MuonCollection> muonToken_;
24+
const double maxEta_;
25+
const double maxChi2_;
26+
const int minMuonHits_;
27+
const int minMatches_;
28+
const bool requireGlobal_;
29+
const bool requireTracker_;
30+
const bool filterEvents_; // flag to control event filtering behavior
31+
32+
// Secondary selection parameters (e.g., for Phase 2)
33+
const bool useSecondarySelection_;
34+
const double secondaryEtaLow_;
35+
const double secondaryEtaHigh_;
36+
const int secondaryMinMatches_;
37+
const bool requireTrackerForSecondary_;
38+
};
39+
40+
void AlignmentGoodIdMuonSelector::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
41+
edm::ParameterSetDescription desc;
42+
desc.add<edm::InputTag>("src", edm::InputTag("muons"))->setComment("Input muon collection");
43+
desc.add<double>("maxEta", 2.5)->setComment("|eta| cut");
44+
desc.add<double>("maxChi2", 20.)->setComment("max chi2 of the global tags");
45+
desc.add<int>("minMuonHits", 0.)->setComment("minimum number of valid muon hits");
46+
desc.add<int>("minMatches", 1.)->setComment("minimum number of matches");
47+
desc.add<bool>("requireGlobal", true)->setComment("is global muons");
48+
desc.add<bool>("requireTracker", true)->setComment("is tracker muon");
49+
desc.add<bool>("useSecondarySelection", false)->setComment("secondary selection");
50+
desc.add<double>("secondaryEtaLow", 2.3)->setComment("min eta cut (secondary)");
51+
desc.add<double>("secondaryEtaHigh", 3.0)->setComment("max eta cut (secondary)");
52+
desc.add<int>("secondaryMinMatches", 0.)->setComment("minimum number of matches (secondary)");
53+
desc.add<bool>("secondaryRequireTracker", true)->setComment("is tracker muon (secondary)");
54+
desc.add<bool>("filter", true)->setComment("retain event only if non empty collection");
55+
descriptions.addWithDefaultLabel(desc);
56+
}
57+
58+
AlignmentGoodIdMuonSelector::AlignmentGoodIdMuonSelector(const edm::ParameterSet& iConfig)
59+
: muonToken_(consumes<reco::MuonCollection>(iConfig.getParameter<edm::InputTag>("src"))),
60+
maxEta_(iConfig.getParameter<double>("maxEta")),
61+
maxChi2_(iConfig.getParameter<double>("maxChi2")),
62+
minMuonHits_(iConfig.getParameter<int>("minMuonHits")),
63+
minMatches_(iConfig.getParameter<int>("minMatches")),
64+
requireGlobal_(iConfig.getParameter<bool>("requireGlobal")),
65+
requireTracker_(iConfig.getParameter<bool>("requireTracker")),
66+
filterEvents_(iConfig.getParameter<bool>("filter")),
67+
68+
// Secondary selection
69+
useSecondarySelection_(iConfig.getParameter<bool>("useSecondarySelection")),
70+
secondaryEtaLow_(iConfig.getParameter<double>("secondaryEtaLow")),
71+
secondaryEtaHigh_(iConfig.getParameter<double>("secondaryEtaHigh")),
72+
secondaryMinMatches_(iConfig.getParameter<int>("secondaryMinMatches")),
73+
requireTrackerForSecondary_(iConfig.getParameter<bool>("secondaryRequireTracker")) {
74+
produces<reco::MuonCollection>();
75+
}
76+
77+
bool AlignmentGoodIdMuonSelector::filter(edm::StreamID, edm::Event& iEvent, const edm::EventSetup&) const {
78+
edm::Handle<reco::MuonCollection> muons;
79+
iEvent.getByToken(muonToken_, muons);
80+
81+
auto selectedMuons = std::make_unique<reco::MuonCollection>();
82+
83+
for (const auto& muon : *muons) {
84+
bool passPrimarySelection = true;
85+
86+
// Check if globalTrack() is valid before using it
87+
if (requireGlobal_) {
88+
if (!muon.isGlobalMuon() || muon.globalTrack().isNull()) {
89+
passPrimarySelection = false;
90+
} else {
91+
// Only access properties if the global track is valid
92+
if (muon.globalTrack()->hitPattern().numberOfValidMuonHits() <= minMuonHits_)
93+
passPrimarySelection = false;
94+
if (muon.globalTrack()->normalizedChi2() >= maxChi2_)
95+
passPrimarySelection = false;
96+
}
97+
}
98+
99+
if (requireTracker_ && !muon.isTrackerMuon())
100+
passPrimarySelection = false;
101+
if (muon.numberOfMatches() <= minMatches_)
102+
passPrimarySelection = false;
103+
if (std::abs(muon.eta()) >= maxEta_)
104+
passPrimarySelection = false;
105+
106+
bool passSecondarySelection = false;
107+
if (useSecondarySelection_) {
108+
if (std::abs(muon.eta()) > secondaryEtaLow_ && std::abs(muon.eta()) < secondaryEtaHigh_ &&
109+
muon.numberOfMatches() >= secondaryMinMatches_ && (!requireTrackerForSecondary_ || muon.isTrackerMuon())) {
110+
passSecondarySelection = true;
111+
}
112+
}
113+
114+
if (passPrimarySelection || passSecondarySelection) {
115+
selectedMuons->push_back(muon);
116+
}
117+
}
118+
119+
const bool passEvent = !selectedMuons->empty();
120+
iEvent.put(std::move(selectedMuons));
121+
122+
// Decide if the event should pass based on filterEvents_ flag
123+
return filterEvents_ ? passEvent : true;
124+
}
125+
126+
#include "FWCore/Framework/interface/MakerMacros.h"
127+
DEFINE_FWK_MODULE(AlignmentGoodIdMuonSelector);
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#include "FWCore/Framework/interface/Event.h"
2+
#include "FWCore/Framework/interface/EventSetup.h"
3+
#include "DataFormats/Common/interface/Handle.h"
4+
#include "DataFormats/MuonReco/interface/Muon.h"
5+
#include "DataFormats/MuonReco/interface/MuonFwd.h"
6+
#include "FWCore/Framework/interface/Frameworkfwd.h"
7+
#include "FWCore/Framework/interface/global/EDFilter.h"
8+
#include "FWCore/ParameterSet/interface/ParameterSet.h"
9+
#include "FWCore/MessageLogger/interface/MessageLogger.h"
10+
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
11+
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
12+
13+
class AlignmentRelCombIsoMuonSelector : public edm::global::EDFilter<> {
14+
public:
15+
explicit AlignmentRelCombIsoMuonSelector(const edm::ParameterSet&);
16+
~AlignmentRelCombIsoMuonSelector() override = default;
17+
18+
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
19+
20+
private:
21+
bool filter(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
22+
23+
edm::EDGetTokenT<reco::MuonCollection> muonToken_;
24+
const double relCombIsoCut_;
25+
const bool useTrackerOnlyIsolation_; // New flag for tracker-only isolation
26+
const bool filterEvents_;
27+
};
28+
29+
void AlignmentRelCombIsoMuonSelector::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
30+
edm::ParameterSetDescription desc;
31+
desc.add<edm::InputTag>("src", edm::InputTag("muons"))->setComment("Input muon collection");
32+
desc.add<double>("relCombIsoCut", 0.15)->setComment("cut on the relative combined isolation");
33+
desc.add<bool>("useTrackerOnlyIsolation", false)->setComment("use only tracker isolation");
34+
desc.add<bool>("filter", true);
35+
descriptions.addWithDefaultLabel(desc);
36+
}
37+
38+
AlignmentRelCombIsoMuonSelector::AlignmentRelCombIsoMuonSelector(const edm::ParameterSet& iConfig)
39+
: muonToken_(consumes<reco::MuonCollection>(iConfig.getParameter<edm::InputTag>("src"))),
40+
relCombIsoCut_(iConfig.getParameter<double>("relCombIsoCut")),
41+
useTrackerOnlyIsolation_(iConfig.getParameter<bool>("useTrackerOnlyIsolation")),
42+
filterEvents_(iConfig.getParameter<bool>("filter")) {
43+
produces<reco::MuonCollection>();
44+
}
45+
46+
bool AlignmentRelCombIsoMuonSelector::filter(edm::StreamID, edm::Event& iEvent, const edm::EventSetup&) const {
47+
edm::Handle<reco::MuonCollection> muons;
48+
iEvent.getByToken(muonToken_, muons);
49+
50+
auto selectedMuons = std::make_unique<reco::MuonCollection>();
51+
52+
for (const auto& muon : *muons) {
53+
double relCombIso;
54+
if (useTrackerOnlyIsolation_) {
55+
// Tracker-only isolation
56+
relCombIso = muon.isolationR03().sumPt / muon.pt();
57+
} else {
58+
// Full combined isolation
59+
relCombIso = (muon.isolationR03().sumPt + muon.isolationR03().emEt + muon.isolationR03().hadEt) / muon.pt();
60+
}
61+
62+
if (relCombIso < relCombIsoCut_) {
63+
selectedMuons->push_back(muon);
64+
}
65+
}
66+
67+
const bool passEvent = !selectedMuons->empty();
68+
iEvent.put(std::move(selectedMuons));
69+
70+
// Apply the filter flag logic
71+
return filterEvents_ ? passEvent : true;
72+
}
73+
74+
#include "FWCore/Framework/interface/MakerMacros.h"
75+
DEFINE_FWK_MODULE(AlignmentRelCombIsoMuonSelector);

Alignment/CommonAlignmentProducer/plugins/BuildFile.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,8 @@
5757
<use name="HLTrigger/HLTcore"/>
5858
<flags EDM_PLUGIN="1"/>
5959
</library>
60+
61+
<library file="Alignment*MuonSelector.cc" name="AlignmentCommonAlignmentProducerSelector">
62+
<use name="DataFormats/MuonReco"/>
63+
<flags EDM_PLUGIN="1"/>
64+
</library>

Alignment/CommonAlignmentProducer/python/ALCARECOTkAlDiMuonAndVertex_cff.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
##################################################################
44
# Exact same configuration as TkAlZMuMu: extract mumu pairs
55
#################################################################
6+
from Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi import *
67
import Alignment.CommonAlignmentProducer.ALCARECOTkAlZMuMu_cff as confALCARECOTkAlZMuMu
78
ALCARECOTkAlDiMuonHLT = confALCARECOTkAlZMuMu.ALCARECOTkAlZMuMuHLT.clone()
89
ALCARECOTkAlDiMuonDCSFilter = confALCARECOTkAlZMuMu.ALCARECOTkAlZMuMuDCSFilter.clone()
9-
ALCARECOTkAlDiMuonGoodMuons = confALCARECOTkAlZMuMu.ALCARECOTkAlZMuMuGoodMuons.clone()
10-
ALCARECOTkAlDiMuonRelCombIsoMuons = confALCARECOTkAlZMuMu.ALCARECOTkAlZMuMuRelCombIsoMuons.clone(src = 'ALCARECOTkAlDiMuonGoodMuons')
1110
ALCARECOTkAlDiMuon = confALCARECOTkAlZMuMu.ALCARECOTkAlZMuMu.clone()
12-
ALCARECOTkAlDiMuon.GlobalSelector.muonSource = 'ALCARECOTkAlDiMuonRelCombIsoMuons'
11+
ALCARECOTkAlDiMuon.GlobalSelector.muonSource = 'TkAlRelCombIsoMuonSelector'
1312

1413
##################################################################
1514
# Tracks from the selected vertex
@@ -31,8 +30,7 @@
3130
#################################################################
3231
seqALCARECOTkAlDiMuonAndVertex = cms.Sequence(ALCARECOTkAlDiMuonHLT+
3332
ALCARECOTkAlDiMuonDCSFilter+
34-
ALCARECOTkAlDiMuonGoodMuons+
35-
ALCARECOTkAlDiMuonRelCombIsoMuons+
33+
seqALCARECOTkAlRelCombIsoMuons+
3634
ALCARECOTkAlDiMuon+
3735
ALCARECOTkAlDiMuonVertexTracks+
3836
TkAlDiMuonAndVertexGenMuonSelector)

Alignment/CommonAlignmentProducer/python/ALCARECOTkAlMuonIsolated_cff.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@
2121
DebugOn = cms.untracked.bool(False)
2222
)
2323

24-
import Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi
25-
ALCARECOTkAlMuonIsolatedGoodMuons = Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi.TkAlGoodIdMuonSelector.clone()
26-
ALCARECOTkAlMuonIsolatedRelCombIsoMuons = Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi.TkAlRelCombIsoMuonSelector.clone(
27-
src = 'ALCARECOTkAlMuonIsolatedGoodMuons'
28-
)
24+
from Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi import *
2925

3026
import Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi
3127
ALCARECOTkAlMuonIsolated = Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi.AlignmentTrackSelector.clone(
@@ -37,7 +33,7 @@
3733
nHitMin = 0
3834
)
3935

40-
ALCARECOTkAlMuonIsolated.GlobalSelector.muonSource = 'ALCARECOTkAlMuonIsolatedRelCombIsoMuons'
36+
ALCARECOTkAlMuonIsolated.GlobalSelector.muonSource = 'TkAlRelCombIsoMuonSelector'
4137
# Isolation is shifted to the muon preselection, and then applied intrinsically if applyGlobalMuonFilter = True
4238
ALCARECOTkAlMuonIsolated.GlobalSelector.applyIsolationtest = False
4339
ALCARECOTkAlMuonIsolated.GlobalSelector.minJetDeltaR = 0.1
@@ -47,8 +43,10 @@
4743
ALCARECOTkAlMuonIsolated.TwoBodyDecaySelector.applyChargeFilter = False
4844
ALCARECOTkAlMuonIsolated.TwoBodyDecaySelector.applyAcoplanarityFilter = False
4945

50-
seqALCARECOTkAlMuonIsolated = cms.Sequence(ALCARECOTkAlMuonIsolatedHLT+ALCARECOTkAlMuonIsolatedDCSFilter+ALCARECOTkAlMuonIsolatedGoodMuons+ALCARECOTkAlMuonIsolatedRelCombIsoMuons+ALCARECOTkAlMuonIsolated)
51-
46+
seqALCARECOTkAlMuonIsolated = cms.Sequence(ALCARECOTkAlMuonIsolatedHLT+
47+
ALCARECOTkAlMuonIsolatedDCSFilter+
48+
seqALCARECOTkAlRelCombIsoMuons+
49+
ALCARECOTkAlMuonIsolated)
5250

5351
## customizations for the pp_on_AA eras
5452
from Configuration.Eras.Modifier_pp_on_XeXe_2017_cff import pp_on_XeXe_2017

Alignment/CommonAlignmentProducer/python/ALCARECOTkAlUpsilonMuMu_cff.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@
2323

2424
import Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi
2525
ALCARECOTkAlUpsilonMuMuGoodMuons = Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi.TkAlGoodIdMuonSelector.clone()
26-
ALCARECOTkAlUpsilonMuMuRelCombIsoMuons = Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi.TkAlRelCombIsoMuonSelector.clone(
27-
src = 'ALCARECOTkAlUpsilonMuMuGoodMuons',
28-
cut = '(isolationR03().sumPt + isolationR03().emEt + isolationR03().hadEt)/pt < 0.3'
29-
30-
)
26+
ALCARECOTkAlUpsilonMuMuRelCombIsoMuons = Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi.TkAlRelCombIsoMuonSelector.clone(src = 'ALCARECOTkAlUpsilonMuMuGoodMuons')
3127

3228
import Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi
3329
ALCARECOTkAlUpsilonMuMu = Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi.AlignmentTrackSelector.clone()

Alignment/CommonAlignmentProducer/python/ALCARECOTkAlZMuMuPA_cff.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
ALCARECOTkAlZMuMuPADCSFilter = ALCARECOTkAlZMuMuDCSFilter.clone()
1111

12-
ALCARECOTkAlZMuMuPAGoodMuons = ALCARECOTkAlZMuMuGoodMuons.clone()
12+
ALCARECOTkAlZMuMuPAGoodMuons = TkAlGoodIdMuonSelector.clone()
1313

1414
ALCARECOTkAlZMuMuPA = ALCARECOTkAlZMuMu.clone(
1515
src = 'generalTracks'
@@ -18,6 +18,6 @@
1818

1919
seqALCARECOTkAlZMuMuPA = cms.Sequence(ALCARECOTkAlZMuMuPAHLT
2020
+ALCARECOTkAlZMuMuPADCSFilter
21-
+ALCARECOTkAlZMuMuPAGoodMuons
21+
+TkAlGoodIdMuonSelector
2222
+ALCARECOTkAlZMuMuPA
2323
)

Alignment/CommonAlignmentProducer/python/ALCARECOTkAlZMuMu_cff.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@
2121
DebugOn = cms.untracked.bool(False)
2222
)
2323

24-
import Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi
25-
ALCARECOTkAlZMuMuGoodMuons = Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi.TkAlGoodIdMuonSelector.clone()
26-
ALCARECOTkAlZMuMuRelCombIsoMuons = Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi.TkAlRelCombIsoMuonSelector.clone(
27-
src = 'ALCARECOTkAlZMuMuGoodMuons'
28-
)
24+
## standard muon selection
25+
from Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi import *
2926

3027
import Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi
3128
ALCARECOTkAlZMuMu = Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi.AlignmentTrackSelector.clone()
@@ -37,7 +34,7 @@
3734
ALCARECOTkAlZMuMu.etaMax = 3.5
3835
ALCARECOTkAlZMuMu.nHitMin = 0
3936

40-
ALCARECOTkAlZMuMu.GlobalSelector.muonSource = 'ALCARECOTkAlZMuMuRelCombIsoMuons'
37+
ALCARECOTkAlZMuMu.GlobalSelector.muonSource = 'TkAlRelCombIsoMuonSelector'
4138
# Isolation is shifted to the muon preselection, and then applied intrinsically if applyGlobalMuonFilter = True
4239
ALCARECOTkAlZMuMu.GlobalSelector.applyIsolationtest = False
4340
ALCARECOTkAlZMuMu.GlobalSelector.applyGlobalMuonFilter = True
@@ -58,7 +55,11 @@
5855
filter = cms.bool(False),
5956
throwOnMissing = cms.untracked.bool(False))
6057

61-
seqALCARECOTkAlZMuMu = cms.Sequence(ALCARECOTkAlZMuMuHLT+ALCARECOTkAlZMuMuDCSFilter+ALCARECOTkAlZMuMuGoodMuons+ALCARECOTkAlZMuMuRelCombIsoMuons+ALCARECOTkAlZMuMu+TkAlZMuMuGenMuonSelector)
58+
seqALCARECOTkAlZMuMu = cms.Sequence(ALCARECOTkAlZMuMuHLT+
59+
ALCARECOTkAlZMuMuDCSFilter+
60+
seqALCARECOTkAlRelCombIsoMuons+
61+
ALCARECOTkAlZMuMu+
62+
TkAlZMuMuGenMuonSelector)
6263

6364
## customizations for the pp_on_AA eras
6465
from Configuration.Eras.Modifier_pp_on_XeXe_2017_cff import pp_on_XeXe_2017

0 commit comments

Comments
 (0)