CMS 3D CMS Logo

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

Public Member Functions

def __call__ (self, tp, out=sys.stdout)
 
def __init__ (self, indent=0, parentage=True, hits=True, tracks=True, trackPrinter=None, bestMatchingTrack=True, seedPrinter=SeedPrinter())
 
def diff (self, tp1, tp2)
 
def diffMatchedSeeds (self, tp1, tp2)
 
def diffMatchedTracks (self, tp1, tp2)
 
def printHits (self, tp)
 
def printMatchedSeeds (self, tp)
 
def printMatchedTracks (self, tp, useTrackPrinter=True)
 
def printTrackingParticle (self, tp)
 
- 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 Member Functions

def _parentageChain (self, tp)
 
def _printMatchedSeeds0 (self)
 
def _printMatchedSeedsHeader (self)
 
def _printMatchedTracks (self, tracks, header=None, useTrackPrinter=True)
 
def _printMatchedTracksHeader (self)
 
def _printTP (self, tp)
 

Private Attributes

 _bestMatchingTrack
 
 _hits
 
 _parentage
 
 _seedPrinter
 
 _trackPrinter
 
 _tracks
 

Detailed Description

Definition at line 1056 of file ntuplePrintersDiff.py.

Constructor & Destructor Documentation

◆ __init__()

def ntuplePrintersDiff.TrackingParticlePrinter.__init__ (   self,
  indent = 0,
  parentage = True,
  hits = True,
  tracks = True,
  trackPrinter = None,
  bestMatchingTrack = True,
  seedPrinter = SeedPrinter() 
)

Definition at line 1057 of file ntuplePrintersDiff.py.

1057  def __init__(self, indent=0, parentage=True, hits=True, tracks=True, trackPrinter=None, bestMatchingTrack=True, seedPrinter=SeedPrinter()):
1058  super(TrackingParticlePrinter, self).__init__(indent)
1059  self._parentage = parentage
1060  self._hits = hits
1061  self._tracks = tracks
1062  self._trackPrinter = trackPrinter
1063  self._bestMatchingTrack = bestMatchingTrack
1064  self._seedPrinter = seedPrinter
1065 

Member Function Documentation

◆ __call__()

def ntuplePrintersDiff.TrackingParticlePrinter.__call__ (   self,
  tp,
  out = sys.stdout 
)

Definition at line 1231 of file ntuplePrintersDiff.py.

1231  def __call__(self, tp, out=sys.stdout):
1232  if isinstance(out, list):
1233  lst = out
1234  else:
1235  lst = []
1236 
1237  lst.extend(self.printTrackingParticle(tp))
1238  lst.extend(self.printHits(tp))
1239  lst.extend(self.printMatchedTracks(tp))
1240  lst.extend(self.printMatchedSeeds(tp))
1241 
1242  for line in lst:
1243  out.write(line)
1244  out.write("\n")
1245 

References TkAccumulatingSensitiveDetector.printHits, HGCalEgammaIDHelper.printHits(), hgcal::EGammaPCAHelper.printHits(), MuonSensitiveDetector.printHits, GlobalTrajectoryBuilderBase.printHits(), GlobalMuonRefitter.printHits(), ntuplePrintersDiff.SeedPrinter.printHits(), ntuplePrintersDiff.TrackPrinter.printHits(), ntuplePrintersDiff.TrackingParticlePrinter.printHits(), ntuplePrintersDiff.TrackingParticlePrinter.printMatchedSeeds(), ntuplePrintersDiff.TrackingParticlePrinter.printMatchedTracks(), and ntuplePrintersDiff.TrackingParticlePrinter.printTrackingParticle().

◆ _parentageChain()

def ntuplePrintersDiff.TrackingParticlePrinter._parentageChain (   self,
  tp 
)
private

Definition at line 1079 of file ntuplePrintersDiff.py.

