CMS 3D CMS Logo

Classes | Functions
ntuplePrintersDiff Namespace Reference

Classes

class  _DiffResult
 
class  _IndentPrinter
 
class  _RecHitPrinter
 
class  _TrackAssociation
 
class  _TrackingParticleMatchPrinter
 
class  _TracksByHitsMatcher
 
class  SeedPrinter
 
class  TrackingParticlePrinter
 
class  TrackPrinter
 

Functions

def _areSameTracks (trk1, trk2)
 
def _associateTracksByTrackingParticlesAndHits (lst1, lst2)
 
def _commonHits (trk1, trk2)
 
def _difflist (list1, list2)
 
def _formatHitDiffForTwiki (diffHits, prefix)
 
def _hitPatternSummary (hits)
 
def _makediff (list1, list2, equalPrefix=" ")
 
def _mapdiff (func, obj1, obj2)
 
def _matchTracksByHits (reftrk, trklist)
 
def diffTrackListsFromSameTrackingParticle (trackPrinter, lst1, lst2, lst1extra=[], lst2extra=[], diffByHitsOnly=False)
 
def diffTrackListsGeneric (trackPrinter, lst1, lst2, ignoreAdditionalLst2=False)
 

Function Documentation

def ntuplePrintersDiff._areSameTracks (   trk1,
  trk2 
)
private

Definition at line 177 of file ntuplePrintersDiff.py.

References _commonHits().

Referenced by diffTrackListsFromSameTrackingParticle(), and diffTrackListsGeneric().

177 def _areSameTracks(trk1, trk2):
178  ncommon = _commonHits(trk1, trk2)
179 
180  # if tracks have same hits, consider their reco as identical
181  if not (ncommon == trk1.nValid() and ncommon == trk2.nValid()):
182  return False
183 
184  # although if there is any change in their iterations, mark them different
185  if not (trk1.algoMask() == trk2.algoMask() and trk1.algo() == trk2.algo() and trk1.originalAlgo() == trk2.originalAlgo()):
186  return False
187 
188  # if reco is the same, check if they are matched to the
189  # same TPs (in case the track-TP matching is modified
190  # between ntuples)
191  if trk1.nMatchedTrackingParticles() != trk2.nMatchedTrackingParticles():
192  return False
193 
194  for tpInfo1, tpInfo2 in itertools.izip(trk1.matchedTrackingParticleInfos(), trk2.matchedTrackingParticleInfos()):
195  if tpInfo1.trackingParticle().index() != tpInfo2.trackingParticle().index():
196  return False
197 
198  return True
199 
def _areSameTracks(trk1, trk2)
def _commonHits(trk1, trk2)
def ntuplePrintersDiff._associateTracksByTrackingParticlesAndHits (   lst1,
  lst2 
)
private

Definition at line 370 of file ntuplePrintersDiff.py.

References list(), and harvestTrackValidationPlots.str.

Referenced by diffTrackListsGeneric().

