CMS 3D CMS Logo

customizeDeltaBetaWeights_cfi.py
Go to the documentation of this file.
1 '''Customization functions for cmsDriver to get neutral weighted isolation'''
2 import FWCore.ParameterSet.Config as cms
3 
5 
6 
7 def customize(process):
8  '''run neutral particle weighting sequence and use it for isolation of electrons, muons and photons
9 
10  syntax: --customise RecoParticleFlow/Configuration/customizeDeltaBetaWeights_cfi.customize
11  It will add 2 new sequences to the RECO sequence that will produce pfWeightedPhotons and
12  pfWeightedNeutralHadrons. They are produced from pfAllPhotons and pfAllNeutralHadrons by rescaling
13  pt of each particle by a weight that reflects the probability that it is from pileup. The formula is
14  w = sumNPU/(sumNPU+sumPU). The sums are running over all charged particles from the PV (NPU) or from the PU.
15  The function used in the sum is ln(pt(i)/deltaR(i,j)) where i is neutral particle that is being weighted and j
16  is the charged particle (either PU or NPU) that is used to access 'pileupility' of a particle.
17 
18  Neutral isolation of electrons, muons and photons is calculated using the weighed collection.
19  '''
20 
21  if hasattr(process,'pfParticleSelectionSequence'):
22  process.load("CommonTools.ParticleFlow.deltaBetaWeights_cff")
23  process.pfParticleSelectionSequence += process.pfDeltaBetaWeightingSequence
24 
25  if hasattr(process,'elPFIsoDepositNeutral'):
26  process.elPFIsoDepositNeutral=isoDepositReplace('pfElectronTranslator:pf','pfWeightedNeutralHadrons')
27 
28  if hasattr(process,'elPFIsoDepositGamma'):
29  process.elPFIsoDepositGamma=isoDepositReplace('pfElectronTranslator:pf','pfWeightedPhotons')
30 
31  if hasattr(process,'gedElPFIsoDepositNeutral'):
32  process.gedElPFIsoDepositNeutral=isoDepositReplace('gedGsfElectronsTmp','pfWeightedNeutralHadrons')
33 
34  if hasattr(process,'gedElPFIsoDepositGamma'):
35  process.gedElPFIsoDepositGamma=isoDepositReplace('gedGsfElectronsTmp','pfWeightedPhotons')
36 
37  if hasattr(process,'muPFIsoDepositNeutral'):
38  process.muPFIsoDepositNeutral=isoDepositReplace('muons1stStep','pfWeightedNeutralHadrons')
39 
40  if hasattr(process,'muPFIsoDepositGamma'):
41  process.muPFIsoDepositGamma=isoDepositReplace('muons1stStep','pfWeightedPhotons')
42 
43  if hasattr(process,'phPFIsoDepositNeutral'):
44  process.phPFIsoDepositNeutral=isoDepositReplace('pfSelectedPhotons','pfWeightedNeutralHadrons')
45 
46  if hasattr(process,'phPFIsoDepositGamma'):
47  process.phPFIsoDepositGamma.ExtractorPSet.inputCandView = cms.InputTag("pfWeightedPhotons")
48 
49  return process
50 
51 
53  '''run neutral particle weighting sequence and use it for isolation of electrons only.
54 
55  syntax: --customise RecoParticleFlow/Configuration/customizeDeltaBetaWeights_cfi.customizeElectronsOnly
56  Same as customize, only that the weighted collections are used only for electron neutral isolation,
57  while muons and photons are left untouched.
58  '''
59 
60  if hasattr(process,'pfParticleSelectionSequence'):
61  process.load("CommonTools.ParticleFlow.deltaBetaWeights_cff")
62  process.pfParticleSelectionSequence += process.pfDeltaBetaWeightingSequence
63 
64  if hasattr(process,'elPFIsoDepositNeutral'):
65  process.elPFIsoDepositNeutral=isoDepositReplace('pfElectronTranslator:pf','pfWeightedNeutralHadrons')
66 
67  if hasattr(process,'elPFIsoDepositGamma'):
68  process.elPFIsoDepositGamma=isoDepositReplace('pfElectronTranslator:pf','pfWeightedPhotons')
69 
70  if hasattr(process,'gedElPFIsoDepositNeutral'):
71  process.gedElPFIsoDepositNeutral=isoDepositReplace('gedGsfElectronsTmp','pfWeightedNeutralHadrons')
72 
73  if hasattr(process,'gedElPFIsoDepositGamma'):
74  process.gedElPFIsoDepositGamma=isoDepositReplace('gedGsfElectronsTmp','pfWeightedPhotons')
75 
76  return process
77 
78 
79 def customizeMuonsOnly(process):
80  '''run neutral particle weighting sequence and use it for isolation of muonss only.
81 
82  syntax: --customise RecoParticleFlow/Configuration/customizeDeltaBetaWeights_cfi.customizeMuonsOnly
83  Same as customize, only that the weighted collections are used only for muon neutral isolation,
84  while electronss and photons are left untouched.
85  '''
86 
87  if hasattr(process,'pfParticleSelectionSequence'):
88  process.load("CommonTools.ParticleFlow.deltaBetaWeights_cff")
89  process.pfParticleSelectionSequence += process.pfDeltaBetaWeightingSequence
90 
91  if hasattr(process,'muPFIsoDepositNeutral'):
92  process.muPFIsoDepositNeutral=isoDepositReplace('muons1stStep','pfWeightedNeutralHadrons')
93 
94  if hasattr(process,'muPFIsoDepositGamma'):
95  process.muPFIsoDepositGamma=isoDepositReplace('muons1stStep','pfWeightedPhotons')
96 
97  return process
98 
99 
100 def customizePhotonsOnly(process):
101  '''run neutral particle weighting sequence and use it for isolation of muons only.
102 
103  syntax: --customise RecoParticleFlow/Configuration/customizeDeltaBetaWeights_cfi.customizePhotonsOnly
104  Same as customize, only that the weighted collections are used only for photon neutral isolation,
105  while electronss and muons are left untouched.
106  '''
107 
108  if hasattr(process,'pfParticleSelectionSequence'):
109  process.load("CommonTools.ParticleFlow.deltaBetaWeights_cff")
110  process.pfParticleSelectionSequence += process.pfDeltaBetaWeightingSequence
111 
112  if hasattr(process,'phPFIsoDepositNeutral'):
113  process.phPFIsoDepositNeutral=isoDepositReplace('pfSelectedPhotons','pfWeightedNeutralHadrons')
114 
115  if hasattr(process,'phPFIsoDepositGamma'):
116  process.phPFIsoDepositGamma.ExtractorPSet.inputCandView = cms.InputTag("pfWeightedPhotons")
117 
118 
119  return process
def isoDepositReplace(toBeIsolated, isolating)
Definition: tools_cfi.py:6