CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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__
 
def __init__
 
def diff
 
def diffSeeds
 
def printHeader
 
def printHits
 
def printMatchedTrackingParticles
 
def printSeed
 
def printTrack
 
def printTrackAndMatchedTrackingParticles
 
- Public Member Functions inherited from ntuplePrintersDiff._RecHitPrinter
def __init__
 
- Public Member Functions inherited from ntuplePrintersDiff._IndentPrinter
def __init__
 
def indent
 
def restoreIndent
 
def setIndentFrom
 

Private Attributes

 _diffForTwiki
 
 _hits
 
 _seedPrinter
 
 _trackingParticleMatchPrinter
 

Detailed Description

Definition at line 896 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 897 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

Member Function Documentation

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

Definition at line 977 of file ntuplePrintersDiff.py.

References ntuplePrintersDiff.TrackPrinter.printTrackAndMatchedTrackingParticles().

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")
def ntuplePrintersDiff.TrackPrinter.diff (   self,
  track1,
  track2,
  diffTrackingParticles = True 
)

Definition at line 990 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, 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(), HGCalEgammaIDHelper.printHits(), TkAccumulatingSensitiveDetector.printHits, hgcal::EGammaPCAHelper.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().

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
def ntuplePrintersDiff.TrackPrinter.diffSeeds (   self,
  track1,
  track2 
)

Definition at line 954 of file ntuplePrintersDiff.py.

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

Referenced by ntuplePrintersDiff.TrackPrinter.diff().

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
def ntuplePrintersDiff.TrackPrinter.printHeader (   self,
  track 
)

Definition at line 904 of file ntuplePrintersDiff.py.

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

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

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
const uint16_t range(const Frame &aFrame)
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
def ntuplePrintersDiff.TrackPrinter.printHits (   self,
  track 
)

Definition at line 937 of file ntuplePrintersDiff.py.

References ntuplePrintersDiff._hitPatternSummary(), FP420HitsObject._hits, TrackerHitsObject._hits, DTBtiChip._hits, ntuplePrintersDiff.SeedPrinter._hits, ntuplePrintersDiff.TrackPrinter._hits, CommonAnalyzer._prefix, ntupleDataFormat._Object._prefix, ntupleDataFormat.BeamSpot._prefix, html.PageSet._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().

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

Definition at line 968 of file ntuplePrintersDiff.py.

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

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

969  def printMatchedTrackingParticles(self, track):
970  return self._trackingParticleMatchPrinter.printMatchedTrackingParticles(self._prefix, track)
def ntuplePrintersDiff.TrackPrinter.printSeed (   self,
  track 
)

Definition at line 946 of file ntuplePrintersDiff.py.

References ntuplePrintersDiff.TrackPrinter._seedPrinter.

Referenced by ntuplePrintersDiff.TrackPrinter.printTrack().

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
def ntuplePrintersDiff.TrackPrinter.printTrack (   self,
  track 
)

Definition at line 962 of file ntuplePrintersDiff.py.

References L1GctLut< NAddressBits, NDataBits >.printHeader(), EcalSelectiveReadout.printHeader(), FastTimerService.printHeader(), ntuplePrintersDiff.SeedPrinter.printHeader(), ntuplePrintersDiff.TrackPrinter.printHeader(), HGCalEgammaIDHelper.printHits(), TkAccumulatingSensitiveDetector.printHits, hgcal::EGammaPCAHelper.printHits(), GlobalTrajectoryBuilderBase.printHits(), GlobalMuonRefitter.printHits(), ntuplePrintersDiff.SeedPrinter.printHits(), ntuplePrintersDiff.TrackPrinter.printHits(), ntuplePrintersDiff.SeedPrinter.printSeed(), and ntuplePrintersDiff.TrackPrinter.printSeed().

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

963  def printTrack(self, track):
964  lst = self.printHeader(track)
965  lst.extend(self.printHits(track))
966  lst.extend(self.printSeed(track))
967  return lst
def ntuplePrintersDiff.TrackPrinter.printTrackAndMatchedTrackingParticles (   self,
  track 
)

Definition at line 971 of file ntuplePrintersDiff.py.

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__().

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

Member Data Documentation

ntuplePrintersDiff.TrackPrinter._diffForTwiki
private

Definition at line 902 of file ntuplePrintersDiff.py.

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

ntuplePrintersDiff.TrackPrinter._hits
private

Definition at line 899 of file ntuplePrintersDiff.py.

Referenced by ntuplePrintersDiff.TrackPrinter.diff(), ntupleDataFormat._RecoHitAdaptor.gluedHits(), ntupleDataFormat._RecoHitAdaptor.hits(), ntupleDataFormat._RecoHitAdaptor.invalidHits(), ntupleDataFormat._RecoHitAdaptor.phase2OTHits(), ntupleDataFormat._RecoHitAdaptor.pixelHits(), ntuplePrintersDiff.TrackPrinter.printHits(), ntuplePrintersDiff.TrackingParticlePrinter.printHits(), and ntupleDataFormat._RecoHitAdaptor.stripHits().

ntuplePrintersDiff.TrackPrinter._seedPrinter
private

Definition at line 900 of file ntuplePrintersDiff.py.

Referenced by ntuplePrintersDiff.TrackingParticlePrinter.diffMatchedSeeds(), ntuplePrintersDiff.TrackPrinter.diffSeeds(), ntuplePrintersDiff.TrackingParticlePrinter.printMatchedSeeds(), and ntuplePrintersDiff.TrackPrinter.printSeed().

ntuplePrintersDiff.TrackPrinter._trackingParticleMatchPrinter
private

Definition at line 901 of file ntuplePrintersDiff.py.