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 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 60 of file pfTools.py.

References helpers.removeIfInSequence(), and warningIsolation().

Referenced by usePF2PAT().

60 
61 def adaptPFElectrons(process,module, postfix):
62  # module.useParticleFlow = True
63  print "Adapting PF Electrons "
64  print "********************* "
66  print
67  module.useParticleFlow = True
68  module.userIsolation = cms.PSet()
69  module.isoDeposits = cms.PSet(
70  pfChargedHadrons = cms.InputTag("isoDepElectronWithCharged" + postfix),
71  pfNeutralHadrons = cms.InputTag("isoDepElectronWithNeutral" + postfix),
72  pfPhotons = cms.InputTag("isoDepElectronWithPhotons" + postfix)
73  )
74  module.isolationValues = cms.PSet(
75  pfChargedHadrons = cms.InputTag("isoValElectronWithCharged" + postfix),
76  pfNeutralHadrons = cms.InputTag("isoValElectronWithNeutral" + postfix),
77  pfPhotons = cms.InputTag("isoValElectronWithPhotons" + postfix)
78  )
79 
80  # COLIN: since we take the egamma momentum for pat Electrons, we must
81  # match the egamma electron to the gen electrons, and not the PFElectron.
82  # -> do not uncomment the line below.
83  # process.electronMatch.src = module.pfElectronSource
84  # COLIN: how do we depend on this matching choice?
85 
86  print " PF electron source:", module.pfElectronSource
87  print " isolation :"
88  print module.isolationValues
89  print " isodeposits: "
90  print module.isoDeposits
91  print
92 
93  print "removing traditional isolation"
94 
95  removeIfInSequence(process, "patElectronIsolation", "patDefaultSequence", postfix)
def adaptPFElectrons
Definition: pfTools.py:60
def warningIsolation
Definition: pfTools.py:29
def removeIfInSequence
Definition: helpers.py:20
def pfTools.adaptPFMuons (   process,
  module,
  postfix = "" 
)

Definition at line 32 of file pfTools.py.

References helpers.applyPostfix(), and warningIsolation().

Referenced by usePF2PAT().

32 
33 def adaptPFMuons(process,module,postfix="" ):
34  print "Adapting PF Muons "
35  print "***************** "
37  print
38  module.useParticleFlow = True
39  module.userIsolation = cms.PSet()
40  module.isoDeposits = cms.PSet(
41  pfChargedHadrons = cms.InputTag("isoDepMuonWithCharged" + postfix),
42  pfNeutralHadrons = cms.InputTag("isoDepMuonWithNeutral" + postfix),
43  pfPhotons = cms.InputTag("isoDepMuonWithPhotons" + postfix)
44  )
45  module.isolationValues = cms.PSet(
46  pfChargedHadrons = cms.InputTag("isoValMuonWithCharged" + postfix),
47  pfNeutralHadrons = cms.InputTag("isoValMuonWithNeutral" + postfix),
48  pfPhotons = cms.InputTag("isoValMuonWithPhotons" + postfix)
49  )
50  # matching the pfMuons, not the standard muons.
51  applyPostfix(process,"muonMatch",postfix).src = module.pfMuonSource
52 
53  print " muon source:", module.pfMuonSource
54  print " isolation :",
55  print module.isolationValues
56  print " isodeposits: "
57  print module.isoDeposits
58  print
59 
def adaptPFMuons
Definition: pfTools.py:32
def applyPostfix
Helpers to perform some technically boring tasks like looking for all modules with a given parameter ...
Definition: helpers.py:6
def warningIsolation
Definition: pfTools.py:29
def pfTools.adaptPFPhotons (   process,
  module 
)

Definition at line 96 of file pfTools.py.

References reconfigurePF2PATTaus().

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

Definition at line 228 of file pfTools.py.

References helpers.applyPostfix(), reconfigurePF2PATTaus(), tauTools.redoPFTauDiscriminators(), python.multivaluedict.remove(), and tauTools.switchToPFTauByType().

Referenced by usePF2PAT().

