7 from __future__
import print_function
11 return '/GLOBAL/DETSTATUS/LBSUMM'
13 return '/GLOBAL/DETSTATUS/TISUMM'
28 "Translate traffic light string (numerical literal or letter) to number"
32 if uplight
in [
"R",
"RED"]:
34 elif uplight
in [
"Y",
"YELLOW"]:
36 elif uplight
in [
"G",
"GREEN"]:
38 elif uplight
in [
"U",
"UNKNOWN"]:
40 elif uplight
in [
"B",
"BLACK"]:
54 self.
namedict={
'PIXB':101,
'PIX0':102,
'PIXEA':104,
'PIXEC':105,
55 'SCTB':111,
'SCTEA':114,
'SCTEC':115,
56 'TRTB':121,
'TRTEA':124,
'TRTEC':125,
'TRTTR':126,
60 'IDPF':160,
'IDVX':161,
62 'EMBA':202,
'EMBC':203,
'EMECA':204,
'EMECC':205,
63 'HECA':214,
'HECC':215,
'FCALA':224,
'FCALC':225,
65 'TILBA':232,
'TILBC':233,
'TIEBA':234,
'TIEBC':235,
66 'MBTSA':244,
'MBTSC':245,
67 'CALBA':251,
'CALEA':254,
'CALEC':255,
68 'MDTBA':302,
'MDTBC':303,
'MDTEA':304,
'MDTEC':305,
69 'RPCBA':312,
'RPCBC':313,
70 'TGCEA':324,
'TGCEC':325,
71 'CSCEA':334,
'CSCEC':335,
72 'LCD':350,
'LCDA':353,
'LCDC':354,
74 'L1CAL':401,
'L1MUB':402,
'L1MUE':403,
'L1CTP':404,
77 'TRBJT':421,
'TRBPH':422,
'TRCOS':423,
'TRELE':424,
78 'TRGAM':425,
'TRJET':426,
'TRMET':427,
'TRMBI':428,
79 'TRMUO':429,
'TRTAU':430,
'TRIDT':431,
80 'LUMI':450,
'LUMIONL':451,
83 'ATLGL':480,
'ATLSOL':481,
'ATLTOR':482,
84 'EIDB':501,
'EIDCR':502,
'EIDE':503,
85 'PIDB':505,
'PIDCR':506,
'PIDE':507,
86 'EIDF':508,
'EIDSOFT':509,
87 'MSTACO':510,
'MMUIDCB':511,
'MMUIDVX':512,
88 'MMUGIRL':513,
'MMUBOY':514,
'MMUIDSA':515,
89 'MMUTAG':516,
'MMTIMO':517,
'MCMUTAG':518,
91 'JETB':521,
'JETEA':524,
'JETEC':525,
92 'JETFA':526,
'JETFC':527,
93 'MET':530,
'METCALO':531,
'METMUON':532,
94 'BTGLIFE':541,
'BTGSOFTE':544,
'BTGSOFTM':545,
95 'TAUB':551,
'TAUCR':552,
'TAUE':553}
106 "Return the numeric channel identifier which exactly matches name"
110 "Return a list of all numeric channel identifiers which match name"
113 if (name==iname[:len(name)]):
128 "Class to hold a list of detector status requirements"
131 "Initialise to empty set of requirements"
138 """Set requirements from a space-separated string with flag req pairs
139 e.g. 'SCTB 3 EMEC G' (numbers or letters for status)"""
141 namelist=self.
names.allNames()
144 while (ix+1<len(tokens)):
147 if (val
is not None):
150 for name
in namelist:
151 if (flagname==name[0:len(flagname)]):
155 print (
"Name %s does not match any status flag" % flagname)
157 print (
"Value %s does not define a status" % tokens[ix+1])
161 "Return the dictionary holding the requirements (channel/value pairs)"
165 "Print representation of status requirements"
168 result+=
"%s %i " % (self.
names.
name(key),val)
172 "Transient representation of one detector status"
173 def __init__(self,start,stop,code,deadfrac,thrust,nconfig=-1,nworking=-1,comment=''):
190 "Transient representation of detector status list (code,deadfrac,thrust)"
192 "Initialise to empty sequence"
196 def merge(self,mobj,override=False):
197 "Merge the given StatusObj into the list, ANDing (default) or override"
198 if (mobj.start>=mobj.stop):
203 while (ix<len(self.
_seq)):
206 if (mobj.start<self.
_seq[ix].start
and mobj.stop>oldstop):
208 nstart=
max(oldstop,mobj.start)
209 nstop=
min(self.
_seq[ix].start,mobj.stop)
213 self.
_seq.insert(ix,
StatusObj(nstart,nstop,mobj.code,mobj.deadfrac,mobj.thrust,mobj.nconfig,mobj.nworking,mobj.comment))
216 if (mobj.start<self.
_seq[ix].stop
and mobj.stop>self.
_seq[ix].start):
221 (mobj.code<=self.
_seq[ix].code
and mobj.code!=0)
or
222 (self.
_seq[ix].code==0)):
224 ecode=self.
_seq[ix].code
225 edeadfrac=self.
_seq[ix].deadfrac
226 ethrust=self.
_seq[ix].thrust
227 enconfig=self.
_seq[ix].nconfig
228 enworking=self.
_seq[ix].nworking
229 ecomment=self.
_seq[ix].comment
230 estart=self.
_seq[ix].start
231 estop=self.
_seq[ix].stop
234 if (mobj.start>estart):
236 self.
_seq.insert(ix,
StatusObj(estart,mobj.start,ecode,edeadfrac,ethrust,enconfig,enworking,ecomment))
239 if (mobj.stop<estop):
241 self.
_seq.insert(ix+1,
StatusObj(mobj.stop,estop,ecode,edeadfrac,ethrust,enconfig,enworking,ecomment))
244 self.
_seq[iy]=
StatusObj(
max(mobj.start,estart),
min(mobj.stop,estop),mobj.code,mobj.deadfrac,mobj.thrust,mobj.nconfig,mobj.nworking,mobj.comment)
246 oldstop=self.
_seq[ix].stop
250 if (len(self.
_seq)>0):
251 oldstop=self.
_seq[-1].stop
252 if (mobj.stop>oldstop):
253 nstart=
max(oldstop,mobj.start)
254 self.
_seq+=[
StatusObj(nstart,mobj.stop,mobj.code,mobj.deadfrac,mobj.thrust,mobj.nconfig,mobj.nworking,mobj.comment)]
257 "Compress StatusList removing redundant entries with IoVs which can be combined"
259 while (ix<len(self.
_seq)):
262 if (self.
_seq[ix].start==self.
_seq[ix-1].stop
and
263 self.
_seq[ix].code==self.
_seq[ix-1].code
and
264 self.
_seq[ix].deadfrac==self.
_seq[ix-1].deadfrac
and
265 self.
_seq[ix].thrust==self.
_seq[ix-1].thrust
and
266 self.
_seq[ix].nconfig==self.
_seq[ix-1].nconfig
and
267 self.
_seq[ix].nworking==self.
_seq[ix-1].nworking
and
268 self.
_seq[ix].comment==self.
_seq[ix-1].comment):
269 self.
_seq[ix].updateStart(self.
_seq[ix-1].start)
273 return len(self.
_seq)
276 "Return size of list"
277 return len(self.
_seq)
280 "Return the list itself"
284 "Print representation of StatusList"
287 rep+=
'[%i %i] : %i %6.3f %6.3f %s\n' % (i.start,i.stop,i.code,i.deadfrac,i.thrust,i.comment)