1079  def _parentageChain(self, tp):
1080  lst = []
1081  prodVtx = tp.parentVertex()
1082  if prodVtx.nSourceTrackingParticles() == 1:
1083  lst.extend(self._printTP(next(prodVtx.sourceTrackingParticles())))
1084  elif prodVtx.nSourceTrackingParticles() >= 2:
1085  self.indent(1)
1086  for tp in prodVtx.sourceTrackingParticles():
1087  self._printTP(tp, out)
1088  self.indent(1)
1089  lst.extend(self._parentageChain(tp))
1090  self.indent(-1)
1091  self.indent(-1)
1092  return lst
1093 

References ntuplePrintersDiff.TrackingParticlePrinter._parentageChain(), ntuplePrintersDiff.TrackingParticlePrinter._printTP(), 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 GetRecoTauVFromDQM_MC_cff.next.

Referenced by ntuplePrintersDiff.TrackingParticlePrinter._parentageChain(), and ntuplePrintersDiff.TrackingParticlePrinter.printTrackingParticle().

◆ _printMatchedSeeds0()

def ntuplePrintersDiff.TrackingParticlePrinter._printMatchedSeeds0 (   self)
private

Definition at line 1182 of file ntuplePrintersDiff.py.

1182  def _printMatchedSeeds0(self):
1183  return [self._prefix+ " not matched to any seed"]
1184 

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

Referenced by ntuplePrintersDiff.TrackingParticlePrinter.printMatchedSeeds().

◆ _printMatchedSeedsHeader()

def ntuplePrintersDiff.TrackingParticlePrinter._printMatchedSeedsHeader (   self)
private

◆ _printMatchedTracks()

def ntuplePrintersDiff.TrackingParticlePrinter._printMatchedTracks (   self,
  tracks,
  header = None,
  useTrackPrinter = True 
)
private

Definition at line 1124 of file ntuplePrintersDiff.py.

1124  def _printMatchedTracks(self, tracks, header=None, useTrackPrinter=True):
1125  lst = []
1126  if header is not None:
1127  lst.append(self._prefix+" "+header)
1128  else:
1129  lst.extend(self._printMatchedTracksHeader())
1130  if self._trackPrinter is None or not useTrackPrinter:
1131  lst[-1] += " "+",".join([str(track.index()) for track in tracks])
1132  else:
1133  self._trackPrinter.indent(2)
1134  for track in tracks:
1135  lst.extend(self._trackPrinter.printTrack(track))
1136  self._trackPrinter.restoreIndent()
1137  return lst
1138 

References CommonAnalyzer._prefix, ntupleDataFormat._Object._prefix, html.PageSet._prefix, ntupleDataFormat.BeamSpot._prefix, ntuplePrintersDiff._IndentPrinter._prefix, ntuplePrintersDiff.TrackingParticlePrinter._printMatchedTracksHeader(), ntuplePrintersDiff.TrackingParticlePrinter._trackPrinter, ntuplePrintersDiff._IndentPrinter.indent(), join(), ntuplePrintersDiff._IndentPrinter.restoreIndent(), and str.

Referenced by ntuplePrintersDiff.TrackingParticlePrinter.printMatchedTracks().

◆ _printMatchedTracksHeader()

def ntuplePrintersDiff.TrackingParticlePrinter._printMatchedTracksHeader (   self)
private

◆ _printTP()

def ntuplePrintersDiff.TrackingParticlePrinter._printTP (   self,
  tp 
)
private

Definition at line 1066 of file ntuplePrintersDiff.py.

1066  def _printTP(self, tp):
1067  genIds = ""
1068  if len(tp.genPdgIds()) > 0:
1069  genIds = " genPdgIds "+",".join([str(pdgId) for pdgId in tp.genPdgIds()])
1070  fromB = ""
1071  if tp.isFromBHadron():
1072  fromB = " from B hadron"
1073  return [
1074  self._prefix+"TP %d pdgId %d%s%s ev:bx %d:%d pT %f eta %f phi %f" % (tp.index(), tp.pdgId(), genIds, fromB, tp.event(), tp.bunchCrossing(), tp.pt(), tp.eta(), tp.phi()),
1075  self._prefix+" pixel hits %d strip hits %d numberOfTrackerHits() %d associated reco clusters %d dxy %f dz %f" % (tp.nPixel(), tp.nStrip(), tp.nTrackerHits(), tp.nRecoClusters(), tp.pca_dxy(), tp.pca_dz())
1076  ]
1077 
1078 

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

