CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions
objects.JetAnalyzer Namespace Reference

Classes

class  JetAnalyzer
 

Functions

def cleanJetsAndLeptons
 
def cleanNearestJetOnly
 

Function Documentation

def objects.JetAnalyzer.cleanJetsAndLeptons (   jets,
  leptons,
  deltaR,
  arbitration 
)

Definition at line 23 of file JetAnalyzer.py.

References reco.deltaR2().

23 
24 def cleanJetsAndLeptons(jets,leptons,deltaR,arbitration):
25  dr2 = deltaR**2
26  goodjet = [ True for j in jets ]
27  goodlep = [ True for l in leptons ]
28  for il, l in enumerate(leptons):
29  ibest, d2m = -1, dr2
30  for i,j in enumerate(jets):
31  d2i = deltaR2(l.eta(),l.phi(), j.eta(),j.phi())
32  if d2i < dr2:
33  if arbitration(j,l) == j:
34  # if the two match, and we prefer the jet, then drop the lepton and be done
35  goodlep[il] = False
36  break
37  if d2i < d2m:
38  ibest, d2m = i, d2i
39  # this lepton has been killed by a jet, then we clean the jet that best matches it
40  if not goodlep[il]: continue
41  if ibest != -1: goodjet[ibest] = False
42  return ( [ j for (i ,j) in enumerate(jets) if goodjet[i ] == True ],
43  [ l for (il,l) in enumerate(leptons) if goodlep[il] == True ] )
44 
double deltaR2(const T1 &t1, const T2 &t2)
Definition: deltaR.h:36
def objects.JetAnalyzer.cleanNearestJetOnly (   jets,
  leptons,
  deltaR 
)

Definition at line 11 of file JetAnalyzer.py.

References reco.deltaR2().

11 
12 def cleanNearestJetOnly(jets,leptons,deltaR):
13  dr2 = deltaR**2
14  good = [ True for j in jets ]
15  for l in leptons:
16  ibest, d2m = -1, dr2
17  for i,j in enumerate(jets):
18  d2i = deltaR2(l.eta(),l.phi(), j.eta(),j.phi())
19  if d2i < d2m:
20  ibest, d2m = i, d2i
21  if ibest != -1: good[ibest] = False
22  return [ j for (i,j) in enumerate(jets) if good[i] == True ]
double deltaR2(const T1 &t1, const T2 &t2)
Definition: deltaR.h:36