52def GetBFields():
53
54 from AthenaCommon.Logging import logging
55 mlog = logging.getLogger('RecExOnline')
56
57
58 partition = 'initial'
59 mlog.debug("Trying to read magnetic field configuration from partition %s", partition)
60
61
62 try:
63 from ipc import IPCPartition
64 ipcPart = IPCPartition(partition)
65 if not ipcPart.isValid():
66 raise UserWarning("Partition %s invalid - cannot access magnetic field setting" % partition)
67
68
69
70
71
72
73
74
75
76
77
78
79 torCurrent = ispy.ISInfoDynAny(ipcPart, 'DdcFloatInfo')
80 solCurrent = ispy.ISInfoDynAny(ipcPart, 'DdcFloatInfo')
81 torInvalid = ispy.ISInfoDynAny(ipcPart, 'DdcIntInfo')
82 solInvalid = ispy.ISInfoDynAny(ipcPart, 'DdcIntInfo')
83
84 torInvalid.value=1
85 solInvalid.value=1
86
87
88 mlog.info("toroidCurrent = %f", torCurrent.value)
89 mlog.info("toroidInvalid = %f", torInvalid.value)
90 mlog.info("solenoidCurrent = %f", solCurrent.value)
91 mlog.info("solenoidInvalid = %f", solInvalid.value)
92
93
94
95 solOn = ((solCurrent.value > 1000.) and (solInvalid.value == 0))
96 torOn = ((torCurrent.value > 1000.) and (torInvalid.value == 0))
97 except UserWarning as err:
98 mlog.error(err)
99
100 mlog.fatal("Failed to read magnetic field configuration from IS, aborting")
101 import sys
102 sys.exit(1)
103
104
105 mlog.info("Magnetic field in solenoid is %s", ((solOn and "ON") or "OFF"))
106 mlog.info("Magnetic field in toroid is %s", ((torOn and "ON") or "OFF"))
107
108
109 return (solCurrent, torCurrent)
110