CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
pfTools.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
6 
7 from PhysicsTools.PatAlgos.tools.helpers import listModules, applyPostfix
8 
9 from copy import deepcopy
10 
12  print "WARNING: particle based isolation must be studied"
13 
14 def adaptPFMuons(process,module,postfix="", muonMatchModule=None ):
15  print "Adapting PF Muons "
16  print "***************** "
17  #warningIsolation()
18  print
19  module.useParticleFlow = True
20  module.pfMuonSource = cms.InputTag("pfIsolatedMuonsPFBRECO" + postfix)
21  module.userIsolation = cms.PSet()
22  ## module.isoDeposits = cms.PSet(
23  ## pfChargedHadrons = cms.InputTag("muPFIsoDepositCharged" + postfix),
24  ## pfChargedAll = cms.InputTag("muPFIsoDepositChargedAll" + postfix),
25  ## pfPUChargedHadrons = cms.InputTag("muPFIsoDepositPU" + postfix),
26  ## pfNeutralHadrons = cms.InputTag("muPFIsoDepositNeutral" + postfix),
27  ## pfPhotons = cms.InputTag("muPFIsoDepositGamma" + postfix)
28  ## )
29  ## module.isolationValues = cms.PSet(
30  ## pfChargedHadrons = cms.InputTag("muPFIsoValueCharged04"+ postfix),
31  ## pfChargedAll = cms.InputTag("muPFIsoValueChargedAll04"+ postfix),
32  ## pfPUChargedHadrons = cms.InputTag("muPFIsoValuePU04" + postfix),
33  ## pfNeutralHadrons = cms.InputTag("muPFIsoValueNeutral04" + postfix),
34  ## pfPhotons = cms.InputTag("muPFIsoValueGamma04" + postfix)
35  ## )
36  # matching the pfMuons, not the standard muons.
37  if muonMatchModule == None :
38  applyPostfix(process,"muonMatch",postfix).src = module.pfMuonSource
39  else :
40  muonMatchModule.src = module.pfMuonSource
41 
42  print " muon source:", module.pfMuonSource
43  ## print " isolation :",
44  ## print module.isolationValues
45  ## print " isodeposits: "
46  ## print module.isoDeposits
47  print
48 
49 
50 def adaptPFElectrons(process,module, postfix):
51  # module.useParticleFlow = True
52  print "Adapting PF Electrons "
53  print "********************* "
54  #warningIsolation()
55  print
56  module.useParticleFlow = True
57  module.pfElectronSource = cms.InputTag("pfIsolatedElectronsPFBRECO" + postfix)
58  module.userIsolation = cms.PSet()
59  ## module.isoDeposits = cms.PSet(
60  ## pfChargedHadrons = cms.InputTag("elPFIsoDepositCharged" + postfix),
61  ## pfChargedAll = cms.InputTag("elPFIsoDepositChargedAll" + postfix),
62  ## pfPUChargedHadrons = cms.InputTag("elPFIsoDepositPU" + postfix),
63  ## pfNeutralHadrons = cms.InputTag("elPFIsoDepositNeutral" + postfix),
64  ## pfPhotons = cms.InputTag("elPFIsoDepositGamma" + postfix)
65  ## )
66  ## module.isolationValues = cms.PSet(
67  ## pfChargedHadrons = cms.InputTag("elPFIsoValueCharged04PFId"+ postfix),
68  ## pfChargedAll = cms.InputTag("elPFIsoValueChargedAll04PFId"+ postfix),
69  ## pfPUChargedHadrons = cms.InputTag("elPFIsoValuePU04PFId" + postfix),
70  ## pfNeutralHadrons = cms.InputTag("elPFIsoValueNeutral04PFId" + postfix),
71  ## pfPhotons = cms.InputTag("elPFIsoValueGamma04PFId" + postfix)
72  ## )
73 
74  # COLIN: since we take the egamma momentum for pat Electrons, we must
75  # match the egamma electron to the gen electrons, and not the PFElectron.
76  # -> do not uncomment the line below.
77  # process.electronMatch.src = module.pfElectronSource
78  # COLIN: how do we depend on this matching choice?
79 
80  print " PF electron source:", module.pfElectronSource
81  ## print " isolation :"
82  ## print module.isolationValues
83  ## print " isodeposits: "
84  ## print module.isoDeposits
85  print
86 
87 
88 
89 
90 def adaptPFPhotons(process,module):
91  raise RuntimeError("Photons are not supported yet")
92 
93 from RecoTauTag.RecoTau.TauDiscriminatorTools import adaptTauDiscriminator, producerIsTauTypeMapper
94 
95 def reconfigurePF2PATTaus(process,
96  tauType='shrinkingConePFTau',
97  pf2patSelection=["DiscriminationByIsolation", "DiscriminationByLeadingPionPtCut"],
98  selectionDependsOn=["DiscriminationByLeadingTrackFinding"],
99  producerFromType=lambda producer: producer+"Producer",
100  postfix = ""):
101  print "patTaus will be produced from taus of type: %s that pass %s" \
102  % (tauType, pf2patSelection)
103 
104 
105 
106  # Get the prototype of tau producer to make, i.e. fixedConePFTauProducer
107  producerName = producerFromType(tauType)
108  # Set as the source for the pf2pat taus (pfTaus) selector
109  applyPostfix(process,"pfTaus", postfix).src = producerName+postfix
110  # Start our pf2pat taus base sequence
111  oldTauSansRefs = getattr(process,'pfTausProducerSansRefs'+postfix)
112  oldTau = getattr(process,'pfTausProducer'+postfix)
113  ## copy tau and setup it properly
114  newTauSansRefs = None
115  newTau = getattr(process,producerName+postfix).clone()
116 
117  ## adapted to new structure in RecoTauProducers PLEASE CHECK!!!
118  if tauType=='shrinkingConePFTau':
119  newTauSansRefs = getattr(process,producerName+"SansRefs").clone()
120  newTauSansRefs.modifiers[1] = cms.PSet(
121  pfTauTagInfoSrc = cms.InputTag("pfTauTagInfoProducer"+postfix),
122  name = cms.string('pfTauTTIworkaround'+postfix),
123  plugin = cms.string('RecoTauTagInfoWorkaroundModifer')
124  )
125  newTau.modifiers[1] = newTauSansRefs.modifiers[1]
126  newTauSansRefs.piZeroSrc = "pfJetsLegacyTaNCPiZeros"+postfix
127  newTau.piZeroSrc = newTauSansRefs.piZeroSrc
128  newTauSansRefs.builders[0].pfCandSrc = oldTauSansRefs.builders[0].pfCandSrc
129  newTauSansRefs.jetRegionSrc = oldTauSansRefs.jetRegionSrc
130  newTauSansRefs.jetSrc = oldTauSansRefs.jetSrc
131  elif tauType=='fixedConePFTau':
132  newTau.piZeroSrc = "pfJetsLegacyTaNCPiZeros"+postfix
133  elif tauType=='hpsPFTau':
134  newTau = getattr(process,'combinatoricRecoTaus'+postfix).clone()
135  newTau.piZeroSrc="pfJetsLegacyHPSPiZeros"+postfix
136  newTau.modifiers[3] = cms.PSet(
137  pfTauTagInfoSrc = cms.InputTag("pfTauTagInfoProducer"+postfix),
138  name = cms.string('pfTauTTIworkaround'+postfix),
139  plugin = cms.string('RecoTauTagInfoWorkaroundModifer')
140  )
141  from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet
142  #cloneProcessingSnippet(process, process.produceHPSPFTaus, postfix)
143  setattr(process,'produceHPSPFTaus'+postfix,cms.Sequence(applyPostfix(process,'hpsSelectionDiscriminator',postfix)+applyPostfix(process,'hpsPFTauProducerSansRefs',postfix)+applyPostfix(process,'hpsPFTauProducer',postfix)))
144  massSearchReplaceParam(getattr(process,"produceHPSPFTaus"+postfix),
145  "PFTauProducer",
146  cms.InputTag("combinatoricRecoTaus"+postfix),
147  cms.InputTag("pfTausBase"+postfix) )
148  massSearchReplaceParam(getattr(process,"produceHPSPFTaus"+postfix),
149  "src",
150  cms.InputTag("combinatoricRecoTaus"+postfix),
151  cms.InputTag("pfTausBase"+postfix) )
152  ### Next three lines crash, oldTau does not have any of these attributes. Why?###
153  #newTau.builders[0].pfCandSrc = oldTau.builders[0].pfCandSrc
154  #newTau.jetRegionSrc = oldTau.jetRegionSrc
155  #newTau.jetSrc = oldTau.jetSrc
156  #newTau.builders[0].pfCandSrc = cms.InputTag("pfNoElectronJME" + postfix)
157  #newTau.jetRegionSrc = cms.InputTag("pfTauPFJets08Region" + postfix)
158  #newTau.jetSrc = cms.InputTag("pfJetsPFBRECO" + postfix)
159  # replace old tau producer by new one put it into baseSequence
160  setattr(process,"pfTausBase"+postfix,newTau)
161  if tauType=='shrinkingConePFTau':
162  setattr(process,"pfTausBaseSansRefs"+postfix,newTauSansRefs)
163  getattr(process,"pfTausBase"+postfix).src = "pfTausBaseSansRefs"+postfix
164  baseSequence += getattr(process,"pfTausBaseSansRefs"+postfix)
165 
166  #make custom mapper to take postfix into account (could have gone with lambda of lambda but... )
167  def producerIsTauTypeMapperWithPostfix(tauProducer):
168  return lambda x: producerIsTauTypeMapper(tauProducer)+x.group(1)+postfix
169 
170  def recoTauTypeMapperWithGroup(tauProducer):
171  return "%s(.*)"%recoTauTypeMapper(tauProducer)
172 
173  # Get our prediscriminants
174  for predisc in selectionDependsOn:
175  # Get the prototype
176  originalName = tauType+predisc # i.e. fixedConePFTauProducerDiscriminationByLeadingTrackFinding
177  clonedName = "pfTausBase"+predisc+postfix
178  clonedDisc = getattr(process, originalName).clone()
179  setattr(process, clonedName, clonedDisc)
180 
181  tauCollectionToSelect = None
182  if tauType != 'hpsPFTau' :
183  tauCollectionToSelect = "pfTausBase"+postfix
184  #cms.InputTag(clonedDisc.PFTauProducer.value()+postfix)
185  else:
186  tauCollectionToSelect = "hpsPFTauProducer"+postfix
187  # Adapt this discriminator for the cloned prediscriminators
188  adaptTauDiscriminator(clonedDisc, newTauProducer="pfTausBase",
189  oldTauTypeMapper=recoTauTypeMapperWithGroup,
190  newTauTypeMapper=producerIsTauTypeMapperWithPostfix,
191  preservePFTauProducer=True)
192  clonedDisc.PFTauProducer = tauCollectionToSelect
193 
194  # Reconfigure the pf2pat PFTau selector discrimination sources
195  getattr(process,"pfTaus" + postfix).discriminators = cms.VPSet()
196  for selection in pf2patSelection:
197  # Get our discriminator that will be used to select pfTaus
198  originalName = tauType+selection
199  clonedName = "pfTausBase"+selection+postfix
200  clonedDisc = getattr(process, originalName).clone()
201  setattr(process, clonedName, clonedDisc)
202 
203  tauCollectionToSelect = None
204 
205  if tauType != 'hpsPFTau' :
206  tauCollectionToSelect = cms.InputTag("pfTausBase"+postfix)
207  #cms.InputTag(clonedDisc.PFTauProducer.value()+postfix)
208  else:
209  tauCollectionToSelect = cms.InputTag("hpsPFTauProducer"+postfix)
210  #Adapt our cloned discriminator to the new prediscriminants
211  adaptTauDiscriminator(clonedDisc, newTauProducer="pfTausBase",
212  oldTauTypeMapper=recoTauTypeMapperWithGroup,
213  newTauTypeMapper=producerIsTauTypeMapperWithPostfix,
214  preservePFTauProducer=True)
215  clonedDisc.PFTauProducer = tauCollectionToSelect
216 
217  # Add this selection to our pfTau selectors
218  getattr(process,"pfTaus" + postfix).discriminators.append(cms.PSet(
219  discriminator=cms.InputTag(clonedName), selectionCut=cms.double(0.5)))
220  # Set the input of the final selector.
221  if tauType != 'hpsPFTau':
222  getattr(process,"pfTaus" + postfix).src = "pfTausBase"+postfix
223  else:
224  # If we are using HPS taus, we need to take the output of the clenaed
225  # collection
226  getattr(process,"pfTaus" + postfix).src = "hpsPFTauProducer"+postfix
227 
228 
229 
230 def adaptPFTaus(process,tauType = 'shrinkingConePFTau', postfix = ""):
231  # Set up the collection used as a preselection to use this tau type
232  if tauType != 'hpsPFTau' :
233  reconfigurePF2PATTaus(process, tauType, postfix=postfix)
234  else:
235  reconfigurePF2PATTaus(process, tauType,
236  ["DiscriminationByDecayModeFinding"],
237  ["DiscriminationByDecayModeFinding"],
238  postfix=postfix)
239  # new default use unselected taus (selected only for jet cleaning)
240  if tauType != 'hpsPFTau' :
241  getattr(process,"patTaus" + postfix).tauSource = cms.InputTag("pfTausBase"+postfix)
242  else:
243  getattr(process,"patTaus" + postfix).tauSource = cms.InputTag("hpsPFTauProducer"+postfix)
244  # to use preselected collection (old default) uncomment line below
245  #applyPostfix(process,"patTaus", postfix).tauSource = cms.InputTag("pfTaus"+postfix)
246 
247  ### apparently not needed anymore, function gone from tauTools.py###
248  #redoPFTauDiscriminators(process,
249  #cms.InputTag(tauType+'Producer'),
250  #applyPostfix(process,"patTaus", postfix).tauSource,
251  #tauType, postfix=postfix)
252 
253 
254  if tauType != 'hpsPFTau' :
255  switchToPFTauByType(process, pfTauType=tauType,
256  patTauLabel="pfTausBase"+postfix,
257  tauSource=cms.InputTag(tauType+'Producer'+postfix),
258  postfix=postfix)
259  getattr(process,"patTaus" + postfix).tauSource = cms.InputTag("pfTausBase"+postfix)
260  else:
261  switchToPFTauByType(process, pfTauType=tauType,
262  patTauLabel="",
263  tauSource=cms.InputTag(tauType+'Producer'+postfix),
264  postfix=postfix)
265  getattr(process,"patTaus" + postfix).tauSource = cms.InputTag("hpsPFTauProducer"+postfix)
266 
267 
268 
269 #helper function for PAT on PF2PAT sample
270 def tauTypeInPF2PAT(process,tauType='shrinkingConePFTau', postfix = ""):
271  process.load("CommonTools.ParticleFlow.pfTaus_cff")
272  applyPostfix(process, "pfTaus",postfix).src = cms.InputTag(tauType+'Producer'+postfix)
273 
274 
275 def addPFCandidates(process,src,patLabel='PFParticles',cut="",postfix=""):
276  from PhysicsTools.PatAlgos.producersLayer1.pfParticleProducer_cfi import patPFParticles
277  # make modules
278  producer = patPFParticles.clone(pfCandidateSource = src)
279  filter = cms.EDFilter("PATPFParticleSelector",
280  src = cms.InputTag("pat" + patLabel),
281  cut = cms.string(cut))
282  counter = cms.EDFilter("PATCandViewCountFilter",
283  minNumber = cms.uint32(0),
284  maxNumber = cms.uint32(999999),
285  src = cms.InputTag("pat" + patLabel))
286  # add modules to process
287  setattr(process, "pat" + patLabel, producer)
288  setattr(process, "selectedPat" + patLabel, filter)
289  setattr(process, "countPat" + patLabel, counter)
290 
291  # summary tables
292  applyPostfix(process, "patCandidateSummary", postfix).candidates.append(cms.InputTag('pat' + patLabel))
293  applyPostfix(process, "selectedPatCandidateSummary", postfix).candidates.append(cms.InputTag('selectedPat' + patLabel))
294 
295 
296 def switchToPFMET(process,input=cms.InputTag('pfMETPFBRECO'), type1=False, postfix=""):
297  print 'MET: using ', input
298  if( not type1 ):
299  oldMETSource = applyPostfix(process, "patMETs",postfix).metSource
300  applyPostfix(process, "patMETs",postfix).metSource = input
301  applyPostfix(process, "patMETs",postfix).addMuonCorrections = False
302  else:
303  # type1 corrected MET
304  # name of corrected MET hardcoded in PAT and meaningless
305  print 'Apply TypeI corrections for MET'
306  #getattr(process, "patPF2PATSequence"+postfix).remove(applyPostfix(process, "patMETCorrections",postfix))
307  jecLabel = getattr(process,'patJetCorrFactors'+postfix).payload.pythonValue().replace("'","")
308  getattr(process,jecLabel+'Type1CorMet'+postfix).src = input.getModuleLabel()
309  #getattr(process,'patMETs'+postfix).metSource = jecLabel+'Type1CorMet'+postfix
310  #getattr(process,'patMETs'+postfix).addMuonCorrections = False
311 
312 def switchToPFJets(process, input=cms.InputTag('pfNoTauClones'), algo='AK4', postfix = "", jetCorrections=('AK4PFchs', ['L1FastJet','L2Relative', 'L3Absolute']), type1=False, outputModules=['out']):
313 
314  print "Switching to PFJets, ", algo
315  print "************************ "
316  print "input collection: ", input
317 
318  if algo == 'AK4':
319  genJetCollection = cms.InputTag('ak4GenJetsNoNu'+postfix)
320  rParam=0.4
321  elif algo == 'AK7':
322  genJetCollection = cms.InputTag('ak7GenJetsNoNu'+postfix)
323  rParam=0.7
324  else:
325  print 'bad jet algorithm:', algo, '! for now, only AK4 and AK7 are allowed. If you need other algorithms, please contact Colin'
326  sys.exit(1)
327 
328  # changing the jet collection in PF2PAT:
329  from CommonTools.ParticleFlow.Tools.jetTools import jetAlgo
330  inputCollection = getattr(process,"pfJetsPFBRECO"+postfix).src
331  setattr(process,"pfJetsPFBRECO"+postfix,jetAlgo(algo)) # problem for cfgBrowser
332  getattr(process,"pfJetsPFBRECO"+postfix).src = inputCollection
333  inputJetCorrLabel=jetCorrections
334 
335  switchJetCollection(process,
336  jetSource = input,
337  algo=algo,
338  rParam=rParam,
339  genJetCollection=genJetCollection,
340  postfix=postfix,
341  jetTrackAssociation=True,
342  jetCorrections=inputJetCorrLabel,
343  outputModules = outputModules,
344  )
345 
346  # check whether L1FastJet is in the list of correction levels or not
347  applyPostfix(process, "patJetCorrFactors", postfix).useRho = False
348  for corr in inputJetCorrLabel[1]:
349  if corr == 'L1FastJet':
350  applyPostfix(process, "patJetCorrFactors", postfix).useRho = True
351  applyPostfix(process, "pfJetsPFBRECO", postfix).doAreaFastjet = True
352  # do correct treatment for TypeI MET corrections
353  #type1=True
354  if type1:
355  for mod in process.producerNames().split(' '):
356 
357  if mod.startswith("kt6") and mod.endswith("Jets"+postfix) and not 'GenJets' in mod:
358  prefix = mod.replace(postfix,'')
359  prefix = prefix.replace('kt6PFJets','')
360  prefix = prefix.replace('kt6CaloJets','')
361  prefix = getattr(process,'patJetCorrFactors'+prefix+postfix).payload.pythonValue().replace("'","")
362  for essource in process.es_sources_().keys():
363  if essource == prefix+'L1FastJet':
364  setattr(process,essource+postfix,getattr(process,essource).clone(srcRho=cms.InputTag(mod,'rho')))
365  setattr(process,prefix+'CombinedCorrector'+postfix,getattr(process,prefix+'CombinedCorrector').clone())
366  getattr(process,prefix+'CorMet'+postfix).corrector = prefix+'CombinedCorrector'+postfix
367  for cor in getattr(process,prefix+'CombinedCorrector'+postfix).correctors:
368  if cor == essource:
369  idx = getattr(process,prefix+'CombinedCorrector'+postfix).correctors.index(essource);
370  getattr(process,prefix+'CombinedCorrector'+postfix).correctors[idx] = essource+postfix
371 
372  if hasattr( getattr( process, "patJets" + postfix), 'embedCaloTowers' ): # optional parameter, which defaults to 'False' anyway
373  applyPostfix(process, "patJets", postfix).embedCaloTowers = False
374  applyPostfix(process, "patJets", postfix).embedPFCandidates = True
375 
376 #-- Remove MC dependence ------------------------------------------------------
377 def removeMCMatchingPF2PAT( process, postfix="", outputModules=['out'] ):
378  #from PhysicsTools.PatAlgos.tools.coreTools import removeMCMatching
379  ### no longe needed in unscheduled mode###
380  #removeIfInSequence(process, "genForPF2PATSequence", "patDefaultSequence", postfix)
381  removeMCMatching(process, names=['All'], postfix=postfix, outputModules=outputModules)
382 
383 
384 def adaptPVs(process, pvCollection=cms.InputTag('offlinePrimaryVertices'), postfix=''):
385  print "Switching PV collection for PF2PAT:", pvCollection
386  print "***********************************"
387 
388  # PV sources to be exchanged:
389  pvExchange = ['Vertices','vertices','pvSrc','primaryVertices','srcPVs','primaryVertex']
390  # PV sources NOT to be exchanged:
391  #noPvExchange = ['src','PVProducer','primaryVertexSrc','vertexSrc']
392 
393  # exchange the primary vertex source of all relevant modules
394  for m in (process.producerNames().split(' ') + process.filterNames().split(' ')):
395  # only if the module has a source with a relevant name
396  for namePvSrc in pvExchange:
397  if hasattr(getattr(process,m),namePvSrc):
398  #print m
399  setattr(getattr(process,m),namePvSrc,deepcopy(pvCollection))
400 
401 
402 def usePF2PAT(process,runPF2PAT=True, jetAlgo='AK4', runOnMC=True, postfix="", jetCorrections=('AK4PFchs', ['L1FastJet','L2Relative','L3Absolute'],'None'), pvCollection=cms.InputTag('goodOfflinePrimaryVerticesPFlow',), typeIMetCorrections=False, outputModules=['out'],excludeFromTopProjection=['Tau']):
403  # PLEASE DO NOT CLOBBER THIS FUNCTION WITH CODE SPECIFIC TO A GIVEN PHYSICS OBJECT.
404  # CREATE ADDITIONAL FUNCTIONS IF NEEDED.
405 
406  if typeIMetCorrections:
407  jetCorrections = (jetCorrections[0],jetCorrections[1],'Type-1')
408  """Switch PAT to use PF2PAT instead of AOD sources. if 'runPF2PAT' is true, we'll also add PF2PAT in front of the PAT sequence"""
409 
410  # -------- CORE ---------------
411  from PhysicsTools.PatAlgos.tools.helpers import loadWithPostfix
412  if runPF2PAT:
413  loadWithPostfix(process,'PhysicsTools.PatAlgos.patSequences_cff',postfix)
414  loadWithPostfix(process,"CommonTools.ParticleFlow.PFBRECO_cff",postfix)
415  else:
416  loadWithPostfix(process,'PhysicsTools.PatAlgos.patSequences_cff',postfix)
417 
418 
419 
420 
421  # -------- OBJECTS ------------
422  # Muons
423 
424  adaptPFMuons(process,
425  applyPostfix(process,"patMuons",postfix),
426  postfix)
427 
428  # Electrons
429 
430  adaptPFElectrons(process,
431  applyPostfix(process,"patElectrons",postfix),
432  postfix)
433 
434  # Photons
435  #print "Temporarily switching off photons completely"
436 
437  #removeSpecificPATObjects(process,names=['Photons'],outputModules=outputModules,postfix=postfix)
438 
439  # Jets
440  if runOnMC :
441  switchToPFJets( process, cms.InputTag('pfNoTauClonesPFBRECO'+postfix), jetAlgo, postfix=postfix,
442  jetCorrections=jetCorrections, type1=typeIMetCorrections, outputModules=outputModules )
443 
444  else :
445  if not 'L2L3Residual' in jetCorrections[1]:
446  ### think of a more accurate warning
447  print '#################################################'
448  print 'WARNING! Not using L2L3Residual but this is data.'
449  print 'If this is okay with you, disregard this message.'
450  print '#################################################'
451  switchToPFJets( process, cms.InputTag('pfNoTauClonesPFBRECO'+postfix), jetAlgo, postfix=postfix,
452  jetCorrections=jetCorrections, type1=typeIMetCorrections, outputModules=outputModules )
453  # Taus
454  #adaptPFTaus( process, tauType='shrinkingConePFTau', postfix=postfix )
455  #adaptPFTaus( process, tauType='fixedConePFTau', postfix=postfix )
456  adaptPFTaus( process, tauType='hpsPFTau', postfix=postfix )
457  # MET
458  switchToPFMET(process, cms.InputTag('pfMETPFBRECO'+postfix), type1=typeIMetCorrections, postfix=postfix)
459 
460  # Unmasked PFCandidates
461  addPFCandidates(process,cms.InputTag('pfNoJetClones'+postfix),patLabel='PFParticles'+postfix,cut="",postfix=postfix)
462 
463  # adapt primary vertex collection
464  adaptPVs(process, pvCollection=pvCollection, postfix=postfix)
465 
466  if not runOnMC:
467  runOnData(process,postfix=postfix,outputModules=outputModules)
468 
469  # Configure Top Projections
470  getattr(process,"pfNoPileUpJME"+postfix).enable = True
471  getattr(process,"pfNoMuonJMEPFBRECO"+postfix).enable = True
472  getattr(process,"pfNoElectronJMEPFBRECO"+postfix).enable = True
473  getattr(process,"pfNoTauPFBRECO"+postfix).enable = False
474  getattr(process,"pfNoJetPFBRECO"+postfix).enable = True
475  exclusionList = ''
476  for object in excludeFromTopProjection:
477  jme = ''
478  if object in ['Muon','Electron']:
479  jme = 'JME'
480  getattr(process,"pfNo"+object+jme+'PFBRECO'+postfix).enable = False
481  exclusionList=exclusionList+object+','
482  exclusionList=exclusionList.rstrip(',')
483  print "Done: PFBRECO interfaced to PAT, postfix=", postfix,", Excluded from Top Projection:",exclusionList
def adaptPFPhotons
Definition: pfTools.py:90
def jetAlgo
Definition: jetTools.py:3
def switchToPFMET
Definition: pfTools.py:296
def adaptPFTaus
Definition: pfTools.py:230
def tauTypeInPF2PAT
Definition: pfTools.py:270
def adaptPFMuons
Definition: pfTools.py:14
def removeMCMatchingPF2PAT
Definition: pfTools.py:377
def reconfigurePF2PATTaus
Definition: pfTools.py:100
def applyPostfix
Definition: helpers.py:70
def usePF2PAT
Definition: pfTools.py:402
def massSearchReplaceParam
Definition: helpers.py:249
def addPFCandidates
Definition: pfTools.py:275
def adaptPVs
Definition: pfTools.py:384
def adaptPFElectrons
Definition: pfTools.py:50
def switchToPFJets
Definition: pfTools.py:312
def loadWithPostfix
Definition: helpers.py:18
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
if(dp >Float(M_PI)) dp-
def warningIsolation
Definition: pfTools.py:11
def switchToPFTauByType
Definition: tauTools.py:227
double split
Definition: MVATrainer.cc:139