CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
python.cmstools.EventTree Class Reference
Inheritance diagram for python.cmstools.EventTree:

Public Member Functions

def __getattr__ (self, name)
 
def __getitem__ (self, key)
 
def __init__ (self, obj)
 
def __iter__ (self)
 
def branch (self, name)
 
def cppCode (self, name)
 
def getListOfAliases (self)
 
def index (self)
 
def SetAlias (self, alias, fullName)
 
def tree (self)
 

Private Member Functions

def __setBranchIndicies (self)
 

Private Attributes

 _aliases
 
 _index
 
 _tree
 
 _usedBranches
 

Detailed Description

Definition at line 67 of file cmstools.py.

Constructor & Destructor Documentation

◆ __init__()

def python.cmstools.EventTree.__init__ (   self,
  obj 
)

Definition at line 68 of file cmstools.py.

68  def __init__(self,obj):
69  sys.stderr.write ("WARNING: This package has been deprecated and will be removed in the near future.\nPlease switch to using FWLite.Python (https://twiki.cern.ch/twiki/bin/viewauth/CMS/WorkBookFWLitePython)\n")
70  treeName = 'Events'
71  if isinstance(obj, ROOT.TTree):
72  self._tree = obj
73  elif isinstance(obj, ROOT.TFile):
74  self._tree = obj.Get(treeName)
75  elif isinstance(obj, str):
76  self._tree = ROOT.TFile.Open(obj).Get(treeName)
77  else:
78  raise cmserror("EventTree accepts only TTrees, TFiles and filenames")
79  self._usedBranches = dict()
80  self._index = -1
81  self._aliases = self._tree.GetListOfAliases()

Member Function Documentation

◆ __getattr__()

def python.cmstools.EventTree.__getattr__ (   self,
  name 
)

◆ __getitem__()

def python.cmstools.EventTree.__getitem__ (   self,
  key 
)

Definition at line 121 of file cmstools.py.

121  def __getitem__(self,key):
122  if key <0 or key > self._tree.GetEntries():
123  raise IndexError
124  self._index = key
125  self.__setBranchIndicies()
126  self._tree.GetEntry(self._index,0)
127  return Event(self)

References python.cmstools.EventTree.__setBranchIndicies(), SeedingNode< DATA >._index, lhef::H5Handler._index, RPCMuonExtraStruct._index, python.cmstools.EventTree._index, and python.cmstools.EventTree._tree.

◆ __iter__()

def python.cmstools.EventTree.__iter__ (   self)

Definition at line 128 of file cmstools.py.

128  def __iter__(self):
129  # flushing/initializing the root buffers
130  entry = 0
131  self._index = entry
132  self.__setBranchIndicies()
133  self._tree.GetEntry(self._index,0)
134  # the real loop
135  for entry in range(self._tree.GetEntries()):
136  self._index = entry
137  self.__setBranchIndicies()
138  self._tree.GetEntry(self._index,0)
139  yield Event(self) # TODO: don't return a new object but update the old one
140 
141 

References python.cmstools.EventTree.__setBranchIndicies(), SeedingNode< DATA >._index, lhef::H5Handler._index, RPCMuonExtraStruct._index, python.cmstools.EventTree._index, python.cmstools.EventTree._tree, and FastTimerService_cff.range.

◆ __setBranchIndicies()

def python.cmstools.EventTree.__setBranchIndicies (   self)
private

Definition at line 116 of file cmstools.py.

116  def __setBranchIndicies(self):
117  for branch in self._usedBranches.values():
118  branch.setIndex(self._index)

References SeedingNode< DATA >._index, lhef::H5Handler._index, RPCMuonExtraStruct._index, python.cmstools.EventTree._index, python.cmstools.EventTree._usedBranches, and contentValuesCheck.values.

Referenced by python.cmstools.EventTree.__getitem__(), and python.cmstools.EventTree.__iter__().

◆ branch()

def python.cmstools.EventTree.branch (   self,
  name 
)

Definition at line 82 of file cmstools.py.

82  def branch(self,name):
83  # support for aliases
84  alias = self._tree.GetAlias(name)
85  if alias != '': name = alias
86  # access the branch in ttree
87  if name in self._usedBranches:
88  return self._usedBranches[name]
89  self._usedBranches[name]=EventBranch(self,name)
90  return self._usedBranches[name]

References python.cmstools.EventTree._tree, and python.cmstools.EventTree._usedBranches.

Referenced by python.cmstools.EventTree.__getattr__().

◆ cppCode()

def python.cmstools.EventTree.cppCode (   self,
  name 
)
C++ code for accessing the product inside the full framework

Definition at line 91 of file cmstools.py.

