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 |
Definition at line 65 of file cmstools.py.
def python::cmstools::EventTree::__init__ | ( | self, | |
obj | |||
) |
Definition at line 66 of file cmstools.py.
00067 : 00068 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") 00069 treeName = 'Events' 00070 if isinstance(obj, ROOT.TTree): 00071 self._tree = obj 00072 elif isinstance(obj, ROOT.TFile): 00073 self._tree = obj.Get(treeName) 00074 elif isinstance(obj, str): 00075 self._tree = ROOT.TFile.Open(obj).Get(treeName) 00076 else: 00077 raise cmserror("EventTree accepts only TTrees, TFiles and filenames") 00078 self._usedBranches = dict() 00079 self._index = -1 self._aliases = self._tree.GetListOfAliases()
def python::cmstools::EventTree::__getattr__ | ( | self, | |
name | |||
) |
Definition at line 117 of file cmstools.py.
def python::cmstools::EventTree::__getitem__ | ( | self, | |
key | |||
) |
Definition at line 119 of file cmstools.py.
def python::cmstools::EventTree::__iter__ | ( | self | ) |
Definition at line 126 of file cmstools.py.
00127 : 00128 # flushing/initializing the root buffers 00129 entry = 0 00130 self._index = entry 00131 self.__setBranchIndicies() 00132 self._tree.GetEntry(self._index,0) 00133 # the real loop 00134 for entry in xrange(self._tree.GetEntries()): 00135 self._index = entry 00136 self.__setBranchIndicies() 00137 self._tree.GetEntry(self._index,0) 00138 yield Event(self) # TODO: don't return a new object but update the old one 00139
def python::cmstools::EventTree::__setBranchIndicies | ( | self | ) | [private] |
Definition at line 114 of file cmstools.py.
def python::cmstools::EventTree::branch | ( | self, | |
name | |||
) |
Definition at line 80 of file cmstools.py.
00081 : 00082 # support for aliases 00083 alias = self._tree.GetAlias(name) 00084 if alias != '': name = alias 00085 # access the branch in ttree 00086 if name in self._usedBranches: 00087 return self._usedBranches[name] 00088 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 89 of file cmstools.py.
00090 : 00091 """C++ code for accessing the product inside the full framework""" 00092 alias = self._tree.GetAlias(name) 00093 if alias != '': name = alias 00094 tmpBranch = self._tree.GetBranch(name) 00095 typeString = ROOT.branchToClass(tmpBranch).GetName() 00096 if "edm::Wrapper" in typeString: 00097 typeString = typeString.replace("<edm::Wrapper","") 00098 typeString = typeString.rstrip(">") 00099 nameParts = name.split("_") 00100 if nameParts[2] == "": 00101 cppCode = 'edm::Handle<%s > dummy;\nevent.getByLabel("%s", dummy);'\ 00102 %(typeString, nameParts[1]) 00103 else: 00104 cppCode = 'edm::Handle<%s > dummy;\nevent.getByLabel("%s", "%s", dummy);'\ 00105 %(typeString, nameParts[1], nameParts[2]) return cppCode
def python::cmstools::EventTree::getListOfAliases | ( | self | ) |
Definition at line 106 of file cmstools.py.
def python::cmstools::EventTree::index | ( | self | ) |
Definition at line 110 of file cmstools.py.
def python::cmstools::EventTree::SetAlias | ( | self, | |
alias, | |||
fullName | |||
) |
Definition at line 108 of file cmstools.py.
def python::cmstools::EventTree::tree | ( | self | ) |
Definition at line 112 of file cmstools.py.
python::cmstools::EventTree::_aliases [private] |
Definition at line 66 of file cmstools.py.
python::cmstools::EventTree::_index [private] |
Definition at line 66 of file cmstools.py.
python::cmstools::EventTree::_tree [private] |
Definition at line 66 of file cmstools.py.
Definition at line 66 of file cmstools.py.