CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
output.OutputBranch Class Reference

Public Member Functions

def __init__ (self, tree, name, rootBranchType, n=1, lenVar=None, title=None, limitedPrecision=False)
 
def fill (self, val)
 

Public Attributes

 branch
 
 buff
 
 lenVar
 
 n
 
 precision
 

Detailed Description

Definition at line 20 of file output.py.

Constructor & Destructor Documentation

◆ __init__()

def output.OutputBranch.__init__ (   self,
  tree,
  name,
  rootBranchType,
  n = 1,
  lenVar = None,
  title = None,
  limitedPrecision = False 
)

Definition at line 24 of file output.py.

References createfilelist.int.

24  ):
25  n = int(n)
26  self.buff = array(
27  _rootBranchType2PythonArray[rootBranchType], n * [0. if rootBranchType in 'FD' else 0])
28  self.lenVar = lenVar
29  self.n = n
30  self.precision = ROOT.MiniFloatConverter.ReduceMantissaToNbitsRounding(
31  limitedPrecision) if limitedPrecision and rootBranchType == 'F' else lambda x: x
32  # check if a branch was already there
33  existingBranch = tree.GetBranch(name)
34  if (existingBranch):
35  self.branch = existingBranch
36  self.branch.SetAddress(self.buff)
37  else:
38  if lenVar != None:
39  self.branch = tree.Branch(
40  name, self.buff, "%s[%s]/%s" % (name, lenVar, rootBranchType))
41  elif n == 1:
42  self.branch = tree.Branch(
43  name, self.buff, name + "/" + rootBranchType)
44  else:
45  self.branch = tree.Branch(
46  name, self.buff, "%s[%d]/%s" % (name, n, rootBranchType))
47  if title:
48  self.branch.SetTitle(title)
49 

Member Function Documentation

◆ fill()

def output.OutputBranch.fill (   self,
  val 
)

Definition at line 50 of file output.py.

References mps_check.array, SummaryTableOutputBranches::NamedBranchPtr.branch, EventStringOutputBranches::NamedBranchPtr.branch, edm::BranchToCount.branch, output.OutputBranch.branch, TableOutputBranches::NamedBranchPtr.branch, TriggerOutputBranches::NamedBranchPtr.branch, LumiOutputBranches::NamedBranchPtr.branch, output.OutputBranch.buff, output.OutputBranch.lenVar, SiStripPI.max, cms::cuda::AtomicPairCounter::Counters.n, Benchmark::PhaseSpace.n, output.OutputBranch.n, CMSCGENnorm.n, DDTrackerAngular.n, DDMuonAngular.n, DDHCalAngular.n, DDGEMAngular.n, edm::CountAndLimit.n, BaseNumericalRandomGenerator.n, PhysicsTools::Spline.n, DDTrackerRingAlgo.n, DDTrackerIrregularRingAlgo.n, edm::StatsCount.n, HcalRawToDigi::Statistics.n, gen.n, cms::cuda::OneToManyAssoc.n, plotscripts.SawTeethFunction.n, JsonOutputProducer::JsonConfiguration.n, JsonOutputProducer::JsonTriggerEventState.n, output.OutputBranch.precision, FWTableViewManager::TableEntry.precision, heppy::Davismt2.precision, and heppy::mt2w_bisect::mt2w.precision.

50  def fill(self, val):
51  if self.lenVar:
52  if len(self.buff) < len(val): # realloc
53  self.buff = array(self.buff.typecode, max(
54  len(val), 2 * len(self.buff)) * [0. if self.buff.typecode in 'fd' else 0])
55  self.branch.SetAddress(self.buff)
56  for i, v in enumerate(val):
57  self.buff[i] = self.precision(v)
58  elif self.n == 1:
59  self.buff[0] = self.precision(val)
60  else:
61  if len(val) != self.n:
62  raise RuntimeError("Mismatch in filling branch %s of fixed length %d with %d values (%s)" % (
63  self.branch.GetName(), self.n, len(val), val))
64  for i, v in enumerate(val):
65  self.buff[i] = v
66 
67 

Member Data Documentation

◆ branch

output.OutputBranch.branch

Definition at line 35 of file output.py.

Referenced by python.cmstools.EventTree.__getattr__(), and output.OutputBranch.fill().

◆ buff

output.OutputBranch.buff

Definition at line 26 of file output.py.

Referenced by output.OutputBranch.fill().

◆ lenVar

output.OutputBranch.lenVar

Definition at line 28 of file output.py.

Referenced by output.OutputBranch.fill().

◆ n

output.OutputBranch.n

Definition at line 29 of file output.py.

Referenced by output.OutputBranch.fill().

◆ precision

output.OutputBranch.precision

Definition at line 30 of file output.py.

Referenced by output.OutputBranch.fill().