371  trks1 = list(lst1)
372  trks2 = list(lst2)
373 
374  trks1Matcher = _TracksByHitsMatcher(trks1)
375  trks2Matcher = _TracksByHitsMatcher(trks2)
376 
377  # Used to have exactly the same Track objects for the same index
378  trks1Dict = {t.index(): t for t in trks1}
379  trks2Dict = {t.index(): t for t in trks2}
380 
381  # Bit of a hack...
382  tps1 = None
383  tps2 = None
384  if len(trks1) > 0:
385  tps1 = TrackingParticles(trks1[0]._tree)
386  if len(trks2) > 0:
387  tps2 = TrackingParticles(trks2[0]._tree)
388 
389  trkAssoc1 = {}
390  trkAssoc2 = {}
391 
392  def _getOrCreateAssoc(trk, d, **kwargs):
393  if trk.index() in d:
394  a = d[trk.index()]
395  else:
396  a = _TrackAssociation()
397  d[trk.index()] = a
398  a.extend(**kwargs)
399  return a
400 
401  while len(trks1) > 0:
402  trk1 = trks1.pop(0)
403  assoc1 = _getOrCreateAssoc(trk1, trkAssoc1, trks1=[trk1])
404 
405  # First associate via TP
406  if trk1.nMatchedTrackingParticles() > 0 and tps2:
407  matched = False
408 
409  for tpInfo1 in trk1.matchedTrackingParticleInfos():
410  tp1 = tpInfo1.trackingParticle()
411 
412  # Find possible duplicates within trks1
413  for trkInfo1 in tp1.matchedTrackInfos():
414  t1 = trkInfo1.track()
415  t1Index = t1.index()
416  if t1Index != trk1.index():
417  if t1Index in trks1Dict:
418  assoc1.extend(trks1=[t1]) # trk1 -> t1
419  _getOrCreateAssoc(t1, trkAssoc1, trks1=[t1, trk1]) # t1 -> trk1
420  #print "trk1 %d <-> t1 %d (TP)" % (trk1.index(), t1.index())
421  trks1.remove(trks1Dict[t1Index])
422  else:
423  #print "trk1 %d -> t1 %d (TP, not in list)" % (trk1.index(), t1.index())
424  assoc1.extend(trks1OutsideList=[t1]) # trk1 -> t1, if t1 is not in trks1
425 
426  # Then look for the same tp in trks2
427  tp2 = tps2[tp1.index()]
428  for trkInfo2 in tp2.matchedTrackInfos():
429  matched = True
430  t2 = trkInfo2.track()
431  t2Index = t2.index()
432  if t2Index in trks2Dict:
433  assoc1.extend(trks2=[t2]) # trk1 -> t2
434  _getOrCreateAssoc(t2, trkAssoc2, trks1=[trk1], trks2=[t2]) # t2 -> trk1
435  #print "trk1 %d <-> t2 %d (TP)" % (trk1.index(), t2.index())
436  try:
437  trks2.remove(trks2Dict[t2Index]) # can fail if t2 has already been matched via hits
438  except ValueError:
439  pass
440  else:
441  #print "trk1 %d -> t2 %d (TP, not in list)" % (trk1.index(), t2.index())
442  assoc1.extend(trks2OutsideList=[t2]) # trk1 -> t2, if t2 is not in trks2
443 
444  if matched:
445  continue
446 
447  # If no matching tracks in trks2 via TrackingParticles, then
448  # proceed finding the best match via hits
449  (matchedTrk2, ncommon) = trks2Matcher.match(trk1)
450  if matchedTrk2 is not None and ncommon >= 3:
451  assoc1.extend(trks2=[matchedTrk2])
452  assoc2 = _getOrCreateAssoc(matchedTrk2, trkAssoc2, trks1=[trk1], trks2=[matchedTrk2])
453  #print "trk1 %d <-> t2 %d (hits)" % (trk1.index(), matchedTrk2.index())
454  try:
455  trks2.remove(matchedTrk2) # can fail if matchedTrk2 has already been matched via TP
456  except ValueError:
457  pass
458 
459  (matchedTrk1, ncommon1) = trks1Matcher.match(matchedTrk2)
460  # if matchedTrk1 has TP, the link from matchedTrk1 -> matchedTrk2 will be created later
461  if (matchedTrk1.nMatchedTrackingParticles() == 0 or not tps2) and matchedTrk1.index() != trk1.index():
462  assoc2.extend(trks1=[matchedTrk1])
463  _getOrCreateAssoc(matchedTrk1, trkAssoc1, trks1=[matchedTrk1], trks2=[matchedTrk2])
464  #print "trk1 %d <-> t2 %d (hits, via t2)" % (matchedTrk1.index(), matchedTrk2.index())
465 
466  # no match
467 
468  # remaining tracks in trks2
469  for trk2 in trks2:
470  assoc2 = _getOrCreateAssoc(trk2, trkAssoc2, trks2=[trk2])
471  # collect duplicates
472  if trk2.nMatchedTrackingParticles() > 0:
473  for tpInfo2 in trk2.matchedTrackingParticleInfos():
474  tp2 = tpInfo2.trackingParticle()
475  for trkInfo2 in tp2.matchedTrackInfos():
476  t2 = trkInfo2.track()
477  t2Index = t2.index()
478  if t2Index in trks2Dict:
479  assoc2.extend(trks2=[t2])
480  #print "trk2 %d -> t2 %d (TP)" % (trk2.index(), t2.index())
481  else:
482  assoc2.extend(trks2OutsideList=[t2])
483  #print "trk2 %d -> t2 %d (TP, not in list)" % (trk2.index(), t2.index())
484 
485  # merge results
486  # any good way to avoid copy-past?
487  for ind, assoc in trkAssoc1.iteritems():
488  for t1 in assoc.trks1():
489  a = trkAssoc1[t1.index()]
490  assoc.merge(a)
491  a.merge(assoc)
492  for t2 in assoc.trks2():
493  a = trkAssoc2[t2.index()]
494  assoc.merge(a)
495  a.merge(assoc)
496  for ind, assoc in trkAssoc2.iteritems():
497  for t2 in assoc.trks2():
498  a = trkAssoc2[t2.index()]
499  assoc.merge(a)
500  a.merge(assoc)
501  for t1 in assoc.trks1():
502  a = trkAssoc1[t1.index()]
503  assoc.merge(a)
504  a.merge(assoc)
505 
506  for ind, assoc in itertools.chain(trkAssoc1.iteritems(), trkAssoc2.iteritems()):
507  #if ind in [437, 1101]:
508  # print "----"
509  # print ind, [t.index() for t in assoc.trks1()], [t.index() for t in assoc.trks2()]
510  for t1 in assoc.trks1():
511  a = trkAssoc1[t1.index()]
512  assoc.merge(a)
513  a.merge(assoc)
514 
515  #if ind in [437, 1101]:
516  # print ind, [t.index() for t in assoc.trks1()], [t.index() for t in assoc.trks2()]
517 
518  for t2 in assoc.trks2():
519  a = trkAssoc2[t2.index()]
520  assoc.merge(a)
521  a.merge(assoc)
522  #if ind in [437, 1101]:
523  # print ind, [t.index() for t in assoc.trks1()], [t.index() for t in assoc.trks2()]
524  # print "####"
525 
526  # collapse to a single collection of associations
527  allAssocs = []
528  while len(trkAssoc1) > 0:
529  (t1Index, assoc) = trkAssoc1.popitem()
530 
531  #if t1Index == 1299:
532  # print t1Index, [t.index() for t in assoc.trks2()]
533  for t1 in assoc.trks1():
534  if t1.index() == t1Index: continue
535  trkAssoc1.pop(t1.index())
536  for t2 in assoc.trks2():
537  trkAssoc2.pop(t2.index())
538  allAssocs.append(assoc)
539  while len(trkAssoc2) > 0:
540  (t2Index, assoc) = trkAssoc2.popitem()
541  if len(assoc.trks1()) > 0:
542  raise Exception("len(assoc.trks1()) %d != 0 !!! %s for t2 %d" % (len(assoc.trks1()), str([t.index() for t in assoc.trks1()]), t2Index))
543  for t2 in assoc.trks2():
544  if t2.index() == t2Index: continue
545  trkAssoc2.pop(t2.index())
546  allAssocs.append(assoc)
547 
548  return allAssocs
549 
def _associateTracksByTrackingParticlesAndHits(lst1, lst2)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
def ntuplePrintersDiff._commonHits (   trk1,
  trk2 
)
private
Returns the number of common hits in trk1 and trk2. Matching is
done via the hit type and index, so effectively the matching is
done by clusters. Invalid hits are ignored.

