ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
DataQuality
DataQualityUtils
scripts
StandAloneDisplay.py
Go to the documentation of this file.
1
#!/bin/env python
2
3
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
4
5
import
os
6
7
CWD = os.getcwd()
8
9
import
sys
10
11
import
ROOT
# noqa: F401
12
15
from
ROOT
import
gSystem
16
os.chdir(CWD)
17
18
19
gSystem.Load(
'libDataQualityUtils'
)
20
from
ROOT
import
dqutils
21
22
23
def
handi
( name, resultsFile, htmlDir ):
24
25
if
( htmlDir.rfind(
"/"
)!=(len(htmlDir)-1) ):
# htmlDir needs "/" at the end
26
htmlDir+=
"/"
27
28
of =
dqutils.HanOutputFile
(resultsFile)
29
30
dirsstring = of.stringListSystemPaths(htmlDir)
31
dirs = dirsstring.rsplit()
32
for
subHtmlDir
in
dirs:
33
if
(
not
os.access(subHtmlDir,os.F_OK) ):
34
try
:
35
os.makedirs(subHtmlDir)
36
except
os.error:
37
print
(
'Cannot create directory "'
+ subHtmlDir +
'"; exiting.'
)
38
sys.exit(-1)
39
40
total=of.stringAllHistograms()
41
of.saveAllHistograms(htmlDir,
False
)
42
43
s=total.rsplit(
'\n'
)
44
# number = number of lines in total
45
number=len(s)
46
if
(len(s[number-1])<1):
# last line is empty
47
number-=1
48
49
list, namelist =
makeAllDirsFile
( htmlDir, name, s, number, resultsFile )
50
51
for
x
in
range(0,len(list)):
52
makeSubDirFile
( htmlDir, name, s, number, namelist[x], list[x] )
53
makeCSSFile
( htmlDir,
""
, namelist[x] )
54
55
makeCSSFile
( htmlDir,
""
,
"."
)
56
57
58
def
usage
():
59
cmdi = sys.argv[0].rfind(
"/"
)
60
cmd = sys.argv[0][cmdi+1:]
61
print
(
"Usage: "
, cmd,
"<imput_file> <html_output_directory>"
)
62
63
def
makeAllDirsFile
( htmlDir, name, s, number, resultsFile ):
64
g=open(htmlDir+
'index.html'
,
'w'
)
65
g.write(
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n'
)
66
g.write(
'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n'
)
67
g.write(
'<head>\n'
)
68
g.write(
'<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />\n'
)
69
g.write(
'<title>'
+ name+
'</title>\n'
)
70
g.write(
'<link rel="stylesheet" href="AutomChecks.css" type="text/css" />\n'
)
71
g.write(
'</head>\n'
)
72
g.write(
'<body>'
)
73
g.write(
'<font class="DQGroup">[<a href="../index.html">Back</a>]</font>\n'
)
74
g.write(
'<h1>'
+ name +
': Monitoring</h1>\n'
)
75
76
# initial number of white spaces, will change to positive value once we go over the lines
77
spaces=-1
78
# list = list with directories (the line number) that contain histos
79
list=[]
80
# namelist = list with corresponding direcotory names
81
namelist=[]
82
83
num_lists=0
84
85
g.write(
'<table>\n<tr valign="top">\n<td width="500">\n'
)
86
for
x
in
range(0,number):
87
sp=s[x].rsplit()
88
if
sp[3]==
'dir'
:
# a directory
89
namedir=sp[0]
90
shortNameDir = namedir
91
namediri = namedir.rfind(
"/"
)
92
if
( namediri != -1 ):
93
shortNameDir = namedir[namediri+1:]
94
if
namedir==
'<top_level>'
:
95
shortNameDir=
'Overall Status'
96
spaces_new=s[x].
find
(sp[0][0])
97
if
spaces_new > spaces:
# current dir is subdir of previous dir -> new item in new list
98
g.write(
'<ul>\n<li>'
)
99
num_lists+=1
100
elif
spaces_new==spaces:
# current en previous dir in same motherdir -> new item
101
g.write(
'</li>\n<li>'
)
102
else
:
# close list and open new one
103
g.write(
'</li>'
)
104
diff = spaces - spaces_new
105
while
diff > 0:
106
g.write(
'</ul></li>\n'
)
107
diff -= 2
108
num_lists-=1
109
g.write(
'<li>'
)
110
if
namedir!=
'<top_level>'
:
111
g.write(
'<img src="pixel.png" width="0" height="13" alt="" />'
)
112
if
( (x<number-1)
and
(s[x+1].rsplit())[3]==
'ass'
):
# check that dir contains histos
113
if
namedir==
'<top_level>'
:
114
namedir =
'.'
115
g.write(
'<font class="DQGroup"><a href="'
+namedir +
'/toplevel.html">'
+shortNameDir+
'</a></font>'
)
116
else
:
117
g.write(
'<font class="DQGroup"><a href="'
+namedir +
'/index.html" >'
+shortNameDir+
'</a></font>'
)
118
list.append(x)
119
namelist.append(namedir)
120
else
:
121
g.write(
'<font class="DQGroup">'
+shortNameDir+
'</font>'
)
122
spaces=spaces_new
123
if
num_lists>0:
124
g.write(
'</li>'
)
125
for
x
in
range(0,num_lists-1):
126
g.write(
'</ul></li>\n'
)
127
if
num_lists>0:
128
g.write(
'</ul>\n'
)
129
g.write(
'</td>\n<td><font class="Info">From file:</font><br/><font class="Note">'
+ resultsFile +
'</font></td>\n</tr>\n</table>'
)
130
g.write(
'</body>\n</html>'
)
131
g.close()
132
return
list, namelist
133
134
135
def
makeSubDirFile
( htmlDir, name, s, number, subname, assessIndex ):
136
137
if
( subname ==
'.'
):
138
h=open(htmlDir+
'/'
+subname+
'/toplevel.html'
,
'w'
)
139
subnameTitle =
'Top Level'
140
else
:
141
h=open(htmlDir+
'/'
+subname+
'/index.html'
,
'w'
)
142
subnameTitle = subname
143
h.write(
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n'
)
144
h.write(
'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n'
)
145
h.write(
'<head>\n'
)
146
h.write(
'<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />\n'
)
147
h.write(
'<title>'
+ name +
' '
+ subnameTitle +
'</title>\n'
)
148
h.write(
'<link rel="stylesheet" href="AutomChecks.css" type="text/css" />\n'
)
149
h.write(
'</head>\n'
)
150
h.write(
'<body>\n'
)
151
h.write(
'<font class="DQGroup">[<a href="'
)
152
for
x
in
range(subname.count(
"/"
)):
153
h.write(
'../'
)
154
h.write(
'../index.html">Back</a>]</font>\n'
)
155
h.write(
'<center>'
)
156
h.write(
'<table>\n<tr valign="top">\n<td width="250"></td>\n'
)
157
h.write(
'<td width="300"><h2>'
+name+
' '
+subnameTitle+
'</h2></td>\n'
)
158
h.write(
'<td width="250">\n<font class="Note">Click on images for details and full size.</font>\n'
)
159
h.write(
'</td>\n</tr>\n</table>\n'
)
160
h.write(
'<table cellpadding="4" cellspacing="20">\n'
)
161
y=assessIndex+1
162
sp=s[y].rsplit()
163
col=0
164
while
(sp[3]==
'ass'
and
y<number):
165
sp=s[y].rsplit()
166
col+=1
167
if
col==1:
168
h.write(
'<tr>\n<td class="'
+ sp[1] +
'"><a href="'
+sp[0]+
'.html"><img src="'
+ sp[0] +
'.png" height="200" alt="'
+ name +
' '
+ subname+
'/'
+sp[0]+
'.png" /></a></td>\n'
)
169
elif
col==3:
170
h.write(
'<td class="'
+ sp[1] +
'"><a href="'
+sp[0]+
'.html"><img src="'
+ sp[0] +
'.png" height="200" alt="'
+ name +
' '
+ subname+
'/'
+sp[0]+
'.png" /></a></td>\n</tr>\n'
)
171
col=0
172
else
:
173
h.write(
'<td class="'
+ sp[1] +
'"><a href="'
+sp[0]+
'.html"><img src="'
+ sp[0] +
'.png" height="200" alt="'
+ name +
' '
+ subname+
'/'
+sp[0]+
'.png" /></a></td>\n'
)
174
makeOneHistFile
( htmlDir, name, subname, sp )
175
y=y+1
176
if
y< number-1:
177
sp=s[y].rsplit()
178
if
not
(col==3):
179
h.write(
'</tr>\n'
)
180
h.write(
'</table>\n</center>\n</body>\n</html>\n'
)
181
h.close()
182
183
184
def
makeOneHistFile
( htmlDir, name, subname, sp ):
185
k=open(htmlDir+
'/'
+subname+
'/'
+sp[0]+
'.html'
,
'w'
)
186
k.write(
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n'
)
187
k.write(
'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n'
)
188
k.write(
'<head>\n'
)
189
k.write(
'<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />\n'
)
190
k.write(
'<title>'
+name+
' '
+ subname+
' '
+ sp[0]+
'</title>\n'
)
191
k.write(
'<link rel="stylesheet" href="AutomChecks.css" type="text/css" />\n'
)
192
k.write(
'</head>\n'
)
193
k.write(
'<body>\n'
)
194
k.write(
'<center>\n'
)
195
k.write(
'<table>\n<tr valign="top">\n'
)
196
if
subname==
'.'
:
197
k.write(
'<td width="250"><font class="DQGroup">[<a href="toplevel.html">Back</a></font>]</td>\n'
)
198
else
:
199
k.write(
'<td width="250"><font class="DQGroup">[<a href="index.html">Back</a></font>]</td>\n'
)
200
k.write(
'<td width="500"><h2>'
+name +
' '
+ subname+
'/'
+sp[0]+
'</h2></td>\n'
)
201
k.write(
'<td width="250"></td>\n</tr></table>\n'
)
202
k.write(
'<table cellpadding="10">\n<tr>\n'
)
203
k.write(
'<td>\n<table width="400">\n'
)
204
k.write(
'<tr><td colspan="2"><font class="Heading">Details:</font></td></tr>\n'
)
205
k.write(
'<tr><td> </td></tr>\n'
)
206
k.write(
'<tr><td align="right"><font class="DatumName">Name:</font></td>'
)
207
k.write(
'<td>'
+sp[0] +
'</td></tr>\n'
)
208
k.write(
'</table>\n</td>\n'
)
209
if
subname ==
'.'
:
210
k.write(
'<td><a href="toplevel.html"><img src="'
+ sp[0] +
'.png" alt="'
+ name +
' '
+ subname+
'/'
+sp[0]+
'.png" /></a></td>\n'
)
211
else
:
212
k.write(
'<td><a href="index.html"><img src="'
+ sp[0] +
'.png" alt="'
+ name +
' '
+ subname+
'/'
+sp[0]+
'.png" /></a></td>\n'
)
213
k.write(
'</tr></table>\n'
)
214
k.write(
'</center>\n</body>\n</html>\n'
)
215
k.close()
216
217
218
def
makeRootFile
( htmlDir, name, subname ):
219
k=open(htmlDir+
'index.html'
,
'w'
)
220
k.write(
'<html>\n<frameset rows="200,*">\n'
)
221
k.write(
'<frame src="'
+name+
'AllDirs.html">\n'
)
222
if
subname !=
""
:
223
if
subname !=
'.'
:
224
k.write(
'<frame src="'
+subname+
'/index.html" name="showframe"> \n'
)
225
else
:
226
k.write(
'<frame src="'
+subname+
'/toplevel.html" name="showframe"> \n'
)
227
k.write(
'</frameset>\n</html> \n'
)
228
k.close()
229
230
231
def
makeCSSFile
( htmlDir, name, subname ):
232
css=open(htmlDir+
'/'
+subname+
'/'
+name+
'AutomChecks.css'
,
'w'
)
233
css.write(
'BODY\n{\n background: #E6E6FA;\n color: #000000;\n font-family: helvetica,sans-serif;\n}\n'
)
234
css.write(
'H1\n{\n font-family: helvetica,sans-serif;\n font-size: x-large;\n text-align: left;\n}\n'
)
235
css.write(
'H2\n{\n font-family: helvetica,sans-serif;\n font-size: large;\n text-align: center;\n}\n'
)
236
css.write(
'H3\n{\n font-family: helvetica,sans-serif;\n font-size: medium;\n text-align: left;\n}\n'
)
237
css.write(
'FONT.Info\n{\n color: black;\n font-style: italic;\n}\n'
)
238
css.write(
'FONT.Heading\n{\n color: black;\n font-weight: bold;\n font-size: large;\n}\n'
)
239
css.write(
'FONT.DatumName\n{\n color: black;\n font-weight: bold;\n}\n'
)
240
css.write(
'FONT.Note\n{\n color: black;\n font-size: small;\n}\n'
)
241
css.write(
'FONT.DQGroup\n{\n font-size: small;\n}\n'
)
242
css.write(
'FONT.Red\n{\n color: red;\n font-weight: bold;\n}\n'
)
243
css.write(
'FONT.Yellow\n{\n color: #ffd700;\n font-weight: bold;\n}\n'
)
244
css.write(
'FONT.Green\n{\n color: green;\n font-weight: bold;\n}\n'
)
245
css.write(
'FONT.Undef\n{\n color: gray;\n font-weight: bold;\n}\n'
)
246
css.write(
'FONT.NoCheck\n{\n color: black;\n font-weight: bold;\n}\n'
)
247
css.write(
'TD.Red\n{\n background-color: red;\n}\n'
)
248
css.write(
'TD.Yellow\n{\n background-color: #ffd700;\n}\n'
)
249
css.write(
'TD.Green\n{\n background-color: green;\n}\n'
)
250
css.write(
'TD.Undef\n{\n background-color: gray;\n}\n'
)
251
css.write(
'TD.NoCheck\n{\n background-color: #E6E6FA;\n}\n'
)
252
css.close()
253
254
255
258
259
if
__name__ ==
"__main__"
:
260
261
if
len(sys.argv) != 3:
262
usage
()
263
sys.exit(0)
264
265
# Input
266
resultsFile = sys.argv[1]
# input .root file
267
html_dir=sys.argv[2]
# destination directory for html files
268
name=resultsFile
269
handi
( name, resultsFile, html_dir )
if
if(pathvar)
Definition
SealSharedLib.cxx:168
print
void print(char *figname, TCanvas *c1)
Definition
TRTCalib_StrawStatusPlots.cxx:26
dqutils::HanOutputFile
Definition
HanOutputFile.h:32
find
std::string find(const std::string &s)
return a remapped string
Definition
hcg.cxx:140
while
while((inf=(TStreamerInfo *) nextinfo()) !=0)
Definition
liststreamerinfos.cxx:13
StandAloneDisplay.makeSubDirFile
makeSubDirFile(htmlDir, name, s, number, subname, assessIndex)
Definition
StandAloneDisplay.py:135
StandAloneDisplay.makeOneHistFile
makeOneHistFile(htmlDir, name, subname, sp)
Definition
StandAloneDisplay.py:184
StandAloneDisplay.makeRootFile
makeRootFile(htmlDir, name, subname)
Definition
StandAloneDisplay.py:218
StandAloneDisplay.makeAllDirsFile
makeAllDirsFile(htmlDir, name, s, number, resultsFile)
Definition
StandAloneDisplay.py:63
StandAloneDisplay.makeCSSFile
makeCSSFile(htmlDir, name, subname)
Definition
StandAloneDisplay.py:231
StandAloneDisplay.usage
usage()
Definition
StandAloneDisplay.py:58
handi
Definition
handi.py:1
Generated on
for ATLAS Offline Software by
1.17.0