3 import FWCore.ParameterSet.Config
as cms
7 '''A function generator to simplify the getattr syntax''' 9 return getattr(process, name+postfix)
13 _PFBRECO_loaded =
False 16 '''The particle-flow based reconstruction sequence should be loaded once in the process. 17 Not optimal, should load it only if it is not detected (hasattr)''' 18 global _PFBRECO_loaded
19 if _PFBRECO_loaded
is False:
20 _PFBRECO_loaded =
True 21 process.load(
"CommonTools.ParticleFlow.PFBRECO_cff")
24 def setupPFIso(process, leptonCollection, particleName, newpostfix='PFIso', postfix='', runPF2PAT = False):
25 '''Generic function to setup particle-based isolation for a given lepton collection. 26 Returns the isolation sequence. 27 You are responsible for adding it to your path. 29 leptonCollection could e.g. be "gsfElectrons" or "muons" 30 particleName must be either "Electron" or "Muon". 31 newpostfix can be specified to define several particle-flow isolation sequences 34 if particleName==
'Electron':
36 elif particleName==
'Muon':
39 raise ValueError(
'particleName should be equal to "Electron" or "Muon"')
41 if runPF2PAT !=
True :
45 fullpostfix = postfix+newpostfix
49 leptonSeq = cms.Sequence(
50 ga(
'pf{lepton}IsolationSequence'.
format(lepton=particleName))
52 setattr( process,
'std{lepton}Sequence{postfix}'.
format(lepton=particleName,
53 postfix=postfix), leptonSeq)
55 leptonSource = leptonCollection
57 ga(
'std{lepton}Sequence'.
format(lepton=particleName)),
60 ganew(
"{lepshort}PFIsoDepositCharged".
format(lepshort=lepshort) ).src = leptonSource
61 ganew(
"{lepshort}PFIsoDepositChargedAll".
format(lepshort=lepshort)).src = leptonSource
62 ganew(
"{lepshort}PFIsoDepositNeutral".
format(lepshort=lepshort)).src = leptonSource
63 ganew(
"{lepshort}PFIsoDepositGamma".
format(lepshort=lepshort)).src = leptonSource
64 ganew(
"{lepshort}PFIsoDepositPU".
format(lepshort=lepshort)).src = leptonSource
66 return ganew(
'std{lepton}Sequence'.
format(lepton=particleName))
69 '''Generic function to setup particle-based isolation for a given lepton collection. 70 Returns the isolation sequence. 71 You are responsible for adding it to your path. 73 leptonCollection could e.g. be "gsfElectrons" or "muons" 74 particleName must be either "Electron" or "Muon". 75 newpostfix can be specified to define several particle-flow isolation sequences 78 if particleName==
'Photon':
81 raise ValueError(
'particleName should be equal to "Photon"')
87 fullpostfix = postfix+newpostfix
92 photonSeq = cms.Sequence(
93 ga(
'pf{photon}IsolationSequence'.
format(photon=particleName))
95 setattr( process,
'std{photon}Sequence{postfix}'.
format(photon=particleName,
96 postfix=postfix), photonSeq)
98 photonSource = photonCollection
100 ga(
'std{photon}Sequence'.
format(photon=particleName)),
103 ganew(
"{phoshort}PFIsoDepositCharged".
format(phoshort=phoshort) ).src = photonSource
104 ganew(
"{phoshort}PFIsoDepositChargedAll".
format(phoshort=phoshort)).src = photonSource
105 ganew(
"{phoshort}PFIsoDepositNeutral".
format(phoshort=phoshort)).src = photonSource
106 ganew(
"{phoshort}PFIsoDepositGamma".
format(phoshort=phoshort)).src = photonSource
107 ganew(
"{phoshort}PFIsoDepositPU".
format(phoshort=phoshort)).src = photonSource
109 return ganew(
'std{photon}Sequence'.
format(photon=particleName))
113 '''Set up particle-based isolation for the muons in muonCollection. 117 return setupPFIso( process, muonCollection,
'Muon', postfix)
121 def setupPFElectronIso(process, electronCollection, newpostfix='PFIso', postfix='', runPF2PAT = False ):
122 '''Set up particle-based isolation for the electrons in electronCollection. 129 return setupPFIso( process, electronCollection,
'Electron', newpostfix, postfix, runPF2PAT)
133 '''Set up particle-based isolation for the electrons in electronCollection. 135 Calls setupPFIsoPhoton. def cloneProcessingSnippet(process, sequence, postfix, removePostfix="", noClones=[], addToTask=False)
def setupPFElectronIso(process, electronCollection, newpostfix='PFIso', postfix='', runPF2PAT=False)
def setupPFIsoPhoton(process, photonCollection, particleName, newpostfix='PFIso')
def _getattrGenerator(process, postfix)
def setupPFMuonIso(process, muonCollection, postfix='PFIso')
def setupPFIso(process, leptonCollection, particleName, newpostfix='PFIso', postfix='', runPF2PAT=False)
def setupPFPhotonIso(process, photonCollection, postfix='PFIso')
def _loadPFBRECO(process)