1 import FWCore.ParameterSet.Config
as cms
11 if hasattr(process, label+postfix):
12 result = getattr(process, label + postfix)
14 raise ValueError(
"Error in <applyPostfix>: No module of name = %s attached to process !!" % (label + postfix))
19 tauSource = cms.InputTag(
'caloRecoTauProducer'),
22 print ' switching PAT Tau input to: ', tauSource
24 applyPostfix(process,
"tauMatch" + patTauLabel, postfix).src = tauSource
25 applyPostfix(process,
"tauGenJetMatch"+ patTauLabel, postfix).src = tauSource
27 applyPostfix(process,
"patTaus" + patTauLabel, postfix).tauSource = tauSource
29 applyPostfix(process,
"patTaus" + patTauLabel, postfix).tauTransverseImpactParameterSource =
"" 33 print "NO PF Isolation will be computed for CaloTau (this could be improved later)" 34 applyPostfix(process,
"patTaus" + patTauLabel, postfix).isolation = cms.PSet()
35 applyPostfix(process,
"patTaus" + patTauLabel, postfix).isoDeposits = cms.PSet()
36 applyPostfix(process,
"patTaus" + patTauLabel, postfix).userIsolation = cms.PSet()
39 if hasattr(process,
"cleanPatTaus" + patTauLabel + postfix):
40 getattr(process,
"cleanPatTaus" + patTauLabel + postfix).preselection = preselection
43 """ Build a PSet defining the tau ID sources to embed into the pat::Tau """ 45 for label, discriminator
in idSources:
46 if ":" in discriminator:
47 discr = discriminator.split(
":")
48 setattr(output, label, cms.InputTag(tauType + discr[0] + postfix +
":" + discr[1]))
50 setattr(output, label, cms.InputTag(tauType + discriminator + postfix))
59 """internal auxiliary function to switch to **any** PFTau collection""" 60 print ' switching PAT Tau input to: ', tauSource
62 applyPostfix(process,
"tauMatch" + patTauLabel, postfix).src = tauSource
63 applyPostfix(process,
"tauGenJetMatch" + patTauLabel, postfix).src = tauSource
65 applyPostfix(process,
"tauIsoDepositPFCandidates" + patTauLabel, postfix).src = tauSource
66 applyPostfix(process,
"tauIsoDepositPFCandidates" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
67 applyPostfix(process,
"tauIsoDepositPFChargedHadrons" + patTauLabel, postfix).src = tauSource
68 applyPostfix(process,
"tauIsoDepositPFChargedHadrons" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
69 applyPostfix(process,
"tauIsoDepositPFNeutralHadrons" + patTauLabel, postfix).src = tauSource
70 applyPostfix(process,
"tauIsoDepositPFNeutralHadrons" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
71 applyPostfix(process,
"tauIsoDepositPFGammas" + patTauLabel, postfix).src = tauSource
72 applyPostfix(process,
"tauIsoDepositPFGammas" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
74 applyPostfix(process,
"patTaus" + patTauLabel, postfix).tauSource = tauSource
76 applyPostfix(process,
"patTaus" + patTauLabel, postfix).tauTransverseImpactParameterSource =
"" 79 if hasattr(process,
"cleanPatTaus" + patTauLabel + postfix):
80 getattr(process,
"cleanPatTaus" + patTauLabel + postfix).preselection = preselection
83 classicTauIDSources = [
84 (
"leadingTrackFinding",
"DiscriminationByLeadingTrackFinding"),
85 (
"leadingTrackPtCut",
"DiscriminationByLeadingTrackPtCut"),
86 (
"trackIsolation",
"DiscriminationByTrackIsolation"),
87 (
"ecalIsolation",
"DiscriminationByECALIsolation"),
88 (
"byIsolation",
"DiscriminationByIsolation"),
89 (
"againstElectron",
"DiscriminationAgainstElectron"),
90 (
"againstMuon",
"DiscriminationAgainstMuon")
93 classicPFTauIDSources = [
94 (
"leadingPionPtCut",
"DiscriminationByLeadingPionPtCut"),
95 (
"trackIsolationUsingLeadingPion",
"DiscriminationByTrackIsolationUsingLeadingPion"),
96 (
"ecalIsolationUsingLeadingPion",
"DiscriminationByECALIsolationUsingLeadingPion"),
97 (
"byIsolationUsingLeadingPion",
"DiscriminationByIsolationUsingLeadingPion")
102 (
"decayModeFindingNewDMs",
"DiscriminationByDecayModeFindingNewDMs"),
103 (
"decayModeFinding",
"DiscriminationByDecayModeFinding"),
104 (
"byLooseCombinedIsolationDeltaBetaCorr3Hits",
"DiscriminationByLooseCombinedIsolationDBSumPtCorr3Hits"),
105 (
"byMediumCombinedIsolationDeltaBetaCorr3Hits",
"DiscriminationByMediumCombinedIsolationDBSumPtCorr3Hits"),
106 (
"byTightCombinedIsolationDeltaBetaCorr3Hits",
"DiscriminationByTightCombinedIsolationDBSumPtCorr3Hits"),
107 (
"byCombinedIsolationDeltaBetaCorrRaw3Hits",
"DiscriminationByRawCombinedIsolationDBSumPtCorr3Hits"),
108 (
"byLooseCombinedIsolationDeltaBetaCorr3HitsdR03",
"DiscriminationByLooseCombinedIsolationDBSumPtCorr3HitsdR03"),
109 (
"byMediumCombinedIsolationDeltaBetaCorr3HitsdR03",
"DiscriminationByMediumCombinedIsolationDBSumPtCorr3HitsdR03"),
110 (
"byTightCombinedIsolationDeltaBetaCorr3HitsdR03",
"DiscriminationByTightCombinedIsolationDBSumPtCorr3HitsdR03"),
111 (
"byPhotonPtSumOutsideSignalCone",
"DiscriminationByPhotonPtSumOutsideSignalCone"),
112 (
"chargedIsoPtSum",
"ChargedIsoPtSum"),
113 (
"neutralIsoPtSum",
"NeutralIsoPtSum"),
114 (
"puCorrPtSum",
"PUcorrPtSum"),
115 (
"neutralIsoPtSumWeight",
"NeutralIsoPtSumWeight"),
116 (
"footprintCorrection",
"FootprintCorrection"),
117 (
"photonPtSumOutsideSignalCone",
"PhotonPtSumOutsideSignalCone"),
118 (
"againstMuonLoose3",
"DiscriminationByLooseMuonRejection3"),
119 (
"againstMuonTight3",
"DiscriminationByTightMuonRejection3"),
120 (
"byIsolationMVArun2v1DBoldDMwLTraw",
"DiscriminationByIsolationMVArun2v1DBoldDMwLTraw"),
121 (
"byVLooseIsolationMVArun2v1DBoldDMwLT",
"DiscriminationByVLooseIsolationMVArun2v1DBoldDMwLT"),
122 (
"byLooseIsolationMVArun2v1DBoldDMwLT",
"DiscriminationByLooseIsolationMVArun2v1DBoldDMwLT"),
123 (
"byMediumIsolationMVArun2v1DBoldDMwLT",
"DiscriminationByMediumIsolationMVArun2v1DBoldDMwLT"),
124 (
"byTightIsolationMVArun2v1DBoldDMwLT",
"DiscriminationByTightIsolationMVArun2v1DBoldDMwLT"),
125 (
"byVTightIsolationMVArun2v1DBoldDMwLT",
"DiscriminationByVTightIsolationMVArun2v1DBoldDMwLT"),
126 (
"byVVTightIsolationMVArun2v1DBoldDMwLT",
"DiscriminationByVVTightIsolationMVArun2v1DBoldDMwLT"),
127 (
"byIsolationMVArun2v1DBnewDMwLTraw",
"DiscriminationByIsolationMVArun2v1DBnewDMwLTraw"),
128 (
"byVLooseIsolationMVArun2v1DBnewDMwLT",
"DiscriminationByVLooseIsolationMVArun2v1DBnewDMwLT"),
129 (
"byLooseIsolationMVArun2v1DBnewDMwLT",
"DiscriminationByLooseIsolationMVArun2v1DBnewDMwLT"),
130 (
"byMediumIsolationMVArun2v1DBnewDMwLT",
"DiscriminationByMediumIsolationMVArun2v1DBnewDMwLT"),
131 (
"byTightIsolationMVArun2v1DBnewDMwLT",
"DiscriminationByTightIsolationMVArun2v1DBnewDMwLT"),
132 (
"byVTightIsolationMVArun2v1DBnewDMwLT",
"DiscriminationByVTightIsolationMVArun2v1DBnewDMwLT"),
133 (
"byVVTightIsolationMVArun2v1DBnewDMwLT",
"DiscriminationByVVTightIsolationMVArun2v1DBnewDMwLT"),
134 (
"byIsolationMVArun2v1PWoldDMwLTraw",
"DiscriminationByIsolationMVArun2v1PWoldDMwLTraw"),
135 (
"byVLooseIsolationMVArun2v1PWoldDMwLT",
"DiscriminationByVLooseIsolationMVArun2v1PWoldDMwLT"),
136 (
"byLooseIsolationMVArun2v1PWoldDMwLT",
"DiscriminationByLooseIsolationMVArun2v1PWoldDMwLT"),
137 (
"byMediumIsolationMVArun2v1PWoldDMwLT",
"DiscriminationByMediumIsolationMVArun2v1PWoldDMwLT"),
138 (
"byTightIsolationMVArun2v1PWoldDMwLT",
"DiscriminationByTightIsolationMVArun2v1PWoldDMwLT"),
139 (
"byVTightIsolationMVArun2v1PWoldDMwLT",
"DiscriminationByVTightIsolationMVArun2v1PWoldDMwLT"),
140 (
"byVVTightIsolationMVArun2v1PWoldDMwLT",
"DiscriminationByVVTightIsolationMVArun2v1PWoldDMwLT"),
141 (
"byIsolationMVArun2v1PWnewDMwLTraw",
"DiscriminationByIsolationMVArun2v1PWnewDMwLTraw"),
142 (
"byVLooseIsolationMVArun2v1PWnewDMwLT",
"DiscriminationByVLooseIsolationMVArun2v1PWnewDMwLT"),
143 (
"byLooseIsolationMVArun2v1PWnewDMwLT",
"DiscriminationByLooseIsolationMVArun2v1PWnewDMwLT"),
144 (
"byMediumIsolationMVArun2v1PWnewDMwLT",
"DiscriminationByMediumIsolationMVArun2v1PWnewDMwLT"),
145 (
"byTightIsolationMVArun2v1PWnewDMwLT",
"DiscriminationByTightIsolationMVArun2v1PWnewDMwLT"),
146 (
"byVTightIsolationMVArun2v1PWnewDMwLT",
"DiscriminationByVTightIsolationMVArun2v1PWnewDMwLT"),
147 (
"byVVTightIsolationMVArun2v1PWnewDMwLT",
"DiscriminationByVVTightIsolationMVArun2v1PWnewDMwLT"),
148 (
"chargedIsoPtSumdR03",
"ChargedIsoPtSumdR03"),
149 (
"neutralIsoPtSumdR03",
"NeutralIsoPtSumdR03"),
150 (
"neutralIsoPtSumWeightdR03",
"NeutralIsoPtSumWeightdR03"),
151 (
"footprintCorrectiondR03",
"FootprintCorrectiondR03"),
152 (
"photonPtSumOutsideSignalConedR03",
"PhotonPtSumOutsideSignalConedR03"),
153 (
"byIsolationMVArun2v1DBdR03oldDMwLTraw",
"DiscriminationByIsolationMVArun2v1DBdR03oldDMwLTraw"),
154 (
"byVLooseIsolationMVArun2v1DBdR03oldDMwLT",
"DiscriminationByVLooseIsolationMVArun2v1DBdR03oldDMwLT"),
155 (
"byLooseIsolationMVArun2v1DBdR03oldDMwLT",
"DiscriminationByLooseIsolationMVArun2v1DBdR03oldDMwLT"),
156 (
"byMediumIsolationMVArun2v1DBdR03oldDMwLT",
"DiscriminationByMediumIsolationMVArun2v1DBdR03oldDMwLT"),
157 (
"byTightIsolationMVArun2v1DBdR03oldDMwLT",
"DiscriminationByTightIsolationMVArun2v1DBdR03oldDMwLT"),
158 (
"byVTightIsolationMVArun2v1DBdR03oldDMwLT",
"DiscriminationByVTightIsolationMVArun2v1DBdR03oldDMwLT"),
159 (
"byVVTightIsolationMVArun2v1DBdR03oldDMwLT",
"DiscriminationByVVTightIsolationMVArun2v1DBdR03oldDMwLT"),
160 (
"byIsolationMVArun2v1PWdR03oldDMwLTraw",
"DiscriminationByIsolationMVArun2v1PWdR03oldDMwLTraw"),
161 (
"byVLooseIsolationMVArun2v1PWdR03oldDMwLT",
"DiscriminationByVLooseIsolationMVArun2v1PWdR03oldDMwLT"),
162 (
"byLooseIsolationMVArun2v1PWdR03oldDMwLT",
"DiscriminationByLooseIsolationMVArun2v1PWdR03oldDMwLT"),
163 (
"byMediumIsolationMVArun2v1PWdR03oldDMwLT",
"DiscriminationByMediumIsolationMVArun2v1PWdR03oldDMwLT"),
164 (
"byTightIsolationMVArun2v1PWdR03oldDMwLT",
"DiscriminationByTightIsolationMVArun2v1PWdR03oldDMwLT"),
165 (
"byVTightIsolationMVArun2v1PWdR03oldDMwLT",
"DiscriminationByVTightIsolationMVArun2v1PWdR03oldDMwLT"),
166 (
"byVVTightIsolationMVArun2v1PWdR03oldDMwLT",
"DiscriminationByVVTightIsolationMVArun2v1PWdR03oldDMwLT"),
167 (
"againstElectronMVA6Raw",
"DiscriminationByMVA6rawElectronRejection"),
168 (
"againstElectronMVA6category",
"DiscriminationByMVA6rawElectronRejection:category"),
169 (
"againstElectronVLooseMVA6",
"DiscriminationByMVA6VLooseElectronRejection"),
170 (
"againstElectronLooseMVA6",
"DiscriminationByMVA6LooseElectronRejection"),
171 (
"againstElectronMediumMVA6",
"DiscriminationByMVA6MediumElectronRejection"),
172 (
"againstElectronTightMVA6",
"DiscriminationByMVA6TightElectronRejection"),
173 (
"againstElectronVTightMVA6",
"DiscriminationByMVA6VTightElectronRejection"),
178 tauSource = cms.InputTag(
'fixedConePFTauProducer'),
181 fixedConeIDSources = copy.copy(classicTauIDSources)
182 fixedConeIDSources.extend(classicPFTauIDSources)
184 _switchToPFTau(process, tauSource,
'fixedConePFTau', fixedConeIDSources,
185 patTauLabel = patTauLabel, postfix = postfix)
189 tauSource = cms.InputTag(
'shrinkingConePFTauProducer'),
192 shrinkingIDSources = copy.copy(classicTauIDSources)
193 shrinkingIDSources.extend(classicPFTauIDSources)
195 _switchToPFTau(process, tauSource,
'shrinkingConePFTau', shrinkingIDSources,
196 patTauLabel = patTauLabel, postfix = postfix)
200 tauSource = cms.InputTag(
'hpsPFTauProducer'),
206 patTauLabel = patTauLabel, postfix = postfix)
209 applyPostfix(process,
"patTaus" + patTauLabel, postfix).tauTransverseImpactParameterSource = tauSource.value().
replace(
"Producer",
"TransverseImpactParameters")
212 if hasattr(process,
"cleanPatTaus" + patTauLabel + postfix):
213 getattr(process,
"cleanPatTaus" + patTauLabel + postfix).preselection = preselection
218 tauSource = cms.InputTag(
'hpsPFTauProducer'),
222 'shrinkingConePFTau' : switchToPFTauShrinkingCone,
223 'fixedConePFTau' : switchToPFTauFixedCone,
224 'hpsPFTau' : switchToPFTauHPS,
225 'caloRecoTau' : switchToCaloTau
227 if not pfTauType
in mapping.keys():
228 raise ValueError(
"Error in <switchToPFTauByType>: Undefined pfTauType = %s !!" % pfTauType)
230 mapping[pfTauType](process, tauSource = tauSource,
231 patTauLabel = patTauLabel, postfix = postfix)
235 """ Add a new collection of taus. Takes the configuration from the 236 already configured standard tau collection as starting point; 237 replaces before calling addTauCollection will also affect the 240 _label=
'addTauCollection' 241 _defaultParameters=dicttypes.SortedKeysDict()
243 ConfigToolBase.__init__(self)
245 self._defaultValue,
'Input tau collection', cms.InputTag)
247 self._defaultValue,
"label to indicate the tau algorithm (e.g.'hps')", str)
249 self._defaultValue,
"label to indicate the type of constituents (either 'PFTau' or 'Tau')", str)
251 True,
"run sequence for computing particle-flow based IsoDeposits")
253 "hps",
"standard algorithm label of the collection from which the clones " \
254 +
"for the new tau collection will be taken from " \
255 +
"(note that this tau collection has to be available in the event before hand)")
257 "PFTau",
"standard constituent type label of the collection from which the clones " \
258 +
" for the new tau collection will be taken from "\
259 +
"(note that this tau collection has to be available in the event before hand)")
268 tauCollection =
None,
271 doPFIsoDeposits =
None,
274 standardType =
None):
276 if tauCollection
is None:
278 if algoLabel
is None:
280 if typeLabel
is None:
282 if doPFIsoDeposits
is None:
284 if standardAlgo
is None:
286 if standardType
is None:
289 self.setParameter(
'tauCollection', tauCollection)
290 self.setParameter(
'algoLabel', algoLabel)
291 self.setParameter(
'typeLabel', typeLabel)
292 self.setParameter(
'doPFIsoDeposits', doPFIsoDeposits)
293 self.setParameter(
'standardAlgo', standardAlgo)
294 self.setParameter(
'standardType', standardType)
299 tauCollection = self.
_parameters[
'tauCollection'].value
302 doPFIsoDeposits = self.
_parameters[
'doPFIsoDeposits'].value
303 standardAlgo = self.
_parameters[
'standardAlgo'].value
304 standardType = self.
_parameters[
'standardType'].value
308 if typeLabel ==
'Tau':
309 print "NO PF Isolation will be computed for CaloTau (this could be improved later)" 310 doPFIsoDeposits =
False 314 def oldLabel(prefix = ''):
318 return prefix +
"PatTaus" 323 def capitalize(label):
324 return label[0].capitalize() + label[1:]
328 def newLabel(oldLabel):
330 if ( oldLabel.find(standardAlgo) >= 0
and oldLabel.find(standardType) >= 0 ):
331 oldLabel = oldLabel.replace(standardAlgo, algoLabel).
replace(standardType, typeLabel)
333 oldLabel = oldLabel + capitalize(algoLabel + typeLabel)
337 def addClone(hook, **replaceStatements):
340 newModule = getattr(process, hook).
clone(**replaceStatements)
343 def addPFIsoDepositClone(hook, **replaceStatements):
344 newModule = getattr(process, hook).
clone(**replaceStatements)
345 newModuleIsoDepositExtractor = getattr(newModule,
"ExtractorPSet")
346 setattr(newModuleIsoDepositExtractor,
"tauSource", getattr(newModule,
"src"))
349 addClone(oldLabel(), tauSource = tauCollection)
352 addClone(oldLabel(
'selected'), src = cms.InputTag(newLabel(oldLabel())))
355 addClone(oldLabel(
'clean'), src=cms.InputTag(newLabel(oldLabel(
'selected'))))
358 newTaus = getattr(process, newLabel(oldLabel()))
361 addClone(
'tauMatch', src = tauCollection)
362 addClone(
'tauGenJetMatch', src = tauCollection)
366 addPFIsoDepositClone(
'tauIsoDepositPFCandidates', src = tauCollection)
367 addPFIsoDepositClone(
'tauIsoDepositPFChargedHadrons', src = tauCollection)
368 addPFIsoDepositClone(
'tauIsoDepositPFNeutralHadrons', src = tauCollection)
369 addPFIsoDepositClone(
'tauIsoDepositPFGammas', src = tauCollection)
373 x.setModuleLabel(newLabel(x.moduleLabel))
376 fixInputTag(newTaus.genParticleMatch)
377 fixInputTag(newTaus.genJetMatch)
378 fixInputTag(newTaus.isoDeposits.pfAllParticles)
379 fixInputTag(newTaus.isoDeposits.pfNeutralHadron)
380 fixInputTag(newTaus.isoDeposits.pfChargedHadron)
381 fixInputTag(newTaus.isoDeposits.pfGamma)
382 fixInputTag(newTaus.userIsolation.pfAllParticles.src)
383 fixInputTag(newTaus.userIsolation.pfNeutralHadron.src)
384 fixInputTag(newTaus.userIsolation.pfChargedHadron.src)
385 fixInputTag(newTaus.userIsolation.pfGamma.src)
389 oldTaus = getattr(process, oldLabel())
390 if typeLabel ==
'Tau':
392 tauSource = getattr(newTaus,
"tauSource"),
393 patTauLabel = capitalize(algoLabel + typeLabel))
396 tauSource = getattr(newTaus,
"tauSource"),
397 patTauLabel = capitalize(algoLabel + typeLabel))
def replace(string, replacements)
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)