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

Classes

class  SimpleServiceLoader
 
class  GeometryServiceGetter
 
class  ServiceManagerInterface
 
class  ServiceManagerClass
 
class  ServiceManagerInstance
 

Functions

def loadGeometry
 LArSoft. More...
 
def justLoadGeometry
 
def loadSimpleService
 
def makeStringList
 special known services More...
 

Variables

string __doc__
 
list __all__
 
 SourceCode = galleryUtils.SourceCode
 Pass-through. More...
 
 readHeader = galleryUtils.readHeader
 

Function Documentation

def LArSoftUtils.justLoadGeometry (   configFile,
  mapping = None 
)
Loads and returns the geometry from the specified configuration file.

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

Definition at line 107 of file icarusalg/icarusalg/gallery/helpers/python/LArSoftUtils.py.

108 def justLoadGeometry(configFile, mapping=None):
109  """Loads and returns the geometry from the specified configuration file.
110 
111  This is a one-stop procedure recommended only when running interactively.
112  """
113  return loadGeometry(config=ConfigurationClass(configFile), mapping=mapping)
114 # justLoadGeometry()
115 
def LArSoftUtils.loadGeometry (   config = None,
  registry = None,
  mapping = None 
)

LArSoft.

The argument `config` is an instance of `ConfigurationClass`.

If a config object is provided, configurations will be read from there.
Otherwise, they will be read from the registry.
If a registry is provided, the services will be registered in there.

Definition at line 50 of file icarusalg/icarusalg/gallery/helpers/python/LArSoftUtils.py.

50 
51 def loadGeometry(config=None, registry=None, mapping=None):
52  """The argument `config` is an instance of `ConfigurationClass`.
53 
54  If a config object is provided, configurations will be read from there.
55  Otherwise, they will be read from the registry.
56  If a registry is provided, the services will be registered in there.
57  """
58  assert(config or registry)
59  serviceName = 'Geometry'
60 
61  # deal with messagefacility first
62  if not (registry and registry.has("message")):
63  messageConfig = config.service("message") if config else registry.config("message")
64  startMessageFacility(messageConfig) # use default name
65  if registry: registry.register("message", None) # there is no direct access, sorry
66  # if need to load message facility
67 
68  geometryConfig = config.service(serviceName) if config else registry.config(serviceName)
69  if geometryConfig is None:
70  raise RuntimeError("Failed to retrieve the configuration for %s service" % serviceName)
71 
72  if not mapping:
73  SourceCode.loadHeaderFromUPS('larcorealg/Geometry/ChannelMapStandardAlg.h')
74  mapping = ROOT.geo.ChannelMapStandardAlg
75  SourceCode.loadHeaderFromUPS("larcorealg/Geometry/StandaloneGeometrySetup.h")
76  SourceCode.loadLibrary("larcorealg_Geometry")
77  service = ROOT.lar.standalone.SetupGeometry[mapping](geometryConfig)
78  if registry: registry.register(serviceName, service)
79 
80  # make it easy to print points and vectors in python
81  for varName in ( 'Point_t', 'Vector_t', ):
82  try: klass = getattr(ROOT.geo, varName)
83  except AttributeError: continue
84  klass.__str__ = ROOTutils.TVector3ToString
85  # ... and IDs...
86  for varName in ( 'CryostatID', 'TPCID', 'PlaneID', 'WireID', ):
87  try: klass = getattr(ROOT.geo, varName)
88  except AttributeError: continue
89  klass.__str__ = klass.toString
90  # for ID
91  for varName in ( 'CryostatID', 'TPCsetID', 'ROPID', ):
92  try: klass = getattr(ROOT.readout, varName)
93  except AttributeError: continue
94  klass.__str__ = klass.toString
95  # for ID
96  # ... and geometry objects
97  for varName in ( 'CryostatGeo', 'TPCGeo', 'PlaneGeo', 'WireGeo', 'OpDetGeo', 'AuxDetGeo', ):
98  try: klass = getattr(ROOT.geo, varName)
99  except AttributeError: continue
100  klass.__str__ = getattr(klass, varName[:-3] + "Info")
101  # for geo object
102 
103  return service
104 # loadGeometry()
105 
def LArSoftUtils.loadSimpleService (   serviceClass,
  config = None,
  registry = None,
  interfaceClass = None,
  args = [] 
)
Loads a service assuming some simple requirements:
 * no dependency from other services
 * constructor accepts a FHiCL parameter set