Definition at line 13 of file ntuplePrintersDiff.py.

Referenced by _areSameTracks(), and diffTrackListsGeneric().

13 def _commonHits(trk1, trk2):
14  """Returns the number of common hits in trk1 and trk2. Matching is
15  done via the hit type and index, so effectively the matching is
16  done by clusters. Invalid hits are ignored.
17 
18  """
19  hits1 = set()
20  for hit in trk1.hits():
21  if not hit.isValidHit(): continue
22  hits1.add( (type(hit), hit.index()) )
23 
24  ncommon = 0
25  for hit in trk2.hits():
26  if not hit.isValidHit(): continue
27  if (type(hit), hit.index()) in hits1:
28  ncommon += 1
29 
30  return ncommon
31 
def _commonHits(trk1, trk2)
def ntuplePrintersDiff._difflist (   list1,
  list2 
)
private

Definition at line 158 of file ntuplePrintersDiff.py.

References list().

Referenced by _makediff().

158 def _difflist(list1, list2):
159  diff = difflib.unified_diff(list1, list2, lineterm="", n=len(list1))
160  for item in diff:
161  if item[:2] == "@@":
162  break
163  return list(diff)
164 
def _difflist(list1, list2)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
def ntuplePrintersDiff._formatHitDiffForTwiki (   diffHits,
  prefix 
)
private

