1 from builtins
import range
9 from operator
import itemgetter, methodcaller
16 """Returns the number of common hits in trk1 and trk2. Matching is 17 done via the hit type and index, so effectively the matching is 18 done by clusters. Invalid hits are ignored. 22 for hit
in trk1.hits():
23 if not hit.isValidHit():
continue 24 hits1.add( (type(hit), hit.index()) )
27 for hit
in trk2.hits():
28 if not hit.isValidHit():
continue 29 if (type(hit), hit.index())
in hits1:
39 for hit
in reftrk.hits():
40 if not hit.isValidHit():
continue 41 hits1.add( (type(hit), hit.index()) )
46 for hit
in trk.hits():
47 if not hit.isValidHit():
continue 48 if (type(hit), hit.index())
in hits1:
57 super(_TracksByHitsMatcher, self).
__init__()
60 for hit
in trk.hits():
65 tracks = collections.defaultdict(int)
67 for hit
in trk.hits():
68 if not hit.isValidHit():
continue 70 idx = (type(hit), hit.index())
76 for ot
in otherTracks:
80 for t, ncommon
in six.iteritems(tracks):
88 def __init__(self, diff=[], hasDifference=False):
100 if isinstance(diff, _DiffResult):
101 self._diff.append(diff)
102 if diff.hasDifference():
105 self._diff.extend(diff)
115 return line[0]+char+line[1:]
118 if not (plus
or minus):
121 for i, line
in enumerate(self.
_diff):
122 if isinstance(line, _DiffResult):
123 line.highlight(plus, minus)
128 if len(plusregexs) == 0
and len(minusregexs) == 0:
131 for i, line
in enumerate(self.
_diff):
132 if isinstance(line, _DiffResult):
133 raise Exception(
"highlightLines() is currently allowed only for text-only _DiffResult objects")
140 for m
in minusregexs:
147 for line
in self.
_diff:
148 if isinstance(line, _DiffResult):
149 for l
in line.lines():
155 return "\n".
join([s
for s
in (
str(item)
for item
in self.
_diff)
if s !=
""])
158 return len(self.
_diff)
161 diff = difflib.unified_diff(list1, list2, lineterm=
"", n=len(list1))
170 return _DiffResult([equalPrefix+s
for s
in list1], hasDifference=
False)
175 lst1 =
func(obj1)
if obj1
is not None else []
176 lst2 =
func(obj2)
if obj2
is not None else []
183 if not (ncommon == trk1.nValid()
and ncommon == trk2.nValid()):
187 if not (trk1.algoMask() == trk2.algoMask()
and trk1.algo() == trk2.algo()
and trk1.originalAlgo() == trk2.originalAlgo()):
193 if trk1.nMatchedTrackingParticles() != trk2.nMatchedTrackingParticles():
196 for tpInfo1, tpInfo2
in itertools.izip(trk1.matchedTrackingParticleInfos(), trk2.matchedTrackingParticleInfos()):
197 if tpInfo1.trackingParticle().
index() != tpInfo2.trackingParticle().
index():
203 """lst1 and lst2 are the main lists to make the diff from. 205 lst1extra and lst2extra are optional to provide suplementary 206 tracks. Use case: lst1 and lst2 are subset of full tracks, 207 lst1extra and lst2extra contain tracks matched to the same 208 TrackingParticle but are outside of the selection of lst1/lst2. 213 _trks1extra =
list(lst1extra)
214 _trks2extra =
list(lst2extra)
216 trks1 =
list(lst1)+_trks1extra
217 trks2 =
list(lst2)+_trks2extra
219 trks1extra = set([t.index()
for t
in _trks1extra])
220 trks2extra = set([t.index()
for t
in _trks2extra])
222 trks1Empty = (len(trks1) == 0)
223 trks2Empty = (len(trks2) == 0)
225 if trks1Empty
and trks2Empty:
231 def _findCommonTP(_lst, _commonTP, _name):
233 if trk.nMatchedTrackingParticles() != 1:
234 raise Exception(
"Track %d from %s is matched to %d TPs. This is not supported by this function yet." % (trk.index(), _name, trk.nMatchedTrackingParticles()))
235 if _commonTP
is None:
236 _commonTP =
next(trk.matchedTrackingParticleInfos()).trackingParticle()
238 tp =
next(trk.matchedTrackingParticleInfos()).trackingParticle()
239 if tp.index() != _commonTP.index():
240 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()))
242 commonTP = _findCommonTP(trks1, commonTP,
"lst1")
243 commonTP = _findCommonTP(trks2, commonTP,
"lst2")
246 someTrk1 = trks1[0]
if not trks1Empty
else None 247 someTrk2 = trks2[0]
if not trks2Empty
else None 253 if matchedTrk2
is None:
254 if trk1.index()
in trks1extra:
255 raise Exception(
"Track %d was found in trks1extra but matchedTrk2 is None, this should not happen" % trk1.index())
256 diff.extend(
_makediff(trackPrinter.printTrack(trk1), []))
258 someTrk2 = matchedTrk2
259 trks2.remove(matchedTrk2)
260 tmp = trackPrinter.diff(trk1, matchedTrk2, diffTrackingParticles=
False)
262 tmp.setDifference(
False)
263 tmp.highlight(plus=(matchedTrk2.index()
in trks2extra), minus=(trk1.index()
in trks1extra))
267 if trk2.index()
in trks2extra:
268 raise Exception(
"Track %d was found in trks2extra, but without matching track in trks1, this should not happen" % trk2.index())
269 diff.extend(
_makediff([], trackPrinter.printTrack(trk2)))
273 tmp =
_mapdiff(trackPrinter.printMatchedTrackingParticles, someTrk1, someTrk2)
274 tmp.setDifference(
False)
277 for i
in lst: r.extend([re.compile(
"Tracks:.*%d:"%i), re.compile(
"matched to tracks.*%d"%i)])
279 plusre = _makere(trks2extra)
280 minusre = _makere(trks1extra)
281 tmp.highlightLines(plusre, minusre)
288 super(_TrackAssociation, self).
__init__()
300 lst = getattr(self, name)
301 ind = getattr(self, name+
"Ind")
303 if not t.index()
in ind:
307 def extend(self, trks1=[], trks2=[], trks1OutsideList=[], trks2OutsideList=[]):
320 self.
_extend(trks,
"_trks1OutsideList")
323 self.
_extend(trks,
"_trks2OutsideList")
334 except StopIteration:
336 if first.nMatchedTrackingParticles() != 1:
339 tpIndex =
next(first.matchedTrackingParticleInfos()).trackingParticle().
index()
342 if t.nMatchedTrackingParticles() != 1:
344 if next(t.matchedTrackingParticleInfos()).trackingParticle().
index() != tpIndex:
356 _min =
lambda lst:
min([t.eta()
for t
in lst])
364 if len(self._trks2_outsideList) > 0:
366 raise Exception(
"This _TrackAssociation is empty, minEta() makes no sense")
369 s =
lambda l:
str([t.index()
for t
in l])
380 trks1Dict = {t.index(): t
for t
in trks1}
381 trks2Dict = {t.index(): t
for t
in trks2}
387 tps1 = TrackingParticles(trks1[0]._tree)
389 tps2 = TrackingParticles(trks2[0]._tree)
394 def _getOrCreateAssoc(trk, d, **kwargs):
403 while len(trks1) > 0:
405 assoc1 = _getOrCreateAssoc(trk1, trkAssoc1, trks1=[trk1])
408 if trk1.nMatchedTrackingParticles() > 0
and tps2:
411 for tpInfo1
in trk1.matchedTrackingParticleInfos():
412 tp1 = tpInfo1.trackingParticle()
415 for trkInfo1
in tp1.matchedTrackInfos():
416 t1 = trkInfo1.track()
418 if t1Index != trk1.index():
419 if t1Index
in trks1Dict:
420 assoc1.extend(trks1=[t1])
421 _getOrCreateAssoc(t1, trkAssoc1, trks1=[t1, trk1])
423 trks1.remove(trks1Dict[t1Index])
426 assoc1.extend(trks1OutsideList=[t1])
429 tp2 = tps2[tp1.index()]
430 for trkInfo2
in tp2.matchedTrackInfos():
432 t2 = trkInfo2.track()
434 if t2Index
in trks2Dict:
435 assoc1.extend(trks2=[t2])
436 _getOrCreateAssoc(t2, trkAssoc2, trks1=[trk1], trks2=[t2])
439 trks2.remove(trks2Dict[t2Index])
444 assoc1.extend(trks2OutsideList=[t2])
451 (matchedTrk2, ncommon) = trks2Matcher.match(trk1)
452 if matchedTrk2
is not None and ncommon >= 3:
453 assoc1.extend(trks2=[matchedTrk2])
454 assoc2 = _getOrCreateAssoc(matchedTrk2, trkAssoc2, trks1=[trk1], trks2=[matchedTrk2])
457 trks2.remove(matchedTrk2)
461 (matchedTrk1, ncommon1) = trks1Matcher.match(matchedTrk2)
463 if (matchedTrk1.nMatchedTrackingParticles() == 0
or not tps2)
and matchedTrk1.index() != trk1.index():
464 assoc2.extend(trks1=[matchedTrk1])
465 _getOrCreateAssoc(matchedTrk1, trkAssoc1, trks1=[matchedTrk1], trks2=[matchedTrk2])
472 assoc2 = _getOrCreateAssoc(trk2, trkAssoc2, trks2=[trk2])
474 if trk2.nMatchedTrackingParticles() > 0:
475 for tpInfo2
in trk2.matchedTrackingParticleInfos():
476 tp2 = tpInfo2.trackingParticle()
477 for trkInfo2
in tp2.matchedTrackInfos():
478 t2 = trkInfo2.track()
480 if t2Index
in trks2Dict:
481 assoc2.extend(trks2=[t2])
484 assoc2.extend(trks2OutsideList=[t2])
489 for ind, assoc
in six.iteritems(trkAssoc1):
490 for t1
in assoc.trks1():
491 a = trkAssoc1[t1.index()]
494 for t2
in assoc.trks2():
495 a = trkAssoc2[t2.index()]
498 for ind, assoc
in six.iteritems(trkAssoc2):
499 for t2
in assoc.trks2():
500 a = trkAssoc2[t2.index()]
503 for t1
in assoc.trks1():
504 a = trkAssoc1[t1.index()]
508 for ind, assoc
in itertools.chain(six.iteritems(trkAssoc1), six.iteritems(trkAssoc2)):
512 for t1
in assoc.trks1():
513 a = trkAssoc1[t1.index()]
520 for t2
in assoc.trks2():
521 a = trkAssoc2[t2.index()]
530 while len(trkAssoc1) > 0:
531 (t1Index, assoc) = trkAssoc1.popitem()
535 for t1
in assoc.trks1():
536 if t1.index() == t1Index:
continue 537 trkAssoc1.pop(t1.index())
538 for t2
in assoc.trks2():
539 trkAssoc2.pop(t2.index())
540 allAssocs.append(assoc)
541 while len(trkAssoc2) > 0:
542 (t2Index, assoc) = trkAssoc2.popitem()
543 if len(assoc.trks1()) > 0:
544 raise Exception(
"len(assoc.trks1()) %d != 0 !!! %s for t2 %d" % (len(assoc.trks1()),
str([t.index()
for t
in assoc.trks1()]), t2Index))
545 for t2
in assoc.trks2():
546 if t2.index() == t2Index:
continue 547 trkAssoc2.pop(t2.index())
548 allAssocs.append(assoc)
556 associations.sort(key=methodcaller(
"minEta"))
559 for assoc
in associations:
560 if assoc.hasCommonTrackingParticle():
561 if len(assoc.trks1()) == 0
and ignoreAdditionalLst2:
565 if tmp.hasDifference():
568 elif len(assoc.trks1()) == 1
and len(assoc.trks2()) == 1:
569 trk1 = assoc.trks1()[0]
570 trk2 = assoc.trks2()[0]
573 diff.extend(trackPrinter.diff(trk1, trk2))
575 elif len(assoc.trks2()) == 0:
576 for t
in assoc.trks1():
577 diff.extend(trackPrinter.diff(t,
None))
579 elif len(assoc.trks1()) == 0:
580 if ignoreAdditionalLst2:
582 for t
in assoc.trks1():
583 diff.extend(trackPrinter.diff(
None, t))
587 trks1 =
list(assoc.trks1())
588 trks2 =
list(assoc.trks2())
589 trks1.sort(key=
lambda t:
next(t.hits()).
r())
590 trks2.sort(key=
lambda t:
next(t.hits()).
r())
594 for i1, t1
in enumerate(trks1):
595 for i2, t2
in enumerate(trks2):
599 ncommon.sort(key=itemgetter(2), reverse=
True)
602 pairs = [
None]*len(trks1)
603 usedT2 = [
False]*len(trks2)
604 for i1, i2, ncom
in ncommon:
605 if pairs[i1]
is None:
609 for i1, i2
in enumerate(pairs):
612 diff.extend(trackPrinter.diff(t1, t2))
613 for i2, used
in enumerate(usedT2):
615 diff.extend(trackPrinter.diff(
None, trks2[i2]))
621 line_re = re.compile(
"(?P<sign>[ \-+])\s+(?P<det>[a-zA-Z]+)(?P<lay>\d+)\D*?(\((?P<missing>missing|inactive)\))?\s+\d+")
626 diffLines = diffHits.lines()
629 for line
in diffLines:
634 for line
in diffLines:
643 m = line_re.search(line)
646 raise Exception(
"regex not found from line %s" % line.rstrip())
647 sign = m.group(
"sign")
653 summary.append(
"%ENDCOLOR%")
655 summary.extend([
" ", det])
660 summary.append(
"%ENDCOLOR%")
662 summary.append(
"%RED%")
664 summary.append(
"%GREEN%")
683 if m.group(
"missing"):
684 if m.group(
"missing") ==
"missing":
685 summary.append(
"(m)")
686 elif m.group(
"missing") ==
"inactive":
687 summary.append(
"(i)")
690 summary.append(
"%ENDCOLOR%")
693 while i < len(summary)-5:
694 if summary[i] ==
"(i)" or summary[i] ==
"(m)":
695 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%":
696 summary[i-2:i+6] = [summary[i-1], summary[i]]
699 line =
" "+
"".
join(summary)
700 return [
"?"+prefix+line]
712 summary +=
" "+SubDet.toString(det)
716 if isinstance(hit, InvalidHit):
717 summary +=
"(%s)"%InvalidHit.Type.toString(hit.type())[0]
733 self._backup.append(self.
_prefix)
737 self._backup.append(self.
_prefix)
742 self.
_prefix = self._backup.pop()
746 super(_RecHitPrinter, self).
__init__(indent)
755 if hasattr(hit,
"matchedSimHitInfos"):
756 matched =
" from %s " % HitSimType.toString(hit.simType())
758 hasChargeFraction =
False 759 for shInfo
in hit.matchedSimHitInfos():
760 m =
"%d:%d" % (shInfo.simHit().trackingParticle().
index(), shInfo.simHit().
index())
761 if hasattr(shInfo,
"chargeFraction"):
762 m +=
"(%.1f)"%(shInfo.chargeFraction()*100)
763 hasChargeFraction =
True 765 if len(matches) == 0:
766 matched +=
"not matched to any TP/SimHit" 768 matched +=
"matched to TP:SimHit" 769 if hasChargeFraction:
771 matched +=
" "+
",".
join(matches)
774 if isinstance(hit, GluedHit):
775 glued =
"monoHit %d stereoHit %d " % (hit.monoHit().
index(), hit.stereoHit().
index())
777 lst.append(self.
_prefix+
"{layer} {hit} detid {detid} {detidStr} {glued}{coord}{matched}".
format(layer=hit.layerStr(), hit=hit.index(),
778 detid=hit.detId(), detidStr=hit.detIdStr(),
779 glued=glued, coord=coord, matched=matched))
783 def __init__(self, trackingParticles, trackingParticlePrinter, bestMatchingTrackingParticle):
794 lst.append(prefix+header+
" "+
",".
join([
str(tp.index())
for tp
in tps]))
796 lst.append(prefix+header)
798 lst.extend(self._trackingParticlePrinter.printTrackingParticle(tp))
799 lst.extend(self._trackingParticlePrinter.printHits(tp))
800 lst.extend(self._trackingParticlePrinter.printMatchedTracks(tp, useTrackPrinter=
False))
810 self._trackingParticlePrinter.indent(len(pfx)+1)
812 if track.nMatchedTrackingParticles() == 0:
814 bestTP = track.bestMatchingTrackingParticle()
815 if bestTP
is not None:
816 lst.extend(self.
_printTrackingParticles(pfx, [bestTP],
"not matched to any TP, but a following TP with >= 3 matched hits is found (shared hit fraction %.2f)" % track.bestMatchingTrackingParticleShareFrac()))
818 lst.append(prefix+
"not matched to any TP")
820 lst.append(prefix+
"not matched to any TP")
822 lst.extend(self.
_printTrackingParticles(pfx, [tpInfo.trackingParticle()
for tpInfo
in track.matchedTrackingParticleInfos()],
"matched to TPs"))
825 self._trackingParticlePrinter.restoreIndent()
830 def __init__(self, indent=0, hits=True, trackingParticles=False, trackingParticlePrinter=None, bestMatchingTrackingParticle=True):
831 super(SeedPrinter, self).
__init__(indent)
839 madeTrack =
"made track %d" % track.index()
841 madeTrack =
"did not make a track, stopReason %s" % SeedStopReason.toString(seed.stopReason())
842 if seed.stopReason() == SeedStopReason.NOT_STOPPED:
843 madeTrack +=
" (usually this means that the track was reconstructed, but rejected by the track selection)" 845 lst.append(self.
_prefix+
"Seed %d algo %s %s" % (seed.indexWithinAlgo(), Algo.toString(seed.algo()), madeTrack))
846 lst.append(self.
_prefix+
" starting state: pT %f local pos x,y %f,%f mom x,y,z %f,%f,%f" % (seed.statePt(), seed.stateTrajX(), seed.stateTrajY(), seed.stateTrajPx(), seed.stateTrajPy(), seed.stateTrajPz()))
859 return self._trackingParticleMatchPrinter.printMatchedTrackingParticles(self.
_prefix, seed)
869 if isinstance(out, list):
876 if not isinstance(out, list):
881 def diff(self, seed1, seed2, diffForTwiki=False, diffTrackingParticles=False):
893 if diffTrackingParticles:
898 def __init__(self, indent=0, hits=True, seedPrinter=SeedPrinter(), trackingParticles=
True, trackingParticlePrinter=
None, bestMatchingTrackingParticle=
True, diffForTwiki=
False):
899 super(TrackPrinter, self).
__init__(indent)
907 lst.append(self.
_prefix+
"Track %d pT %f eta %f phi %f dxy %f err %f dz %f err %f" % (track.index(), track.pt(), track.eta(), track.phi(), track.dxy(), track.dxyErr(), track.dz(), track.dzErr()))
914 oriAlgo = track.originalAlgo()
916 algoMask = track.algoMask()
917 for i
in range(Algo.algoSize):
919 algos.append(Algo.toString(i))
920 algoMask = algoMask >> 1
923 algoMaskStr =
" algoMask "+
",".
join(algos)
926 lst.append(self.
_prefix+
" pixel hits %d strip hits %d chi2/ndof %f" % (track.nPixel(), track.nStrip(), track.nChi2()))
927 lst.append(self.
_prefix+
" is %s algo %s originalAlgo %s%s stopReason %s" % (hp, Algo.toString(track.algo()), Algo.toString(track.originalAlgo()), algoMaskStr, StopReason.toString(track.stopReason())))
928 lst.append(self.
_prefix+
" px %f py %f pz %f p %f" % (track.px(), track.py(), track.pz(), math.sqrt(track.px()**2+track.py()**2+track.pz()**2)))
929 if self._trackingParticleMatchPrinter.bestMatchingTrackingParticle():
930 bestTP = track.bestMatchingTrackingParticle()
932 lst.append(self.
_prefix+
" best-matching TP %d" % bestTP.index())
933 lst.append(self.
_prefix+
" shared hits %d reco denom %.3f sim denom %.3f sim cluster denom %.3f" % (track.bestMatchingTrackingParticleShareFrac()*track.nValid(), track.bestMatchingTrackingParticleShareFrac(), track.bestMatchingTrackingParticleShareFracSimDenom(), track.bestMatchingTrackingParticleShareFracSimClusterDenom()))
934 lst.append(self.
_prefix+
" matching chi2/ndof %f" % track.bestMatchingTrackingParticleNormalizedChi2())
935 lst.append(self.
_prefix+
" pulls pt %f theta %f phi %f dxy %f dz %f" % (track.ptPull(), track.thetaPull(), track.phiPull(), track.dxyPull(), track.dzPull()))
950 self._seedPrinter.setIndentFrom(self, adjust=1)
951 lst.extend(self._seedPrinter.printSeed(track.seed()))
952 self._seedPrinter.restoreIndent()
958 self._seedPrinter.setIndentFrom(self, adjust=1)
959 ret.extend(self._seedPrinter.diff(track1.seed(), track2.seed(), self.
_diffForTwiki))
960 self._seedPrinter.restoreIndent()
970 return self._trackingParticleMatchPrinter.printMatchedTrackingParticles(self.
_prefix, track)
979 if isinstance(out, list):
986 if not isinstance(out, list):
991 def diff(self, track1, track2, diffTrackingParticles=True):
1002 trk1TPs = [tpInfo.trackingParticle()
for tpInfo
in track1.matchedTrackingParticleInfos()]
1003 trk2TPs = [tpInfo.trackingParticle()
for tpInfo
in track2.matchedTrackingParticleInfos()]
1012 ptPull1 = track1.ptPull()
1013 ptPull2 = track2.ptPull()
1014 if ptPull1
is not None and ptPull2
is not None:
1016 pt_pull1 = fmt.format(pull=ptPull1)
1017 pt_pull2 = fmt.format(pull=ptPull2)
1018 dxy_pull1 = fmt.format(pull=track1.dxyPull())
1019 dxy_pull2 = fmt.format(pull=track2.dxyPull())
1020 dz_pull1 = fmt.format(pull=track1.dzPull())
1021 dz_pull2 = fmt.format(pull=track2.dzPull())
1025 self.
_prefix+
" pt %RED%{pt1:.3g}%ENDCOLOR% %GREEN%{pt2:.3g}%ENDCOLOR%".
format(pt1=track1.pt(), pt2=track2.pt()),
1027 if pt_pull1 !=
"None":
1028 lst.append(self.
_prefix+
" pull %RED%{pull1}%ENDCOLOR% %GREEN%{pull2}%ENDCOLOR%".
format(pull1=pt_pull1, pull2=pt_pull2))
1030 self.
_prefix+
" eta %RED%{eta1:.3g}%ENDCOLOR% %GREEN%{eta2:.3g}%ENDCOLOR%".
format(eta1=track1.eta(), eta2=track2.eta()),
1031 self.
_prefix+
" phi %RED%{phi1:.3g}%ENDCOLOR% %GREEN%{phi2:.3g}%ENDCOLOR%".
format(phi1=track1.phi(), phi2=track2.phi()),
1032 self.
_prefix+
" dxy %RED%{dxy1:.3g}%ENDCOLOR% %GREEN%{dxy2:.3g}%ENDCOLOR% ({dxy1rel:.2f}*err1, {dxy2rel:.2f}*err2)".
format(dxy1=track1.dxy(), dxy2=track2.dxy(), dxy1rel=(track2.dxy()-track1.dxy())/track1.dxyErr(), dxy2rel=(track2.dxy()-track1.dxy())/track2.dxyErr()),
1034 if dxy_pull1 !=
"None":
1035 lst.append(self.
_prefix+
" pull %RED%{pull1}%ENDCOLOR% %GREEN%{pull2}%ENDCOLOR%".
format(pull1=dxy_pull1, pull2=dxy_pull2))
1037 self.
_prefix+
" dz %RED%{dz1:.3g}%ENDCOLOR% %GREEN%{dz2:.3g}%ENDCOLOR% ({dz1rel:.2f}*err1, {dz2rel:.2f}*err2)".
format(dz1=track1.dz(), dz2=track2.dz(), dz1rel=(track2.dz()-track1.dz())/track1.dzErr(), dz2rel=(track2.dz()-track1.dz())/track2.dzErr()),
1039 if dz_pull1 !=
"None":
1040 lst.append(self.
_prefix+
" pull %RED%{pull1}%ENDCOLOR% %GREEN%{pull2}%ENDCOLOR%".
format(pull1=dz_pull1, pull2=dz_pull2))
1042 self.
_prefix+
" chi2/ndof %RED%{chi1:.3g}%ENDCOLOR% %GREEN%{chi2:.3g}%ENDCOLOR%".
format(chi1=track1.nChi2(), chi2=track2.nChi2()),
1044 ret.extend(
_makediff(lst, lst, equalPrefix=
"?"))
1047 ret.extend(diffHits)
1051 ret.extend(self.
diffSeeds(track1, track2))
1052 if diffTrackingParticles:
1057 def __init__(self, indent=0, parentage=True, hits=True, tracks=True, trackPrinter=None, bestMatchingTrack=True, seedPrinter=SeedPrinter()):
1058 super(TrackingParticlePrinter, self).
__init__(indent)
1068 if len(tp.genPdgIds()) > 0:
1069 genIds =
" genPdgIds "+
",".
join([
str(pdgId)
for pdgId
in tp.genPdgIds()])
1071 if tp.isFromBHadron():
1072 fromB =
" from B hadron" 1074 self.
_prefix+
"TP %d pdgId %d%s%s ev:bx %d:%d pT %f eta %f phi %f" % (tp.index(), tp.pdgId(), genIds, fromB, tp.event(), tp.bunchCrossing(), tp.pt(), tp.eta(), tp.phi()),
1075 self.
_prefix+
" pixel hits %d strip hits %d numberOfTrackerHits() %d associated reco clusters %d dxy %f dz %f" % (tp.nPixel(), tp.nStrip(), tp.nTrackerHits(), tp.nRecoClusters(), tp.pca_dxy(), tp.pca_dz())
1081 prodVtx = tp.parentVertex()
1082 if prodVtx.nSourceTrackingParticles() == 1:
1083 lst.extend(self.
_printTP(
next(prodVtx.sourceTrackingParticles())))
1084 elif prodVtx.nSourceTrackingParticles() >= 2:
1086 for tp
in prodVtx.sourceTrackingParticles():
1098 if tp.parentVertex().nSourceTrackingParticles() > 0:
1099 lst.append(self.
_prefix+
" parentage chain")
1109 for simhit
in tp.simHits():
1111 for h
in simhit.hits():
1112 tmp.append(
",".
join([
str(trk.index())
for trk
in h.tracks()]) +
":%d"%h.index())
1114 matched =
"not matched to any Track/RecHit" 1116 matched =
"matched to Tracks:RecHits "+
";".
join(tmp)
1118 lst.append(self.
_prefix+
" %s %d pdgId %d process %d detId %d %s x,y,z %f,%f,%f %s" % (simhit.layerStr(), simhit.index(), simhit.particle(), simhit.process(), simhit.detId(), simhit.detIdStr(), simhit.x(), simhit.y(), simhit.z(), matched))
1122 return [self.
_prefix+
" matched to tracks"]
1126 if header
is not None:
1127 lst.append(self.
_prefix+
" "+header)
1131 lst[-1] +=
" "+
",".
join([
str(track.index())
for track
in tracks])
1133 self._trackPrinter.indent(2)
1134 for track
in tracks:
1135 lst.extend(self._trackPrinter.printTrack(track))
1136 self._trackPrinter.restoreIndent()
1141 if tp.nMatchedTracks() == 0:
1142 header =
"not matched to any track" 1143 lst.append(self.
_prefix+
" "+header)
1145 bestTrack = tp.bestMatchingTrack()
1146 if bestTrack
is not None:
1148 lst.extend(self.
_printMatchedTracks([bestTrack], header+
", but a following track with >= 3 matched hits is found", useTrackPrinter=useTrackPrinter))
1150 lst.extend(self.
_printMatchedTracks([trkInfo.track()
for trkInfo
in tp.matchedTrackInfos()], useTrackPrinter=useTrackPrinter))
1154 ntrk1 = tp1.nMatchedTracks()
1155 ntrk2 = tp2.nMatchedTracks()
1160 self._trackPrinter.indent(2)
1163 trks1 = [trkInfo1.track()
for trkInfo1
in tp1.matchedTrackInfos()]
1164 trks2 = [trkInfo2.track()
for trkInfo2
in tp2.matchedTrackInfos()]
1179 self._trackPrinter.restoreIndent()
1183 return [self.
_prefix+
" not matched to any seed"]
1186 return [self.
_prefix+
" matched to seeds"]
1191 if tp.nMatchedSeeds() == 0:
1195 self._seedPrinter.setIndentFrom(self, adjust=2)
1196 for seedInfo
in tp.matchedSeedInfos():
1197 lst.extend(self._seedPrinter.printSeed(seedInfo.seed()))
1198 self._seedPrinter.restoreIndent()
1205 nseed1 = tp1.nMatchedSeeds()
1206 nseed2 = tp2.nMatchedSeeds()
1207 if nseed1 == 0
or nseed2 == 0:
1210 self._seedPrinter.setIndentFrom(self, adjust=2)
1213 seeds2 = [seedInfo2.seed()
for seedInfo2
in tp2.matchedSeedInfos()]
1214 for seedInfo1
in tp1.matchedSeedInfos():
1215 seed1 = seedInfo1.seed()
1218 if matchedSeed2
is None:
1219 diff.extend(
_makediff(self._seedPrinter.printSeed(seed1), []))
1221 seeds2.remove(matchedSeed2)
1222 diff.extend(
_makediff(self._seedPrinter.printSeed(seed1), self._seedPrinter.printSeed(matchedSeed2)))
1224 for seed2
in seeds2:
1225 diff.extend(
_makediff([], self._seedPrinter.printSeed(seed2)))
1227 self._seedPrinter.restoreIndent()
1232 if isinstance(out, list):
def printHeader(self, seed)
def _mapdiff(func, obj1, obj2)
def printSeed(self, track)
def printMatchedTrackingParticles(self, prefix, track)
def printHits(self, track)
def __init__(self, trackingParticles, trackingParticlePrinter, bestMatchingTrackingParticle)
def trks2OutsideList(self)
def setIndentFrom(self, printer, adjust=0)
def __init__(self, indent=0)
def __call__(self, tp, out=sys.stdout)
def __init__(self, indent=0, parentage=True, hits=True, tracks=True, trackPrinter=None, bestMatchingTrack=True, seedPrinter=SeedPrinter())
_trackingParticleMatchPrinter
def hasCommonTrackingParticle(self)
def bestMatchingTrackingParticle(self)
def highlightLines(self, plusregexs=[], minusregexs=[])
def _highlightLine(self, line, plus, minus)
def diff(self, track1, track2, diffTrackingParticles=True)
def _areSameTracks(trk1, trk2)
def printTrackAndMatchedTrackingParticles(self, track)
def diffMatchedTracks(self, tp1, tp2)
def _makediff(list1, list2, equalPrefix=" ")
def _printMatchedTracksHeader(self)
def __init__(self, indent=0, hits=True, seedPrinter=SeedPrinter(), trackingParticles=True, trackingParticlePrinter=None, bestMatchingTrackingParticle=True, diffForTwiki=False)
def _formatHitDiffForTwiki(diffHits, prefix)
def setDifference(self, diff=True)
def highlight(self, plus=False, minus=False)
def __call__(self, seed, out=sys.stdout)
def __init__(self, diff=[], hasDifference=False)
def printMatchedSeeds(self, tp)
def extendTrks1(self, trks)
def diffTrackListsFromSameTrackingParticle(trackPrinter, lst1, lst2, lst1extra=[], lst2extra=[], diffByHitsOnly=False)
def __init__(self, indent=0, hits=True, trackingParticles=False, trackingParticlePrinter=None, bestMatchingTrackingParticle=True)
def _matchTracksByHits(reftrk, trklist)
def _commonHits(trk1, trk2)
def __init__(self, trklist)
def _hitPatternSummary(hits)
def _printTrackingParticles(self, prefix, tps, header)
def diffTrackListsGeneric(trackPrinter, lst1, lst2, ignoreAdditionalLst2=False)
def _printMatchedTracks(self, tracks, header=None, useTrackPrinter=True)
def __init__(self, indent=0)
def printMatchedTrackingParticles(self, track)
def printHits(self, seed)
def _parentageChain(self, tp)
def extendTrks2(self, trks)
static std::string join(char **cmd)
def __call__(self, track, out=sys.stdout)
def printMatchedTracks(self, tp, useTrackPrinter=True)
def printTrack(self, track)
_bestMatchingTrackingParticle
def extend(self, trks1=[], trks2=[], trks1OutsideList=[], trks2OutsideList=[])
def _difflist(list1, list2)
def extendTrks2OutsideList(self, trks)
def printSeed(self, seed)
def trks1OutsideList(self)
def diffSeeds(self, track1, track2)
def extendTrks1OutsideList(self, trks)
def diffMatchedSeeds(self, tp1, tp2)
def printHeader(self, track)
def diff(self, seed1, seed2, diffForTwiki=False, diffTrackingParticles=False)
def _printMatchedSeeds0(self)
def _associateTracksByTrackingParticlesAndHits(lst1, lst2)
def _printMatchedSeedsHeader(self)
_trackingParticleMatchPrinter
def _printHits(self, hits)
def _extend(self, trks, name)
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 printMatchedTrackingParticles(self, seed)
def printTrackingParticle(self, tp)