CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
pfTools Namespace Reference

Functions

def adaptPFElectrons
 
def adaptPFMuons
 
def adaptPFPhotons
 
def adaptPFTaus
 
def adaptPVs
 
def addPFCandidates
 
def reconfigurePF2PATTaus
 
def removeMCMatchingPF2PAT
 
def switchToPFJets
 
def switchToPFMET
 
def tauTypeInPF2PAT
 
def usePF2PAT
 
def warningIsolation
 

Function Documentation

def pfTools.adaptPFElectrons (   process,
  module,
  postfix 
)

Definition at line 50 of file pfTools.py.

Referenced by usePF2PAT().

50 
51 def adaptPFElectrons(process,module, postfix):
52  # module.useParticleFlow = True
53  print "Adapting PF Electrons "
54  print "********************* "
55  #warningIsolation()
56  print
57  module.useParticleFlow = True
58  module.pfElectronSource = cms.InputTag("pfIsolatedElectronsPFBRECO" + postfix)
59  module.userIsolation = cms.PSet()
60  ## module.isoDeposits = cms.PSet(
61  ## pfChargedHadrons = cms.InputTag("elPFIsoDepositCharged" + postfix),
62  ## pfChargedAll = cms.InputTag("elPFIsoDepositChargedAll" + postfix),
63  ## pfPUChargedHadrons = cms.InputTag("elPFIsoDepositPU" + postfix),
64  ## pfNeutralHadrons = cms.InputTag("elPFIsoDepositNeutral" + postfix),
65  ## pfPhotons = cms.InputTag("elPFIsoDepositGamma" + postfix)
66  ## )
67  ## module.isolationValues = cms.PSet(
68  ## pfChargedHadrons = cms.InputTag("elPFIsoValueCharged04PFId"+ postfix),
69  ## pfChargedAll = cms.InputTag("elPFIsoValueChargedAll04PFId"+ postfix),
70  ## pfPUChargedHadrons = cms.InputTag("elPFIsoValuePU04PFId" + postfix),
71  ## pfNeutralHadrons = cms.InputTag("elPFIsoValueNeutral04PFId" + postfix),
72  ## pfPhotons = cms.InputTag("elPFIsoValueGamma04PFId" + postfix)
73  ## )
74 
75  # COLIN: since we take the egamma momentum for pat Electrons, we must
76  # match the egamma electron to the gen electrons, and not the PFElectron.
77  # -> do not uncomment the line below.
78  # process.electronMatch.src = module.pfElectronSource
79  # COLIN: how do we depend on this matching choice?
80 
81  print " PF electron source:", module.pfElectronSource
82  ## print " isolation :"
83  ## print module.isolationValues
84  ## print " isodeposits: "
85  ## print module.isoDeposits
86  print
87 
88 
89 
def adaptPFElectrons
Definition: pfTools.py:50
def pfTools.adaptPFMuons (   process,
  module,
  postfix = "",
  muonMatchModule = None 
)

Definition at line 14 of file pfTools.py.

References helpers.applyPostfix().

Referenced by usePF2PAT().

