CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 67 of file cmstools.py.

Constructor & Destructor Documentation

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

Definition at line 68 of file cmstools.py.

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

Member Function Documentation

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

Definition at line 119 of file cmstools.py.

References LumiOutputBranches.branch(), TableOutputBranches.branch(), SummaryTableOutputBranches::NamedBranchPtr.branch, EventStringOutputBranches::NamedBranchPtr.branch, edm::BranchToCount.branch, TableOutputBranches::NamedBranchPtr.branch, LumiOutputBranches::NamedBranchPtr.branch, TriggerOutputBranches::NamedBranchPtr.branch, python.cmstools.EventTree.branch(), NanoAODOutputModule::CommonEventBranches.branch(), NanoAODOutputModule::CommonLumiBranches.branch(), and NanoAODOutputModule::CommonRunBranches.branch().

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

Definition at line 121 of file cmstools.py.

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

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

Definition at line 128 of file cmstools.py.

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

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

Definition at line 116 of file cmstools.py.

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

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

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

Definition at line 82 of file cmstools.py.

References python.cmstools.EventTree._usedBranches.

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

82 
83  def branch(self,name):
84  # support for aliases
85  alias = self._tree.GetAlias(name)
86  if alias != '': name = alias
87  # access the branch in ttree
88  if name in self._usedBranches:
89  return self._usedBranches[name]
90  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 91 of file cmstools.py.

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

Definition at line 108 of file cmstools.py.

References python.cmstools.EventTree._aliases.

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

Definition at line 112 of file cmstools.py.

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

Referenced by BeautifulSoup.PageElement._invert().

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

Definition at line 110 of file cmstools.py.

References tree.Tree.tree, HIPMonitorVariables.tree, SimpleTreeProducer.SimpleTreeProducer.tree, eventstfile.Events.tree, CSCTFAnalyzer.tree, CSCTFanalyzer.tree, core.TreeAnalyzerNumpy.TreeAnalyzerNumpy.tree, TreeWriterForEcalCorrection.tree, AlignmentIORootBase.tree, TkOfflineVariables.tree, HIPTwoBodyDecayAnalyzer.tree, EcalPerEvtMatacqAnalyzer.tree, edm::DuplicateTreeSentry.tree(), HcalIsoTrackAnalyzer.tree, CheckSecondary.tree, FWFileEntry.tree(), KVFTest.tree, EcalMatacqAnalyzer.tree, edm::RootOutputTree.tree(), BPHHistoSpecificDecay.tree, PhysicsTools::TreeReader.tree, KinematicVertex.tree, IsoTrackCalibration.tree, python.cmstools.EventTree.tree(), edm::FileBlock.tree(), IsoTrackCalib.tree, KinematicParticle.tree, edm::root::TFWLiteSelectorMembers.tree(), edm::RootTree.tree(), TkAlMap.TkAlMap.tree, HcalIsoTrkSimAnalyzer.tree, HcalIsoTrkAnalyzer.tree, and svgfig.SVG.tree().

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

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

115  def tree(self):
return self._tree

Member Data Documentation

python.cmstools.EventTree._aliases
private

Definition at line 81 of file cmstools.py.

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

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(), 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 72 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

Definition at line 79 of file cmstools.py.

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