16from CoolRunQuery.AtlRunQueryRun
import Run
18from CoolRunQuery.utils.AtlRunQueryUtils
import addKommaToNumber, filesize
19from CoolRunQuery.utils.AtlRunQueryTimer
import timer
21from CoolRunQuery.html.AtlRunQueryPageMaker
import PageMaker
as PM
22from CoolRunQuery.selector.AtlRunQuerySelectorBase
import DataKey
34 setattr (PI, x, pageinfo[x])
38 cachelink = PI.datapath[PI.datapath.rfind(
'arq_'):].rstrip(
'/')
39 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
41 extraReplace = [ (
'<!--INSERTLINKCACHE-->', cachelinkline) ]
48 body += cls._OverallSummary( pageinfo )
51 if PI.makeDQSummary
or PI.makeDQPlots:
52 body += cls._DQSummaryWrap( pageinfo, doPickle=doDQPickle )
53 extraReplace += [ (
'<!--CONTACT_START-->.*<!--CONTACT_END-->',
'<a href="http://consult.cern.ch/xwho/people/572921">Jessica Leveque</a>') ]
56 pageinfo[
'selstr'] = cls._makeSelectionSteps( pageinfo )
57 body += cls._InitialSummary( pageinfo )
59 if PI.makeDQSummary
or PI.makeDQPlots:
61 body += cls._defineToolTips( pageinfo, globalOnly=
True )
64 body +=
'<hr style="width:95%; background-color: #999999; height:1px; margin-left:14px; border:0">\n<p>\n'
67 pageinfo[
'sumstr'] = cls._makeYellowLine( pageinfo )
68 body += cls._makeResultsTable( pageinfo )
71 body += cls._defineToolTips( pageinfo )
75 body += cls._makeBottomTable(pageinfo)
77 PM.makePage(body, PI.origQuery, extraReplace=extraReplace, removeExamples = (PI.makeDQSummary
or PI.makeDQPlots))
86 setattr (PI, x, pageinfo[x])
89 resultstable =
'<table class="resulttable" id="resulttable" style="margin-left: 13px">\n'
92 resultstable += Run.header()
95 with timer(
"print the runs"):
97 with timer(
"print run %i" % r.runNr):
98 resultstable += str(r)
101 headlist = Run.headerkeys()
102 resultstable +=
" <tr class=\"space\"><td style=\"text-align: left;\" colspan=\"%i\"><font size=-2><i>Summary</i>:</font></td></tr>\n" % (len(headlist)-1)
103 resultstable +=
" <tr class=\"sum\">" + PI.sumstr +
"</tr>\n"
104 resultstable +=
"</table>\n"
113 setattr (PI, x, pageinfo[x])
116 with timer(
"print the tooltips"):
117 dw_call = [
'<script type="text/javascript">']
118 dw_call += [
"if(dw_Tooltip.content_vars==undefined) {dw_Tooltip.content_vars = {}; };"]
119 dw_call += Run.GlobalTooltips
122 dw_call += r.tooltips
123 dw_call += [
'</script>']
125 tooltips += ttip +
'\n'
136 setattr (PI, x, pageinfo[x])
138 bottomTable =
'<table cellspacing="0" style="color: #777777; font-size: 80%; margin-left: 13px">\n'
139 bottomTable +=
'<tr>\n<td valign="top">\n'
140 bottomTable += cls._Description()
141 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>'
144 bottomTable += cls._XMLFormat(PI.datapath, PI.xmlfilename, PI.xmlhtmlstr)
147 bottomTable += cls._PickledOutput(PI.datapath)
150 bottomTable += cls._RootOutput(PI.roothtmlstr, PI.datapath)
153 bottomTable +=
'<tr><td colspan="2"><p>\n<p>\n</td></tr>'
154 bottomTable +=
'</table>'
163 for x
in [
"dicsum",
"dic",
"datapath",
"makeDQeff"]:
164 setattr (PI, x, pageinfo[x])
166 if PI.dicsum
and PI.makeDQeff:
167 with timer(
"make the DQ efficiency summary"):
168 from CoolRunQuery.utils.AtlRunQueryDQUtils
import MakeDQeffHtml
169 return MakeDQeffHtml( PI.dic, PI.dicsum, PI.datapath )
179 setattr (PI, x, pageinfo[x])
181 with timer(
"make the yellow summary line"):
183 for key, summary
in PI.dicsum.items():
184 if key.Type == DataKey.STREAM:
185 s = addKommaToNumber(summary[0])+
' <BR><font size="-2">(%s)</font>' % filesize(summary[1])
187 s = addKommaToNumber(summary) +
" runs"
189 s = addKommaToNumber(summary)
190 sumdic[key.ResultKey] = s.strip()
192 headlist = Run.headerkeys()
193 for title
in headlist:
194 sumstr +=
'<td style="text-align:right;">%s</td>' % (sumdic[title]
if title
in sumdic
else '')
204 setattr (PI, x, pageinfo[x])
206 selstr =
'<table style="color: #777777; font-size: 100%" cellpadding="0" cellspacing="0">'
207 for sel
in PI.selout:
208 if 'SELOUT' == sel[0:6]:
209 selout = sel[7:].
split(
'==>')
211 selstr +=
'<tr><td width="400" style="vertical-align:top">%s</td></tr>' % selout[0]
213 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])
222 """Converts a float to a string with appropriately placed commas"""
224 s =
"%.*f" % (width, n)
227 dec = s.find(decimal)
230 threes = int((dec-1)/3)
231 for i
in range(threes):
233 s = s[:loc] + delim + s[loc:]
242 setattr (PI, x, pageinfo[x])
244 with timer(
"make the summary"):
245 from CoolRunQuery.html.AtlRunQuerySummary
import MakeSummaryHtml
246 overallsummarystr = MakeSummaryHtml( PI.dic, PI.dicsum, PI.datapath )
247 if overallsummarystr ==
'':
249 s =
'''<table width="95%" cellpadding="5" style="margin-left: 13px">
250 <tr><td colspan=2 bgcolor=gainsboro><font size=+1><b>Search Result Summary</b></font></td></tr>
253 s += overallsummarystr
260 from CoolRunQuery.utils.AtlRunQueryUtils
import runsOnServer
261 if not runsOnServer()
and doPickle:
263 from CoolRunQuery.AtlRunQueryQueryConfig
import QC
264 with open(
'%s/dqsum_pi.pickle' % QC.datapath,
"wb")
as fh:
265 pickle.dump(pageinfo, fh)
270 setattr (PI, x, pageinfo[x])
272 with timer(
"make the DQ summary"):
273 from CoolRunQuery.html.AtlRunQueryDQSummary
import DQSummary
274 dqsummary = DQSummary.makeHTML( PI.dic, PI.dicsum, doDQSummary=PI.makeDQSummary, doDQPlots=PI.makeDQPlots, dqsumGRL=PI.dqsumgrl, dbbTag=PI.dbbtag)
278 s =
'''<table width="95%" cellpadding="5" style="margin-left: 13px">
279 <tr><td colspan=2 bgcolor=gainsboro><font size=+1><b>Data Quality Summary</b></font></td></tr>
292 setattr (PI, x, pageinfo[x])
295 totEv,naEv = Run.totevents[0:2]
296 s_table =
'''<table width="95%" cellpadding="5" style="margin-left: 13px">
297 <tr><td colspan=2 bgcolor=gainsboro><font size=+1><b>Search Result</b></font></td></tr>
299 s_table +=
'<table width="95%" cellpadding="0" cellspacing="3" style="font-size: 90%; margin-left: 13px">\n'
300 s_table +=
'<tr height="10"></tr>\n'
301 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
302 if 'erbose' in PI.fullQuery:
303 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">'
304 s_table +=
"""<a href="javascript:animatedcollapse.toggle('AtlRunQueryCmd')">"""
305 s_table +=
'<font color="#777777">[ Click to expand/collapse command... ]</font></a>'
306 s_table +=
'<div id="AtlRunQueryCmd" style="width: 100%; background: #FFFFFF; color: #777777; display:none">'
307 s_table +=
'%s' % (PI.fullQuery)
308 s_table +=
'</div></td></tr>\n'
309 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)
311 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)
318 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))
320 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)
322 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))
323 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)
324 s_table +=
'<tr><td height=5 valign=top></td></tr>\n'
325 s_table +=
'</table>'
331 return '''<tr><td style="vertical-align: top"><img vspace=0 src="images/download.gif"> </td><td>
332 <a href="./%s/atlrunquery.pickle" target=_blank title="Query results as serialised python dictionary">
333 Result table as pickled <b>python dictionary</b> (right-click link to download)</a>
336 −
337 open file (f) in python and deserialise ("unpickle")
338 via: dico = pickle.load(f)<br> − the dictionary keys are equal to the column titles,
339 the lines are stored as list entries for each key
340 </td></tr>''' % datapath
345 if roothtmlstr
is not None:
347 <tr><td style="vertical-align: top"><img vspace=0 width="17" src="images/tree_icon.gif"> </td><td>
348 <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>
349 <tr><td style="vertical-align: top"><img vspace=0 src="images/statistics.gif"> </td><td style="vertical-align: top">
350 <font color="#333333"><b>Graphs</b> of table columns versus run numbers:</font>
352 <tr><td style="vertical-align: top"></td><td style="vertical-align: top">%s
353 </td></tr>''' % (datapath, roothtmlstr)
356 <tr><td style="vertical-align: top"><img vspace=0 width="17" src="images/tree_icon.gif"> </td><td style="color: #000064;">
357 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>
358 <tr><td style="vertical-align: top"><img vspace=0 src="images/statistics.gif"> </td><td style="vertical-align: top">
359 <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>
365 return '''<tr style="line-height: 6.5"><td colspan="2"></td></tr>
366 <tr><td style="vertical-align: top"><img vspace=0 src="images/info.gif"> </td><td height="55"><i>n.a.</i>
367 in the table stands for <i>not available</i>:<br> −
368 in case of <i>#Events</i> this mostly indicates unproperly closed runs<br> −
369 in case of <i>data quality flags</i> it indicates that the corresponding flag was not set<br> −
370 <i><font color="red">runs in red</font></i> indicate that their selection is questionable due to n.a. information
371 (n.a. fields pass the corresponding selection query)
377 s =
'<tr><td><img vspace=0 src="images/printtopic.gif"> </td>\n'
378 s +=
'<td><a href="javascript:openWindow('
379 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%%">"
380 s +=
'<tr><td>%s</td></tr>' % s_table.replace(
'"',
'"')
381 s +=
'<tr><td>' + resstr.replace(
'resulttable',
'resulttabletext').
replace(
'"',
'quot;') +
'</td></tr>'
382 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())
384 s +=
'" title="Query results in text format for easy printing">Print version of results</a>'
391 if xmlhtmlstr
is not None:
392 s =
'''<tr><td style="vertical-align: top"><img vspace=0 src="images/xml-small.gif"> </td><td>
393 <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> /
394 <a href="./LumiRangeCollection.dtd" target="_blank" title="Corresponding DTD file">DTD file</a>
395 </td></tr>''' % (datapath, xmlfilename)
396 s +=
'<tr><td style="vertical-align: top"></td><td>'
397 s +=
'<a href="javascript:openTextWindow('
398 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%%">"
399 s +=
'<tr><td>%s</td></tr>' % xmlhtmlstr
400 s +=
'</table></body></html>'
402 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>'
406 return '''<tr><td style="vertical-align: top;"><img vspace=0 src="images/xml-small.gif"> </td><td style="color: #000064;">
407 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>'''
_prettyNumber(cls, n, width=-1, delim=',', decimal='.')
_makeYellowLine(cls, pageinfo)
_DQSummaryWrap(cls, pageinfo, doPickle=True)
makePage(cls, pageinfo, doDQPickle=True)
_InitialSummary(cls, pageinfo)
_PrintFormat(cls, s_table, resstr)
_XMLFormat(cls, datapath, xmlfilename, xmlhtmlstr)
_OverallSummary(cls, pageinfo)
_makeResultsTable(cls, pageinfo)
_makeSelectionSteps(cls, pageinfo)
_makeBottomTable(cls, pageinfo)
_PickledOutput(cls, datapath)
_RootOutput(cls, roothtmlstr, datapath)
_makeDQeff(cls, pageinfo)
_defineToolTips(cls, pageinfo, globalOnly=False)
std::string replace(std::string s, const std::string &s2, const std::string &s3)
std::vector< std::string > split(const std::string &s, const std::string &t=":")