CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions
python.cmstools Namespace Reference

Classes

class  cmserror
 
class  Event
 
class  EventBranch
 
class  EventTree
 

Functions

def all
 workaround iterator generators for ROOT classes More...
 
def createBranchBuffer
 auto branch types (Chris Jones) More...
 
def loop
 

Detailed Description

Python helper tools for CMS FWLite

benedikt.hegner@cern.ch

Function Documentation

def python.cmstools.all (   container)

workaround iterator generators for ROOT classes

Definition at line 23 of file cmstools.py.

23 
24 def all(container):
25 
26  # loop over ROOT::TTree and similar
27  if hasattr(container,'GetEntries'):
28  try:
29  entries = container.GetEntries()
30  for entry in xrange(entries):
31  yield entry
32  except:
33  raise cmserror("Looping of %s failed" %container)
34 
35  # loop over std::vectors and similar
36  elif hasattr(container, 'size'):
37  try:
38  entries = container.size()
39  for entry in xrange(entries):
40  yield container[entry]
41  except:
42  pass
43 
# loop over containers with begin and end iterators
def all
workaround iterator generators for ROOT classes
Definition: cmstools.py:23
def python.cmstools.createBranchBuffer (   branch)

auto branch types (Chris Jones)

Definition at line 51 of file cmstools.py.

References reco.if().

51 
52 def createBranchBuffer(branch):
53  reColons = re.compile(r'::')
54  reCloseTemplate =re.compile(r'>')
55  reOpenTemplate =re.compile(r'<')
56  branchType = ROOT.branchToClass(branch)
57  #buffer = eval ('ROOT.'+reColons.sub(".",reOpenTemplate.sub("(ROOT.",reCloseTemplate.sub(")",branchType.GetName())))+'()')
58  buffer = ROOT.MakeRootClass(branchType.GetName()) ()
59  if( branch.GetName()[-1] != '.') and (branch.GetName()!="EventAuxiliary"):
60  branch.SetAddress(buffer)
61  else:
62  branch.SetAddress(ROOT.AddressOf(buffer))
63  return buffer
64 
def createBranchBuffer
auto branch types (Chris Jones)
Definition: cmstools.py:51
if(dp >Float(M_PI)) dp-
def python.cmstools.loop (   begin,
  end 
)
Convert a pair of C++ iterators into a python generator

Definition at line 44 of file cmstools.py.

Referenced by optutl::CommandLineParser._getSectionFiles(), RawDataConverter.ClearData(), CmsShowMainFrame.CmsShowMainFrame(), DDCheckMaterial(), SiStripTFile.dirContent(), MillePedeAlignmentAlgorithm.doIO(), LaserAlignment.DumpPosFileSet(), LaserAlignment.DumpStripFileSet(), SETSeedFinder.estimateMomentum(), PhysicsTools::MVAComputer.evalInternal(), LMFDefFabric.getColor(), LMFDefFabric.getColorFromID(), RawDataConverter.GetDigis(), LMFDefFabric.getRunTag(), LMFDefFabric.getRunTagFromID(), LMFDefFabric.getTrigType(), LMFDefFabric.getTrigTypeFromID(), pat::EventHypothesis.loop(), output(), optutl::CommandLineParser.parseArguments(), EcalDigiSelector.produce(), SiStripTFile.readDQMFormat(), TrajectoryManager.reconstruct(), stdcomb.recursive_combination(), LMFColoredTable.setColor(), LMFColoredTable.setSystem(), HcalTestAnalysis.update(), DDI::Polyhedra.volume(), and DDI::Polycone.volume().

44 
45 def loop(begin, end):
46  """Convert a pair of C++ iterators into a python generator"""
47  while (begin != end):
48  yield begin.__deref__() #*b
49  begin.__preinc__() #++b