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 __init__ (self, indent=0)
 
def indent (self, num)
 
def restoreIndent (self)
 
def setIndentFrom (self, printer, adjust=0)
 

Private Attributes

 _diffForTwiki
 
 _hits
 
 _seedPrinter
 
 _trackingParticleMatchPrinter
 

Detailed Description

Definition at line 895 of file ntuplePrintersDiff.py.

Constructor & Destructor Documentation

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

Definition at line 896 of file ntuplePrintersDiff.py.

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

Member Function Documentation

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

Definition at line 976 of file ntuplePrintersDiff.py.

References ntuplePrintersDiff.TrackPrinter.printTrackAndMatchedTrackingParticles().

976  def __call__(self, track, out=sys.stdout):
977  if isinstance(out, list):
978  lst = out
979  else:
980  lst = []
981 
982  lst.extend(self.printTrackAndMatchedTrackingParticles(track))
983 
984  if not isinstance(out, list):
985  for line in lst:
986  out.write(line)
987  out.write("\n")
988 
def printTrackAndMatchedTrackingParticles(self, track)
def __call__(self, track, out=sys.stdout)
def ntuplePrintersDiff.TrackPrinter.diff (   self,
  track1,
  track2,
  diffTrackingParticles = True 
)

Definition at line 989 of file ntuplePrintersDiff.py.

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, html.PageSet._prefix, ntupleDataFormat.BeamSpot._prefix, ntuplePrintersDiff._IndentPrinter._prefix, ntuplePrintersDiff.TrackPrinter.diffSeeds(), L1GctLut< NAddressBits, NDataBits >.printHeader(), EcalSelectiveReadout.printHeader(), FastTimerService.printHeader(), ntuplePrintersDiff.SeedPrinter.printHeader(), ntuplePrintersDiff.TrackPrinter.printHeader(), HGCalEgammaIDHelper.printHits(), TkAccumulatingSensitiveDetector.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().

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

Definition at line 953 of file ntuplePrintersDiff.py.

References ntuplePrintersDiff.TrackPrinter._diffForTwiki, and ntuplePrintersDiff.TrackPrinter._seedPrinter.

Referenced by ntuplePrintersDiff.TrackPrinter.diff().

953  def diffSeeds(self, track1, track2):
954  ret = _DiffResult()
955  if self._seedPrinter:
956  self._seedPrinter.setIndentFrom(self, adjust=1)
957  ret.extend(self._seedPrinter.diff(track1.seed(), track2.seed(), self._diffForTwiki))
958  self._seedPrinter.restoreIndent()
959  return ret
960 
def diffSeeds(self, track1, track2)
def ntuplePrintersDiff.TrackPrinter.printHeader (   self,
  track 
)

Definition at line 903 of file ntuplePrintersDiff.py.

References CommonAnalyzer._prefix, ntupleDataFormat._Object._prefix, html.PageSet._prefix, ntupleDataFormat.BeamSpot._prefix, ntuplePrintersDiff._IndentPrinter._prefix, and join().

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

903  def printHeader(self, track):
904  lst = []
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()))
906 
907  hp = "loose"
908  if track.isHP():
909  hp = "HP"
910 
911  algo = track.algo()
912  oriAlgo = track.originalAlgo()
913  algos = []
914  algoMask = track.algoMask()
915  for i in xrange(Algo.algoSize):
916  if algoMask & 1:
917  algos.append(Algo.toString(i))
918  algoMask = algoMask >> 1
919  algoMaskStr = ""
920  if len(algos) >= 2:
921  algoMaskStr = " algoMask "+",".join(algos)
922 
923 
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  bestTP = track.bestMatchingTrackingParticle()
929  if bestTP:
930  lst.append(self._prefix+" best-matching TP %d" % bestTP.index())
931  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()))
932  lst.append(self._prefix+" matching chi2/ndof %f" % track.bestMatchingTrackingParticleNormalizedChi2())
933  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()))
934  return lst
935 
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def ntuplePrintersDiff.TrackPrinter.printHits (   self,
  track 
)

Definition at line 936 of file ntuplePrintersDiff.py.

References ntuplePrintersDiff._hitPatternSummary(), FP420HitsObject._hits, TrackerHitsObject._hits, DTBtiChip._hits, ntuplePrintersDiff.SeedPrinter._hits, ntuplePrintersDiff.TrackPrinter._hits, CommonAnalyzer._prefix, ntupleDataFormat._Object._prefix, html.PageSet._prefix, ntupleDataFormat.BeamSpot._prefix, ntuplePrintersDiff._IndentPrinter._prefix, ntuplePrintersDiff._RecHitPrinter._printHits(), Mixins.PrintOptions.indent(), FWLayoutBuilder.indent(), edm::DocFormatHelper.indent(), Json::StyledWriter.indent(), FWDialogBuilder.indent(), edm::service::ELdestination.indent, Json::StyledStreamWriter.indent(), JsonOutputProducer.indent(), ntuplePrintersDiff._IndentPrinter.indent(), and ntuplePrintersDiff._IndentPrinter.restoreIndent().

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

936  def printHits(self, track):
937  lst = []
938  if self._hits:
939  lst.append(self._prefix+" hits"+_hitPatternSummary(track.hits()))
940  self.indent(2)
941  lst.extend(self._printHits(track.hits()))
942  self.restoreIndent()
943  return lst
944 
def ntuplePrintersDiff.TrackPrinter.printMatchedTrackingParticles (   self,
  track 
)
def ntuplePrintersDiff.TrackPrinter.printSeed (   self,
  track 
)

Definition at line 945 of file ntuplePrintersDiff.py.

References ntuplePrintersDiff.TrackPrinter._seedPrinter.

Referenced by ntuplePrintersDiff.TrackPrinter.printTrack().

945  def printSeed(self, track):
946  lst = []
947  if self._seedPrinter:
948  self._seedPrinter.setIndentFrom(self, adjust=1)
949  lst.extend(self._seedPrinter.printSeed(track.seed()))
950  self._seedPrinter.restoreIndent()
951  return lst
952 
def ntuplePrintersDiff.TrackPrinter.printTrack (   self,
  track 
)
def ntuplePrintersDiff.TrackPrinter.printTrackAndMatchedTrackingParticles (   self,
  track 
)

Member Data Documentation

ntuplePrintersDiff.TrackPrinter._diffForTwiki
private
ntuplePrintersDiff.TrackPrinter._hits
private
ntuplePrintersDiff.TrackPrinter._seedPrinter
private
ntuplePrintersDiff.TrackPrinter._trackingParticleMatchPrinter
private

Definition at line 900 of file ntuplePrintersDiff.py.