229 def adaptPFTaus(process,tauType = 'shrinkingConePFTau', postfix = ""):
230  # Set up the collection used as a preselection to use this tau type
231  if tauType != 'hpsPFTau' :
232  reconfigurePF2PATTaus(process, tauType, postfix=postfix)
233  else:
234  reconfigurePF2PATTaus(process, tauType,
235  ["DiscriminationByLooseChargedIsolation","DiscriminationByLooseIsolation"],
236  ["DiscriminationByDecayModeFinding"],
237  postfix=postfix)
238  applyPostfix(process,"patTaus", postfix).tauSource = cms.InputTag("pfTaus"+postfix)
239 
240  redoPFTauDiscriminators(process,
241  cms.InputTag(tauType+'Producer'),
242  applyPostfix(process,"patTaus", postfix).tauSource,
243  tauType, postfix=postfix)
244 
245  switchToPFTauByType(process, pfTauType=tauType,
246  pfTauLabelNew=applyPostfix(process,"patTaus", postfix).tauSource,
247  pfTauLabelOld=cms.InputTag(tauType+'Producer'),
248  postfix=postfix)
249 
250  applyPostfix(process,"makePatTaus", postfix).remove(
251  applyPostfix(process,"patPFCandidateIsoDepositSelection", postfix)
252  )
253 
#helper function for PAT on PF2PAT sample
def adaptPFTaus
Definition: pfTools.py:228
def redoPFTauDiscriminators
Definition: tauTools.py:12
def reconfigurePF2PATTaus
Definition: pfTools.py:106
def applyPostfix
Helpers to perform some technically boring tasks like looking for all modules with a given parameter ...
Definition: helpers.py:6
def switchToPFTauByType
Definition: tauTools.py:266
def pfTools.addPFCandidates (   process,
  src,
  patLabel = 'PFParticles',
  cut = "",
  postfix = "" 
)

Definition at line 259 of file pfTools.py.

References helpers.applyPostfix(), edm::eventsetup::heterocontainer.insert(), and python.rootplot.root2matplotlib.replace().

Referenced by usePF2PAT().

