ATLAS Offline Software
Functions | Variables
ros2rob_from_partition Namespace Reference

Functions

def argparser ()
 
def make_parser_print_help_on_error (parser)
 
def get_roses (pfname, pname)
 
def get_ros2rob (roses)
 
def get_robs (ros)
 
def get_roib_robs ()
 
def print_ros2rob (ros2rob, out)
 
def print_header (dbfile, outname, out)
 
def print_footer (out)
 

Variables

def args = argparser().parse_args()
 
def out = open(args.output_file, 'w') if args.output_file else stdout
 
 file
 

Function Documentation

◆ argparser()

def ros2rob_from_partition.argparser ( )

Definition at line 13 of file ros2rob_from_partition.py.

13 def argparser():
14  parser = ArgumentParser(description='Produce a ros2rob map, as a python '
15  'dictionary, from a given partition.')
16  parser.add_argument('--database_file', '-d', required=True,
17  help='A partition filename (e.g. ATLAS.data.xml).')
18  parser.add_argument('--partition', '-p', required=True,
19  help='A partition filename. The name of the partition '
20  'that is read from pfile (e.g. ATLAS).')
21  parser.add_argument('--output_file', '-o',
22  help='The output filename. The name of the file to which '
23  'the ros2rob map is written. If omitted, stdout is '
24  'used (e.g. myros2rob.py).')
26  return parser
27 

◆ get_robs()

def ros2rob_from_partition.get_robs (   ros)
Get the list of ROBs that correspond to a ROS

Definition at line 62 of file ros2rob_from_partition.py.

62 def get_robs(ros):
63  """
64  Get the list of ROBs that correspond to a ROS
65  """
66  return [eformat.helper.SourceIdentifier(rol.Id).code()
67  for robin in ros.Contains for rol in robin.Contains]
68 

◆ get_roib_robs()

def ros2rob_from_partition.get_roib_robs ( )
Get a hardcoded list of RoIBuilder ROB IDs which are not listed in the partition

Definition at line 69 of file ros2rob_from_partition.py.

69 def get_roib_robs():
70  """
71  Get a hardcoded list of RoIBuilder ROB IDs which are not listed in the partition
72  """
73  return [
74  # CTP
75  0x770001,
76  # L1Calo
77  0x7300a8, 0x7300a9, 0x7300aa, 0x7300ab, 0x7500ac, 0x7500ad,
78  # L1Topo
79  0x910081, 0x910091, 0x910082, 0x910092]
80 

◆ get_ros2rob()

def ros2rob_from_partition.get_ros2rob (   roses)
Get the ros2rob map from the ROS list

Definition at line 48 of file ros2rob_from_partition.py.

48 def get_ros2rob(roses):
49  """
50  Get the ros2rob map from the ROS list
51  """
52  ros2rob = {}
53  for ros in roses:
54  if ros.id in ros2rob:
55  print("WARNING: %s is repeated in the partition: ignoring "
56  "second occurrence", file=stderr)
57  else:
58  ros2rob[ros.id] = get_robs(ros)
59  ros2rob['RoIBuilder'] = get_roib_robs()
60  return ros2rob
61 

◆ get_roses()

def ros2rob_from_partition.get_roses (   pfname,
  pname 
)
Get all the ROSes and swRODs in the partition

Definition at line 39 of file ros2rob_from_partition.py.

39 def get_roses(pfname, pname):
40  """
41  Get all the ROSes and swRODs in the partition
42  """
43  partition = Project(pfname).getObject('Partition', pname)
44  roses = partition.get('ROS')
45  swrods = partition.get('SwRodApplication')
46  return roses + swrods
47 

◆ make_parser_print_help_on_error()

def ros2rob_from_partition.make_parser_print_help_on_error (   parser)
Alter an ArgumentParser so that it shows a help msg whenever there is an 
error in the command line

Definition at line 28 of file ros2rob_from_partition.py.

