CMS 3D CMS Logo

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

Public Member Functions

def __init__ (self, fileName, tree="trackingNtuple/tree")
 
def __iter__ (self)
 
def file (self)
 
def getEvent (self, index)
 
def hasHits (self)
 
def hasSeeds (self)
 
def nevents (self)
 
def tree (self)
 

Private Attributes

 _entries
 
 _file
 
 _tree
 

Detailed Description

Class abstracting the whole ntuple/TTree.

Main benefit is to provide nice interface for
- iterating over events
- querying whether hit/seed information exists

Note that to iteratate over the evets with zip(), you should use
itertools.izip() instead.

Definition at line 380 of file ntupleDataFormat.py.

Constructor & Destructor Documentation

def ntupleDataFormat.TrackingNtuple.__init__ (   self,
  fileName,
  tree = "trackingNtuple/tree" 
)
Constructor.

Arguments:
fileName -- String for path to the ROOT file
tree     -- Name of the TTree object inside the ROOT file (default: 'trackingNtuple/tree')

Definition at line 390 of file ntupleDataFormat.py.

390  def __init__(self, fileName, tree="trackingNtuple/tree"):
391  """Constructor.
392 
393  Arguments:
394  fileName -- String for path to the ROOT file
395  tree -- Name of the TTree object inside the ROOT file (default: 'trackingNtuple/tree')
396  """
397  super(TrackingNtuple, self).__init__()
398  self._file = ROOT.TFile.Open(fileName)
399  self._tree = self._file.Get(tree)
400  self._entries = self._tree.GetEntriesFast()
401 
def __init__(self, fileName, tree="trackingNtuple/tree")

Member Function Documentation

def ntupleDataFormat.TrackingNtuple.__iter__ (   self)
Returns generator for iterating over TTree entries (events)

Generator returns Event objects.

Definition at line 419 of file ntupleDataFormat.py.

References ntupleDataFormat.TrackingNtuple._entries, ntupleDataFormat._Collection._tree, ntupleDataFormat._Object._tree, python.cmstools.EventTree._tree, and ntupleDataFormat.TrackingNtuple._tree.

419  def __iter__(self):
420  """Returns generator for iterating over TTree entries (events)
421 
422  Generator returns Event objects.
423 
424  """
425  for jentry in xrange(self._entries):
426  # get the next tree in the chain and verify
427  ientry = self._tree.LoadTree( jentry )
428  if ientry < 0: break
429  # copy next entry into memory and verify
430  nb = self._tree.GetEntry( jentry )
431  if nb <= 0: continue
432 
433  yield Event(self._tree, jentry)
434 
def ntupleDataFormat.TrackingNtuple.file (   self)
def ntupleDataFormat.TrackingNtuple.getEvent (   self,
  index 
)
Returns Event for a given index

Definition at line 435 of file ntupleDataFormat.py.

References ntupleDataFormat._Collection._tree, ntupleDataFormat._Object._tree, python.cmstools.EventTree._tree, and ntupleDataFormat.TrackingNtuple._tree.

435  def getEvent(self, index):
436  """Returns Event for a given index"""
437  ientry = self._tree.LoadTree(index)
438  if ientry < 0: return None
439  nb = self._tree.GetEntry(ientry) # ientry or jentry?
440  if nb <= 0: None
441 
442  return Event(self._tree, ientry) # ientry of jentry?
443 
def ntupleDataFormat.TrackingNtuple.hasHits (   self)
Returns true if the ntuple has hit information.

Definition at line 411 of file ntupleDataFormat.py.

References ntupleDataFormat._Collection._tree, ntupleDataFormat._Object._tree, python.cmstools.EventTree._tree, and ntupleDataFormat.TrackingNtuple._tree.

411  def hasHits(self):
412  """Returns true if the ntuple has hit information."""
413  return hasattr(self._tree, "pix_isBarrel")
414 
def ntupleDataFormat.TrackingNtuple.hasSeeds (   self)
Returns true if the ntuple has seed information.

Definition at line 415 of file ntupleDataFormat.py.

References ntupleDataFormat._Collection._tree, ntupleDataFormat._Object._tree, python.cmstools.EventTree._tree, and ntupleDataFormat.TrackingNtuple._tree.

415  def hasSeeds(self):
416  """Returns true if the ntuple has seed information."""
417  return hasattr(self._tree, "see_fitok")
418 
def ntupleDataFormat.TrackingNtuple.nevents (   self)
def ntupleDataFormat.TrackingNtuple.tree (   self)

Member Data Documentation

ntupleDataFormat.TrackingNtuple._entries
private
ntupleDataFormat.TrackingNtuple._file
private

Definition at line 398 of file ntupleDataFormat.py.

Referenced by ntupleDataFormat.TrackingNtuple.file().

ntupleDataFormat.TrackingNtuple._tree
private

Definition at line 399 of file ntupleDataFormat.py.

Referenced by ntupleDataFormat.BeamSpot.__getattr__(), ntupleDataFormat.TrackingNtuple.__iter__(), ntupleDataFormat._SimHitMatchAdaptor._nMatchedSimHits(), ntupleDataFormat._TrackingParticleMatchAdaptor._nMatchedTrackingParticles(), ntupleDataFormat.Event.beamspot(), ntupleDataFormat._TrackingParticleMatchAdaptor.bestMatchingTrackingParticle(), ntupleDataFormat._TrackingParticleMatchAdaptor.bestMatchingTrackingParticleFromFirstHit(), ntupleDataFormat._DetIdStrAdaptor.detIdStr(), ntupleDataFormat.TrackingNtuple.getEvent(), ntupleDataFormat._RecoHitAdaptor.gluedHits(), ntupleDataFormat.Event.gluedHits(), ntupleDataFormat.TrackingNtuple.hasHits(), ntupleDataFormat.TrackingNtuple.hasSeeds(), ntupleDataFormat._RecoHitAdaptor.hits(), ntupleDataFormat._RecoHitAdaptor.invalidHits(), ntupleDataFormat._DetIdStrAdaptor.layerStr(), ntupleDataFormat._SimHitMatchAdaptor.matchedSimHitInfos(), ntupleDataFormat._TrackingParticleMatchAdaptor.matchedTrackingParticleInfos(), ntupleDataFormat._RecoHitAdaptor.phase2OTHits(), ntupleDataFormat.Event.phase2OTHits(), ntupleDataFormat._RecoHitAdaptor.pixelHits(), ntupleDataFormat.Event.pixelHits(), ntupleDataFormat.Event.seeds(), ntupleDataFormat._RecoHitAdaptor.stripHits(), ntupleDataFormat.Event.stripHits(), ntupleDataFormat.Event.trackingParticles(), ntupleDataFormat.Event.trackingVertices(), ntupleDataFormat.Event.tracks(), ntupleDataFormat.TrackingNtuple.tree(), and ntupleDataFormat.Event.vertices().