3 Utilities to get the online configuration.
5 Code modernised and ported from
6 Reconstruction/RecExample/RecExOnline/python/OnlineISConfiguration.py
8 Example usage from as CLI:
9 python -m PyUtils.OnlineISConfig
11 Example usage in python:
12 from PyUtils.OnlineISConfig import GetRunType
13 print(GetRunType()[1])
20 from AthenaCommon.Logging
import logging
21 from ispy
import IPCPartition, ISInfoDynAny, ISObject
23 log = logging.getLogger(
"OnlineISConfig")
28 r4p = ISObject(IPCPartition(
"ATLAS"),
"RunParams.Ready4Physics",
"RunParams")
30 return r4p.ready4physics
32 log.error(
"#### Failed to determine if we are ready for physics")
37 """Get the run type by reading the run-type setting in the partition from IS"""
41 partition = os.environ[
"TDAQ_PARTITION"]
42 if partition ==
"EventDisplays":
47 f
"TDAQ_PARTITION not defined in environment, using {partition} as default"
52 ipcPart = ipc.IPCPartition(partition)
53 if not ipcPart.isValid():
54 raise UserWarning(f
"{partition=} invalid - cannot access run type settings")
55 runparams = ISObject(ipcPart,
"RunParams.RunParams",
"RunParams")
57 beamEnergy = runparams.beam_energy
58 projectTag = runparams.T0_project_tag
59 except UserWarning
as err:
64 log.info(f
"Setting {projectTag=}")
75 log.debug(f
"Trying to read magnetic field configuration from {partition=}")
79 ipcPart = ipc.IPCPartition(partition)
80 if not ipcPart.isValid():
82 f
"{partition=} invalid - cannot access magnetic field setting "
85 torCurrent = ISInfoDynAny(ipcPart,
"DdcFloatInfo")
86 solCurrent = ISInfoDynAny(ipcPart,
"DdcFloatInfo")
87 torInvalid = ISInfoDynAny(ipcPart,
"DdcIntInfo")
88 solInvalid = ISInfoDynAny(ipcPart,
"DdcIntInfo")
93 log.info(f
"toroidCurrent = {torCurrent.value}")
94 log.info(f
"toroidInvalid = {torInvalid.value}")
95 log.info(f
"solenoidCurrent = {solCurrent.value}")
96 log.info(f
"solenoidInvalid = {solInvalid.value}")
99 solOn = (solCurrent.value > 1000.0)
and (solInvalid.value == 0)
100 torOn = (torCurrent.value > 1000.0)
and (torInvalid.value == 0)
101 except UserWarning
as err:
104 log.fatal(
"Failed to read magnetic field configuration from IS, aborting")
109 log.info(f
"Magnetic field in solenoid is {((solOn and 'ON') or 'OFF')}")
110 log.info(f
"Magnetic field in toroid is {((torOn and 'ON') or 'OFF')}")
113 return (solCurrent, torCurrent)
116 if __name__ ==
"__main__":
118 print(f
"(BeamType, BeamEnergy, ProjectTag): {runType}")
120 print(f
"(SolCurrent, TorCurrent): ({bFields[0].value, bFields[1].value})")