All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions | Variables
ICARUSutils Namespace Reference

Functions

def getChannelMappingConfiguration
 Geometry. More...
 
def loadICARUSchannelMappingClass
 
def loadICARUSgeometry
 
def justLoadICARUSgeometry
 

Variables

string __doc__
 
list __all__
 
dictionary ICARUSchannelMappings
 
string DefaultChannelMapping = 'ICARUSsplitInductionChannelMapSetupTool'
 

Function Documentation

def ICARUSutils.getChannelMappingConfiguration (   config)

Geometry.

Definition at line 40 of file ICARUSutils.py.

40 
41  config: "ConfigurationClass object with complete job configuration",
42  registry: "ServiceRegistryClass object with the configuration of all services",
43  ) -> "configuration of channel mapping algorithm as a FHiCL parameter set":
44 
45  #
46  # Try first if there is a configuration in the geometry service configuration;
47  # this is the "default" for the future. If not, back up to
48  # ExptGeoHelperInterface service.
49  #
50 
51  serviceName = 'Geometry'
52  try:
53  serviceConfig = config.service(serviceName) if config else registry.config(serviceName)
54  except Exception: serviceConfig = None
55  if serviceConfig and serviceConfig.has_key('ChannelMapping'):
56  mapperConfig = galleryUtils.getTableIfPresent(serviceConfig, 'ChannelMapping')
57  else:
58  serviceName = 'ExptGeoHelperInterface'
59  serviceConfig = config.service(serviceName) if config else registry.config(serviceName)
60  if serviceConfig is None:
61  raise RuntimeError("Failed to retrieve the configuration for %s service" % serviceName)
62  if serviceConfig.get(str)('service_provider') != 'IcarusGeometryHelper':
63  raise RuntimeError(
64  "{} in configuration is '{}', not IcarusGeometryHelper"
65  .format(serviceName, serviceConfig['service_provider'])
66  )
67  # if
68  mapperConfig = galleryUtils.getTableIfPresent(serviceConfig, 'Mapper')
69  # if no mapper in geometry service (or no geometry service??)
70 
71  if mapperConfig:
72  try:
73  plugin_type = mapperConfig.get(str)('tool_type')
74  except:
75  raise RuntimeError(
76  "{} service configuration of channel mapping is missing the tool_type:\n{}"
77  .format(serviceName, mapperConfig.to_indented_string(" "))
78  )
79  # try ... except
80  else: plugin_type = DefaultChannelMapping
81 
82  return plugin_type
83 # getChannelMappingConfiguration()
84 
static std::string format(PyObject *obj, unsigned int pos, unsigned int indent, unsigned int maxlen, unsigned int depth)
Definition: fclmodule.cxx:374
def ICARUSutils.justLoadICARUSgeometry (   configFile,
  mappingClass = None 
)
Loads and returns ICARUS geometry from the specified configuration file.

This is a one-stop procedure recommended only when running interactively.

Definition at line 154 of file ICARUSutils.py.

155 def justLoadICARUSgeometry(configFile, mappingClass = None):
156  """Loads and returns ICARUS geometry from the specified configuration file.
157 
158  This is a one-stop procedure recommended only when running interactively.
159  """
160  return loadICARUSgeometry(config=LArSoftUtils.ConfigurationClass(configFile))
161 # justLoadICARUSgeometry()
162 
def justLoadICARUSgeometry
Definition: ICARUSutils.py:154
def loadICARUSgeometry
Definition: ICARUSutils.py:141
def ICARUSutils.loadICARUSchannelMappingClass (   config)

Definition at line 86 of file ICARUSutils.py.

86 
87  config: "ConfigurationClass object with complete job configuration",
88  registry: "ServiceRegistryClass object with the configuration of all services",
89  ) -> "Class object for the proper channel mapping":
90 
91  #
92  # we need to:
93  # 1. find out which mapping is required
94  # 2. load the proper libraries
95  # 3. return the Python class object for the mapping class we want
96  #
97 
98  #
99  # 1. find out which mapping is required: known configurations
100  #
101  plugin_type = getChannelMappingConfiguration(config=config, registry=registry)
102 
103  #
104  # 2. load the proper libraries
105  #
106 
107  # get the specification record
108  try: mappingInfo = ICARUSchannelMappings[plugin_type]
109  except KeyError:
110  # when you get to this error, check that the tool name in the configuration
111  # is actually spelled correctly first...
112  raise RuntimeError(
113  "Mapping plug in not supported: '{}': Python library needs to be updated."
114  .format(plugin_type)
115  )
116  # try ... except
117 
118  # load the libraries
119  for codeObj in mappingInfo.get('load', []):
120  LArSoftUtils.SourceCode.load(codeObj)
121 
122  # get the class object
123  try: mapperClass = ROOTutils.getROOTclass(mappingInfo['mapperClassName'])
124  except AttributeError:
125  # this needs investigation, as the code above should be sufficient to it
126  raise RuntimeError(
127  "The library with '{}' has not been correctly loaded!"
128  .format(mappingInfo['mapperClassName'])
129  )
130  # try ... except
131 
132  #
133  # 3. return the Python class object for the mapping class we want
134  #
135  return mapperClass
136 
137 # loadICARUSchannelMappingClass()
138 
def getChannelMappingConfiguration
Geometry.
Definition: ICARUSutils.py:40
static std::string format(PyObject *obj, unsigned int pos, unsigned int indent, unsigned int maxlen, unsigned int depth)
Definition: fclmodule.cxx:374
def ICARUSutils.loadICARUSgeometry (   config = None,
  registry = None,
  mappingClass = None 
)
Loads and returns ICARUS geometry with the standard ICARUS channel mapping.

See `loadGeometry()` for the meaning of the arguments.

Definition at line 141 of file ICARUSutils.py.

142  ):
143  """Loads and returns ICARUS geometry with the standard ICARUS channel mapping.
144 
145  See `loadGeometry()` for the meaning of the arguments.
146  """
147 
148  if mappingClass is None:
149  mappingClass = loadICARUSchannelMappingClass(config=config, registry=registry)
150  return LArSoftUtils.loadGeometry \
151  (config=config, registry=registry, mapping=mappingClass)
152 # loadICARUSgeometry()
153 
def loadICARUSchannelMappingClass
Definition: ICARUSutils.py:86

Variable Documentation

list ICARUSutils.__all__
Initial value:
1 = [
2  'loadICARUSgeometry',
3  'justLoadICARUSgeometry',
4 ]

Definition at line 10 of file ICARUSutils.py.

string ICARUSutils.__doc__
Initial value:
1 = """
2 Collection of utilities to interface ICARUS with python, gallery and LArSoft.
3 
4 This module requires ROOT.
5 """

Definition at line 4 of file ICARUSutils.py.

string ICARUSutils.DefaultChannelMapping = 'ICARUSsplitInductionChannelMapSetupTool'

Definition at line 34 of file ICARUSutils.py.

dictionary ICARUSutils.ICARUSchannelMappings
Initial value:
1 = {
2  'ICARUSsplitInductionChannelMapSetupTool': {
3  'tool_type': 'ICARUSsplitInductionChannelMapSetupTool',
4  'mapperClassName': 'icarus::ICARUSChannelMapAlg',
5  'load': [
6  'larcorealg_Geometry',
7  'icarusalg/Geometry/ICARUSChannelMapAlg.h',
8  'icarusalg/Geometry/ICARUSstandaloneGeometrySetup.h',
9  'icarusalg_Geometry',
10  ],
11  }, # 'ICARUSsplitInductionChannelMapSetupTool'
12 }

Definition at line 22 of file ICARUSutils.py.