Referenced by ntuplePrintersDiff.TrackingParticlePrinter._parentageChain(), and ntuplePrintersDiff.TrackingParticlePrinter.printTrackingParticle().

◆ diff()

def ntuplePrintersDiff.TrackingParticlePrinter.diff (   self,
  tp1,
  tp2 
)

◆ diffMatchedSeeds()

def ntuplePrintersDiff.TrackingParticlePrinter.diffMatchedSeeds (   self,
  tp1,
  tp2 
)

Definition at line 1201 of file ntuplePrintersDiff.py.

1201  def diffMatchedSeeds(self, tp1, tp2):
1202  if not self._seedPrinter:
1203  return []
1204 
1205  nseed1 = tp1.nMatchedSeeds()
1206  nseed2 = tp2.nMatchedSeeds()
1207  if nseed1 == 0 or nseed2 == 0:
1208  return _makediff(self.printMatchedSeeds(tp1), self.printMatchedSeeds(tp2))
1209 
1210  self._seedPrinter.setIndentFrom(self, adjust=2)
1211 
1212  diff = _makediff(self._printMatchedSeedsHeader(), self._printMatchedSeedsHeader())
1213  seeds2 = [seedInfo2.seed() for seedInfo2 in tp2.matchedSeedInfos()]
1214  for seedInfo1 in tp1.matchedSeedInfos():
1215  seed1 = seedInfo1.seed()
1216  matchedSeed2 = _matchTracksByHits(seed1, seeds2)[0]
1217 
1218  if matchedSeed2 is None: # no more seeds in tp2
1219  diff.extend(_makediff(self._seedPrinter.printSeed(seed1), []))
1220  else: # diff seed1 to best-matching seed from tp2
1221  seeds2.remove(matchedSeed2)
1222  diff.extend(_makediff(self._seedPrinter.printSeed(seed1), self._seedPrinter.printSeed(matchedSeed2)))
1223 
1224  for seed2 in seeds2: # remiaining seeds in tp2
1225  diff.extend(_makediff([], self._seedPrinter.printSeed(seed2)))
1226 
1227  self._seedPrinter.restoreIndent()
1228 
1229  return diff
1230 

References ntuplePrintersDiff._makediff(), ntuplePrintersDiff._matchTracksByHits(), ntuplePrintersDiff.TrackingParticlePrinter._printMatchedSeedsHeader(), ntuplePrintersDiff.TrackPrinter._seedPrinter, ntuplePrintersDiff.TrackingParticlePrinter._seedPrinter, ntuplePrintersDiff.TrackingParticlePrinter.printMatchedSeeds(), ntuplePrintersDiff._IndentPrinter.restoreIndent(), and ntuplePrintersDiff._IndentPrinter.setIndentFrom().

Referenced by ntuplePrintersDiff.TrackingParticlePrinter.diff().

◆ diffMatchedTracks()

def ntuplePrintersDiff.TrackingParticlePrinter.diffMatchedTracks (   self,
  tp1,
  tp2 
)

Definition at line 1153 of file ntuplePrintersDiff.py.

