8 from operator
import itemgetter, methodcaller
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. 20 for hit
in trk1.hits():
21 if not hit.isValidHit():
continue 22 hits1.add( (type(hit), hit.index()) )
25 for hit
in trk2.hits():
26 if not hit.isValidHit():
continue 27 if (type(hit), hit.index())
in hits1:
37 for hit
in reftrk.hits():
38 if not hit.isValidHit():
continue 39 hits1.add( (type(hit), hit.index()) )
44 for hit
in trk.hits():
45 if not hit.isValidHit():
continue 46 if (type(hit), hit.index())
in hits1:
55 super(_TracksByHitsMatcher, self).
__init__()
58 for hit
in trk.hits():
63 tracks = collections.defaultdict(int)
65 for hit
in trk.hits():
66 if not hit.isValidHit():
continue 68 idx = (type(hit), hit.index())
74 for ot
in otherTracks:
78 for t, ncommon
in tracks.iteritems():
86 def __init__(self, diff=[], hasDifference=False):
98 if isinstance(diff, _DiffResult):
99 self._diff.append(diff)
100 if diff.hasDifference():
103 self._diff.extend(diff)
113 return line[0]+char+line[1:]
116 if not (plus
or minus):
119 for i, line
in enumerate(self.
_diff):
120 if isinstance(line, _DiffResult):
121 line.highlight(plus, minus)
126 if len(plusregexs) == 0
and len(minusregexs) == 0:
129 for i, line
in enumerate(self.
_diff):
130 if isinstance(line, _DiffResult):
131 raise Exception(
"highlightLines() is currently allowed only for text-only _DiffResult objects")
138 for m
in minusregexs:
145 for line
in self.
_diff:
146 if isinstance(line, _DiffResult):
147 for l
in line.lines():
156 return len(self.
_diff)
159 diff = difflib.unified_diff(list1, list2, lineterm=
"", n=len(list1))
168 return _DiffResult([equalPrefix+s
for s
in list1], hasDifference=
False)
173 lst1 =
func(obj1)
if obj1
is not None else []
174 lst2 =
func(obj2)
if obj2
is not None else []
181 if not (ncommon == trk1.nValid()
and ncommon == trk2.nValid()):
185 if not (trk1.algoMask() == trk2.algoMask()
and trk1.algo() == trk2.algo()
and trk1.originalAlgo() == trk2.originalAlgo()):
191 if trk1.nMatchedTrackingParticles() != trk2.nMatchedTrackingParticles():
194 for tpInfo1, tpInfo2
in itertools.izip(trk1.matchedTrackingParticleInfos(), trk2.matchedTrackingParticleInfos()):
195 if tpInfo1.trackingParticle().
index() != tpInfo2.trackingParticle().
index():
201 """lst1 and lst2 are the main lists to make the diff from. 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. 211 _trks1extra =
list(lst1extra)
212 _trks2extra =
list(lst2extra)
214 trks1 =
list(lst1)+_trks1extra
215 trks2 =
list(lst2)+_trks2extra
217 trks1extra = set([t.index()
for t
in _trks1extra])
218 trks2extra = set([t.index()
for t
in _trks2extra])
220 trks1Empty = (len(trks1) == 0)
221 trks2Empty = (len(trks2) == 0)
223 if trks1Empty
and trks2Empty:
229 def _findCommonTP(_lst, _commonTP, _name):
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()
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()))
240 commonTP = _findCommonTP(trks1, commonTP,
"lst1")
241 commonTP = _findCommonTP(trks2, commonTP,
"lst2")
244 someTrk1 = trks1[0]
if not trks1Empty
else None 245 someTrk2 = trks2[0]
if not trks2Empty
else None 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), []))
256 someTrk2 = matchedTrk2
257 trks2.remove(matchedTrk2)
258 tmp = trackPrinter.diff(trk1, matchedTrk2, diffTrackingParticles=
False)
260 tmp.setDifference(
False)
261 tmp.highlight(plus=(matchedTrk2.index()
in trks2extra), minus=(trk1.index()
in trks1extra))
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)))
271 tmp =
_mapdiff(trackPrinter.printMatchedTrackingParticles, someTrk1, someTrk2)
272 tmp.setDifference(
False)
275 for i
in lst: r.extend([re.compile(
"Tracks:.*%d:"%i), re.compile(
"matched to tracks.*%d"%i)])
277 plusre = _makere(trks2extra)
278 minusre = _makere(trks1extra)
279 tmp.highlightLines(plusre, minusre)
286 super(_TrackAssociation, self).
__init__()
298 lst = getattr(self, name)
299 ind = getattr(self, name+
"Ind")
301 if not t.index()
in ind:
305 def extend(self, trks1=[], trks2=[], trks1OutsideList=[], trks2OutsideList=[]):
318 self.
_extend(trks,
"_trks1OutsideList")
321 self.
_extend(trks,
"_trks2OutsideList")
332 except StopIteration:
334 if first.nMatchedTrackingParticles() != 1:
337 tpIndex =
next(first.matchedTrackingParticleInfos()).trackingParticle().
index()
340 if t.nMatchedTrackingParticles() != 1:
342 if next(t.matchedTrackingParticleInfos()).trackingParticle().
index() != tpIndex:
354 _min =
lambda lst:
min([t.eta()
for t
in lst])
362 if len(self._trks2_outsideList) > 0:
364 raise Exception(
"This _TrackAssociation is empty, minEta() makes no sense")
367 s =
lambda l:
str([t.index()
for t
in l])
378 trks1Dict = {t.index(): t
for t
in trks1}
379 trks2Dict = {t.index(): t
for t
in trks2}
385 tps1 = TrackingParticles(trks1[0]._tree)
387 tps2 = TrackingParticles(trks2[0]._tree)
392 def _getOrCreateAssoc(trk, d, **kwargs):
401 while len(trks1) > 0:
403 assoc1 = _getOrCreateAssoc(trk1, trkAssoc1, trks1=[trk1])
406 if trk1.nMatchedTrackingParticles() > 0
and tps2:
409 for tpInfo1
in trk1.matchedTrackingParticleInfos():
410 tp1 = tpInfo1.trackingParticle()
413 for trkInfo1
in tp1.matchedTrackInfos():
414 t1 = trkInfo1.track()
416 if t1Index != trk1.index():
417 if t1Index
in trks1Dict:
418 assoc1.extend(trks1=[t1])
419 _getOrCreateAssoc(t1, trkAssoc1, trks1=[t1, trk1])
421 trks1.remove(trks1Dict[t1Index])
424 assoc1.extend(trks1OutsideList=[t1])
427 tp2 = tps2[tp1.index()]
428 for trkInfo2
in tp2.matchedTrackInfos():
430 t2 = trkInfo2.track()
432 if t2Index
in trks2Dict:
433 assoc1.extend(trks2=[t2])
434 _getOrCreateAssoc(t2, trkAssoc2, trks1=[trk1], trks2=[t2])
437 trks2.remove(trks2Dict[t2Index])
442 assoc1.extend(trks2OutsideList=[t2])
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])
455 trks2.remove(matchedTrk2)
459 (matchedTrk1, ncommon1) = trks1Matcher.match(matchedTrk2)
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])
470 assoc2 = _getOrCreateAssoc(trk2, trkAssoc2, trks2=[trk2])
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()
478 if t2Index
in trks2Dict:
479 assoc2.extend(trks2=[t2])
482 assoc2.extend(trks2OutsideList=[t2])
487 for ind, assoc
in trkAssoc1.iteritems():
488 for t1
in assoc.trks1():
489 a = trkAssoc1[t1.index()]
492 for t2
in assoc.trks2():
493 a = trkAssoc2[t2.index()]
496 for ind, assoc
in trkAssoc2.iteritems():
497 for t2
in assoc.trks2():
498 a = trkAssoc2[t2.index()]
501 for t1
in assoc.trks1():
502 a = trkAssoc1[t1.index()]
506 for ind, assoc
in itertools.chain(trkAssoc1.iteritems(), trkAssoc2.iteritems()):
510 for t1
in assoc.trks1():
511 a = trkAssoc1[t1.index()]
518 for t2
in assoc.trks2():
519 a = trkAssoc2[t2.index()]
528 while len(trkAssoc1) > 0:
529 (t1Index, assoc) = trkAssoc1.popitem()
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)
554 associations.sort(key=methodcaller(
"minEta"))
557 for assoc
in associations:
558 if assoc.hasCommonTrackingParticle():
559 if len(assoc.trks1()) == 0
and ignoreAdditionalLst2:
563 if tmp.hasDifference():
566 elif len(assoc.trks1()) == 1
and len(assoc.trks2()) == 1:
567 trk1 = assoc.trks1()[0]
568 trk2 = assoc.trks2()[0]
571 diff.extend(trackPrinter.diff(trk1, trk2))
573 elif len(assoc.trks2()) == 0:
574 for t
in assoc.trks1():
575 diff.extend(trackPrinter.diff(t,
None))
577 elif len(assoc.trks1()) == 0:
578 if ignoreAdditionalLst2:
580 for t
in assoc.trks1():
581 diff.extend(trackPrinter.diff(
None, t))
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())
592 for i1, t1
in enumerate(trks1):
593 for i2, t2
in enumerate(trks2):
597 ncommon.sort(key=itemgetter(2), reverse=
True)
600 pairs = [
None]*len(trks1)
601 usedT2 = [
False]*len(trks2)
602 for i1, i2, ncom
in ncommon:
603 if pairs[i1]
is None:
607 for i1, i2
in enumerate(pairs):
610 diff.extend(trackPrinter.diff(t1, t2))
611 for i2, used
in enumerate(usedT2):
613 diff.extend(trackPrinter.diff(
None, trks2[i2]))
619 line_re = re.compile(
"(?P<sign>[ \-+])\s+(?P<det>[a-zA-Z]+)(?P<lay>\d+)\D*?(\((?P<missing>missing|inactive)\))?\s+\d+")
624 diffLines = diffHits.lines()
627 for line
in diffLines:
632 for line
in diffLines:
641 m = line_re.search(line)
644 raise Exception(
"regex not found from line %s" % line.rstrip())
645 sign = m.group(
"sign")
651 summary.append(
"%ENDCOLOR%")
653 summary.extend([
" ", det])
658 summary.append(
"%ENDCOLOR%")
660 summary.append(
"%RED%")
662 summary.append(
"%GREEN%")
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)")
688 summary.append(
"%ENDCOLOR%")
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]]
697 line =
" "+
"".
join(summary)
698 return [
"?"+prefix+line]
710 summary +=
" "+SubDet.toString(det)
714 if isinstance(hit, InvalidHit):
715 summary +=
"(%s)"%InvalidHit.Type.toString(hit.type())[0]
731 self._backup.append(self.
_prefix)
735 self._backup.append(self.
_prefix)
740 self.
_prefix = self._backup.pop()
744 super(_RecHitPrinter, self).
__init__(indent)
753 if hasattr(hit,
"matchedSimHitInfos"):
754 matched =
" from %s " % HitSimType.toString(hit.simType())
756 hasChargeFraction =
False 757 for shInfo
in hit.matchedSimHitInfos():
758 m =
"%d:%d" % (shInfo.simHit().trackingParticle().
index(), shInfo.simHit().
index())
759 if hasattr(shInfo,
"chargeFraction"):
760 m +=
"(%.1f)"%(shInfo.chargeFraction()*100)
761 hasChargeFraction =
True 763 if len(matches) == 0:
764 matched +=
"not matched to any TP/SimHit" 766 matched +=
"matched to TP:SimHit" 767 if hasChargeFraction:
769 matched +=
" "+
",".
join(matches)
772 if isinstance(hit, GluedHit):
773 glued =
"monoHit %d stereoHit %d " % (hit.monoHit().
index(), hit.stereoHit().
index())
775 lst.append(self.
_prefix+
"{layer} {hit} detid {detid} {detidStr} {glued}{coord}{matched}".
format(layer=hit.layerStr(), hit=hit.index(),
776 detid=hit.detId(), detidStr=hit.detIdStr(),
777 glued=glued, coord=coord, matched=matched))
781 def __init__(self, trackingParticles, trackingParticlePrinter, bestMatchingTrackingParticle):
792 lst.append(prefix+header+
" "+
",".
join([
str(tp.index())
for tp
in tps]))
794 lst.append(prefix+header)
796 lst.extend(self._trackingParticlePrinter.printTrackingParticle(tp))
797 lst.extend(self._trackingParticlePrinter.printHits(tp))
798 lst.extend(self._trackingParticlePrinter.printMatchedTracks(tp, useTrackPrinter=
False))
808 self._trackingParticlePrinter.indent(len(pfx)+1)
810 if track.nMatchedTrackingParticles() == 0:
812 bestTP = track.bestMatchingTrackingParticle()
813 if bestTP
is not None:
814 lst.extend(self.
_printTrackingParticles(pfx, [bestTP],
"not matched to any TP, but a following TP with >= 3 matched hits is found"))
816 lst.append(prefix+
"not matched to any TP")
818 lst.append(prefix+
"not matched to any TP")
820 lst.extend(self.
_printTrackingParticles(pfx, [tpInfo.trackingParticle()
for tpInfo
in track.matchedTrackingParticleInfos()],
"matched to TPs"))
823 self._trackingParticlePrinter.restoreIndent()
828 def __init__(self, indent=0, hits=True, trackingParticles=False, trackingParticlePrinter=None, bestMatchingTrackingParticle=True):
829 super(SeedPrinter, self).
__init__(indent)
837 madeTrack =
"made track %d" % track.index()
839 madeTrack =
"did not make a track, stopReason %s" % SeedStopReason.toString(seed.stopReason())
840 if seed.stopReason() == SeedStopReason.NOT_STOPPED:
841 madeTrack +=
" (usually this means that the track was reconstructed, but rejected by the track selection)" 843 lst.append(self.
_prefix+
"Seed %d algo %s %s" % (seed.indexWithinAlgo(), Algo.toString(seed.algo()), madeTrack))
844 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()))
857 return self._trackingParticleMatchPrinter.printMatchedTrackingParticles(self.
_prefix, seed)
867 if isinstance(out, list):
874 if not isinstance(out, list):
879 def diff(self, seed1, seed2, diffForTwiki=False, diffTrackingParticles=False):
891 if diffTrackingParticles:
896 def __init__(self, indent=0, hits=True, seedPrinter=SeedPrinter(), trackingParticles=
True, trackingParticlePrinter=
None, bestMatchingTrackingParticle=
True, diffForTwiki=
False):
897 super(TrackPrinter, self).
__init__(indent)
905 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()))
912 oriAlgo = track.originalAlgo()
914 algoMask = track.algoMask()
915 for i
in xrange(Algo.algoSize):
917 algos.append(Algo.toString(i))
918 algoMask = algoMask >> 1
921 algoMaskStr =
" algoMask "+
",".
join(algos)
924 lst.append(self.
_prefix+
" pixel hits %d strip hits %d chi2/ndof %f" % (track.nPixel(), track.nStrip(), track.nChi2()))
925 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())))
926 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)))
927 if self._trackingParticleMatchPrinter.bestMatchingTrackingParticle():
928 ptPull = track.ptPull()
929 if ptPull
is not None:
930 lst.append(self.
_prefix+
" pulls pt %f dxy %f dz %f" % (ptPull, track.dxyPull(), track.dzPull()))
945 self._seedPrinter.setIndentFrom(self, adjust=1)
946 lst.extend(self._seedPrinter.printSeed(track.seed()))
947 self._seedPrinter.restoreIndent()
953 self._seedPrinter.setIndentFrom(self, adjust=1)
954 ret.extend(self._seedPrinter.diff(track1.seed(), track2.seed(), self.
_diffForTwiki))
955 self._seedPrinter.restoreIndent()
965 return self._trackingParticleMatchPrinter.printMatchedTrackingParticles(self.
_prefix, track)
974 if isinstance(out, list):
981 if not isinstance(out, list):
986 def diff(self, track1, track2, diffTrackingParticles=True):
997 trk1TPs = [tpInfo.trackingParticle()
for tpInfo
in track1.matchedTrackingParticleInfos()]
998 trk2TPs = [tpInfo.trackingParticle()
for tpInfo
in track2.matchedTrackingParticleInfos()]
1007 ptPull1 = track1.ptPull()
1008 ptPull2 = track2.ptPull()
1009 if ptPull1
is not None and ptPull2
is not None:
1011 pt_pull1 = fmt.format(pull=ptPull1)
1012 pt_pull2 = fmt.format(pull=ptPull2)
1013 dxy_pull1 = fmt.format(pull=track1.dxyPull())
1014 dxy_pull2 = fmt.format(pull=track2.dxyPull())
1015 dz_pull1 = fmt.format(pull=track1.dzPull())
1016 dz_pull2 = fmt.format(pull=track2.dzPull())
1020 self.
_prefix+
" pt %RED%{pt1:.3g}%ENDCOLOR% %GREEN%{pt2:.3g}%ENDCOLOR%".
format(pt1=track1.pt(), pt2=track2.pt()),
1022 if pt_pull1 !=
"None":
1023 lst.append(self.
_prefix+
" pull %RED%{pull1}%ENDCOLOR% %GREEN%{pull2}%ENDCOLOR%".
format(pull1=pt_pull1, pull2=pt_pull2))
1025 self.
_prefix+
" eta %RED%{eta1:.3g}%ENDCOLOR% %GREEN%{eta2:.3g}%ENDCOLOR%".
format(eta1=track1.eta(), eta2=track2.eta()),
1026 self.
_prefix+
" phi %RED%{phi1:.3g}%ENDCOLOR% %GREEN%{phi2:.3g}%ENDCOLOR%".
format(phi1=track1.phi(), phi2=track2.phi()),
1027 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()),
1029 if dxy_pull1 !=
"None":
1030 lst.append(self.
_prefix+
" pull %RED%{pull1}%ENDCOLOR% %GREEN%{pull2}%ENDCOLOR%".
format(pull1=dxy_pull1, pull2=dxy_pull2))
1032 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()),
1034 if dz_pull1 !=
"None":
1035 lst.append(self.
_prefix+
" pull %RED%{pull1}%ENDCOLOR% %GREEN%{pull2}%ENDCOLOR%".
format(pull1=dz_pull1, pull2=dz_pull2))
1037 self.
_prefix+
" chi2/ndof %RED%{chi1:.3g}%ENDCOLOR% %GREEN%{chi2:.3g}%ENDCOLOR%".
format(chi1=track1.nChi2(), chi2=track2.nChi2()),
1039 ret.extend(
_makediff(lst, lst, equalPrefix=
"?"))
1042 ret.extend(diffHits)
1046 ret.extend(self.
diffSeeds(track1, track2))
1047 if diffTrackingParticles:
1052 def __init__(self, indent=0, parentage=True, hits=True, tracks=True, trackPrinter=None, bestMatchingTrack=True, seedPrinter=SeedPrinter()):
1053 super(TrackingParticlePrinter, self).
__init__(indent)
1063 if len(tp.genPdgIds()) > 0:
1064 genIds =
" genPdgIds "+
",".
join([
str(pdgId)
for pdgId
in tp.genPdgIds()])
1066 if tp.isFromBHadron():
1067 fromB =
" from B hadron" 1069 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()),
1070 self.
_prefix+
" pixel hits %d strip hits %d dxy %f dz %f" % (tp.nPixel(), tp.nStrip(), tp.pca_dxy(), tp.pca_dz())
1076 prodVtx = tp.parentVertex()
1077 if prodVtx.nSourceTrackingParticles() == 1:
1078 lst.extend(self.
_printTP(
next(prodVtx.sourceTrackingParticles())))
1079 elif prodVtx.nSourceTrackingParticles() >= 2:
1081 for tp
in prodVtx.sourceTrackingParticles():
1093 if tp.parentVertex().nSourceTrackingParticles() > 0:
1094 lst.append(self.
_prefix+
" parentage chain")
1104 for simhit
in tp.simHits():
1106 for h
in simhit.hits():
1107 tmp.append(
",".
join([
str(trk.index())
for trk
in h.tracks()]) +
":%d"%h.index())
1109 matched =
"not matched to any Track/RecHit" 1111 matched =
"matched to Tracks:RecHits "+
";".
join(tmp)
1113 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))
1117 return [self.
_prefix+
" matched to tracks"]
1121 if header
is not None:
1122 lst.append(self.
_prefix+
" "+header)
1126 lst[-1] +=
" "+
",".
join([
str(track.index())
for track
in tracks])
1128 self._trackPrinter.indent(2)
1129 for track
in tracks:
1130 lst.extend(self._trackPrinter.printTrack(track))
1131 self._trackPrinter.restoreIndent()
1136 if tp.nMatchedTracks() == 0:
1137 header =
"not matched to any track" 1138 lst.append(self.
_prefix+
" "+header)
1140 bestTrack = tp.bestMatchingTrack()
1141 if bestTrack
is not None:
1143 lst.extend(self.
_printMatchedTracks([bestTrack], header+
", but a following track with >= 3 matched hits is found", useTrackPrinter=useTrackPrinter))
1145 lst.extend(self.
_printMatchedTracks([trkInfo.track()
for trkInfo
in tp.matchedTrackInfos()], useTrackPrinter=useTrackPrinter))
1149 ntrk1 = tp1.nMatchedTracks()
1150 ntrk2 = tp2.nMatchedTracks()
1155 self._trackPrinter.indent(2)
1158 trks1 = [trkInfo1.track()
for trkInfo1
in tp1.matchedTrackInfos()]
1159 trks2 = [trkInfo2.track()
for trkInfo2
in tp2.matchedTrackInfos()]
1174 self._trackPrinter.restoreIndent()
1178 return [self.
_prefix+
" not matched to any seed"]
1181 return [self.
_prefix+
" matched to seeds"]
1186 if tp.nMatchedSeeds() == 0:
1190 self._seedPrinter.setIndentFrom(self, adjust=2)
1191 for seedInfo
in tp.matchedSeedInfos():
1192 lst.extend(self._seedPrinter.printSeed(seedInfo.seed()))
1193 self._seedPrinter.restoreIndent()
1200 nseed1 = tp1.nMatchedSeeds()
1201 nseed2 = tp2.nMatchedSeeds()
1202 if nseed1 == 0
or nseed2 == 0:
1205 self._seedPrinter.setIndentFrom(self, adjust=2)
1208 seeds2 = [seedInfo2.seed()
for seedInfo2
in tp2.matchedSeedInfos()]
1209 for seedInfo1
in tp1.matchedSeedInfos():
1210 seed1 = seedInfo1.seed()
1213 if matchedSeed2
is None:
1214 diff.extend(
_makediff(self._seedPrinter.printSeed(seed1), []))
1216 seeds2.remove(matchedSeed2)
1217 diff.extend(
_makediff(self._seedPrinter.printSeed(seed1), self._seedPrinter.printSeed(matchedSeed2)))
1219 for seed2
in seeds2:
1220 diff.extend(
_makediff([], self._seedPrinter.printSeed(seed2)))
1222 self._seedPrinter.restoreIndent()
1227 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)