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

◆ __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 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, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)

Member Function Documentation

◆ __iter__()

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, ntupleDataFormat.TrackingNtuple._tree, and FastTimerService_cff.range.

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 range(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 

◆ file()

def ntupleDataFormat.TrackingNtuple.file (   self)

Definition at line 403 of file ntupleDataFormat.py.

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

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

◆ getEvent()

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 

◆ hasHits()

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 

◆ hasSeeds()

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 

◆ nevents()

def ntupleDataFormat.TrackingNtuple.nevents (   self)

Definition at line 409 of file ntupleDataFormat.py.

References ntupleDataFormat.TrackingNtuple._entries.

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

◆ tree()

def ntupleDataFormat.TrackingNtuple.tree (   self)

Member Data Documentation

◆ _entries

ntupleDataFormat.TrackingNtuple._entries
private

◆ _file

ntupleDataFormat.TrackingNtuple._file
private

Definition at line 399 of file ntupleDataFormat.py.

Referenced by ntupleDataFormat.TrackingNtuple.file().

◆ _tree

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.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().