Definition at line 618 of file ntuplePrintersDiff.py.

References join().

Referenced by ntuplePrintersDiff.SeedPrinter.diff(), and ntuplePrintersDiff.TrackPrinter.diff().

618 def _formatHitDiffForTwiki(diffHits, prefix):
619  line_re = re.compile("(?P<sign>[ \-+])\s+(?P<det>[a-zA-Z]+)(?P<lay>\d+)\D*?(\((?P<missing>missing|inactive)\))?\s+\d+")
620 
621  summary = []
622  prevdet = ""
623  prevsign = " "
624  diffLines = diffHits.lines()
625 
626  # skip anything before the first line with "hits"
627  for line in diffLines:
628  if "hits" in line:
629  break
630 
631  header = True
632  for line in diffLines:
633  # skip multiple occurrances of "hits" line, but only until
634  # first line without "hits" is encountered
635  if header:
636  if "hits" in line:
637  continue
638  else:
639  header = False
640 
641  m = line_re.search(line)
642  if not m:
643  break
644  raise Exception("regex not found from line %s" % line.rstrip())
645  sign = m.group("sign")
646  det = m.group("det")
647  lay = m.group("lay")
648 
649  if det != prevdet:
650  if prevsign != " ":
651  summary.append("%ENDCOLOR%")
652  prevsign = " "
653  summary.extend([" ", det])
654  prevdet = det
655 
656  if sign != prevsign:
657  if prevsign != " ":
658  summary.append("%ENDCOLOR%")
659  if sign == "-":
660  summary.append("%RED%")
661  elif sign == "+":
662  summary.append("%GREEN%")
663  prevsign = sign
664 
665  #print sign, det, lay
666  #if len(summary) > 0:
667  # print " ", summary[-1]
668 
669  #if det != prevdet:
670  # if prevsign != " ":
671  # #if len(summary) > 0:
672  # # if
673  # summary.append("%ENDCOLOR")
674  # summary.extend([" ", det])
675  # if prevsign == "-":
676  # summary.append("%RED%")
677  # elif prevsign == "+":
678  # summary.append("%GREEN%")
679  # prevdet = det
680  summary.append(lay)
681  if m.group("missing"):
682  if m.group("missing") == "missing":
683  summary.append("(m)")
684  elif m.group("missing") == "inactive":
685  summary.append("(i)")
686 
687  if prevsign != " ":
688  summary.append("%ENDCOLOR%")
689  # prune "changed" missing/inactive hits
690  i = 2
691  while i < len(summary)-5:
692  if summary[i] == "(i)" or summary[i] == "(m)":
693  if summary[i-2] == "%RED%" and summary[i+1] == "%ENDCOLOR%" and summary[i+2] == "%GREEN%" and summary[i+3] == summary[i-1] and summary[i+4] == summary[i] and summary[i+5] == "%ENDCOLOR%":
694  summary[i-2:i+6] = [summary[i-1], summary[i]]
695  i += 1
696 
697  line = " "+"".join(summary)
698  return ["?"+prefix+line]
699 
700 # Common detailed printout helpers
def _formatHitDiffForTwiki(diffHits, prefix)
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def ntuplePrintersDiff._hitPatternSummary (   hits)
private

Definition at line 701 of file ntuplePrintersDiff.py.

References harvestTrackValidationPlots.str.