260 def addPFCandidates(process,src,patLabel='PFParticles',cut="",postfix=""):
261  from PhysicsTools.PatAlgos.producersLayer1.pfParticleProducer_cfi import patPFParticles
262  # make modules
263  producer = patPFParticles.clone(pfCandidateSource = src)
264  filter = cms.EDFilter("PATPFParticleSelector",
265  src = cms.InputTag("pat" + patLabel),
266  cut = cms.string(cut))
267  counter = cms.EDFilter("PATCandViewCountFilter",
268  minNumber = cms.uint32(0),
269  maxNumber = cms.uint32(999999),
270  src = cms.InputTag("pat" + patLabel))
271  # add modules to process
272  setattr(process, "pat" + patLabel, producer)
273  setattr(process, "selectedPat" + patLabel, filter)
274  setattr(process, "countPat" + patLabel, counter)
275  # insert into sequence
276  getattr(process, "patDefaultSequence"+postfix).replace(
277  applyPostfix(process, "patCandidateSummary", postfix),
278  producer+applyPostfix(process, "patCandidateSummary", postfix)
279  )
280  getattr(process, "patDefaultSequence"+postfix).replace(
281  applyPostfix(process, "selectedPatCandidateSummary", postfix),
282  filter+applyPostfix(process, "selectedPatCandidateSummary", postfix)
283  )
284  index = len( applyPostfix( process, "patDefaultSequence", postfix ).moduleNames() )
285  applyPostfix( process, "patDefaultSequence", postfix ).insert( index, counter )
286  # summary tables
287  applyPostfix(process, "patCandidateSummary", postfix).candidates.append(cms.InputTag('pat' + patLabel))
288  applyPostfix(process, "selectedPatCandidateSummary", postfix).candidates.append(cms.InputTag('selectedPat' + patLabel))
289 
def applyPostfix
Helpers to perform some technically boring tasks like looking for all modules with a given parameter ...
Definition: helpers.py:6
def addPFCandidates
Definition: pfTools.py:259
bool insert(Storage &, ItemType *, const IdTag &)
def pfTools.reconfigurePF2PATTaus (   process,
  tauType = 'shrinkingConePFTau',
  pf2patSelection = ["DiscriminationByIsolation",
  DiscriminationByLeadingPionPtCut,
  selectionDependsOn = ["DiscriminationByLeadingTrackFinding"],
  producerFromType = lambda producer: producer+"Producer",
  postfix = "" 
)

Definition at line 106 of file pfTools.py.

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

Referenced by adaptPFPhotons(), and adaptPFTaus().

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

Definition at line 355 of file pfTools.py.

References helpers.removeIfInSequence().

Referenced by usePF2PAT().

356 def removeMCMatchingPF2PAT( process, postfix="" ):
357  from PhysicsTools.PatAlgos.tools.coreTools import removeMCMatching
358  removeIfInSequence(process, "genForPF2PATSequence", "patDefaultSequence", postfix)
359  removeMCMatching(process, ['All'],postfix)
360 
def removeMCMatchingPF2PAT
Definition: pfTools.py:355
def removeIfInSequence
Definition: helpers.py:20
def pfTools.switchToPFJets (   process,
  input = cms.InputTag('pfNoTau'),
  algo = 'AK5',
  postfix = "",
  jetCorrections = ('AK5PFchs', ['L1FastJet',
  L2Relative,
  L3Absolute 
)

Definition at line 312 of file pfTools.py.

References helpers.applyPostfix(), if(), and python.Tools.jetTools.jetAlgo().

Referenced by usePF2PAT().

313 def switchToPFJets(process, input=cms.InputTag('pfNoTau'), algo='AK5', postfix = "", jetCorrections=('AK5PFchs', ['L1FastJet','L2Relative', 'L3Absolute']) ):
314 
315  print "Switching to PFJets, ", algo
316  print "************************ "
317  print "input collection: ", input
318 
319  if( algo == 'IC5' ):
320  genJetCollection = cms.InputTag('iterativeCone5GenJetsNoNu')
321  elif algo == 'AK5':
322  genJetCollection = cms.InputTag('ak5GenJetsNoNu')
323  elif algo == 'AK7':
324  genJetCollection = cms.InputTag('ak7GenJetsNoNu')
325  else:
326  print 'bad jet algorithm:', algo, '! for now, only IC5, AK5 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,"pfJets"+postfix).src
332  setattr(process, "pfJets"+postfix, jetAlgo( algo ) ) # problem for cfgBrowser
333  getattr(process,"pfJets"+postfix).src = inputCollection
334  inputJetCorrLabel=jetCorrections
335  switchJetCollection(process,
336  input,
337  jetIdLabel = algo,
338  doJTA=True,
339  doBTagging=True,
340  jetCorrLabel=inputJetCorrLabel,
341  #doType1MET=False,
342  doType1MET=True,
343  genJetCollection = genJetCollection,
344  doJetID = True,
345  postfix = postfix
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, "patJets", postfix).embedCaloTowers = False
353  applyPostfix(process, "patJets", postfix).embedPFCandidates = True
354 
#-- Remove MC dependence ------------------------------------------------------
def applyPostfix
Helpers to perform some technically boring tasks like looking for all modules with a given parameter ...
Definition: helpers.py:6
def switchToPFJets
Definition: pfTools.py:312
perl if(1 lt scalar(@::datatypes))
Definition: edlooper.cc:31
def pfTools.switchToPFMET (   process,
  input = cms.InputTag('pfMET'),
  type1 = False,
  postfix = "" 
)

Definition at line 290 of file pfTools.py.

References helpers.applyPostfix(), if(), and python.multivaluedict.remove().

Referenced by usePF2PAT().

291 def switchToPFMET(process,input=cms.InputTag('pfMET'), type1=False, postfix=""):
292  print 'MET: using ', input
293  if( not type1 ):
294  oldMETSource = applyPostfix(process, "patMETs",postfix).metSource
295  applyPostfix(process, "patMETs",postfix).metSource = input
296  applyPostfix(process, "patMETs",postfix).addMuonCorrections = False
297  getattr(process, "patDefaultSequence"+postfix).remove(
298  applyPostfix(process, "patMETCorrections",postfix)
299  )
300  else:
301  # type1 corrected MET
302  # name of coreccted MET hardcoded in PAT and meaningless
303  print 'Apply type1 corrections for MET'
304  applyPostfix(process, "metJESCorAK5CaloJet",postfix).inputUncorMetLabel = input.getModuleLabel()
305  applyPostfix(process, "metJESCorAK5CaloJet",postfix).metType = 'PFMET'
306  applyPostfix(process, "metJESCorAK5CaloJet",postfix).jetPTthreshold = 1.0
307  applyPostfix(process, "patMETs",postfix).metSource = "metJESCorAK5CaloJet"+postfix
308  applyPostfix(process, "patMETs",postfix).addMuonCorrections = False
309  getattr(process, "patDefaultSequence"+postfix).remove(
310  applyPostfix(process, "metJESCorAK5CaloJetMuons",postfix)
311  )
def switchToPFMET
Definition: pfTools.py:290
def applyPostfix
Helpers to perform some technically boring tasks like looking for all modules with a given parameter ...
Definition: helpers.py:6
perl if(1 lt scalar(@::datatypes))
Definition: edlooper.cc:31
def pfTools.tauTypeInPF2PAT (   process,
  tauType = 'shrinkingConePFTau',
  postfix = "" 
)

Definition at line 254 of file pfTools.py.

References helpers.applyPostfix().

255 def tauTypeInPF2PAT(process,tauType='shrinkingConePFTau', postfix = ""):
256  process.load("CommonTools.ParticleFlow.pfTaus_cff")
257  applyPostfix(process, "pfTaus",postfix).src = cms.InputTag(tauType+'Producer'+postfix)
258 
def tauTypeInPF2PAT
Definition: pfTools.py:254
def applyPostfix
Helpers to perform some technically boring tasks like looking for all modules with a given parameter ...
Definition: helpers.py:6
def pfTools.usePF2PAT (   process,
  runPF2PAT = True,
  jetAlgo = 'AK5',
  runOnMC = True,
  postfix = "",
  jetCorrections = ('AK5PFchs', ['L1FastJet',
  L2Relative,
  L3Absolute 
)
Switch PAT to use PF2PAT instead of AOD sources. if 'runPF2PAT' is true, we'll also add PF2PAT in front of the PAT sequence

Definition at line 361 of file pfTools.py.

References adaptPFElectrons(), adaptPFMuons(), adaptPFTaus(), addPFCandidates(), helpers.applyPostfix(), helpers.cloneProcessingSnippet(), helpers.removeIfInSequence(), removeMCMatchingPF2PAT(), python.rootplot.root2matplotlib.replace(), switchToPFJets(), and switchToPFMET().

362 def usePF2PAT(process, runPF2PAT=True, jetAlgo='AK5', runOnMC=True, postfix = "", jetCorrections=('AK5PFchs', ['L1FastJet','L2Relative','L3Absolute']) ):
363  # PLEASE DO NOT CLOBBER THIS FUNCTION WITH CODE SPECIFIC TO A GIVEN PHYSICS OBJECT.
364  # CREATE ADDITIONAL FUNCTIONS IF NEEDED.
365 
366  """Switch PAT to use PF2PAT instead of AOD sources. if 'runPF2PAT' is true, we'll also add PF2PAT in front of the PAT sequence"""
367 
368  # -------- CORE ---------------
369  if runPF2PAT:
370  process.load("CommonTools.ParticleFlow.PF2PAT_cff")
371  #add Pf2PAT *before* cloning so that overlapping modules are cloned too
372  #process.patDefaultSequence.replace( process.patCandidates, process.PF2PAT+process.patCandidates)
373  process.patPF2PATSequence = cms.Sequence( process.PF2PAT + process.patDefaultSequence)
374  else:
375  process.patPF2PATSequence = cms.Sequence( process.patDefaultSequence )
376 
377  if not postfix == "":
378  from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet
379  cloneProcessingSnippet(process, process.patPF2PATSequence, postfix)
380  #delete everything pat PF2PAT modules! if you want to test the postfixing for completeness
381  #from PhysicsTools.PatAlgos.tools.helpers import listModules,listSequences
382  #for module in listModules(process.patDefaultSequence):
383  # if not module.label() is None: process.__delattr__(module.label())
384  #for sequence in listSequences(process.patDefaultSequence):
385  # if not sequence.label() is None: process.__delattr__(sequence.label())
386  #del process.patDefaultSequence
387 
388  removeCleaning(process, postfix=postfix)
389 
390  # -------- OBJECTS ------------
391  # Muons
392  adaptPFMuons(process,
393  applyPostfix(process,"patMuons",postfix),
394  postfix)
395 
396  # Electrons
397  adaptPFElectrons(process,
398  applyPostfix(process,"patElectrons",postfix),
399  postfix)
400 
401  # Photons
402  print "Temporarily switching off photons completely"
403 
404  removeSpecificPATObjects(process,['Photons'],False,postfix)
405  removeIfInSequence(process, "patPhotonIsolation", "patDefaultSequence", postfix)
406 
407  # Jets
408  if runOnMC :
409  switchToPFJets( process, cms.InputTag('pfNoTau'+postfix), jetAlgo, postfix=postfix,
410  jetCorrections=jetCorrections )
411  applyPostfix(process,"patDefaultSequence",postfix).replace(
412  applyPostfix(process,"patJetGenJetMatch",postfix),
413  getattr(process,"genForPF2PATSequence") *
414  applyPostfix(process,"patJetGenJetMatch",postfix)
415  )
416  else :
417  if not 'L2L3Residual' in jetCorrections[1]:
418  print '#################################################'
419  print 'WARNING! Not using L2L3Residual but this is data.'
420  print 'If this is okay with you, disregard this message.'
421  print '#################################################'
422  switchToPFJets( process, cms.InputTag('pfNoTau'+postfix), jetAlgo, postfix=postfix,
423  jetCorrections=jetCorrections )
424 
425  # Taus
426  adaptPFTaus( process, tauType='shrinkingConePFTau', postfix=postfix )
427  #adaptPFTaus( process, tauType='fixedConePFTau', postfix=postfix )
428  #adaptPFTaus( process, tauType='hpsPFTau', postfix=postfix )
429 
430  # MET
431  switchToPFMET(process, cms.InputTag('pfMET'+postfix), postfix=postfix)
432 
433  # Unmasked PFCandidates
434  addPFCandidates(process,cms.InputTag('pfNoJet'+postfix),patLabel='PFParticles'+postfix,cut="",postfix=postfix)
435 
436  if runOnMC:
437  process.load("CommonTools.ParticleFlow.genForPF2PAT_cff")
438  getattr(process, "patDefaultSequence"+postfix).replace(
439  applyPostfix(process,"patCandidates",postfix),
440  process.genForPF2PATSequence+applyPostfix(process,"patCandidates",postfix)
441  )
442  else:
443  removeMCMatchingPF2PAT( process, postfix )
444 
445  print "Done: PF2PAT interfaced to PAT, postfix=", postfix
def switchToPFMET
Definition: pfTools.py:290
def adaptPFTaus
Definition: pfTools.py:228
def adaptPFMuons
Definition: pfTools.py:32
def cloneProcessingSnippet
Definition: helpers.py:257
def removeMCMatchingPF2PAT
Definition: pfTools.py:355
def applyPostfix
Helpers to perform some technically boring tasks like looking for all modules with a given parameter ...
Definition: helpers.py:6
def usePF2PAT
Definition: pfTools.py:361
def addPFCandidates
Definition: pfTools.py:259
def adaptPFElectrons
Definition: pfTools.py:60
def switchToPFJets
Definition: pfTools.py:312
def removeIfInSequence
Definition: helpers.py:20
def pfTools.warningIsolation ( )

Definition at line 29 of file pfTools.py.

Referenced by adaptPFElectrons(), and adaptPFMuons().

29 
30 def warningIsolation():
31  print "WARNING: particle based isolation must be studied"
def warningIsolation
Definition: pfTools.py:29