def loadGeometry(config=None, registry=None, mapping=None): """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. """ assert(config or registry) serviceName = 'Geometry' # deal with messagefacility first if not (registry and registry.has("message")): messageConfig = config.service("message") if config else registry.config("message") startMessageFacility(messageConfig) # use default name if registry: registry.register("message", None) # there is no direct access, sorry # if need to load message facility geometryConfig = config.service(serviceName) if config else registry.config(serviceName) if geometryConfig is None: raise RuntimeError("Failed to retrieve the configuration for %s service" % serviceName) if not mapping: SourceCode.loadHeaderFromUPS('larcorealg/Geometry/ChannelMapStandardAlg.h') mapping = ROOT.geo.ChannelMapStandardAlg SourceCode.loadHeaderFromUPS("larcorealg/Geometry/StandaloneGeometrySetup.h") SourceCode.loadLibrary("larcorealg_Geometry") service = ROOT.lar.standalone.SetupGeometry(mapping)(geometryConfig) if registry: registry.register(serviceName, service) # make it easy to print points and vectors in python for varName in ( 'Point_t', 'Vector_t', ): try: klass = getattr(ROOT.geo, varName) except AttributeError: continue klass.__str__ = ROOTutils.TVector3ToString # ... and IDs... for varName in ( 'CryostatID', 'TPCID', 'PlaneID', 'WireID', ): try: klass = getattr(ROOT.geo, varName) except AttributeError: continue klass.__str__ = klass.toString # for ID for varName in ( 'CryostatID', 'TPCsetID', 'ROPID', ): try: klass = getattr(ROOT.readout, varName) except AttributeError: continue klass.__str__ = klass.toString # for ID # ... and geometry objects for varName in ( 'CryostatGeo', 'TPCGeo', 'PlaneGeo', 'WireGeo', 'OpDetGeo', 'AuxDetGeo', ): try: klass = getattr(ROOT.geo, varName) except AttributeError: continue klass.__str__ = getattr(klass, varName[:-3] + "Info") # for geo object return service
def __init__(self, config, loadingTable = {}, preload = []): # # prepare the service registry # self.registry_ = galleryUtils.ServiceRegistryClass(config) # # register the standard services # self.loadingTable = loadingTable.copy() # # message facility # galleryUtils.startMessageFacility(self.registry().config("message")) self.registry().register("message", None) # there is no direct access, sorry # # preload services # for serviceKey in preload: self.get(serviceKey)