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

Constructor & Destructor Documentation

def ntuplePrintersDiff._TracksByHitsMatcher.__init__ (   self,
  trklist 
)

Definition at line 56 of file ntuplePrintersDiff.py.

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

Member Function Documentation

def ntuplePrintersDiff._TracksByHitsMatcher.match (   self,
  trk 
)

Definition at line 64 of file ntuplePrintersDiff.py.

References ntuplePrintersDiff._TracksByHitsMatcher._hitsToTracks.

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

Member Data Documentation

ntuplePrintersDiff._TracksByHitsMatcher._hitsToTracks
private

Definition at line 58 of file ntuplePrintersDiff.py.

Referenced by ntuplePrintersDiff._TracksByHitsMatcher.match().