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 973 of file ntuplePrintersDiff.py.

References ntuplePrintersDiff.TrackPrinter.printTrackAndMatchedTrackingParticles().

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

Definition at line 986 of file ntuplePrintersDiff.py.

References ntuplePrintersDiff.TrackPrinter._diffForTwiki, ntuplePrintersDiff._formatHitDiffForTwiki(), FP420HitsObject._hits, TrackerHitsObject._hits, SortingOutput._hits, MatchingOutput._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(), TkAccumulatingSensitiveDetector.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().

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

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

Referenced by ntuplePrintersDiff.TrackPrinter.diff().

950  def diffSeeds(self, track1, track2):
951  ret = _DiffResult()
952  if self._seedPrinter:
953  self._seedPrinter.setIndentFrom(self, adjust=1)
954  ret.extend(self._seedPrinter.diff(track1.seed(), track2.seed(), self._diffForTwiki))
955  self._seedPrinter.restoreIndent()
956  return ret
957 
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  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()))
931  return lst
932 
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def ntuplePrintersDiff.TrackPrinter.printHits (   self,
  track 
)

Definition at line 933 of file ntuplePrintersDiff.py.

References ntuplePrintersDiff._hitPatternSummary(), TrackerHitsObject._hits, FP420HitsObject._hits, SortingOutput._hits, MatchingOutput._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().

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

Definition at line 942 of file ntuplePrintersDiff.py.

References ntuplePrintersDiff.TrackPrinter._seedPrinter.

Referenced by ntuplePrintersDiff.TrackPrinter.printTrack().

942  def printSeed(self, track):
943  lst = []
944  if self._seedPrinter:
945  self._seedPrinter.setIndentFrom(self, adjust=1)
946  lst.extend(self._seedPrinter.printSeed(track.seed()))
947  self._seedPrinter.restoreIndent()
948  return lst
949 
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.