13 from __future__
import with_statement, print_function
14 from functools
import total_ordering
15 from CoolRunQuery.utils.AtlRunQueryTimer
import timer
17 from CoolRunQuery.utils.AtlRunQueryUtils
import addKommaToNumber, filesize, prettyNumber, RunPeriods
18 from CoolRunQuery.utils.AtlRunQueryLookup
import DecodeDetectorMask
19 from CoolRunQuery.utils.AtlRunQueryIOV
import IOVRange,IOVTime
20 from CoolRunQuery.utils.AtlRunQueryLookup
import LArConfig, isDQ, OLCAlgorithms
21 from CoolRunQuery.output.AtlRunQueryRoot
import makeLBPlot, makeLBPlotList, makeTimePlotList, makeBSPlots, SaveGraphsToFile
22 from CoolRunQuery.AtlRunQueryQueryConfig
import QC
23 from CoolRunQuery.selector.AtlRunQuerySelectorBase
import DataKey, Selector
33 _fW = {
'Run' : 12,
'NLB': 5,
'Time': 50,
'#Events': 10,
'Stream': 10}
36 def __init__(self, iov, value, reject=False, valueForStorage=None):
47 return "<DataEntry %s>" % self
51 if length_L>0x7FFFFFFF:
65 return ((0x100000000 + self.
endlb)-1) & 0xFFFFFFFF
74 lbstart, lbend = lbrange
79 return {
'firstlb' : self.
startlb,
'lastlb' : self.
lastlb,
'value' : v,
'accepted' :
not self.
rejected }
99 return [x
for x
in self
if x.contains(lb)]
103 return set([e.startlb
for e
in self]).union(
set([e.lastlb+1
for e
in self]))
107 return max([e.lastlb
for e
in self])
111 return max([e.endlb
for e
in self])
114 return [e.pickled()
for e
in self]
117 return [e.json()
for e
in self]
125 DefectSelector =
None
137 return k
in self.
data or k.ResultKey
in self.
data
138 return k
in self.
data
146 return self.
data[k]
if k
in self.
data else self.
data[k.ResultKey]
154 for lb
in self.
stops:
187 need_dq_check =
False
189 if k
in RunData.DQKeys:
205 for orGroup
in RunData.DQLogic:
228 if not s.isRejectedCurrentLB:
234 if 'Ready for physics' not in self:
235 raise RuntimeError(
"No ready data available")
236 readydata = [x
for x
in self.
data[
'Ready for physics']
if x.value==
'1']
244 if type(lb)==tuple
and len(lb)==2:
249 raise RuntimeError(
"Can't interpret lb to check isReady(lb=%r)" % lb)
254 a = [(
int(data.lb),
not data.isRejectedCurrentLB)
for data
in self
if data.lb<=last_lb]
263 ranges += [(state, start, x[0])]
265 last_start,last_state = a[-1]
266 if last_state==state:
267 ranges += [(state, start, last_lb+1)]
269 ranges += [(state, start, last_start)]
270 ranges += [(last_state, last_start, last_lb+1)]
272 return [x
for x
in ranges
if x[0]]
283 stops.update(entrylist.stops())
286 def addResult(self, iov, k, value, reject, valueForStorage = None):
288 iov = IOVRange(runStart=self.
run, lbStart=1, runEnd=self.
run+1, lbEnd=0)
289 self[k].
append(
DataEntry(iov=iov, value=value, reject=reject, valueForStorage=valueForStorage))
294 s +=
"%*s %*s " % (4, self.
lb, 4, self.
lbend())
297 s +=
"%*s " % (_fW[
'Time'],
'')
300 for k
in Run.SortedShowOrder():
310 if k ==
"#Events" or k[0:4] ==
"STR:" or k==
"TriggerMenu" or k==
"TriggerRates" or k==
"olc:bcidmask":
319 _SortedShowOrder =
None
320 DisplayOrder = map(re.compile,[
'#Events',
'Ready',
'lhc:|olc:',
'TriggerMenu|SMK|Release|L1 PSK|HLT PSK|BGS|TriggerRates',
'bs:',
'STR:',
'DQ|SHIFTOFL:|LBSUMM:',
'lar:',
'Detector',
'.*'])
335 runPeriods = RunPeriods()
346 cls.
GlobalTooltips += [
'dw_Tooltip.content_vars["%s"] = {content: \'%s\'};' % (var, content.replace(
"'",
"'"))]
371 if self.
runNr > 378000:
375 elif self.
runNr > 249000:
382 if self.
runNr > 168206
and self.
runNr <= 170482:
391 return "%i" % self.
runNr
395 return self.
data.data_current_lb
406 self.
tooltips += [
'dw_Tooltip.content_vars["%s\"] = {content: \'%s\'};' % (var, content.replace(
"'",
"'"))]
409 if len(self.
xvecStb)==0
and 'lhc:stablebeams' in Run.ShowOrder
and 'lhc:stablebeams' in self.
data:
410 entries = self.
data[
'lhc:stablebeams']
411 for entry
in entries:
412 if entry.startlb == 0:
414 if 'true' in entry.value.lower():
421 if Run._SortedShowOrder
is not None:
422 if len(Run._SortedShowOrder) != len(Run.ShowOrder):
423 raise RuntimeError (
"Sorting not up-to-date %i %i" % (len(Run._SortedShowOrder), len(Run.ShowOrder) ))
424 return Run._SortedShowOrder
426 for order
in Run.DisplayOrder:
427 for x
in Run.ShowOrder:
428 if not order.match(x.ResultKey):
433 Run._SortedShowOrder = hk
434 if len(Run._SortedShowOrder) != len(Run.ShowOrder):
435 raise RuntimeError (
"Sorting not up-to-date after creation %i %i" % (len(Run._SortedShowOrder), len(Run.ShowOrder) ))
436 return Run._SortedShowOrder
442 hk += [
'Run',
'Links',
'#LB']
444 hk += [
'Start and endtime (%s)' % QC.localStr()]
449 if 'L1 PSK' in x
or (
'olc:' in x
and (
'beam1bunches' in x
or 'beam2bunches' in x
or 'collbunches' in x
or 'beam1intensity' in x
or 'beam2intensity' in x)):
462 s +=
' <th>Run</th><th>Links</th><th>#LB</th>\n'
464 s +=
' <th>Start and endtime (%s)</th>\n' % QC.localStr()
466 s +=
' <th>Duration</th>\n'
467 for ik, data_key
in enumerate(Run.SortedShowOrder()):
468 k = data_key.ResultKey
470 s +=
' <th><font size="-2">%s_<BR>%s</font></th>' % tuple(k[4:].
split(
'_',1))
471 elif k[0:8] ==
"Detector":
472 s +=
' <th>%s</th>' % k
473 elif "SolCurrent" in k:
474 s +=
' <th>Solenoid<br>current (A)</th>'
475 elif "TorCurrent" in k:
476 s +=
' <th>Toroid<br>current (A)</th>'
479 matching_names = dict(Run.Fieldinfo[
'DQ'][
'DefMatch'])
481 for channelname
in Run.Fieldinfo[
'DQ'][
'DefChannels']:
482 tip =
"defect_match_%s" % channelname
483 info =
"%s # %s" % (channelname
if channelname!=
"" else "*",data_key._second_internal_key
if data_key._second_internal_key!=
"" else "HEAD")
484 s +=
'<th style="align:center; white-space:nowrap; padding-right: 10px; padding-left: 10px; ">'
485 s +=
'Data Quality<br><span class="showTip %s tooltip" style="font-weight:normal; font-size:80%%">(%s)</span>' % (tip, info)
487 s +=
'<div style="font-size: xx-small; cursor: pointer;" onclick="toggle_dq(this)">[show tolerable]</div>'
491 allDefects =
sorted(matching_names[channelname])
492 n = 4*[len(allDefects)//4]
493 for x
in range(len(allDefects) % 4):
500 columns.append( allDefects[
slice(cx,cx+x)] )
503 for x
in columns[1:]:
506 columnsTransposed = zip(*columns)
509 for z
in columnsTransposed:
510 tts +=
'<tr>%s</tr>' %
''.
join([
"<td>%s</td>"% x
for x
in z])
511 content =
'<table style="width:500px; font-size:80%%;">%s</table>' % tts
512 Run.addGlobalToolTip(tip,content)
515 foldertag,flag = k.split(
':')
517 if flag
in Run.Fieldinfo:
518 tipname =
'dqvfdesc_%s' % flag
519 commentbox =
'%s' % (Run.Fieldinfo[flag])
520 Run.addGlobalToolTip(tipname, commentbox)
521 s +=
'<th class="showTip %s tooltip" style="cursor:pointer">' % tipname
525 s +=
'<font size="-1">%s</font><BR><font style="font-weight:normal;font-size:70%%">' % flag
527 s +=
'(%s #<br>%s)' % tuple(foldertag.split(
'#',1))
529 s +=
'(%s)' % (foldertag)
535 s +=
' <th>Prescale keys</th>'
537 s +=
' <th>HLT Release</th>'
538 elif k ==
"Datasets":
539 s +=
' <th>Tier-0 Datasets</th>'
540 elif k ==
'#Events (incl. calib.)':
541 s +=
' <th>#Events<br><font size="-2">(incl. calib.)</font></th>'
542 elif k ==
'#Events (streamed)' :
543 s +=
' <th>#Events<br><font size="-2">(streamed)</font></th>'
546 s +=
' <th><font size="-2">Run type</font></th>'
547 elif 'nsamples' in k:
548 s +=
' <th><font size="-2">#Samples</font></th>'
549 elif 'firstsample' in k:
550 s +=
' <th><font size="-2">1st sample</font></th>'
552 s +=
' <th><font size="-2">Format</font></th>'
554 print (
'ERROR: unknown LAr option "%s"' % k)
557 if 'fillnumber' in k:
558 s +=
' <th> LHC Fill</th>'
559 elif 'stablebeams' in k:
560 s +=
' <th>Stable beams</th>'
561 if 'lhc:beammode' in Run.ShowOrder:
562 s +=
' <th>Beam mode</th>'
563 if 'lhc:beamenergy' in Run.ShowOrder:
564 s +=
' <th>Beam energy and intensities</th>'
566 elif 'beamenergy' in k:
569 s +=
' <th>#Bunches B1 <br><font size="-2"><b>(NOT YET RELIABLE)</b></font></th>'
571 s +=
' <th>#Bunches B2 <br><font size="-2"><b>(NOT YET RELIABLE)</b></font></th>'
572 elif 'nbunchcoll' in k:
573 s +=
' <th>#Bunches<br>colliding <br><font size="-2"><b>(NOT YET RELIABLE)</b></font></th>'
574 elif 'beamtype1' in k:
575 s +=
' <th>Beam type B1</th>'
576 elif 'beamtype2' in k:
577 s +=
' <th>Beam type B2</th>'
578 elif 'machinemode' in k:
579 s +=
' <th>LHC mode</th>'
580 elif 'beammode' in k:
583 print (
'ERROR: unknown LHC option "%s"' % k)
585 elif 'ofllumi:' in k:
587 s +=
' <th>Offline Luminosity<br><font style="font-weight:normal">(%s)</font></font></th>' % k.split(
':')[-1]
590 kt = k.replace(
'bs:',
'')
591 if 'bs:Pos' in k
or 'bs:Sig' in k:
592 s +=
' <th><font size="-2">%s<br><font style="font-weight:normal">(mm)</font></font></th>' % kt
594 s +=
' <th><font size="-2">%s<br><font style="font-weight:normal">(rad)</font></font></th>' % kt
596 s +=
' <th><font size="-2">%s</font></th>' % kt
598 s +=
' <th>Beam Position Monitors (BPM)</th>'
601 tp1, tp2, chan = k.split(
':')
606 if chan
in OLCAlgorithms:
607 chanstr = OLCAlgorithms[chan]
610 s +=
' <th>Online del. Luminosity <font size="-2"><br><font style="font-weight:normal">[%s]</font></font></th>' % chanstr
611 elif 'beam1bunches' in k:
613 elif 'beam2bunches' in k:
615 elif 'collbunches' in k:
617 elif 'bcidmask' in k:
618 s +=
' <th>Bunch structure</th>'
619 elif 'beam1intensity' in k:
621 elif 'beam2intensity' in k:
624 s +=
' <th>%s</th>' % k
627 s +=
' <th>Bunch group key</th>'
630 s +=
' <th>%s</th>' % k
636 patterns = [ (
'lar:',
'LAr configuration'),
637 (
'lhc:|olc:',
'LHC and online luminosity information' if any([
'olc:' in x
for x
in Run.headerkeys()])
else 'LHC information' ),
638 (
'bs:',
'Beam spot parameters (%s)' % Run.BeamspotSource),
639 (
'STR:',
'Data stream statistics'),
640 (
'TriggerMenu|SMK|Release|L1 PSK|HLT PSK|BGS|TriggerRates',
'Trigger information'),
641 (
'SHIFTOFL:',
'Data quality (SHIFTOFL)'),
642 (
'LBSUMM:',
'Data quality (LBSUMM)')
646 for (p,hdesc)
in patterns:
647 matchedpositions = [idx
for (idx,head)
in enumerate(Run.headerkeys())
if re.match(p,head)]
650 order += [(
min(matchedpositions),
max(matchedpositions),hdesc)]
659 secondheader +=
'<th colspan="%s"></th>' % (th[0]-current)
661 for x
in range(th[0]-current):
662 secondheader +=
'<th></th>'
663 secondheader +=
'<th colspan="%s">%s</th>' % (th[1]-th[0]+1,th[2])
665 if len(Run.headerkeys())>current:
667 secondheader +=
'<th colspan="%s"></th>' % (len(Run.headerkeys())-current)
669 for x
in range(len(Run.headerkeys())-current):
670 secondheader +=
'<th></th>'
671 secondheader =
"<tr>%s</tr>" % secondheader
674 s =
'<thead>' + secondheader + s +
'</thead>\n'
679 if any([k
for k
in Run.ShowOrder
if "olc:lumi" in k.ResultKey]):
680 boxcontent =
'<font color="#AA0000">Click to enlarge figure and to obtain online integrated luminosity versus LB</font>'
681 Run.addGlobalToolTip(
"OLCLumi", boxcontent)
684 if any([k
for k
in Run.ShowOrder
if "ofllumi" in k.ResultKey]):
685 boxcontent =
'<font color="#AA0000">Click to obtain offline integrated luminosity versus LB</font>'
686 Run.addGlobalToolTip(
"OFLLumi", boxcontent)
689 if any([k
for k
in Run.ShowOrder
if "bs:" in k.ResultKey]):
690 boxcontent =
'<font color="#AA0000">Click to obtain %s beamspot versus LB</font>' % (Run.BeamspotSource.split()[0])
691 Run.addGlobalToolTip(
"OFLBS", boxcontent)
694 if any([k
for k
in Run.ShowOrder
if "BPM" == k.ResultKey]):
695 boxcontent =
'<font color="#AA0000">Click to enlarge figure</font>'
696 Run.addGlobalToolTip(
"BPM", boxcontent)
699 if any([k
for k
in Run.ShowOrder
if "lhc:fillnumber" in k.ResultKey]):
700 boxcontent =
'<font color="#AA0000">Click to enlarge figure</font>'
701 Run.addGlobalToolTip(
"LHCSummary", boxcontent)
708 s +=
'%-*s %*s ' % (_fW[
'Run'],
'Run',_fW[
'NLB'],
'#LB')
710 s +=
'%-*s %*s ' % (_fW[
'Run'],
' ',_fW[
'NLB'],
' ')
713 hstr =
'Start and endtime (%s)' % QC.localStr()
715 s +=
'%*s ' %(_fW[
'Time'],hstr)
717 s +=
'%*s ' %(_fW[
'Time'],
' ')
720 s +=
'%*s ' % (10,
'Duration')
722 s +=
'%*s ' % (10,
' ')
723 for k
in Run.SortedShowOrder():
724 if k.Type == DataKey.STREAM:
725 w =
max(len(k.Header)-k.Header.find(
'_'),_fW[
'Stream'])
727 s +=
'%*s ' % (w,k.Header[4:k.Header.find(
'_')])
729 s +=
'%*s ' % (w,k.Header[k.Header.find(
'_')+1:])
735 s +=
'%*s ' % (w,k.Header)
737 s +=
'%*s ' % (w,
' ')
742 def addResult(self, resDictKey, value, iov=None, reject=False, valueForStorage=None):
743 if resDictKey==
'DQ' and value==
'n.a.':
745 if resDictKey
not in self.
result:
746 self.
result[resDictKey] = value
748 if iov.startTime.lb>self.
lastlb:
750 iov.endTime =
min(iov.endTime, IOVTime(self.
runNr,self.
lastlb+1) )
751 self.
data.
addResult(iov, resDictKey, value, reject, valueForStorage=valueForStorage)
756 if time.gmtime(self.
sor/1.E9).tm_year >= 2010:
757 s +=
' <a href="http://atlas.web.cern.ch/Atlas/GROUPS/DATAPREPARATION/DataSummary/%i/run.py?run=%i" target="_blank" title="Data summary information for run %i"><font size="-3">DS</font></a>, \n' % (time.gmtime(self.
sor/1.E9).tm_year, self.
runNr, self.
runNr)
759 s +=
' <a href="http://atlas-service-db-runlist.web.cern.ch/atlas-service-db-runlist/php/runDetails.php?run=%i" target="_blank" title="Run summary information for run %i"><font size="-3">RS</font></a>, \n' % (self.
runNr, self.
runNr)
761 s +=
' <a href="https://atlas-beamspot.cern.ch/webapp/jobs/?r=%i" target="_blank" title="Beam spot fit information for run %i"><font size="-3">BS</font></a>, \n' % (self.
runNr, self.
runNr)
763 s +=
' <a href="https://ami.in2p3.fr/AMI/servlet/net.hep.atlas.Database.Bookkeeping.AMI.Servlet.Command?Converter=/AMIXmlToAMIProdHtml.xsl&Command=FormBrowseDatasetPerRun+-runNumber=%i" target="_blank" title="AMI reference for run %i"><font size="-3">AMI</font></a>, \n' % (self.
runNr, self.
runNr)
765 s +=
' <a href="https://atlasdqm.web.cern.ch/atlasdqm/DQBrowser/makeMatrix.php?selection=All&run=%i&runup=&dbinstance=COMP200_SHIFTOFL&tag=HEAD" target="_blank" title="Browse detailed data quality entries for run %i (uses SHIFTOFL folder in COMP200 conditions database)"><font size="-3">DQ</font></a>,<br>\n' % (self.
runNr, self.
runNr)
767 s +=
' <a href="https://atlasop.cern.ch/elog/ATLAS/ATLAS/?mode=full&reverse=0&reverse=1&npp=20&ma=1&ya=2008&last=3064&subtext=%i&sall=0" target="_blank" title="Search for ELOG entries on run %i"><font size="-3">ELOG</font></a>, \n' % (self.
runNr, self.
runNr)
769 tbeg = time.strftime(
"%Y-%m-%d-%H-%M-%S", time.gmtime(self.
sor/1.E9))
770 t = time.gmtime(self.
eor/1.E9)
771 tend =
"%4i-%02i-%02i-%02i-%02i" % (t[0], t[1], t[2], t[3], t[4])
772 s +=
' <a href="http://atlas-dcs.cern.ch/navigation.php?date2=%s" target="_blank" title="DCS status at begin of run %i"><font size="-3">DCS:SoR</font></a>/' % (tbeg, self.
runNr)
773 s +=
'<a href="http://atlas-dcs.cern.ch/navigation.php?date2=%s" target="_blank" title="DCS status at end of run %i"><font size="-3">EoR</font></a>, \n ' % (tend, self.
runNr)
780 s +=
' <a href="http://cern.ch/atlas-project-tdaq-cc/cgi/getdata.sh?tdaq-05-05-00&oracle://atlas_oks/r&atlas_oks_archive&%i&%i&ATLAS" target="_blank" title="Download online configuration for run %i"><font size="-3">OKS</font></a>\n' % ( self.
data[
'oks'][0].value + (self.
runNr,) )
782 (hash, release) = self.
data[
"oks"][0].value
783 s+= f
' <a href="https://gitlab.cern.ch/atlas-tdaq-oks/p1/{release}/-/tree/{hash[5:]}" target="_blank" title="Browse online configuration for run {self.runNr}"><font size="-3">OKS</font></a>\n'
787 fname =
'http://atlas.web.cern.ch/Atlas/GROUPS/DATAPREPARATION/DataSummary/runsum.py?run=%i\n' % (self.
runNr)
788 fwget = urllib.request.urlopen(fname)
792 if '</head>' in str(line)
and '<base href' not in wincontent:
793 wincontent +=
'<base href="http://atlas.web.cern.ch/Atlas/GROUPS/DATAPREPARATION/DataSummary/2010/"></base>'
794 wincontent +=
str(line)
795 wincontent = wincontent.replace(
'href="css/atlas-datasummary.css"',
'href="http://atlas.web.cern.ch/Atlas/GROUPS/DATAPREPARATION/DataSummary/css/atlas-datasummary.css"')
798 wincontent = wincontent.replace(
'<td>\n<a href="rundata/run%i/run%i_ilumr.png"><img src="rundata/run%i/run%i_ilumr.png" alt="InstLumi" style="width: 200px; "></a></td>' % (self.
runNr,self.
runNr,self.
runNr,self.
runNr),
'')
799 wincontent = wincontent.replace(
'"',
'"')
800 wincontent = wincontent.replace(
'./RunSummary/figs',
'https://atlas.web.cern.ch/Atlas/GROUPS/DATAPREPARATION/RunSummary/figs')
801 wincontent = wincontent.replace(
'<a href',
'<a target="_blank" href')
802 wincontent = wincontent.replace(
'width: 200px',
'width: 350px')
803 wincontent = wincontent.replace(
'width: 250px',
'width: 350px')
806 openwincmd =
'javascript:openLumiWindow('
807 openwincmd +=
"'Print','<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html xmlns:"my"><head><title>Luminosity information for run %i</title></head><body style="background-color:#ffffff">" % self.
runNr
808 openwincmd += wincontent
809 openwincmd +=
'</body></html>'
816 """ sor and eor is always in UTC, so sor=0 means the run started 1.1.1970 at 00:00:00"""
818 begin = time.localtime(self.
sor/1.E9)
819 end = time.localtime(self.
eor/1.E9)
821 begin = time.gmtime(self.
sor/1.E9)
822 end = time.gmtime(self.
eor/1.E9)
825 beginstr = time.strftime(
"%a %b %d %Y %X",begin)
830 endformat =
"%a %b %d, %Y %X"
831 elif end[1]>begin[1]
or end[2]>begin[2]:
832 endformat =
"%a %b %d, %X"
836 endstr = time.strftime(endformat,end)
838 endstr =
'<font color=#BB0000>ongoing</font>' if format==
'html' else 'ongoing'
842 return '%s − %s' % (beginstr,endstr)
843 elif format==
'seconds':
844 return '%12.3f, %12.3f' % (self.
sor/1.E9, self.
eor/1.E9)
845 elif format==
'secondsNum':
846 return self.
sor/1.E9, self.
eor/1.E9
848 return '%s - %s' % (beginstr,endstr)
851 dt = time.gmtime((self.
eor-self.
sor)/1.E9)[2:6]
853 return "%id %ih %im %is" % ((dt[0]-1,) + dt[1:])
855 return "%ih %im %is" % dt[1:]
876 s =
"%s (%s)" % (tr.name,pss)
880 res = {
'L1': [],
'L2': [],
'EF': [] }
881 for tr,pslist
in chainlist.items():
885 res[k] += [Run.prettyChain(tr,pslist)]
889 l1chains =
'<br> '.
join(res[
'L1'])
890 l2chains =
'<br> '.
join(res[
'L2'])
891 efchains =
'<br> '.
join(res[
'EF'])
894 ret += (l1chains.replace(
'.0',
''), )
896 ret += (l2chains.replace(
'.0',
''), )
898 ret += (efchains.replace(
'.0',
''), )
907 for lbr
in self.
data:
908 s+=
"\n" + lbr.astxt()
912 if isinstance(other,Run):
913 return self.
runNr < other.runNr
914 return self.
runNr < other
917 if isinstance(other,Run):
918 return self.
runNr == other.runNr
919 return self.
runNr == other
925 s +=
"run %*s %*s " % (_fW[
'Run']-4,self.
runNrS, _fW[
'NLB'], self.
NrLBs)
929 s +=
"%*s " % (_fW[
'Time'],self.
timestr(
'txt'))
932 dt = time.gmtime((self.
eor-self.
sor)/1.E9)[2:6]
934 s +=
"%id %ih %im %is " % ((dt[0]-1,) + dt[1:])
936 s +=
"%2ih %2im %2is " % dt[1:]
938 for k
in Run.SortedShowOrder():
942 v = self.
result[k.ResultKey]
946 elif k.Type == DataKey.STREAM:
947 w=
max(len(k.Header)-k.Header.find(
'_'),_fW[
'Stream'])
948 if isinstance(ostr,tuple):
950 elif k==
"TriggerMenu":
951 pv = [Run.prettyChain(tr,pslist)
for (tr,pslist)
in v.items()
if tr.forshow]
953 elif k==
"TriggerRates":
955 elif k==
"olc:bcidmask":
958 s +=
"%*s " % (w,ostr)
965 import CoolRunQuery.html.AtlRunQueryHtmlUtils
as HU
967 with timer(
"print runnur, runtime, etc"):
968 s =
"<!-- Run %s -->\n" % run.runNrS
971 if Run.bgcolor ==
"1":
978 if run.showDataIncomplete:
979 runrowclass=
"showmiss"
980 if run.selDataIncomplete:
981 runrowclass=
"selmiss"
984 s +=
'<tr class="out%s">\n' % (color)
988 if run.runNr == Run.runnropen:
989 s +=
' <td style="text-align:center" class="%s"><font color="#BB0000">%s<br><font size="-2">(ongoing)</font></font>' % (runrowclass, run.runNrS)
991 s +=
'<td style="text-align:center" class="%s">%s' % (runrowclass, run.runNrS)
992 p = Run.runPeriods.findPeriod( run.runNr )
996 for i
in range(p.count(
',')//2+1):
997 idx = p.find(
',',idx+1)
998 s +=
'<br><font color="#488AC7"><font size=-2><nobr>Period: %s<br>%s</nobr></font></font>' % (p[:idx],p[idx+1:])
1001 if run.runNr
in Run.PromptCalibRuns:
1002 s +=
'<br><font color="#008800"><font size="-2">(in calib loop)</font></font>'
1006 s +=
'\n <td>\n%s</td>' % run.runlinks()
1009 lbcontent =
'%s' % run.NrLBs
1011 vf =
float(run.NrLBs)
1013 lbcontent =
'%s<br><font size="-2">(%i s)</font>' % (run.NrLBs, (run.eor-run.sor)/(1.0E9*vf) )
1017 window = HU.OpenWindow( HU.CreateLBTable(run), extracss=[
'html/atlas-runquery-lb.css'] )
1020 tip =
'showTip LBStart_%i' % run.runNr
1021 s +=
'\n <!-- LB Content -->\n'
1022 s +=
' <td style="text-align: right"><div class="%s tooltip" style="display:inline;cursor:pointer">%s%s</a></div></td>\n' % (tip, window, lbcontent)
1026 s +=
' <td>%s</td>' % run.timestr(
'html',run.runNr != Run.runnropen)
1029 if Run.showduration:
1030 if run.runNr == Run.runnropen:
1031 s +=
' <td><font color="#BB0000">%s<br><font size="-2">(ongoing)</font></font></td>' % run.durationstr()
1033 s +=
" <td>%s</td>" % run.durationstr()
1037 for k
in Run.SortedShowOrder():
1038 if k.Type == DataKey.STREAM
and k.ResultKey
in run.stats
and 'calibration' not in k.ResultKey:
1039 sumstrnev += run.result[k.ResultKey][0]
1048 with timer(
"print keys"):
1049 for data_key
in Run.SortedShowOrder():
1050 k = data_key.ResultKey
1053 with timer(
"keybuild %s" % k, disabled=
True):
1054 if any([
'olc:beam2intensity' in k,
1055 'olc:beam1intensity' in k,
1056 'lhc:beamenergy' in k,
1057 'beam1bunches' in k,
1058 'beam2bunches' in k,
1070 durInSec = (run.eor-run.sor)/1.0E9
1074 rate =
'%.1f Hz' % (
float(v)/durInSec)
1077 s +=
' <td style="text-align: right">%s<BR><font size="-2">(%s)</font></td>' % (
addKommaToNumber(v),rate)
1082 if k ==
"#L1A" or k ==
'#L2A' or k ==
'#EFA' or k ==
'#Events (streamed)' or k ==
'#Events (incl. calib.)':
1089 intolerable = Run.Fieldinfo[
'DQ'][
'IntolerableDefects']
1091 for channelname
in Run.Fieldinfo[
'DQ'][
'DefChannels']:
1092 if channelname ==
'':
1093 matching_dqentries = run.stats[k][
"defects"]
1094 elif channelname ==
'DET':
1095 matching_dqentries = [dqentry
for dqentry
in run.stats[k][
"defects"]
if '_' not in dqentry[0]]
1097 from re
import compile
1098 pattern = compile(channelname)
1099 matching_dqentries = [dqentry
for dqentry
in run.stats[k][
"defects"]
if pattern.match(dqentry[0])]
1103 matching_dqentries_ready = []
1104 for (defect, listLBranges)
in matching_dqentries:
1105 readyLBRanges = [lbrange
for lbrange
in listLBranges
if run.data.isReady(lbrange)]
1106 if len(readyLBRanges)>0:
1107 matching_dqentries_ready += [ (defect, readyLBRanges) ]
1110 if len(matching_dqentries_ready)==0:
1111 dq_info =
"<table class='dqdefects' style='border-color: limegreen; height=100%'><tr><td> </td></tr></table>\n"
1113 dq_info =
"<table class='dqdefects'>\n"
1114 for defect,listLBranges
in matching_dqentries_ready:
1115 tip =
'showTip dqdefect_%i_%s tooltip' % (run.runNr, defect)
1116 if defect
in intolerable:
1117 dq_info +=
"<tr class='%s'><td class='intolerable'>%s</td><td class='lb'>" % (tip, defect)
1119 dq_info +=
"<tr class='%s tolerable' style='visibility:collapse;'><td>%s</td><td class='lb'>" % (tip, defect)
1120 dq_info +=
", ".
join([(
"%g−%g" % (x[0],x[1]-1)
if x[1]-x[0]!=1
else "%g" % x[0])
for x
in listLBranges])
1121 dq_info +=
"</td></tr>\n"
1122 dq_info +=
'<tr height="100%%"><td height="100%%"></td></tr>\n'
1123 dq_info +=
"</table>\n"
1124 s +=
'<td class="def">%s</td>' % dq_info
1133 dqmax = run.stats[k][
"max"]
1134 n = run.stats[k][
"counts"]
1136 foundComment =
False
1137 for (dq,comment), start, end
in run.stats[k][
"blocks"]:
1144 if n[dq]>0
and dq != dqmax:
1146 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)
1148 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)
1151 tip =
'showTip dqcomm_%s_%i' % (k, run.runNr)
1153 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>'
1156 s +=
'<td class="%s td tooltip td%s">%s%s</td>' % (tip,dqmax,dqmax,extraDQInfo)
1158 s +=
'<td class="td td%s">%s%s</td>' % (dqmax,dqmax,extraDQInfo)
1164 if "detector systems" in k.lower():
1166 mask =
'0x'+v
if Selector.condDB()==
'CONDBR2' else v
1168 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)
1176 hasStableBeamsInfo, xvecStb = run.getStableBeamsVector()
1179 printMu =
'olc:bcidmask' in Run.SortedShowOrder()
and run.runNr>=151260
and run.givepeakmuinfo
1185 for entry
in run.data[k]:
1186 assert entry.startlb != 0,
'entry should not start at LB=0'
1187 val = entry.value
if (entry.value!=
'n.a.' and entry.value>0)
else 0
1188 lastlb =
min(entry.lastlb,run.nr_lb)
1189 xvec +=
range(entry.startlb,lastlb+1)
1190 nlb = lastlb - entry.startlb + 1
1192 yvecInt += nlb*[val]
1195 intlumi, intlumiStb = (0, 0)
1205 if len(xvecStb) > 15:
1210 for idx,(lbtime,lbendtime)
in enumerate(run.lbtimes):
1213 yvecInt[idx] *= dt/1000.0*run.lumiunit
1214 yvec[idx] *= 1.0*run.lumiunit
1215 intlumi += yvecInt[idx]
1217 if yvec[idx] > peaklumi:
1218 peaklumi = yvec[idx]
1220 intlumiStb += yvecInt[idx]
1228 if y1 > 0
and y2 > 0:
1229 lifetime = (t2 - t1)/(3600*math.log(y1/y2))
1232 if hasStableBeamsInfo:
1233 fullprint_ =
'All LBs: %0.4g<br>Stable B: %0.4g' % (intlumi,intlumiStb)
1234 histoText =
'Integrated luminosity: %.4g %s-1 (all LBs) and %.4g %s-1 (stable beams)' % (intlumi,run.lumiunittxt,intlumiStb,run.lumiunittxt)
1236 fullprint_ =
'All LBs: %0.4g' % (intlumi)
1237 histoText =
'Integrated luminosity: %.4g %s-1 (all LBs)' % (intlumi,run.lumiunittxt)
1240 tp1, tp2, chan = k.split(
':')
1243 if chan
in OLCAlgorithms:
1244 chanstr = OLCAlgorithms[chan]
1250 path =
makeLBPlot( xvec, xvecStb, yvec,
'Luminosity block number',
'Online luminosity (10^{%s}cm^{-2}s^{-1})' % run.instlumiunittxt,
'',
1251 'olclumi_vs_lb_run_%i' % (run.runNr),
1252 'Online lumi [%s] per LB for run %i' % (chanstr, run.runNr),
1253 QC.datapath, histoText )
1256 wincontent =
'<table class="outer" style="padding: 5px"><tr><td>'
1257 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))
1258 wincontent +=
'<hr color="black" size=1>'
1259 wincontent +=
'<table style="padding: 0px"><tr><td>'
1260 wincontent +=
'<img src="%s" align="left">' % path
1261 wincontent +=
'</td></tr></table>'
1262 wincontent +=
'<hr color="black" size=1>'
1263 wincontent +=
'<table class="LB">'
1264 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)
1265 wincontent +=
'<th>Int. luminosity<br>(%s<sup>−1</sup>)</th><th>Cumul. luminosity<br>(%s<sup>−1</sup>)</th>' % (run.lumiunittxt, run.lumiunittxt)
1267 wincontent +=
'<th> <μ> </th>'
1268 if hasStableBeamsInfo:
1269 wincontent +=
'<th>Stable beams</th>'
1270 wincontent +=
'</tr><tr style="background:%s">' %
'#eeeeee'
1273 minBiasXsec = 80.0
if Selector.isRun2()
else 71.5
1275 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))
1279 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))
1283 for idx,(lbtime,lbendtime)
in enumerate(run.lbtimes):
1285 isStableBeams = (lb
in xvecStb)
1286 intlumi += yvecInt[idx]
1287 stbBeams =
'T' if isStableBeams
else '−'
1288 timetuple = time.localtime(lbtime/1.E9)
if QC.localtime
else time.gmtime(lbtime/1.E9)
1289 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)
1293 for n,v,lbstart,lbend
in run.stats[
'olc:bcidmask'][
'blocks']:
1294 if lb >= lbstart
and lb <= lbend:
1299 lumi_mb = yvec[idx]*1000.0
1302 mu = lumi_mb * minBiasXsec / 11245.511 / nb
1303 wincontent +=
'<td>%.3g</td>' % mu
1304 if isStableBeams
and mu > mumax:
1306 if hasStableBeamsInfo:
1307 wincontent +=
'<td>%s</td>' % stbBeams
1312 wincontent +=
'</tr><tr style="background:%s">' % col
1314 printMuInfoToFile =
True
1315 if printMuInfoToFile:
1316 mutextfilename = QC.datapath +
'/mu_vs_run_output.txt'
1317 muout =
open( mutextfilename,
'a' )
1318 muout.write(
'%10i %f\n' % (run.runNr, mumax) )
1324 s_mumax =
"%0.3e" % mumax
1326 s_mumax =
"%0.3f" % mumax
1328 if run.runNr == Run.runnropen:
1329 wincontent +=
'<tr><td style="text-align:left"colspan="3"><i> Run still ongoing ...</i></td></tr>'
1330 wincontent +=
'</tr></table>'
1332 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())
1333 wincontent +=
'</td></tr></table>'
1335 openwincmd =
'<a href="javascript:openLargeWindow('
1336 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%%">"
1337 openwincmd += wincontent
1338 openwincmd +=
"')\">"
1341 fullprint =
'<table class="bcidtable">'
1342 fullprint +=
'<tr><td colspan="2"><img src="%s" align="left" width="90px"></td></tr>' % path
1343 if hasStableBeamsInfo:
1344 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)
1346 fullprint +=
'<tr><td style="text-align:left">Approx. lifetime:</td><td style="text-align:left"> %0.2g h</td></tr>' % (lifetime)
1348 fullprint +=
'<td style="text-align:left">All LBs:</td><td style="text-align:left"> %0.4g</td></tr>' % (intlumi)
1349 fullprint +=
'</table>'
1352 s +=
'<td class="showTip OLCLumi stream" style="text-decoration:none; text-align: right">%s%s</a></td>' % (openwincmd, fullprint)
1358 if 'olc:bcidmask' in k:
1360 firstGoodRun = 151260
1361 if run.runNr < firstGoodRun:
1362 s +=
'<td style="text-align:center;color:#AA0000;font-size:60%%;">BCID information only available for run numbers larger than %i</font></td>' % firstGoodRun
1366 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>'
1368 wincontent =
'<table class="outer" style="padding: 5px"><tr><td>'
1369 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))
1370 wincontent +=
'<hr color="black" size=1>'
1371 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>')
1375 hasStableBeamsInfo, xvecStb = run.getStableBeamsVector()
1378 for n,v,lbstart,lbend
in run.stats[k][
'blocks']:
1380 cls =
'tr1' if (ic%2==1)
else 'tr2'
1383 isInStableBeamPeriod =
False
1384 stableBeamWord =
'−'
1385 if hasStableBeamsInfo:
1386 if lbstart <= xvecStb[-1]
and lbend >= xvecStb[0]:
1387 isInStableBeamPeriod =
True
1388 stableBeamWord =
'<b>T</b>'
1390 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)
1392 beam1, beam2, beam12 = v
1393 unpaired1 = [b
for b
in beam1
if b
not in beam12]
1394 unpaired2 = [b
for b
in beam2
if b
not in beam12]
1396 noBunches =
not unpaired1
and not unpaired2
and not beam12
1398 unpaired1 = [
'−']
1400 unpaired2 = [
'−']
1402 beam12 = [
'−']
1405 if isInStableBeamPeriod
and first
and not noBunches:
1408 maxBunchDistanceInTrain = 6
1409 if int(run.runNr) > 168665:
1410 maxBunchDistanceInTrain = 25
1414 if bp > 0
and b - bp <= maxBunchDistanceInTrain:
1415 if trains[-1][-1] != bp:
1418 elif len(beam12) > 1
and bp <= 0
and beam12[0] - b <= maxBunchDistanceInTrain:
1422 fullprint =
'<table class = "triggerlinktable">'
1423 fullprint +=
'<tr><td style="text-align:left"><nobr>No. of coll. bunches: </nobr></td><td> <b>%i</b></td></tr>' % len(beam12)
1424 fullprint +=
'<tr><td style="text-align:left"><nobr>No. of bunch trains:</nobr></td><td><b> %i</b></td></tr>' % len(trains)
1426 Run.TmpBoxContent =
'<strong><b><nobr>Bunch train configuration for run <font color="#AA0000">%i</font></nobr></b></strong>' % run.runNr
1427 Run.TmpBoxContent +=
'<hr size=1>'
1434 if len(trains[icoor]) > 1:
1435 bunchDist = trains[icoor][1] - trains[icoor][0]
1436 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)
1439 if len(trains[0]) == 1:
1440 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>'
1441 fullprint +=
'</table><hr size=1>'
1442 Run.TmpBoxContent +=
'<table><tr><td>Train</td><td><nobr>No. of bunches</nobr></td><td style="text-align:right"> BCID range</td></tr>'
1443 for it, train
in enumerate(trains):
1444 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])
1445 Run.TmpBoxContent +=
'</table><hr size=1>'
1447 Run.TmpBoxContent =
'<nobr>No bunch trains in this run</nobr> <hr size=1>'
1448 fullprint +=
'</table><hr size=1>'
1449 Run.TmpBoxContent +=
'<p><font color="#AA0000"><b><nobr>Click to obtain full list of BCIDs</nobr></b></font>'
1450 fullprint +=
'<span style="font-size: xx-small; color: #555555">[ <i>Mouse over for train configuration. Click for full list of BCIDs</i> ]</span>'
1452 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)) )
1454 wincontent +=
'<td class="td1" style="text-align:right">%s</td><td style="text-align:right">%s</td><td style="text-align:right">%s</td>' % (
'−',
'−',
'−')
1456 wincontent +=
'</tr>'
1459 wincontent +=
'</table></td>'
1460 wincontent +=
'</td></tr></table>'
1463 openwincmd = HU.OpenWindow(wincontent, title=
"Run query result for online luminosity", extracss=
None, size=
"large")
1469 s +=
'<td class="showTip OLCBCID_%i stream" style="text-decoration:none; text-align: left">%s%s</a></td>' % (run.runNr, openwincmd, fullprint)
1475 if k.startswith(
'bs:Pos')
or k.startswith(
'bs:Sig')
or k.startswith(
'bs:Tilt'):
1479 statkey =
'bs:Status'
1481 onloffltype =
'Online' if (run.stats[
'Beamspot']==
'online')
else 'Offline'
1494 for entry
in run.data[k]:
1495 if entry.startlb==0
and entry.lastlb==0:
1498 val,valerr = entry.value
1499 ref = run.data[refkey].atLB(entry.startlb)[0].value[0]
1500 stat = run.data[statkey].atLB(entry.startlb)[0].value
1502 lastlb =
min(entry.lastlb,run.lastlb)
1503 lbs =
range(entry.startlb,lastlb+1)
1507 yvec += [(val,valerr)]
1509 bsidx += [idx] * nlb
1515 eave += nlb * val**2
1520 s +=
'<td>n.a.</td>'
1525 rad = eave/iave - vave*vave
1527 eave = math.sqrt(rad)
1533 ymin = vave - 3*eave
1534 ymax = vave + 3*eave
1544 delta = 0.1*abs(ymax)
1546 delta = 0.1*(ymax-ymin)
1556 bstype += k[k.find(
'-'):]
1558 histoText =
'Average beam spot %s: (%.4g +- %.1g) mm' % (bstype, vave, eave)
1561 xtitle =
'Luminosity block number', ytitle =
'%s beamspot %s (mm)' % (onloffltype, bstype),
1562 histname =
'%s_vs_lb_run_%i' % (k.replace(
':',
'_').
replace(
'-',
'_'), run.runNr),
1563 histtitle =
'%s beamspot %s per LB for run %i' % (onloffltype, bstype, run.runNr),
1564 datapath = QC.datapath, ymin = ymin, ymax = ymax, printText = histoText )
1568 wincontent =
'<table class="outer" style="padding: 5px"><tr><td>'
1569 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))
1570 wincontent +=
'<table style="padding: 0px"><tr><td>'
1571 wincontent +=
'<img src="%s" align="left">' % (path)
1572 wincontent +=
'</td></tr></table>'
1573 wincontent +=
'<hr color="black" size=1>'
1575 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; ">'
1576 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)
1577 wincontent +=
'</tr><tr style="background:%s">' %
'#eeeeee'
1578 for idx,(lbtime,lbendtime)
in enumerate(run.lbtimes):
1580 timetuple = time.localtime(lbtime/1.E9)
if QC.localtime
else time.gmtime(lbtime/1.E9)
1581 wincontent +=
'<td style="text-align:right"> %s</td>' % lb
1582 wincontent +=
'<td style="text-align:right"> %s</td>' % time.strftime(
"%X",timetuple)
1583 wincontent +=
'<td style="text-align:right">%.2f</td>' % ((
float(lbendtime)-
float(lbtime))/1.E9)
1584 wincontent +=
'<td style="text-align:right">%.4g ± %.2g</td>' % yvec[bsidx[idx]]
1585 wincontent +=
'<td style="text-align:right">%i</td>' % yvecSt[bsidx[idx]]
1591 wincontent +=
'</tr><tr style="background:%s">' % col
1592 if run.runNr == Run.runnropen:
1593 wincontent +=
'<tr><td style="text-align:left"colspan="3"><i> Run still ongoing ...</i></td></tr>'
1594 wincontent +=
'</tr></table>'
1596 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())
1597 wincontent +=
'</td></tr></table>'
1599 openwincmd =
'<a href="javascript:openWindow('
1600 openwincmd +=
"'Print','<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">"
1601 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())
1602 openwincmd +=
"<body><table style="font-family: sans-serif; font-size: 85%">"
1603 openwincmd += wincontent
1604 openwincmd +=
"</table></body></html>"
1605 openwincmd +=
"')\">"
1608 fullprint =
'<table class="triggerlinktable">'
1609 fullprint +=
'<tr><td colspan="2"><img src="%s" align="left" width="90px"></td></tr>' % path
1610 fullprint +=
'<tr><td colspan="2"></td></tr>'
1612 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)
1613 fullprint +=
'</table>'
1616 s +=
'<td class="showTip OFLBS stream" style="text-decoration:none; text-align: right">%s%s</a></td>' % (openwincmd, fullprint)
1621 if "STR:" == k[0:4]:
1624 s +=
'<td class="tdna">n.a.</td>'
1628 durInSec = (run.eor-run.sor)/1.0E9
1629 rate =
'n.a. Hz'
1632 rate =
'%.3f Hz' % (v[0]/durInSec)
1639 if 'calibration' not in k:
1640 fracstr =
'%.1f%%,' % (
float(strevents)/sumstrnev*100)
1656 lbrecinfo = run.stats[k][
'LBRecInfo']
1658 isPhysicsStream = lbrecinfo
is not None and len(lbrecinfo)>0
1660 ev = dict(lbrecinfo)
1663 for lb,nev
in lbrecinfo:
1665 for idx,(lbtime,lbendtime)
in enumerate(run.lbtimes):
1676 yvecR[-1] = nev/((
float(lbendtime)-
float(lbtime))/1.E9)
1682 hasStableBeamsInfo, xvecStb = run.getStableBeamsVector()
1685 wincontent =
'<table class="outer" style="padding: 5px">'
1686 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))
1689 pathN =
makeLBPlot( xvec, xvecStb, yvecN,
'Luminosity block number',
'Number of events / LB',
'',
1690 'nev_vs_lb_str_%s_run_%i' % (streamName, run.runNr),
1691 'N events per LB in stream "%s", run %i' % (streamName, run.runNr),
1692 QC.datapath,
'Total number of events: %i' % nevtot )
1693 pathR =
makeLBPlot( xvec, xvecStb, yvecR,
'Luminosity block numer',
'Event rate [Hz] / LB',
'',
1694 'rate_vs_lb_str_%s_run_%i' % (streamName, run.runNr),
1695 'Event rate per LB in stream "%s", run %i' % (streamName, run.runNr),
1697 wincontent +=
'<table style="padding: 0px">\n<tr><td>'
1698 wincontent +=
'<img src="%s" width="350">' % pathN.split(
'/')[-1]
1699 wincontent +=
'</td><td>'
1700 wincontent +=
'<img src="%s" width="350">' % pathR.split(
'/')[-1]
1701 wincontent +=
'</td></tr></table>\n'
1702 wincontent +=
'<hr color="black" size=1>\n'
1703 wincontent +=
'<table class="lb">\n'
1704 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()
1705 if hasStableBeamsInfo:
1706 wincontent +=
'<th>Stable beams</th>'
1707 wincontent +=
'</tr>\n<tr style="background:%s">' %
'#eeeeee'
1709 for idx,(lbtime,lbendtime)
in enumerate(run.lbtimes):
1715 stbBeams =
'−'
1717 averate += yvecR[idx]
1718 if yvecR[idx] > maxrate:
1719 maxrate = yvecR[idx]
1724 timetuple = time.localtime(lbtime/1.E9)
if QC.localtime
else time.gmtime(lbtime/1.E9)
1725 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])
1726 if hasStableBeamsInfo:
1727 wincontent +=
'<td>%s</td>' % stbBeams
1732 wincontent +=
'</tr>\n<tr style="background:%s">' % col
1736 averate /=
float(nc)
1738 if run.runNr == Run.runnropen:
1739 wincontent +=
'<tr><td style="text-align:left"colspan="3"><i> Run still ongoing ...</i></td></tr>\n'
1740 wincontent +=
'</tr></table>\n'
1741 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())
1742 wincontent +=
'</td></tr></table>'
1747 tooltipkey =
"STROV_%i_%s" % (run.runNr, streamName)
1749 physStrOnlyInfo =
""
1751 maxrate =
'max: %.2f Hz' % (maxrate)
1752 averate =
'ave: %.2f Hz' % (averate)
1753 physStrOnlyInfo =
"%s,<br>%s,<br>%s, " % (maxrate, averate, fracstr)
1756 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())
1757 evtsize =
',<br>%s/evt' %
filesize(
float(strsize)/
float(strevents))
if (strevents>0)
else ""
1758 tdcontent =
'%s <BR><font size="-2">(%s%s/run%s%s)' % (
addKommaToNumber(strevents), physStrOnlyInfo,
filesize(strsize), evtsize, debugStrLink)
1761 tdcontent =
'<div class="showTip %s stream" style="display:inline;cursor:pointer">%s</div>' % (tooltipkey, tdcontent)
1765 filename = HU.CreatePopupHtmlPage(
'streamov_%i_%s' % (run.runNr, streamName), HU.WrapIntoHTML(wincontent, title=
"%s Stream Content" % streamName) )
1766 tdcontent =
'<a class="externalWindow" style="text-decoration:none" href="%s">%s</a>' % (filename, tdcontent)
1768 s +=
'<td style="text-decoration:none">%s</td>' % (tdcontent)
1774 if k==
"TriggerMenu":
1775 chains = run.splitTriggerChains(v)
1778 elif len(chains)==1:
1779 s +=
'<td style="min-width:300px"><font size="-2">%s</font></td>' % ( chains )
1780 elif len(chains)==2:
1781 s +=
'<td style="min-width:300px"><font size="-2">%s<hr color="gray" size=1>%s</font></td>' % ( chains )
1783 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 )
1788 if k==
"TriggerRates":
1790 s +=
'<td>%s</td>'%v
1793 triggergroups,imgpaths,openwincmds = HU.createRatePopupWindow(v,run)
1794 for idx,(trgroup,imgpath,openwincmd)
in enumerate(zip(triggergroups,imgpaths,openwincmds)):
1795 tooltipkey =
"TrRate_Set%i_%i" % (idx,run.runNr)
1796 contentpage =
"%s/popupContent_trRates_%i_%i.html" % (QC.datapath, run.runNr, idx)
1799 tablecontent +=
' <tr><td colspan="2"><hr color="gray"></td></tr>'
1800 imgcontent =
'<img src="%s" align="center" width="90px"><br>' % imgpath
1801 imagerow =
'<div class="showTip %s ratespopup" id="%s" style="display:inline;cursor:pointer;font-size:80%%;">%s</div>' % (tooltipkey, contentpage, imgcontent)
1802 tablecontent +=
' <tr><td colspan="2" >%s</td></tr>' % imagerow
1803 for tr,avr
in trgroup:
1804 tablecontent +=
' <tr><td>%s</td><td>: %3.1f Hz</td></tr>' % (tr,avr)
1805 s+=
"<td><table class='ratestable'>\n%s\n </table></td>" % tablecontent
1812 streamtypes = [
'physics_',
'express_',
'calibration_',
'debug_',
'debugrec_']
1813 steptypes = [
'.daq.',
'.recon.',
'.merge.',
'other',
'Reproc' ]
1814 datatypes = [
'.RAW',
'.DRAW',
'.ESD.',
'.DESD',
'.AOD.',
'.TAG.',
'.TAG_COMM.',
'.HIST.',
'.NTUP',
'other']
1815 vetotypes = [
'_TMP']
1819 s +=
'<table class="datasettable">'
1823 for stype
in streamtypes:
1824 for step
in steptypes:
1825 for dtype
in datatypes:
1828 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:
1830 for veto
in vetotypes:
1837 st += [
' %s' % (
filesize(ds[5]))]
1839 st += [
' unkn. evts ']
1841 st += [
' %s evts ' % (
prettyNumber(ds[6]))]
1842 selectedds[ds[0]] = st
1844 if 'replicate:done' in ds[2]:
1845 selectedds[ds[0]] += [
True]
1847 selectedds[ds[0]] += [
False]
1849 selectedds[ds[0]] += [
True]
1851 selectedds[ds[0]] += [
False]
1852 selectedds[ds[0]] += [ds[7]]
1853 shownlist.append(ds[0])
1857 dsnames = selectedds.keys()
1862 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)
1863 for dsname
in dsnames:
1865 dsnspl = dsname.split(
'.')
1866 lk =
"https://ami.in2p3.fr/AMI/servlet/net.hep.atlas.Database.Bookkeeping.AMI.Servlet.Command?Converter=/AMIXmlToAMIProdHtml.xsl&Command=FormBrowseDatasetPerParameter+-runNumber%3D"
1872 s +=
'<a href="https://ami.in2p3.fr/AMI/servlet/net.hep.atlas.Database.Bookkeeping.AMI.Servlet.Command?Converter=/AMIXmlToAMIProdHtml.xsl&Command=FormBrowseDatasetPerParameter+-runNumber%3D'
1873 s += runNum +
"+-dataType=" + format +
"+-projectName=" + project +
"+-streamName=" + stream
1874 s +=
'" target="_blank" title="AMI dataset information">'
1875 s += dsname +
'</td>'
1876 res = selectedds[dsname]
1877 s +=
'<td style="text-align:right"><font color="#005500"> [</font></td>'
1879 s +=
'<td style="text-align:right"><font color="#005500">%s</font></td>' % st
1880 s +=
'<td style="text-align:right"><font color="#005500">]</font></td>'
1882 if Run.showCAFLinks:
1883 s +=
'<td><a href="javascript:openPageWindow('
1884 s +=
"'data/%s.html','%s')" % (dsname,dsname)
1885 s +=
'"title="Check which files of this dataset are available on ATLCAL disk pool">'
1886 s +=
'<font color="#BB0517"> [ on CAF ]</font></a></td>'
1889 deltat = (datetime.datetime.utcnow() - res[5])
1890 deltat = deltat.days*24.*3600. + deltat.seconds
1891 allcafdsnames += dsname +
'@' +
'%g' % deltat +
','
1893 s +=
'<td><font color="#BB0517"> [ on CAF ]</font></td>'
1897 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 +
'">'
1898 s +=
'<td>%s<font color="#153EBB"> [ in DDM ]</font></a></td>' % lk
1903 if dtype != datatypes[-1]:
1904 hrline =
'<tr><td colspan="8"><hr style="width:100%; background-color: #BBBBBB; height:1px; margin-left:0; border:0"/></td>'
1908 if step != steptypes[-1]:
1909 hrline =
'<tr><td colspan="8"><hr style="width:100%; background-color: #666666; height:2px; margin-left:0; border:0"/></td>'
1910 if stype != streamtypes[-1]:
1911 hrline =
'<tr><td colspan="8"><hr style="width:100%; background-color: #6D7B8D; height:3px; margin-left:0; border:0"/></td>'
1915 if 'TMP.' not in ds[0]
and ds[0]
not in shownlist:
1916 s_ +=
'<tr><td colspan=8>' + ds[0] +
'</td></tr>'
1918 s +=
'<tr><td colspan="8"><hr style="width:100%; background-color: #EE0000; height:3px; margin-left:0; border:0"/></td>'
1919 s +=
'<tr><td colspan=8><font color="#EE0000"><i>Remaining, unassigned datasets:</i></font></td></tr>'
1928 subprocess.Popen(
'python subproc.py caf %s' % (allcafdsnames[:-1]), shell=
True)
1936 linklist = run.stats[
'PSK'][
'blocks']
1938 '<a href="https://atlas-trigconf.cern.ch/run/smkey/{smk}/l1key/{l1psk}/hltkey/{hltpsk}/" target="_blank" '
1939 'title="L1: \'{l1name}\', HLT \'{hltname}\'. '
1940 'You can obtain the full trigger menu corresponding to SMK={smk} and prescale keys L1={l1psk}, HLT={hltpsk} in an independent window"'
1941 '>{l1psk} | {hltpsk}</a>'
1944 '<a href="https://atlas-triggertool.web.cern.ch/db/{db}/smk/{smk}/l1psk/{l1psk}/" target="_blank" '
1945 'title="L1: \'{l1name}\'. You can obtain the full trigger menu corresponding to SMK={smk} and L1 prescale key {l1psk} in an independent window"'
1949 '<a href="https://atlas-triggertool.web.cern.ch/db/{db}/smk/{smk}/hltpsk/{hltpsk}/" target="_blank" '
1950 'title="HLT: \'{hltname}\'. You can obtain the full trigger menu corresponding to SMK={smk} and HLT prescale key {l1psk} in an independent window"'
1954 if len(linklist)<=15:
1956 elif len(linklist)<=30:
1960 if len(linklist)<=15:
1961 nrow = len(linklist)
1962 elif len(linklist)<=45:
1965 nrow = (len(linklist)+2)//3
1967 s +=
'<td align="center"><table class="triggerlinktable" align="center">'
1969 for x
in range(ncol):
1970 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>'
1973 for row
in range(nrow):
1975 for col
in range(ncol):
1976 entry = row + col*nrow
1977 if entry>=len(linklist):
1979 link = dict(zip( (
"startlb",
"endlb",
"l1psk",
"hltpsk",
"l1name",
"hltname"),linklist[entry]))
1981 "smk" : run.result[
"SMK"],
1982 "db" :
"dev1_i8" if int(run.result[
"SMK"]) < 3000
else "run3"
1984 s += f
'<td style="padding-left: 0.8em">{link["startlb"]}</td><td>−</td><td>{link["endlb"]}: </td>'
1986 cellContent = linkRun12.format(**link)
1988 cellContent = linkRun3L1.format(**link) +
" | " + linkRun3HLT.format(**link)
1989 s += f
'<td style="border-right: 1px solid gray; padding-right: 0.8em">{cellContent}</td>'
1992 s +=
'<hr style="width:100%; background-color: #AAAABB; height:1px; margin-left:0; border:0"/>'
1993 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
1996 s +=
'<td style="text-align:center">n.a.</td>'
2003 smk =
int(run.result[
"SMK"])
2004 bgskOffset = 10000
if (smk<3000
and run.lhcRun==3)
else 0
2006 if len(run.stats[
'BGS Key' ][
'blocks'])>0:
2007 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>'
2008 for bgskey, lbbeg, lbend
in run.stats[
'BGS Key' ][
'blocks']:
2009 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)
2011 f
' <a href="https://atlas-trigconf.cern.ch/bunchgroups?key={bgskey+bgskOffset}" target="_blank" '
2012 f
'title="Obtain bunch group description for BGS Key={bgskey} in independent window"'
2015 s += f
'<td>{cellContent}</td></tr>'
2019 s +=
'<td style="text-align:center">n.a.</td>'
2021 s +=
'<td class="tdna">n.a.</td>'
2028 s +=
'<td class="tdna">n.a.</td>'
2030 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']
2031 s +=
'<td style="text-align: center;">%s<br>%s</td>' % (v,namecomment)
2036 if 'lar:runtype' in k
or 'lar:format' in k:
2039 s +=
'<td style="text-align: center">%s<br><font size="-2">(%s)</font></td>' % (v,info[
int(v)])
2042 s +=
'<td class="tdna">n.a.</td>'
2044 s +=
'<td style="text-align: right">%s</td>' % v
2052 fullprint =
'<table class="triggerlinktable" align="center">'
2059 toffset =
int(run.sor/1.E9)
2060 deltat =
int(run.eor/1.E9) -
int(run.sor/1.E9)
2064 for idx,(lbtime,lbendtime)
in enumerate(run.lbtimes):
2066 xveclb.append( [lbtime/1.E9-toffset, (
float(lbendtime)-
float(lbtime))/1.E9] )
2071 for ik,key
in enumerate(keys):
2076 for (val,dte)
in v[key]:
2080 ts = time.strptime( dte[:dte.rfind(
':')] +
'/UTC',
'%d-%m-%Y %H:%M:%S/%Z' )
2081 tsec =
int(calendar.timegm(ts))
2082 xvec[-1].
append(tsec - toffset)
2088 arg = y2/
float(ic) - y*y
2093 ymin =
min(ymin,y - 1.5*y2)
2094 ymax =
max(ymax,y + 1.5*y2)
2098 if 'B1' in key
and 'hori' in key:
2099 vname =
'B1 horiz. IP'
2100 lname =
'B1 horizont IP pos.'
2101 elif 'B1' in key
and 'vert' in key:
2102 vname =
'B1 vert. IP'
2103 lname =
'B1 vertical IP pos.'
2104 elif 'B2' in key
and 'hori' in key:
2105 vname =
'B2 horiz. IP'
2106 lname =
'B2 horizontal IP pos.'
2107 elif 'B2' in key
and 'vert' in key:
2108 vname =
'B2 vert. IP'
2109 lname =
'B2 vertical IP pos.'
2110 legend.append( lname )
2111 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)
2114 fullprint +=
'<td rowspan="4">REPLACEME</td>'
2115 fullprint +=
'</tr>'
2118 bpmrootfilename = QC.datapath +
'/bpm_output_run%i.root' % run.runNr
2119 SaveGraphsToFile( bpmrootfilename, keys, xvec, yvec,
"TimeOffset", toffset )
2121 bpmtextfilename = QC.datapath +
'/bpm_output_run%i.txt' % run.runNr
2122 bpmout =
open( bpmtextfilename,
'w' )
2124 bpmout.write(
'# BPM Output for run %i\n' % run.runNr )
2125 bpmout.write(
'# Start - end of run: %s [UTC]\n' % run.timestr(
'txt') )
2126 bpmout.write(
'# Time offset applied below in seconds: %i\n' %
int(toffset) )
2127 bpmout.write(
'#\n' )
2128 bpmout.write(
'# ---------------------------------------------------------------------------------\n' )
2129 for ik,key
in enumerate(keys):
2130 bpmout.write(
'# Output for variable: "%s"\n' % key )
2131 bpmout.write(
'# Format: index / timestamp (seconds) wrt. begin of run / BPM position in microns\n' )
2132 bpmout.write(
'#\n' )
2133 for i
in range(len(xvec[ik])):
2134 bpmout.write(
"%4i %9.2f %14.6f\n" % (i, xvec[ik][i], yvec[ik][i]) )
2135 bpmout.write(
'#\n' )
2136 bpmout.write(
'# ---------------------------------------------------------------------------------\n' )
2139 fullprint +=
'<tr><td colspan=8><hr style="width:100%; background-color:#999999; height:1px; margin-left:0; border:0"/></td></tr>'
2140 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)
2141 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)
2142 fullprint +=
'</table>'
2146 'Time of day (UTC)',
'Beam position (microns)', legend,
2147 'bp_vs_time_run_%i' % (run.runNr),
2148 'Beam position versus time of day for run %i' % (run.runNr),
2151 replacetxt =
'<img src="%s" align="left" width="70px">' % path
2152 fullprint = fullprint.replace(
'REPLACEME',replacetxt)
2155 wincontent =
'<table class="outer" style="padding: 5px"><tr><td>'
2156 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))
2157 wincontent +=
'<table style="padding: 0px"><tr><td>'
2158 wincontent +=
'<img src="%s" align="left"></td>' % path
2159 wincontent +=
'</td></tr></table>'
2160 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())
2161 wincontent +=
'</td></tr></table>'
2164 openwincmd = HU.OpenWindow(wincontent,title=
"Summary of LHC information")
2167 s +=
'<td style="text-decoration:none">%s<div class="showTip BPM stream" style="display:inline;cursor:pointer">%s</div></a></td>' % (tooltipkey, fullprint)
2179 hasStableBeamsInfo, xvecStb = run.getStableBeamsVector()
2185 for kp
in Run.ShowOrder:
2186 if 'ofllumi:' in kp.ResultKey:
2187 name, chanstr, tagstr = kp.ResultKey.split(
':')
2189 chans.append(chanstr)
2196 if ich
in OLCAlgorithms:
2197 chanstr.append(OLCAlgorithms[ich])
2199 chanstr.append(
'Unknown')
2207 for ikp,kp
in enumerate(kref):
2211 intlumiStb.append(0)
2212 for entry
in run.data[kp]:
2213 if entry.startlb == 0:
2215 val = entry.value
if entry.value!=
'n.a.' and entry.value>0
else 0
2216 lastlb =
min(entry.lastlb,run.lastlb)
2217 lbs =
range(entry.startlb,lastlb+1)
2220 yvec[-1] += len(lbs)*[
float(val)]
2223 for idx,(lbtime,lbendtime)
in enumerate(run.lbtimes):
2226 for ich
in range(len(chans)):
2228 intlumi[ich] += tmp[idx]*dt/1000.0
2230 intlumiStb[ich] += yvec[ich][idx]*dt/1000.0
2232 yvec[ich][idx] *= 1.0
2233 if yvec[ich][idx] > peaklumi[ich]:
2234 peaklumi[ich] = yvec[ich][idx]
2238 if hasStableBeamsInfo:
2239 for ich,ch
in enumerate(chans):
2240 fullprint_ +=
'Integrated (channel: %s): %0.4g<br>Stable B: %0.4g<br>' % (ch,intlumi[ich],intlumiStb[ich])
2241 histoText =
'Integr. lumi (channel: %i): %.4g nb-1 (all LBs) and %.4g nb-1 (stable beams)' % (0, intlumi[0],intlumiStb[0])
2243 for ich,ch
in enumerate(chans):
2244 fullprint_ +=
'Integrated (channel: %s): %0.4g<br>' % (ch,intlumi[ich])
2245 histoText =
'Integr. lumi (channel: %i): %.4g nb-1 (all LBs)' % (0, intlumi[0])
2249 'Luminosity block number',
'Offline luminosity (10^{30}cm^{-2}s^{-1})', chanstr,
2250 'ofllumi%s_vs_lb_run_%i' % (chans[0],run.runNr),
2251 'Offline lumi per LB for run %i' % (run.runNr),
2252 QC.datapath, histoText )
2255 wincontent =
'<table class="outer" style="padding: 5px"><tr><td>'
2256 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))
2257 wincontent +=
'<hr color="black" size=1>'
2258 wincontent +=
'<table style="padding: 0px"><tr><td>'
2259 wincontent +=
'<img src="%s" align="left">' % path
2260 wincontent +=
'</td></tr></table>'
2261 wincontent +=
'<hr color="black" size=1>'
2262 wincontent +=
'<table class="LB">'
2263 wincontent +=
'<tr><th>LB</th><th>Start time<br> (%s)</th><th>Duration<br>(sec)</th>' % QC.tzdesc()
2265 wincontent +=
'<th>Inst. luminosity<br>(1e%s cm<sup>−2</sup>s<sup>−1</sup>)<br>[ %s ]</th>' % (run.instlumiunittxt,ch)
2266 wincontent +=
'<th>Stable beams</th>'
2267 wincontent +=
'</tr><tr style="background:%s">' %
'#eeeeee'
2268 for idx,(lbtime,lbendtime)
in enumerate(run.lbtimes):
2270 stbBeams =
'−'
2273 timetuple = time.localtime(lbtime/1.E9)
if QC.localtime
else time.gmtime(lbtime/1.E9)
2274 wincontent +=
'<td>%i</td><td>%s</td><td>%.2f</td>' % (lb, time.strftime(
"%X",timetuple), (
float(lbendtime)-
float(lbtime))/1.E9)
2275 for ich
in range(len(chans)):
2276 wincontent +=
'<td>%.4g</td>' % (yvec[ich][idx])
2277 wincontent +=
'<td>%s</td>' % stbBeams
2282 wincontent +=
'</tr><tr style="background:%s">' % col
2283 if run.runNr == Run.runnropen:
2284 wincontent +=
'<tr><td style="text-align:left"colspan="3"><i> Run still ongoing ...</i></td></tr>'
2285 wincontent +=
'</tr></table>'
2286 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())
2287 wincontent +=
'</td></tr></table>'
2289 openwincmd = HU.OpenWindow(wincontent,title=
"Run query result for online luminosity")
2292 fullprint =
'<table class="bcidtable">'
2293 fullprint +=
'<tr><td colspan="2"><img src="%s" align="left" width="90px"></td></tr>' % path
2294 if hasStableBeamsInfo:
2295 for ich
in range(len(chans)):
2296 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)
2298 for ich
in range(len(chans)):
2299 fullprint +=
'<td style="text-align:left">All LBs:</td><td style="text-align:left"> %0.4g</td></tr>' % (intlumi[ich])
2300 fullprint +=
'</table>'
2303 s +=
'<td class="showTip OFLLumi stream" style="text-decoration:none; text-align: right">%s%s</a></td>' % (openwincmd, fullprint)
2308 if any( [ (
'lhc:' in k
and 'beamenergy' not in k),
2309 (
'TorCurrent' in k),
2310 (
'SolCurrent' in k),
2312 (
'Ready for physics' in k),
2318 for entry
in run.data[k]:
2319 if entry.startlb == 0:
2325 if 'bs:' not in k
and 'ofllumi:' not in k
and 'beam1intensity' not in k
and 'beam2intensity' not in k:
2331 if 'beamenergy' in k
and val>=7864:
2334 if not keys
or res[-1] != val:
2336 keys[-1][1] = entry.startlb
2338 keys.append( [entry.startlb, entry.endlb] )
2339 elif res[-1] == val:
2340 keys[-1][1] = entry.endlb
2344 s +=
'<td><table class="triggerlinktable" align="center">'
2345 for i, c
in enumerate(keys):
2346 if int(c[0]) !=
int(c[1])-1:
2347 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)
2349 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]))
2352 if 'bs:' in k
or 'beam1intensity' in k
or 'beam2intensity' in k:
2353 vt =
'%.4g' % abs(val)
2357 vt = vt.replace(
'e-',
'e−')
2358 s +=
'<td style="text-align:right">%s</td></tr>' % vt
2359 elif 'ofllumi:' in k:
2360 s +=
'<td style="text-align:right">%g</td></tr>' % val
2362 s +=
'<td style="text-align:right">%i</td></tr>' %
round(val)
2364 s +=
'<td style="text-align:left">%s</td></tr>' % res[i].strip()
2365 s +=
'</table></td>'
2370 vt =
'%.4g' % abs(
float(v))
2376 v = v.replace(
'e-',
'e−')
2379 if 'beamenergy' in k
and v >= 7864:
2385 s +=
'<td style="text-align:center;font-size: 85%%">%s</td>' % v
2388 if (
'lhc:stablebeams' in k
and 'lhc:beamenergy' in Run.ShowOrder
and 'lhc:beammode' not in Run.ShowOrder)
or 'lhc:beammode' in k:
2389 imgpath, xvec, yvec, ymax = HU.makeSummaryPlotForLHC(run)
2390 wincontent = HU.makeSummaryPageForLHC(run, yvec, imgpath)
2391 openwincmd = HU.OpenWindow(wincontent,
'Summary of LHC information')
2392 fullprint =
'<table class="bcidtable">'
2393 fullprint +=
'<tr><td><img src="%s" align="left" width="90px"></td></tr>' % imgpath
2394 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])
2395 fullprint +=
'<tr><td style="text-align:left">Maximum beam energy:<br>%i GeV</td></tr>' %
int(ymax[2])
2396 fullprint +=
'</table>'
2397 fullprint +=
'<span style="font-size: xx-small; color: #555555">[ <i>Numbers given for stable beam period (if applies)</i> ]</span>'
2399 s +=
'<td class="showTip LHCSummary stream" style="text-decoration:none; text-align: left">%s %s </a></td>' % (openwincmd, fullprint)
2407 s +=
'<td class="tdna">n.a.</td>'
2409 s +=
'<td style="text-align: right">%s</td>' % v
2421 with timer(
"Tooltips"):
2429 import CoolRunQuery.html.AtlRunQueryHtmlUtils
as HU
2431 HU.CreateLBTooltip(run)
2434 if 'DQ' in Run.ShowOrder:
2435 HU.CreateDQTooltip(run)
2438 for k
in [k
for k
in Run.ShowOrder
if k.Type==DataKey.STREAM
and k.ResultKey
in run.stats]:
2439 HU.CreateStreamOverlapTooltip(run, k)
2442 for data_key
in Run.ShowOrder:
2443 k = data_key.ResultKey
2446 if k
not in run.stats:
2449 for (dq,comment), start, end
in run.stats[k][
"blocks"]:
2452 comment =
'no comment'
2461 commentbox +=
'<tr style="color:%s"><td style="vertical-align:top;">LB </td><td style="text-align:right;vertical-align:top;">%s</td><td style="text-align:right;vertical-align:top;"></td><td style="text-align:right;vertical-align:top;"> (%s) : </td><td style="text-align:left;vertical-align:top;"><i><strong><b>"%s"</b></strong></i></td></tr>' % (col,start,dq,comment)
2463 commentbox +=
'<tr style="color:%s"><td style="vertical-align:top;">LB </td><td style="text-align:right;vertical-align:top;">%s</td><td style="text-align:right;vertical-align:top;">−</td><td style="text-align:right;vertical-align:top;">%s (%s) : </td><td style="text-align:left;vertical-align:top;"><i><strong><b>"%s"</b></strong></i></td></tr>' % (col,start,end-1,dq,comment)
2466 commentbox +=
'<tr style="color:#222222"><td style="vertical-align:top;">LB </td><td style="text-align:right;vertical-align:top;">%s</td><td style="text-align:right;vertical-align:top;"></td><td style="text-align:right;vertical-align:top;"> (n.a.) </td><td style="text-align:left;vertical-align:top;"></td></tr>' % (start)
2468 commentbox +=
'<tr style="color:#222222"><td style="vertical-align:top;">LB </td><td style="text-align:right;vertical-align:top;">%s</td><td style="text-align:right;vertical-align:top;">−</td><td style="text-align:right;vertical-align:top;">%s (n.a.) </td><td style="text-align:left;vertical-align:top;"></td></tr>' % (start,end-1)
2471 commentbox =
'<strong><b>Comments for %s DQ channel "%s" in run %s:</b></strong>' % (sp[0],sp[1],run.runNr) +
'<table>' + commentbox
2472 commentbox +=
'</table>'
2473 run.addToolTip(
"dqcomm_%s_%i" % (k, run.runNr), commentbox)
2477 lbtrigtypes = {
'L1 PSK': [
'L1 PSK',
'L1K'],
'HLT PSK' : [
'HLT PSK',
'HLTK'] }
2478 for lbtrigtype, c
in lbtrigtypes.items():
2479 if lbtrigtype
in Run.ShowOrder
and 'blocks' in run.stats[lbtrigtype]
and len(run.stats[lbtrigtype][
'blocks'])>1:
2480 boxcontent =
'<strong><b>%s evolved during run:</b></strong><br>' % c[0]
2481 boxcontent +=
'<table style="width: auto; border: 0px solid; border-width: margin: 0 0 0 0; 0px; border-spacing: 0px; border-collapse: separate; padding: 0px; font-size: 100%">'
2482 for item, start, stop
in run.stats[lbtrigtype][
'blocks']:
2483 boxcontent +=
'<tr><td>LB </td><td style="text-align:right">%s</td><td style="text-align:right">−</td><td style="text-align:right">%s</td><td style="text-align:right">: %s</td></tr>' % (start,stop-1,item)
2484 boxcontent +=
'</table>'
2485 run.addToolTip(
"%s_%i" % (c[1], run.runNr), boxcontent)
2489 if any([k
for k
in Run.ShowOrder
if "olc:bcidmask" in k.ResultKey]):
2490 boxcontent = Run.TmpBoxContent
2492 Run.addGlobalToolTip(
"OLCBCID_%i" % run.runNr, boxcontent)