29  """
30  Alter an ArgumentParser so that it shows a help msg whenever there is an
31  error in the command line
32  """
33  def error(self, msg):
34  print('error: %s\n' % msg, file=stderr)
35  self.print_help()
36  exit(2)
37  parser.error = MethodType(error, parser)
38 

◆ print_footer()

def ros2rob_from_partition.print_footer (   out)

Definition at line 112 of file ros2rob_from_partition.py.

112 def print_footer(out):
113  footer = """
114 class ROSToROBMap:
115 \tdef __init__(self):
116 \t\tself.data = ros2rob
117 
118 \tdef get_mapping(self):
119 \t\treturn self.data
120 """
121  print(footer, file=out)
122 
123 # main

◆ print_header()

def ros2rob_from_partition.print_header (   dbfile,
  outname,
  out 
)

Definition at line 100 of file ros2rob_from_partition.py.

100 def print_header(dbfile, outname, out):
101  header = f"""
102 #
103 # Copyright (C) 2002-{datetime.now().year} CERN for the benefit of the ATLAS collaboration
104 #
105 '''
106 @file {outname}
107 @brief Store ROS to ROB map extracted from {dbfile}
108 '''
109 """
110  print(header, file=out)
111 

◆ print_ros2rob()

def ros2rob_from_partition.print_ros2rob (   ros2rob,
  out 
)
Print the ros2rob map as an easily readable/editable python dictionary

Definition at line 81 of file ros2rob_from_partition.py.

81 def print_ros2rob(ros2rob, out):
82  """
83  Print the ros2rob map as an easily readable/editable python dictionary
84  """
85  print("ros2rob = {", file=out)
86  count = 0
87  for k, v in ros2rob.items():
88  count += 1
89  print("\t'%s': \n\t[" % k, file=out)
90  for i in range(len(v)):
91  print("\t\t%s" % hex(v[i]), end=' ', file=out)
92  if i+1 != len(v):
93  print(",", file=out)
94  else:
95  print("\n\t]", end=' ', file=out)
96  if count != len(ros2rob):
97  print(",", file=out)
98  print("\n}", file=out)
99 

Variable Documentation

◆ args

def ros2rob_from_partition.args = argparser().parse_args()

Definition at line 125 of file ros2rob_from_partition.py.

◆ file

ros2rob_from_partition.file

Definition at line 127 of file ros2rob_from_partition.py.

◆ out

def ros2rob_from_partition.out = open(args.output_file, 'w') if args.output_file else stdout

Definition at line 126 of file ros2rob_from_partition.py.

ros2rob_from_partition.get_roib_robs
def get_roib_robs()
Definition: ros2rob_from_partition.py:69
ros2rob_from_partition.print_ros2rob
def print_ros2rob(ros2rob, out)
Definition: ros2rob_from_partition.py:81
ros2rob_from_partition.get_roses
def get_roses(pfname, pname)
Definition: ros2rob_from_partition.py:39
NSWL1::Project
Polygon Project(const Polygon &p, float Zinit, float Zfin)
Definition: GeoUtils.cxx:19
ros2rob_from_partition.argparser
def argparser()
Definition: ros2rob_from_partition.py:13
histSizes.code
code
Definition: histSizes.py:129
ros2rob_from_partition.make_parser_print_help_on_error
def make_parser_print_help_on_error(parser)
Definition: ros2rob_from_partition.py:28
ros2rob_from_partition.print_footer
def print_footer(out)
Definition: ros2rob_from_partition.py:112
ros2rob_from_partition.get_ros2rob
def get_ros2rob(roses)
Definition: ros2rob_from_partition.py:48
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:194
calibdata.exit
exit
Definition: calibdata.py:235
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
ros2rob_from_partition.get_robs
def get_robs(ros)
Definition: ros2rob_from_partition.py:62
ros2rob_from_partition.print_header
def print_header(dbfile, outname, out)
Definition: ros2rob_from_partition.py:100
get_generator_info.error
error
Definition: get_generator_info.py:40