13 from __future__
import with_statement
17 from CoolRunQuery.AtlRunQueryRun
import Run
19 from CoolRunQuery.utils.AtlRunQueryUtils
import addKommaToNumber, filesize
20 from CoolRunQuery.utils.AtlRunQueryTimer
import timer
22 from CoolRunQuery.html.AtlRunQueryPageMaker
import PageMaker
as PM
23 from CoolRunQuery.selector.AtlRunQuerySelectorBase
import DataKey
35 setattr (PI, x, pageinfo[x])
39 cachelink = PI.datapath[PI.datapath.rfind(
'arq_'):].rstrip(
'/')
40 cachelinkline =
'[ <a style="font-size:11px;font-weight:100;font-style:normal" href="query.py?q=%s"><i>cached link to this result page</i></a> ]' % cachelink
42 extraReplace = [ (
'<!--INSERTLINKCACHE-->', cachelinkline) ]
49 body += cls._OverallSummary( pageinfo )
52 if PI.makeDQSummary
or PI.makeDQPlots:
53 body += cls._DQSummaryWrap( pageinfo, doPickle=doDQPickle )
54 extraReplace += [ (
'<!--CONTACT_START-->.*<!--CONTACT_END-->',
'<a href="http://consult.cern.ch/xwho/people/572921">Jessica Leveque</a>') ]
57 pageinfo[
'selstr'] = cls._makeSelectionSteps( pageinfo )
58 body += cls._InitialSummary( pageinfo )
60 if PI.makeDQSummary
or PI.makeDQPlots:
62 body += cls._defineToolTips( pageinfo, globalOnly=
True )
65 body +=
'<hr style="width:95%; background-color: #999999; height:1px; margin-left:14px; border:0">\n<p>\n'
68 pageinfo[
'sumstr'] = cls._makeYellowLine( pageinfo )
69 body += cls._makeResultsTable( pageinfo )
72 body += cls._defineToolTips( pageinfo )
76 body += cls._makeBottomTable(pageinfo)
78 PM.makePage(body, PI.origQuery, extraReplace=extraReplace, removeExamples = (PI.makeDQSummary
or PI.makeDQPlots))
87 setattr (PI, x, pageinfo[x])
90 resultstable =
'<table class="resulttable" id="resulttable" style="margin-left: 13px">\n'
93 resultstable += Run.header()
96 with timer(
"print the runs"):
98 with timer(
"print run %i" % r.runNr):
99 resultstable +=
str(r)
102 headlist = Run.headerkeys()
103 resultstable +=
" <tr class=\"space\"><td style=\"text-align: left;\" colspan=\"%i\"><font size=-2><i>Summary</i>:</font></td></tr>\n" % (len(headlist)-1)
104 resultstable +=
" <tr class=\"sum\">" + PI.sumstr +
"</tr>\n"
105 resultstable +=
"</table>\n"
114 setattr (PI, x, pageinfo[x])
117 with timer(
"print the tooltips"):
118 dw_call = [
'<script type="text/javascript">']
119 dw_call += [
"if(dw_Tooltip.content_vars==undefined) {dw_Tooltip.content_vars = {}; };"]
120 dw_call += Run.GlobalTooltips
123 dw_call += r.tooltips
124 dw_call += [
'</script>']
126 tooltips += ttip +
'\n'
137 setattr (PI, x, pageinfo[x])
139 bottomTable =
'<table cellspacing="0" style="color: #777777; font-size: 80%; margin-left: 13px">\n'
140 bottomTable +=
'<tr>\n<td valign="top">\n'
141 bottomTable += cls._Description()
142 bottomTable +=
'<tr><td colspan="2"><p><hr style="width:40%; color:#999999; background-color: #999999; height:1px; margin-left:0; border:0"/>\n<p>\n</td></tr>'
145 bottomTable += cls._XMLFormat(PI.datapath, PI.xmlfilename, PI.xmlhtmlstr)
148 bottomTable += cls._PickledOutput(PI.datapath)
151 bottomTable += cls._RootOutput(PI.roothtmlstr, PI.datapath)
154 bottomTable +=
'<tr><td colspan="2"><p>\n<p>\n</td></tr>'
155 bottomTable +=
'</table>'
164 for x
in [
"dicsum",
"dic",
"datapath",
"makeDQeff"]:
165 setattr (PI, x, pageinfo[x])
167 if PI.dicsum
and PI.makeDQeff:
168 with timer(
"make the DQ efficiency summary"):
169 from CoolRunQuery.utils.AtlRunQueryDQUtils
import MakeDQeffHtml
180 setattr (PI, x, pageinfo[x])
182 with timer(
"make the yellow summary line"):
184 for key, summary
in PI.dicsum.items():
185 if key.Type == DataKey.STREAM:
191 sumdic[key.ResultKey] = s.strip()
193 headlist = Run.headerkeys()
194 for title
in headlist:
195 sumstr +=
'<td style="text-align:right;">%s</td>' % (sumdic[title]
if title
in sumdic
else '')
205 setattr (PI, x, pageinfo[x])
207 selstr =
'<table style="color: #777777; font-size: 100%" cellpadding="0" cellspacing="0">'
208 for sel
in PI.selout:
209 if 'SELOUT' == sel[0:6]:
210 selout = sel[7:].
split(
'==>')
212 selstr +=
'<tr><td width="400" style="vertical-align:top">%s</td></tr>' % selout[0]
214 selstr +=
'<tr><td width="400" style="vertical-align:top">%s</td><td width="20" style="vertical-align:top">:</td><td style="vertical-align:top">%s</td></tr>' % tuple(selout[0:2])
223 """Converts a float to a string with appropriately placed commas"""
225 s =
"%.*f" % (width, n)
228 dec = s.find(decimal)
231 threes =
int((dec-1)/3)
232 for i
in range(threes):
234 s = s[:loc] + delim + s[loc:]
243 setattr (PI, x, pageinfo[x])
245 with timer(
"make the summary"):
246 from CoolRunQuery.html.AtlRunQuerySummary
import MakeSummaryHtml
248 if overallsummarystr ==
'':
250 s =
'''<table width="95%" cellpadding="5" style="margin-left: 13px">
251 <tr><td colspan=2 bgcolor=gainsboro><font size=+1><b>Search Result Summary</b></font></td></tr>
254 s += overallsummarystr
261 from CoolRunQuery.utils.AtlRunQueryUtils
import runsOnServer
264 from CoolRunQuery.AtlRunQueryQueryConfig
import QC
265 with open(
'%s/dqsum_pi.pickle' % QC.datapath,
"wb")
as fh:
266 pickle.dump(pageinfo, fh)
271 setattr (PI, x, pageinfo[x])
273 with timer(
"make the DQ summary"):
274 from CoolRunQuery.html.AtlRunQueryDQSummary
import DQSummary
275 dqsummary = DQSummary.makeHTML( PI.dic, PI.dicsum, doDQSummary=PI.makeDQSummary, doDQPlots=PI.makeDQPlots, dqsumGRL=PI.dqsumgrl, dbbTag=PI.dbbtag)
279 s =
'''<table width="95%" cellpadding="5" style="margin-left: 13px">
280 <tr><td colspan=2 bgcolor=gainsboro><font size=+1><b>Data Quality Summary</b></font></td></tr>
293 setattr (PI, x, pageinfo[x])
296 totEv,naEv = Run.totevents[0:2]
297 s_table =
'''<table width="95%" cellpadding="5" style="margin-left: 13px">
298 <tr><td colspan=2 bgcolor=gainsboro><font size=+1><b>Search Result</b></font></td></tr>
300 s_table +=
'<table width="95%" cellpadding="0" cellspacing="3" style="font-size: 90%; margin-left: 13px">\n'
301 s_table +=
'<tr height="10"></tr>\n'
302 s_table +=
'<tr><td height="10" width="130" style="vertical-align:top"><i>Selection rule:</i></td><td width=10></td><td valign=top>%s</td></tr>\n' % PI.origQuery
303 if 'erbose' in PI.fullQuery:
304 s_table +=
'<tr><td height="10" style="vertical-align: top; color: #777777"><i>Query command:</i></td><td width=10 style="color: #777777"></td><td style="color: #777777">'
305 s_table +=
"""<a href="javascript:animatedcollapse.toggle('AtlRunQueryCmd')">"""
306 s_table +=
'<font color="#777777">[ Click to expand/collapse command... ]</font></a>'
307 s_table +=
'<div id="AtlRunQueryCmd" style="width: 100%; background: #FFFFFF; color: #777777; display:none">'
308 s_table +=
'%s' % (PI.fullQuery)
309 s_table +=
'</div></td></tr>\n'
310 s_table +=
'<tr><td height="10" style="vertical-align: top; color: #777777"><i>Selection sequence:</i></td><td width=10 style="color: #777777"></td><td style="vertical-align: top">%s</td></tr>\n' % (PI.selstr)
312 s_table +=
'<tr><td height="10" style="vertical-align: top"><i>No. of runs selected:</i></td><td></td><td valign="top">%s</td></tr>\n' % len(PI.runlist)
319 s_table +=
'<tr><td height="10" valign="top"><i>Total no. of events:</i></td><td></td><td valign="top">%s</td></tr>\n' % (cls._prettyNumber(totEv))
321 s_table +=
'<tr><td height="10" valign="top"><i>Total no. of events:</i></td><td></td><td valign="top">%s (excluding %i %s without available "#Events" information)</td></tr>\n' % (cls._prettyNumber(totEv), naEv, sr)
323 s_table +=
'<tr><td height="10" valign="top"><i>Total no. of events:</i></td><td></td><td valign="top">%s</td></tr>\n' % (cls._prettyNumber(totEv))
324 s_table +=
'<tr><td height="10" valign="top"><i>Execution time:</i></td><td></td><td valign="top">%.1f sec</td></tr>\n' %
round(PI.querytime,1)
325 s_table +=
'<tr><td height=5 valign=top></td></tr>\n'
326 s_table +=
'</table>'
332 return '''<tr><td style="vertical-align: top"><img vspace=0 src="images/download.gif"> </td><td>
333 <a href="./%s/atlrunquery.pickle" target=_blank title="Query results as serialised python dictionary">
334 Result table as pickled <b>python dictionary</b> (right-click link to download)</a>
337 −
338 open file (f) in python and deserialise ("unpickle")
339 via: dico = pickle.load(f)<br> − the dictionary keys are equal to the column titles,
340 the lines are stored as list entries for each key
341 </td></tr>''' % datapath
346 if roothtmlstr
is not None:
348 <tr><td style="vertical-align: top"><img vspace=0 width="17" src="images/tree_icon.gif"> </td><td>
349 <a href="./%s/atlrunquery.root" title="Query results as ROOT TTree">Result table as <b>TTree</b> in ROOT file (right-click link to download)</a></td></tr>
350 <tr><td style="vertical-align: top"><img vspace=0 src="images/statistics.gif"> </td><td style="vertical-align: top">
351 <font color="#333333"><b>Graphs</b> of table columns versus run numbers:</font>
353 <tr><td style="vertical-align: top"></td><td style="vertical-align: top">%s
354 </td></tr>''' % (datapath, roothtmlstr)
357 <tr><td style="vertical-align: top"><img vspace=0 width="17" src="images/tree_icon.gif"> </td><td style="color: #000064;">
358 Not available. <font color="#333333">The creation of a ROOT file with the results has been disabled by default. Please use option <b><i>root</i></b> as shown in the examples under <font style="color:red">Xtras</font></font></td></tr>
359 <tr><td style="vertical-align: top"><img vspace=0 src="images/statistics.gif"> </td><td style="vertical-align: top">
360 <font color="#333333">The creation of <b>Graphs</b> has been disabled by default. Please use option <b><i>root</i></b> as shown in the examples under <font style="color:red">Xtras</font></font>
366 return '''<tr style="line-height: 6.5"><td colspan="2"></td></tr>
367 <tr><td style="vertical-align: top"><img vspace=0 src="images/info.gif"> </td><td height="55"><i>n.a.</i>
368 in the table stands for <i>not available</i>:<br> −
369 in case of <i>#Events</i> this mostly indicates unproperly closed runs<br> −
370 in case of <i>data quality flags</i> it indicates that the corresponding flag was not set<br> −
371 <i><font color="red">runs in red</font></i> indicate that their selection is questionable due to n.a. information
372 (n.a. fields pass the corresponding selection query)
378 s =
'<tr><td><img vspace=0 src="images/printtopic.gif"> </td>\n'
379 s +=
'<td><a href="javascript:openWindow('
380 s +=
"'Print','<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html xmlns:"my"><head><title>Run query result</title><LINK href="atlas-runquery.css" rel="stylesheet" type="text/css"><body><table style="font-family: sans-serif; font-size: 85%%">"
381 s +=
'<tr><td>%s</td></tr>' % s_table.replace(
'"',
'"')
382 s +=
'<tr><td>' + resstr.replace(
'resulttable',
'resulttabletext').
replace(
'"',
'quot;') +
'</td></tr>'
383 s +=
'<tr><td><hr color="red" size=1></td></tr><tr><td><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())
385 s +=
'" title="Query results in text format for easy printing">Print version of results</a>'
392 if xmlhtmlstr
is not None:
393 s =
'''<tr><td style="vertical-align: top"><img vspace=0 src="images/xml-small.gif"> </td><td>
394 <a href="./%s/%s" target="_blank" title="Query result as LB collection in standard XML good-run-list format">Query result as standard <b>Good Run-LB List in XML format</b> (right-click link to download)</a> /
395 <a href="./LumiRangeCollection.dtd" target="_blank" title="Corresponding DTD file">DTD file</a>
396 </td></tr>''' % (datapath, xmlfilename)
397 s +=
'<tr><td style="vertical-align: top"></td><td>'
398 s +=
'<a href="javascript:openTextWindow('
399 s +=
"'Print','<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html xmlns:"my"><head><title>Run query result</title><LINK href="atlas-runquery.css" rel="stylesheet" type="text/css"><body><table style="padding: 10px;font-family: sans-serif; font-size: 95%%">"
400 s +=
'<tr><td>%s</td></tr>' % xmlhtmlstr
401 s +=
'</table></body></html>'
403 s +=
'" title="Query result in text format">Query result as standard <b>Good Run-LB List in pretty-text format</b> for visual inspection (click for pop-up)</a>'
407 return '''<tr><td style="vertical-align: top;"><img vspace=0 src="images/xml-small.gif"> </td><td style="color: #000064;">
408 Not available. <font color="#333333">The creation of <b>GRLs</b> based on the query result has been disabled by default. Please use option <b><i>grl</i></b> as shown in the examples under <font style="color:red">Xtras</font></font></td></tr>'''