CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions | Variables
pfIsolation Namespace Reference

Functions

def _getattrGenerator
 
def _loadPFBRECO
 
def setupPFElectronIso
 
def setupPFIso
 
def setupPFIsoPhoton
 
def setupPFMuonIso
 
def setupPFPhotonIso
 

Variables

 _PFBRECO_loaded = False
 

Function Documentation

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

Definition at line 6 of file pfIsolation.py.

Referenced by setupPFIso(), and setupPFIsoPhoton().

6 
7 def _getattrGenerator( process, postfix ):
8  '''A function generator to simplify the getattr syntax'''
9  def fun(name):
10  return getattr(process, name+postfix)
11  return fun
12 
def _getattrGenerator
Definition: pfIsolation.py:6
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.

Referenced by setupPFIso(), and setupPFIsoPhoton().

15 
16 def _loadPFBRECO(process):
17  '''The particle-flow based reconstruction sequence should be loaded once in the process.
18  Not optimal, should load it only if it is not detected (hasattr)'''
19  global _PFBRECO_loaded
20  if _PFBRECO_loaded is False:
21  _PFBRECO_loaded = True
22  process.load("CommonTools.ParticleFlow.PFBRECO_cff")
23 
def _loadPFBRECO
Definition: pfIsolation.py:15
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.

References setupPFIso().

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

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

Referenced by setupPFElectronIso(), and setupPFMuonIso().

24 
25 def setupPFIso(process, leptonCollection, particleName, newpostfix='PFIso', postfix='', runPF2PAT = False):
26  '''Generic function to setup particle-based isolation for a given lepton collection.
27  Returns the isolation sequence.
28  You are responsible for adding it to your path.
29 
30  leptonCollection could e.g. be "gsfElectrons" or "muons"
31  particleName must be either "Electron" or "Muon".
32  newpostfix can be specified to define several particle-flow isolation sequences
33  '''
34  lepshort = None
35  if particleName=='Electron':
36  lepshort='el'
37  elif particleName=='Muon':
38  lepshort='mu'
39  else:
40  raise ValueError('particleName should be equal to "Electron" or "Muon"')
41 
42  if runPF2PAT != True :
43  _loadPFBRECO(process)
44 
45  # ADD VETOES IN ENDCAPS!
46  fullpostfix = postfix+newpostfix
47  ga = _getattrGenerator( process, postfix )
48  ganew = _getattrGenerator( process, fullpostfix )
49 
50  leptonSeq = cms.Sequence(
51  ga('pf{lepton}IsolationSequence'.format(lepton=particleName))
52  )
53  setattr( process, 'std{lepton}Sequence{postfix}'.format(lepton=particleName,
54  postfix=postfix), leptonSeq)
55 
56  leptonSource = leptonCollection
57  cloneProcessingSnippet(process,
58  ga('std{lepton}Sequence'.format(lepton=particleName)),
59  newpostfix)
60 
61  ganew("{lepshort}PFIsoDepositCharged".format(lepshort=lepshort) ).src = leptonSource
62  ganew("{lepshort}PFIsoDepositChargedAll".format(lepshort=lepshort)).src = leptonSource
63  ganew("{lepshort}PFIsoDepositNeutral".format(lepshort=lepshort)).src = leptonSource
64  ganew("{lepshort}PFIsoDepositGamma".format(lepshort=lepshort)).src = leptonSource
65  ganew("{lepshort}PFIsoDepositPU".format(lepshort=lepshort)).src = leptonSource
66 
67  return ganew('std{lepton}Sequence'.format(lepton=particleName))
def cloneProcessingSnippet
Definition: helpers.py:257
def _loadPFBRECO
Definition: pfIsolation.py:15
def _getattrGenerator
Definition: pfIsolation.py:6
def setupPFIso
Definition: pfIsolation.py:24
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.

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

Referenced by setupPFPhotonIso().

68 
69 def setupPFIsoPhoton(process, photonCollection, particleName, newpostfix='PFIso'):
70  '''Generic function to setup particle-based isolation for a given lepton collection.
71  Returns the isolation sequence.
72  You are responsible for adding it to your path.
73 
74  leptonCollection could e.g. be "gsfElectrons" or "muons"
75  particleName must be either "Electron" or "Muon".
76  newpostfix can be specified to define several particle-flow isolation sequences
77  '''
78  phoshort = None
79  if particleName=='Photon':
80  phoshort='ph'
81  else:
82  raise ValueError('particleName should be equal to "Photon"')
83 
84  _loadPFBRECO(process)
85 
86  postfix = ''
87  # ADD VETOES IN ENDCAPS!
88  fullpostfix = postfix+newpostfix
89  #fullpostfix = ''
90  ga = _getattrGenerator( process, postfix )
91  ganew = _getattrGenerator( process, fullpostfix )
92 
93  photonSeq = cms.Sequence(
94  ga('pf{photon}IsolationSequence'.format(photon=particleName))
95  )
96  setattr( process, 'std{photon}Sequence{postfix}'.format(photon=particleName,
97  postfix=postfix), photonSeq)
98 
99  photonSource = photonCollection
100  cloneProcessingSnippet(process,
101  ga('std{photon}Sequence'.format(photon=particleName)),
102  newpostfix)
103 
104  ganew("{phoshort}PFIsoDepositCharged".format(phoshort=phoshort) ).src = photonSource
105  ganew("{phoshort}PFIsoDepositChargedAll".format(phoshort=phoshort)).src = photonSource
106  ganew("{phoshort}PFIsoDepositNeutral".format(phoshort=phoshort)).src = photonSource
107  ganew("{phoshort}PFIsoDepositGamma".format(phoshort=phoshort)).src = photonSource
108  ganew("{phoshort}PFIsoDepositPU".format(phoshort=phoshort)).src = photonSource
109 
110  return ganew('std{photon}Sequence'.format(photon=particleName))
111 
def cloneProcessingSnippet
Definition: helpers.py:257
def _loadPFBRECO
Definition: pfIsolation.py:15
def setupPFIsoPhoton
Definition: pfIsolation.py:68
def _getattrGenerator
Definition: pfIsolation.py:6
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.

References setupPFIso().

113 def setupPFMuonIso(process, muonCollection, postfix='PFIso' ):
114  '''Set up particle-based isolation for the muons in muonCollection.
115 
116  Calls setupPFIso.
117  '''
118  return setupPFIso( process, muonCollection, 'Muon', postfix)
119 
120 
def setupPFMuonIso
Definition: pfIsolation.py:112
def setupPFIso
Definition: pfIsolation.py:24
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.

References setupPFIsoPhoton().

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

Variable Documentation

pfIsolation._PFBRECO_loaded = False

Definition at line 13 of file pfIsolation.py.