91  def cppCode(self, name):
92  """C++ code for accessing the product inside the full framework"""
93  alias = self._tree.GetAlias(name)
94  if alias != '': name = alias
95  tmpBranch = self._tree.GetBranch(name)
96  typeString = ROOT.branchToClass(tmpBranch).GetName()
97  if "edm::Wrapper" in typeString:
98  typeString = typeString.replace("<edm::Wrapper","")
99  typeString = typeString.rstrip(">")
100  nameParts = name.split("_")
101  if nameParts[2] == "":
102  cppCode = 'edm::Handle<%s > dummy;\nevent.getByLabel("%s", dummy);'\
103  %(typeString, nameParts[1])
104  else:
105  cppCode = 'edm::Handle<%s > dummy;\nevent.getByLabel("%s", "%s", dummy);'\
106  %(typeString, nameParts[1], nameParts[2])
107  return cppCode

References python.cmstools.EventTree._tree.

◆ getListOfAliases()

def python.cmstools.EventTree.getListOfAliases (   self)

Definition at line 108 of file cmstools.py.

108  def getListOfAliases(self):
109  return self._aliases

References python.cmstools.EventTree._aliases.

◆ index()

def python.cmstools.EventTree.index (   self)

Definition at line 112 of file cmstools.py.

112  def index(self):
113  return self._index

References SeedingNode< DATA >._index, lhef::H5Handler._index, RPCMuonExtraStruct._index, and python.cmstools.EventTree._index.

Referenced by BeautifulSoup.PageElement.insert().

◆ SetAlias()

def python.cmstools.EventTree.SetAlias (   self,
  alias,
  fullName 
)

◆ tree()

def python.cmstools.EventTree.tree (   self)

Member Data Documentation

◆ _aliases

python.cmstools.EventTree._aliases
private

Definition at line 81 of file cmstools.py.

Referenced by python.cmstools.EventTree.getListOfAliases().

◆ _index

python.cmstools.EventTree._index
private

Definition at line 80 of file cmstools.py.

Referenced by ntupleDataFormat._Object.__getattr__(), python.cmstools.EventTree.__getitem__(), python.cmstools.EventTree.__iter__(), python.cmstools.EventBranch.__readData(), python.cmstools.EventTree.__setBranchIndicies(), ntupleDataFormat.TrackingParticle._nMatchedSeeds(), ntupleDataFormat._SimHitMatchAdaptor._nMatchedSimHits(), ntupleDataFormat._TrackingParticleMatchAdaptor._nMatchedTrackingParticles(), ntupleDataFormat.TrackingParticle._nMatchedTracks(), html.HtmlReport.addNote(), ntupleDataFormat.TrackingVertex.daughterTrackingParticles(), ntupleDataFormat.TrackingParticle.decayVertices(), ntupleDataFormat._DetIdStrAdaptor.detIdStr(), ntupleDataFormat._Object.index(), python.cmstools.EventTree.index(), ntupleDataFormat.Seed.indexWithinAlgo(), ntupleDataFormat._Object.isValid(), ntupleDataFormat._DetIdStrAdaptor.layerStr(), ntupleDataFormat.InvalidHit.layerStr(), ntupleDataFormat.TrackingParticle.matchedSeedInfos(), ntupleDataFormat._SimHitMatchAdaptor.matchedSimHitInfos(), ntupleDataFormat.TrackingParticle.matchedTrackInfos(), ntupleDataFormat._TrackingParticleMatchAdaptor.matchedTrackingParticleInfos(), ntupleDataFormat.GluedHit.monoHit(), ntupleDataFormat.TrackingVertex.nDaughterTrackingParticles(), ntupleDataFormat.SimHit.nRecHits(), ntupleDataFormat._HitObject.nseeds(), ntupleDataFormat.GluedHit.nseeds(), ntupleDataFormat.TrackingVertex.nSourceTrackingParticles(), ntupleDataFormat._HitObject.ntracks(), ntupleDataFormat.Vertex.nTracks(), ntupleDataFormat.TrackingParticle.parentVertex(), ntupleDataFormat.SeedMatchInfo.seed(), ntupleDataFormat.Track.seed(), ntupleDataFormat._HitObject.seeds(), ntupleDataFormat.GluedHit.seeds(), python.cmstools.EventBranch.setIndex(), ntupleDataFormat.SimHitMatchInfo.simHit(), ntupleDataFormat.TrackingVertex.sourceTrackingParticles(), ntupleDataFormat.GluedHit.stereoHit(), ntupleDataFormat.Seed.track(), ntupleDataFormat.SimHit.trackingParticle(), ntupleDataFormat._HitObject.tracks(), ntupleDataFormat.Vertex.tracks(), ntupleDataFormat.Track.vertex(), and html.HtmlReport.write().

