parameters: (trackPrinter, lst1, lst2, lst1extra=[], lst2extra=[], diffByHitsOnly=False)
return_statement: return diff
docstring: lst1 and lst2 are the main lists to make the diff from.
  
      lst1extra and lst2extra are optional to provide suplementary
      tracks. Use case: lst1 and lst2 are subset of full tracks,
      lst1extra and lst2extra contain tracks matched to the same
      TrackingParticle but are outside of the selection of lst1/lst2.
docstring_summary: lst1 and lst2 are the main lists to make the diff from.
docstring_tokens: lst1 and lst2 are the main lists to make the diff from .
function: def diffTrackListsFromSameTrackingParticle(trackPrinter, lst1, lst2, lst1extra=[], lst2extra=[], diffByHitsOnly=False):
      """lst1 and lst2 are the main lists to make the diff from.
  
      lst1extra and lst2extra are optional to provide suplementary
      tracks. Use case: lst1 and lst2 are subset of full tracks,
      lst1extra and lst2extra contain tracks matched to the same
      TrackingParticle but are outside of the selection of lst1/lst2.
      """
  
      diff = _DiffResult()
  
      _trks1extra = list(lst1extra)
      _trks2extra = list(lst2extra)
  
      trks1 = list(lst1)+_trks1extra
      trks2 = list(lst2)+_trks2extra # make copy because it is modified
  
      trks1extra = set([t.index() for t in _trks1extra])
      trks2extra = set([t.index() for t in _trks2extra])
  
      trks1Empty = (len(trks1) == 0)
      trks2Empty = (len(trks2) == 0)
  
      if trks1Empty and trks2Empty:
          return diff
  
      # make sure all tracks really come from a single TP
      # just to simplify the work loop, generalization can be considered later
      commonTP = None
      def _findCommonTP(_lst, _commonTP, _name):
          for trk in _lst:
              if trk.nMatchedTrackingParticles() != 1:
                  raise Exception("Track %d from %s is matched to %d TPs. This is not supported by this function yet." % (trk.index(), _name, trk.nMatchedTrackingParticles()))
              if _commonTP is None:
                  _commonTP = next(trk.matchedTrackingParticleInfos()).trackingParticle()
              else:
                  tp = next(trk.matchedTrackingParticleInfos()).trackingParticle()
                  if tp.index() != _commonTP.index():
                      raise Exception("Track %d from %s is matched to TP %d, which differs from the TP %d of already processed tracks." % (trk.index(), _name, _commonTP.index(), tp.index()))
          return _commonTP
      commonTP = _findCommonTP(trks1, commonTP, "lst1")
      commonTP = _findCommonTP(trks2, commonTP, "lst2")
  
      # Need some tracks from trks1 and trks2 to print the TrackingParticle information
      someTrk1 = trks1[0] if not trks1Empty else None
      someTrk2 = trks2[0] if not trks2Empty else None
  
      for trk1 in trks1:
          (matchedTrk2, ncommon) = _matchTracksByHits(trk1, trks2)
  
          # no more tracks in tp2
          if matchedTrk2 is None:
              if trk1.index() in trks1extra:
                  raise Exception("Track %d was found in trks1extra but matchedTrk2 is None, this should not happen" % trk1.index())
              diff.extend(_makediff(trackPrinter.printTrack(trk1), []))
          else: # diff trk1 to best-matching track from trks2
              someTrk2 = matchedTrk2
              trks2.remove(matchedTrk2)
              tmp = trackPrinter.diff(trk1, matchedTrk2, diffTrackingParticles=False)
              if diffByHitsOnly and _areSameTracks(trk1, matchedTrk2):
                  tmp.setDifference(False)
              tmp.highlight(plus=(matchedTrk2.index() in trks2extra), minus=(trk1.index() in trks1extra))
              diff.extend(tmp)
  
      for trk2 in trks2: # remaining tracks in trks2
          if trk2.index() in trks2extra:
              raise Exception("Track %d was found in trks2extra, but without matching track in trks1, this should not happen" % trk2.index())
          diff.extend(_makediff([], trackPrinter.printTrack(trk2)))
  
      # finally add information of the trackingParticle
      # easiest is to pass a track matched to the TP
      tmp = _mapdiff(trackPrinter.printMatchedTrackingParticles, someTrk1, someTrk2)
      tmp.setDifference(False) # we know the TP is the same, even if the "track match" information will differ
      def _makere(lst):
          r = []
          for i in lst: r.extend([re.compile("Tracks:.*%d:"%i), re.compile("matched to tracks.*%d"%i)])
          return r
      plusre = _makere(trks2extra)
      minusre = _makere(trks1extra)
      tmp.highlightLines(plusre, minusre)
      diff.extend(tmp)
  
      return diff
