File indexing completed on 2024-04-06 12:27:20
0001 '''Customization functions for cmsDriver to get neutral weighted isolation'''
0002 import FWCore.ParameterSet.Config as cms
0003
0004 from CommonTools.ParticleFlow.Isolation.tools_cfi import *
0005
0006
0007 def customize(process):
0008 '''run neutral particle weighting sequence and use it for isolation of electrons, muons and photons
0009
0010 syntax: --customise RecoParticleFlow/Configuration/customizeDeltaBetaWeights_cfi.customize
0011 It will add 2 new sequences to the RECO sequence that will produce pfWeightedPhotons and
0012 pfWeightedNeutralHadrons. They are produced from pfAllPhotons and pfAllNeutralHadrons by rescaling
0013 pt of each particle by a weight that reflects the probability that it is from pileup. The formula is
0014 w = sumNPU/(sumNPU+sumPU). The sums are running over all charged particles from the PV (NPU) or from the PU.
0015 The function used in the sum is ln(pt(i)/deltaR(i,j)) where i is neutral particle that is being weighted and j
0016 is the charged particle (either PU or NPU) that is used to access 'pileupility' of a particle.
0017
0018 Neutral isolation of electrons, muons and photons is calculated using the weighed collection.
0019 '''
0020
0021 if hasattr(process,'pfParticleSelectionSequence'):
0022 process.load("CommonTools.ParticleFlow.deltaBetaWeights_cff")
0023 process.pfParticleSelectionSequence += process.pfDeltaBetaWeightingSequence
0024
0025 if hasattr(process,'elPFIsoDepositNeutral'):
0026 process.elPFIsoDepositNeutral=isoDepositReplace('pfElectronTranslator:pf','pfWeightedNeutralHadrons')
0027
0028 if hasattr(process,'elPFIsoDepositGamma'):
0029 process.elPFIsoDepositGamma=isoDepositReplace('pfElectronTranslator:pf','pfWeightedPhotons')
0030
0031 if hasattr(process,'gedElPFIsoDepositNeutral'):
0032 process.gedElPFIsoDepositNeutral=isoDepositReplace('gedGsfElectronsTmp','pfWeightedNeutralHadrons')
0033
0034 if hasattr(process,'gedElPFIsoDepositGamma'):
0035 process.gedElPFIsoDepositGamma=isoDepositReplace('gedGsfElectronsTmp','pfWeightedPhotons')
0036
0037 if hasattr(process,'muPFIsoDepositNeutral'):
0038 process.muPFIsoDepositNeutral=isoDepositReplace('muons1stStep','pfWeightedNeutralHadrons')
0039
0040 if hasattr(process,'muPFIsoDepositGamma'):
0041 process.muPFIsoDepositGamma=isoDepositReplace('muons1stStep','pfWeightedPhotons')
0042
0043 if hasattr(process,'phPFIsoDepositNeutral'):
0044 process.phPFIsoDepositNeutral=isoDepositReplace('pfSelectedPhotons','pfWeightedNeutralHadrons')
0045
0046 if hasattr(process,'phPFIsoDepositGamma'):
0047 process.phPFIsoDepositGamma.ExtractorPSet.inputCandView = cms.InputTag("pfWeightedPhotons")
0048
0049 return process
0050
0051
0052 def customizeElectronsOnly(process):
0053 '''run neutral particle weighting sequence and use it for isolation of electrons only.
0054
0055 syntax: --customise RecoParticleFlow/Configuration/customizeDeltaBetaWeights_cfi.customizeElectronsOnly
0056 Same as customize, only that the weighted collections are used only for electron neutral isolation,
0057 while muons and photons are left untouched.
0058 '''
0059
0060 if hasattr(process,'pfParticleSelectionSequence'):
0061 process.load("CommonTools.ParticleFlow.deltaBetaWeights_cff")
0062 process.pfParticleSelectionSequence += process.pfDeltaBetaWeightingSequence
0063
0064 if hasattr(process,'elPFIsoDepositNeutral'):
0065 process.elPFIsoDepositNeutral=isoDepositReplace('pfElectronTranslator:pf','pfWeightedNeutralHadrons')
0066
0067 if hasattr(process,'elPFIsoDepositGamma'):
0068 process.elPFIsoDepositGamma=isoDepositReplace('pfElectronTranslator:pf','pfWeightedPhotons')
0069
0070 if hasattr(process,'gedElPFIsoDepositNeutral'):
0071 process.gedElPFIsoDepositNeutral=isoDepositReplace('gedGsfElectronsTmp','pfWeightedNeutralHadrons')
0072
0073 if hasattr(process,'gedElPFIsoDepositGamma'):
0074 process.gedElPFIsoDepositGamma=isoDepositReplace('gedGsfElectronsTmp','pfWeightedPhotons')
0075
0076 return process
0077
0078
0079 def customizeMuonsOnly(process):
0080 '''run neutral particle weighting sequence and use it for isolation of muonss only.
0081
0082 syntax: --customise RecoParticleFlow/Configuration/customizeDeltaBetaWeights_cfi.customizeMuonsOnly
0083 Same as customize, only that the weighted collections are used only for muon neutral isolation,
0084 while electronss and photons are left untouched.
0085 '''
0086
0087 if hasattr(process,'pfParticleSelectionSequence'):
0088 process.load("CommonTools.ParticleFlow.deltaBetaWeights_cff")
0089 process.pfParticleSelectionSequence += process.pfDeltaBetaWeightingSequence
0090
0091 if hasattr(process,'muPFIsoDepositNeutral'):
0092 process.muPFIsoDepositNeutral=isoDepositReplace('muons1stStep','pfWeightedNeutralHadrons')
0093
0094 if hasattr(process,'muPFIsoDepositGamma'):
0095 process.muPFIsoDepositGamma=isoDepositReplace('muons1stStep','pfWeightedPhotons')
0096
0097 return process
0098
0099
0100 def customizePhotonsOnly(process):
0101 '''run neutral particle weighting sequence and use it for isolation of muons only.
0102
0103 syntax: --customise RecoParticleFlow/Configuration/customizeDeltaBetaWeights_cfi.customizePhotonsOnly
0104 Same as customize, only that the weighted collections are used only for photon neutral isolation,
0105 while electronss and muons are left untouched.
0106 '''
0107
0108 if hasattr(process,'pfParticleSelectionSequence'):
0109 process.load("CommonTools.ParticleFlow.deltaBetaWeights_cff")
0110 process.pfParticleSelectionSequence += process.pfDeltaBetaWeightingSequence
0111
0112 if hasattr(process,'phPFIsoDepositNeutral'):
0113 process.phPFIsoDepositNeutral=isoDepositReplace('pfSelectedPhotons','pfWeightedNeutralHadrons')
0114
0115 if hasattr(process,'phPFIsoDepositGamma'):
0116 process.phPFIsoDepositGamma.ExtractorPSet.inputCandView = cms.InputTag("pfWeightedPhotons")
0117
0118
0119 return process