14 
15 def adaptPFMuons(process,module,postfix="", muonMatchModule=None ):
16  print "Adapting PF Muons "
17  print "***************** "
18  #warningIsolation()
19  print
20  module.useParticleFlow = True
21  module.pfMuonSource = cms.InputTag("pfIsolatedMuonsPFBRECO" + postfix)
22  module.userIsolation = cms.PSet()
23  ## module.isoDeposits = cms.PSet(
24  ## pfChargedHadrons = cms.InputTag("muPFIsoDepositCharged" + postfix),
25  ## pfChargedAll = cms.InputTag("muPFIsoDepositChargedAll" + postfix),
26  ## pfPUChargedHadrons = cms.InputTag("muPFIsoDepositPU" + postfix),
27  ## pfNeutralHadrons = cms.InputTag("muPFIsoDepositNeutral" + postfix),
28  ## pfPhotons = cms.InputTag("muPFIsoDepositGamma" + postfix)
29  ## )
30  ## module.isolationValues = cms.PSet(
31  ## pfChargedHadrons = cms.InputTag("muPFIsoValueCharged04"+ postfix),
32  ## pfChargedAll = cms.InputTag("muPFIsoValueChargedAll04"+ postfix),
33  ## pfPUChargedHadrons = cms.InputTag("muPFIsoValuePU04" + postfix),
34  ## pfNeutralHadrons = cms.InputTag("muPFIsoValueNeutral04" + postfix),
35  ## pfPhotons = cms.InputTag("muPFIsoValueGamma04" + postfix)
36  ## )
37  # matching the pfMuons, not the standard muons.
38  if muonMatchModule == None :
39  applyPostfix(process,"muonMatch",postfix).src = module.pfMuonSource
40  else :
41  muonMatchModule.src = module.pfMuonSource
42 
43  print " muon source:", module.pfMuonSource
44  ## print " isolation :",
45  ## print module.isolationValues
46  ## print " isodeposits: "
47  ## print module.isoDeposits
48  print
49 
def adaptPFMuons
Definition: pfTools.py:14
def applyPostfix
Definition: helpers.py:76
def pfTools.adaptPFPhotons (   process,
  module 
)

Definition at line 90 of file pfTools.py.

References reconfigurePF2PATTaus().

90 
91 def adaptPFPhotons(process,module):
92  raise RuntimeError("Photons are not supported yet")
def adaptPFPhotons
Definition: pfTools.py:90
def pfTools.adaptPFTaus (   process,
  tauType = 'shrinkingConePFTau',
  postfix = "" 
)

Definition at line 230 of file pfTools.py.

References reconfigurePF2PATTaus(), and tauTools.switchToPFTauByType().

Referenced by usePF2PAT().

231 def adaptPFTaus(process,tauType = 'shrinkingConePFTau', postfix = ""):
232  # Set up the collection used as a preselection to use this tau type
233  if tauType != 'hpsPFTau' :
234  reconfigurePF2PATTaus(process, tauType, postfix=postfix)
235  else:
236  reconfigurePF2PATTaus(process, tauType,
237  ["DiscriminationByDecayModeFinding"],
238  ["DiscriminationByDecayModeFinding"],
239  postfix=postfix)
240  # new default use unselected taus (selected only for jet cleaning)
241  if tauType != 'hpsPFTau' :
242  getattr(process,"patTaus" + postfix).tauSource = cms.InputTag("pfTausBase"+postfix)
243  else:
244  getattr(process,"patTaus" + postfix).tauSource = cms.InputTag("hpsPFTauProducer"+postfix)
245  # to use preselected collection (old default) uncomment line below
246  #applyPostfix(process,"patTaus", postfix).tauSource = cms.InputTag("pfTaus"+postfix)
247 
248  ### apparently not needed anymore, function gone from tauTools.py###
249  #redoPFTauDiscriminators(process,
250  #cms.InputTag(tauType+'Producer'),
251  #applyPostfix(process,"patTaus", postfix).tauSource,
252  #tauType, postfix=postfix)
253 
254 
255  if tauType != 'hpsPFTau' :
256  switchToPFTauByType(process, pfTauType=tauType,
257  patTauLabel="pfTausBase"+postfix,
258  tauSource=cms.InputTag(tauType+'Producer'+postfix),
259  postfix=postfix)
260  getattr(process,"patTaus" + postfix).tauSource = cms.InputTag("pfTausBase"+postfix)
261  else:
262  switchToPFTauByType(process, pfTauType=tauType,
263  patTauLabel="",
264  tauSource=cms.InputTag(tauType+'Producer'+postfix),
265  postfix=postfix)
266  getattr(process,"patTaus" + postfix).tauSource = cms.InputTag("hpsPFTauProducer"+postfix)
267 
268 
269 
#helper function for PAT on PF2PAT sample
def adaptPFTaus
Definition: pfTools.py:230
def reconfigurePF2PATTaus
Definition: pfTools.py:100
def switchToPFTauByType
Definition: tauTools.py:220
def pfTools.adaptPVs (   process,
  pvCollection = cms.InputTag('offlinePrimaryVertices'),
  postfix = '' 
)

