1 import FWCore.ParameterSet.Config
as cms
14 process.load(
'PhysicsTools.PatAlgos.producersLayer1.tauProducer_cff')
15 process.load(
'PhysicsTools.PatAlgos.selectionLayer1.tauSelector_cfi')
16 process.selectedPatTaus.cut=
"pt > 18. && tauID(\'decayModeFindingNewDMs\')> 0.5"
18 process.load(
"RecoTauTag.Configuration.RecoPFTauTag_cff")
20 process.miniAODTausTask = cms.Task(
22 process.makePatTausTask,
23 process.selectedPatTaus
25 process.miniAODTausSequence = cms.Sequence(process.miniAODTausTask)
27 process.TauReco = cms.Path(process.miniAODTausSequence)
31 module = getattr(process, name)
32 if hasattr(module,
'particleFlowSrc'):
33 module.particleFlowSrc = cms.InputTag(
"packedPFCandidates",
"",
"")
34 if hasattr(module,
'vertexSrc'):
35 module.vertexSrc = cms.InputTag(
'offlineSlimmedPrimaryVertices')
36 if hasattr(module,
'qualityCuts')
and hasattr(module.qualityCuts,
'primaryVertexSrc'):
37 module.qualityCuts.primaryVertexSrc = cms.InputTag(
'offlineSlimmedPrimaryVertices')
44 jetCollection =
'slimmedJets'
47 jetCollection =
'patJetsPAT'
49 process.ak4PFJetsPAT = ak4PFJets.clone(
50 src=cms.InputTag(
"packedPFCandidates")
54 process.patJetsPAT = _patJets.clone(
55 jetSource = cms.InputTag(
"ak4PFJetsPAT"),
56 addJetCorrFactors = cms.bool(
False),
57 jetCorrFactorsSource = cms.VInputTag(),
58 addBTagInfo = cms.bool(
False),
59 addDiscriminators = cms.bool(
False),
60 discriminatorSources = cms.VInputTag(),
61 addAssociatedTracks = cms.bool(
False),
62 addJetCharge = cms.bool(
False),
63 addGenPartonMatch = cms.bool(
False),
64 embedGenPartonMatch = cms.bool(
False),
65 addGenJetMatch = cms.bool(
False),
66 getJetMCFlavour = cms.bool(
False),
67 addJetFlavourInfo = cms.bool(
False),
69 process.miniAODTausTask.add(process.ak4PFJetsPAT)
70 process.miniAODTausTask.add(process.patJetsPAT)
80 process.recoTauAK4Jets08RegionPAT = cms.EDProducer(
"RecoTauPatJetRegionProducer",
81 deltaR = process.recoTauAK4PFJets08Region.deltaR,
82 maxJetAbsEta = process.recoTauAK4PFJets08Region.maxJetAbsEta,
83 minJetPt = process.recoTauAK4PFJets08Region.minJetPt,
84 pfCandAssocMapSrc = cms.InputTag(
""),
85 pfCandSrc = cms.InputTag(
"packedPFCandidates"),
86 src = cms.InputTag(jetCollection)
89 process.recoTauPileUpVertices.src = cms.InputTag(
"offlineSlimmedPrimaryVertices")
92 process.recoTauCommonTask = cms.Task(
93 process.recoTauAK4Jets08RegionPAT,
94 process.recoTauPileUpVertices
97 for moduleName
in process.TauReco.moduleNames():
102 process.ak4PFJetsLegacyHPSPiZeros.builders[0].qualityCuts.primaryVertexSrc = cms.InputTag(
"offlineSlimmedPrimaryVertices")
103 process.ak4PFJetsLegacyHPSPiZeros.jetSrc = cms.InputTag(jetCollection)
106 for builder
in process.ak4PFJetsRecoTauChargedHadrons.builders:
107 builder.qualityCuts.primaryVertexSrc = cms.InputTag(
"offlineSlimmedPrimaryVertices")
108 if builder.name.value() ==
'tracks':
109 builder.name =
'lostTracks'
110 builder.plugin =
'PFRecoTauChargedHadronFromLostTrackPlugin'
111 builder.srcTracks = cms.InputTag(
"lostTracks")
112 process.ak4PFJetsRecoTauChargedHadrons.jetSrc = cms.InputTag(jetCollection)
115 process.combinatoricRecoTaus.jetRegionSrc =
'recoTauAK4Jets08RegionPAT'
116 process.combinatoricRecoTaus.jetSrc = jetCollection
118 for builder
in process.combinatoricRecoTaus.builders:
119 for name,value
in six.iteritems(builder.parameters_()):
120 if name ==
'qualityCuts':
121 builder.qualityCuts.primaryVertexSrc =
'offlineSlimmedPrimaryVertices'
122 elif name ==
'pfCandSrc':
123 builder.pfCandSrc =
'packedPFCandidates'
125 modifiersToRemove_ = cms.VPSet()
126 for mod
in process.combinatoricRecoTaus.modifiers:
127 if mod.name.value() ==
'elec_rej':
128 modifiersToRemove_.append(mod)
130 elif mod.name.value() ==
'TTIworkaround':
131 modifiersToRemove_.append(mod)
133 for name,value
in six.iteritems(mod.parameters_()):
134 if name ==
'qualityCuts':
135 mod.qualityCuts.primaryVertexSrc =
'offlineSlimmedPrimaryVertices'
136 for mod
in modifiersToRemove_:
137 process.combinatoricRecoTaus.modifiers.remove(mod)
141 process.hpsPFTauPrimaryVertexProducer.__dict__[
'_TypedParameterizable__type'] =
'PFTauMiniAODPrimaryVertexProducer'
142 process.hpsPFTauPrimaryVertexProducer.PVTag =
'offlineSlimmedPrimaryVertices'
143 process.hpsPFTauPrimaryVertexProducer.packedCandidatesTag = cms.InputTag(
"packedPFCandidates")
144 process.hpsPFTauPrimaryVertexProducer.lostCandidatesTag = cms.InputTag(
"lostTracks")
147 process.hpsPFTauSecondaryVertexProducer = cms.EDProducer(
"PFTauSecondaryVertexProducer",
148 PFTauTag = cms.InputTag(
"hpsPFTauProducer")
152 for moduleName
in process.TauReco.moduleNames():
153 if 'ElectronRejection' in moduleName
or 'MuonRejection' in moduleName:
154 if 'ByDeadECALElectronRejection' in moduleName:
continue
155 process.miniAODTausTask.remove(getattr(process, moduleName))
158 from RecoTauTag.RecoTau.hpsPFTauDiscriminationByMuonRejectionSimple_cff
import hpsPFTauDiscriminationByMuonRejectionSimple
160 process.hpsPFTauDiscriminationByMuonRejectionSimple = hpsPFTauDiscriminationByMuonRejectionSimple
161 process.miniAODTausTask.add(process.hpsPFTauDiscriminationByMuonRejectionSimple)
166 process.tauGenJets.GenParticles = cms.InputTag(
"prunedGenParticles")
167 process.tauMatch.matched = cms.InputTag(
"prunedGenParticles")
170 for name, src
in six.iteritems(process.patTaus.tauIDSources.parameters_()):
171 if name.find(
'againstElectron') > -1
or name.find(
'againstMuon') > -1:
172 if name.find(
'againstElectronDeadECAL') > -1:
continue
173 delattr(process.patTaus.tauIDSources,name)
175 setattr(process.patTaus.tauIDSources,
'againstMuonLooseSimple',
176 cms.PSet(inputTag = cms.InputTag(
'hpsPFTauDiscriminationByMuonRejectionSimple'),
177 provenanceConfigLabel = cms.string(
'IDWPdefinitions'),
178 idLabel = cms.string(
'ByLooseMuonRejectionSimple')
180 setattr(process.patTaus.tauIDSources,
'againstMuonTightSimple',
181 cms.PSet(inputTag = cms.InputTag(
'hpsPFTauDiscriminationByMuonRejectionSimple'),
182 provenanceConfigLabel = cms.string(
'IDWPdefinitions'),
183 idLabel = cms.string(
'ByTightMuonRejectionSimple')
187 _updatedTauName =
'selectedPatTausNewIDs'
188 _noUpdatedTauName =
'selectedPatTausNoNewIDs'
189 import RecoTauTag.RecoTau.tools.runTauIdMVA
as tauIdConfig
190 tauIdEmbedder = tauIdConfig.TauIDEmbedder(
191 process, debug =
False,
192 updatedTauName = _updatedTauName,
193 toKeep = [
'againstEle2018',
'deepTau2017v2p1']
195 tauIdEmbedder.runTauID()
196 setattr(process, _noUpdatedTauName, process.selectedPatTaus.clone())
197 process.miniAODTausTask.add(getattr(process,_noUpdatedTauName))
198 delattr(process,
'selectedPatTaus')
199 process.deepTau2017v2p1.taus = _noUpdatedTauName
200 process.patTauDiscriminationByElectronRejectionMVA62018Raw.PATTauProducer = _noUpdatedTauName
201 process.patTauDiscriminationByElectronRejectionMVA62018.PATTauProducer = _noUpdatedTauName
202 process.selectedPatTaus = getattr(process, _updatedTauName).
clone(
203 src = _noUpdatedTauName
205 process.newTauIDsTask = cms.Task(
206 process.rerunMvaIsolationTask,
207 process.selectedPatTaus
209 process.miniAODTausTask.add(process.newTauIDsTask)
219 output = cms.OutputModule(
221 fileName=cms.untracked.string(
'miniAOD_TauReco.root'),
222 fastCloning=cms.untracked.bool(
False),
223 dataset=cms.untracked.PSet(
224 dataTier=cms.untracked.string(
'MINIAODSIM'),
225 filterName=cms.untracked.string(
'')
227 outputCommands = evtContent.MINIAODSIMEventContent.outputCommands,
228 SelectEvents=cms.untracked.PSet(
229 SelectEvents=cms.vstring(
'*',)
232 output.outputCommands.append(
'keep *_selectedPatTaus_*_*')
234 for prod
in evtContent.RecoTauTagAOD.outputCommands:
235 if prod.find(
'ElectronRejection') > -1
and prod.find(
'DeadECAL') == -1:
237 if prod.find(
'MuonRejection') > -1:
239 output.outputCommands.append(prod)
240 output.outputCommands.append(
'keep *_hpsPFTauDiscriminationByMuonRejectionSimple_*_*')
241 output.outputCommands.append(
'keep *_combinatoricReco*_*_*')
242 output.outputCommands.append(
'keep *_ak4PFJetsRecoTauChargedHadrons_*_*')
243 output.outputCommands.append(
'keep *_ak4PFJetsLegacyHPSPiZeros_*_*')
244 output.outputCommands.append(
'keep *_patJetsPAT_*_*')