1 from __future__
import print_function
2 import FWCore.ParameterSet.Config
as cms
13 patMuonsWithoutTrigger = PhysicsTools.PatAlgos.producersLayer1.muonProducer_cfi.patMuons.clone(
17 embedCombinedMuon =
True,
18 embedStandAloneMuon =
True,
19 embedPFCandidate =
False,
20 embedCaloMETMuonCorrs = cms.bool(
False),
21 embedTcMETMuonCorrs = cms.bool(
False),
22 embedPfEcalEnergy = cms.bool(
False),
25 embedPickyMuon =
False,
26 embedTpfmsMuon =
False,
27 userIsolation = cms.PSet(),
28 isoDeposits = cms.PSet(),
32 patMuonsWithoutTrigger.userData.userInts.src = []
33 patMuonsWithoutTrigger.userData.userFloats.src = []
34 patMuonsWithoutTrigger.userData.userCands.src = []
35 patMuonsWithoutTrigger.userData.userClasses.src = []
48 "Load variables inside PAT muon, from module <l1ModuleLabel> that you must run before it"
49 patMuonProducer.userData.userInts.src += [
50 cms.InputTag(l1ModuleLabel,
"quality"),
52 patMuonProducer.userData.userFloats.src += [
53 cms.InputTag(l1ModuleLabel,
"deltaR"),
55 patMuonProducer.userData.userFloats.src += [
56 cms.InputTag(l1ModuleLabel,
"deltaPhi"),
58 patMuonProducer.userData.userInts.src += [
59 cms.InputTag(l1ModuleLabel,
"bx"),
61 patMuonProducer.userData.userCands.src += [
62 cms.InputTag(l1ModuleLabel)
78 patTriggerFull.onlyStandAlone =
True
79 patTrigger = cms.EDProducer(
"TriggerObjectFilterByCollection",
80 src = cms.InputTag(
"patTriggerFull"),
81 collections = cms.vstring(
"hltL1extraParticles",
"hltGmtStage2Digis",
"hltL2MuonCandidates",
"hltIterL3MuonCandidates",
"hltIterL3FromL2MuonCandidates",
"hltHighPtTkMuonCands",
"hltGlbTrkMuonCands",
"hltMuTrackJpsiCtfTrackCands",
"hltMuTrackJpsiEffCtfTrackCands",
"hltMuTkMuJpsiTrackerMuonCands",
"hltTracksIter"),
89 muonTriggerMatchHLT = cms.EDProducer(
"PATTriggerMatcherDRDPtLessByR",
90 src = cms.InputTag(
"patMuonsWithoutTrigger" ),
91 matched = cms.InputTag(
"patTrigger" ),
92 matchedCuts = cms.string(
""),
99 maxDPtRel = cms.double( 0.5 ),
100 maxDeltaR = cms.double( 0.5 ),
101 resolveAmbiguities = cms.bool(
True ),
102 resolveByMatchQuality = cms.bool(
True )
106 from MuonAnalysis.MuonAssociators.muonHLTL1Match_cfi
import muonHLTL1Match
107 muonMatchL1 = muonHLTL1Match.clone(
108 src = muonTriggerMatchHLT.src,
109 matched = muonTriggerMatchHLT.matched,
113 muonMatchHLTL1 = muonMatchL1.clone(matchedCuts = cms.string(
'coll("hltL1extraParticles")'))
114 muonMatchHLTL2 = muonTriggerMatchHLT.clone(matchedCuts = cms.string(
'coll("hltL2MuonCandidates")'), maxDeltaR = 0.3, maxDPtRel = 10.0)
115 muonMatchHLTL3 = muonTriggerMatchHLT.clone(matchedCuts = cms.string(
'coll("hltIterL3MuonCandidates")'), maxDeltaR = 0.1, maxDPtRel = 10.0)
116 muonMatchHLTL3T = muonTriggerMatchHLT.clone(matchedCuts = cms.string(
'coll("hltGlbTrkMuonCands")'), maxDeltaR = 0.1, maxDPtRel = 10.0)
117 muonMatchHLTL3fromL2 = muonTriggerMatchHLT.clone(matchedCuts = cms.string(
'coll("hltIterL3FromL2MuonCandidates")'), maxDeltaR = 0.1, maxDPtRel = 10.0)
118 muonMatchHLTTkMu = muonTriggerMatchHLT.clone(matchedCuts = cms.string(
'coll("hltHighPtTkMuonCands")'), maxDeltaR = 0.1, maxDPtRel = 10.0)
119 muonMatchHLTCtfTrack = muonTriggerMatchHLT.clone(matchedCuts = cms.string(
'coll("hltMuTrackJpsiCtfTrackCands")'), maxDeltaR = 0.1, maxDPtRel = 10.0)
120 muonMatchHLTCtfTrack2 = muonTriggerMatchHLT.clone(matchedCuts = cms.string(
'coll("hltMuTrackJpsiEffCtfTrackCands")'), maxDeltaR = 0.1, maxDPtRel = 10.0)
121 muonMatchHLTTrackMu = muonTriggerMatchHLT.clone(matchedCuts = cms.string(
'coll("hltMuTkMuJpsiTrackerMuonCands")'), maxDeltaR = 0.1, maxDPtRel = 10.0)
122 muonMatchHLTTrackIt = muonTriggerMatchHLT.clone(matchedCuts = cms.string(
'coll("hltTracksIter")'), maxDeltaR = 0.1, maxDPtRel = 1.0)
124 patTriggerMatchers1Mu = cms.Sequence(
129 muonMatchHLTL3fromL2 +
132 patTriggerMatchers1MuInputTags = [
135 cms.InputTag(
'muonMatchHLTL2'),
136 cms.InputTag(
'muonMatchHLTL3'),
137 cms.InputTag(
'muonMatchHLTL3T'),
138 cms.InputTag(
'muonMatchHLTL3fromL2'),
139 cms.InputTag(
'muonMatchHLTTkMu'),
142 patTriggerMatchers2Mu = cms.Sequence(
143 muonMatchHLTCtfTrack +
144 muonMatchHLTCtfTrack2 +
145 muonMatchHLTTrackMu +
148 patTriggerMatchers2MuInputTags = [
149 cms.InputTag(
'muonMatchHLTCtfTrack'),
150 cms.InputTag(
'muonMatchHLTCtfTrack2'),
151 cms.InputTag(
'muonMatchHLTTrackMu'),
152 cms.InputTag(
'muonMatchHLTTrackIt'),
156 patMuonsWithTrigger = cms.EDProducer(
"PATTriggerMatchMuonEmbedder",
157 src = cms.InputTag(
"patMuonsWithoutTrigger" ),
158 matches = cms.VInputTag()
160 patMuonsWithTrigger.matches += patTriggerMatchers1MuInputTags
161 patMuonsWithTrigger.matches += patTriggerMatchers2MuInputTags
165 patTriggerMatching = cms.Sequence(
166 patTriggerFull * patTrigger *
167 patTriggerMatchers1Mu *
168 patTriggerMatchers2Mu *
172 patMuonsWithTriggerSequence = cms.Sequence(
174 patMuonsWithoutTrigger *
181 "Switch off ambiguity resolution: allow multiple reco muons to match to the same trigger muon"
182 process.muonMatchHLTL1.resolveAmbiguities =
False
183 process.muonMatchHLTL2.resolveAmbiguities =
False
184 process.muonMatchHLTL3.resolveAmbiguities =
False
185 process.muonMatchHLTL3fromL2.resolveAmbiguities =
False
186 process.muonMatchHLTTkMu.resolveAmbiguities =
False
187 process.muonMatchHLTCtfTrack.resolveAmbiguities =
False
188 process.muonMatchHLTTrackMu.resolveAmbiguities =
False
189 process.muonMatchHLTTrackIt.resolveAmbiguities =
False
192 "Change the process name under which the trigger was run"
193 patTriggerFull.processName = triggerProcessName
196 "Use a different input collection of reco muons"
201 "Start from existing pat Muons instead of producing them"
202 process.patMuonsWithTriggerSequence.remove(process.patMuonsWithoutTrigger)
203 process.patMuonsWithTriggerSequence.remove(process.muonL1Info)
204 process.patMuonsWithTrigger.src = newPatMuonTag
208 process.muonL1Info.src = newPatMuonTag.muonSource
209 addL1UserData(getattr(process,newPatMuonTag.moduleLabel),
'muonL1Info')
212 "Add a preselection cut to the muons before matching (might be relevant, due to ambiguity resolution in trigger matching!"
213 process.patMuonsWithoutTriggerUnfiltered = process.patMuonsWithoutTrigger.clone()
214 process.globalReplace(
'patMuonsWithoutTrigger', cms.EDFilter(
"PATMuonSelector", src = cms.InputTag(
'patMuonsWithoutTriggerUnfiltered'), cut = cms.string(cut)))
215 process.patMuonsWithTriggerSequence.replace(process.patMuonsWithoutTrigger, process.patMuonsWithoutTriggerUnfiltered * process.patMuonsWithoutTrigger)
218 "Add MC matching information to the muons"
219 process.load(
"PhysicsTools.PatAlgos.mcMatchLayer0.muonMatch_cfi")
220 process.patMuonsWithTriggerSequence.replace(process.patMuonsWithoutTrigger, process.muonMatch + process.patMuonsWithoutTrigger)
221 process.patMuonsWithoutTrigger.addGenMatch =
True
222 process.patMuonsWithoutTrigger.embedGenMatch =
True
223 process.patMuonsWithoutTrigger.genParticleMatch =
'muonMatch'
226 print(
"[MuonAnalysis.MuonAssociators.patMuonsWithTrigger_cff] Di-muon triggers are already enabled by default")
229 process.patMuonsWithTriggerSequence.replace(process.muonMatchHLTL3, process.muonMatchHLTL1 + process.muonMatchHLTL3)
230 getattr(process,embedder).matches += [ cms.InputTag(
'muonMatchHLTL1'), cms.InputTag(
'muonMatchHLTL1',
'propagatedReco') ]
233 "Change the L1 trigger matching window to be suitable also for CSC single triggers"
234 if hasattr(process,
'muonL1Info'):
235 process.muonL1Info.maxDeltaR = 0.3
236 process.muonL1Info.maxDeltaEta = 0.2
237 process.muonL1Info.fallbackToME1 =
True
238 if hasattr(process,
'muonMatchHLTL1'):
239 process.muonMatchHLTL1.maxDeltaR = 0.3
240 process.muonMatchHLTL1.maxDeltaEta = 0.2
241 process.muonMatchHLTL1.fallbackToME1 =
True
245 if hasattr(process,
'muonL1Info'):
250 process.muonL1Info.useMB2InOverlap = cms.bool(
True)
251 process.muonL1Info.useStage2L1 = cms.bool(
True)
252 process.muonL1Info.preselection = cms.string(
"")
253 process.muonL1Info.matched = cms.InputTag(
"gmtStage2Digis:Muon:")
256 if hasattr(process,
'muonL1Info'):
257 newMuonL1Info = process.muonL1Info.clone(sortBy = cms.string(algo),
258 sortByQuality = cms.bool(algo ==
"quality"),
259 sortByDeltaPhi = cms.bool(algo ==
"deltaEta"),
260 sortByDeltaEta = cms.bool(algo ==
"deltaPhi"),
261 sortByPt = cms.bool(algo ==
"pt"),
262 maxDeltaR = cms.double(0.3))
263 setattr(process,
"muonL1Info" + algo.title(), newMuonL1Info)
264 process.patMuonsWithTriggerSequence.replace(process.muonL1Info, process.muonL1Info + getattr(process,
'muonL1Info' + algo.title()))
265 addL1UserData(patMuonsWithoutTrigger,
"muonL1Info" + algo.title())
def useL1Stage2Candidates
def switchOffAmbiguityResolution
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def massSearchReplaceAnyInputTag
def useL1MatchingWindowForSinglets
def changeTriggerProcessName
def addL1UserData
Define a generic function, so that it can be used with existing PAT Muons.