◆ _tree

python.cmstools.EventTree._tree
private

Definition at line 72 of file cmstools.py.

Referenced by ntupleDataFormat._Object.__getattr__(), ntupleDataFormat.BeamSpot.__getattr__(), ntupleDataFormat._Collection.__getitem__(), python.cmstools.EventTree.__getitem__(), ntupleDataFormat._Collection.__iter__(), python.cmstools.EventTree.__iter__(), ntupleDataFormat.TrackingNtuple.__iter__(), ntupleDataFormat.TrackingParticle._nMatchedSeeds(), ntupleDataFormat._SimHitMatchAdaptor._nMatchedSimHits(), ntupleDataFormat._TrackingParticleMatchAdaptor._nMatchedTrackingParticles(), ntupleDataFormat.TrackingParticle._nMatchedTracks(), ntupleDataFormat.Event.beamspot(), ntupleDataFormat.TrackingParticle.bestMatchingTrack(), ntupleDataFormat._TrackingParticleMatchAdaptor.bestMatchingTrackingParticle(), ntupleDataFormat._TrackingParticleMatchAdaptor.bestMatchingTrackingParticleFromFirstHit(), python.cmstools.EventTree.branch(), python.cmstools.EventTree.cppCode(), ntupleDataFormat.TrackingVertex.daughterTrackingParticles(), ntupleDataFormat.TrackingParticle.decayVertices(), 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.Seed.indexWithinAlgo(), ntupleDataFormat._RecoHitAdaptor.invalidHits(), ntupleDataFormat.TrackingParticle.isLooper(), ntupleDataFormat._DetIdStrAdaptor.layerStr(), ntupleDataFormat.InvalidHit.layerStr(), ntupleDataFormat.Event.lumi(), ntupleDataFormat.TrackingParticle.matchedSeedInfos(), ntupleDataFormat._SimHitMatchAdaptor.matchedSimHitInfos(), ntupleDataFormat.TrackingParticle.matchedTrackInfos(), ntupleDataFormat._TrackingParticleMatchAdaptor.matchedTrackingParticleInfos(), ntupleDataFormat.GluedHit.monoHit(), ntupleDataFormat.TrackingVertex.nDaughterTrackingParticles(), ntupleDataFormat.SimHit.nRecHits(), ntupleDataFormat._HitObject.nseeds(), ntupleDataFormat.GluedHit.nseeds(), ntupleDataFormat.Seeds.nSeedsForAlgo(), ntupleDataFormat.TrackingVertex.nSourceTrackingParticles(), ntupleDataFormat._HitObject.ntracks(), ntupleDataFormat.Vertex.nTracks(), ntupleDataFormat.TrackingParticle.parentVertex(), ntupleDataFormat._RecoHitAdaptor.phase2OTHits(), ntupleDataFormat.Event.phase2OTHits(), ntupleDataFormat._RecoHitAdaptor.pixelHits(), ntupleDataFormat.Event.pixelHits(), ntupleDataFormat.Event.run(), ntupleDataFormat.SeedMatchInfo.seed(), ntupleDataFormat.Track.seed(), ntupleDataFormat.Seeds.seedForAlgo(), ntupleDataFormat._HitObject.seeds(), ntupleDataFormat.Event.seeds(), ntupleDataFormat.GluedHit.seeds(), ntupleDataFormat.Seeds.seedsForAlgo(), ntupleDataFormat.SimHitMatchInfo.simHit(), ntupleDataFormat.TrackingParticle.simHits(), ntupleDataFormat._Collection.size(), ntupleDataFormat.TrackingVertex.sourceTrackingParticles(), ntupleDataFormat.GluedHit.stereoHit(), ntupleDataFormat._RecoHitAdaptor.stripHits(), ntupleDataFormat.Event.stripHits(), ntupleDataFormat.TrackMatchInfo.track(), ntupleDataFormat.Seed.track(), ntupleDataFormat.TrackingParticleMatchInfo.trackingParticle(), ntupleDataFormat.SimHit.trackingParticle(), ntupleDataFormat.Event.trackingParticles(), ntupleDataFormat.Event.trackingVertices(), ntupleDataFormat._HitObject.tracks(), ntupleDataFormat.Event.tracks(), ntupleDataFormat.Vertex.tracks(), python.cmstools.EventTree.tree(), ntupleDataFormat.TrackingNtuple.tree(), ntupleDataFormat.Track.vertex(), and ntupleDataFormat.Event.vertices().

◆ _usedBranches

python.cmstools.EventTree._usedBranches
private
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
MicroEventContent_cff.branch
branch
Definition: MicroEventContent_cff.py:174
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
Event
MainPageGenerator.tree
tree
Definition: MainPageGenerator.py:264
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46