Definition at line 384 of file pfTools.py.

References split.

Referenced by usePF2PAT().

385 def adaptPVs(process, pvCollection=cms.InputTag('offlinePrimaryVertices'), postfix=''):
386  print "Switching PV collection for PF2PAT:", pvCollection
387  print "***********************************"
388 
389  # PV sources to be exchanged:
390  pvExchange = ['Vertices','vertices','pvSrc','primaryVertices','srcPVs','primaryVertex']
391  # PV sources NOT to be exchanged:
392  #noPvExchange = ['src','PVProducer','primaryVertexSrc','vertexSrc']
393 
394  # exchange the primary vertex source of all relevant modules
395  for m in (process.producerNames().split(' ') + process.filterNames().split(' ')):
396  # only if the module has a source with a relevant name
397  for namePvSrc in pvExchange:
398  if hasattr(getattr(process,m),namePvSrc):
399  #print m
400  setattr(getattr(process,m),namePvSrc,deepcopy(pvCollection))
401 
def adaptPVs
Definition: pfTools.py:384
double split
Definition: MVATrainer.cc:139
def pfTools.addPFCandidates (   process,
  src,
  patLabel = 'PFParticles',
  cut = "",
  postfix = "" 
)

Definition at line 275 of file pfTools.py.

References helpers.applyPostfix().

Referenced by usePF2PAT().

