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

931  def __init__(self, tree, index):
932  """Constructor.
933 
934  Arguments:
935  tree -- TTree object
936  index -- Index of the TrackingParticle
937  """
938  super(TrackingParticle, self).__init__(tree, index, "sim")
939 

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 958 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.

958  def bestMatchingTrack(self):
959  """Returns best-matching track, even for non-reconstructed TrackingParticles, or None, if there is no best-matching track.
960 
961  Best-matching is defined as the one with largest number of
962  hits matched to the hits of a TrackingParticle (>= 3). If
963  there are many fulfilling the same number of hits, the one
964  inducing the innermost hit of the TrackingParticle is chosen.
965  """
966  self._checkIsValid()
967  if self._nMatchedTracks() == 1:
968  return next(self.matchedTrackInfos()).track()
969 
970  tracks = collections.OrderedDict()
971  for hit in self.simHits():
972  for recHit in hit.hits():
973  for track in recHit.tracks():
974  if track.index() in tracks:
975  tracks[track.index()] += 1
976  else:
977  tracks[track.index()] = 1
978 
979  best = (None, 2)
980  for trackIndex, nhits in tracks.iteritems():
981  if nhits > best[1]:
982  best = (trackIndex, nhits)
983  if best[0] is None:
984  return None
985  return Tracks(self._tree)[best[0]]
986 
def ntupleDataFormat.TrackingParticle.decayVertices (   self)
Returns a generator for decay vertices.

The generator returns TrackingVertex objects.

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

1020  def decayVertices(self):
1021  """Returns a generator for decay vertices.
1022 
1023  The generator returns TrackingVertex objects.
1024  """
1025  self._checkIsValid()
1026  for ivtx in self._tree.sim_decayVtxIdx[self._index]:
1027  yield TrackingVertex(self._tree, ivtx)
1028 
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 1029 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.

1029  def isLooper(self):
1030  """Returns True if this TrackingParticle is a looper.
1031 
1032  Note that the check involves looping over the SimHits, so it is not too cheap."""
1033  self._checkIsValid()
1034  prevr = 0
1035  for ihit in self.simHitIdx():
1036  hit = SimHit(self._tree, ihit)
1037  r = hit.x()**2 + hit.y()**2
1038  if r < prevr:
1039  return True
1040  prevr = r
1041  return False
1042 
1043 
def ntupleDataFormat.TrackingParticle.matchedSeedInfos (   self)
Returns a generator for matched tracks.

The generator returns SeedMatchInfo objects.

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

996  def matchedSeedInfos(self):
997  """Returns a generator for matched tracks.
998 
999  The generator returns SeedMatchInfo objects.
1000  """
1001  self._checkIsValid()
1002  for imatch in xrange(self._nMatchedSeeds()):
1003  yield SeedMatchInfo(self._tree, self._index, imatch, self._prefix)
1004 
def ntupleDataFormat.TrackingParticle.matchedTrackInfos (   self)
Returns a generator for matched tracks.

The generator returns TrackMatchInfo objects.

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

949  def matchedTrackInfos(self):
950  """Returns a generator for matched tracks.
951 
952  The generator returns TrackMatchInfo objects.
953  """
954  self._checkIsValid()
955  for imatch in xrange(self._nMatchedTracks()):
956  yield TrackMatchInfo(self._tree, self._index, imatch, self._prefix)
957 
def ntupleDataFormat.TrackingParticle.nMatchedSeeds (   self)
Returns the number of matched seeds.

Definition at line 991 of file ntupleDataFormat.py.

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

991  def nMatchedSeeds(self):
992  """Returns the number of matched seeds."""
993  self._checkIsValid()
994  return self._nMatchedSeeds()
995 
def ntupleDataFormat.TrackingParticle.nMatchedTracks (   self)
Returns the number of matched tracks.

Definition at line 944 of file ntupleDataFormat.py.

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

944  def nMatchedTracks(self):
945  """Returns the number of matched tracks."""
946  self._checkIsValid()
947  return self._nMatchedTracks()
948 
def ntupleDataFormat.TrackingParticle.nSimHits (   self)

Definition at line 1005 of file ntupleDataFormat.py.

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

1005  def nSimHits(self):
1006  self._checkIsValid()
1007  return self.simHitIdx().size()
1008 
size
Write out results.
def ntupleDataFormat.TrackingParticle.parentVertex (   self)
def ntupleDataFormat.TrackingParticle.simHits (   self)
Returns generator for SimHits.

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

1009  def simHits(self):
1010  """Returns generator for SimHits."""
1011  self._checkIsValid()
1012  for ihit in self.simHitIdx():
1013  yield SimHit(self._tree, ihit)
1014