1153  def diffMatchedTracks(self, tp1, tp2):
1154  ntrk1 = tp1.nMatchedTracks()
1155  ntrk2 = tp2.nMatchedTracks()
1156 
1157  if ntrk1 == 0 or ntrk2 == 0 or self._trackPrinter is None:
1158  return _makediff(self.printMatchedTracks(tp1), self.printMatchedTracks(tp2))
1159 
1160  self._trackPrinter.indent(2)
1161 
1162  diff = _makediff(self._printMatchedTracksHeader(), self._printMatchedTracksHeader())
1163  trks1 = [trkInfo1.track() for trkInfo1 in tp1.matchedTrackInfos()]
1164  trks2 = [trkInfo2.track() for trkInfo2 in tp2.matchedTrackInfos()]
1165  #for trkInfo1 in tp1.matchedTrackInfos():
1166  # trk1 = trkInfo1.track()
1167  # matchedTrk2 = _matchTracksByHits(trk1, trks2)
1168  #
1169  # if matchedTrk2 is None: # no more tracks in tp2
1170  # diff.extend(_makediff(self._trackPrinter.printTrack(trk1), []))
1171  # else: # diff trk1 to best-matching track from tp2
1172  # trks2.remove(matchedTrk2)
1173  # diff.extend(self._trackPrinter.diff(trk1, matchedTrk2))
1174  #
1175  #for trk2 in trks2: # remaining tracks in tp2
1176  # diff.extend(_makediff([], self._trackPrinter.printTrack(trk2)))
1177  diff.extend(diffTrackListsFromSameTrackingParticle(self._trackPrinter, trks1, trks2))
1178 
1179  self._trackPrinter.restoreIndent()
1180  return diff
1181 

References ntuplePrintersDiff._makediff(), ntuplePrintersDiff.TrackingParticlePrinter._printMatchedTracksHeader(), ntuplePrintersDiff.TrackingParticlePrinter._trackPrinter, ntuplePrintersDiff.diffTrackListsFromSameTrackingParticle(), ntuplePrintersDiff._IndentPrinter.indent(), ntuplePrintersDiff.TrackingParticlePrinter.printMatchedTracks(), and ntuplePrintersDiff._IndentPrinter.restoreIndent().

Referenced by ntuplePrintersDiff.TrackingParticlePrinter.diff().

◆ printHits()

def ntuplePrintersDiff.TrackingParticlePrinter.printHits (   self,
  tp 
)

Definition at line 1105 of file ntuplePrintersDiff.py.

1105  def printHits(self, tp):
1106  lst = []
1107  if self._hits:
1108  lst.append(self._prefix+" sim hits"+_hitPatternSummary(tp.simHits()))
1109  for simhit in tp.simHits():
1110  tmp = []
1111  for h in simhit.hits():
1112  tmp.append(",".join([str(trk.index()) for trk in h.tracks()]) + ":%d"%h.index())
1113  if len(tmp) == 0:
1114  matched = "not matched to any Track/RecHit"
1115  else:
1116  matched = "matched to Tracks:RecHits "+";".join(tmp)
1117 
1118  lst.append(self._prefix+" %s %d pdgId %d process %d detId %d %s x,y,z %f,%f,%f %s" % (simhit.layerStr(), simhit.index(), simhit.particle(), simhit.process(), simhit.detId(), simhit.detIdStr(), simhit.x(), simhit.y(), simhit.z(), matched))
1119  return lst
1120 

References ntuplePrintersDiff._hitPatternSummary(), FP420HitsObject._hits, TrackerHitsObject._hits, DTBtiChip._hits, ntuplePrintersDiff.SeedPrinter._hits, ntuplePrintersDiff.TrackPrinter._hits, ntuplePrintersDiff.TrackingParticlePrinter._hits, CommonAnalyzer._prefix, ntupleDataFormat._Object._prefix, html.PageSet._prefix, ntupleDataFormat.BeamSpot._prefix, ntuplePrintersDiff._IndentPrinter._prefix, join(), and str.

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

◆ printMatchedSeeds()

def ntuplePrintersDiff.TrackingParticlePrinter.printMatchedSeeds (   self,
  tp 
)

Definition at line 1188 of file ntuplePrintersDiff.py.

1188  def printMatchedSeeds(self, tp):
1189  lst = []
1190  if self._seedPrinter:
1191  if tp.nMatchedSeeds() == 0:
1192  lst.extend(self._printMatchedSeeds0())
1193  else:
1194  lst.extend(self._printMatchedSeedsHeader())
1195  self._seedPrinter.setIndentFrom(self, adjust=2)
1196  for seedInfo in tp.matchedSeedInfos():
1197  lst.extend(self._seedPrinter.printSeed(seedInfo.seed()))
1198  self._seedPrinter.restoreIndent()
1199  return lst
1200 

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

