12 import getopt,os,glob,argparse,sys
14 parser = argparse.ArgumentParser(description=
'Create the Physics Validation web page:', usage=
'%(prog)s -i ROC/ ')
15 parser.add_argument(
"-i",
"--input_dir", help=
"path to the folder holding the plots (default: ./)", default=os.getcwd())
16 parser.add_argument(
"-n",
"--number_of_histo", help=
"number of histo per raw (default is 4)", default=4)
18 parser.add_argument(
"-f",
"--format", help=
'format for the plots (default: "*.png")', default=
"*.png")
23 return [alist[i:i+sublen]
for i
in range(0, len(alist), sublen)]
26 numrows = (len(alist)+sublen-1) // sublen
27 return [alist[i::sublen]
for i
in range(numrows)]
36 string =
'<html><table>'
40 list_len = len(sublist)
44 idx = sublist.index(file)
45 print(
"Histo: " + sublist[idx])
46 list_end = list_len - idx
49 string +=
'<p style=\"color:#0000FF\";>'+
str(file)+
'<p> </th><th>'
52 string +=
'<p style=\"color:#0000FF\";>'+
str(file)+
'<p> </th></tr> '
57 idx = sublist.index(file)
58 list_end = list_len - idx
61 string +=
'<a href="'+
str(file)+
'"> <img alt="'+
str(file)+
'" src="'+
str(file)+
'" width="400" height="300"></a> </td><th>'
63 string +=
'<a href="'+
str(file)+
'"> <img alt="'+
str(file)+
'" src="'+
str(file)+
'" width="400" height="300"></a> </td><tr>'
67 string +=
'</table></html>'
80 args = parser.parse_args()
81 folder = os.path.abspath(args.input_dir)
83 if not os.path.isdir(folder):
84 print(
"The folder " + folder +
" doesn't exist !")
89 nHisto =
int(args.number_of_histo)
97 files = glob.glob(format)
101 print(
"=================================================")
102 print(
"Processing histo in directory "+folder)
103 print(
"=================================================")
107 hs =
open(
"FTAG_PhysValWebPage.html",
'w')
108 hs.write(my_htm_page)
110 print(
"See "+folder+
"/FTAG_PhysValWebPage.html")
112 folder_eff= folder+
"/eff_vs_Lxy"
113 if (os.path.isdir(folder_eff)):
115 files = glob.glob(format)
117 hs =
open(
"FTAG_PhysValWebPage.html",
'w')
118 hs.write(my_htm_page)
122 print(
"There is no Efficiency vs Lxy directory: " + folder_eff)
125 folder_pt= folder+
"/eff_vs_pt_ttbar"
127 if (os.path.isdir(folder_pt)):
129 files = glob.glob(format)
131 hs =
open(
"FTAG_PhysValWebPage.html",
'w')
132 hs.write(my_htm_page)
137 folder_pt= folder+
"/eff_vs_pt_Zprime"
138 if (os.path.isdir(folder_pt)):
140 files = glob.glob(format)
142 hs =
open(
"FTAG_PhysValWebPage.html",
'w')
143 hs.write(my_htm_page)
147 print(
"There is no Efficiency vs pT directory (ttbar or Z'): " + folder_pt)
151 mypage =
"<html><table>"
152 mypage +=
'<tr><th><p style=\"color:#0000FF\";> FTAG Physics validation web page <p> </th> </tr>'
153 mypage +=
'<tr><td> <a href="FTAG_PhysValWebPage.html">' +
str(args.input_dir)+
'</a> </td></tr> '
154 mypage +=
'<tr><td> <ul> <li> <a href="eff_vs_Lxy/FTAG_PhysValWebPage.html"> Efficiency versus Lxy </a> </li> '
156 mypage +=
' <li> <a href="eff_vs_pt_ttbar/FTAG_PhysValWebPage.html"> Efficiency versus pT </a> </li> </td></tr> '
158 mypage +=
' <li> <a href="eff_vs_pt_Zprime/FTAG_PhysValWebPage.html"> Efficiency versus pT </a> </li> </td></tr> '
159 mypage +=
"</table></html>"
162 hs =
open(
"FTAG_PhysVal.html",
'w')
164 print(
"See "+folder+
"/FTAG_PhysVal.html")