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

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

Member Function Documentation

◆ __call__()

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

Definition at line 1230 of file ntuplePrintersDiff.py.

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

References HGCalEgammaIDHelper.printHits(), TkAccumulatingSensitiveDetector.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 1078 of file ntuplePrintersDiff.py.

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

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

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

References CommonAnalyzer._prefix, ntupleDataFormat._Object._prefix, ntupleDataFormat.BeamSpot._prefix, html.PageSet._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 1123 of file ntuplePrintersDiff.py.

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

References CommonAnalyzer._prefix, ntupleDataFormat._Object._prefix, ntupleDataFormat.BeamSpot._prefix, html.PageSet._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 1065 of file ntuplePrintersDiff.py.

1065  def _printTP(self, tp):
1066  genIds = ""
1067  if len(tp.genPdgIds()) > 0:
1068  genIds = " genPdgIds "+",".join([str(pdgId) for pdgId in tp.genPdgIds()])
1069  fromB = ""
1070  if tp.isFromBHadron():
1071  fromB = " from B hadron"
1072  return [
1073  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()),
1074  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())
1075  ]
1076 
1077 

References CommonAnalyzer._prefix, ntupleDataFormat._Object._prefix, ntupleDataFormat.BeamSpot._prefix, html.PageSet._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 1200 of file ntuplePrintersDiff.py.

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

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

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

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

1104  def printHits(self, tp):
1105  lst = []
1106  if self._hits:
1107  lst.append(self._prefix+" sim hits"+_hitPatternSummary(tp.simHits()))
1108  for simhit in tp.simHits():
1109  tmp = []
1110  for h in simhit.hits():
1111  tmp.append(",".join([str(trk.index()) for trk in h.tracks()]) + ":%d"%h.index())
1112  if len(tmp) == 0:
1113  matched = "not matched to any Track/RecHit"
1114  else:
1115  matched = "matched to Tracks:RecHits "+";".join(tmp)
1116 
1117  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))
1118  return lst
1119 

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

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

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

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

References ntuplePrintersDiff.TrackingParticlePrinter._bestMatchingTrack, CommonAnalyzer._prefix, ntupleDataFormat._Object._prefix, ntupleDataFormat.BeamSpot._prefix, html.PageSet._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 1060 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:201
join
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
ntuplePrintersDiff._mapdiff
def _mapdiff(func, obj1, obj2)
Definition: ntuplePrintersDiff.py:173
str
#define str(s)
Definition: TestProcessor.cc:53
ntuplePrintersDiff._makediff
def _makediff(list1, list2, equalPrefix=" ")
Definition: ntuplePrintersDiff.py:166
ntuplePrintersDiff._matchTracksByHits
def _matchTracksByHits(reftrk, trklist)
Definition: ntuplePrintersDiff.py:33
ntuplePrintersDiff._hitPatternSummary
def _hitPatternSummary(hits)
Definition: ntuplePrintersDiff.py:702
util.rrClient.indent
indent
Definition: rrClient.py:41
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31