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

◆ __init__()

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 

Member Function Documentation

◆ __iter__()

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.

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 

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

◆ file()

def ntupleDataFormat.TrackingNtuple.file (   self)

Definition at line 404 of file ntupleDataFormat.py.

404  def file(self):
405  return self._file
406 

References CommonAnalyzer._file, dqm-mbProfile.Profile._file, and ntupleDataFormat.TrackingNtuple._file.

◆ getEvent()

def ntupleDataFormat.TrackingNtuple.getEvent (   self,
  index 
)
Returns Event for a given index

Definition at line 437 of file ntupleDataFormat.py.

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 

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

◆ hasHits()

def ntupleDataFormat.TrackingNtuple.hasHits (   self)
Returns true if the ntuple has hit information.

Definition at line 413 of file ntupleDataFormat.py.

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

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

◆ hasSeeds()

def ntupleDataFormat.TrackingNtuple.hasSeeds (   self)
Returns true if the ntuple has seed information.

Definition at line 417 of file ntupleDataFormat.py.

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

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

◆ nevents()

def ntupleDataFormat.TrackingNtuple.nevents (   self)

Definition at line 410 of file ntupleDataFormat.py.

410  def nevents(self):
411  return self._entries
412 

References ntupleDataFormat.TrackingNtuple._entries.

◆ tree()

def ntupleDataFormat.TrackingNtuple.tree (   self)

Member Data Documentation

◆ _entries

ntupleDataFormat.TrackingNtuple._entries
private

◆ _file

ntupleDataFormat.TrackingNtuple._file
private

Definition at line 400 of file ntupleDataFormat.py.

Referenced by ntupleDataFormat.TrackingNtuple.file().

◆ _tree

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.Event.event(), ntupleDataFormat.Event.eventId(), 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.Event.lumi(), ntupleDataFormat._SimHitMatchAdaptor.matchedSimHitInfos(), ntupleDataFormat._TrackingParticleMatchAdaptor.matchedTrackingParticleInfos(), ntupleDataFormat._RecoHitAdaptor.phase2OTHits(), ntupleDataFormat.Event.phase2OTHits(), ntupleDataFormat._RecoHitAdaptor.pixelHits(), ntupleDataFormat.Event.pixelHits(), ntupleDataFormat.Event.run(), 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().

cmsHarvester.nevents
nevents
Definition: cmsHarvester.py:3177
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
Event
MainPageGenerator.tree
tree
Definition: MainPageGenerator.py:264
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13