CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions
ntupleDataFormat.TrackingParticle Class Reference
Inheritance diagram for ntupleDataFormat.TrackingParticle:
ntupleDataFormat._Object

Public Member Functions

def __init__ (self, tree, index)
 
def bestMatchingTrack (self)
 
def decayVertices (self)
 
def isLooper (self)
 
def matchedSeedInfos (self)
 
def matchedTrackInfos (self)
 
def nMatchedSeeds (self)
 
def nMatchedTracks (self)
 
def nSimHits (self)
 
def parentVertex (self)
 
def simHits (self)
 
- Public Member Functions inherited from ntupleDataFormat._Object
def __getattr__ (self, attr)
 
def __init__ (self, tree, index, prefix)
 
def index (self)
 
def isValid (self)
 

Private Member Functions

def _nMatchedSeeds (self)
 
def _nMatchedTracks (self)
 

Detailed Description

Class representing a TrackingParticle.

Definition at line 971 of file ntupleDataFormat.py.

Constructor & Destructor Documentation

◆ __init__()

def ntupleDataFormat.TrackingParticle.__init__ (   self,
  tree,
  index 
)
Constructor.

Arguments:
tree  -- TTree object
index -- Index of the TrackingParticle

Definition at line 973 of file ntupleDataFormat.py.

973  def __init__(self, tree, index):
974  """Constructor.
975 
976  Arguments:
977  tree -- TTree object
978  index -- Index of the TrackingParticle
979  """
980  super(TrackingParticle, self).__init__(tree, index, "sim")
981 
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

◆ _nMatchedSeeds()

def ntupleDataFormat.TrackingParticle._nMatchedSeeds (   self)
private
Internal function to get the number of matched seeds.

Definition at line 1029 of file ntupleDataFormat.py.

References SeedingNode< DATA >._index, lhef::H5Handler._index, RPCMuonExtraStruct._index, ntupleDataFormat._Object._index, python.cmstools.EventTree._index, python.cmstools.EventBranch._index, html.HtmlReport._index, ntupleDataFormat._Collection._tree, ntupleDataFormat._Object._tree, python.cmstools.EventTree._tree, and findQualityFiles.size.

Referenced by ntupleDataFormat.TrackingParticle.matchedSeedInfos(), and ntupleDataFormat.TrackingParticle.nMatchedSeeds().

1029  def _nMatchedSeeds(self):
1030  """Internal function to get the number of matched seeds."""
1031  return self._tree.sim_seedIdx[self._index].size()
1032 
size
Write out results.

◆ _nMatchedTracks()

def ntupleDataFormat.TrackingParticle._nMatchedTracks (   self)
private

◆ bestMatchingTrack()

def ntupleDataFormat.TrackingParticle.bestMatchingTrack (   self)
Returns best-matching track, even for non-reconstructed TrackingParticles, or None, if there is no best-matching track.

Best-matching is defined as the one with largest number of
hits matched to the hits of a TrackingParticle (>= 3). If
there are many fulfilling the same number of hits, the one
inducing the innermost hit of the TrackingParticle is chosen.

Definition at line 1000 of file ntupleDataFormat.py.

References ntupleDataFormat._Object._checkIsValid(), ntupleDataFormat.TrackingParticle._nMatchedTracks(), ntupleDataFormat._Collection._tree, ntupleDataFormat._Object._tree, python.cmstools.EventTree._tree, ntupleDataFormat.TrackingParticle.matchedTrackInfos(), GetRecoTauVFromDQM_MC_cff.next, MuonTruth.simHits(), MuonSimHitMatcher.simHits(), PHcalTB06Info.simHits(), EdgeProperty.simHits, Phase2TrackerValidateDigi.simHits, ntupleDataFormat.TrackingParticle.simHits(), and HLT_2022v14_cff.track.

