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

◆ __init__()

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

◆ match()

def ntuplePrintersDiff._TracksByHitsMatcher.match (   self,
  trk 
)

Definition at line 64 of file ntuplePrintersDiff.py.

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

References ntuplePrintersDiff._TracksByHitsMatcher._hitsToTracks.

Member Data Documentation

◆ _hitsToTracks

ntuplePrintersDiff._TracksByHitsMatcher._hitsToTracks
private

Definition at line 58 of file ntuplePrintersDiff.py.

Referenced by ntuplePrintersDiff._TracksByHitsMatcher.match().

mps_setup.append
append
Definition: mps_setup.py:85
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10