Referenced by ntuplePrintersDiff.SeedPrinter.printHits(), ntuplePrintersDiff.TrackPrinter.printHits(), and ntuplePrintersDiff.TrackingParticlePrinter.printHits().

702  summary = ""
703 
704  prevdet = 0
705  for hit in hits:
706  det = hit.subdet()
707  lay = hit.layer()
708 
709  if det != prevdet:
710  summary += " "+SubDet.toString(det)
711  prevdet = det
712 
713  summary += str(lay)
714  if isinstance(hit, InvalidHit):
715  summary += "(%s)"%InvalidHit.Type.toString(hit.type())[0]
716 
717  return summary
718 
def ntuplePrintersDiff._makediff (   list1,
  list2,
  equalPrefix = " " 
)
private

Definition at line 165 of file ntuplePrintersDiff.py.

References _difflist().

Referenced by _mapdiff(), ntuplePrintersDiff.SeedPrinter.diff(), ntuplePrintersDiff.TrackPrinter.diff(), ntuplePrintersDiff.TrackingParticlePrinter.diffMatchedSeeds(), ntuplePrintersDiff.TrackingParticlePrinter.diffMatchedTracks(), and diffTrackListsFromSameTrackingParticle().

165 def _makediff(list1, list2, equalPrefix=" "):
166  diff = _difflist(list1, list2)
167  if len(diff) == 0:
168  return _DiffResult([equalPrefix+s for s in list1], hasDifference=False)
169  else:
170  return _DiffResult(diff, hasDifference=True)
171 
def _makediff(list1, list2, equalPrefix=" ")
def _difflist(list1, list2)
def ntuplePrintersDiff._mapdiff (   func,
  obj1,
  obj2 
)
private

Definition at line 172 of file ntuplePrintersDiff.py.

References _makediff(), and RecoEcal_EventContent_cff.func.

Referenced by ntuplePrintersDiff.SeedPrinter.diff(), ntuplePrintersDiff.TrackPrinter.diff(), ntuplePrintersDiff.TrackingParticlePrinter.diff(), and diffTrackListsFromSameTrackingParticle().

172 def _mapdiff(func, obj1, obj2):
173  lst1 = func(obj1) if obj1 is not None else []
174  lst2 = func(obj2) if obj2 is not None else []
175  return _makediff(lst1, lst2)
176 
def _mapdiff(func, obj1, obj2)
def _makediff(list1, list2, equalPrefix=" ")
def ntuplePrintersDiff._matchTracksByHits (   reftrk,
  trklist 
)
private

Definition at line 32 of file ntuplePrintersDiff.py.

Referenced by ntuplePrintersDiff.TrackingParticlePrinter.diffMatchedSeeds(), and diffTrackListsFromSameTrackingParticle().

32 def _matchTracksByHits(reftrk, trklist):
33  if len(trklist) == 0:
34  return (None, 0)
35 
36  hits1 = set()
37  for hit in reftrk.hits():
38  if not hit.isValidHit(): continue
39  hits1.add( (type(hit), hit.index()) )
40 
41  best = (None, 0)
42  for trk in trklist:
43  ncommon = 0
44  for hit in trk.hits():
45  if not hit.isValidHit(): continue
46  if (type(hit), hit.index()) in hits1:
47  ncommon += 1
48  if ncommon > best[1]:
49  best = (trk, ncommon)
50 
51  return best
52 
def _matchTracksByHits(reftrk, trklist)
def ntuplePrintersDiff.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.

Definition at line 200 of file ntuplePrintersDiff.py.

References _areSameTracks(), _makediff(), _mapdiff(), _matchTracksByHits(), list(), and GetRecoTauVFromDQM_MC_cff.next.

Referenced by ntuplePrintersDiff.TrackingParticlePrinter.diffMatchedTracks(), and diffTrackListsGeneric().

