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
39 self.process.PFTauMVAIsoTask = cms.Task(
40 self.process.hpsPFTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw,
41 self.process.hpsPFTauDiscriminationByIsolationMVArun2v1DBoldDMwLT,
42 self.process.hpsPFTauDiscriminationByIsolationMVArun2v1DBnewDMwLTraw,
43 self.process.hpsPFTauDiscriminationByIsolationMVArun2v1DBnewDMwLT
45 self.process.PFTauTask.add(self.process.PFTauMVAIsoTask)
50 del self.
process.miniAODTausTask
54 module = getattr(self.
process, name)
55 if hasattr(module,
'particleFlowSrc'):
56 module.particleFlowSrc = cms.InputTag(
"packedPFCandidates",
"",
"")
57 if hasattr(module,
'vertexSrc'):
58 module.vertexSrc = cms.InputTag(
'offlineSlimmedPrimaryVertices')
59 if hasattr(module,
'qualityCuts')
and hasattr(module.qualityCuts,
'primaryVertexSrc'):
60 module.qualityCuts.primaryVertexSrc = cms.InputTag(
'offlineSlimmedPrimaryVertices')
66 jetCollection =
'slimmedJets' 69 jetCollection =
'boostedTauSeedsPAT'+self.
postfix 70 from RecoTauTag.Configuration.boostedHPSPFTaus_cff
import ca8PFJetsCHSprunedForBoostedTaus
71 setattr(self.
process,
'ca8PFJetsCHSprunedForBoostedTausPAT'+self.
postfix,ca8PFJetsCHSprunedForBoostedTaus.clone(
72 src =
'packedPFCandidates',
73 jetCollInstanceName =
'subJetsForSeedingBoostedTausPAT' 76 cms.EDProducer(
"PATBoostedTauSeedsProducer",
77 subjetSrc = cms.InputTag(
'ca8PFJetsCHSprunedForBoostedTausPAT'+self.
postfix,
'subJetsForSeedingBoostedTausPAT'),
78 pfCandidateSrc = cms.InputTag(
'packedPFCandidates'),
79 verbosity = cms.int32(0)
84 jetCollection =
'patJetsPAT'+self.
postfix 87 src =
"packedPFCandidates" 93 addJetCorrFactors =
False,
94 jetCorrFactorsSource = [],
96 addDiscriminators =
False,
97 discriminatorSources = [],
98 addAssociatedTracks =
False,
100 addGenPartonMatch =
False,
101 embedGenPartonMatch =
False,
102 addGenJetMatch =
False,
103 getJetMCFlavour =
False,
104 addJetFlavourInfo =
False,
121 cms.EDProducer(
"RecoTauPatJetRegionProducer",
122 deltaR = self.
process.recoTauAK4PFJets08Region.deltaR,
123 maxJetAbsEta = self.
process.recoTauAK4PFJets08Region.maxJetAbsEta,
124 minJetPt = self.
process.recoTauAK4PFJets08Region.minJetPt,
125 pfCandAssocMapSrc = cms.InputTag(
""),
126 pfCandSrc = cms.InputTag(
"packedPFCandidates"),
127 src = cms.InputTag(jetCollection)
129 _jetRegionProducer = getattr(self.
process,
'recoTauAK4Jets08RegionPAT'+self.
postfix)
132 _jetRegionProducer.pfCandAssocMapSrc = cms.InputTag(jetCollection,
'pfCandAssocMapForIsolation')
134 getattr(self.
process,
'recoTauPileUpVertices'+self.
postfix).src =
"offlineSlimmedPrimaryVertices" 142 for builder
in _piZeroProducer.builders:
143 builder.qualityCuts.primaryVertexSrc =
"offlineSlimmedPrimaryVertices" 144 _piZeroProducer.jetSrc = jetCollection
147 _chargedHadronProducer = getattr(self.
process,
'ak4PFJetsRecoTauChargedHadrons'+self.
postfix)
148 for builder
in _chargedHadronProducer.builders:
149 builder.qualityCuts.primaryVertexSrc =
"offlineSlimmedPrimaryVertices" 150 if builder.name.value() ==
'tracks':
151 builder.name =
'lostTracks' 152 builder.plugin =
'PFRecoTauChargedHadronFromLostTrackPlugin' 153 builder.srcTracks =
"lostTracks" 156 builder.dRconeLimitedToJetArea =
True 157 _chargedHadronProducer.jetSrc = jetCollection
160 _combinatoricRecoTauProducer = getattr(self.
process,
'combinatoricRecoTaus'+self.
postfix)
161 _combinatoricRecoTauProducer.jetRegionSrc =
'recoTauAK4Jets08RegionPAT'+self.
postfix 162 _combinatoricRecoTauProducer.jetSrc = jetCollection
164 for builder
in _combinatoricRecoTauProducer.builders:
165 for name,value
in builder.parameters_().
items():
166 if name ==
'qualityCuts':
167 builder.qualityCuts.primaryVertexSrc =
'offlineSlimmedPrimaryVertices' 168 elif name ==
'pfCandSrc':
169 builder.pfCandSrc =
'packedPFCandidates' 171 _modifiersToRemove = cms.VPSet()
172 for mod
in _combinatoricRecoTauProducer.modifiers:
173 if mod.name.value() ==
'elec_rej':
174 _modifiersToRemove.append(mod)
176 elif mod.name.value() ==
'TTIworkaround':
177 _modifiersToRemove.append(mod)
179 elif mod.name.value() ==
'tau_lost_tracks':
180 _modifiersToRemove.append(mod)
182 for name,value
in mod.parameters_().
items():
183 if name ==
'qualityCuts':
184 mod.qualityCuts.primaryVertexSrc =
'offlineSlimmedPrimaryVertices' 185 for mod
in _modifiersToRemove:
186 _combinatoricRecoTauProducer.modifiers.remove(mod)
190 _tauPVProducer = getattr(self.
process,
'hpsPFTauPrimaryVertexProducer'+self.
postfix)
191 _tauPVProducer.__dict__[
'_TypedParameterizable__type'] =
'PFTauMiniAODPrimaryVertexProducer' 192 _tauPVProducer.PVTag =
'offlineSlimmedPrimaryVertices' 193 _tauPVProducer.packedCandidatesTag = cms.InputTag(
"packedPFCandidates")
194 _tauPVProducer.lostCandidatesTag = cms.InputTag(
"lostTracks")
197 setattr(self.
process,
'hpsPFTauSecondaryVertexProducer'+self.
postfix,
198 cms.EDProducer(
"PFTauSecondaryVertexProducer",
199 PFTauTag = cms.InputTag(
"hpsPFTauProducer"+self.
postfix)
204 if 'ElectronRejection' in moduleName
or 'MuonRejection' in moduleName:
205 if 'ByDeadECALElectronRejection' in moduleName:
continue 209 from RecoTauTag.RecoTau.hpsPFTauDiscriminationByMuonRejectionSimple_cff
import hpsPFTauDiscriminationByMuonRejectionSimple
211 setattr(self.
process,
'hpsPFTauDiscriminationByMuonRejectionSimple'+self.
postfix,
212 hpsPFTauDiscriminationByMuonRejectionSimple.clone(
213 PFTauProducer =
"hpsPFTauProducer"+self.
postfix))
214 _tauIDAntiMuSimple = getattr(self.
process,
'hpsPFTauDiscriminationByMuonRejectionSimple'+self.
postfix)
216 _tauIDAntiMuSimple.dRmuonMatch = 0.1
222 getattr(self.
process,
'tauGenJets'+self.
postfix).GenParticles =
"prunedGenParticles" 227 for name,src
in _patTauProducer.tauIDSources.parameters_().
items():
228 if name.find(
'againstElectron') > -1
or name.find(
'againstMuon') > -1:
229 if name.find(
'againstElectronDeadECAL') > -1:
continue 230 delattr(_patTauProducer.tauIDSources,name)
232 setattr(_patTauProducer.tauIDSources,
'againstMuonLooseSimple',
233 cms.PSet(inputTag = cms.InputTag(
'hpsPFTauDiscriminationByMuonRejectionSimple'+self.
postfix),
234 provenanceConfigLabel = cms.string(
'IDWPdefinitions'),
235 idLabel = cms.string(
'ByLooseMuonRejectionSimple')
237 setattr(_patTauProducer.tauIDSources,
'againstMuonTightSimple',
238 cms.PSet(inputTag = cms.InputTag(
'hpsPFTauDiscriminationByMuonRejectionSimple'+self.
postfix),
239 provenanceConfigLabel = cms.string(
'IDWPdefinitions'),
240 idLabel = cms.string(
'ByTightMuonRejectionSimple')
246 "hpsPFTauDiscriminationByIsolationMVArun2v1DBoldDMwLT"+self.
postfix,
248 [
"byIsolationMVArun2DBoldDMwLTraw",
"discriminator"]
251 "hpsPFTauDiscriminationByIsolationMVArun2v1DBoldDMwLT"+self.
postfix,
253 [
"byVVLooseIsolationMVArun2DBoldDMwLT",
"_VVLoose"],
254 [
"byVLooseIsolationMVArun2DBoldDMwLT",
"_VLoose"],
255 [
"byLooseIsolationMVArun2DBoldDMwLT",
"_Loose"],
256 [
"byMediumIsolationMVArun2DBoldDMwLT",
"_Medium"],
257 [
"byTightIsolationMVArun2DBoldDMwLT",
"_Tight"],
258 [
"byVTightIsolationMVArun2DBoldDMwLT",
"_VTight"],
259 [
"byVVTightIsolationMVArun2DBoldDMwLT",
"_VVTight"]
262 "hpsPFTauDiscriminationByIsolationMVArun2v1DBnewDMwLT"+self.
postfix,
264 [
"byIsolationMVArun2DBnewDMwLTraw",
"discriminator"]
267 "hpsPFTauDiscriminationByIsolationMVArun2v1DBnewDMwLT"+self.
postfix,
269 [
"byVVLooseIsolationMVArun2DBnewDMwLT",
"_VVLoose"],
270 [
"byVLooseIsolationMVArun2DBnewDMwLT",
"_VLoose"],
271 [
"byLooseIsolationMVArun2DBnewDMwLT",
"_Loose"],
272 [
"byMediumIsolationMVArun2DBnewDMwLT",
"_Medium"],
273 [
"byTightIsolationMVArun2DBnewDMwLT",
"_Tight"],
274 [
"byVTightIsolationMVArun2DBnewDMwLT",
"_VTight"],
275 [
"byVVTightIsolationMVArun2DBnewDMwLT",
"_VVTight"]
279 _updatedTauName =
'selectedPatTausNewIDs'+self.
postfix 280 _noUpdatedTauName =
'selectedPatTausNoNewIDs'+self.
postfix 281 toKeep = [
'deepTau2017v2p1']
284 toKeep = [
'againstEle']
285 import RecoTauTag.RecoTau.tools.runTauIdMVA
as tauIdConfig
286 tauIdEmbedder = tauIdConfig.TauIDEmbedder(
288 originalTauName = _noUpdatedTauName,
289 updatedTauName = _updatedTauName,
293 tauIdEmbedder.runTauID()
298 delattr(self.
process, _updatedTauName)
300 getattr(self.
process,
'rerunMvaIsolationTaskMiniAODTaus'+self.
postfix),
313 output = cms.OutputModule(
315 fileName=cms.untracked.string(
'miniAOD_TauReco.root'),
316 fastCloning=cms.untracked.bool(
False),
317 dataset=cms.untracked.PSet(
318 dataTier=cms.untracked.string(
'MINIAODSIM'),
319 filterName=cms.untracked.string(
'')
321 outputCommands = evtContent.MINIAODSIMEventContent.outputCommands,
322 SelectEvents=cms.untracked.PSet(
323 SelectEvents=cms.vstring(
'*',)
326 output.outputCommands.append(
'keep *_selectedPatTaus'+self.
postfix+
'_*_*')
329 for prod
in evtContent.RecoTauTagAOD.outputCommands:
330 if prod.find(
'ElectronRejection') > -1
and prod.find(
'DeadECAL') == -1:
332 if prod.find(
'MuonRejection') > -1:
334 if prod.find(
"_*_*")>-1:
335 output.outputCommands.append(prod.replace(
"_*_*",self.
postfix+
"_*_*"))
337 m = re.search(
r'_[A-Za-z0-9]+_\*', prod)
340 output.outputCommands.append(prod.replace(inst,self.
postfix+inst))
342 print(
"Warning: \"%s\" do not match known name patterns; trying to keep w/o postfix" % prod)
343 output.outputCommands.append(prod)
345 output.outputCommands.append(
'keep *_hpsPFTauDiscriminationByMuonRejectionSimple'+self.
postfix+
'_*_*')
346 output.outputCommands.append(
'keep *_combinatoricReco*_*_*')
347 output.outputCommands.append(
'keep *_ak4PFJetsRecoTauChargedHadrons'+self.
postfix+
'_*_*')
348 output.outputCommands.append(
'keep *_ak4PFJetsLegacyHPSPiZeros'+self.
postfix+
'_*_*')
349 output.outputCommands.append(
'keep *_patJetsPAT'+self.
postfix+
'_*_*')
350 output.outputCommands.append(
'keep *_boostedTauSeedsPAT'+self.
postfix+
'_*_*')
def setOutputModule(self, mode=0)
def containerID(pset, inputID, provCfgLabel, wps)
def adaptTauToMiniAODReReco(self, reclusterJets=True)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def remove(d, key, TELL=False)
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
void add(std::map< std::string, TH1 *> &h, TH1 *hist)
def __init__(self, process, runBoosted=False, postfix="")
def convertModuleToMiniAODInput(self, name)