1 import FWCore.ParameterSet.Config
as cms
10 if hasattr(process, label+postfix):
11 result = getattr(process, label + postfix)
13 raise ValueError(
"Error in <applyPostfix>: No module of name = %s attached to process !!" % (label + postfix))
18 tauSource = cms.InputTag(
'caloRecoTauProducer'),
21 print ' switching PAT Tau input to: ', tauSource
23 applyPostfix(process,
"tauMatch" + patTauLabel, postfix).src = tauSource
24 applyPostfix(process,
"tauGenJetMatch"+ patTauLabel, postfix).src = tauSource
26 applyPostfix(process,
"patTaus" + patTauLabel, postfix).tauSource = tauSource
28 applyPostfix(process,
"patTaus" + patTauLabel, postfix).tauTransverseImpactParameterSource =
""
32 print "NO PF Isolation will be computed for CaloTau (this could be improved later)"
33 applyPostfix(process,
"patTaus" + patTauLabel, postfix).isolation = cms.PSet()
34 applyPostfix(process,
"patTaus" + patTauLabel, postfix).isoDeposits = cms.PSet()
35 applyPostfix(process,
"patTaus" + patTauLabel, postfix).userIsolation = cms.PSet()
38 if hasattr(process,
"cleanPatTaus" + patTauLabel + postfix):
39 getattr(process,
"cleanPatTaus" + patTauLabel + postfix).preselection = \
40 'tauID("leadingTrackFinding") > 0.5 & tauID("leadingTrackPtCut") > 0.5' \
41 +
' & tauID("byIsolation") > 0.5 & tauID("againstElectron") > 0.5 & (signalTracks.size() = 1 | signalTracks.size() = 3)'
44 """ Build a PSet defining the tau ID sources to embed into the pat::Tau """
46 for label, discriminator
in idSources:
47 if ":" in discriminator:
48 discr = discriminator.split(
":")
49 setattr(output, label, cms.InputTag(tauType + discr[0] + postfix +
":" + discr[1]))
51 setattr(output, label, cms.InputTag(tauType + discriminator + postfix))
60 """internal auxiliary function to switch to **any** PFTau collection"""
61 print ' switching PAT Tau input to: ', tauSource
63 applyPostfix(process,
"tauMatch" + patTauLabel, postfix).src = tauSource
64 applyPostfix(process,
"tauGenJetMatch" + patTauLabel, postfix).src = tauSource
66 applyPostfix(process,
"tauIsoDepositPFCandidates" + patTauLabel, postfix).src = tauSource
67 applyPostfix(process,
"tauIsoDepositPFCandidates" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
68 applyPostfix(process,
"tauIsoDepositPFChargedHadrons" + patTauLabel, postfix).src = tauSource
69 applyPostfix(process,
"tauIsoDepositPFChargedHadrons" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
70 applyPostfix(process,
"tauIsoDepositPFNeutralHadrons" + patTauLabel, postfix).src = tauSource
71 applyPostfix(process,
"tauIsoDepositPFNeutralHadrons" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
72 applyPostfix(process,
"tauIsoDepositPFGammas" + patTauLabel, postfix).src = tauSource
73 applyPostfix(process,
"tauIsoDepositPFGammas" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
75 applyPostfix(process,
"patTaus" + patTauLabel, postfix).tauSource = tauSource
77 applyPostfix(process,
"patTaus" + patTauLabel, postfix).tauTransverseImpactParameterSource =
""
80 if hasattr(process,
"cleanPatTaus" + patTauLabel + postfix):
81 getattr(process,
"cleanPatTaus" + patTauLabel + postfix).preselection = \
82 'tauID("leadingTrackFinding") > 0.5 & tauID("leadingPionPtCut") > 0.5 & tauID("byIsolationUsingLeadingPion") > 0.5' \
83 +
' & tauID("againstMuon") > 0.5 & tauID("againstElectron") > 0.5' \
84 +
' & (signalPFChargedHadrCands.size() = 1 | signalPFChargedHadrCands.size() = 3)'
87 classicTauIDSources = [
88 (
"leadingTrackFinding",
"DiscriminationByLeadingTrackFinding"),
89 (
"leadingTrackPtCut",
"DiscriminationByLeadingTrackPtCut"),
90 (
"trackIsolation",
"DiscriminationByTrackIsolation"),
91 (
"ecalIsolation",
"DiscriminationByECALIsolation"),
92 (
"byIsolation",
"DiscriminationByIsolation"),
93 (
"againstElectron",
"DiscriminationAgainstElectron"),
94 (
"againstMuon",
"DiscriminationAgainstMuon")
97 classicPFTauIDSources = [
98 (
"leadingPionPtCut",
"DiscriminationByLeadingPionPtCut"),
99 (
"trackIsolationUsingLeadingPion",
"DiscriminationByTrackIsolationUsingLeadingPion"),
100 (
"ecalIsolationUsingLeadingPion",
"DiscriminationByECALIsolationUsingLeadingPion"),
101 (
"byIsolationUsingLeadingPion",
"DiscriminationByIsolationUsingLeadingPion")
106 (
"decayModeFindingNewDMs",
"DiscriminationByDecayModeFindingNewDMs"),
107 (
"decayModeFinding",
"DiscriminationByDecayModeFinding"),
108 (
"byLooseCombinedIsolationDeltaBetaCorr3Hits",
"DiscriminationByLooseCombinedIsolationDBSumPtCorr3Hits"),
109 (
"byMediumCombinedIsolationDeltaBetaCorr3Hits",
"DiscriminationByMediumCombinedIsolationDBSumPtCorr3Hits"),
110 (
"byTightCombinedIsolationDeltaBetaCorr3Hits",
"DiscriminationByTightCombinedIsolationDBSumPtCorr3Hits"),
111 (
"byCombinedIsolationDeltaBetaCorrRaw3Hits",
"DiscriminationByRawCombinedIsolationDBSumPtCorr3Hits"),
112 (
"byLooseCombinedIsolationDeltaBetaCorr3HitsdR03",
"DiscriminationByLooseCombinedIsolationDBSumPtCorr3HitsdR03"),
113 (
"byMediumCombinedIsolationDeltaBetaCorr3HitsdR03",
"DiscriminationByMediumCombinedIsolationDBSumPtCorr3HitsdR03"),
114 (
"byTightCombinedIsolationDeltaBetaCorr3HitsdR03",
"DiscriminationByTightCombinedIsolationDBSumPtCorr3HitsdR03"),
115 (
"byPhotonPtSumOutsideSignalCone",
"DiscriminationByPhotonPtSumOutsideSignalCone"),
116 (
"chargedIsoPtSum",
"ChargedIsoPtSum"),
117 (
"neutralIsoPtSum",
"NeutralIsoPtSum"),
118 (
"puCorrPtSum",
"PUcorrPtSum"),
119 (
"neutralIsoPtSumWeight",
"NeutralIsoPtSumWeight"),
120 (
"footprintCorrection",
"FootprintCorrection"),
121 (
"photonPtSumOutsideSignalCone",
"PhotonPtSumOutsideSignalCone"),
122 (
"againstMuonLoose3",
"DiscriminationByLooseMuonRejection3"),
123 (
"againstMuonTight3",
"DiscriminationByTightMuonRejection3"),
124 (
"byIsolationMVArun2v1DBoldDMwLTraw",
"DiscriminationByIsolationMVArun2v1DBoldDMwLTraw"),
125 (
"byVLooseIsolationMVArun2v1DBoldDMwLT",
"DiscriminationByVLooseIsolationMVArun2v1DBoldDMwLT"),
126 (
"byLooseIsolationMVArun2v1DBoldDMwLT",
"DiscriminationByLooseIsolationMVArun2v1DBoldDMwLT"),
127 (
"byMediumIsolationMVArun2v1DBoldDMwLT",
"DiscriminationByMediumIsolationMVArun2v1DBoldDMwLT"),
128 (
"byTightIsolationMVArun2v1DBoldDMwLT",
"DiscriminationByTightIsolationMVArun2v1DBoldDMwLT"),
129 (
"byVTightIsolationMVArun2v1DBoldDMwLT",
"DiscriminationByVTightIsolationMVArun2v1DBoldDMwLT"),
130 (
"byVVTightIsolationMVArun2v1DBoldDMwLT",
"DiscriminationByVVTightIsolationMVArun2v1DBoldDMwLT"),
131 (
"byIsolationMVArun2v1DBnewDMwLTraw",
"DiscriminationByIsolationMVArun2v1DBnewDMwLTraw"),
132 (
"byVLooseIsolationMVArun2v1DBnewDMwLT",
"DiscriminationByVLooseIsolationMVArun2v1DBnewDMwLT"),
133 (
"byLooseIsolationMVArun2v1DBnewDMwLT",
"DiscriminationByLooseIsolationMVArun2v1DBnewDMwLT"),
134 (
"byMediumIsolationMVArun2v1DBnewDMwLT",
"DiscriminationByMediumIsolationMVArun2v1DBnewDMwLT"),
135 (
"byTightIsolationMVArun2v1DBnewDMwLT",
"DiscriminationByTightIsolationMVArun2v1DBnewDMwLT"),
136 (
"byVTightIsolationMVArun2v1DBnewDMwLT",
"DiscriminationByVTightIsolationMVArun2v1DBnewDMwLT"),
137 (
"byVVTightIsolationMVArun2v1DBnewDMwLT",
"DiscriminationByVVTightIsolationMVArun2v1DBnewDMwLT"),
138 (
"byIsolationMVArun2v1PWoldDMwLTraw",
"DiscriminationByIsolationMVArun2v1PWoldDMwLTraw"),
139 (
"byVLooseIsolationMVArun2v1PWoldDMwLT",
"DiscriminationByVLooseIsolationMVArun2v1PWoldDMwLT"),
140 (
"byLooseIsolationMVArun2v1PWoldDMwLT",
"DiscriminationByLooseIsolationMVArun2v1PWoldDMwLT"),
141 (
"byMediumIsolationMVArun2v1PWoldDMwLT",
"DiscriminationByMediumIsolationMVArun2v1PWoldDMwLT"),
142 (
"byTightIsolationMVArun2v1PWoldDMwLT",
"DiscriminationByTightIsolationMVArun2v1PWoldDMwLT"),
143 (
"byVTightIsolationMVArun2v1PWoldDMwLT",
"DiscriminationByVTightIsolationMVArun2v1PWoldDMwLT"),
144 (
"byVVTightIsolationMVArun2v1PWoldDMwLT",
"DiscriminationByVVTightIsolationMVArun2v1PWoldDMwLT"),
145 (
"byIsolationMVArun2v1PWnewDMwLTraw",
"DiscriminationByIsolationMVArun2v1PWnewDMwLTraw"),
146 (
"byVLooseIsolationMVArun2v1PWnewDMwLT",
"DiscriminationByVLooseIsolationMVArun2v1PWnewDMwLT"),
147 (
"byLooseIsolationMVArun2v1PWnewDMwLT",
"DiscriminationByLooseIsolationMVArun2v1PWnewDMwLT"),
148 (
"byMediumIsolationMVArun2v1PWnewDMwLT",
"DiscriminationByMediumIsolationMVArun2v1PWnewDMwLT"),
149 (
"byTightIsolationMVArun2v1PWnewDMwLT",
"DiscriminationByTightIsolationMVArun2v1PWnewDMwLT"),
150 (
"byVTightIsolationMVArun2v1PWnewDMwLT",
"DiscriminationByVTightIsolationMVArun2v1PWnewDMwLT"),
151 (
"byVVTightIsolationMVArun2v1PWnewDMwLT",
"DiscriminationByVVTightIsolationMVArun2v1PWnewDMwLT"),
152 (
"chargedIsoPtSumdR03",
"ChargedIsoPtSumdR03"),
153 (
"neutralIsoPtSumdR03",
"NeutralIsoPtSumdR03"),
154 (
"neutralIsoPtSumWeightdR03",
"NeutralIsoPtSumWeightdR03"),
155 (
"footprintCorrectiondR03",
"FootprintCorrectiondR03"),
156 (
"photonPtSumOutsideSignalConedR03",
"PhotonPtSumOutsideSignalConedR03"),
157 (
"byIsolationMVArun2v1DBdR03oldDMwLTraw",
"DiscriminationByIsolationMVArun2v1DBdR03oldDMwLTraw"),
158 (
"byVLooseIsolationMVArun2v1DBdR03oldDMwLT",
"DiscriminationByVLooseIsolationMVArun2v1DBdR03oldDMwLT"),
159 (
"byLooseIsolationMVArun2v1DBdR03oldDMwLT",
"DiscriminationByLooseIsolationMVArun2v1DBdR03oldDMwLT"),
160 (
"byMediumIsolationMVArun2v1DBdR03oldDMwLT",
"DiscriminationByMediumIsolationMVArun2v1DBdR03oldDMwLT"),
161 (
"byTightIsolationMVArun2v1DBdR03oldDMwLT",
"DiscriminationByTightIsolationMVArun2v1DBdR03oldDMwLT"),
162 (
"byVTightIsolationMVArun2v1DBdR03oldDMwLT",
"DiscriminationByVTightIsolationMVArun2v1DBdR03oldDMwLT"),
163 (
"byVVTightIsolationMVArun2v1DBdR03oldDMwLT",
"DiscriminationByVVTightIsolationMVArun2v1DBdR03oldDMwLT"),
164 (
"byIsolationMVArun2v1PWdR03oldDMwLTraw",
"DiscriminationByIsolationMVArun2v1PWdR03oldDMwLTraw"),
165 (
"byVLooseIsolationMVArun2v1PWdR03oldDMwLT",
"DiscriminationByVLooseIsolationMVArun2v1PWdR03oldDMwLT"),
166 (
"byLooseIsolationMVArun2v1PWdR03oldDMwLT",
"DiscriminationByLooseIsolationMVArun2v1PWdR03oldDMwLT"),
167 (
"byMediumIsolationMVArun2v1PWdR03oldDMwLT",
"DiscriminationByMediumIsolationMVArun2v1PWdR03oldDMwLT"),
168 (
"byTightIsolationMVArun2v1PWdR03oldDMwLT",
"DiscriminationByTightIsolationMVArun2v1PWdR03oldDMwLT"),
169 (
"byVTightIsolationMVArun2v1PWdR03oldDMwLT",
"DiscriminationByVTightIsolationMVArun2v1PWdR03oldDMwLT"),
170 (
"byVVTightIsolationMVArun2v1PWdR03oldDMwLT",
"DiscriminationByVVTightIsolationMVArun2v1PWdR03oldDMwLT"),
171 (
"againstElectronMVA6Raw",
"DiscriminationByMVA6rawElectronRejection"),
172 (
"againstElectronMVA6category",
"DiscriminationByMVA6rawElectronRejection:category"),
173 (
"againstElectronVLooseMVA6",
"DiscriminationByMVA6VLooseElectronRejection"),
174 (
"againstElectronLooseMVA6",
"DiscriminationByMVA6LooseElectronRejection"),
175 (
"againstElectronMediumMVA6",
"DiscriminationByMVA6MediumElectronRejection"),
176 (
"againstElectronTightMVA6",
"DiscriminationByMVA6TightElectronRejection"),
177 (
"againstElectronVTightMVA6",
"DiscriminationByMVA6VTightElectronRejection"),
182 tauSource = cms.InputTag(
'fixedConePFTauProducer'),
185 fixedConeIDSources = copy.copy(classicTauIDSources)
186 fixedConeIDSources.extend(classicPFTauIDSources)
188 _switchToPFTau(process, tauSource,
'fixedConePFTau', fixedConeIDSources,
189 patTauLabel = patTauLabel, postfix = postfix)
193 tauSource = cms.InputTag(
'shrinkingConePFTauProducer'),
196 shrinkingIDSources = copy.copy(classicTauIDSources)
197 shrinkingIDSources.extend(classicPFTauIDSources)
199 _switchToPFTau(process, tauSource,
'shrinkingConePFTau', shrinkingIDSources,
200 patTauLabel = patTauLabel, postfix = postfix)
204 tauSource = cms.InputTag(
'hpsPFTauProducer'),
210 patTauLabel = patTauLabel, postfix = postfix)
213 applyPostfix(process,
"patTaus" + patTauLabel, postfix).tauTransverseImpactParameterSource = tauSource.value().
replace(
"Producer",
"TransverseImpactParameters")
216 if hasattr(process,
"cleanPatTaus" + patTauLabel + postfix):
217 getattr(process,
"cleanPatTaus" + patTauLabel + postfix).preselection = \
218 'pt > 18 & abs(eta) < 2.3 & tauID("decayModeFinding") > 0.5 & tauID("byLooseCombinedIsolationDeltaBetaCorr3Hits") > 0.5' \
219 +
' & tauID("againstMuonTight3") > 0.5 & tauID("againstElectronVLooseMVA6") > 0.5'
225 tauSource = cms.InputTag(
'hpsPFTauProducer'),
229 'shrinkingConePFTau' : switchToPFTauShrinkingCone,
230 'fixedConePFTau' : switchToPFTauFixedCone,
231 'hpsPFTau' : switchToPFTauHPS,
232 'caloRecoTau' : switchToCaloTau
234 if not pfTauType
in mapping.keys():
235 raise ValueError(
"Error in <switchToPFTauByType>: Undefined pfTauType = %s !!" % pfTauType)
237 mapping[pfTauType](process, tauSource = tauSource,
238 patTauLabel = patTauLabel, postfix = postfix)
242 """ Add a new collection of taus. Takes the configuration from the
243 already configured standard tau collection as starting point;
244 replaces before calling addTauCollection will also affect the
247 _label=
'addTauCollection'
248 _defaultParameters=dicttypes.SortedKeysDict()
250 ConfigToolBase.__init__(self)
252 self._defaultValue,
'Input tau collection', cms.InputTag)
254 self._defaultValue,
"label to indicate the tau algorithm (e.g.'hps')", str)
256 self._defaultValue,
"label to indicate the type of constituents (either 'PFTau' or 'Tau')", str)
258 True,
"run sequence for computing particle-flow based IsoDeposits")
260 "hps",
"standard algorithm label of the collection from which the clones " \
261 +
"for the new tau collection will be taken from " \
262 +
"(note that this tau collection has to be available in the event before hand)")
264 "PFTau",
"standard constituent type label of the collection from which the clones " \
265 +
" for the new tau collection will be taken from "\
266 +
"(note that this tau collection has to be available in the event before hand)")
275 tauCollection =
None,
278 doPFIsoDeposits =
None,
281 standardType =
None):
283 if tauCollection
is None:
285 if algoLabel
is None:
287 if typeLabel
is None:
289 if doPFIsoDeposits
is None:
291 if standardAlgo
is None:
293 if standardType
is None:
296 self.setParameter(
'tauCollection', tauCollection)
297 self.setParameter(
'algoLabel', algoLabel)
298 self.setParameter(
'typeLabel', typeLabel)
299 self.setParameter(
'doPFIsoDeposits', doPFIsoDeposits)
300 self.setParameter(
'standardAlgo', standardAlgo)
301 self.setParameter(
'standardType', standardType)
306 tauCollection = self.
_parameters[
'tauCollection'].value
309 doPFIsoDeposits = self.
_parameters[
'doPFIsoDeposits'].value
310 standardAlgo = self.
_parameters[
'standardAlgo'].value
311 standardType = self.
_parameters[
'standardType'].value
315 if typeLabel ==
'Tau':
316 print "NO PF Isolation will be computed for CaloTau (this could be improved later)"
317 doPFIsoDeposits =
False
321 def oldLabel(prefix = ''):
325 return prefix +
"PatTaus"
330 def capitalize(label):
331 return label[0].capitalize() + label[1:]
335 def newLabel(oldLabel):
337 if ( oldLabel.find(standardAlgo) >= 0
and oldLabel.find(standardType) >= 0 ):
338 oldLabel = oldLabel.replace(standardAlgo, algoLabel).
replace(standardType, typeLabel)
340 oldLabel = oldLabel + capitalize(algoLabel + typeLabel)
344 def addClone(hook, **replaceStatements):
347 newModule = getattr(process, hook).
clone(**replaceStatements)
350 def addPFIsoDepositClone(hook, **replaceStatements):
351 newModule = getattr(process, hook).
clone(**replaceStatements)
352 newModuleIsoDepositExtractor = getattr(newModule,
"ExtractorPSet")
353 setattr(newModuleIsoDepositExtractor,
"tauSource", getattr(newModule,
"src"))
356 addClone(oldLabel(), tauSource = tauCollection)
359 addClone(oldLabel(
'selected'), src = cms.InputTag(newLabel(oldLabel())))
362 addClone(oldLabel(
'clean'), src=cms.InputTag(newLabel(oldLabel(
'selected'))))
365 newTaus = getattr(process, newLabel(oldLabel()))
368 addClone(
'tauMatch', src = tauCollection)
369 addClone(
'tauGenJetMatch', src = tauCollection)
373 addPFIsoDepositClone(
'tauIsoDepositPFCandidates', src = tauCollection)
374 addPFIsoDepositClone(
'tauIsoDepositPFChargedHadrons', src = tauCollection)
375 addPFIsoDepositClone(
'tauIsoDepositPFNeutralHadrons', src = tauCollection)
376 addPFIsoDepositClone(
'tauIsoDepositPFGammas', src = tauCollection)
380 x.setModuleLabel(newLabel(x.moduleLabel))
383 fixInputTag(newTaus.genParticleMatch)
384 fixInputTag(newTaus.genJetMatch)
385 fixInputTag(newTaus.isoDeposits.pfAllParticles)
386 fixInputTag(newTaus.isoDeposits.pfNeutralHadron)
387 fixInputTag(newTaus.isoDeposits.pfChargedHadron)
388 fixInputTag(newTaus.isoDeposits.pfGamma)
389 fixInputTag(newTaus.userIsolation.pfAllParticles.src)
390 fixInputTag(newTaus.userIsolation.pfNeutralHadron.src)
391 fixInputTag(newTaus.userIsolation.pfChargedHadron.src)
392 fixInputTag(newTaus.userIsolation.pfGamma.src)
396 oldTaus = getattr(process, oldLabel())
397 if typeLabel ==
'Tau':
399 tauSource = getattr(newTaus,
"tauSource"),
400 patTauLabel = capitalize(algoLabel + typeLabel))
403 tauSource = getattr(newTaus,
"tauSource"),
404 patTauLabel = capitalize(algoLabel + typeLabel))
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)