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 972 of file ntupleDataFormat.py.

Constructor & Destructor Documentation

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

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

Definition at line 974 of file ntupleDataFormat.py.

974  def __init__(self, tree, index):
975  """Constructor.
976 
977  Arguments:
978  tree -- TTree object
979  index -- Index of the TrackingParticle
980  """
981  super(TrackingParticle, self).__init__(tree, index, "sim")
982 

Member Function Documentation

def ntupleDataFormat.TrackingParticle._nMatchedSeeds (   self)
private
def ntupleDataFormat.TrackingParticle._nMatchedTracks (   self)
private
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 1001 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, ntupleDataFormat.TrackingParticle.simHits(), and HiIsolationCommonParameters_cff.track.

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

The generator returns TrackingVertex objects.

Definition at line 1063 of file ntupleDataFormat.py.

References ntupleDataFormat._Object._checkIsValid(), SeedingNode< DATA >._index, Vispa.Share.FindAlgorithm.FindAlgorithm._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.

1063  def decayVertices(self):
1064  """Returns a generator for decay vertices.
1065 
1066  The generator returns TrackingVertex objects.
1067  """
1068  self._checkIsValid()
1069  for ivtx in self._tree.sim_decayVtxIdx[self._index]:
1070  yield TrackingVertex(self._tree, ivtx)
1071 
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 1072 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.

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

The generator returns SeedMatchInfo objects.

Definition at line 1039 of file ntupleDataFormat.py.

References ntupleDataFormat._Object._checkIsValid(), SeedingNode< DATA >._index, Vispa.Share.FindAlgorithm.FindAlgorithm._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, and python.cmstools.EventTree._tree.

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

The generator returns TrackMatchInfo objects.

Definition at line 992 of file ntupleDataFormat.py.

References ntupleDataFormat._Object._checkIsValid(), SeedingNode< DATA >._index, Vispa.Share.FindAlgorithm.FindAlgorithm._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, and python.cmstools.EventTree._tree.

Referenced by ntupleDataFormat.TrackingParticle.bestMatchingTrack().

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

Definition at line 1034 of file ntupleDataFormat.py.

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

1034  def nMatchedSeeds(self):
1035  """Returns the number of matched seeds."""
1036  self._checkIsValid()
1037  return self._nMatchedSeeds()
1038 
def ntupleDataFormat.TrackingParticle.nMatchedTracks (   self)
Returns the number of matched tracks.

Definition at line 987 of file ntupleDataFormat.py.

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

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

Definition at line 1048 of file ntupleDataFormat.py.

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

1048  def nSimHits(self):
1049  self._checkIsValid()
1050  return self.simHitIdx().size()
1051 
size
Write out results.
def ntupleDataFormat.TrackingParticle.parentVertex (   self)
def ntupleDataFormat.TrackingParticle.simHits (   self)
Returns generator for SimHits.

Definition at line 1052 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().

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