CMS 3D CMS Logo

Functions
pfIsolation Namespace Reference

Functions

def _getattrGenerator (process, postfix)
 
def _loadPFBRECO (process)
 
def setupPFElectronIso (process, electronCollection, newpostfix='PFIso', postfix='', runPF2PAT=False)
 
def setupPFIso (process, leptonCollection, particleName, newpostfix='PFIso', postfix='', runPF2PAT=False)
 
def setupPFIsoPhoton (process, photonCollection, particleName, newpostfix='PFIso')
 
def setupPFMuonIso (process, muonCollection, postfix='PFIso')
 
def setupPFPhotonIso (process, photonCollection, postfix='PFIso')
 

Function Documentation

◆ _getattrGenerator()

def pfIsolation._getattrGenerator (   process,
  postfix 
)
private
A function generator to simplify the getattr syntax

Definition at line 6 of file pfIsolation.py.

6 def _getattrGenerator( process, postfix ):
7  '''A function generator to simplify the getattr syntax'''
8  def fun(name):
9  return getattr(process, name+postfix)
10  return fun
11 
12 

Referenced by setupPFIso(), and setupPFIsoPhoton().

◆ _loadPFBRECO()

def pfIsolation._loadPFBRECO (   process)
private
The particle-flow based reconstruction sequence should be loaded once in the process.
Not optimal, should load it only if it is not detected (hasattr)

Definition at line 15 of file pfIsolation.py.

15 def _loadPFBRECO(process):
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")
22 
23 

Referenced by setupPFIso(), and setupPFIsoPhoton().

◆ setupPFElectronIso()

def pfIsolation.setupPFElectronIso (   process,
  electronCollection,
  newpostfix = 'PFIso',
  postfix = '',
  runPF2PAT = False 
)
Set up particle-based isolation for the electrons in electronCollection.

Calls setupPFIso.

Definition at line 121 of file pfIsolation.py.

121 def setupPFElectronIso(process, electronCollection, newpostfix='PFIso', postfix='', runPF2PAT = False ):
122  '''Set up particle-based isolation for the electrons in electronCollection.
123 
124  Calls setupPFIso.
125  '''
126  # print 'WARNING!!! the vetoes are the ones defined for the PF e-s (no veto...).'
127  # print 'Vetoes should be applied in the endcaps when doing particle-based isolation on gsfElectrons.'
128  # print 'Need a volunteer to implement that.'
129  return setupPFIso( process, electronCollection, 'Electron', newpostfix, postfix, runPF2PAT)
130 
131 

References setupPFIso().

◆ setupPFIso()

def pfIsolation.setupPFIso (   process,
  leptonCollection,
  particleName,
  newpostfix = 'PFIso',
  postfix = '',
  runPF2PAT = False 
)
Generic function to setup particle-based isolation for a given lepton collection.
Returns the isolation sequence.
You are responsible for adding it to your path.

leptonCollection could e.g. be "gsfElectrons" or "muons"
particleName must be either "Electron" or "Muon".
newpostfix can be specified to define several particle-flow isolation sequences

