00001 import FWCore.ParameterSet.Config as cms
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 import PhysicsTools.PatAlgos.producersLayer1.muonProducer_cfi
00012 patMuonsWithoutTrigger = PhysicsTools.PatAlgos.producersLayer1.muonProducer_cfi.patMuons.clone(
00013 muonSource = 'muons',
00014
00015 embedTrack = True,
00016 embedCombinedMuon = True,
00017 embedStandAloneMuon = True,
00018 embedPFCandidate = False,
00019 embedCaloMETMuonCorrs = cms.bool(False),
00020 embedTcMETMuonCorrs = cms.bool(False),
00021
00022
00023 embedPickyMuon = False,
00024 embedTpfmsMuon = False,
00025 userIsolation = cms.PSet(),
00026 isoDeposits = cms.PSet(),
00027 addGenMatch = False,
00028 )
00029
00030 patMuonsWithoutTrigger.userData.userInts.src = []
00031 patMuonsWithoutTrigger.userData.userFloats.src = []
00032 patMuonsWithoutTrigger.userData.userCands.src = []
00033 patMuonsWithoutTrigger.userData.userClasses.src = []
00034
00035
00036
00037
00038
00039
00040
00041
00042 from MuonAnalysis.MuonAssociators.muonL1Match_cfi import muonL1Match as muonL1Info
00043
00044
00045 def muons.">addL1UserData(patMuonProducer, l1ModuleLabel = "muonL1Info"):
00046 "Load variables inside PAT muon, from module <l1ModuleLabel> that you must run before it"
00047 patMuonProducer.userData.userInts.src += [
00048 cms.InputTag(l1ModuleLabel, "quality"),
00049 ]
00050 patMuonProducer.userData.userFloats.src += [
00051 cms.InputTag(l1ModuleLabel, "deltaR"),
00052 ]
00053 patMuonProducer.userData.userCands.src += [
00054 cms.InputTag(l1ModuleLabel)
00055 ]
00056
00057
00058 addL1UserData(patMuonsWithoutTrigger, "muonL1Info")
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 from PhysicsTools.PatAlgos.triggerLayer1.triggerProducer_cfi import patTrigger as patTriggerFull
00070 patTriggerFull.onlyStandAlone = True
00071 patTrigger = cms.EDFilter("PATTriggerObjectStandAloneSelector",
00072 src = cms.InputTag("patTriggerFull"),
00073 cut = cms.string('coll("hltL1extraParticles") || coll("hltL2MuonCandidates") || coll("hltL3MuonCandidates") || coll("hltGlbTrkMuonCands") || coll("hltMuTrackJpsiCtfTrackCands") || coll("hltMuTrackJpsiEffCtfTrackCands") || coll("hltMuTkMuJpsiTrackerMuonCands")'),
00074 )
00075
00076
00077 muonTriggerMatchHLT = cms.EDProducer( "PATTriggerMatcherDRDPtLessByR",
00078 src = cms.InputTag( "patMuonsWithoutTrigger" ),
00079 matched = cms.InputTag( "patTrigger" ),
00080 matchedCuts = cms.string(""),
00081
00082
00083
00084
00085
00086
00087 maxDPtRel = cms.double( 0.5 ),
00088 maxDeltaR = cms.double( 0.5 ),
00089 resolveAmbiguities = cms.bool( True ),
00090 resolveByMatchQuality = cms.bool( True )
00091 )
00092
00093
00094 from MuonAnalysis.MuonAssociators.muonHLTL1Match_cfi import muonHLTL1Match
00095 muonMatchL1 = muonHLTL1Match.clone(
00096 src = muonTriggerMatchHLT.src,
00097 matched = muonTriggerMatchHLT.matched,
00098 )
00099
00100
00101 muonMatchHLTL1 = muonMatchL1.clone(matchedCuts = cms.string('coll("hltL1extraParticles")'))
00102 muonMatchHLTL2 = muonTriggerMatchHLT.clone(matchedCuts = cms.string('coll("hltL2MuonCandidates")'), maxDeltaR = 0.3, maxDPtRel = 10.0)
00103 muonMatchHLTL3 = muonTriggerMatchHLT.clone(matchedCuts = cms.string('coll("hltL3MuonCandidates")'), maxDeltaR = 0.1, maxDPtRel = 10.0)
00104 muonMatchHLTL3T = muonTriggerMatchHLT.clone(matchedCuts = cms.string('coll("hltGlbTrkMuonCands")'), maxDeltaR = 0.1, maxDPtRel = 10.0)
00105 muonMatchHLTCtfTrack = muonTriggerMatchHLT.clone(matchedCuts = cms.string('coll("hltMuTrackJpsiCtfTrackCands")'), maxDeltaR = 0.1, maxDPtRel = 10.0)
00106 muonMatchHLTCtfTrack2 = muonTriggerMatchHLT.clone(matchedCuts = cms.string('coll("hltMuTrackJpsiEffCtfTrackCands")'), maxDeltaR = 0.1, maxDPtRel = 10.0)
00107 muonMatchHLTTrackMu = muonTriggerMatchHLT.clone(matchedCuts = cms.string('coll("hltMuTkMuJpsiTrackerMuonCands")'), maxDeltaR = 0.1, maxDPtRel = 10.0)
00108
00109 patTriggerMatchers1Mu = cms.Sequence(
00110 muonMatchHLTL1 +
00111 muonMatchHLTL2 +
00112 muonMatchHLTL3 +
00113 muonMatchHLTL3T
00114 )
00115 patTriggerMatchers1MuInputTags = [
00116 cms.InputTag('muonMatchHLTL1','propagatedReco'),
00117 cms.InputTag('muonMatchHLTL1'),
00118 cms.InputTag('muonMatchHLTL2'),
00119 cms.InputTag('muonMatchHLTL3'),
00120 cms.InputTag('muonMatchHLTL3T'),
00121 ]
00122
00123 patTriggerMatchers2Mu = cms.Sequence(
00124 muonMatchHLTCtfTrack +
00125 muonMatchHLTCtfTrack2 +
00126 muonMatchHLTTrackMu
00127 )
00128 patTriggerMatchers2MuInputTags = [
00129 cms.InputTag('muonMatchHLTCtfTrack'),
00130 cms.InputTag('muonMatchHLTCtfTrack2'),
00131 cms.InputTag('muonMatchHLTTrackMu'),
00132 ]
00133
00134
00135 patMuonsWithTrigger = cms.EDProducer( "PATTriggerMatchMuonEmbedder",
00136 src = cms.InputTag( "patMuonsWithoutTrigger" ),
00137 matches = cms.VInputTag()
00138 )
00139 patMuonsWithTrigger.matches += patTriggerMatchers1MuInputTags
00140 patMuonsWithTrigger.matches += patTriggerMatchers2MuInputTags
00141
00142
00143
00144 patTriggerMatching = cms.Sequence(
00145 patTriggerFull * patTrigger *
00146 patTriggerMatchers1Mu *
00147 patTriggerMatchers2Mu *
00148 patMuonsWithTrigger
00149 )
00150
00151 patMuonsWithTriggerSequence = cms.Sequence(
00152 muonL1Info *
00153 patMuonsWithoutTrigger *
00154 patTriggerMatching
00155 )
00156
00157
00158
00159 def switchOffAmbiguityResolution(process):
00160 "Switch off ambiguity resolution: allow multiple reco muons to match to the same trigger muon"
00161 process.muonMatchHLTL1.resolveAmbiguities = False
00162 process.muonMatchHLTL2.resolveAmbiguities = False
00163 process.muonMatchHLTL3.resolveAmbiguities = False
00164 process.muonMatchHLTCtfTrack.resolveAmbiguities = False
00165 process.muonMatchHLTTrackMu.resolveAmbiguities = False
00166
00167 def changeTriggerProcessName(process, triggerProcessName, oldProcessName="HLT"):
00168 "Change the process name under which the trigger was run"
00169 patTriggerFull.processName = triggerProcessName
00170
00171 def changeRecoMuonInput(process, recoMuonCollectionTag, oldRecoMuonCollectionTag=cms.InputTag("muons")):
00172 "Use a different input collection of reco muons"
00173 from PhysicsTools.PatAlgos.tools.helpers import massSearchReplaceAnyInputTag
00174 massSearchReplaceAnyInputTag(process.patMuonsWithTriggerSequence, oldRecoMuonCollectionTag, recoMuonCollectionTag)
00175
00176 def useExistingPATMuons(process, newPatMuonTag, addL1Info=False):
00177 "Start from existing pat muons instead of producing them"
00178 process.patMuonsWithTriggerSequence.remove(process.patMuonsWithoutTrigger)
00179 process.patMuonsWithTriggerSequence.remove(process.muonL1Info)
00180 process.patMuonsWithTrigger.src = newPatMuonTag
00181 from PhysicsTools.PatAlgos.tools.helpers import massSearchReplaceAnyInputTag
00182 massSearchReplaceAnyInputTag(process.patMuonsWithTriggerSequence, cms.InputTag('patMuonsWithoutTrigger'), newPatMuonTag)
00183 if addL1Info:
00184 process.muonL1Info.src = newPatMuonTag.muonSource
00185 addL1UserData(getattr(process,newPatMuonTag.moduleLabel), 'muonL1Info')
00186
00187 def addPreselection(process, cut):
00188 "Add a preselection cut to the muons before matching (might be relevant, due to ambiguity resolution in trigger matching!"
00189 process.patMuonsWithoutTriggerUnfiltered = process.patMuonsWithoutTrigger.clone()
00190 process.globalReplace('patMuonsWithoutTrigger', cms.EDFilter("PATMuonSelector", src = cms.InputTag('patMuonsWithoutTriggerUnfiltered'), cut = cms.string(cut)))
00191 process.patMuonsWithTriggerSequence.replace(process.patMuonsWithoutTrigger, process.patMuonsWithoutTriggerUnfiltered * process.patMuonsWithoutTrigger)
00192
00193 def addMCinfo(process):
00194 "Add MC matching information to the muons"
00195 process.load("PhysicsTools.PatAlgos.mcMatchLayer0.muonMatch_cfi")
00196 process.patMuonsWithTriggerSequence.replace(process.patMuonsWithoutTrigger, process.muonMatch + process.patMuonsWithoutTrigger)
00197 process.patMuonsWithoutTrigger.addGenMatch = True
00198 process.patMuonsWithoutTrigger.embedGenMatch = True
00199 process.patMuonsWithoutTrigger.genParticleMatch = 'muonMatch'
00200
00201 def addDiMuonTriggers(process):
00202 print "[MuonAnalysis.MuonAssociators.patMuonsWithTrigger_cff] Di-muon triggers are already enabled by default"
00203
00204 def useL1MatchingWindowForSinglets(process):
00205 "Change the L1 trigger matching window to be suitable also for CSC single triggers"
00206 if hasattr(process, 'muonL1Info'):
00207 process.muonL1Info.maxDeltaR = 0.3
00208 process.muonL1Info.maxDeltaEta = 0.2
00209 process.muonL1Info.fallbackToME1 = True
00210 if hasattr(process, 'muonMatchHLTL1'):
00211 process.muonMatchHLTL1.maxDeltaR = 0.3
00212 process.muonMatchHLTL1.maxDeltaEta = 0.2
00213 process.muonMatchHLTL1.fallbackToME1 = True
00214