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

897  def __init__(self, indent=0, hits=True, seedPrinter=SeedPrinter(), trackingParticles=True, trackingParticlePrinter=None, bestMatchingTrackingParticle=True, diffForTwiki=False):
898  super(TrackPrinter, self).__init__(indent)
899  self._hits = hits
900  self._seedPrinter = seedPrinter
901  self._trackingParticleMatchPrinter = _TrackingParticleMatchPrinter(trackingParticles, trackingParticlePrinter, bestMatchingTrackingParticle)
902  self._diffForTwiki = diffForTwiki
903 
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)

Member Function Documentation

◆ __call__()

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

Definition at line 977 of file ntuplePrintersDiff.py.

References ntuplePrintersDiff.TrackPrinter.printTrackAndMatchedTrackingParticles().

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

◆ diff()

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

Definition at line 990 of file ntuplePrintersDiff.py.

References ntuplePrintersDiff.TrackPrinter._diffForTwiki, ntuplePrintersDiff._formatHitDiffForTwiki(), TrackerHitsObject._hits, FP420HitsObject._hits, DTBtiChip._hits, ntuplePrintersDiff.SeedPrinter._hits, ntuplePrintersDiff.TrackPrinter._hits, ntuplePrintersDiff._makediff(), ntuplePrintersDiff._mapdiff(), CommonAnalyzer._prefix, ntupleDataFormat._Object._prefix, datamodel.Object._prefix, datamodel.Collection._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().

Referenced by ntuplePrintersDiff.TrackPrinter.diffSeeds().

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

◆ diffSeeds()

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

Definition at line 954 of file ntuplePrintersDiff.py.

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

Referenced by ntuplePrintersDiff.TrackPrinter.diff().

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

◆ printHeader()

def ntuplePrintersDiff.TrackPrinter.printHeader (   self,
  track 
)

Definition at line 904 of file ntuplePrintersDiff.py.

References CommonAnalyzer._prefix, ntupleDataFormat._Object._prefix, datamodel.Object._prefix, datamodel.Collection._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().

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

◆ printHits()

def ntuplePrintersDiff.TrackPrinter.printHits (   self,
  track 
)

◆ printMatchedTrackingParticles()

def ntuplePrintersDiff.TrackPrinter.printMatchedTrackingParticles (   self,
  track 
)

◆ printSeed()

def ntuplePrintersDiff.TrackPrinter.printSeed (   self,
  track 
)

Definition at line 946 of file ntuplePrintersDiff.py.

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

Referenced by ntuplePrintersDiff.TrackPrinter.printTrack().

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

◆ printTrack()

def ntuplePrintersDiff.TrackPrinter.printTrack (   self,
  track 
)

◆ printTrackAndMatchedTrackingParticles()

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

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

Member Data Documentation

◆ _diffForTwiki

ntuplePrintersDiff.TrackPrinter._diffForTwiki
private

◆ _hits

ntuplePrintersDiff.TrackPrinter._hits
private

◆ _seedPrinter

ntuplePrintersDiff.TrackPrinter._seedPrinter
private

◆ _trackingParticleMatchPrinter

ntuplePrintersDiff.TrackPrinter._trackingParticleMatchPrinter
private