200 def diffTrackListsFromSameTrackingParticle(trackPrinter, lst1, lst2, lst1extra=[], lst2extra=[], diffByHitsOnly=False):
201  """lst1 and lst2 are the main lists to make the diff from.
202 
203  lst1extra and lst2extra are optional to provide suplementary
204  tracks. Use case: lst1 and lst2 are subset of full tracks,
205  lst1extra and lst2extra contain tracks matched to the same
206  TrackingParticle but are outside of the selection of lst1/lst2.
207  """
208 
209  diff = _DiffResult()
210 
211  _trks1extra = list(lst1extra)
212  _trks2extra = list(lst2extra)
213 
214  trks1 = list(lst1)+_trks1extra
215  trks2 = list(lst2)+_trks2extra # make copy because it is modified
216 
217  trks1extra = set([t.index() for t in _trks1extra])
218  trks2extra = set([t.index() for t in _trks2extra])
219 
220  trks1Empty = (len(trks1) == 0)
221  trks2Empty = (len(trks2) == 0)
222 
223  if trks1Empty and trks2Empty:
224  return diff
225 
226  # make sure all tracks really come from a single TP
227  # just to simplify the work loop, generalization can be considered later
228  commonTP = None
229  def _findCommonTP(_lst, _commonTP, _name):
230  for trk in _lst:
231  if trk.nMatchedTrackingParticles() != 1:
232  raise Exception("Track %d from %s is matched to %d TPs. This is not supported by this function yet." % (trk.index(), _name, trk.nMatchedTrackingParticles()))
233  if _commonTP is None:
234  _commonTP = next(trk.matchedTrackingParticleInfos()).trackingParticle()
235  else:
236  tp = next(trk.matchedTrackingParticleInfos()).trackingParticle()
237  if tp.index() != _commonTP.index():
238  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()))
239  return _commonTP
240  commonTP = _findCommonTP(trks1, commonTP, "lst1")
241  commonTP = _findCommonTP(trks2, commonTP, "lst2")
242 
243  # Need some tracks from trks1 and trks2 to print the TrackingParticle information
244  someTrk1 = trks1[0] if not trks1Empty else None
245  someTrk2 = trks2[0] if not trks2Empty else None
246 
247  for trk1 in trks1:
248  (matchedTrk2, ncommon) = _matchTracksByHits(trk1, trks2)
249 
250  # no more tracks in tp2
251  if matchedTrk2 is None:
252  if trk1.index() in trks1extra:
253  raise Exception("Track %d was found in trks1extra but matchedTrk2 is None, this should not happen" % trk1.index())
254  diff.extend(_makediff(trackPrinter.printTrack(trk1), []))
255  else: # diff trk1 to best-matching track from trks2
256  someTrk2 = matchedTrk2
257  trks2.remove(matchedTrk2)
258  tmp = trackPrinter.diff(trk1, matchedTrk2, diffTrackingParticles=False)
259  if diffByHitsOnly and _areSameTracks(trk1, matchedTrk2):
260  tmp.setDifference(False)
261  tmp.highlight(plus=(matchedTrk2.index() in trks2extra), minus=(trk1.index() in trks1extra))
262  diff.extend(tmp)
263 
264  for trk2 in trks2: # remaining tracks in trks2
265  if trk2.index() in trks2extra:
266  raise Exception("Track %d was found in trks2extra, but without matching track in trks1, this should not happen" % trk2.index())
267  diff.extend(_makediff([], trackPrinter.printTrack(trk2)))
268 
269  # finally add information of the trackingParticle
270  # easiest is to pass a track matched to the TP
271  tmp = _mapdiff(trackPrinter.printMatchedTrackingParticles, someTrk1, someTrk2)
272  tmp.setDifference(False) # we know the TP is the same, even if the "track match" information will differ
273  def _makere(lst):
274  r = []
275  for i in lst: r.extend([re.compile("Tracks:.*%d:"%i), re.compile("matched to tracks.*%d"%i)])
276  return r
277  plusre = _makere(trks2extra)
278  minusre = _makere(trks1extra)
279  tmp.highlightLines(plusre, minusre)
280  diff.extend(tmp)
281 
282  return diff
283 
def _mapdiff(func, obj1, obj2)
def _areSameTracks(trk1, trk2)
def _makediff(list1, list2, equalPrefix=" ")
def diffTrackListsFromSameTrackingParticle(trackPrinter, lst1, lst2, lst1extra=[], lst2extra=[], diffByHitsOnly=False)
def _matchTracksByHits(reftrk, trklist)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
def ntuplePrintersDiff.diffTrackListsGeneric (   trackPrinter,
  lst1,
  lst2,
  ignoreAdditionalLst2 = False 
)

