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 69 of file cmstools.py.

Constructor & Destructor Documentation

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

Definition at line 70 of file cmstools.py.

70  def __init__(self,obj):
71  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")
72  treeName = 'Events'
73  if isinstance(obj, ROOT.TTree):
74  self._tree = obj
75  elif isinstance(obj, ROOT.TFile):
76  self._tree = obj.Get(treeName)
77  elif isinstance(obj, str):
78  self._tree = ROOT.TFile.Open(obj).Get(treeName)
79  else:
80  raise cmserror("EventTree accepts only TTrees, TFiles and filenames")
82  self._index = -1
83  self._aliases = self._tree.GetListOfAliases()
def __init__(self, obj)
Definition: cmstools.py:70

Member Function Documentation

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

Definition at line 123 of file cmstools.py.

References python.cmstools.EventTree.__setBranchIndicies(), SeedingNode< DATA >._index, Vispa.Share.FindAlgorithm.FindAlgorithm._index, RPCMuonExtraStruct._index, and python.cmstools.EventTree._index.

123  def __getitem__(self,key):
124  if key <0 or key > self._tree.GetEntries():
125  raise IndexError
126  self._index = key
127  self.__setBranchIndicies()
128  self._tree.GetEntry(self._index,0)
129  return Event(self)
def __setBranchIndicies(self)
Definition: cmstools.py:118
def __getitem__(self, key)
Definition: cmstools.py:123
def python.cmstools.EventTree.__iter__ (   self)

Definition at line 130 of file cmstools.py.

References python.cmstools.EventTree.__setBranchIndicies(), SeedingNode< DATA >._index, Vispa.Share.FindAlgorithm.FindAlgorithm._index, RPCMuonExtraStruct._index, and python.cmstools.EventTree._index.

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

Definition at line 84 of file cmstools.py.

References python.cmstools.EventTree._usedBranches.

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

84  def branch(self,name):
85  # support for aliases
86  alias = self._tree.GetAlias(name)
87  if alias != '': name = alias
88  # access the branch in ttree
89  if name in self._usedBranches:
90  return self._usedBranches[name]
91  self._usedBranches[name]=EventBranch(self,name)
92  return self._usedBranches[name]
def branch(self, name)
Definition: cmstools.py:84
def python.cmstools.EventTree.cppCode (   self,
  name 
)
C++ code for accessing the product inside the full framework

Definition at line 93 of file cmstools.py.

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

Definition at line 110 of file cmstools.py.

References python.cmstools.EventTree._aliases.

110  def getListOfAliases(self):
111  return self._aliases
def getListOfAliases(self)
Definition: cmstools.py:110
def python.cmstools.EventTree.index (   self)
def python.cmstools.EventTree.SetAlias (   self,
  alias,
  fullName 
)
def python.cmstools.EventTree.tree (   self)

Member Data Documentation

python.cmstools.EventTree._aliases
private

Definition at line 83 of file cmstools.py.

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

python.cmstools.EventTree._index
private

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

python.cmstools.EventTree._tree
private

Definition at line 74 of file cmstools.py.

Referenced by ntupleDataFormat._Object.__getattr__(), ntupleDataFormat.BeamSpot.__getattr__(), ntupleDataFormat._Collection.__getitem__(), ntupleDataFormat._Collection.__iter__(), ntupleDataFormat.TrackingNtuple.__iter__(), ntupleDataFormat._SimHitMatchAdaptor._nMatchedSimHits(), ntupleDataFormat._TrackingParticleMatchAdaptor._nMatchedTrackingParticles(), ntupleDataFormat.Event.beamspot(), ntupleDataFormat.TrackingParticle.bestMatchingTrack(), ntupleDataFormat._TrackingParticleMatchAdaptor.bestMatchingTrackingParticle(), ntupleDataFormat._TrackingParticleMatchAdaptor.bestMatchingTrackingParticleFromFirstHit(), ntupleDataFormat.TrackingVertex.daughterTrackingParticles(), ntupleDataFormat.TrackingParticle.decayVertices(), ntupleDataFormat._DetIdStrAdaptor.detIdStr(), 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.TrackingParticle.matchedSeedInfos(), ntupleDataFormat._SimHitMatchAdaptor.matchedSimHitInfos(), ntupleDataFormat.TrackingParticle.matchedTrackInfos(), ntupleDataFormat._TrackingParticleMatchAdaptor.matchedTrackingParticleInfos(), ntupleDataFormat.GluedHit.monoHit(), ntupleDataFormat._HitObject.nseeds(), ntupleDataFormat.Seeds.nSeedsForAlgo(), ntupleDataFormat._HitObject.ntracks(), ntupleDataFormat.TrackingParticle.parentVertex(), ntupleDataFormat._RecoHitAdaptor.phase2OTHits(), ntupleDataFormat.Event.phase2OTHits(), ntupleDataFormat._RecoHitAdaptor.pixelHits(), ntupleDataFormat.Event.pixelHits(), 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().

python.cmstools.EventTree._usedBranches
private