function_tokens: def diffTrackListsFromSameTrackingParticle ( trackPrinter , lst1 , lst2 , lst1extra = [ ] , lst2extra = [ ] , diffByHitsOnly = False ) : diff = _DiffResult ( ) _trks1extra = list ( lst1extra ) _trks2extra = list ( lst2extra ) trks1 = list ( lst1 ) + _trks1extra trks2 = list ( lst2 ) + _trks2extra # make copy because it is modified trks1extra = set ( [ t . index ( ) for t in _trks1extra ] ) trks2extra = set ( [ t . index ( ) for t in _trks2extra ] ) trks1Empty = ( len ( trks1 ) == 0 ) trks2Empty = ( len ( trks2 ) == 0 ) if trks1Empty and trks2Empty : return diff # make sure all tracks really come from a single TP # just to simplify the work loop, generalization can be considered later commonTP = None def _findCommonTP ( _lst , _commonTP , _name ) : for trk in _lst : if trk . nMatchedTrackingParticles ( ) != 1 : raise Exception ( "Track %d from %s is matched to %d TPs. This is not supported by this function yet." % ( trk . index ( ) , _name , trk . nMatchedTrackingParticles ( ) ) ) if _commonTP is None : _commonTP = next ( trk . matchedTrackingParticleInfos ( ) ) . trackingParticle ( ) else : tp = next ( trk . matchedTrackingParticleInfos ( ) ) . trackingParticle ( ) if tp . index ( ) != _commonTP . index ( ) : raise Exception ( "Track %d from %s is matched to TP %d, which differs from the TP %d of already processed tracks." % ( trk . index ( ) , _name , _commonTP . index ( ) , tp . index ( ) ) ) return _commonTP commonTP = _findCommonTP ( trks1 , commonTP , "lst1" ) commonTP = _findCommonTP ( trks2 , commonTP , "lst2" ) # Need some tracks from trks1 and trks2 to print the TrackingParticle information someTrk1 = trks1 [ 0 ] if not trks1Empty else None someTrk2 = trks2 [ 0 ] if not trks2Empty else None for trk1 in trks1 : ( matchedTrk2 , ncommon ) = _matchTracksByHits ( trk1 , trks2 ) # no more tracks in tp2 if matchedTrk2 is None : if trk1 . index ( ) in trks1extra : raise Exception ( "Track %d was found in trks1extra but matchedTrk2 is None, this should not happen" % trk1 . index ( ) ) diff . extend ( _makediff ( trackPrinter . printTrack ( trk1 ) , [ ] ) ) else : # diff trk1 to best-matching track from trks2 someTrk2 = matchedTrk2 trks2 . remove ( matchedTrk2 ) tmp = trackPrinter . diff ( trk1 , matchedTrk2 , diffTrackingParticles = False ) if diffByHitsOnly and _areSameTracks ( trk1 , matchedTrk2 ) : tmp . setDifference ( False ) tmp . highlight ( plus = ( matchedTrk2 . index ( ) in trks2extra ) , minus = ( trk1 . index ( ) in trks1extra ) ) diff . extend ( tmp ) for trk2 in trks2 : # remaining tracks in trks2 if trk2 . index ( ) in trks2extra : raise Exception ( "Track %d was found in trks2extra, but without matching track in trks1, this should not happen" % trk2 . index ( ) ) diff . extend ( _makediff ( [ ] , trackPrinter . printTrack ( trk2 ) ) ) # finally add information of the trackingParticle # easiest is to pass a track matched to the TP tmp = _mapdiff ( trackPrinter . printMatchedTrackingParticles , someTrk1 , someTrk2 ) tmp . setDifference ( False ) # we know the TP is the same, even if the "track match" information will differ def _makere ( lst ) : r = [ ] for i in lst : r . extend ( [ re . compile ( "Tracks:.*%d:" % i ) , re . compile ( "matched to tracks.*%d" % i ) ] ) return r plusre = _makere ( trks2extra ) minusre = _makere ( trks1extra ) tmp . highlightLines ( plusre , minusre ) diff . extend ( tmp ) return diff