49 "Get the magnetic field currents (MagFieldDCSInfo) for a given run"
53 runiov=(run << 32)+(lumiblock
or 0)
54 if runiov
in _fieldForLB:
55 return _fieldForLB[runiov]
59 print (
"Reading magnetic field for run %i, CONDBR2 %s" % (run,newdb))
63 sorfolder=
'/TDAQ/RunCtrl/SOR'
64 fntname=
'T0ProjectTag'
67 sorfolder=
'/TDAQ/RunCtrl/SOR_Params'
72 print (
"MagFieldUtils.getFieldForRun ERROR: Cannot connect to COOLONL_TDAQ/%s" % dbname)
76 tdaqfolder=tdaqDB.getFolder(sorfolder)
78 obj=tdaqfolder.findObject(runiov,0)
80 sortime=payload[
'SORTime']
82 except Exception
as e:
83 print (
"MagFieldUtils.getFieldForRun ERROR accessing folder %s" % sorfolder)
85 tdaqDB.closeDatabase()
88 if lumiblock
is not None:
90 print (
"Reading specific timestamp for lumiblock %i" % lumiblock)
93 if (lbtime==0
and lumiblock>1):
95 print (
"MagFieldUtils.getFieldForRun WARNING: Cannot find LB %i, trying %i" % (lumiblock,lumiblock-1))
98 print (
"MagFieldUtils.getFieldForRun WARNING: Cannot find LB %i, fall back on SOR time" % lumiblock)
102 print (
"Lumiblock starts %i seconds from start of run" %
int((lbtime-sortime)/1.E9))
105 print (
"MagFieldUtils.getFieldForRun ERROR accessing /TRIGGER/LUMI/LBLB")
106 print (
"Fall back on SOR time from %s" % sorfolder)
110 if (sortime==0):
return None
115 print (
"MagFieldUtils.getFieldForRun ERROR: Cannot connect to COOLOFL_DCS/%s" % dbname)
122 currentmap={
'CentralSol_Current':0,
'CentralSol_SCurrent':1,
123 'Toroids_Current':2,
'Toroids_SCurrent':3}
124 dcsfolder=dcsDB.getFolder(
'/EXT/DCS/MAGNETS/SENSORDATA')
125 objs=dcsfolder.findObjects(sortime,cool.ChannelSelection.all())
126 data=[-1.,-1.,-1.,-1.]
129 channame=dcsfolder.channelName(chan)
130 if channame
in currentmap.keys():
131 data[currentmap[channame]]=obj.payload()[
'value']
132 except Exception
as e:
133 print (
"MagFieldUtils.getFieldForRun ERROR accessing /EXT/DCS/MAGNETS/SENSORDATA")
135 dcsDB.closeDatabase()
140 retval=MagFieldDCSInfo(data[0],data[1],data[2],data[3],fnt)
141 _fieldForLB[runiov]=retval