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 382 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 392 of file ntupleDataFormat.py.

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

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

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

Definition at line 437 of file ntupleDataFormat.py.

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

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

Definition at line 413 of file ntupleDataFormat.py.

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

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

Definition at line 417 of file ntupleDataFormat.py.

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

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

Member Data Documentation

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

Definition at line 400 of file ntupleDataFormat.py.

Referenced by ntupleDataFormat.TrackingNtuple.file().

ntupleDataFormat.TrackingNtuple._tree
private

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