5 Collection of utilities to interface ICARUS with python, gallery and LArSoft.
7 This module requires ROOT.
12 'justLoadICARUSgeometry',
18 from ROOTutils
import ROOT
22 ICARUSchannelMappings = {
23 'ICARUSsplitInductionChannelMapSetupTool': {
24 'tool_type':
'ICARUSsplitInductionChannelMapSetupTool',
25 'mapperClassName':
'icarus::ICARUSChannelMapAlg',
27 'larcorealg_Geometry',
28 'icarusalg/Geometry/ICARUSChannelMapAlg.h',
29 'icarusalg/Geometry/ICARUSstandaloneGeometrySetup.h',
34 DefaultChannelMapping =
'ICARUSsplitInductionChannelMapSetupTool'
40 config:
"ConfigurationClass object with complete job configuration",
41 registry:
"ServiceRegistryClass object with the configuration of all services",
42 ) ->
"configuration of channel mapping algorithm as a FHiCL parameter set":
50 serviceName =
'Geometry'
52 serviceConfig = config.service(serviceName)
if config
else registry.config(serviceName)
53 except Exception: serviceConfig =
None
54 if serviceConfig
and serviceConfig.has_key(
'ChannelMapping'):
57 serviceName =
'ExptGeoHelperInterface'
58 serviceConfig = config.service(serviceName)
if config
else registry.config(serviceName)
59 if serviceConfig
is None:
60 raise RuntimeError(
"Failed to retrieve the configuration for %s service" % serviceName)
61 if serviceConfig.get(str)(
'service_provider') !=
'IcarusGeometryHelper':
63 "{} in configuration is '{}', not IcarusGeometryHelper"
64 .
format(serviceName, serviceConfig[
'service_provider'])
72 plugin_type = mapperConfig.get(str)(
'tool_type')
75 "{} service configuration of channel mapping is missing the tool_type:\n{}"
76 .
format(serviceName, mapperConfig.to_indented_string(
" "))
79 else: plugin_type = DefaultChannelMapping
86 config:
"ConfigurationClass object with complete job configuration",
87 registry:
"ServiceRegistryClass object with the configuration of all services",
88 ) ->
"Class object for the proper channel mapping":
107 try: mappingInfo = ICARUSchannelMappings[plugin_type]
112 "Mapping plug in not supported: '{}': Python library needs to be updated."
118 for codeObj
in mappingInfo.get(
'load', []):
119 LArSoftUtils.SourceCode.load(codeObj)
123 except AttributeError:
126 "The library with '{}' has not been correctly loaded!"
127 .
format(mappingInfo[
'mapperClassName'])
140 config =
None, registry =
None, mappingClass =
None,
142 """Loads and returns ICARUS geometry with the standard ICARUS channel mapping.
144 See `loadGeometry()` for the meaning of the arguments.
147 if mappingClass
is None:
149 return LArSoftUtils.loadGeometry \
150 (config=config, registry=registry, mapping=mappingClass)
155 """Loads and returns ICARUS geometry from the specified configuration file.
157 This is a one-stop procedure recommended only when running interactively.
def getChannelMappingConfiguration
Geometry.
static std::string format(PyObject *obj, unsigned int pos, unsigned int indent, unsigned int maxlen, unsigned int depth)
def loadICARUSchannelMappingClass
def justLoadICARUSgeometry