ATLAS Offline Software
Loading...
Searching...
No Matches
BeamSpotSummary.py
Go to the documentation of this file.
1# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2
3
4"""
5ATLAS beam spot web page for displaying beam spot job data.
6"""
7
8__author__ = 'Juerg Beringer'
9__version__ = '$Id $'
10
11from BeamSpotWebPage import BeamSpotWebPage
13from InDetBeamSpotExample.Utils import blankIfNone
14import time
15import glob
16
17# TODO: default sorting
18tableSorter = """\
19<script type="text/javascript" src="../js/jquery-latest.js"></script>
20<script type="text/javascript" src="../js/jquery.tablesorter.js"></script>
21<script type="text/javascript" id="js">
22$(document).ready(function() {
23 $("table").tablesorter({
24 headers: { 3: { sorter: "shortDate" } },
25 sortList: [[0,1]]
26 });
27});
28</script>
29"""
30
31tableHeader = """<table cellspacing="0" class="tablesorter">
32<thead>
33<tr>
34<th>Run</th>
35<th>Stream</th>
36<th>Latest %s Task</th>
37<th>Updated</th>
38<th>Status</th>
39<th>Results</th>
40<th>Data in COOL</th>
41<th>Validation<br>Job Status</th>
42<th>Validation<br>Job Results</th>
43<th>Links</th>
44</tr>
45</thead>
46<tbody>
47"""
48
49runCount = """\
50<div class="text">
51<h3>%s runs(s) with tasks of type %s:</h3>
52</div>
53"""
54
55runCountLimit = """\
56<div class="text">
57<h3>%s runs(s) with tasks of type %s, displaying last %i runs:</h3>
58</div>
59"""
60
61
63
64 def __init__(self):
65 BeamSpotWebPage.__init__(self)
66 self.pageConfig['pageTitle'] = 'ATLAS Beam Spot Summary'
67 self.addToPageHeader(tableSorter)
68
69 def content(self,**args):
70 if 'type' in args:
71 type = args['type']
72 else:
73 type = ''
74 limit = int(args['limit']) if 'limit' in args else 50
75 with TaskManager(self.globalConfig['taskDb']) as taskman:
76 if not limit:
77 limit = 99999999
78 table = runCount % (taskman.getCount('distinct(runnr)',[ "where TASKNAME like '%s%%'" % type]), type)
79 else:
80 table = runCountLimit % (taskman.getCount('distinct(runnr)',[ "where TASKNAME like '%s%%'" % type]), type,limit)
81 table += tableHeader % type
82 for r in taskman.taskIterDict('distinct(DSNAME),RUNNR',["where TASKNAME like '%s%%' order by RUNNR desc" % type], limit):
83 runnr = r['RUNNR']
84 dsname = r['DSNAME']
85 try:
86 stream = dsname.split('.')[-1].split('_')[-1]
87 except:
88 stream = ''
89 if not runnr: continue
90 table += "<tr>"
91 table += '<td><a href="http://atlas-runquery.cern.ch/query.py?q=find+r+%s+/+sh+lhc+all+and+r+and+t+and+mag+and+dq+idbs,pix,sct">%s</a></td>' % (runnr,runnr)
92 table += '<td>%s</td>' % stream
93 try:
94 t = taskman.taskIterDict('*',['where RUNNR =',DbParam(runnr),'and DSNAME =',DbParam(dsname),"and TASKNAME like '%s%%' order by UPDATED desc" % type]).next()
95 taskName = t['TASKNAME']
96 datatag = taskName.split('.')[-1].split('_')[0]
97 if taskName[:11] == 'DB_BEAMSPOT.':
98 # Special naming convention for T0 beam spot jobs
99 monTaskName = 'MON.%s.%s' % (taskName,datatag)
100 elif taskName[:-1] == 'REPROHIMAR2011_BEAMSPOT.r2074.v':
101 # Kludge to fix inconsistent naming for Mar 2011 HI reprocessing jobs
102 monTaskName = 'MON.REPROHIMAR2011_BEAMSPOT.r2074'
103 else:
104 # Other monitoring jobs
105 monTaskName = 'MON.%s%%' % (taskName)
106 try:
107 m = taskman.taskIterDict('*',['where RUNNR =',DbParam(runnr),'and DSNAME =',DbParam(dsname),'and TASKNAME like ',DbParam(monTaskName),'order by UPDATED desc']).next()
108 stat = m['STATUS']
109 monStatus = '<td class="%s"><a href="../details?d=%s&t=%s">%s</a></td>' % (getStatusClass(stat),t['DSNAME'],m['TASKNAME'],getKey(TaskManager.StatusCodes,stat))
110 monResults = "<td>%s</td>" % (blankIfNone(m['RESULTLINKS']))
111 except:
112 monStatus = '<td></td>'
113 monResults = '<td></td>'
114 table += '<td><a href="../details?d=%s&t=%s">%s</a></td>' % (t['DSNAME'],taskName,taskName)
115 table += "<td>%s</td>" % (time.ctime(t['UPDATED']))
116 stat = t['STATUS']
117 table += '<td class="%s">%s</td>' % (getStatusClass(stat),getKey(TaskManager.StatusCodes,stat))
118 table += "<td>%s</td>" % (blankIfNone(t['RESULTLINKS']))
119 table += "<td>"
120 cooltags = t['COOLTAGS']
121 if not cooltags:
122 cooltags = '' # make sure it is not None
123 for tag in cooltags.split():
124 table += '<a href="http://atlas-runquery.cern.ch/query.py?q=find+run+%s+/+show+bs+%s">%s</a> ' % (runnr,tag,tag)
125 table += '<br>'
126 table += "</td>"
127 except Exception as e:
128 table += "<td>%s</td>" % str(e)
129 table += "<td></td>"
130 table += "<td></td>"
131 table += "<td></td>"
132 table += "<td></td>"
133 monStatus = '<td></td>'
134 monResults = '<td></td>'
135 table += monStatus
136 table += monResults
137 table += '<td><a href="../jobs?r=%s">all tasks</a></td>' % runnr
138 table += "</tr>\n"
139 table += "</tbody></table>\n"
140 return table
141
142
143# Code to test or run locally
144if __name__ == '__main__':
146 print (p.index())
addToPageHeader(self, snippet)
Definition WebPage.py:320
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177