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 Member Functions | Private Attributes
ntuplePrintersDiff.TrackingParticlePrinter Class Reference
Inheritance diagram for ntuplePrintersDiff.TrackingParticlePrinter:
ntuplePrintersDiff._IndentPrinter

Public Member Functions

def __call__
 
def __init__
 
def diff
 
def diffMatchedSeeds
 
def diffMatchedTracks
 
def printHits
 
def printMatchedSeeds
 
def printMatchedTracks
 
def printTrackingParticle
 
- Public Member Functions inherited from ntuplePrintersDiff._IndentPrinter
def __init__
 
def indent
 
def restoreIndent
 
def setIndentFrom
 

Private Member Functions

def _parentageChain
 
def _printMatchedSeeds0
 
def _printMatchedSeedsHeader
 
def _printMatchedTracks
 
def _printMatchedTracksHeader
 
def _printTP
 

Private Attributes

 _bestMatchingTrack
 
 _hits
 
 _parentage
 
 _seedPrinter
 
 _trackPrinter
 
 _tracks
 

Detailed Description

Definition at line 1055 of file ntuplePrintersDiff.py.

Constructor & Destructor Documentation

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.

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

Member Function Documentation

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

Definition at line 1230 of file ntuplePrintersDiff.py.

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

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")
def ntuplePrintersDiff.TrackingParticlePrinter._parentageChain (   self,
  tp 
)
private

Definition at line 1078 of file ntuplePrintersDiff.py.

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

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
def ntuplePrintersDiff.TrackingParticlePrinter._printMatchedSeeds0 (   self)
private

Definition at line 1181 of file ntuplePrintersDiff.py.

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

Referenced by ntuplePrintersDiff.TrackingParticlePrinter.printMatchedSeeds().

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

Definition at line 1184 of file ntuplePrintersDiff.py.

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

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

1185  def _printMatchedSeedsHeader(self):
1186  return [self._prefix+" matched to seeds"]
def ntuplePrintersDiff.TrackingParticlePrinter._printMatchedTracks (   self,
  tracks,
  header = None,
  useTrackPrinter = True 
)
private

Definition at line 1123 of file ntuplePrintersDiff.py.

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

Referenced by ntuplePrintersDiff.TrackingParticlePrinter.printMatchedTracks().

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
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
#define str(s)
def ntuplePrintersDiff.TrackingParticlePrinter._printMatchedTracksHeader (   self)
private

Definition at line 1120 of file ntuplePrintersDiff.py.

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

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

1121  def _printMatchedTracksHeader(self):
1122  return [self._prefix+" matched to tracks"]
def ntuplePrintersDiff.TrackingParticlePrinter._printTP (   self,
  tp 
)
private

Definition at line 1065 of file ntuplePrintersDiff.py.

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

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 
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
#define str(s)
def ntuplePrintersDiff.TrackingParticlePrinter.diff (   self,
  tp1,
  tp2 
)

Definition at line 1245 of file ntuplePrintersDiff.py.

References ntuplePrintersDiff._mapdiff(), ntuplePrintersDiff.TrackingParticlePrinter.diffMatchedSeeds(), ntuplePrintersDiff.TrackingParticlePrinter.diffMatchedTracks(), HGCalEgammaIDHelper.printHits(), TkAccumulatingSensitiveDetector.printHits, hgcal::EGammaPCAHelper.printHits(), GlobalTrajectoryBuilderBase.printHits(), GlobalMuonRefitter.printHits(), ntuplePrintersDiff.SeedPrinter.printHits(), ntuplePrintersDiff.TrackPrinter.printHits(), ntuplePrintersDiff.TrackingParticlePrinter.printHits(), and ntuplePrintersDiff.TrackingParticlePrinter.printTrackingParticle().

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

Definition at line 1200 of file ntuplePrintersDiff.py.

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

Referenced by ntuplePrintersDiff.TrackingParticlePrinter.diff().

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 
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
def ntuplePrintersDiff.TrackingParticlePrinter.diffMatchedTracks (   self,
  tp1,
  tp2 
)

Definition at line 1152 of file ntuplePrintersDiff.py.

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

Referenced by ntuplePrintersDiff.TrackingParticlePrinter.diff().

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 
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
def ntuplePrintersDiff.TrackingParticlePrinter.printHits (   self,
  tp 
)

Definition at line 1104 of file ntuplePrintersDiff.py.

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

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
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
#define str(s)
def ntuplePrintersDiff.TrackingParticlePrinter.printMatchedSeeds (   self,
  tp 
)

Definition at line 1187 of file ntuplePrintersDiff.py.

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

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

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
def ntuplePrintersDiff.TrackingParticlePrinter.printMatchedTracks (   self,
  tp,
  useTrackPrinter = True 
)

Definition at line 1138 of file ntuplePrintersDiff.py.

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

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
def ntuplePrintersDiff.TrackingParticlePrinter.printTrackingParticle (   self,
  tp 
)

Definition at line 1093 of file ntuplePrintersDiff.py.

References ntuplePrintersDiff.TrackingParticlePrinter._parentage, ntuplePrintersDiff.TrackingParticlePrinter._parentageChain(), CommonAnalyzer._prefix, ntupleDataFormat._Object._prefix, ntupleDataFormat.BeamSpot._prefix, html.PageSet._prefix, ntuplePrintersDiff._IndentPrinter._prefix, 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(), and ntuplePrintersDiff._IndentPrinter.indent().

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

1094  def printTrackingParticle(self, tp):
1095  lst = []
1096  lst.extend(self._printTP(tp))
1097  if self._parentage:
1098  if tp.parentVertex().nSourceTrackingParticles() > 0:
1099  lst.append(self._prefix+" parentage chain")
1100  self.indent(2)
1101  lst.extend(self._parentageChain(tp))
1102  self.indent(-2)
1103  return lst

Member Data Documentation

ntuplePrintersDiff.TrackingParticlePrinter._bestMatchingTrack
private

Definition at line 1062 of file ntuplePrintersDiff.py.

Referenced by ntuplePrintersDiff.TrackingParticlePrinter.printMatchedTracks().

ntuplePrintersDiff.TrackingParticlePrinter._hits
private

Definition at line 1059 of file ntuplePrintersDiff.py.

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

ntuplePrintersDiff.TrackingParticlePrinter._parentage
private

Definition at line 1058 of file ntuplePrintersDiff.py.

Referenced by ntuplePrintersDiff.TrackingParticlePrinter.printTrackingParticle().

ntuplePrintersDiff.TrackingParticlePrinter._seedPrinter
private

Definition at line 1063 of file ntuplePrintersDiff.py.

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

ntuplePrintersDiff.TrackingParticlePrinter._trackPrinter
private

Definition at line 1061 of file ntuplePrintersDiff.py.

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

ntuplePrintersDiff.TrackingParticlePrinter._tracks
private

Definition at line 1060 of file ntuplePrintersDiff.py.