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 54 of file ntuplePrintersDiff.py.

Constructor & Destructor Documentation

def ntuplePrintersDiff._TracksByHitsMatcher.__init__ (   self,
  trklist 
)

Definition at line 55 of file ntuplePrintersDiff.py.

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

Member Function Documentation

def ntuplePrintersDiff._TracksByHitsMatcher.match (   self,
  trk 
)

Definition at line 63 of file ntuplePrintersDiff.py.

References ntuplePrintersDiff._TracksByHitsMatcher._hitsToTracks.

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

Member Data Documentation

ntuplePrintersDiff._TracksByHitsMatcher._hitsToTracks
private

Definition at line 57 of file ntuplePrintersDiff.py.

Referenced by ntuplePrintersDiff._TracksByHitsMatcher.match().