1000  def bestMatchingTrack(self):
1001  """Returns best-matching track, even for non-reconstructed TrackingParticles, or None, if there is no best-matching track.
1002 
1003  Best-matching is defined as the one with largest number of
1004  hits matched to the hits of a TrackingParticle (>= 3). If
1005  there are many fulfilling the same number of hits, the one
1006  inducing the innermost hit of the TrackingParticle is chosen.
1007  """
1008  self._checkIsValid()
1009  if self._nMatchedTracks() == 1:
1010  return next(self.matchedTrackInfos()).track()
1011 
1012  tracks = collections.OrderedDict()
1013  for hit in self.simHits():
1014  for recHit in hit.hits():
1015  for track in recHit.tracks():
1016  if track.index() in tracks:
1017  tracks[track.index()] += 1
1018  else:
1019  tracks[track.index()] = 1
1020 
1021  best = (None, 2)
1022  for trackIndex, nhits in tracks.items():
1023  if nhits > best[1]:
1024  best = (trackIndex, nhits)
1025  if best[0] is None:
1026  return None
1027  return Tracks(self._tree)[best[0]]
1028 

◆ decayVertices()

def ntupleDataFormat.TrackingParticle.decayVertices (   self)
Returns a generator for decay vertices.

The generator returns TrackingVertex objects.

Definition at line 1062 of file ntupleDataFormat.py.

References ntupleDataFormat._Object._checkIsValid(), SeedingNode< DATA >._index, lhef::H5Handler._index, RPCMuonExtraStruct._index, ntupleDataFormat._Object._index, python.cmstools.EventTree._index, python.cmstools.EventBranch._index, html.HtmlReport._index, ntupleDataFormat._Collection._tree, ntupleDataFormat._Object._tree, and python.cmstools.EventTree._tree.

1062  def decayVertices(self):
1063  """Returns a generator for decay vertices.
1064 
1065  The generator returns TrackingVertex objects.
1066  """
1067  self._checkIsValid()
1068  for ivtx in self._tree.sim_decayVtxIdx[self._index]:
1069  yield TrackingVertex(self._tree, ivtx)
1070 

◆ isLooper()

def ntupleDataFormat.TrackingParticle.isLooper (   self)
Returns True if this TrackingParticle is a looper.

Note that the check involves looping over the SimHits, so it is not too cheap.

Definition at line 1071 of file ntupleDataFormat.py.

References ntupleDataFormat._Object._checkIsValid(), ntupleDataFormat._Collection._tree, ntupleDataFormat._Object._tree, python.cmstools.EventTree._tree, TrackingNtuple::TPHitIndex.simHitIdx, hit.x, and hit.y.

1071  def isLooper(self):
1072  """Returns True if this TrackingParticle is a looper.
1073 
1074  Note that the check involves looping over the SimHits, so it is not too cheap."""
1075  self._checkIsValid()
1076  prevr = 0
1077  for ihit in self.simHitIdx():
1078  hit = SimHit(self._tree, ihit)
1079  r = hit.x()**2 + hit.y()**2
1080  if r < prevr:
1081  return True
1082  prevr = r
1083  return False
1084 
1085 

◆ matchedSeedInfos()

def ntupleDataFormat.TrackingParticle.matchedSeedInfos (   self)
Returns a generator for matched tracks.

The generator returns SeedMatchInfo objects.

Definition at line 1038 of file ntupleDataFormat.py.

References ntupleDataFormat._Object._checkIsValid(), SeedingNode< DATA >._index, lhef::H5Handler._index, RPCMuonExtraStruct._index, ntupleDataFormat._Object._index, python.cmstools.EventTree._index, python.cmstools.EventBranch._index, html.HtmlReport._index, ntupleDataFormat.TrackingParticle._nMatchedSeeds(), CommonAnalyzer._prefix, ntupleDataFormat._Object._prefix, html.PageSet._prefix, ntupleDataFormat._Collection._tree, ntupleDataFormat._Object._tree, python.cmstools.EventTree._tree, and FastTimerService_cff.range.

1038  def matchedSeedInfos(self):
1039  """Returns a generator for matched tracks.
1040 
1041  The generator returns SeedMatchInfo objects.
1042  """
1043  self._checkIsValid()
1044  for imatch in range(self._nMatchedSeeds()):
1045  yield SeedMatchInfo(self._tree, self._index, imatch, self._prefix)
1046 

◆ matchedTrackInfos()

def ntupleDataFormat.TrackingParticle.matchedTrackInfos (   self)
Returns a generator for matched tracks.