Definition at line 24 of file pfIsolation.py.

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.
28 
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
32  '''
33  lepshort = None
34  if particleName=='Electron':
35  lepshort='el'
36  elif particleName=='Muon':
37  lepshort='mu'
38  else:
39  raise ValueError('particleName should be equal to "Electron" or "Muon"')
40 
41  if runPF2PAT != True :
42  _loadPFBRECO(process)
43 
44  # ADD VETOES IN ENDCAPS!
45  fullpostfix = postfix+newpostfix
46  ga = _getattrGenerator( process, postfix )
47  ganew = _getattrGenerator( process, fullpostfix )
48 
49  leptonSeq = cms.Sequence(
50  ga('pf{lepton}IsolationSequence'.format(lepton=particleName))
51  )
52  setattr( process, 'std{lepton}Sequence{postfix}'.format(lepton=particleName,
53  postfix=postfix), leptonSeq)
54 
55  leptonSource = leptonCollection
56  cloneProcessingSnippet(process,
57  ga('std{lepton}Sequence'.format(lepton=particleName)),
58  newpostfix)
59 
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
65 
66  return ganew('std{lepton}Sequence'.format(lepton=particleName))
67 

References _getattrGenerator(), _loadPFBRECO(), and helpers.cloneProcessingSnippet().

Referenced by setupPFElectronIso(), and setupPFMuonIso().

◆ setupPFIsoPhoton()

def pfIsolation.setupPFIsoPhoton (   process,
  photonCollection,
  particleName,
  newpostfix = 'PFIso' 
)
Generic function to setup particle-based isolation for a given lepton collection.
Returns the isolation sequence.
You are responsible for adding it to your path.

leptonCollection could e.g. be "gsfElectrons" or "muons"
particleName must be either "Electron" or "Muon".
newpostfix can be specified to define several particle-flow isolation sequences

Definition at line 68 of file pfIsolation.py.

68 def setupPFIsoPhoton(process, photonCollection, particleName, newpostfix='PFIso'):
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.
72 
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
76  '''
77  phoshort = None
78  if particleName=='Photon':
79  phoshort='ph'
80  else:
81  raise ValueError('particleName should be equal to "Photon"')
82 
83  _loadPFBRECO(process)
84 
85  postfix = ''
86  # ADD VETOES IN ENDCAPS!
87  fullpostfix = postfix+newpostfix
88  #fullpostfix = ''
89  ga = _getattrGenerator( process, postfix )
90  ganew = _getattrGenerator( process, fullpostfix )
91 
92  photonSeq = cms.Sequence(
93  ga('pf{photon}IsolationSequence'.format(photon=particleName))
94  )
95  setattr( process, 'std{photon}Sequence{postfix}'.format(photon=particleName,
96  postfix=postfix), photonSeq)
97 
98  photonSource = photonCollection
99  cloneProcessingSnippet(process,
100  ga('std{photon}Sequence'.format(photon=particleName)),
101  newpostfix)
102 
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
108 
109  return ganew('std{photon}Sequence'.format(photon=particleName))
110 
111 

References _getattrGenerator(), _loadPFBRECO(), and helpers.cloneProcessingSnippet().

Referenced by setupPFPhotonIso().

◆ setupPFMuonIso()

def pfIsolation.setupPFMuonIso (   process,
  muonCollection,
  postfix = 'PFIso' 
)
Set up particle-based isolation for the muons in muonCollection.

Calls setupPFIso.

Definition at line 112 of file pfIsolation.py.

112 def setupPFMuonIso(process, muonCollection, postfix='PFIso' ):
113  '''Set up particle-based isolation for the muons in muonCollection.
114 
115  Calls setupPFIso.
116  '''
117  return setupPFIso( process, muonCollection, 'Muon', postfix)
118 
119 
120 

References setupPFIso().

◆ setupPFPhotonIso()

def pfIsolation.setupPFPhotonIso (   process,
  photonCollection,
  postfix = 'PFIso' 
)
Set up particle-based isolation for the electrons in electronCollection.

Calls setupPFIsoPhoton.

Definition at line 132 of file pfIsolation.py.

132 def setupPFPhotonIso(process, photonCollection, postfix='PFIso' ):
133  '''Set up particle-based isolation for the electrons in electronCollection.
134 
135  Calls setupPFIsoPhoton.
136  '''
137  # print 'WARNING!!! the vetoes are the ones defined for the PF e-s (no veto...).'
138  # print 'Please make sure that your file with vetoes is up to date'
139  return setupPFIsoPhoton( process, photonCollection, 'Photon', postfix)
140 

References setupPFIsoPhoton().

pfIsolation.setupPFMuonIso
def setupPFMuonIso(process, muonCollection, postfix='PFIso')
Definition: pfIsolation.py:112
pfIsolation._loadPFBRECO
def _loadPFBRECO(process)
Definition: pfIsolation.py:15
pfIsolation._getattrGenerator
def _getattrGenerator(process, postfix)
Definition: pfIsolation.py:6
pfIsolation.setupPFIso
def setupPFIso(process, leptonCollection, particleName, newpostfix='PFIso', postfix='', runPF2PAT=False)
Definition: pfIsolation.py:24
pfIsolation.setupPFIsoPhoton
def setupPFIsoPhoton(process, photonCollection, particleName, newpostfix='PFIso')
Definition: pfIsolation.py:68
pfIsolation.setupPFPhotonIso
def setupPFPhotonIso(process, photonCollection, postfix='PFIso')
Definition: pfIsolation.py:132
format
helpers.cloneProcessingSnippet
def cloneProcessingSnippet(process, sequence, postfix, removePostfix="", noClones=[], addToTask=False, verbose=False)
Definition: helpers.py:258
pfIsolation.setupPFElectronIso
def setupPFElectronIso(process, electronCollection, newpostfix='PFIso', postfix='', runPF2PAT=False)
Definition: pfIsolation.py:121