CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
ntuplePrintersDiff._TracksByHitsMatcher Class Reference
Inheritance diagram for ntuplePrintersDiff._TracksByHitsMatcher:

Public Member Functions

def __init__ (self, trklist)
 
def match (self, trk)
 

Private Attributes

 _hitsToTracks
 

Detailed Description

Definition at line 53 of file ntuplePrintersDiff.py.

Constructor & Destructor Documentation

def ntuplePrintersDiff._TracksByHitsMatcher.__init__ (   self,
  trklist 
)

Definition at line 54 of file ntuplePrintersDiff.py.

54  def __init__(self, trklist):
55  super(_TracksByHitsMatcher, self).__init__()
56  self._hitsToTracks = collections.defaultdict(list)
57  for trk in trklist:
58  for hit in trk.hits():
59  if hit.isValidHit():
60  self._hitsToTracks[ (type(hit), hit.index()) ].append(trk)
61 

Member Function Documentation

def ntuplePrintersDiff._TracksByHitsMatcher.match (   self,
  trk 
)

Definition at line 62 of file ntuplePrintersDiff.py.

References ntuplePrintersDiff._TracksByHitsMatcher._hitsToTracks.

62  def match(self, trk):
63  tracks = collections.defaultdict(int)
64 
65  for hit in trk.hits():
66  if not hit.isValidHit(): continue
67 
68  idx = (type(hit), hit.index())
69  try:
70  otherTracks = self._hitsToTracks[idx]
71  except KeyError:
72  continue
73 
74  for ot in otherTracks:
75  tracks[ot] += 1
76 
77  best = (None, 0)
78  for t, ncommon in tracks.iteritems():
79  if ncommon > best[1]:
80  best = (t, ncommon)
81  return best
82 
83 
84 # Common diff helpers, used in the printout helpers

Member Data Documentation

ntuplePrintersDiff._TracksByHitsMatcher._hitsToTracks
private

Definition at line 56 of file ntuplePrintersDiff.py.

Referenced by ntuplePrintersDiff._TracksByHitsMatcher.match().