The generator returns TrackMatchInfo objects.

Definition at line 991 of file ntupleDataFormat.py.

References ntupleDataFormat._Object._checkIsValid(), SeedingNode< DATA >._index, lhef::H5Handler._index, RPCMuonExtraStruct._index, ntupleDataFormat._Object._index, python.cmstools.EventTree._index, python.cmstools.EventBranch._index, html.HtmlReport._index, ntupleDataFormat.TrackingParticle._nMatchedTracks(), CommonAnalyzer._prefix, ntupleDataFormat._Object._prefix, html.PageSet._prefix, ntupleDataFormat._Collection._tree, ntupleDataFormat._Object._tree, python.cmstools.EventTree._tree, and FastTimerService_cff.range.

Referenced by ntupleDataFormat.TrackingParticle.bestMatchingTrack().

991  def matchedTrackInfos(self):
992  """Returns a generator for matched tracks.
993 
994  The generator returns TrackMatchInfo objects.
995  """
996  self._checkIsValid()
997  for imatch in range(self._nMatchedTracks()):
998  yield TrackMatchInfo(self._tree, self._index, imatch, self._prefix)
999 

◆ nMatchedSeeds()

def ntupleDataFormat.TrackingParticle.nMatchedSeeds (   self)
Returns the number of matched seeds.

Definition at line 1033 of file ntupleDataFormat.py.

References ntupleDataFormat._Object._checkIsValid(), and ntupleDataFormat.TrackingParticle._nMatchedSeeds().

1033  def nMatchedSeeds(self):
1034  """Returns the number of matched seeds."""
1035  self._checkIsValid()
1036  return self._nMatchedSeeds()
1037 

◆ nMatchedTracks()

def ntupleDataFormat.TrackingParticle.nMatchedTracks (   self)
Returns the number of matched tracks.

Definition at line 986 of file ntupleDataFormat.py.

References ntupleDataFormat._Object._checkIsValid(), and ntupleDataFormat.TrackingParticle._nMatchedTracks().

986  def nMatchedTracks(self):
987  """Returns the number of matched tracks."""
988  self._checkIsValid()
989  return self._nMatchedTracks()
990 

◆ nSimHits()

def ntupleDataFormat.TrackingParticle.nSimHits (   self)

Definition at line 1047 of file ntupleDataFormat.py.

References ntupleDataFormat._Object._checkIsValid(), TrackingNtuple::TPHitIndex.simHitIdx, and findQualityFiles.size.

1047  def nSimHits(self):
1048  self._checkIsValid()
1049  return self.simHitIdx().size()
1050 
size
Write out results.

◆ parentVertex()

def ntupleDataFormat.TrackingParticle.parentVertex (   self)
Returns the parent TrackingVertex.

Definition at line 1057 of file ntupleDataFormat.py.

References ntupleDataFormat._Object._checkIsValid(), SeedingNode< DATA >._index, lhef::H5Handler._index, RPCMuonExtraStruct._index, ntupleDataFormat._Object._index, python.cmstools.EventTree._index, python.cmstools.EventBranch._index, html.HtmlReport._index, ntupleDataFormat._Collection._tree, ntupleDataFormat._Object._tree, and python.cmstools.EventTree._tree.

1057  def parentVertex(self):
1058  """Returns the parent TrackingVertex."""
1059  self._checkIsValid()
1060  return TrackingVertex(self._tree, self._tree.sim_parentVtxIdx[self._index])
1061 

◆ simHits()

def ntupleDataFormat.TrackingParticle.simHits (   self)
Returns generator for SimHits.

Definition at line 1051 of file ntupleDataFormat.py.

References ntupleDataFormat._Object._checkIsValid(), ntupleDataFormat._Collection._tree, ntupleDataFormat._Object._tree, python.cmstools.EventTree._tree, and TrackingNtuple::TPHitIndex.simHitIdx.

Referenced by ntupleDataFormat.TrackingParticle.bestMatchingTrack().

1051  def simHits(self):
1052  """Returns generator for SimHits."""
1053  self._checkIsValid()
1054  for ihit in self.simHitIdx():
1055  yield SimHit(self._tree, ihit)
1056