ATLAS Offline Software
Loading...
Searching...
No Matches
magnets.py
Go to the documentation of this file.
1# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
2
3from DCSCalculator2.lib import DCSC_Subdetector, DCSC_Defect_Global_Variable
4from DCSCalculator2.variable import DefectIOV
5from DQUtils import process_iovs
6from DQUtils.sugar import IOVSet
7
8TOLERANCE_SOLENOID = 5 # Amperes
9TOLERANCE_TOROID = 10 # Amperes
10
11class Magnet_Currents(DCSC_Defect_Global_Variable):
12 """
13 Overloads calculate_good_iovs
14 """
15 def make_good_iovs(self, iovs):
16 atlsol_iovs = self.magnet_iov_generator(iovs, 'GLOBAL_SOLENOID', 1, 2,
17 TOLERANCE_SOLENOID)
18 atltor_iovs = self.magnet_iov_generator(iovs, 'GLOBAL_TOROID', 3, 4,
19 TOLERANCE_TOROID)
20 return IOVSet(list(atlsol_iovs) + list(atltor_iovs))
21
22 def magnet_iov_generator(self, iovs, system,
23 measured_channel, desired_channel, tolerance):
24
25 measured_iovs = iovs.select_channels(measured_channel)
26 desired_iovs = iovs.select_channels(desired_channel)
27
28 events = process_iovs(measured_iovs, desired_iovs)
29
30 for since, until, (measured, desired) in events:
31
32 # 28-05-2015: excluding empty 'desired' value, because how do we make
33 # a decision without an expectation? Should debug this some more, as
34 # the issue came up in 2015 run 253014.
35
36 # At least temporarily ignore desired value
37 # if measured is not None and desired is not None and not desired._is_empty:
38 if measured is not None:
39 # NOTE: if measured is 'empty', this is always true
40 if measured.value is None:
41 continue
42 elif measured.value <= tolerance:
43 # Magnet off
44 defect = system + '_OFF'
45
46 # this code is what we should use if desired values become valid again
47 # elif abs(measured.value - desired.value) <= tolerance:
48 # if ((system == 'GLOBAL_SOLENOID' and abs(desired.value - 7730.) > tolerance)
49 # or (system == 'GLOBAL_TOROID' and abs(desired.value - 20400.) > tolerance)):
50 # # Magnet has non-nominal current
51 # defect = system + '_NOTNOMINAL'
52 # else:
53 # defect = None
54 elif ((system == 'GLOBAL_SOLENOID' and abs(measured.value - 7730.) < tolerance)
55 or (system == 'GLOBAL_TOROID' and abs(measured.value - 20400.) < tolerance)):
56 # Magnet is nominal
57 defect = None
58 else:
59 # Magnet is ramping (possibly not true if we run at reduced field ...)
60 defect = system + '_RAMPING'
61
62 if defect is None:
63 continue
64
65 mcurrent = '%.1f' % measured.value if measured.value is not None else 'None'
66 scurrent = '%.1f' % desired.value if desired.value is not None else 'None'
67 yield DefectIOV(since, until, defect, True,
68 comment='Measured current: %s, Set current: %s' % (mcurrent, scurrent))
69
70
71class Magnets(DCSC_Subdetector):
72 #__DISABLED__ = True
73 folder_base = '/EXT/DCS/MAGNETS'
74
75 variables = [
76 Magnet_Currents('SENSORDATA', lambda x: True)
77 ]
78
79 def __init__(self, tolerance=2):
80 pass
81
82 def run(self, lbtime, run_iovs=None):
83 """
84 The magnets are very different to all other systems. There is no need
85 to run the usual processing, since the variables spit out iovs in one
86 step.
87 """
88 self.evaluate_inputs(lbtime)
89 return self.variables[0].iovs
magnet_iov_generator(self, iovs, system, measured_channel, desired_channel, tolerance)
Definition magnets.py:23
__init__(self, tolerance=2)
Definition magnets.py:79
Definition run.py:1