ATLAS Offline Software
OnlineISConfiguration.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2 
3 import ispy
4 
5 
7  from ispy import ISObject, IPCPartition
8  try:
9  r4p = ISObject(IPCPartition("ATLAS"), 'RunParams.Ready4Physics', 'RunParams')
10  r4p.checkout()
11  return r4p.ready4physics
12  except Exception:
13  print ("#### Failed to determine if we are ready for physics")
14  raise
15 
16 def GetRunType():
17  """Get the run type by reading the run-type setting in the partition from IS """
18 
19  #Get a logger so we can show formated messages
20  from AthenaCommon.Logging import logging
21  mlog = logging.getLogger('RecExOnline')
22 
23  #Try to get the partition name
24  try:
25  import os
26  partition = os.environ['TDAQ_PARTITION']
27  if partition == "EventDisplays":
28  partition = "ATLAS"
29  except KeyError:
30  partition = "ATLAS"
31  mlog.warning("TDAQ_PARTITION not defined in environment, using %s as default", partition)
32 
33  #now try and read the information from IS
34  try:
35  from ipc import IPCPartition
36  from ispy import ISObject
37  ipcPart = IPCPartition(partition)
38  if not ipcPart.isValid():
39  raise UserWarning("Partition %s invalid - cannot access run type settings" % partition)
40  runparams = ISObject(ipcPart, 'RunParams.RunParams', 'RunParams')
41  runparams.checkout()
42  beamEnergy = runparams.beam_energy
43  projectTag = runparams.T0_project_tag
44  except UserWarning as err:
45  mlog.error(err)
46  beamEnergy = None
47  projectTag = None
48 
49  mlog.info("Setting project tag to %s", projectTag)
50  return (None, beamEnergy, projectTag) # the BeamType in the IS RunParams is not useful for auto-configuration
51 
52 def GetBFields():
53  #Get a logger so we can show formated messages
54  from AthenaCommon.Logging import logging
55  mlog = logging.getLogger('RecExOnline')
56 
57  #BFields are read from initial partition
58  partition = 'initial'
59  mlog.debug("Trying to read magnetic field configuration from partition %s", partition)
60 
61  #now try and read the information from IS
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  #Get the current and valid status
68  # from ispy import ISObject
69  # torCurrent = ISObject(ipcPart, 'DCS_GENERAL.MagnetToroidsCurrent.value', 'DdcFloatInfo')
70  # solCurrent = ISObject(ipcPart, 'DCS_GENERAL.MagnetSolenoidCurrent.value', 'DdcFloatInfo')
71  # torInvalid = ISObject(ipcPart, 'DCS_GENERAL.MagnetToroidsCurrent.invalid', 'DdcIntInfo')
72  # solInvalid = ISObject(ipcPart, 'DCS_GENERAL.MagnetSolenoidCurrent.invalid', 'DdcIntInfo')
73  # torCurrent.checkout()
74  # solCurrent.checkout()
75  # torInvalid.checkout()
76  # solInvalid.checkout()
77 
78  # AL playing around: start
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  # AL playing around: end
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  #And calculate the flags
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  #Should always be able to access initial parititon
100  mlog.fatal("Failed to read magnetic field configuration from IS, aborting")
101  import sys
102  sys.exit(1)
103 
104  #print the result
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  #finally return our values
109  return (solCurrent, torCurrent)
110 
111 if __name__ == "__main__":
112  runType = GetRunType()
113  print ("(BeamType, BeamEnergy, ProjectTag): ", runType)
114  bFields = GetBFields()
115  print ("(SolCurrent, TorCurrent):", (bFields[0].value, bFields[1].value))
python.OnlineISConfiguration.GetRunType
def GetRunType()
Definition: OnlineISConfiguration.py:16
python.OnlineISConfiguration.GetAtlasReady
def GetAtlasReady()
Definition: OnlineISConfiguration.py:6
python.OnlineISConfiguration.GetBFields
def GetBFields()
Definition: OnlineISConfiguration.py:52