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

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

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 999 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(), PHcalTB06Info.simHits(), ntupleDataFormat.TrackingParticle.simHits(), and HiIsolationCommonParameters_cff.track.

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

The generator returns TrackingVertex objects.

Definition at line 1061 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.

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

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

The generator returns SeedMatchInfo objects.

Definition at line 1037 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.

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

The generator returns TrackMatchInfo objects.

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

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

Definition at line 1032 of file ntupleDataFormat.py.

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

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

Definition at line 985 of file ntupleDataFormat.py.

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

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

Definition at line 1046 of file ntupleDataFormat.py.

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

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

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

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