ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tools
PyUtils
python
OnlineISConfig.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2
"""
3
Utilities to get the online configuration.
4
5
Code modernised and ported from
6
Reconstruction/RecExample/RecExOnline/python/OnlineISConfiguration.py
7
8
Example usage from as CLI:
9
python -m PyUtils.OnlineISConfig
10
11
Example usage in python:
12
from PyUtils.OnlineISConfig import GetRunType
13
print(GetRunType()[1])
14
15
"""
16
import
os
17
import
sys
18
19
import
ipc
20
from
AthenaCommon.Logging
import
logging
21
from
ispy
import
IPCPartition, ISInfoDynAny, ISObject
22
23
log = logging.getLogger(
"OnlineISConfig"
)
24
25
26
def
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
36
def
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
72
def
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
116
if
__name__ ==
"__main__"
:
117
runType =
GetRunType
()
118
print
(f
"(BeamType, BeamEnergy, ProjectTag): {runType}"
)
119
bFields =
GetBFields
()
120
print
(f
"(SolCurrent, TorCurrent): ({bFields[0].value, bFields[1].value})"
)
print
void print(char *figname, TCanvas *c1)
Definition
TRTCalib_StrawStatusPlots.cxx:26
python.OnlineISConfig.GetAtlasReady
GetAtlasReady()
Definition
OnlineISConfig.py:26
python.OnlineISConfig.GetBFields
GetBFields()
Definition
OnlineISConfig.py:72
python.OnlineISConfig.GetRunType
GetRunType()
Definition
OnlineISConfig.py:36
Generated on
for ATLAS Offline Software by
1.17.0