CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
ntuplePrintersDiff.TrackPrinter Class Reference
Inheritance diagram for ntuplePrintersDiff.TrackPrinter:
ntuplePrintersDiff._RecHitPrinter ntuplePrintersDiff._IndentPrinter

Public Member Functions

def __call__ (self, track, out=sys.stdout)
 
def __init__ (self, indent=0, hits=True, seedPrinter=SeedPrinter(), trackingParticles=True, trackingParticlePrinter=None, bestMatchingTrackingParticle=True, diffForTwiki=False)
 
def diff (self, track1, track2, diffTrackingParticles=True)
 
def diffSeeds (self, track1, track2)
 
def printHeader (self, track)
 
def printHits (self, track)
 
def printMatchedTrackingParticles (self, track)
 
def printSeed (self, track)
 
def printTrack (self, track)
 
def printTrackAndMatchedTrackingParticles (self, track)
 
- Public Member Functions inherited from ntuplePrintersDiff._RecHitPrinter
def __init__ (self, indent=0)
 
- Public Member Functions inherited from ntuplePrintersDiff._IndentPrinter
def indent (self, num)
 
def restoreIndent (self)
 
def setIndentFrom (self, printer, adjust=0)
 

Private Attributes

 _diffForTwiki
 
 _hits
 
 _seedPrinter
 
 _trackingParticleMatchPrinter
 

Detailed Description

Definition at line 897 of file ntuplePrintersDiff.py.

Constructor & Destructor Documentation

◆ __init__()

def ntuplePrintersDiff.TrackPrinter.__init__ (   self,
  indent = 0,
  hits = True,
  seedPrinter = SeedPrinter(),
  trackingParticles = True,
  trackingParticlePrinter = None,
  bestMatchingTrackingParticle = True,
  diffForTwiki = False 
)

Definition at line 898 of file ntuplePrintersDiff.py.

898  def __init__(self, indent=0, hits=True, seedPrinter=SeedPrinter(), trackingParticles=True, trackingParticlePrinter=None, bestMatchingTrackingParticle=True, diffForTwiki=False):
899  super(TrackPrinter, self).__init__(indent)
900  self._hits = hits
901  self._seedPrinter = seedPrinter
902  self._trackingParticleMatchPrinter = _TrackingParticleMatchPrinter(trackingParticles, trackingParticlePrinter, bestMatchingTrackingParticle)
903  self._diffForTwiki = diffForTwiki
904 

Member Function Documentation

◆ __call__()

def ntuplePrintersDiff.TrackPrinter.__call__ (   self,
  track,
  out = sys.stdout 
)

Definition at line 978 of file ntuplePrintersDiff.py.

978  def __call__(self, track, out=sys.stdout):
979  if isinstance(out, list):
980  lst = out
981  else:
982  lst = []
983 
984  lst.extend(self.printTrackAndMatchedTrackingParticles(track))
985 
986  if not isinstance(out, list):
987  for line in lst:
988  out.write(line)
989  out.write("\n")
990 

References ntuplePrintersDiff.TrackPrinter.printTrackAndMatchedTrackingParticles().

◆ diff()

def ntuplePrintersDiff.TrackPrinter.diff (   self,
  track1,
  track2,
  diffTrackingParticles = True 
)

Definition at line 991 of file ntuplePrintersDiff.py.

