test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
embeddingCustomizePF.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 
3 import FWCore.ParameterSet.Config as cms
4 import os
5 
6 def customise(process, inputProcess):
7 
8  process.particleFlowORG = process.particleFlow.clone()
9 
10  # Since CMSSW 4_4 the particleFlow reco works a bit differently. The step is
11  # twofold, first particleFlowTmp is created and then the final particleFlow
12  # collection. What we do in this case is that we merge the final ParticleFlow
13  # collection. For the muon reconstruction, we also merge particleFlowTmp in
14  # order to get PF-based isolation right.
15  if hasattr(process, 'particleFlowTmp'):
16  process.particleFlowTmpMixed = cms.EDProducer('PFCandidateMixer',
17  col1 = cms.untracked.InputTag("cleanedParticleFlow"),
18  col2 = cms.untracked.InputTag("particleFlowTmp", ""),
19  trackCol = cms.untracked.InputTag("generalTracks"),
20 
21  # Don't produce value maps:
22  muons = cms.untracked.InputTag(""),
23  gsfElectrons = cms.untracked.InputTag("")
24  )
25  process.muons.PFCandidates = cms.InputTag("particleFlowTmpMixed")
26 
27  for p in process.paths:
28  pth = getattr(process,p)
29  if "particleFlow" in pth.moduleNames():
30  pth.replace(process.particleFlow, process.particleFlowORG*process.particleFlow)
31  if "muons" in pth.moduleNames():
32  pth.replace(process.muons, process.particleFlowTmpMixed*process.muons)
33  else:
34  # CMSSW_4_2
35  if hasattr(process,"famosParticleFlowSequence"):
36  process.famosParticleFlowSequence.remove(process.pfPhotonTranslatorSequence)
37  process.famosParticleFlowSequence.remove(process.pfElectronTranslatorSequence)
38  process.famosParticleFlowSequence.remove(process.particleFlow)
39  process.famosParticleFlowSequence.__iadd__(process.particleFlowORG)
40  process.famosParticleFlowSequence.__iadd__(process.particleFlow)
41  process.famosParticleFlowSequence.__iadd__(process.pfElectronTranslatorSequence)
42  process.famosParticleFlowSequence.__iadd__(process.pfPhotonTranslatorSequence)
43  elif hasattr(process,"particleFlowReco"):
44  process.particleFlowReco.remove(process.pfPhotonTranslatorSequence)
45  process.particleFlowReco.remove(process.pfElectronTranslatorSequence)
46  process.particleFlowReco.remove(process.particleFlow)
47  process.particleFlowReco.__iadd__(process.particleFlowORG)
48  process.particleFlowReco.__iadd__(process.particleFlow)
49  process.particleFlowReco.__iadd__(process.pfElectronTranslatorSequence)
50  process.particleFlowReco.__iadd__(process.pfPhotonTranslatorSequence)
51  else :
52  raise "Cannot find particleFlow sequence"
53 
54  process.pfSelectedElectrons.src = cms.InputTag("particleFlowORG")
55  process.pfSelectedPhotons.src = cms.InputTag("particleFlowORG")
56 
57  process.particleFlow = cms.EDProducer('PFCandidateMixer',
58  col1 = cms.untracked.InputTag("cleanedParticleFlow"),
59  col2 = cms.untracked.InputTag("particleFlowORG", ""),
60  trackCol = cms.untracked.InputTag("generalTracks"),
61  muons = cms.untracked.InputTag("muons"),
62  gsfElectrons = cms.untracked.InputTag("gsfElectrons")
63  # TODO: photons ???
64  )
65 
66  return process