CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HPSTancTaus_cff.py
Go to the documentation of this file.
2 import RecoTauTag.RecoTau.RecoTauCleanerPlugins as cleaners
3 from RecoTauTag.RecoTau.TauDiscriminatorTools import adaptTauDiscriminator, producerIsTauTypeMapper
4 from RecoTauTag.RecoTau.PFRecoTauQualityCuts_cfi import PFTauQualityCuts
5 import copy
6 
7 from RecoTauTag.RecoTau.hpstanc_transforms import transforms, cuts
8 
9 # Apply the TaNC to the input tau collection
10 from RecoTauTag.RecoTau.TauDiscriminatorTools import noPrediscriminants
11 
12 from RecoTauTag.RecoTau.PFRecoTauDiscriminationByLeadingPionPtCut_cfi import pfRecoTauDiscriminationByLeadingPionPtCut
13 # Common discrimination by lead pion
14 combinatoricRecoTausDiscriminationByLeadingPionPtCut = pfRecoTauDiscriminationByLeadingPionPtCut.clone(
15  PFTauProducer = cms.InputTag("combinatoricRecoTaus")
16  )
17 
18 # Steering file that loads the TaNC database, if necessary. If unused it will
19 # be 'None'
20 from RecoTauTag.Configuration.RecoTauMVAConfiguration_cfi import TauTagMVAComputerRecord, esPreferLocalTancDB
21 
22 # Build the tanc discriminates
23 from RecoTauTag.RecoTau.RecoTauDiscriminantConfiguration import discriminantConfiguration
24 
25 combinatoricRecoTausDiscriminationByTanc = cms.EDProducer(
26  "RecoTauMVADiscriminator",
27  PFTauProducer = cms.InputTag("combinatoricRecoTaus"),
28  Prediscriminants = noPrediscriminants,
29  dbLabel = cms.string("hpstanc"),
30  remapOutput = cms.bool(True),
31  mvas = cms.VPSet(
32  cms.PSet(
33  nCharged = cms.uint32(1),
34  nPiZeros = cms.uint32(0),
35  mvaLabel = cms.string("1prong0pi0"),
36  ),
37  cms.PSet(
38  nCharged = cms.uint32(1),
39  nPiZeros = cms.uint32(1),
40  mvaLabel = cms.string("1prong1pi0"),
41  ),
42  cms.PSet(
43  nCharged = cms.uint32(1),
44  nPiZeros = cms.uint32(2),
45  mvaLabel = cms.string("1prong2pi0"),
46  ),
47  cms.PSet(
48  nCharged = cms.uint32(3),
49  nPiZeros = cms.uint32(0),
50  mvaLabel = cms.string("3prong0pi0"),
51  ),
52  ),
53  discriminantOptions = discriminantConfiguration,
54 )
55 
56 
57 #Produce the transformed TaNC output
58 combinatoricRecoTausTancTransform = cms.EDProducer(
59  "RecoTauMVATransform",
60  transforms = transforms, # blank for now
61  PFTauProducer = cms.InputTag("combinatoricRecoTaus"),
62  toTransform = cms.InputTag("combinatoricRecoTausDiscriminationByTanc"),
63  Prediscriminants = noPrediscriminants
64 )
65 
66 from RecoTauTag.RecoTau.PFRecoTauDiscriminationByHPSSelection_cfi import hpsSelectionDiscriminator
67 
68 combinatoricRecoTausHPSSelector = hpsSelectionDiscriminator.clone(
69  src = cms.InputTag("combinatoricRecoTaus"),
70  minTauPt = cms.double(5.),
71  # Turn off narrowness req.
72  coneSizeFormula = cms.string('0.3'),
73 )
74 
75 # Clean the taus according to the transformed output
76 hpsTancTausSansRefs = cms.EDProducer(
77  "RecoTauCleaner",
78  src = cms.InputTag("combinatoricRecoTaus"),
79  cleaners = cms.VPSet(
80  # Prefer taus that don't have charge == 3
81  cleaners.unitCharge,
82  # Prefer taus that are within DR<0.1 of the jet axis
83  cleaners.matchingConeCut,
84  # Prefer taus that pass the lead pion requirement
85  cms.PSet(
86  name = cms.string("lead pion"),
87  plugin = cms.string("RecoTauDiscriminantCleanerPlugin"),
88  src = cms.InputTag("combinatoricRecoTausDiscriminationByLeadingPionPtCut")
89  ),
90  # Prefer taus that pass the HPS selection
91  cms.PSet(
92  name = cms.string("HPS selection"),
93  plugin = cms.string("RecoTauDiscriminantCleanerPlugin"),
94  src = cms.InputTag("combinatoricRecoTausHPSSelector")
95  ),
96  cleaners.combinedIsolation
97  )
98 )
99 
100 hpsTancTaus = cms.EDProducer(
101  "RecoTauPiZeroUnembedder",
102  src = cms.InputTag("hpsTancTausSansRefs")
103 )
104 
105 # Rerun the leading pion cut on our clean taus
106 hpsTancTausDiscriminationByLeadingPionPtCut = combinatoricRecoTausDiscriminationByLeadingPionPtCut.clone(
107  PFTauProducer = cms.InputTag("hpsTancTaus")
108  )
109 
110 _leadPionPrediscriminant = cms.PSet(
111  BooleanOperator = cms.string("and"),
112  leadPion = cms.PSet(
113  Producer = cms.InputTag(
114  'hpsTancTausDiscriminationByLeadingPionPtCut'),
115  cut = cms.double(0.5)
116  )
117 )
118 
119 # Build the HPS selection discriminator
120 hpsTancTausDiscriminationByDecayModeSelection = combinatoricRecoTausHPSSelector.clone(
121  PFTauProducer = cms.InputTag("hpsTancTaus")
122  )
123 
124 from RecoTauTag.Configuration.HPSPFTaus_cff import requireDecayMode,\
125  hpsPFTauDiscriminationByVLooseIsolation,\
126  hpsPFTauDiscriminationByLooseIsolation,\
127  hpsPFTauDiscriminationByMediumIsolation,\
128  hpsPFTauDiscriminationByTightIsolation
129 
130 # Build the lead track and lepton discriminators
131 from RecoTauTag.RecoTau.PFRecoTauDiscriminationByLeadingTrackFinding_cfi import pfRecoTauDiscriminationByLeadingTrackFinding
132 hpsTancTausDiscriminationByLeadingTrackFinding = pfRecoTauDiscriminationByLeadingTrackFinding.clone(
133  PFTauProducer = cms.InputTag("hpsTancTaus")
134  )
135 
136 from RecoTauTag.RecoTau.PFRecoTauDiscriminationByLeadingTrackPtCut_cfi import pfRecoTauDiscriminationByLeadingTrackPtCut
137 hpsTancTausDiscriminationByLeadingTrackPtCut = pfRecoTauDiscriminationByLeadingTrackPtCut.clone(
138  PFTauProducer = cms.InputTag("hpsTancTaus")
139  )
140 
141 
142 # Build lepton discriminants
143 from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstElectron_cfi import pfRecoTauDiscriminationAgainstElectron
144 
145 hpsTancTausDiscriminationByLooseElectronRejection = pfRecoTauDiscriminationAgainstElectron.clone(
146  PFTauProducer = cms.InputTag("hpsTancTaus"),
147  Prediscriminants = noPrediscriminants,
148  PFElectronMVA_maxValue = cms.double(0.6)
149  )
150 
151 hpsTancTausDiscriminationByMediumElectronRejection = pfRecoTauDiscriminationAgainstElectron.clone(
152  PFTauProducer = cms.InputTag("hpsTancTaus"),
153  Prediscriminants = noPrediscriminants,
154  ApplyCut_EcalCrackCut = cms.bool(True)
155  )
156 
157 hpsTancTausDiscriminationByTightElectronRejection = pfRecoTauDiscriminationAgainstElectron.clone(
158  PFTauProducer = cms.InputTag("hpsTancTaus"),
159  Prediscriminants = noPrediscriminants,
160  ApplyCut_EcalCrackCut = cms.bool(True),
161  ApplyCut_BremCombined = cms.bool(True)
162  )
163 
164 from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstMuon_cfi import pfRecoTauDiscriminationAgainstMuon
165 
166 hpsTancTausDiscriminationByLooseMuonRejection = pfRecoTauDiscriminationAgainstMuon.clone(
167  PFTauProducer = cms.InputTag("hpsTancTaus"),
168  Prediscriminants = noPrediscriminants
169  )
170 
171 hpsTancTausDiscriminationByTightMuonRejection = pfRecoTauDiscriminationAgainstMuon.clone(
172  PFTauProducer = cms.InputTag("hpsTancTaus"),
173  Prediscriminants = noPrediscriminants,
174  discriminatorOption = cms.string('noAllArbitrated')
175  )
176 
177 from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstCaloMuon_cfi import pfRecoTauDiscriminationAgainstCaloMuon
178 hpsTancTausDiscriminationAgainstCaloMuon = pfRecoTauDiscriminationAgainstCaloMuon.clone(
179  PFTauProducer = cms.InputTag("hpsTancTaus")
180  )
181 hpsTancTausDiscriminationAgainstCaloMuon.Prediscriminants.leadTrack.Producer = cms.InputTag("hpsTancTausDiscriminationByLeadingTrackFinding")
182 
183 # Update the decay mode prediscriminant
184 hpsTancRequireDecayMode = requireDecayMode.clone()
185 hpsTancRequireDecayMode.decayMode.Producer = cms.InputTag("hpsTancTausDiscriminationByDecayModeSelection")
186 
187 hpsTancTausDiscriminationByFlightPath = cms.EDProducer(
188  "PFRecoTauDiscriminationByFlight",
189  PFTauProducer = cms.InputTag("hpsTancTaus"),
190  vertexSource = PFTauQualityCuts.primaryVertexSrc,
191  beamspot = cms.InputTag("offlineBeamSpot"),
192  refitPV = cms.bool(True),
193  Prediscriminants = cms.PSet(
194  BooleanOperator = cms.string("and"),
195  leadTrack = cms.PSet(
196  Producer = cms.InputTag(
197  "hpsTancTausDiscriminationByDecayModeSelection"),
198  cut = cms.double(0.5),
199  )
200  )
201 )
202 
203 # Build the isolation discriminators
204 hpsTancTausDiscriminationByVLooseIsolation = \
205  hpsPFTauDiscriminationByVLooseIsolation.clone(
206  PFTauProducer = cms.InputTag("hpsTancTaus"),
207  Prediscriminants = hpsTancRequireDecayMode
208  )
209 hpsTancTausDiscriminationByVLooseIsolation.Prediscriminants = hpsTancRequireDecayMode
210 
211 hpsTancTausDiscriminationByLooseIsolation = \
212  hpsPFTauDiscriminationByLooseIsolation.clone(
213  PFTauProducer = cms.InputTag("hpsTancTaus"),
214  Prediscriminants = hpsTancRequireDecayMode
215  )
216 hpsTancTausDiscriminationByLooseIsolation.Prediscriminants = hpsTancRequireDecayMode
217 
218 hpsTancTausDiscriminationByMediumIsolation = \
219  hpsPFTauDiscriminationByMediumIsolation.clone(
220  PFTauProducer = cms.InputTag("hpsTancTaus"),
221  Prediscriminants = hpsTancRequireDecayMode
222  )
223 hpsTancTausDiscriminationByMediumIsolation.Prediscriminants = hpsTancRequireDecayMode
224 
225 hpsTancTausDiscriminationByTightIsolation = \
226  hpsPFTauDiscriminationByTightIsolation.clone(
227  PFTauProducer = cms.InputTag("hpsTancTaus"),
228  Prediscriminants = hpsTancRequireDecayMode
229  )
230 hpsTancTausDiscriminationByTightIsolation.Prediscriminants = hpsTancRequireDecayMode
231 
232 _tancPrediscriminants = _leadPionPrediscriminant.clone(
233  hpsSelect = cms.PSet(
234  Producer = cms.InputTag(
235  'hpsTancTausDiscriminationByDecayModeSelection'),
236  cut = cms.double(0.5)
237  )
238 )
239 
240 # Rerun the TaNC on our clean taus - in the future, rekey.
241 hpsTancTausDiscriminationByTancRaw = \
242  combinatoricRecoTausDiscriminationByTanc.clone(
243  PFTauProducer = cms.InputTag("hpsTancTaus"),
244  Prediscriminants = _tancPrediscriminants,
245  )
246 
247 # Rerun the transformation
248 hpsTancTausDiscriminationByTanc = \
249  combinatoricRecoTausTancTransform.clone(
250  PFTauProducer = cms.InputTag("hpsTancTaus"),
251  toTransform = cms.InputTag("hpsTancTausDiscriminationByTancRaw"),
252  transforms = transforms,
253  Prediscriminants = _tancPrediscriminants,
254  )
255 
256 hpsTancTausDiscriminationByTancLoose = cms.EDProducer(
257  # There is no PT selection applied; we use this only to use the
258  # prediscriminants to make binary cuts.
259  "PFRecoTauDiscriminationByLeadingObjectPtCut",
260  PFTauProducer = cms.InputTag("hpsTancTaus"),
261  UseOnlyChargedHadrons = cms.bool(True),
262  MinPtLeadingObject = cms.double(0.0),
263  Prediscriminants = cms.PSet(
264  BooleanOperator = cms.string("and"),
265  tancCut = cms.PSet(
266  Producer = cms.InputTag("hpsTancTausDiscriminationByTanc"),
267  cut = cuts.looseCut
268  )
269  )
270 )
271 
272 # Make a very loose cut
273 hpsTancTausDiscriminationByTancVLoose = \
274  hpsTancTausDiscriminationByTancLoose.clone()
275 hpsTancTausDiscriminationByTancVLoose.Prediscriminants.tancCut.cut = cuts.vlooseCut
276 
277 hpsTancTausDiscriminationByTancMedium = \
278  hpsTancTausDiscriminationByTancLoose.clone()
279 hpsTancTausDiscriminationByTancMedium.Prediscriminants.tancCut.cut = cuts.mediumCut
280 
281 hpsTancTausDiscriminationByTancTight = \
282  hpsTancTausDiscriminationByTancLoose.clone()
283 hpsTancTausDiscriminationByTancTight.Prediscriminants.tancCut.cut = cuts.tightCut
284 
285 hpsTancTauInitialSequence = cms.Sequence(
286  combinatoricRecoTausDiscriminationByLeadingPionPtCut
287  + combinatoricRecoTausHPSSelector
288  # select & clean each decay mode
289  + hpsTancTausSansRefs
290  + hpsTancTaus
291  + hpsTancTausDiscriminationByLeadingTrackFinding
292  + hpsTancTausDiscriminationByLeadingPionPtCut
293  + hpsTancTausDiscriminationByLeadingTrackPtCut
294  + hpsTancTausDiscriminationByDecayModeSelection
295  #+ hpsTancTausDiscriminationByFlightPath
296 )
297 
298 hpsTancTauDiscriminantSequence = cms.Sequence(
299  #+ hpsTancTausDiscriminationAgainstCaloMuon
300  hpsTancTausDiscriminationByTancRaw
301  + hpsTancTausDiscriminationByTanc
302  + hpsTancTausDiscriminationByTancVLoose
303  + hpsTancTausDiscriminationByTancLoose
304  + hpsTancTausDiscriminationByTancMedium
305  + hpsTancTausDiscriminationByTancTight
306  + hpsTancTausDiscriminationByVLooseIsolation
307  + hpsTancTausDiscriminationByLooseIsolation
308  + hpsTancTausDiscriminationByMediumIsolation
309  + hpsTancTausDiscriminationByTightIsolation
310  + hpsTancTausDiscriminationByLooseElectronRejection
311  + hpsTancTausDiscriminationByMediumElectronRejection
312  + hpsTancTausDiscriminationByTightElectronRejection
313  + hpsTancTausDiscriminationByLooseMuonRejection
314  + hpsTancTausDiscriminationByTightMuonRejection
315 )