991  def diff(self, track1, track2, diffTrackingParticles=True):
992  if track1 is None:
993  lst = self.printTrack(track2) + self.printMatchedTrackingParticles(track2)
994  return _makediff([], lst)
995  if track2 is None:
996  lst = self.printTrack(track1) + self.printMatchedTrackingParticles(track1)
997  return _makediff(lst, [])
998 
999  ret = _DiffResult()
1000  ret.extend(_mapdiff(self.printHeader, track1, track2))
1001  if self._diffForTwiki:
1002  trk1TPs = [tpInfo.trackingParticle() for tpInfo in track1.matchedTrackingParticleInfos()]
1003  trk2TPs = [tpInfo.trackingParticle() for tpInfo in track2.matchedTrackingParticleInfos()]
1004 
1005  pt_pull1 = "None"
1006  pt_pull2 = "None"
1007  dxy_pull1 = "None"
1008  dxy_pull2 = "None"
1009  dz_pull1 = "None"
1010  dz_pull2 = "None"
1011 
1012  ptPull1 = track1.ptPull()
1013  ptPull2 = track2.ptPull()
1014  if ptPull1 is not None and ptPull2 is not None:
1015  fmt = "{pull:.3g}"
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())
1022 
1023  lst = [
1024  self._prefix+" parameters",
1025  self._prefix+" pt %RED%{pt1:.3g}%ENDCOLOR% %GREEN%{pt2:.3g}%ENDCOLOR%".format(pt1=track1.pt(), pt2=track2.pt()),
1026  ]
1027  if pt_pull1 != "None":
1028  lst.append(self._prefix+" pull %RED%{pull1}%ENDCOLOR% %GREEN%{pull2}%ENDCOLOR%".format(pull1=pt_pull1, pull2=pt_pull2))
1029  lst.extend([
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()),
1033  ])
1034  if dxy_pull1 != "None":
1035  lst.append(self._prefix+" pull %RED%{pull1}%ENDCOLOR% %GREEN%{pull2}%ENDCOLOR%".format(pull1=dxy_pull1, pull2=dxy_pull2))
1036  lst.extend([
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()),
1038  ])
1039  if dz_pull1 != "None":
1040  lst.append(self._prefix+" pull %RED%{pull1}%ENDCOLOR% %GREEN%{pull2}%ENDCOLOR%".format(pull1=dz_pull1, pull2=dz_pull2))
1041  lst.extend([
1042  self._prefix+" chi2/ndof %RED%{chi1:.3g}%ENDCOLOR% %GREEN%{chi2:.3g}%ENDCOLOR%".format(chi1=track1.nChi2(), chi2=track2.nChi2()),
1043  ])
1044  ret.extend(_makediff(lst, lst, equalPrefix="?"))
1045 
1046  diffHits = _mapdiff(self.printHits, track1, track2)
1047  ret.extend(diffHits)
1048  if self._hits and self._diffForTwiki:
1049  ret.extend(_formatHitDiffForTwiki(diffHits, self._prefix))
1050 
1051  ret.extend(self.diffSeeds(track1, track2))
1052  if diffTrackingParticles:
1053  ret.extend(_mapdiff(self.printMatchedTrackingParticles, track1, track2))
1054  return ret
1055 

References ntuplePrintersDiff.TrackPrinter._diffForTwiki, ntuplePrintersDiff._formatHitDiffForTwiki(), FP420HitsObject._hits, TrackerHitsObject._hits, DTBtiChip._hits, ntuplePrintersDiff.SeedPrinter._hits, ntuplePrintersDiff.TrackPrinter._hits, ntuplePrintersDiff._makediff(), ntuplePrintersDiff._mapdiff(), CommonAnalyzer._prefix, ntupleDataFormat._Object._prefix, ntupleDataFormat.BeamSpot._prefix, html.PageSet._prefix, ntuplePrintersDiff._IndentPrinter._prefix, ntuplePrintersDiff.TrackPrinter.diffSeeds(), L1GctLut< NAddressBits, NDataBits >.printHeader(), EcalSelectiveReadout.printHeader(), FastTimerService.printHeader(), ntuplePrintersDiff.SeedPrinter.printHeader(), ntuplePrintersDiff.TrackPrinter.printHeader(), TkAccumulatingSensitiveDetector.printHits, HGCalEgammaIDHelper.printHits(), hgcal::EGammaPCAHelper.printHits(), MuonSensitiveDetector.printHits, GlobalTrajectoryBuilderBase.printHits(), GlobalMuonRefitter.printHits(), ntuplePrintersDiff.SeedPrinter.printHits(), ntuplePrintersDiff.TrackPrinter.printHits(), ntuplePrintersDiff._TrackingParticleMatchPrinter.printMatchedTrackingParticles(), ntuplePrintersDiff.SeedPrinter.printMatchedTrackingParticles(), ntuplePrintersDiff.TrackPrinter.printMatchedTrackingParticles(), SimHitPrinter.printTrack(), IsolatedTracksCone.printTrack(), IsolatedTracksNxN.printTrack(), and ntuplePrintersDiff.TrackPrinter.printTrack().

Referenced by ntuplePrintersDiff.TrackPrinter.diffSeeds().

◆ diffSeeds()

def ntuplePrintersDiff.TrackPrinter.diffSeeds (   self,
  track1,
  track2 
)

Definition at line 955 of file ntuplePrintersDiff.py.

955  def diffSeeds(self, track1, track2):
956  ret = _DiffResult()
957  if self._seedPrinter:
958  self._seedPrinter.setIndentFrom(self, adjust=1)
959  ret.extend(self._seedPrinter.diff(track1.seed(), track2.seed(), self._diffForTwiki))
960  self._seedPrinter.restoreIndent()
961  return ret
962 

References ntuplePrintersDiff.TrackPrinter._diffForTwiki, ntuplePrintersDiff.TrackPrinter._seedPrinter, ntuplePrintersDiff.TrackPrinter.diff(), ntuplePrintersDiff._IndentPrinter.restoreIndent(), and ntuplePrintersDiff._IndentPrinter.setIndentFrom().