276 def addPFCandidates(process,src,patLabel='PFParticles',cut="",postfix=""):
277  from PhysicsTools.PatAlgos.producersLayer1.pfParticleProducer_cfi import patPFParticles
278  # make modules
279  producer = patPFParticles.clone(pfCandidateSource = src)
280  filter = cms.EDFilter("PATPFParticleSelector",
281  src = cms.InputTag("pat" + patLabel),
282  cut = cms.string(cut))
283  counter = cms.EDFilter("PATCandViewCountFilter",
284  minNumber = cms.uint32(0),
285  maxNumber = cms.uint32(999999),
286  src = cms.InputTag("pat" + patLabel))
287  # add modules to process
288  setattr(process, "pat" + patLabel, producer)
289  setattr(process, "selectedPat" + patLabel, filter)
290  setattr(process, "countPat" + patLabel, counter)
291 
292  # summary tables
293  applyPostfix(process, "patCandidateSummary", postfix).candidates.append(cms.InputTag('pat' + patLabel))
294  applyPostfix(process, "selectedPatCandidateSummary", postfix).candidates.append(cms.InputTag('selectedPat' + patLabel))
295 
def applyPostfix
Definition: helpers.py:76
def addPFCandidates
Definition: pfTools.py:275
def pfTools.reconfigurePF2PATTaus (   process,
  tauType = 'shrinkingConePFTau',
  pf2patSelection = ["DiscriminationByIsolation",
  DiscriminationByLeadingPionPtCut,
  selectionDependsOn = ["DiscriminationByLeadingTrackFinding"],
  producerFromType = lambda producer: producer+"Producer",
  postfix = "" 
)

Definition at line 100 of file pfTools.py.

References TauDiscriminatorTools.adaptTauDiscriminator(), helpers.applyPostfix(), clone(), helpers.massSearchReplaceParam(), TauDiscriminatorTools.producerIsTauTypeMapper, and TauDiscriminatorTools.recoTauTypeMapper().

Referenced by adaptPFPhotons(), and adaptPFTaus().

101  postfix = ""):
102  print "patTaus will be produced from taus of type: %s that pass %s" \
103  % (tauType, pf2patSelection)
104 
105 
106 
107  # Get the prototype of tau producer to make, i.e. fixedConePFTauProducer
108  producerName = producerFromType(tauType)
109  # Set as the source for the pf2pat taus (pfTaus) selector
110  applyPostfix(process,"pfTaus", postfix).src = producerName+postfix
111  # Start our pf2pat taus base sequence
112  oldTauSansRefs = getattr(process,'pfTausProducerSansRefs'+postfix)
113  oldTau = getattr(process,'pfTausProducer'+postfix)
114  ## copy tau and setup it properly
115  newTauSansRefs = None
116  newTau = getattr(process,producerName+postfix).clone()
117 
118  ## adapted to new structure in RecoTauProducers PLEASE CHECK!!!
119  if tauType=='shrinkingConePFTau':
120  newTauSansRefs = getattr(process,producerName+"SansRefs").clone()
121  newTauSansRefs.modifiers[1] = cms.PSet(
122  pfTauTagInfoSrc = cms.InputTag("pfTauTagInfoProducer"+postfix),
123  name = cms.string('pfTauTTIworkaround'+postfix),
124  plugin = cms.string('RecoTauTagInfoWorkaroundModifer')
125  )
126  newTau.modifiers[1] = newTauSansRefs.modifiers[1]
127  newTauSansRefs.piZeroSrc = "pfJetsLegacyTaNCPiZeros"+postfix
128  newTau.piZeroSrc = newTauSansRefs.piZeroSrc
129  newTauSansRefs.builders[0].pfCandSrc = oldTauSansRefs.builders[0].pfCandSrc
130  newTauSansRefs.jetRegionSrc = oldTauSansRefs.jetRegionSrc
131  newTauSansRefs.jetSrc = oldTauSansRefs.jetSrc
132  elif tauType=='fixedConePFTau':
133  newTau.piZeroSrc = "pfJetsLegacyTaNCPiZeros"+postfix
134  elif tauType=='hpsPFTau':
135  newTau = getattr(process,'combinatoricRecoTaus'+postfix).clone()
136  newTau.piZeroSrc="pfJetsLegacyHPSPiZeros"+postfix
137  newTau.modifiers[3] = cms.PSet(
138  pfTauTagInfoSrc = cms.InputTag("pfTauTagInfoProducer"+postfix),
139  name = cms.string('pfTauTTIworkaround'+postfix),
140  plugin = cms.string('RecoTauTagInfoWorkaroundModifer')
141  )
142  from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet
143  #cloneProcessingSnippet(process, process.produceHPSPFTaus, postfix)
144  setattr(process,'produceHPSPFTaus'+postfix,cms.Sequence(applyPostfix(process,'hpsSelectionDiscriminator',postfix)+applyPostfix(process,'hpsPFTauProducerSansRefs',postfix)+applyPostfix(process,'hpsPFTauProducer',postfix)))
145  massSearchReplaceParam(getattr(process,"produceHPSPFTaus"+postfix),
146  "PFTauProducer",
147  cms.InputTag("combinatoricRecoTaus"+postfix),
148  cms.InputTag("pfTausBase"+postfix) )
149  massSearchReplaceParam(getattr(process,"produceHPSPFTaus"+postfix),
150  "src",
151  cms.InputTag("combinatoricRecoTaus"+postfix),
152  cms.InputTag("pfTausBase"+postfix) )
153  ### Next three lines crash, oldTau does not have any of these attributes. Why?###
154  #newTau.builders[0].pfCandSrc = oldTau.builders[0].pfCandSrc
155  #newTau.jetRegionSrc = oldTau.jetRegionSrc
156  #newTau.jetSrc = oldTau.jetSrc
157  #newTau.builders[0].pfCandSrc = cms.InputTag("pfNoElectronJME" + postfix)
158  #newTau.jetRegionSrc = cms.InputTag("pfTauPFJets08Region" + postfix)
159  #newTau.jetSrc = cms.InputTag("pfJetsPFBRECO" + postfix)
160  # replace old tau producer by new one put it into baseSequence
161  setattr(process,"pfTausBase"+postfix,newTau)
162  if tauType=='shrinkingConePFTau':
163  setattr(process,"pfTausBaseSansRefs"+postfix,newTauSansRefs)
164  getattr(process,"pfTausBase"+postfix).src = "pfTausBaseSansRefs"+postfix
165  baseSequence += getattr(process,"pfTausBaseSansRefs"+postfix)
166 
167  #make custom mapper to take postfix into account (could have gone with lambda of lambda but... )
168  def producerIsTauTypeMapperWithPostfix(tauProducer):
169  return lambda x: producerIsTauTypeMapper(tauProducer)+x.group(1)+postfix
170 
171  def recoTauTypeMapperWithGroup(tauProducer):
172  return "%s(.*)"%recoTauTypeMapper(tauProducer)
173 
174  # Get our prediscriminants
175  for predisc in selectionDependsOn:
176  # Get the prototype
177  originalName = tauType+predisc # i.e. fixedConePFTauProducerDiscriminationByLeadingTrackFinding
178  clonedName = "pfTausBase"+predisc+postfix
179  clonedDisc = getattr(process, originalName).clone()
180  setattr(process, clonedName, clonedDisc)
181 
182  tauCollectionToSelect = None
183  if tauType != 'hpsPFTau' :
184  tauCollectionToSelect = "pfTausBase"+postfix
185  #cms.InputTag(clonedDisc.PFTauProducer.value()+postfix)
186  else:
187  tauCollectionToSelect = "hpsPFTauProducer"+postfix
188  # Adapt this discriminator for the cloned prediscriminators
189  adaptTauDiscriminator(clonedDisc, newTauProducer="pfTausBase",
190  oldTauTypeMapper=recoTauTypeMapperWithGroup,
191  newTauTypeMapper=producerIsTauTypeMapperWithPostfix,
192  preservePFTauProducer=True)
193  clonedDisc.PFTauProducer = tauCollectionToSelect
194 
195  # Reconfigure the pf2pat PFTau selector discrimination sources
196  getattr(process,"pfTaus" + postfix).discriminators = cms.VPSet()
197  for selection in pf2patSelection:
198  # Get our discriminator that will be used to select pfTaus
199  originalName = tauType+selection
200  clonedName = "pfTausBase"+selection+postfix
201  clonedDisc = getattr(process, originalName).clone()
202  setattr(process, clonedName, clonedDisc)
203 
204  tauCollectionToSelect = None
205 
206  if tauType != 'hpsPFTau' :
207  tauCollectionToSelect = cms.InputTag("pfTausBase"+postfix)
208  #cms.InputTag(clonedDisc.PFTauProducer.value()+postfix)
209  else:
210  tauCollectionToSelect = cms.InputTag("hpsPFTauProducer"+postfix)
211  #Adapt our cloned discriminator to the new prediscriminants
212  adaptTauDiscriminator(clonedDisc, newTauProducer="pfTausBase",
213  oldTauTypeMapper=recoTauTypeMapperWithGroup,
214  newTauTypeMapper=producerIsTauTypeMapperWithPostfix,
215  preservePFTauProducer=True)
216  clonedDisc.PFTauProducer = tauCollectionToSelect
217 
218  # Add this selection to our pfTau selectors
219  getattr(process,"pfTaus" + postfix).discriminators.append(cms.PSet(
220  discriminator=cms.InputTag(clonedName), selectionCut=cms.double(0.5)))
221  # Set the input of the final selector.
222  if tauType != 'hpsPFTau':
223  getattr(process,"pfTaus" + postfix).src = "pfTausBase"+postfix
224  else:
225  # If we are using HPS taus, we need to take the output of the clenaed
226  # collection
227  getattr(process,"pfTaus" + postfix).src = "hpsPFTauProducer"+postfix
228 
229 
def applyPostfix
Definition: helpers.py:76
def massSearchReplaceParam
Definition: helpers.py:258
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
def pfTools.removeMCMatchingPF2PAT (   process,
  postfix = "",
  outputModules = ['out'] 
)

