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

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

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

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

Definition at line 436 of file ntupleDataFormat.py.

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

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

Definition at line 412 of file ntupleDataFormat.py.

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

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

Definition at line 416 of file ntupleDataFormat.py.

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

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

Member Data Documentation

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

Definition at line 399 of file ntupleDataFormat.py.

Referenced by ntupleDataFormat.TrackingNtuple.file().

ntupleDataFormat.TrackingNtuple._tree
private

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