If a config object is provided, configurations will be read from there.
Otherwise, they will be read from the registry.
If a registry is provided, the services will be registered in there.

The service configuration is read from an item called as `interfaceClass`,
or `serviceClass` itself if `interfaceClass` is None, with "Service" appended.

As a first attempt, the test helpers are attempted to load the service, and
the arguments are used to construct a `providers_type` object.
If there is no test helper for `serviceClass`, then direct construction is
attempted using all the specified arguments.

Definition at line 118 of file icarusalg/icarusalg/gallery/helpers/python/LArSoftUtils.py.

119  (serviceClass, config=None, registry=None, interfaceClass=None, args = []):
120  """Loads a service assuming some simple requirements:
121  * no dependency from other services
122  * constructor accepts a FHiCL parameter set
123 
124  If a config object is provided, configurations will be read from there.
125  Otherwise, they will be read from the registry.
126  If a registry is provided, the services will be registered in there.
127 
128  The service configuration is read from an item called as `interfaceClass`,
129  or `serviceClass` itself if `interfaceClass` is None, with "Service" appended.
130 
131  As a first attempt, the test helpers are attempted to load the service, and
132  the arguments are used to construct a `providers_type` object.
133  If there is no test helper for `serviceClass`, then direct construction is
134  attempted using all the specified arguments.
135  """
136 
137  serviceName = (interfaceClass if interfaceClass else serviceClass).__name__
138  configKey = serviceName + "Service"
139 
140  if not isinstance(config, ROOT.fhicl.ParameterSet):
141  config = config.service(configKey) if config else registry.config(configKey)
142  if config is None:
143  raise RuntimeError("Failed to retrieve the configuration for %s service" % serviceName)
144 
145  TestSetupClass = ROOT.testing.ProviderSetupClass(serviceClass)
146  if TestSetupClass:
147  serviceSetup = TestSetupClass.setup
148  try: providers = [ serviceClass.providers_type(*args), ]
149  except:
150  # we received arguments, called expected them to be used, we did not:
151  if args: raise # there must have been some problem
152  providers = []
153  service = serviceSetup(config, *providers)
154  else:
155  service = serviceClass(config, *args)
156 
157  if registry: registry.register(serviceName, service)
158  return service
159 # loadSimpleService()
160 
def LArSoftUtils.makeStringList (   l)

special known services

Definition at line 167 of file icarusalg/icarusalg/gallery/helpers/python/LArSoftUtils.py.

168 def makeStringList(l): return [ l, ] if isinstance(l, str) else l
169 

Variable Documentation

list LArSoftUtils.__all__
Initial value:
1 = [
2  'readHeader',
3  'SourceCode',
4  'make_getValidHandle',
5  'makeFileList',
6  'forEach',
7  'eventLoop',
8  'findFHiCL',
9  'loadConfiguration',
10  'ConfigurationClass',
11  'startMessageFacility',
12  'ServiceRegistryClass',
13  'ConfigurationHelper',
14  'loadGeometry',
15  'justLoadGeometry',
16  'loadSimpleService',
17  ]

Definition at line 11 of file icarusalg/icarusalg/gallery/helpers/python/LArSoftUtils.py.

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

Definition at line 5 of file icarusalg/icarusalg/gallery/helpers/python/LArSoftUtils.py.

LArSoftUtils.readHeader = galleryUtils.readHeader

Definition at line 44 of file icarusalg/icarusalg/gallery/helpers/python/LArSoftUtils.py.

LArSoftUtils.SourceCode = galleryUtils.SourceCode

Pass-through.

Definition at line 43 of file icarusalg/icarusalg/gallery/helpers/python/LArSoftUtils.py.