Referenced by ntuplePrintersDiff.TrackPrinter.diff().

◆ printHeader()

def ntuplePrintersDiff.TrackPrinter.printHeader (   self,
  track 
)

Definition at line 905 of file ntuplePrintersDiff.py.

905  def printHeader(self, track):
906  lst = []
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()))
908 
909  hp = "loose"
910  if track.isHP():
911  hp = "HP"
912 
913  algo = track.algo()
914  oriAlgo = track.originalAlgo()
915  algos = []
916  algoMask = track.algoMask()
917  for i in range(Algo.algoSize):
918  if algoMask & 1:
919  algos.append(Algo.toString(i))
920  algoMask = algoMask >> 1
921  algoMaskStr = ""
922  if len(algos) >= 2:
923  algoMaskStr = " algoMask "+",".join(algos)
924 
925 
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()
931  if bestTP:
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()))
936  return lst
937 

References CommonAnalyzer._prefix, ntupleDataFormat._Object._prefix, ntupleDataFormat.BeamSpot._prefix, html.PageSet._prefix, ntuplePrintersDiff._IndentPrinter._prefix, ntuplePrintersDiff.SeedPrinter._trackingParticleMatchPrinter, ntuplePrintersDiff.TrackPrinter._trackingParticleMatchPrinter, join(), and FastTimerService_cff.range.

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

◆ printHits()

def ntuplePrintersDiff.TrackPrinter.printHits (   self,
  track 
)

◆ printMatchedTrackingParticles()

def ntuplePrintersDiff.TrackPrinter.printMatchedTrackingParticles (   self,
  track 
)

◆ printSeed()

def ntuplePrintersDiff.TrackPrinter.printSeed (   self,
  track 
)

Definition at line 947 of file ntuplePrintersDiff.py.

947  def printSeed(self, track):
948  lst = []
949  if self._seedPrinter:
950  self._seedPrinter.setIndentFrom(self, adjust=1)
951  lst.extend(self._seedPrinter.printSeed(track.seed()))
952  self._seedPrinter.restoreIndent()
953  return lst
954 

References ntuplePrintersDiff.TrackPrinter._seedPrinter, ntuplePrintersDiff._IndentPrinter.restoreIndent(), and ntuplePrintersDiff._IndentPrinter.setIndentFrom().

Referenced by ntuplePrintersDiff.TrackPrinter.printTrack().

◆ printTrack()

def ntuplePrintersDiff.TrackPrinter.printTrack (   self,
  track 
)

◆ printTrackAndMatchedTrackingParticles()

def ntuplePrintersDiff.TrackPrinter.printTrackAndMatchedTrackingParticles (   self,
  track 
)

Definition at line 972 of file ntuplePrintersDiff.py.

972  def printTrackAndMatchedTrackingParticles(self, track):
973  lst = []
974  lst.extend(self.printTrack(track))
975  lst.extend(self.printMatchedTrackingParticles(track))
976  return lst
977 

References ntuplePrintersDiff._TrackingParticleMatchPrinter.printMatchedTrackingParticles(), ntuplePrintersDiff.SeedPrinter.printMatchedTrackingParticles(), ntuplePrintersDiff.TrackPrinter.printMatchedTrackingParticles(), SimHitPrinter.printTrack(), IsolatedTracksCone.printTrack(), IsolatedTracksNxN.printTrack(), and ntuplePrintersDiff.TrackPrinter.printTrack().

Referenced by ntuplePrintersDiff.TrackPrinter.__call__().

Member Data Documentation

◆ _diffForTwiki

ntuplePrintersDiff.TrackPrinter._diffForTwiki
private

◆ _hits

ntuplePrintersDiff.TrackPrinter._hits
private

◆ _seedPrinter

ntuplePrintersDiff.TrackPrinter._seedPrinter
private

◆ _trackingParticleMatchPrinter

ntuplePrintersDiff.TrackPrinter._trackingParticleMatchPrinter
private
change_name.diff
diff
Definition: change_name.py:13
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
join
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
ntuplePrintersDiff._mapdiff
def _mapdiff(func, obj1, obj2)
Definition: ntuplePrintersDiff.py:174
ntuplePrintersDiff._makediff
def _makediff(list1, list2, equalPrefix=" ")
Definition: ntuplePrintersDiff.py:167
ntuplePrintersDiff._formatHitDiffForTwiki
def _formatHitDiffForTwiki(diffHits, prefix)
Definition: ntuplePrintersDiff.py:620
ntuplePrintersDiff._hitPatternSummary
def _hitPatternSummary(hits)
Definition: ntuplePrintersDiff.py:703
format