1 import FWCore.ParameterSet.Config
as cms
13 def __init__(self, process, runBoosted=False, postfix=""):
18 self.
postfix =
'Boosted'+postfix
26 self.process.load(
'PhysicsTools.PatAlgos.producersLayer1.tauProducer_cff')
27 self.process.load(
'PhysicsTools.PatAlgos.selectionLayer1.tauSelector_cfi')
28 self.process.selectedPatTaus.cut=
"pt > 18. && tauID(\'decayModeFindingNewDMs\')> 0.5"
30 self.process.load(
"RecoTauTag.Configuration.RecoPFTauTag_cff")
32 self.process.miniAODTausTask = cms.Task(
33 self.process.PFTauTask,
34 self.process.makePatTausTask,
35 self.process.selectedPatTaus
41 del self.process.miniAODTausTask
45 module = getattr(self.
process, name)
46 if hasattr(module,
'particleFlowSrc'):
47 module.particleFlowSrc = cms.InputTag(
"packedPFCandidates",
"",
"")
48 if hasattr(module,
'vertexSrc'):
49 module.vertexSrc = cms.InputTag(
'offlineSlimmedPrimaryVertices')
50 if hasattr(module,
'qualityCuts')
and hasattr(module.qualityCuts,
'primaryVertexSrc'):
51 module.qualityCuts.primaryVertexSrc = cms.InputTag(
'offlineSlimmedPrimaryVertices')
57 jetCollection =
'slimmedJets'
60 jetCollection =
'boostedTauSeedsPAT'+self.
postfix
61 from RecoTauTag.Configuration.boostedHPSPFTaus_cff
import ca8PFJetsCHSprunedForBoostedTaus
62 setattr(self.
process,
'ca8PFJetsCHSprunedForBoostedTausPAT'+self.
postfix,ca8PFJetsCHSprunedForBoostedTaus.clone(
63 src =
'packedPFCandidates',
64 jetCollInstanceName =
'subJetsForSeedingBoostedTausPAT'
67 cms.EDProducer(
"PATBoostedTauSeedsProducer",
68 subjetSrc = cms.InputTag(
'ca8PFJetsCHSprunedForBoostedTausPAT'+self.
postfix,
'subJetsForSeedingBoostedTausPAT'),
69 pfCandidateSrc = cms.InputTag(
'packedPFCandidates'),
70 verbosity = cms.int32(0)
72 self.miniAODTausTask.add(getattr(self.
process,
'ca8PFJetsCHSprunedForBoostedTausPAT'+self.
postfix))
73 self.miniAODTausTask.add(getattr(self.
process,
'boostedTauSeedsPAT'+self.
postfix))
75 jetCollection =
'patJetsPAT'+self.
postfix
78 src =
"packedPFCandidates"
84 addJetCorrFactors =
False,
85 jetCorrFactorsSource = [],
87 addDiscriminators =
False,
88 discriminatorSources = [],
89 addAssociatedTracks =
False,
91 addGenPartonMatch =
False,
92 embedGenPartonMatch =
False,
93 addGenJetMatch =
False,
94 getJetMCFlavour =
False,
95 addJetFlavourInfo =
False,
97 self.miniAODTausTask.add(getattr(self.
process,
'ak4PFJetsPAT'+self.
postfix))
98 self.miniAODTausTask.add(getattr(self.
process,
'patJetsPAT'+self.
postfix))
107 self.miniAODTausTask.remove(getattr(self.
process,
'ak4PFJetTracksAssociatorAtVertex'+self.
postfix))
108 self.miniAODTausTask.remove(getattr(self.
process,
'pfRecoTauTagInfoProducer'+self.
postfix))
110 self.miniAODTausTask.remove(getattr(self.
process,
'recoTauAK4PFJets08Region'+self.
postfix))
112 cms.EDProducer(
"RecoTauPatJetRegionProducer",
113 deltaR = self.process.recoTauAK4PFJets08Region.deltaR,
114 maxJetAbsEta = self.process.recoTauAK4PFJets08Region.maxJetAbsEta,
115 minJetPt = self.process.recoTauAK4PFJets08Region.minJetPt,
116 pfCandAssocMapSrc = cms.InputTag(
""),
117 pfCandSrc = cms.InputTag(
"packedPFCandidates"),
118 src = cms.InputTag(jetCollection)
120 _jetRegionProducer = getattr(self.
process,
'recoTauAK4Jets08RegionPAT'+self.
postfix)
121 self.miniAODTausTask.add(_jetRegionProducer)
123 _jetRegionProducer.pfCandAssocMapSrc = cms.InputTag(jetCollection,
'pfCandAssocMapForIsolation')
125 getattr(self.
process,
'recoTauPileUpVertices'+self.
postfix).src =
"offlineSlimmedPrimaryVertices"
127 for moduleName
in self.miniAODTausTask.moduleNames():
133 for builder
in _piZeroProducer.builders:
134 builder.qualityCuts.primaryVertexSrc =
"offlineSlimmedPrimaryVertices"
135 _piZeroProducer.jetSrc = jetCollection
138 _chargedHadronProducer = getattr(self.
process,
'ak4PFJetsRecoTauChargedHadrons'+self.
postfix)
139 for builder
in _chargedHadronProducer.builders:
140 builder.qualityCuts.primaryVertexSrc =
"offlineSlimmedPrimaryVertices"
141 if builder.name.value() ==
'tracks':
142 builder.name =
'lostTracks'
143 builder.plugin =
'PFRecoTauChargedHadronFromLostTrackPlugin'
144 builder.srcTracks =
"lostTracks"
147 builder.dRconeLimitedToJetArea =
True
148 _chargedHadronProducer.jetSrc = jetCollection
151 _combinatoricRecoTauProducer = getattr(self.
process,
'combinatoricRecoTaus'+self.
postfix)
152 _combinatoricRecoTauProducer.jetRegionSrc =
'recoTauAK4Jets08RegionPAT'+self.
postfix
153 _combinatoricRecoTauProducer.jetSrc = jetCollection
155 for builder
in _combinatoricRecoTauProducer.builders:
156 for name,value
in builder.parameters_().
items():
157 if name ==
'qualityCuts':
158 builder.qualityCuts.primaryVertexSrc =
'offlineSlimmedPrimaryVertices'
159 elif name ==
'pfCandSrc':
160 builder.pfCandSrc =
'packedPFCandidates'
162 _modifiersToRemove = cms.VPSet()
163 for mod
in _combinatoricRecoTauProducer.modifiers:
164 if mod.name.value() ==
'elec_rej':
165 _modifiersToRemove.append(mod)
167 elif mod.name.value() ==
'TTIworkaround':
168 _modifiersToRemove.append(mod)
170 for name,value
in mod.parameters_().
items():
171 if name ==
'qualityCuts':
172 mod.qualityCuts.primaryVertexSrc =
'offlineSlimmedPrimaryVertices'
173 for mod
in _modifiersToRemove:
174 _combinatoricRecoTauProducer.modifiers.remove(mod)
178 _tauPVProducer = getattr(self.
process,
'hpsPFTauPrimaryVertexProducer'+self.
postfix)
179 _tauPVProducer.__dict__[
'_TypedParameterizable__type'] =
'PFTauMiniAODPrimaryVertexProducer'
180 _tauPVProducer.PVTag =
'offlineSlimmedPrimaryVertices'
181 _tauPVProducer.packedCandidatesTag = cms.InputTag(
"packedPFCandidates")
182 _tauPVProducer.lostCandidatesTag = cms.InputTag(
"lostTracks")
185 setattr(self.
process,
'hpsPFTauSecondaryVertexProducer'+self.
postfix,
186 cms.EDProducer(
"PFTauSecondaryVertexProducer",
187 PFTauTag = cms.InputTag(
"hpsPFTauProducer"+self.
postfix)
191 for moduleName
in self.miniAODTausTask.moduleNames():
192 if 'ElectronRejection' in moduleName
or 'MuonRejection' in moduleName:
193 if 'ByDeadECALElectronRejection' in moduleName:
continue
194 self.miniAODTausTask.remove(getattr(self.
process, moduleName))
197 from RecoTauTag.RecoTau.hpsPFTauDiscriminationByMuonRejectionSimple_cff
import hpsPFTauDiscriminationByMuonRejectionSimple
199 setattr(self.
process,
'hpsPFTauDiscriminationByMuonRejectionSimple'+self.
postfix,
200 hpsPFTauDiscriminationByMuonRejectionSimple.clone(
201 PFTauProducer =
"hpsPFTauProducer"+self.
postfix))
202 _tauIDAntiMuSimple = getattr(self.
process,
'hpsPFTauDiscriminationByMuonRejectionSimple'+self.
postfix)
204 _tauIDAntiMuSimple.dRmuonMatch = 0.1
205 self.miniAODTausTask.add(_tauIDAntiMuSimple)
210 getattr(self.
process,
'tauGenJets'+self.
postfix).GenParticles =
"prunedGenParticles"
211 getattr(self.
process,
'tauMatch'+self.
postfix).matched =
"prunedGenParticles"
215 for name,src
in _patTauProducer.tauIDSources.parameters_().
items():
216 if name.find(
'againstElectron') > -1
or name.find(
'againstMuon') > -1:
217 if name.find(
'againstElectronDeadECAL') > -1:
continue
218 delattr(_patTauProducer.tauIDSources,name)
220 setattr(_patTauProducer.tauIDSources,
'againstMuonLooseSimple',
221 cms.PSet(inputTag = cms.InputTag(
'hpsPFTauDiscriminationByMuonRejectionSimple'+self.
postfix),
222 provenanceConfigLabel = cms.string(
'IDWPdefinitions'),
223 idLabel = cms.string(
'ByLooseMuonRejectionSimple')
225 setattr(_patTauProducer.tauIDSources,
'againstMuonTightSimple',
226 cms.PSet(inputTag = cms.InputTag(
'hpsPFTauDiscriminationByMuonRejectionSimple'+self.
postfix),
227 provenanceConfigLabel = cms.string(
'IDWPdefinitions'),
228 idLabel = cms.string(
'ByTightMuonRejectionSimple')
232 _updatedTauName =
'selectedPatTausNewIDs'+self.
postfix
233 _noUpdatedTauName =
'selectedPatTausNoNewIDs'+self.
postfix
234 toKeep = [
'againstEle2018']
236 toKeep.append(
'deepTau2017v2p1')
237 import RecoTauTag.RecoTau.tools.runTauIdMVA
as tauIdConfig
238 tauIdEmbedder = tauIdConfig.TauIDEmbedder(
240 originalTauName = _noUpdatedTauName,
241 updatedTauName = _updatedTauName,
242 postfix =
"MiniAODTaus"+self.
postfix,
245 tauIdEmbedder.runTauID()
247 self.miniAODTausTask.add(getattr(self.
process,_noUpdatedTauName))
250 delattr(self.
process, _updatedTauName)
252 getattr(self.
process,
'rerunMvaIsolationTaskMiniAODTaus'+self.
postfix),
255 self.miniAODTausTask.add(getattr(self.
process,
'newTauIDsTask'+self.
postfix))
265 output = cms.OutputModule(
267 fileName=cms.untracked.string(
'miniAOD_TauReco.root'),
268 fastCloning=cms.untracked.bool(
False),
269 dataset=cms.untracked.PSet(
270 dataTier=cms.untracked.string(
'MINIAODSIM'),
271 filterName=cms.untracked.string(
'')
273 outputCommands = evtContent.MINIAODSIMEventContent.outputCommands,
274 SelectEvents=cms.untracked.PSet(
275 SelectEvents=cms.vstring(
'*',)
278 output.outputCommands.append(
'keep *_selectedPatTaus'+self.
postfix+
'_*_*')
281 for prod
in evtContent.RecoTauTagAOD.outputCommands:
282 if prod.find(
'ElectronRejection') > -1
and prod.find(
'DeadECAL') == -1:
284 if prod.find(
'MuonRejection') > -1:
286 if prod.find(
"_*_*")>-1:
287 output.outputCommands.append(prod.replace(
"_*_*",self.
postfix+
"_*_*"))
289 m = re.search(
r'_[A-Za-z0-9]+_\*', prod)
292 output.outputCommands.append(prod.replace(inst,self.
postfix+inst))
294 print(
"Warning: \"%s\" do not match known name patterns; trying to keep w/o postfix" % prod)
295 output.outputCommands.append(prod)
297 output.outputCommands.append(
'keep *_hpsPFTauDiscriminationByMuonRejectionSimple'+self.
postfix+
'_*_*')
298 output.outputCommands.append(
'keep *_combinatoricReco*_*_*')
299 output.outputCommands.append(
'keep *_ak4PFJetsRecoTauChargedHadrons'+self.
postfix+
'_*_*')
300 output.outputCommands.append(
'keep *_ak4PFJetsLegacyHPSPiZeros'+self.
postfix+
'_*_*')
301 output.outputCommands.append(
'keep *_patJetsPAT'+self.
postfix+
'_*_*')
302 output.outputCommands.append(
'keep *_boostedTauSeedsPAT'+self.
postfix+
'_*_*')
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
def adaptTauToMiniAODReReco
def convertModuleToMiniAODInput