Referenced by ntuplePrintersDiff.TrackingParticlePrinter.__call__(), and ntuplePrintersDiff.TrackingParticlePrinter.diffMatchedSeeds().

◆ printMatchedTracks()

def ntuplePrintersDiff.TrackingParticlePrinter.printMatchedTracks (   self,
  tp,
  useTrackPrinter = True 
)

Definition at line 1139 of file ntuplePrintersDiff.py.

1139  def printMatchedTracks(self, tp, useTrackPrinter=True):
1140  lst = []
1141  if tp.nMatchedTracks() == 0:
1142  header = "not matched to any track"
1143  lst.append(self._prefix+" "+header)
1144  if self._bestMatchingTrack:
1145  bestTrack = tp.bestMatchingTrack()
1146  if bestTrack is not None:
1147  lst.pop()
1148  lst.extend(self._printMatchedTracks([bestTrack], header+", but a following track with >= 3 matched hits is found", useTrackPrinter=useTrackPrinter))
1149  else:
1150  lst.extend(self._printMatchedTracks([trkInfo.track() for trkInfo in tp.matchedTrackInfos()], useTrackPrinter=useTrackPrinter))
1151  return lst
1152 

References ntuplePrintersDiff.TrackingParticlePrinter._bestMatchingTrack, CommonAnalyzer._prefix, ntupleDataFormat._Object._prefix, html.PageSet._prefix, ntupleDataFormat.BeamSpot._prefix, ntuplePrintersDiff._IndentPrinter._prefix, and ntuplePrintersDiff.TrackingParticlePrinter._printMatchedTracks().

Referenced by ntuplePrintersDiff.TrackingParticlePrinter.__call__(), and ntuplePrintersDiff.TrackingParticlePrinter.diffMatchedTracks().

◆ printTrackingParticle()

def ntuplePrintersDiff.TrackingParticlePrinter.printTrackingParticle (   self,
  tp 
)

Member Data Documentation

◆ _bestMatchingTrack

ntuplePrintersDiff.TrackingParticlePrinter._bestMatchingTrack
private

◆ _hits

ntuplePrintersDiff.TrackingParticlePrinter._hits
private

◆ _parentage

ntuplePrintersDiff.TrackingParticlePrinter._parentage
private

◆ _seedPrinter

ntuplePrintersDiff.TrackingParticlePrinter._seedPrinter
private

◆ _trackPrinter

ntuplePrintersDiff.TrackingParticlePrinter._trackPrinter
private

◆ _tracks

ntuplePrintersDiff.TrackingParticlePrinter._tracks
private

Definition at line 1061 of file ntuplePrintersDiff.py.

change_name.diff
diff
Definition: change_name.py:13
ntuplePrintersDiff.diffTrackListsFromSameTrackingParticle
def diffTrackListsFromSameTrackingParticle(trackPrinter, lst1, lst2, lst1extra=[], lst2extra=[], diffByHitsOnly=False)
Definition: ntuplePrintersDiff.py:202
join
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
ntuplePrintersDiff._mapdiff
def _mapdiff(func, obj1, obj2)
Definition: ntuplePrintersDiff.py:174
str
#define str(s)
Definition: TestProcessor.cc:51
ntuplePrintersDiff._makediff
def _makediff(list1, list2, equalPrefix=" ")
Definition: ntuplePrintersDiff.py:167
ntuplePrintersDiff._matchTracksByHits
def _matchTracksByHits(reftrk, trklist)
Definition: ntuplePrintersDiff.py:34
ntuplePrintersDiff._hitPatternSummary
def _hitPatternSummary(hits)
Definition: ntuplePrintersDiff.py:703
util.rrClient.indent
indent
Definition: rrClient.py:41
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31