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 22 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 26 of file output.py.

References createfilelist.int.

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

Member Function Documentation

◆ fill()

def output.OutputBranch.fill (   self,
  val 
)

Definition at line 52 of file output.py.

References mps_check.array, SummaryTableOutputBranches::NamedBranchPtr.branch, EventStringOutputBranches::NamedBranchPtr.branch, edm::BranchToCount.branch, TableOutputBranches::NamedBranchPtr.branch, TriggerOutputBranches::NamedBranchPtr.branch, output.OutputBranch.branch, LumiOutputBranches::NamedBranchPtr.branch, output.OutputBranch.buff, output.OutputBranch.lenVar, WZElectronSkims53X_cff.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.

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

Member Data Documentation

◆ branch

output.OutputBranch.branch

Definition at line 37 of file output.py.

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

◆ buff

output.OutputBranch.buff

Definition at line 28 of file output.py.

Referenced by output.OutputBranch.fill().

◆ lenVar

output.OutputBranch.lenVar

Definition at line 30 of file output.py.

Referenced by output.OutputBranch.fill().

◆ n

output.OutputBranch.n

Definition at line 31 of file output.py.

Referenced by output.OutputBranch.fill().

◆ precision

output.OutputBranch.precision

Definition at line 32 of file output.py.

Referenced by output.OutputBranch.fill().