test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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__
 
def __getitem__
 
def __init__
 
def __iter__
 
def branch
 
def cppCode
 
def getListOfAliases
 
def index
 
def SetAlias
 
def tree
 

Private Member Functions

def __setBranchIndicies
 

Private Attributes

 _aliases
 
 _index
 
 _tree
 
 _usedBranches
 

Detailed Description

Definition at line 66 of file cmstools.py.

Constructor & Destructor Documentation

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

Definition at line 67 of file cmstools.py.

67 
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")
80  self._index = -1
self._aliases = self._tree.GetListOfAliases()

Member Function Documentation

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

Definition at line 118 of file cmstools.py.

References python.cmstools.EventTree.branch().

119  def __getattr__(self, name):
return self.branch(name)
def python.cmstools.EventTree.__getitem__ (   self,
  key 
)

Definition at line 120 of file cmstools.py.

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

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)
return Event(self)
def python.cmstools.EventTree.__iter__ (   self)

Definition at line 127 of file cmstools.py.

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

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 xrange(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 
def python.cmstools.EventTree.__setBranchIndicies (   self)
private

Definition at line 115 of file cmstools.py.

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

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

116  def __setBranchIndicies(self):
117  for branch in self._usedBranches.itervalues():
branch.setIndex(self._index)
def python.cmstools.EventTree.branch (   self,
  name 
)

Definition at line 81 of file cmstools.py.

References python.cmstools.EventTree._usedBranches.

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

81 
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)
return self._usedBranches[name]
def python.cmstools.EventTree.cppCode (   self,
  name 
)
C++ code for accessing the product inside the full framework

Definition at line 90 of file cmstools.py.

90 
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])
return cppCode
def python.cmstools.EventTree.getListOfAliases (   self)

Definition at line 107 of file cmstools.py.

References python.cmstools.EventTree._aliases.

108  def getListOfAliases(self):
return self._aliases
def python.cmstools.EventTree.index (   self)

Definition at line 111 of file cmstools.py.

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

Referenced by BeautifulSoup.PageElement._invert().

112  def index(self):
return self._index
def python.cmstools.EventTree.SetAlias (   self,
  alias,
  fullName 
)

Definition at line 109 of file cmstools.py.

References tree.Tree.tree, SimpleTreeProducer.SimpleTreeProducer.tree, eventstfile.Events.tree, CSCTFanalyzer.tree, CSCTFAnalyzer.tree, core.TreeAnalyzerNumpy.TreeAnalyzerNumpy.tree, HcalTestHistoManager.tree, TreeWriterForEcalCorrection.tree, TkOfflineVariables.tree, AlignmentIORootBase.tree, edm::DuplicateTreeSentry.tree(), IsolatedParticlesGeneratedJets.tree, KVFTest.tree, EcalPerEvtMatacqAnalyzer.tree, CheckSecondary.tree, FWFileEntry.tree(), EcalDeadChannelRecoveryNN< DetIdT >::MultiLayerPerceptronContext.tree, edm::RootOutputTree.tree(), TreeSaver.tree, EcalMatacqAnalyzer.tree, PhysicsTools::TreeReader.tree, edm::FileBlock.tree(), python.cmstools.EventTree.tree(), IsoTrackCalibration.tree, KinematicVertex.tree, HcalIsoTrkAnalyzer.tree, IsoTrackCalib.tree, KinematicParticle.tree, edm::RootTree.tree(), IsolatedGenParticles.tree, edm::root::TFWLiteSelectorMembers.tree(), IsolatedTracksHcalScale.tree, IsolatedTracksNxN.tree, and svgfig.SVG.tree().

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

Definition at line 113 of file cmstools.py.

References python.cmstools.EventTree._tree.

Referenced by ZJetsTreeAnalyzer.ZJetsTreeAnalyzer.beginLoop(), MetTreeProducer.MetTreeProducer.declareVariables(), core.AutoFillTreeProducer.AutoFillTreeProducer.declareVariables(), core.AutoFillTreeProducer.AutoFillTreeProducer.fillTree(), ZJetsTreeAnalyzer.ZJetsTreeAnalyzer.process(), MetTreeProducer.MetTreeProducer.process(), and python.cmstools.EventTree.SetAlias().

114  def tree(self):
return self._tree

Member Data Documentation

python.cmstools.EventTree._aliases
private

Definition at line 80 of file cmstools.py.

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

python.cmstools.EventTree._index
private

Definition at line 79 of file cmstools.py.

Referenced by python.cmstools.EventTree.__getitem__(), python.cmstools.EventTree.__iter__(), python.cmstools.EventBranch.__readData(), python.cmstools.EventTree.__setBranchIndicies(), python.cmstools.EventTree.index(), python.cmstools.EventBranch.setIndex(), and html.HtmlReport.write().

python.cmstools.EventTree._tree
private

Definition at line 71 of file cmstools.py.

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

python.cmstools.EventTree._usedBranches
private

Definition at line 78 of file cmstools.py.

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