Definition at line 550 of file ntuplePrintersDiff.py.

References _areSameTracks(), _associateTracksByTrackingParticlesAndHits(), _commonHits(), diffTrackListsFromSameTrackingParticle(), list(), GetRecoTauVFromDQM_MC_cff.next, and alignCSCRings.r.

550 def diffTrackListsGeneric(trackPrinter, lst1, lst2, ignoreAdditionalLst2=False):
551  associations = _associateTracksByTrackingParticlesAndHits(lst1, lst2)
552 
553  # sort in eta
554  associations.sort(key=methodcaller("minEta"))
555 
556  diff = _DiffResult()
557  for assoc in associations:
558  if assoc.hasCommonTrackingParticle():
559  if len(assoc.trks1()) == 0 and ignoreAdditionalLst2:
560  continue
561 
562  tmp = diffTrackListsFromSameTrackingParticle(trackPrinter, assoc.trks1(), assoc.trks2(), lst1extra=assoc.trks1OutsideList(), lst2extra=assoc.trks2OutsideList(), diffByHitsOnly=True)
563  if tmp.hasDifference():
564  diff.extend(tmp)
565  diff.extend([" "])
566  elif len(assoc.trks1()) == 1 and len(assoc.trks2()) == 1:
567  trk1 = assoc.trks1()[0]
568  trk2 = assoc.trks2()[0]
569 
570  if not _areSameTracks(trk1, trk2):
571  diff.extend(trackPrinter.diff(trk1, trk2))
572  diff.extend([" "])
573  elif len(assoc.trks2()) == 0:
574  for t in assoc.trks1():
575  diff.extend(trackPrinter.diff(t, None))
576  diff.extend([" "])
577  elif len(assoc.trks1()) == 0:
578  if ignoreAdditionalLst2:
579  continue
580  for t in assoc.trks1():
581  diff.extend(trackPrinter.diff(None, t))
582  diff.extend([" "])
583  else:
584  # needs to be rather generic, let's start by sorting by the innermost hit
585  trks1 = list(assoc.trks1())
586  trks2 = list(assoc.trks2())
587  trks1.sort(key=lambda t: next(t.hits()).r())
588  trks2.sort(key=lambda t: next(t.hits()).r())
589 
590  # then calculate number of shared hits for each pair
591  ncommon = []
592  for i1, t1 in enumerate(trks1):
593  for i2, t2 in enumerate(trks2):
594  ncommon.append( (i1, i2, _commonHits(t1, t2)) )
595 
596  # sort that by number of common hits, descending order
597  ncommon.sort(key=itemgetter(2), reverse=True)
598 
599  # then make the diffs starting from the pair with largest number of common hits
600  pairs = [None]*len(trks1)
601  usedT2 = [False]*len(trks2)
602  for i1, i2, ncom in ncommon:
603  if pairs[i1] is None:
604  pairs[i1] = i2
605  usedT2[i2] = True
606 
607  for i1, i2 in enumerate(pairs):
608  t1 = trks1[i1]
609  t2 = trks2[i2]
610  diff.extend(trackPrinter.diff(t1, t2))
611  for i2, used in enumerate(usedT2):
612  if not used:
613  diff.extend(trackPrinter.diff(None, trks2[i2]))
614  diff.extend([" "])
615 
616  return diff
617 
def _areSameTracks(trk1, trk2)
def diffTrackListsFromSameTrackingParticle(trackPrinter, lst1, lst2, lst1extra=[], lst2extra=[], diffByHitsOnly=False)
def _commonHits(trk1, trk2)
def diffTrackListsGeneric(trackPrinter, lst1, lst2, ignoreAdditionalLst2=False)
def _associateTracksByTrackingParticlesAndHits(lst1, lst2)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run