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
30 print "NO PF Isolation will be computed for CaloTau (this could be improved later)"
31 applyPostfix(process,
"patTaus" + patTauLabel, postfix).isolation = cms.PSet()
32 applyPostfix(process,
"patTaus" + patTauLabel, postfix).isoDeposits = cms.PSet()
33 applyPostfix(process,
"patTaus" + patTauLabel, postfix).userIsolation = cms.PSet()
36 if hasattr(process,
"cleanPatTaus" + patTauLabel + postfix):
37 getattr(process,
"cleanPatTaus" + patTauLabel + postfix).preselection = \
38 'tauID("leadingTrackFinding") > 0.5 & tauID("leadingTrackPtCut") > 0.5' \
39 +
' & tauID("byIsolation") > 0.5 & tauID("againstElectron") > 0.5 & (signalTracks.size() = 1 | signalTracks.size() = 3)'
42 """ Build a PSet defining the tau ID sources to embed into the pat::Tau """
44 for label, discriminator
in idSources:
45 if ":" in discriminator:
46 discr = discriminator.split(
":")
47 setattr(output, label, cms.InputTag(tauType + discr[0] + postfix +
":" + discr[1]))
49 setattr(output, label, cms.InputTag(tauType + discriminator + postfix))
58 """internal auxiliary function to switch to **any** PFTau collection"""
59 print ' switching PAT Tau input to: ', tauSource
61 applyPostfix(process,
"tauMatch" + patTauLabel, postfix).src = tauSource
62 applyPostfix(process,
"tauGenJetMatch" + patTauLabel, postfix).src = tauSource
64 applyPostfix(process,
"tauIsoDepositPFCandidates" + patTauLabel, postfix).src = tauSource
65 applyPostfix(process,
"tauIsoDepositPFCandidates" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
66 applyPostfix(process,
"tauIsoDepositPFChargedHadrons" + patTauLabel, postfix).src = tauSource
67 applyPostfix(process,
"tauIsoDepositPFChargedHadrons" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
68 applyPostfix(process,
"tauIsoDepositPFNeutralHadrons" + patTauLabel, postfix).src = tauSource
69 applyPostfix(process,
"tauIsoDepositPFNeutralHadrons" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
70 applyPostfix(process,
"tauIsoDepositPFGammas" + patTauLabel, postfix).src = tauSource
71 applyPostfix(process,
"tauIsoDepositPFGammas" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
73 applyPostfix(process,
"patTaus" + patTauLabel, postfix).tauSource = tauSource
76 if hasattr(process,
"cleanPatTaus" + patTauLabel + postfix):
77 getattr(process,
"cleanPatTaus" + patTauLabel + postfix).preselection = \
78 'tauID("leadingTrackFinding") > 0.5 & tauID("leadingPionPtCut") > 0.5 & tauID("byIsolationUsingLeadingPion") > 0.5' \
79 +
' & tauID("againstMuon") > 0.5 & tauID("againstElectron") > 0.5' \
80 +
' & (signalPFChargedHadrCands.size() = 1 | signalPFChargedHadrCands.size() = 3)'
83 classicTauIDSources = [
84 (
"leadingTrackFinding",
"DiscriminationByLeadingTrackFinding"),
85 (
"leadingTrackPtCut",
"DiscriminationByLeadingTrackPtCut"),
86 (
"trackIsolation",
"DiscriminationByTrackIsolation"),
87 (
"ecalIsolation",
"DiscriminationByECALIsolation"),
88 (
"byIsolation",
"DiscriminationByIsolation"),
89 (
"againstElectron",
"DiscriminationAgainstElectron"),
90 (
"againstMuon",
"DiscriminationAgainstMuon") ]
92 classicPFTauIDSources = [
93 (
"leadingPionPtCut",
"DiscriminationByLeadingPionPtCut"),
94 (
"trackIsolationUsingLeadingPion",
"DiscriminationByTrackIsolationUsingLeadingPion"),
95 (
"ecalIsolationUsingLeadingPion",
"DiscriminationByECALIsolationUsingLeadingPion"),
96 (
"byIsolationUsingLeadingPion",
"DiscriminationByIsolationUsingLeadingPion")]
100 (
"decayModeFinding",
"DiscriminationByDecayModeFinding"),
101 (
"byLooseIsolation",
"DiscriminationByLooseIsolation"),
102 (
"byVLooseCombinedIsolationDeltaBetaCorr",
"DiscriminationByVLooseCombinedIsolationDBSumPtCorr"),
103 (
"byLooseCombinedIsolationDeltaBetaCorr",
"DiscriminationByLooseCombinedIsolationDBSumPtCorr"),
104 (
"byMediumCombinedIsolationDeltaBetaCorr",
"DiscriminationByMediumCombinedIsolationDBSumPtCorr"),
105 (
"byTightCombinedIsolationDeltaBetaCorr",
"DiscriminationByTightCombinedIsolationDBSumPtCorr"),
106 (
"byCombinedIsolationDeltaBetaCorrRaw",
"DiscriminationByRawCombinedIsolationDBSumPtCorr"),
107 (
"byLooseCombinedIsolationDeltaBetaCorr3Hits",
"DiscriminationByLooseCombinedIsolationDBSumPtCorr3Hits"),
108 (
"byMediumCombinedIsolationDeltaBetaCorr3Hits",
"DiscriminationByMediumCombinedIsolationDBSumPtCorr3Hits"),
109 (
"byTightCombinedIsolationDeltaBetaCorr3Hits",
"DiscriminationByTightCombinedIsolationDBSumPtCorr3Hits"),
110 (
"byCombinedIsolationDeltaBetaCorrRaw3Hits",
"DiscriminationByRawCombinedIsolationDBSumPtCorr3Hits"),
111 (
"byIsolationMVAraw",
"DiscriminationByIsolationMVAraw"),
112 (
"byLooseIsolationMVA",
"DiscriminationByLooseIsolationMVA"),
113 (
"byMediumIsolationMVA",
"DiscriminationByMediumIsolationMVA"),
114 (
"byTightIsolationMVA",
"DiscriminationByTightIsolationMVA"),
115 (
"againstElectronLoose",
"DiscriminationByLooseElectronRejection"),
116 (
"againstElectronMedium",
"DiscriminationByMediumElectronRejection"),
117 (
"againstElectronTight",
"DiscriminationByTightElectronRejection"),
118 (
"againstElectronMVA",
"DiscriminationByMVAElectronRejection"),
119 (
"againstElectronMVA2raw",
"DiscriminationByMVA2rawElectronRejection"),
120 (
"againstElectronMVA2category",
"DiscriminationByMVA2rawElectronRejection:category"),
121 (
"againstElectronVLooseMVA2",
"DiscriminationByMVA2VLooseElectronRejection"),
122 (
"againstElectronLooseMVA2",
"DiscriminationByMVA2LooseElectronRejection"),
123 (
"againstElectronMediumMVA2",
"DiscriminationByMVA2MediumElectronRejection"),
124 (
"againstElectronTightMVA2",
"DiscriminationByMVA2TightElectronRejection"),
125 (
"againstElectronMVA3raw",
"DiscriminationByMVA3rawElectronRejection"),
126 (
"againstElectronMVA3category",
"DiscriminationByMVA3rawElectronRejection:category"),
127 (
"againstElectronLooseMVA3",
"DiscriminationByMVA3LooseElectronRejection"),
128 (
"againstElectronMediumMVA3",
"DiscriminationByMVA3MediumElectronRejection"),
129 (
"againstElectronTightMVA3",
"DiscriminationByMVA3TightElectronRejection"),
130 (
"againstElectronDeadECAL",
"DiscriminationByDeadECALElectronRejection"),
131 (
"againstMuonLoose",
"DiscriminationByLooseMuonRejection"),
132 (
"againstMuonMedium",
"DiscriminationByMediumMuonRejection"),
133 (
"againstMuonTight",
"DiscriminationByTightMuonRejection"),
134 (
"againstMuonLoose2",
"DiscriminationByLooseMuonRejection2"),
135 (
"againstMuonMedium2",
"DiscriminationByMediumMuonRejection2"),
136 (
"againstMuonTight2",
"DiscriminationByTightMuonRejection2"),
137 (
"againstMuonLoose3",
"DiscriminationByLooseMuonRejection3"),
138 (
"againstMuonTight3",
"DiscriminationByTightMuonRejection3")
143 tauSource = cms.InputTag(
'fixedConePFTauProducer'),
146 fixedConeIDSources = copy.copy(classicTauIDSources)
147 fixedConeIDSources.extend(classicPFTauIDSources)
149 _switchToPFTau(process, tauSource,
'fixedConePFTau', fixedConeIDSources,
150 patTauLabel = patTauLabel, postfix = postfix)
154 tauSource = cms.InputTag(
'shrinkingConePFTauProducer'),
157 shrinkingIDSources = copy.copy(classicTauIDSources)
158 shrinkingIDSources.extend(classicPFTauIDSources)
160 _switchToPFTau(process, tauSource,
'shrinkingConePFTau', shrinkingIDSources,
161 patTauLabel = patTauLabel, postfix = postfix)
165 tauSource = cms.InputTag(
'hpsPFTauProducer'),
171 patTauLabel = patTauLabel, postfix = postfix)
174 if hasattr(process,
"cleanPatTaus" + patTauLabel + postfix):
175 getattr(process,
"cleanPatTaus" + patTauLabel + postfix).preselection = \
176 'pt > 15 & abs(eta) < 2.3 & tauID("decayModeFinding") > 0.5 & tauID("byLooseIsolation") > 0.5' \
177 +
' & tauID("againstMuonTight") > 0.5 & tauID("againstElectronLoose") > 0.5'
182 tauSource = cms.InputTag(
'hpsPFTauProducer'),
186 'shrinkingConePFTau' : switchToPFTauShrinkingCone,
187 'fixedConePFTau' : switchToPFTauFixedCone,
188 'hpsPFTau' : switchToPFTauHPS,
189 'caloRecoTau' : switchToCaloTau
191 if not pfTauType
in mapping.keys():
192 raise ValueError(
"Error in <switchToPFTauByType>: Undefined pfTauType = %s !!" % pfTauType)
194 mapping[pfTauType](process, tauSource = tauSource,
195 patTauLabel = patTauLabel, postfix = postfix)
199 """ Add a new collection of taus. Takes the configuration from the
200 already configured standard tau collection as starting point;
201 replaces before calling addTauCollection will also affect the
204 _label=
'addTauCollection'
205 _defaultParameters=dicttypes.SortedKeysDict()
207 ConfigToolBase.__init__(self)
209 self._defaultValue,
'Input tau collection', cms.InputTag)
211 self._defaultValue,
"label to indicate the tau algorithm (e.g.'hps')", str)
213 self._defaultValue,
"label to indicate the type of constituents (either 'PFTau' or 'Tau')", str)
215 True,
"run sequence for computing particle-flow based IsoDeposits")
217 "hps",
"standard algorithm label of the collection from which the clones " \
218 +
"for the new tau collection will be taken from " \
219 +
"(note that this tau collection has to be available in the event before hand)")
221 "PFTau",
"standard constituent type label of the collection from which the clones " \
222 +
" for the new tau collection will be taken from "\
223 +
"(note that this tau collection has to be available in the event before hand)")
232 tauCollection =
None,
235 doPFIsoDeposits =
None,
238 standardType =
None):
240 if tauCollection
is None:
242 if algoLabel
is None:
244 if typeLabel
is None:
246 if doPFIsoDeposits
is None:
248 if standardAlgo
is None:
250 if standardType
is None:
253 self.setParameter(
'tauCollection', tauCollection)
254 self.setParameter(
'algoLabel', algoLabel)
255 self.setParameter(
'typeLabel', typeLabel)
256 self.setParameter(
'doPFIsoDeposits', doPFIsoDeposits)
257 self.setParameter(
'standardAlgo', standardAlgo)
258 self.setParameter(
'standardType', standardType)
263 tauCollection = self.
_parameters[
'tauCollection'].value
266 doPFIsoDeposits = self.
_parameters[
'doPFIsoDeposits'].value
267 standardAlgo = self.
_parameters[
'standardAlgo'].value
268 standardType = self.
_parameters[
'standardType'].value
272 if typeLabel ==
'Tau':
273 print "NO PF Isolation will be computed for CaloTau (this could be improved later)"
274 doPFIsoDeposits =
False
278 def oldLabel(prefix = ''):
282 return prefix +
"PatTaus"
287 def capitalize(label):
288 return label[0].capitalize() + label[1:]
292 def newLabel(oldLabel):
294 if ( oldLabel.find(standardAlgo) >= 0
and oldLabel.find(standardType) >= 0 ):
295 oldLabel = oldLabel.replace(standardAlgo, algoLabel).
replace(standardType, typeLabel)
297 oldLabel = oldLabel + capitalize(algoLabel + typeLabel)
301 def addClone(hook, **replaceStatements):
304 newModule = getattr(process, hook).
clone(**replaceStatements)
307 def addPFIsoDepositClone(hook, **replaceStatements):
308 newModule = getattr(process, hook).
clone(**replaceStatements)
309 newModuleIsoDepositExtractor = getattr(newModule,
"ExtractorPSet")
310 setattr(newModuleIsoDepositExtractor,
"tauSource", getattr(newModule,
"src"))
313 addClone(oldLabel(), tauSource = tauCollection)
316 addClone(oldLabel(
'selected'), src = cms.InputTag(newLabel(oldLabel())))
319 addClone(oldLabel(
'clean'), src=cms.InputTag(newLabel(oldLabel(
'selected'))))
322 newTaus = getattr(process, newLabel(oldLabel()))
325 addClone(
'tauMatch', src = tauCollection)
326 addClone(
'tauGenJetMatch', src = tauCollection)
330 addPFIsoDepositClone(
'tauIsoDepositPFCandidates', src = tauCollection)
331 addPFIsoDepositClone(
'tauIsoDepositPFChargedHadrons', src = tauCollection)
332 addPFIsoDepositClone(
'tauIsoDepositPFNeutralHadrons', src = tauCollection)
333 addPFIsoDepositClone(
'tauIsoDepositPFGammas', src = tauCollection)
337 x.setModuleLabel(newLabel(x.moduleLabel))
340 fixInputTag(newTaus.genParticleMatch)
341 fixInputTag(newTaus.genJetMatch)
342 fixInputTag(newTaus.isoDeposits.pfAllParticles)
343 fixInputTag(newTaus.isoDeposits.pfNeutralHadron)
344 fixInputTag(newTaus.isoDeposits.pfChargedHadron)
345 fixInputTag(newTaus.isoDeposits.pfGamma)
346 fixInputTag(newTaus.userIsolation.pfAllParticles.src)
347 fixInputTag(newTaus.userIsolation.pfNeutralHadron.src)
348 fixInputTag(newTaus.userIsolation.pfChargedHadron.src)
349 fixInputTag(newTaus.userIsolation.pfGamma.src)
353 oldTaus = getattr(process, oldLabel())
354 if typeLabel ==
'Tau':
356 tauSource = getattr(newTaus,
"tauSource"),
357 patTauLabel = capitalize(algoLabel + typeLabel))
360 tauSource = getattr(newTaus,
"tauSource"),
361 patTauLabel = capitalize(algoLabel + typeLabel))
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)