964 import CoolRunQuery.html.AtlRunQueryHtmlUtils
as HU
966 with timer(
"print runnur, runtime, etc"):
967 s =
"<!-- Run %s -->\n" % run.runNrS
970 if Run.bgcolor ==
"1":
977 if run.showDataIncomplete:
978 runrowclass=
"showmiss"
979 if run.selDataIncomplete:
980 runrowclass=
"selmiss"
983 s +=
'<tr class="out%s">\n' % (color)
987 if run.runNr == Run.runnropen:
988 s +=
' <td style="text-align:center" class="%s"><font color="#BB0000">%s<br><font size="-2">(ongoing)</font></font>' % (runrowclass, run.runNrS)
990 s +=
'<td style="text-align:center" class="%s">%s' % (runrowclass, run.runNrS)
991 p = Run.runPeriods.findPeriod( run.runNr )
995 for i
in range(p.count(
',')//2+1):
996 idx = p.find(
',',idx+1)
997 s +=
'<br><font color="#488AC7"><font size=-2><nobr>Period: %s<br>%s</nobr></font></font>' % (p[:idx],p[idx+1:])
1000 if run.runNr
in Run.PromptCalibRuns:
1001 s +=
'<br><font color="#008800"><font size="-2">(in calib loop)</font></font>'
1005 s +=
'\n <td>\n%s</td>' % run.runlinks()
1008 lbcontent =
'%s' % run.NrLBs
1010 vf =
float(run.NrLBs)
1012 lbcontent =
'%s<br><font size="-2">(%i s)</font>' % (run.NrLBs, (run.eor-run.sor)/(1.0E9*vf) )
1016 window = HU.OpenWindow( HU.CreateLBTable(run), extracss=[
'html/atlas-runquery-lb.css'] )
1019 tip =
'showTip LBStart_%i' % run.runNr
1020 s +=
'\n <!-- LB Content -->\n'
1021 s +=
' <td style="text-align: right"><div class="%s tooltip" style="display:inline;cursor:pointer">%s%s</a></div></td>\n' % (tip, window, lbcontent)
1025 s +=
' <td>%s</td>' % run.timestr(
'html',run.runNr != Run.runnropen)
1028 if Run.showduration:
1029 if run.runNr == Run.runnropen:
1030 s +=
' <td><font color="#BB0000">%s<br><font size="-2">(ongoing)</font></font></td>' % run.durationstr()
1032 s +=
" <td>%s</td>" % run.durationstr()
1036 for k
in Run.SortedShowOrder():
1037 if k.Type == DataKey.STREAM
and k.ResultKey
in run.stats
and 'calibration' not in k.ResultKey:
1038 sumstrnev += run.result[k.ResultKey][0]
1047 with timer(
"print keys"):
1048 for data_key
in Run.SortedShowOrder():
1049 k = data_key.ResultKey
1052 with timer(
"keybuild %s" % k, disabled=
True):
1053 if any([
'olc:beam2intensity' in k,
1054 'olc:beam1intensity' in k,
1055 'lhc:beamenergy' in k,
1056 'beam1bunches' in k,
1057 'beam2bunches' in k,
1069 durInSec = (run.eor-run.sor)/1.0E9
1073 rate =
'%.1f Hz' % (
float(v)/durInSec)
1076 s +=
' <td style="text-align: right">%s<BR><font size="-2">(%s)</font></td>' % (
addKommaToNumber(v),rate)
1081 if k ==
"#L1A" or k ==
'#L2A' or k ==
'#EFA' or k ==
'#Events (streamed)' or k ==
'#Events (incl. calib.)':
1088 intolerable = Run.Fieldinfo[
'DQ'][
'IntolerableDefects']
1090 for channelname
in Run.Fieldinfo[
'DQ'][
'DefChannels']:
1091 if channelname ==
'':
1092 matching_dqentries = run.stats[k][
"defects"]
1093 elif channelname ==
'DET':
1094 matching_dqentries = [dqentry
for dqentry
in run.stats[k][
"defects"]
if '_' not in dqentry[0]]
1096 from re
import compile
1097 pattern = compile(channelname)
1098 matching_dqentries = [dqentry
for dqentry
in run.stats[k][
"defects"]
if pattern.match(dqentry[0])]
1102 matching_dqentries_ready = []
1103 for (defect, listLBranges)
in matching_dqentries:
1104 readyLBRanges = [lbrange
for lbrange
in listLBranges
if run.data.isReady(lbrange)]
1105 if len(readyLBRanges)>0:
1106 matching_dqentries_ready += [ (defect, readyLBRanges) ]
1109 if len(matching_dqentries_ready)==0:
1110 dq_info =
"<table class='dqdefects' style='border-color: limegreen; height=100%'><tr><td> </td></tr></table>\n"
1112 dq_info =
"<table class='dqdefects'>\n"
1113 for defect,listLBranges
in matching_dqentries_ready:
1114 tip =
'showTip dqdefect_%i_%s tooltip' % (run.runNr, defect)
1115 if defect
in intolerable:
1116 dq_info +=
"<tr class='%s'><td class='intolerable'>%s</td><td class='lb'>" % (tip, defect)
1118 dq_info +=
"<tr class='%s tolerable' style='visibility:collapse;'><td>%s</td><td class='lb'>" % (tip, defect)
1119 dq_info +=
", ".
join([(
"%g−%g" % (x[0],x[1]-1)
if x[1]-x[0]!=1
else "%g" % x[0])
for x
in listLBranges])
1120 dq_info +=
"</td></tr>\n"
1121 dq_info +=
'<tr height="100%%"><td height="100%%"></td></tr>\n'
1122 dq_info +=
"</table>\n"
1123 s +=
'<td class="def">%s</td>' % dq_info
1132 dqmax = run.stats[k][
"max"]
1133 n = run.stats[k][
"counts"]
1135 foundComment =
False
1136 for (dq,comment), start, end
in run.stats[k][
"blocks"]:
1143 if n[dq]>0
and dq != dqmax:
1145 extraDQInfo +=
'<tr><td class="td%s" style="min-width: 45px; text-align: left; border-width: 0px; padding:1px;"> LB %g:</td><td class="td%s" style="text-align: left; border-width: 0px; padding: 1px; ">%s </td></tr>' % (dqcss,start,dqcss,dq)
1147 extraDQInfo +=
'<tr><td class="td%s" style="min-width: 45px; text-align: left; border-width: 0px; padding:1px;"> LB %g−%g:</td><td class="td%s" style="text-align: left; border-width: 0px; padding: 1px; ">%s </td></tr>' % (dqcss,start,end-1,dqcss,dq)
1150 tip =
'showTip dqcomm_%s_%i' % (k, run.runNr)
1152 extraDQInfo =
'<br><img vspace=2 height="1" width="1" src="wdot.jpg"><br><table style="width: 100%; border: 1px solid; border-width: 1px; border-spacing: 0px; border-color: #eeeeee; border-collapse: separate; padding: 0px; font-size: 65%"><tr>' + extraDQInfo +
'</table>'
1155 s +=
'<td class="%s td tooltip td%s">%s%s</td>' % (tip,dqmax,dqmax,extraDQInfo)
1157 s +=
'<td class="td td%s">%s%s</td>' % (dqmax,dqmax,extraDQInfo)
1163 if "detector systems" in k.lower():
1165 mask =
'0x'+v
if Selector.condDB()==
'CONDBR2' else v
1167 s +=
' <td style="min-width:%ipx"><font size="-2">%s<hr color="#aaaaaa" size=1>[<a href="http://sroe.home.cern.ch/sroe/cgi-bin/avgmodule.py?run=%i" target=_blank>SCT HV setting</a>]</font></td>' % (1.1*len(v),v,run.runNr)
1175 hasStableBeamsInfo, xvecStb = run.getStableBeamsVector()
1178 printMu =
'olc:bcidmask' in Run.SortedShowOrder()
and run.runNr>=151260
and run.givepeakmuinfo
1184 for entry
in run.data[k]:
1185 assert entry.startlb != 0,
'entry should not start at LB=0'
1186 val = entry.value
if (entry.value!=
'n.a.' and entry.value>0)
else 0
1187 lastlb =
min(entry.lastlb,run.nr_lb)
1188 xvec +=
range(entry.startlb,lastlb+1)
1189 nlb = lastlb - entry.startlb + 1
1191 yvecInt += nlb*[val]
1194 intlumi, intlumiStb = (0, 0)
1204 if len(xvecStb) > 15:
1209 for idx,(lbtime,lbendtime)
in enumerate(run.lbtimes):
1212 yvecInt[idx] *= dt/1000.0*run.lumiunit
1213 yvec[idx] *= 1.0*run.lumiunit
1214 intlumi += yvecInt[idx]
1216 if yvec[idx] > peaklumi:
1217 peaklumi = yvec[idx]
1219 intlumiStb += yvecInt[idx]
1227 if y1 > 0
and y2 > 0:
1228 lifetime = (t2 - t1)/(3600*math.log(y1/y2))
1231 if hasStableBeamsInfo:
1232 fullprint_ =
'All LBs: %0.4g<br>Stable B: %0.4g' % (intlumi,intlumiStb)
1233 histoText =
'Integrated luminosity: %.4g %s-1 (all LBs) and %.4g %s-1 (stable beams)' % (intlumi,run.lumiunittxt,intlumiStb,run.lumiunittxt)
1235 fullprint_ =
'All LBs: %0.4g' % (intlumi)
1236 histoText =
'Integrated luminosity: %.4g %s-1 (all LBs)' % (intlumi,run.lumiunittxt)
1239 tp1, tp2, chan = k.split(
':')
1242 if chan
in OLCAlgorithms:
1243 chanstr = OLCAlgorithms[chan]
1249 path =
makeLBPlot( xvec, xvecStb, yvec,
'Luminosity block number',
'Online luminosity (10^{%s}cm^{-2}s^{-1})' % run.instlumiunittxt,
'',
1250 'olclumi_vs_lb_run_%i' % (run.runNr),
1251 'Online lumi [%s] per LB for run %i' % (chanstr, run.runNr),
1252 QC.datapath, histoText )
1255 wincontent =
'<table class="outer" style="padding: 5px"><tr><td>'
1256 wincontent +=
'<strong><b>Online luminosity [algorithm: %s] per LB for run %i:</b></strong><br><font size="-1" color="#888888">(Begin/end of run: %s)</font>' % (chanstr, run.runNr, run.timestr(
'html', run.runNr != Run.runnropen))
1257 wincontent +=
'<hr color="black" size=1>'
1258 wincontent +=
'<table style="padding: 0px"><tr><td>'
1259 wincontent +=
'<img src="%s" align="left">' % path
1260 wincontent +=
'</td></tr></table>'
1261 wincontent +=
'<hr color="black" size=1>'
1262 wincontent +=
'<table class="LB">'
1263 wincontent +=
'<tr><th>LB</th><th>Start time<br> (%s)</th><th>Duration<br>(sec)</th><th>Inst. luminosity<br>(1e%s cm<sup>−2</sup>s<sup>−1</sup>)</th>' % (QC.tzdesc(), run.instlumiunittxt)
1264 wincontent +=
'<th>Int. luminosity<br>(%s<sup>−1</sup>)</th><th>Cumul. luminosity<br>(%s<sup>−1</sup>)</th>' % (run.lumiunittxt, run.lumiunittxt)
1266 wincontent +=
'<th> <μ> </th>'
1267 if hasStableBeamsInfo:
1268 wincontent +=
'<th>Stable beams</th>'
1269 wincontent +=
'</tr><tr style="background:%s">' %
'#eeeeee'
1272 minBiasXsec = 80.0
if Selector.isRun2()
else 71.5
1274 is5TeVRun = (run.sor/1.E9) > time.mktime((2017,11,11,0,0,0,0,0,0))
and (run.sor/1.E9) < time.mktime((2017,11,21,8,0,0,0,0,0))
1278 is5TeVHIRun = (run.sor/1.E9) > time.mktime((2018,11,7,0,0,0,0,0,0))
and (run.sor/1.E9) < time.mktime((2018,12,31,0,0,0,0,0,0))
1282 for idx,(lbtime,lbendtime)
in enumerate(run.lbtimes):
1284 isStableBeams = (lb
in xvecStb)
1285 intlumi += yvecInt[idx]
1286 stbBeams =
'T' if isStableBeams
else '−'
1287 timetuple = time.localtime(lbtime/1.E9)
if QC.localtime
else time.gmtime(lbtime/1.E9)
1288 wincontent +=
'<td>%s</td><td>%s</td><td>%.2f</td><td>%.4g</td><td>%.4g</td><td>%.4g</td>' % (lb, time.strftime(
"%X",timetuple), (
float(lbendtime)-
float(lbtime))/1.E9, yvec[idx], yvecInt[idx], intlumi)
1292 for n,v,lbstart,lbend
in run.stats[
'olc:bcidmask'][
'blocks']:
1293 if lb >= lbstart
and lb <= lbend:
1298 lumi_mb = yvec[idx]*1000.0
1301 mu = lumi_mb * minBiasXsec / 11245.511 / nb
1302 wincontent +=
'<td>%.3g</td>' % mu
1303 if isStableBeams
and mu > mumax:
1305 if hasStableBeamsInfo:
1306 wincontent +=
'<td>%s</td>' % stbBeams
1311 wincontent +=
'</tr><tr style="background:%s">' % col
1313 printMuInfoToFile =
True
1314 if printMuInfoToFile:
1315 mutextfilename = QC.datapath +
'/mu_vs_run_output.txt'
1316 muout =
open( mutextfilename,
'a' )
1317 muout.write(
'%10i %f\n' % (run.runNr, mumax) )
1323 s_mumax =
"%0.3e" % mumax
1325 s_mumax =
"%0.3f" % mumax
1327 if run.runNr == Run.runnropen:
1328 wincontent +=
'<tr><td style="text-align:left"colspan="3"><i> Run still ongoing ...</i></td></tr>'
1329 wincontent +=
'</tr></table>'
1331 wincontent +=
"""<hr color="red" size=1><font color="#777777"><font size="-1"><i><font size="-2">Created by AtlRunQuery on: %s</font></i></font></td></tr></table><script type="text/javascript"></script></body></html>""" %
str(datetime.datetime.now())
1332 wincontent +=
'</td></tr></table>'
1334 openwincmd =
'<a href="javascript:openLargeWindow('
1335 openwincmd +=
"'Print','<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html xmlns:"my"><head><title>Run query result for online luminosity</title><LINK href="html/atlas-runquery-lb.css" rel="stylesheet" type="text/css"></head><body><table style="font-family: sans-serif; font-size: 85%%">"
1336 openwincmd += wincontent
1337 openwincmd +=
"')\">"
1340 fullprint =
'<table class="bcidtable">'
1341 fullprint +=
'<tr><td colspan="2"><img src="%s" align="left" width="90px"></td></tr>' % path
1342 if hasStableBeamsInfo:
1343 fullprint +=
'<tr><td style="text-align:left">Entire run:</td><td style="text-align:left"> %0.4g %s<sup>−1</sup></td></tr><tr><td style="text-align:left">Stable beams:</td><td style="text-align:left"> %0.4g %s<sup>−1</sup></td></tr><tr><td style="text-align:left">Peak lumi:</td><td style="text-align:left"> %.2g e%s cm<sup>−2</sup>s<sup>−1</sup></td></tr><tr><td style="text-align:left">Peak <μ>:</td><td style="text-align:left"> %s</td></tr>' % (intlumi, run.lumiunittxt, intlumiStb, run.lumiunittxt, peaklumi, run.instlumiunittxt, s_mumax)
1345 fullprint +=
'<tr><td style="text-align:left">Approx. lifetime:</td><td style="text-align:left"> %0.2g h</td></tr>' % (lifetime)
1347 fullprint +=
'<td style="text-align:left">All LBs:</td><td style="text-align:left"> %0.4g</td></tr>' % (intlumi)
1348 fullprint +=
'</table>'
1351 s +=
'<td class="showTip OLCLumi stream" style="text-decoration:none; text-align: right">%s%s</a></td>' % (openwincmd, fullprint)
1357 if 'olc:bcidmask' in k:
1359 firstGoodRun = 151260
1360 if run.runNr < firstGoodRun:
1361 s +=
'<td style="text-align:center;color:#AA0000;font-size:60%%;">BCID information only available for run numbers larger than %i</font></td>' % firstGoodRun
1365 fullprint =
'<font size=-2><i>Run without stable beams (or, in few cases, missing bunch information in COOL). Click here to obtain bunch crossing information</i>.</font>'
1367 wincontent =
'<table class="outer" style="padding: 5px"><tr><td>'
1368 wincontent +=
'<strong><b>Identifiers (BCID) for paired and unpaired bunches for run %i:</b></strong><br><font size="-1" color="#888888">(Begin/end of run: %s)</font>' % (run.runNr, run.timestr(
'html', run.runNr != Run.runnropen))
1369 wincontent +=
'<hr color="black" size=1>'
1370 wincontent +=
'<table class="bcidtable" align="center"><tr class="tr0"><td style="text-align:left;font-weight:bold" colspan="3">LB range</td><td style="text-align:right;font-weight:bold"> Stable<br>beams</td><td style="text-align:right;font-weight:bold">%s</td><td style="text-align:right;font-weight:bold">%s</td><td style="text-align:right;font-weight:bold">%s</td></tr>' % (
' Crossing (Paired)',
'<nobr> Unpaired Beam-1 </nobr>',
'<nobr> Unpaired Beam-2</nobr>')
1374 hasStableBeamsInfo, xvecStb = run.getStableBeamsVector()
1377 for n,v,lbstart,lbend
in run.stats[k][
'blocks']:
1379 cls =
'tr1' if (ic%2==1)
else 'tr2'
1382 isInStableBeamPeriod =
False
1383 stableBeamWord =
'−'
1384 if hasStableBeamsInfo:
1385 if lbstart <= xvecStb[-1]
and lbend >= xvecStb[0]:
1386 isInStableBeamPeriod =
True
1387 stableBeamWord =
'<b>T</b>'
1389 wincontent +=
'<tr class="%s"><td class="td1" style="text-align:right"><b>%s</b></td><td style="text-align:right"><b>−</b></td><td style="text-align:right"><b>%s:</b> </td><td>%s </td>' % (cls,
str(lbstart),
str(lbend-1),stableBeamWord)
1391 beam1, beam2, beam12 = v
1392 unpaired1 = [b
for b
in beam1
if b
not in beam12]
1393 unpaired2 = [b
for b
in beam2
if b
not in beam12]
1395 noBunches =
not unpaired1
and not unpaired2
and not beam12
1397 unpaired1 = [
'−']
1399 unpaired2 = [
'−']
1401 beam12 = [
'−']
1404 if isInStableBeamPeriod
and first
and not noBunches:
1407 maxBunchDistanceInTrain = 6
1408 if int(run.runNr) > 168665:
1409 maxBunchDistanceInTrain = 25
1413 if bp > 0
and b - bp <= maxBunchDistanceInTrain:
1414 if trains[-1][-1] != bp:
1417 elif len(beam12) > 1
and bp <= 0
and beam12[0] - b <= maxBunchDistanceInTrain:
1421 fullprint =
'<table class = "triggerlinktable">'
1422 fullprint +=
'<tr><td style="text-align:left"><nobr>No. of coll. bunches: </nobr></td><td> <b>%i</b></td></tr>' % len(beam12)
1423 fullprint +=
'<tr><td style="text-align:left"><nobr>No. of bunch trains:</nobr></td><td><b> %i</b></td></tr>' % len(trains)
1425 Run.TmpBoxContent =
'<strong><b><nobr>Bunch train configuration for run <font color="#AA0000">%i</font></nobr></b></strong>' % run.runNr
1426 Run.TmpBoxContent +=
'<hr size=1>'
1433 if len(trains[icoor]) > 1:
1434 bunchDist = trains[icoor][1] - trains[icoor][0]
1435 fullprint +=
'<tr><td style="text-align:left"><nobr>Bunch dist. in trains:</nobr></td><td><nobr><b> %i</b> (%i ns)</nobr></td></tr>' % (bunchDist, bunchDist*25)
1438 if len(trains[0]) == 1:
1439 fullprint +=
'<tr><td style="text-align:left;color:#4477EE" colspan=2><i>The first "bunch train" is trivial and consists of only the colliding pilot bunch</td></tr>'
1440 fullprint +=
'</table><hr size=1>'
1441 Run.TmpBoxContent +=
'<table><tr><td>Train</td><td><nobr>No. of bunches</nobr></td><td style="text-align:right"> BCID range</td></tr>'
1442 for it, train
in enumerate(trains):
1443 Run.TmpBoxContent +=
'<tr><td> %i: </td><td> %i</td><td style="text-align:right"><nobr> %i − %i</nobr></td></tr>' % (it+1, len(train), train[0], train[-1])
1444 Run.TmpBoxContent +=
'</table><hr size=1>'
1446 Run.TmpBoxContent =
'<nobr>No bunch trains in this run</nobr> <hr size=1>'
1447 fullprint +=
'</table><hr size=1>'
1448 Run.TmpBoxContent +=
'<p><font color="#AA0000"><b><nobr>Click to obtain full list of BCIDs</nobr></b></font>'
1449 fullprint +=
'<span style="font-size: xx-small; color: #555555">[ <i>Mouse over for train configuration. Click for full list of BCIDs</i> ]</span>'
1451 wincontent +=
'<td class="td1" style="text-align:right">%s</td><td style="text-align:right; border-left:1px #C0C0D0 solid;border-right:1px #C0C0D0 solid">%s</td><td style="text-align:right">%s</td>' % (
', '.
join(map(str,beam12)),
', '.
join(map(str,unpaired1)),
', '.
join(map(str,unpaired2)) )
1453 wincontent +=
'<td class="td1" style="text-align:right">%s</td><td style="text-align:right">%s</td><td style="text-align:right">%s</td>' % (
'−',
'−',
'−')
1455 wincontent +=
'</tr>'
1458 wincontent +=
'</table></td>'
1459 wincontent +=
'</td></tr></table>'
1462 openwincmd = HU.OpenWindow(wincontent, title=
"Run query result for online luminosity", extracss=
None, size=
"large")
1468 s +=
'<td class="showTip OLCBCID_%i stream" style="text-decoration:none; text-align: left">%s%s</a></td>' % (run.runNr, openwincmd, fullprint)
1474 if k.startswith(
'bs:Pos')
or k.startswith(
'bs:Sig')
or k.startswith(
'bs:Tilt'):
1478 statkey =
'bs:Status'
1480 onloffltype =
'Online' if (run.stats[
'Beamspot']==
'online')
else 'Offline'
1493 for entry
in run.data[k]:
1494 if entry.startlb==0
and entry.lastlb==0:
1497 val,valerr = entry.value
1498 ref = run.data[refkey].atLB(entry.startlb)[0].value[0]
1499 stat = run.data[statkey].atLB(entry.startlb)[0].value
1501 lastlb =
min(entry.lastlb,run.lastlb)
1502 lbs =
range(entry.startlb,lastlb+1)
1506 yvec += [(val,valerr)]
1508 bsidx += [idx] * nlb
1514 eave += nlb * val**2
1519 s +=
'<td>n.a.</td>'
1524 rad = eave/iave - vave*vave
1526 eave = math.sqrt(rad)
1532 ymin = vave - 3*eave
1533 ymax = vave + 3*eave
1543 delta = 0.1*abs(ymax)
1545 delta = 0.1*(ymax-ymin)
1555 bstype += k[k.find(
'-'):]
1557 histoText =
'Average beam spot %s: (%.4g +- %.1g) mm' % (bstype, vave, eave)
1560 xtitle =
'Luminosity block number', ytitle =
'%s beamspot %s (mm)' % (onloffltype, bstype),
1561 histname =
'%s_vs_lb_run_%i' % (k.replace(
':',
'_').
replace(
'-',
'_'), run.runNr),
1562 histtitle =
'%s beamspot %s per LB for run %i' % (onloffltype, bstype, run.runNr),
1563 datapath = QC.datapath, ymin = ymin, ymax = ymax, printText = histoText )
1567 wincontent =
'<table class="outer" style="padding: 5px"><tr><td>'
1568 wincontent +=
'<strong><b>%s beamspot %s per LB for run %i:</b></strong><br><font size="-1"><font color="#888888">(Begin/end of run: %s)</font></font><hr color="black" size=1>' % (onloffltype, bstype, run.runNr, run.timestr(
'html', run.runNr != Run.runnropen))
1569 wincontent +=
'<table style="padding: 0px"><tr><td>'
1570 wincontent +=
'<img src="%s" align="left">' % (path)
1571 wincontent +=
'</td></tr></table>'
1572 wincontent +=
'<hr color="black" size=1>'
1574 wincontent +=
'<table style="width: auto; border: 0px solid; border-width: margin: 0 0 0 0; border-spacing: 0px; border-collapse: separate; padding: 0px; font-size: 90%; vertical-align:top; ">'
1575 wincontent +=
'<tr><th style="text-align:right">LB</th><th style="text-align:right"> Start time<br> (%s)</th><th style="text-align:right"> Duration<br>(sec)</th><th style="text-align:right"> Beamspot %s<br>(mm)</th><th style="text-align:right"> Fit status</th>' % (QC.tzdesc(),bstype)
1576 wincontent +=
'</tr><tr style="background:%s">' %
'#eeeeee'
1577 for idx,(lbtime,lbendtime)
in enumerate(run.lbtimes):
1579 timetuple = time.localtime(lbtime/1.E9)
if QC.localtime
else time.gmtime(lbtime/1.E9)
1580 wincontent +=
'<td style="text-align:right"> %s</td>' % lb
1581 wincontent +=
'<td style="text-align:right"> %s</td>' % time.strftime(
"%X",timetuple)
1582 wincontent +=
'<td style="text-align:right">%.2f</td>' % ((
float(lbendtime)-
float(lbtime))/1.E9)
1583 wincontent +=
'<td style="text-align:right">%.4g ± %.2g</td>' % yvec[bsidx[idx]]
1584 wincontent +=
'<td style="text-align:right">%i</td>' % yvecSt[bsidx[idx]]
1590 wincontent +=
'</tr><tr style="background:%s">' % col
1591 if run.runNr == Run.runnropen:
1592 wincontent +=
'<tr><td style="text-align:left"colspan="3"><i> Run still ongoing ...</i></td></tr>'
1593 wincontent +=
'</tr></table>'
1595 wincontent +=
"""<hr color="red" size=1><font color="#777777"><font size="-1"><i><font size="-2">Created by AtlRunQuery on: %s</font></i></font></td></tr></table><script type="text/javascript"></script></body></html>""" %
str(datetime.datetime.now())
1596 wincontent +=
'</td></tr></table>'
1598 openwincmd =
'<a href="javascript:openWindow('
1599 openwincmd +=
"'Print','<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">"
1600 openwincmd +=
"<html><head><title>Run query result for the %s beamspot</title><LINK href="html/atlas-runquery-lb.css" rel="stylesheet" type="text/css"></head>" % (onloffltype.lower())
1601 openwincmd +=
"<body><table style="font-family: sans-serif; font-size: 85%">"
1602 openwincmd += wincontent
1603 openwincmd +=
"</table></body></html>"
1604 openwincmd +=
"')\">"
1607 fullprint =
'<table class="triggerlinktable">'
1608 fullprint +=
'<tr><td colspan="2"><img src="%s" align="left" width="90px"></td></tr>' % path
1609 fullprint +=
'<tr><td colspan="2"></td></tr>'
1611 fullprint +=
'<tr><td style="text-align:left">Average %s:</td></tr><tr><td style="text-align:left"><nobr> %0.3g ± %.2g (RMS)</nobr></td></tr>' % (bstype, vave, eave)
1612 fullprint +=
'</table>'
1615 s +=
'<td class="showTip OFLBS stream" style="text-decoration:none; text-align: right">%s%s</a></td>' % (openwincmd, fullprint)
1620 if "STR:" == k[0:4]:
1623 s +=
'<td class="tdna">n.a.</td>'
1627 durInSec = (run.eor-run.sor)/1.0E9
1628 rate =
'n.a. Hz'
1631 rate =
'%.3f Hz' % (v[0]/durInSec)
1638 if 'calibration' not in k:
1639 fracstr =
'%.1f%%,' % (
float(strevents)/sumstrnev*100)
1655 lbrecinfo = run.stats[k][
'LBRecInfo']
1657 isPhysicsStream = lbrecinfo
is not None and len(lbrecinfo)>0
1659 ev = dict(lbrecinfo)
1662 for lb,nev
in lbrecinfo:
1664 for idx,(lbtime,lbendtime)
in enumerate(run.lbtimes):
1675 yvecR[-1] = nev/((
float(lbendtime)-
float(lbtime))/1.E9)
1681 hasStableBeamsInfo, xvecStb = run.getStableBeamsVector()
1684 wincontent =
'<table class="outer" style="padding: 5px">'
1685 wincontent +=
'<tr><td><b>Number of events and rates per LB for stream %s run %i:</b><br><font size="-1"><font color="#888888">(Begin/end of run: %s)</font></font><hr color="black" size=1>' % (streamName, run.runNr, run.timestr(
'html', run.runNr != Run.runnropen))
1688 pathN =
makeLBPlot( xvec, xvecStb, yvecN,
'Luminosity block number',
'Number of events / LB',
'',
1689 'nev_vs_lb_str_%s_run_%i' % (streamName, run.runNr),
1690 'N events per LB in stream "%s", run %i' % (streamName, run.runNr),
1691 QC.datapath,
'Total number of events: %i' % nevtot )
1692 pathR =
makeLBPlot( xvec, xvecStb, yvecR,
'Luminosity block numer',
'Event rate [Hz] / LB',
'',
1693 'rate_vs_lb_str_%s_run_%i' % (streamName, run.runNr),
1694 'Event rate per LB in stream "%s", run %i' % (streamName, run.runNr),
1696 wincontent +=
'<table style="padding: 0px">\n<tr><td>'
1697 wincontent +=
'<img src="%s" width="350">' % pathN.split(
'/')[-1]
1698 wincontent +=
'</td><td>'
1699 wincontent +=
'<img src="%s" width="350">' % pathR.split(
'/')[-1]
1700 wincontent +=
'</td></tr></table>\n'
1701 wincontent +=
'<hr color="black" size=1>\n'
1702 wincontent +=
'<table class="lb">\n'
1703 wincontent +=
'<tr><th>LB</th><th>Start time (%s)</th><th>Duration (sec)</th><th>Nevents</th><th>Cumul. Nevents</th><th>Rate [Hz]</th>' % QC.tzdesc()
1704 if hasStableBeamsInfo:
1705 wincontent +=
'<th>Stable beams</th>'
1706 wincontent +=
'</tr>\n<tr style="background:%s">' %
'#eeeeee'
1708 for idx,(lbtime,lbendtime)
in enumerate(run.lbtimes):
1714 stbBeams =
'−'
1716 averate += yvecR[idx]
1717 if yvecR[idx] > maxrate:
1718 maxrate = yvecR[idx]
1723 timetuple = time.localtime(lbtime/1.E9)
if QC.localtime
else time.gmtime(lbtime/1.E9)
1724 wincontent +=
'<td>%s</td><td>%s</td><td>%.2f</td><td>%i</td><td>%i</td><td>%.3g</td>' % (lb, time.strftime(
"%X",timetuple), (
float(lbendtime)-
float(lbtime))/1.E9,
int(yvecN[idx]), sumnev, yvecR[idx])
1725 if hasStableBeamsInfo:
1726 wincontent +=
'<td>%s</td>' % stbBeams
1731 wincontent +=
'</tr>\n<tr style="background:%s">' % col
1735 averate /=
float(nc)
1737 if run.runNr == Run.runnropen:
1738 wincontent +=
'<tr><td style="text-align:left"colspan="3"><i> Run still ongoing ...</i></td></tr>\n'
1739 wincontent +=
'</tr></table>\n'
1740 wincontent +=
'<hr color="red" size=1><font color="#777777"><font size="-1"><i><font size="-2">Created by AtlRunQuery on: %s</font></i></font></td></tr></table><script type="text/javascript"></script></body></html>' %
str(datetime.datetime.now())
1741 wincontent +=
'</td></tr></table>'
1746 tooltipkey =
"STROV_%i_%s" % (run.runNr, streamName)
1748 physStrOnlyInfo =
""
1750 maxrate =
'max: %.2f Hz' % (maxrate)
1751 averate =
'ave: %.2f Hz' % (averate)
1752 physStrOnlyInfo =
"%s,<br>%s,<br>%s, " % (maxrate, averate, fracstr)
1755 debugStrLink =
' <a href="https://trigmon.web.cern.ch/trigmon/ResultsAnalysis/RESULTS/%i/00%i_%s" target=_blank><font color="#993333">[MON]</font></a>' % (time.gmtime(run.sor/1.E9)[0], run.runNr, k[4:].strip())
1756 evtsize =
',<br>%s/evt' %
filesize(
float(strsize)/
float(strevents))
if (strevents>0)
else ""
1757 tdcontent =
'%s <BR><font size="-2">(%s%s/run%s%s)' % (
addKommaToNumber(strevents), physStrOnlyInfo,
filesize(strsize), evtsize, debugStrLink)
1760 tdcontent =
'<div class="showTip %s stream" style="display:inline;cursor:pointer">%s</div>' % (tooltipkey, tdcontent)
1764 filename = HU.CreatePopupHtmlPage(
'streamov_%i_%s' % (run.runNr, streamName), HU.WrapIntoHTML(wincontent, title=
"%s Stream Content" % streamName) )
1765 tdcontent =
'<a class="externalWindow" style="text-decoration:none" href="%s">%s</a>' % (filename, tdcontent)
1767 s +=
'<td style="text-decoration:none">%s</td>' % (tdcontent)
1773 if k==
"TriggerMenu":
1774 chains = run.splitTriggerChains(v)
1777 elif len(chains)==1:
1778 s +=
'<td style="min-width:300px"><font size="-2">%s</font></td>' % ( chains )
1779 elif len(chains)==2:
1780 s +=
'<td style="min-width:300px"><font size="-2">%s<hr color="gray" size=1>%s</font></td>' % ( chains )
1782 s +=
'<td style="min-width:300px"><font size="-2">%s<hr color="gray" size=1>%s<hr color="gray" size=1>%s</font></td>' % ( chains )
1787 if k==
"TriggerRates":
1789 s +=
'<td>%s</td>'%v
1792 triggergroups,imgpaths,openwincmds = HU.createRatePopupWindow(v,run)
1793 for idx,(trgroup,imgpath,openwincmd)
in enumerate(zip(triggergroups,imgpaths,openwincmds)):
1794 tooltipkey =
"TrRate_Set%i_%i" % (idx,run.runNr)
1795 contentpage =
"%s/popupContent_trRates_%i_%i.html" % (QC.datapath, run.runNr, idx)
1798 tablecontent +=
' <tr><td colspan="2"><hr color="gray"></td></tr>'
1799 imgcontent =
'<img src="%s" align="center" width="90px"><br>' % imgpath
1800 imagerow =
'<div class="showTip %s ratespopup" id="%s" style="display:inline;cursor:pointer;font-size:80%%;">%s</div>' % (tooltipkey, contentpage, imgcontent)
1801 tablecontent +=
' <tr><td colspan="2" >%s</td></tr>' % imagerow
1802 for tr,avr
in trgroup:
1803 tablecontent +=
' <tr><td>%s</td><td>: %3.1f Hz</td></tr>' % (tr,avr)
1804 s+=
"<td><table class='ratestable'>\n%s\n </table></td>" % tablecontent
1811 streamtypes = [
'physics_',
'express_',
'calibration_',
'debug_',
'debugrec_']
1812 steptypes = [
'.daq.',
'.recon.',
'.merge.',
'other',
'Reproc' ]
1813 datatypes = [
'.RAW',
'.DRAW',
'.ESD.',
'.DESD',
'.AOD.',
'.TAG.',
'.TAG_COMM.',
'.HIST.',
'.NTUP',
'other']
1814 vetotypes = [
'_TMP']
1818 s +=
'<table class="datasettable">'
1822 for stype
in streamtypes:
1823 for step
in steptypes:
1824 for dtype
in datatypes:
1827 if (stype
in ds[0]
and step
in ds[0]
and dtype
in ds[0])
or (stype
in ds[0]
and stype ==
'debug_' and step ==
'other' and (dtype
in ds[0]
or dtype ==
'other'))
and not ds[0]
in shownlist:
1829 for veto
in vetotypes:
1836 st += [
' %s' % (
filesize(ds[5]))]
1838 st += [
' unkn. evts ']
1840 st += [
' %s evts ' % (
prettyNumber(ds[6]))]
1841 selectedds[ds[0]] = st
1843 if 'replicate:done' in ds[2]:
1844 selectedds[ds[0]] += [
True]
1846 selectedds[ds[0]] += [
False]
1848 selectedds[ds[0]] += [
True]
1850 selectedds[ds[0]] += [
False]
1851 selectedds[ds[0]] += [ds[7]]
1852 shownlist.append(ds[0])
1856 dsnames = selectedds.keys()
1861 s +=
'<tr><td colspan="1"><font color="#666666"><i>[ Stream type + processing step + data type: <b>%s</b> + <b>%s</b> + <b>%s</b> ]</i> </font></td></tr>' % (stype, step, dtype)
1862 for dsname
in dsnames:
1864 dsnspl = dsname.split(
'.')
1865 lk =
"https://ami.in2p3.fr/AMI/servlet/net.hep.atlas.Database.Bookkeeping.AMI.Servlet.Command?Converter=/AMIXmlToAMIProdHtml.xsl&Command=FormBrowseDatasetPerParameter+-runNumber%3D"
1871 s +=
'<a href="https://ami.in2p3.fr/AMI/servlet/net.hep.atlas.Database.Bookkeeping.AMI.Servlet.Command?Converter=/AMIXmlToAMIProdHtml.xsl&Command=FormBrowseDatasetPerParameter+-runNumber%3D'
1872 s += runNum +
"+-dataType=" + format +
"+-projectName=" + project +
"+-streamName=" + stream
1873 s +=
'" target="_blank" title="AMI dataset information">'
1874 s += dsname +
'</td>'
1875 res = selectedds[dsname]
1876 s +=
'<td style="text-align:right"><font color="#005500"> [</font></td>'
1878 s +=
'<td style="text-align:right"><font color="#005500">%s</font></td>' % st
1879 s +=
'<td style="text-align:right"><font color="#005500">]</font></td>'
1881 if Run.showCAFLinks:
1882 s +=
'<td><a href="javascript:openPageWindow('
1883 s +=
"'data/%s.html','%s')" % (dsname,dsname)
1884 s +=
'"title="Check which files of this dataset are available on ATLCAL disk pool">'
1885 s +=
'<font color="#BB0517"> [ on CAF ]</font></a></td>'
1888 deltat = (datetime.datetime.utcnow() - res[5])
1889 deltat = deltat.days*24.*3600. + deltat.seconds
1890 allcafdsnames += dsname +
'@' +
'%g' % deltat +
','
1892 s +=
'<td><font color="#BB0517"> [ on CAF ]</font></td>'
1896 lk =
'<a href="https://ami.in2p3.fr/AMI/servlet/net.hep.atlas.Database.Bookkeeping.AMI.Servlet.Command?Command=FormGetDQ2InfoPerDataset+-logicalDatasetName%3D%22' + dsname +
'%22&Converter=%2FAMIXmlToProdFrameHtml.xsl" target="_blank" title="DQ2 information (via AMI) for dataset: ' + dsname +
'">'
1897 s +=
'<td>%s<font color="#153EBB"> [ in DDM ]</font></a></td>' % lk
1902 if dtype != datatypes[-1]:
1903 hrline =
'<tr><td colspan="8"><hr style="width:100%; background-color: #BBBBBB; height:1px; margin-left:0; border:0"/></td>'
1907 if step != steptypes[-1]:
1908 hrline =
'<tr><td colspan="8"><hr style="width:100%; background-color: #666666; height:2px; margin-left:0; border:0"/></td>'
1909 if stype != streamtypes[-1]:
1910 hrline =
'<tr><td colspan="8"><hr style="width:100%; background-color: #6D7B8D; height:3px; margin-left:0; border:0"/></td>'
1914 if 'TMP.' not in ds[0]
and ds[0]
not in shownlist:
1915 s_ +=
'<tr><td colspan=8>' + ds[0] +
'</td></tr>'
1917 s +=
'<tr><td colspan="8"><hr style="width:100%; background-color: #EE0000; height:3px; margin-left:0; border:0"/></td>'
1918 s +=
'<tr><td colspan=8><font color="#EE0000"><i>Remaining, unassigned datasets:</i></font></td></tr>'
1927 subprocess.Popen(
'python subproc.py caf %s' % (allcafdsnames[:-1]), shell=
True)
1935 linklist = run.stats[
'PSK'][
'blocks']
1937 '<a href="https://atlas-trigconf.cern.ch/run/smkey/{smk}/l1key/{l1psk}/hltkey/{hltpsk}/" target="_blank" '
1938 'title="L1: \'{l1name}\', HLT \'{hltname}\'. '
1939 'You can obtain the full trigger menu corresponding to SMK={smk} and prescale keys L1={l1psk}, HLT={hltpsk} in an independent window"'
1940 '>{l1psk} | {hltpsk}</a>'
1943 '<a href="https://atlas-triggertool.web.cern.ch/db/{db}/smk/{smk}/l1psk/{l1psk}/" target="_blank" '
1944 'title="L1: \'{l1name}\'. You can obtain the full trigger menu corresponding to SMK={smk} and L1 prescale key {l1psk} in an independent window"'
1948 '<a href="https://atlas-triggertool.web.cern.ch/db/{db}/smk/{smk}/hltpsk/{hltpsk}/" target="_blank" '
1949 'title="HLT: \'{hltname}\'. You can obtain the full trigger menu corresponding to SMK={smk} and HLT prescale key {l1psk} in an independent window"'
1953 if len(linklist)<=15:
1955 elif len(linklist)<=30:
1959 if len(linklist)<=15:
1960 nrow = len(linklist)
1961 elif len(linklist)<=45:
1964 nrow = (len(linklist)+2)//3
1966 s +=
'<td align="center"><table class="triggerlinktable" align="center">'
1968 for x
in range(ncol):
1969 s +=
'<td style="text-align:center;font-weight:bold" colspan="3">LB range</td><td style="text-align:center;font-weight:bold">L1 HLT</td>'
1972 for row
in range(nrow):
1974 for col
in range(ncol):
1975 entry = row + col*nrow
1976 if entry>=len(linklist):
1978 link = dict(zip( (
"startlb",
"endlb",
"l1psk",
"hltpsk",
"l1name",
"hltname"),linklist[entry]))
1980 "smk" : run.result[
"SMK"],
1981 "db" :
"dev1_i8" if int(run.result[
"SMK"]) < 3000
else "run3"
1983 s += f
'<td style="padding-left: 0.8em">{link["startlb"]}</td><td>−</td><td>{link["endlb"]}: </td>'
1985 cellContent = linkRun12.format(**link)
1987 cellContent = linkRun3L1.format(**link) +
" | " + linkRun3HLT.format(**link)
1988 s += f
'<td style="border-right: 1px solid gray; padding-right: 0.8em">{cellContent}</td>'
1991 s +=
'<hr style="width:100%; background-color: #AAAABB; height:1px; margin-left:0; border:0"/>'
1992 s +=
'<a href="https://atlas-trigconf.cern.ch/psevo/%i/" target="_blank" title="Obtain prescale evolution for all L1/L2/EF chains of this run in independent window"><font size="-2"><i>Prescale evolution...</i></font></a>' % run.runNr
1995 s +=
'<td style="text-align:center">n.a.</td>'
2002 smk =
int(run.result[
"SMK"])
2003 bgskOffset = 10000
if (smk<3000
and run.lhcRun==3)
else 0
2005 if len(run.stats[
'BGS Key' ][
'blocks'])>0:
2006 s +=
'<td align="center"><table class="triggerlinktable" align="center"><tr><td style="text-align:left;font-weight:bold" colspan="3">LB range</td><td style="text-align:right;font-weight:bold">BGS</td></tr>'
2007 for bgskey, lbbeg, lbend
in run.stats[
'BGS Key' ][
'blocks']:
2008 s +=
'<tr><td style="text-align:right">%i</td><td style="text-align:right">−</td><td style="text-align:right">%i: </td>' % (lbbeg, lbend-1)
2010 f
' <a href="https://atlas-trigconf.cern.ch/bunchgroups?key={bgskey+bgskOffset}" target="_blank" '
2011 f
'title="Obtain bunch group description for BGS Key={bgskey} in independent window"'
2014 s += f
'<td>{cellContent}</td></tr>'
2018 s +=
'<td style="text-align:center">n.a.</td>'
2020 s +=
'<td class="tdna">n.a.</td>'
2027 s +=
'<td class="tdna">n.a.</td>'
2029 namecomment =
'<div style="font-size:80%%;color:#488AC7"><b>%s</b> (v.%i)</div><div style="width:200px;font-size:60%%;color:#777777;text-align:left">%s</div>' % run.stats[
'SMK'][
'info']
2030 s +=
'<td style="text-align: center;">%s<br>%s</td>' % (v,namecomment)
2035 if 'lar:runtype' in k
or 'lar:format' in k:
2038 s +=
'<td style="text-align: center">%s<br><font size="-2">(%s)</font></td>' % (v,info[
int(v)])
2041 s +=
'<td class="tdna">n.a.</td>'
2043 s +=
'<td style="text-align: right">%s</td>' % v
2051 fullprint =
'<table class="triggerlinktable" align="center">'
2058 toffset =
int(run.sor/1.E9)
2059 deltat =
int(run.eor/1.E9) -
int(run.sor/1.E9)
2063 for idx,(lbtime,lbendtime)
in enumerate(run.lbtimes):
2065 xveclb.append( [lbtime/1.E9-toffset, (
float(lbendtime)-
float(lbtime))/1.E9] )
2070 for ik,key
in enumerate(keys):
2075 for (val,dte)
in v[key]:
2079 ts = time.strptime( dte[:dte.rfind(
':')] +
'/UTC',
'%d-%m-%Y %H:%M:%S/%Z' )
2080 tsec =
int(calendar.timegm(ts))
2081 xvec[-1].
append(tsec - toffset)
2087 arg = y2/
float(ic) - y*y
2092 ymin =
min(ymin,y - 1.5*y2)
2093 ymax =
max(ymax,y + 1.5*y2)
2097 if 'B1' in key
and 'hori' in key:
2098 vname =
'B1 horiz. IP'
2099 lname =
'B1 horizont IP pos.'
2100 elif 'B1' in key
and 'vert' in key:
2101 vname =
'B1 vert. IP'
2102 lname =
'B1 vertical IP pos.'
2103 elif 'B2' in key
and 'hori' in key:
2104 vname =
'B2 horiz. IP'
2105 lname =
'B2 horizontal IP pos.'
2106 elif 'B2' in key
and 'vert' in key:
2107 vname =
'B2 vert. IP'
2108 lname =
'B2 vertical IP pos.'
2109 legend.append( lname )
2110 fullprint +=
'<tr><td style="text-align:left">%s: </td><td>(</td><td style="text-align:right"> %s</td><td style="text-align:left"> ± </td><td style="text-align:left">%.4g</td><td>) um</td><td> </td>' % (vname, (
'%.4g' % y).
replace(
'-',
'−'), y2)
2113 fullprint +=
'<td rowspan="4">REPLACEME</td>'
2114 fullprint +=
'</tr>'
2117 bpmrootfilename = QC.datapath +
'/bpm_output_run%i.root' % run.runNr
2118 SaveGraphsToFile( bpmrootfilename, keys, xvec, yvec,
"TimeOffset", toffset )
2120 bpmtextfilename = QC.datapath +
'/bpm_output_run%i.txt' % run.runNr
2121 bpmout =
open( bpmtextfilename,
'w' )
2123 bpmout.write(
'# BPM Output for run %i\n' % run.runNr )
2124 bpmout.write(
'# Start - end of run: %s [UTC]\n' % run.timestr(
'txt') )
2125 bpmout.write(
'# Time offset applied below in seconds: %i\n' %
int(toffset) )
2126 bpmout.write(
'#\n' )
2127 bpmout.write(
'# ---------------------------------------------------------------------------------\n' )
2128 for ik,key
in enumerate(keys):
2129 bpmout.write(
'# Output for variable: "%s"\n' % key )
2130 bpmout.write(
'# Format: index / timestamp (seconds) wrt. begin of run / BPM position in microns\n' )
2131 bpmout.write(
'#\n' )
2132 for i
in range(len(xvec[ik])):
2133 bpmout.write(
"%4i %9.2f %14.6f\n" % (i, xvec[ik][i], yvec[ik][i]) )
2134 bpmout.write(
'#\n' )
2135 bpmout.write(
'# ---------------------------------------------------------------------------------\n' )
2138 fullprint +=
'<tr><td colspan=8><hr style="width:100%; background-color:#999999; height:1px; margin-left:0; border:0"/></td></tr>'
2139 fullprint +=
'<tr><td colspan=8 style="text-align:left"><a href="%s" target="_blank" title="Tabulated BPM information versus time for run %i"><i>Click here for tabulated BPM values versus time...</i></a></td></tr>' % (bpmtextfilename, run.runNr)
2140 fullprint +=
'<tr><td colspan=8 style="text-align:left"><a href="%s" target="_blank" title="BPM information versus time for run %i as four TGraph objects in ROOT file"><i>Right-click to download ROOT file with TGraphs...</i></a></td></tr>' % (bpmrootfilename, run.runNr)
2141 fullprint +=
'</table>'
2145 'Time of day (UTC)',
'Beam position (microns)', legend,
2146 'bp_vs_time_run_%i' % (run.runNr),
2147 'Beam position versus time of day for run %i' % (run.runNr),
2150 replacetxt =
'<img src="%s" align="left" width="70px">' % path
2151 fullprint = fullprint.replace(
'REPLACEME',replacetxt)
2154 wincontent =
'<table class="outer" style="padding: 5px"><tr><td>'
2155 wincontent +=
'<strong><b>LHC beam positions at IP verssu time for run %i:</b></strong><br><font size="-1"><font color="#888888">(Begin/end of run: %s)</font></font><hr color="black" size=1>' % (run.runNr, run.timestr(
'html', run.runNr != Run.runnropen))
2156 wincontent +=
'<table style="padding: 0px"><tr><td>'
2157 wincontent +=
'<img src="%s" align="left"></td>' % path
2158 wincontent +=
'</td></tr></table>'
2159 wincontent +=
"""<hr color="red" size=1><font color="#777777"><font size="-1"><i><font size="-2">Created by AtlRunQuery on: %s</font></i></font></td></tr></table><script type="text/javascript"></script></body></html>""" %
str(datetime.datetime.now())
2160 wincontent +=
'</td></tr></table>'
2163 openwincmd = HU.OpenWindow(wincontent,title=
"Summary of LHC information")
2166 s +=
'<td style="text-decoration:none">%s<div class="showTip BPM stream" style="display:inline;cursor:pointer">%s</div></a></td>' % (tooltipkey, fullprint)
2178 hasStableBeamsInfo, xvecStb = run.getStableBeamsVector()
2184 for kp
in Run.ShowOrder:
2185 if 'ofllumi:' in kp.ResultKey:
2186 name, chanstr, tagstr = kp.ResultKey.split(
':')
2188 chans.append(chanstr)
2195 if ich
in OLCAlgorithms:
2196 chanstr.append(OLCAlgorithms[ich])
2198 chanstr.append(
'Unknown')
2206 for ikp,kp
in enumerate(kref):
2210 intlumiStb.append(0)
2211 for entry
in run.data[kp]:
2212 if entry.startlb == 0:
2214 val = entry.value
if entry.value!=
'n.a.' and entry.value>0
else 0
2215 lastlb =
min(entry.lastlb,run.lastlb)
2216 lbs =
range(entry.startlb,lastlb+1)
2219 yvec[-1] += len(lbs)*[
float(val)]
2222 for idx,(lbtime,lbendtime)
in enumerate(run.lbtimes):
2225 for ich
in range(len(chans)):
2227 intlumi[ich] += tmp[idx]*dt/1000.0
2229 intlumiStb[ich] += yvec[ich][idx]*dt/1000.0
2231 yvec[ich][idx] *= 1.0
2232 if yvec[ich][idx] > peaklumi[ich]:
2233 peaklumi[ich] = yvec[ich][idx]
2237 if hasStableBeamsInfo:
2238 for ich,ch
in enumerate(chans):
2239 fullprint_ +=
'Integrated (channel: %s): %0.4g<br>Stable B: %0.4g<br>' % (ch,intlumi[ich],intlumiStb[ich])
2240 histoText =
'Integr. lumi (channel: %i): %.4g nb-1 (all LBs) and %.4g nb-1 (stable beams)' % (0, intlumi[0],intlumiStb[0])
2242 for ich,ch
in enumerate(chans):
2243 fullprint_ +=
'Integrated (channel: %s): %0.4g<br>' % (ch,intlumi[ich])
2244 histoText =
'Integr. lumi (channel: %i): %.4g nb-1 (all LBs)' % (0, intlumi[0])
2248 'Luminosity block number',
'Offline luminosity (10^{30}cm^{-2}s^{-1})', chanstr,
2249 'ofllumi%s_vs_lb_run_%i' % (chans[0],run.runNr),
2250 'Offline lumi per LB for run %i' % (run.runNr),
2251 QC.datapath, histoText )
2254 wincontent =
'<table class="outer" style="padding: 5px"><tr><td>'
2255 wincontent +=
'<strong><b>Offline luminosity per LB for run %i:</b></strong><br><font size="-1" color="#888888">(Begin/end of run: %s)</font>' % (run.runNr, run.timestr(
'html', run.runNr != Run.runnropen))
2256 wincontent +=
'<hr color="black" size=1>'
2257 wincontent +=
'<table style="padding: 0px"><tr><td>'
2258 wincontent +=
'<img src="%s" align="left">' % path
2259 wincontent +=
'</td></tr></table>'
2260 wincontent +=
'<hr color="black" size=1>'
2261 wincontent +=
'<table class="LB">'
2262 wincontent +=
'<tr><th>LB</th><th>Start time<br> (%s)</th><th>Duration<br>(sec)</th>' % QC.tzdesc()
2264 wincontent +=
'<th>Inst. luminosity<br>(1e%s cm<sup>−2</sup>s<sup>−1</sup>)<br>[ %s ]</th>' % (run.instlumiunittxt,ch)
2265 wincontent +=
'<th>Stable beams</th>'
2266 wincontent +=
'</tr><tr style="background:%s">' %
'#eeeeee'
2267 for idx,(lbtime,lbendtime)
in enumerate(run.lbtimes):
2269 stbBeams =
'−'
2272 timetuple = time.localtime(lbtime/1.E9)
if QC.localtime
else time.gmtime(lbtime/1.E9)
2273 wincontent +=
'<td>%i</td><td>%s</td><td>%.2f</td>' % (lb, time.strftime(
"%X",timetuple), (
float(lbendtime)-
float(lbtime))/1.E9)
2274 for ich
in range(len(chans)):
2275 wincontent +=
'<td>%.4g</td>' % (yvec[ich][idx])
2276 wincontent +=
'<td>%s</td>' % stbBeams
2281 wincontent +=
'</tr><tr style="background:%s">' % col
2282 if run.runNr == Run.runnropen:
2283 wincontent +=
'<tr><td style="text-align:left"colspan="3"><i> Run still ongoing ...</i></td></tr>'
2284 wincontent +=
'</tr></table>'
2285 wincontent +=
"""<hr color="red" size=1><font color="#777777"><font size="-1"><i><font size="-2">Created by AtlRunQuery on: %s</font></i></font></td></tr></table><script type="text/javascript"></script></body></html>""" %
str(datetime.datetime.now())
2286 wincontent +=
'</td></tr></table>'
2288 openwincmd = HU.OpenWindow(wincontent,title=
"Run query result for online luminosity")
2291 fullprint =
'<table class="bcidtable">'
2292 fullprint +=
'<tr><td colspan="2"><img src="%s" align="left" width="90px"></td></tr>' % path
2293 if hasStableBeamsInfo:
2294 for ich
in range(len(chans)):
2295 fullprint +=
'<tr><td style="text-align:left">Entire run:</td><td style="text-align:left"> %0.4g %s<sup>−1</sup></td></tr><tr><td style="text-align:left">Stable beams:</td><td style="text-align:left"> %0.4g %s<sup>−1</sup></td></tr><tr><td style="text-align:left">Peak lumi:</td><td style="text-align:left"> %0.3g e%s cm<sup>−2</sup>s<sup>−1</sup></td></tr>' % (intlumi[ich], run.lumiunittxt, intlumiStb[ich], run.lumiunittxt, peaklumi[ich], run.instlumiunittxt)
2297 for ich
in range(len(chans)):
2298 fullprint +=
'<td style="text-align:left">All LBs:</td><td style="text-align:left"> %0.4g</td></tr>' % (intlumi[ich])
2299 fullprint +=
'</table>'
2302 s +=
'<td class="showTip OFLLumi stream" style="text-decoration:none; text-align: right">%s%s</a></td>' % (openwincmd, fullprint)
2307 if any( [ (
'lhc:' in k
and 'beamenergy' not in k),
2308 (
'TorCurrent' in k),
2309 (
'SolCurrent' in k),
2311 (
'Ready for physics' in k),
2317 for entry
in run.data[k]:
2318 if entry.startlb == 0:
2324 if 'bs:' not in k
and 'ofllumi:' not in k
and 'beam1intensity' not in k
and 'beam2intensity' not in k:
2330 if 'beamenergy' in k
and val>=7864:
2333 if not keys
or res[-1] != val:
2335 keys[-1][1] = entry.startlb
2337 keys.append( [entry.startlb, entry.endlb] )
2338 elif res[-1] == val:
2339 keys[-1][1] = entry.endlb
2343 s +=
'<td><table class="triggerlinktable" align="center">'
2344 for i, c
in enumerate(keys):
2345 if int(c[0]) !=
int(c[1])-1:
2346 s +=
'<tr><td>LB </td><td style="text-align:right">%i</td><td style="text-align:right">−</td><td style="text-align:right">%i: </td>' % (
int(c[0]),
int(c[1])-1)
2348 s +=
'<tr><td>LB </td><td style="text-align:right">%i</td><td style="text-align:right"></td><td style="text-align:right">: </td>' % (
int(c[0]))
2351 if 'bs:' in k
or 'beam1intensity' in k
or 'beam2intensity' in k:
2352 vt =
'%.4g' % abs(val)
2356 vt = vt.replace(
'e-',
'e−')
2357 s +=
'<td style="text-align:right">%s</td></tr>' % vt
2358 elif 'ofllumi:' in k:
2359 s +=
'<td style="text-align:right">%g</td></tr>' % val
2361 s +=
'<td style="text-align:right">%i</td></tr>' %
round(val)
2363 s +=
'<td style="text-align:left">%s</td></tr>' % res[i].strip()
2364 s +=
'</table></td>'
2369 vt =
'%.4g' % abs(
float(v))
2375 v = v.replace(
'e-',
'e−')
2378 if 'beamenergy' in k
and v >= 7864:
2384 s +=
'<td style="text-align:center;font-size: 85%%">%s</td>' % v
2387 if (
'lhc:stablebeams' in k
and 'lhc:beamenergy' in Run.ShowOrder
and 'lhc:beammode' not in Run.ShowOrder)
or 'lhc:beammode' in k:
2388 imgpath, xvec, yvec, ymax = HU.makeSummaryPlotForLHC(run)
2389 wincontent = HU.makeSummaryPageForLHC(run, yvec, imgpath)
2390 openwincmd = HU.OpenWindow(wincontent,
'Summary of LHC information')
2391 fullprint =
'<table class="bcidtable">'
2392 fullprint +=
'<tr><td><img src="%s" align="left" width="90px"></td></tr>' % imgpath
2393 fullprint +=
'<tr><td style="text-align:left">Maximum intensities:<br>Beam 1: %0.3g e11 protons<br>Beam 2: %0.3g e11 protons</td></tr>' % (ymax[0], ymax[1])
2394 fullprint +=
'<tr><td style="text-align:left">Maximum beam energy:<br>%i GeV</td></tr>' %
int(ymax[2])
2395 fullprint +=
'</table>'
2396 fullprint +=
'<span style="font-size: xx-small; color: #555555">[ <i>Numbers given for stable beam period (if applies)</i> ]</span>'
2398 s +=
'<td class="showTip LHCSummary stream" style="text-decoration:none; text-align: left">%s %s </a></td>' % (openwincmd, fullprint)
2406 s +=
'<td class="tdna">n.a.</td>'
2408 s +=
'<td style="text-align: right">%s</td>' % v
2420 with timer(
"Tooltips"):