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

362  def __init__(self, fileName, tree="trackingNtuple/tree"):
363  """Constructor.
364 
365  Arguments:
366  fileName -- String for path to the ROOT file
367  tree -- Name of the TTree object inside the ROOT file (default: 'trackingNtuple/tree')
368  """
369  super(TrackingNtuple, self).__init__()
370  self._file = ROOT.TFile.Open(fileName)
371  self._tree = self._file.Get(tree)
372  self._entries = self._tree.GetEntriesFast()
373 
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 391 of file ntupleDataFormat.py.

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

391  def __iter__(self):
392  """Returns generator for iterating over TTree entries (events)
393 
394  Generator returns Event objects.
395 
396  """
397  for jentry in xrange(self._entries):
398  # get the next tree in the chain and verify
399  ientry = self._tree.LoadTree( jentry )
400  if ientry < 0: break
401  # copy next entry into memory and verify
402  nb = self._tree.GetEntry( jentry )
403  if nb <= 0: continue
404 
405  yield Event(self._tree, jentry)
406 
def ntupleDataFormat.TrackingNtuple.file (   self)
def ntupleDataFormat.TrackingNtuple.getEvent (   self,
  index 
)
Returns Event for a given index

Definition at line 407 of file ntupleDataFormat.py.

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

407  def getEvent(self, index):
408  """Returns Event for a given index"""
409  ientry = self._tree.LoadTree(index)
410  if ientry < 0: return None
411  nb = self._tree.GetEntry(ientry) # ientry or jentry?
412  if nb <= 0: None
413 
414  return Event(self._tree, ientry) # ientry of jentry?
415 
def ntupleDataFormat.TrackingNtuple.hasHits (   self)
Returns true if the ntuple has hit information.

Definition at line 383 of file ntupleDataFormat.py.

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

383  def hasHits(self):
384  """Returns true if the ntuple has hit information."""
385  return hasattr(self._tree, "pix_isBarrel")
386 
def ntupleDataFormat.TrackingNtuple.hasSeeds (   self)
Returns true if the ntuple has seed information.

Definition at line 387 of file ntupleDataFormat.py.

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

387  def hasSeeds(self):
388  """Returns true if the ntuple has seed information."""
389  return hasattr(self._tree, "see_fitok")
390 
def ntupleDataFormat.TrackingNtuple.nevents (   self)
def ntupleDataFormat.TrackingNtuple.tree (   self)

Member Data Documentation

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

Definition at line 370 of file ntupleDataFormat.py.

Referenced by ntupleDataFormat.TrackingNtuple.file().

ntupleDataFormat.TrackingNtuple._tree
private