Definition at line 377 of file pfTools.py.

378 def removeMCMatchingPF2PAT( process, postfix="", outputModules=['out'] ):
379  #from PhysicsTools.PatAlgos.tools.coreTools import removeMCMatching
380  ### no longe needed in unscheduled mode###
381  #removeIfInSequence(process, "genForPF2PATSequence", "patDefaultSequence", postfix)
382  removeMCMatching(process, names=['All'], postfix=postfix, outputModules=outputModules)
383 
def removeMCMatchingPF2PAT
Definition: pfTools.py:377
def pfTools.switchToPFJets (   process,
  input = cms.InputTag('pfNoTauClones'),
  algo = 'AK4',
  postfix = "",
  jetCorrections = ('AK4PFchs', ['L1FastJet',
  L2Relative,
  L3Absolute,
  type1 = False,
  outputModules = ['out'] 
)

Definition at line 312 of file pfTools.py.

References helpers.applyPostfix(), clone(), jetTools.jetAlgo(), relativeConstraints.keys, python.rootplot.root2matplotlib.replace(), and split.

Referenced by usePF2PAT().

313 def switchToPFJets(process, input=cms.InputTag('pfNoTauClones'), algo='AK4', postfix = "", jetCorrections=('AK4PFchs', ['L1FastJet','L2Relative', 'L3Absolute']), type1=False, outputModules=['out']):
314 
315  print "Switching to PFJets, ", algo
316  print "************************ "
317  print "input collection: ", input
318 
319  if algo == 'AK4':
320  genJetCollection = cms.InputTag('ak4GenJetsNoNu'+postfix)
321  rParam=0.4
322  elif algo == 'AK7':
323  genJetCollection = cms.InputTag('ak7GenJetsNoNu'+postfix)
324  rParam=0.7
325  else:
326  print 'bad jet algorithm:', algo, '! for now, only AK4 and AK7 are allowed. If you need other algorithms, please contact Colin'
327  sys.exit(1)
328 
329  # changing the jet collection in PF2PAT:
330  from CommonTools.ParticleFlow.Tools.jetTools import jetAlgo
331  inputCollection = getattr(process,"pfJetsPFBRECO"+postfix).src
332  setattr(process,"pfJetsPFBRECO"+postfix,jetAlgo(algo)) # problem for cfgBrowser
333  getattr(process,"pfJetsPFBRECO"+postfix).src = inputCollection
334  inputJetCorrLabel=jetCorrections
335 
336  switchJetCollection(process,
337  jetSource = input,
338  algo=algo,
339  rParam=rParam,
340  genJetCollection=genJetCollection,
341  postfix=postfix,
342  jetTrackAssociation=True,
343  jetCorrections=inputJetCorrLabel,
344  outputModules = outputModules,
345  )
346 
347  # check whether L1FastJet is in the list of correction levels or not
348  applyPostfix(process, "patJetCorrFactors", postfix).useRho = False
349  for corr in inputJetCorrLabel[1]:
350  if corr == 'L1FastJet':
351  applyPostfix(process, "patJetCorrFactors", postfix).useRho = True
352  applyPostfix(process, "pfJetsPFBRECO", postfix).doAreaFastjet = True
353  # do correct treatment for TypeI MET corrections
354  #type1=True
355  if type1:
356  for mod in process.producerNames().split(' '):
357 
358  if mod.startswith("kt6") and mod.endswith("Jets"+postfix) and not 'GenJets' in mod:
359  prefix = mod.replace(postfix,'')
360  prefix = prefix.replace('kt6PFJets','')
361  prefix = prefix.replace('kt6CaloJets','')
362  prefix = getattr(process,'patJetCorrFactors'+prefix+postfix).payload.pythonValue().replace("'","")
363  for essource in process.es_sources_().keys():
364  if essource == prefix+'L1FastJet':
365  setattr(process,essource+postfix,getattr(process,essource).clone(srcRho=cms.InputTag(mod,'rho')))
366  setattr(process,prefix+'CombinedCorrector'+postfix,getattr(process,prefix+'CombinedCorrector').clone())
367  getattr(process,prefix+'CorMet'+postfix).corrector = prefix+'CombinedCorrector'+postfix
368  for cor in getattr(process,prefix+'CombinedCorrector'+postfix).correctors:
369  if cor == essource:
370  idx = getattr(process,prefix+'CombinedCorrector'+postfix).correctors.index(essource);
371  getattr(process,prefix+'CombinedCorrector'+postfix).correctors[idx] = essource+postfix
372 
373  if hasattr( getattr( process, "patJets" + postfix), 'embedCaloTowers' ): # optional parameter, which defaults to 'False' anyway
374  applyPostfix(process, "patJets", postfix).embedCaloTowers = False
375  applyPostfix(process, "patJets", postfix).embedPFCandidates = True
376 
#-- Remove MC dependence ------------------------------------------------------
def jetAlgo
Definition: jetTools.py:3
def applyPostfix
Definition: helpers.py:76
def switchToPFJets
Definition: pfTools.py:312
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
double split
Definition: MVATrainer.cc:139
def pfTools.switchToPFMET (   process,
  input = cms.InputTag('pfMETPFBRECO'),
  type1 = False,
  postfix = "" 
)

Definition at line 296 of file pfTools.py.

References helpers.applyPostfix(), reco.if(), and python.rootplot.root2matplotlib.replace().

Referenced by usePF2PAT().

297 def switchToPFMET(process,input=cms.InputTag('pfMETPFBRECO'), type1=False, postfix=""):
298  print 'MET: using ', input
299  if( not type1 ):
300  oldMETSource = applyPostfix(process, "patMETs",postfix).metSource
301  applyPostfix(process, "patMETs",postfix).metSource = input
302  applyPostfix(process, "patMETs",postfix).addMuonCorrections = False
303  else:
304  # type1 corrected MET
305  # name of corrected MET hardcoded in PAT and meaningless
306  print 'Apply TypeI corrections for MET'
307  #getattr(process, "patPF2PATSequence"+postfix).remove(applyPostfix(process, "patMETCorrections",postfix))
308  jecLabel = getattr(process,'patJetCorrFactors'+postfix).payload.pythonValue().replace("'","")
309  getattr(process,jecLabel+'Type1CorMet'+postfix).src = input.getModuleLabel()
310  #getattr(process,'patMETs'+postfix).metSource = jecLabel+'Type1CorMet'+postfix
311  #getattr(process,'patMETs'+postfix).addMuonCorrections = False
def switchToPFMET
Definition: pfTools.py:296
def applyPostfix
Definition: helpers.py:76
if(dp >Float(M_PI)) dp-
def pfTools.tauTypeInPF2PAT (   process,
  tauType = 'shrinkingConePFTau',
  postfix = "" 
)

Definition at line 270 of file pfTools.py.

References helpers.applyPostfix().

271 def tauTypeInPF2PAT(process,tauType='shrinkingConePFTau', postfix = ""):
272  process.load("CommonTools.ParticleFlow.pfTaus_cff")
273  applyPostfix(process, "pfTaus",postfix).src = cms.InputTag(tauType+'Producer'+postfix)
274 
def tauTypeInPF2PAT
Definition: pfTools.py:270
def applyPostfix
Definition: helpers.py:76
def pfTools.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'] 
)

Definition at line 402 of file pfTools.py.

References adaptPFElectrons(), adaptPFMuons(), adaptPFTaus(), adaptPVs(), addPFCandidates(), helpers.applyPostfix(), helpers.loadWithPostfix(), switchToPFJets(), and switchToPFMET().

403 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']):
404  # PLEASE DO NOT CLOBBER THIS FUNCTION WITH CODE SPECIFIC TO A GIVEN PHYSICS OBJECT.
405  # CREATE ADDITIONAL FUNCTIONS IF NEEDED.
406 
407  if typeIMetCorrections:
408  jetCorrections = (jetCorrections[0],jetCorrections[1],'Type-1')
409  """Switch PAT to use PF2PAT instead of AOD sources. if 'runPF2PAT' is true, we'll also add PF2PAT in front of the PAT sequence"""
410 
411  # -------- CORE ---------------
412  from PhysicsTools.PatAlgos.tools.helpers import loadWithPostfix
413  if runPF2PAT:
414  loadWithPostfix(process,'PhysicsTools.PatAlgos.patSequences_cff',postfix)
415  loadWithPostfix(process,"CommonTools.ParticleFlow.PFBRECO_cff",postfix)
416  else:
417  loadWithPostfix(process,'PhysicsTools.PatAlgos.patSequences_cff',postfix)
418 
419 
420 
421 
422  # -------- OBJECTS ------------
423  # Muons
424 
425  adaptPFMuons(process,
426  applyPostfix(process,"patMuons",postfix),
427  postfix)
428 
429  # Electrons
430 
431  adaptPFElectrons(process,
432  applyPostfix(process,"patElectrons",postfix),
433  postfix)
434 
435  # Photons
436  #print "Temporarily switching off photons completely"
437 
438  #removeSpecificPATObjects(process,names=['Photons'],outputModules=outputModules,postfix=postfix)
439 
440  # Jets
441  if runOnMC :
442  switchToPFJets( process, cms.InputTag('pfNoTauClonesPFBRECO'+postfix), jetAlgo, postfix=postfix,
443  jetCorrections=jetCorrections, type1=typeIMetCorrections, outputModules=outputModules )
444 
445  else :
446  if not 'L2L3Residual' in jetCorrections[1]:
447  ### think of a more accurate warning
448  print '#################################################'
449  print 'WARNING! Not using L2L3Residual but this is data.'
450  print 'If this is okay with you, disregard this message.'
451  print '#################################################'
452  switchToPFJets( process, cms.InputTag('pfNoTauClonesPFBRECO'+postfix), jetAlgo, postfix=postfix,
453  jetCorrections=jetCorrections, type1=typeIMetCorrections, outputModules=outputModules )
454  # Taus
455  #adaptPFTaus( process, tauType='shrinkingConePFTau', postfix=postfix )
456  #adaptPFTaus( process, tauType='fixedConePFTau', postfix=postfix )
457  adaptPFTaus( process, tauType='hpsPFTau', postfix=postfix )
458  # MET
459  switchToPFMET(process, cms.InputTag('pfMETPFBRECO'+postfix), type1=typeIMetCorrections, postfix=postfix)
460 
461  # Unmasked PFCandidates
462  addPFCandidates(process,cms.InputTag('pfNoJetClones'+postfix),patLabel='PFParticles'+postfix,cut="",postfix=postfix)
463 
464  # adapt primary vertex collection
465  adaptPVs(process, pvCollection=pvCollection, postfix=postfix)
466 
467  if not runOnMC:
468  runOnData(process,postfix=postfix,outputModules=outputModules)
469 
470  # Configure Top Projections
471  getattr(process,"pfNoPileUpJME"+postfix).enable = True
472  getattr(process,"pfNoMuonJMEPFBRECO"+postfix).enable = True
473  getattr(process,"pfNoElectronJMEPFBRECO"+postfix).enable = True
474  getattr(process,"pfNoTauPFBRECO"+postfix).enable = False
475  getattr(process,"pfNoJetPFBRECO"+postfix).enable = True
476  exclusionList = ''
477  for object in excludeFromTopProjection:
478  jme = ''
479  if object in ['Muon','Electron']:
480  jme = 'JME'
481  getattr(process,"pfNo"+object+jme+'PFBRECO'+postfix).enable = False
482  exclusionList=exclusionList+object+','
483  exclusionList=exclusionList.rstrip(',')
484  print "Done: PFBRECO interfaced to PAT, postfix=", postfix,", Excluded from Top Projection:",exclusionList
def switchToPFMET
Definition: pfTools.py:296
def adaptPFTaus
Definition: pfTools.py:230
def adaptPFMuons
Definition: pfTools.py:14
def applyPostfix
Definition: helpers.py:76
def usePF2PAT
Definition: pfTools.py:402
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:21
def pfTools.warningIsolation ( )

Definition at line 11 of file pfTools.py.

11 
12 def warningIsolation():
13  print "WARNING: particle based isolation must be studied"
def warningIsolation
Definition: pfTools.py:11