Belle II Software  release-05-01-25
__init__.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 import argparse
5 import basf2.utils as b2utils
6 import ROOT
7 from ROOT import Belle2
8 """
9 Makes analysis variables (which can be used in many of the functions defined
10 in :mod:`modularAnalysis`) available to Python.
11 Details can be found in the VariableManager section at https://software.belle2.org/
12 """
13 from ROOT import gSystem
14 gSystem.Load('libanalysis.so')
15 
16 # import everything into current namespace.
18 
19 
20 def std_vector(*args):
21  """
22  Creates an std::vector which can be passed to pyROOT
23  """
24  v = ROOT.std.vector(type(args[0]))()
25  for x in args:
26  v.push_back(x)
27  return v
28 
29 
30 def getCommandLineOptions():
31  """ Parses the command line options of the fei and returns the corresponding arguments. """
32  parser = argparse.ArgumentParser()
33  parser.add_argument('--no-pager', dest='pager', default=True, action='store_false',
34  help='Use a pager to show output or print to terminal.')
35  args = parser.parse_args()
36  return args
37 
38 
39 def printVars(changedVariableNames=None):
40  """
41  Print list of all available variables.
42  """
43 
44  if changedVariableNames:
45  print(changedVariableNames)
46  print('Available variables in Variable::Manager:')
47  allVars = variables.getVariables()
48  vars = []
49  for v in allVars:
50  vars.append((v.group, v.name, v.description))
51 
52  rows = []
53  current_group = ''
54  for (group, name, description) in sorted(vars):
55  if current_group != group:
56  current_group = group
57  rows.append([group])
58  rows.append([name, description])
59  b2utils.pretty_print_description_list(rows)
60 
61 
62 def getAllTrgNames():
63  """
64  Return all PSNM trigger bit names
65  """
66 
67  bits = Belle2.PyDBObj('TRGGDLDBFTDLBits')
68  evt = Belle2.EventMetaData()
69  Belle2.DBStore.Instance().update(evt)
70  size = Belle2.TRGSummary.c_ntrgWords * Belle2.TRGSummary.c_trgWordSize
71  return [bits.getoutbitname(i) for i in range(size) if bits.getoutbitname(i) != '']
basf2.utils
Definition: utils.py:1
Belle2::PyDBObj
Class to access a DBObjPtr from Python.
Definition: PyDBObj.h:50
Belle2::DBStore::Instance
static DBStore & Instance()
Instance of a singleton DBStore.
Definition: DBStore.cc:36
Belle2::EventMetaData
Store event, run, and experiment numbers.
Definition: EventMetaData.h:43
Belle2::Variable::Manager::Instance
static Manager & Instance()
get singleton instance.
Definition: Manager.cc:27