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