ATLAS Offline Software
Loading...
Searching...
No Matches
python.OnlineISConfig Namespace Reference

Functions

 GetAtlasReady ()
 GetRunType ()
 GetBFields ()

Variables

 log = logging.getLogger("OnlineISConfig")
 runType = GetRunType()
 bFields = GetBFields()

Detailed Description

Utilities to get the online configuration.

Code modernised and ported from
Reconstruction/RecExample/RecExOnline/python/OnlineISConfiguration.py

    Example usage from as CLI:
        python -m PyUtils.OnlineISConfig

    Example usage in python:
        from PyUtils.OnlineISConfig import GetRunType
        print(GetRunType()[1])

Function Documentation

◆ GetAtlasReady()

python.OnlineISConfig.GetAtlasReady ( )

Definition at line 26 of file OnlineISConfig.py.

26def GetAtlasReady():
27 try:
28 r4p = ISObject(IPCPartition("ATLAS"), "RunParams.Ready4Physics", "RunParams")
29 r4p.checkout()
30 return r4p.ready4physics
31 except Exception:
32 log.error("#### Failed to determine if we are ready for physics")
33 raise
34
35

◆ GetBFields()

python.OnlineISConfig.GetBFields ( )

Definition at line 72 of file OnlineISConfig.py.

72def GetBFields():
73 # BFields are read from initial partition
74 partition = "initial"
75 log.debug(f"Trying to read magnetic field configuration from {partition=}")
76
77 # now try and read the information from IS
78 try:
79 ipcPart = ipc.IPCPartition(partition)
80 if not ipcPart.isValid():
81 raise UserWarning(
82 f"{partition=} invalid - cannot access magnetic field setting "
83 )
84
85 torCurrent = ISInfoDynAny(ipcPart, "DdcFloatInfo")
86 solCurrent = ISInfoDynAny(ipcPart, "DdcFloatInfo")
87 torInvalid = ISInfoDynAny(ipcPart, "DdcIntInfo")
88 solInvalid = ISInfoDynAny(ipcPart, "DdcIntInfo")
89
90 torInvalid.value = 1
91 solInvalid.value = 1
92
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}")
97
98 # And calculate the flags
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:
102 log.error(err)
103 # Should always be able to access initial parititon
104 log.fatal("Failed to read magnetic field configuration from IS, aborting")
105
106 sys.exit(1)
107
108 # print the result
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')}")
111
112 # finally return our values
113 return (solCurrent, torCurrent)
114
115

◆ GetRunType()

python.OnlineISConfig.GetRunType ( )
Get the run type by reading the run-type setting in the partition from IS

Definition at line 36 of file OnlineISConfig.py.

36def GetRunType():
37 """Get the run type by reading the run-type setting in the partition from IS"""
38
39 # Try to get the partition name
40 try:
41 partition = os.environ["TDAQ_PARTITION"]
42 if partition == "EventDisplays":
43 partition = "ATLAS"
44 except KeyError:
45 partition = "ATLAS"
46 log.warning(
47 f"TDAQ_PARTITION not defined in environment, using {partition} as default"
48 )
49
50 # now try and read the information from IS
51 try:
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")
56 runparams.checkout()
57 beamEnergy = runparams.beam_energy
58 projectTag = runparams.T0_project_tag
59 except UserWarning as err:
60 log.error(err)
61 beamEnergy = None
62 projectTag = None
63
64 log.info(f"Setting {projectTag=}")
65 return (
66 None,
67 beamEnergy,
68 projectTag,
69 ) # the BeamType in the IS RunParams is not useful for auto-configuration
70
71

Variable Documentation

◆ bFields

python.OnlineISConfig.bFields = GetBFields()

Definition at line 119 of file OnlineISConfig.py.

◆ log

python.OnlineISConfig.log = logging.getLogger("OnlineISConfig")

Definition at line 23 of file OnlineISConfig.py.

◆ runType

python.OnlineISConfig.runType = GetRunType()

Definition at line 117 of file OnlineISConfig.py.