CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions
htmlCreator Namespace Reference

Classes

class  TexTemplate
 

Functions

def create
 

Function Documentation

def htmlCreator.create (   alignables,
  pedeDump,
  additionalData,
  outputFile,
  config 
)

Definition at line 22 of file htmlCreator.py.

References any().

Referenced by mps_validate.main().

22 
23 def create(alignables, pedeDump, additionalData, outputFile, config):
24  logger = logging.getLogger("mpsvalidate")
25 
26  # load template
27  with open(os.path.join(config.mpspath, "html_template.html"), "r") as template:
28  data = template.read()
29  template.close()
30 
31  # create object where data could be substituted
32  data = TexTemplate(data)
33 
34  # output string
35  out = ""
36 
37  # general information
38 
39  out += "<h1>General information</h1>\n"
40 
41  if (config.message):
42  out += "Project: {0}\n<br>".format(config.message)
43  out += "Input-Path: {0}\n<br>".format(config.jobDataPath)
44 
45  # alignment_merge.py
46  try:
47  out += "<h2>Alignment Configuration</h2>\n"
48  out += "<b>PedeSteerer method:</b> {0}<br>\n".format(
49  additionalData.pedeSteererMethod)
50  out += "<b>PedeSteerer options:</b>\n"
51  for line in additionalData.pedeSteererOptions:
52  out += "{0}<br>\n".format(line)
53  out += "<b>PedeSteerer command:</b> {0}<br>\n".format(
54  additionalData.pedeSteererCommand)
55 
56  for selector in additionalData.pattern:
57  out += "<b>{0}:</b><br>\n".format(additionalData.pattern[selector][3])
58  for line in additionalData.pattern[selector][0]:
59  for i in line:
60  out += "{0} ".format(i)
61  out += "<br>\n"
62  for line in additionalData.pattern[selector][2]:
63  out += "{0} \n".format(line)
64  out += "<br>\n"
65  except Exception as e:
66  logger.error("data not found - {0} {1}".format(type(e), e))
67 
68  # table of input files with number of tracks
69  if (config.showmonitor):
70  out += "<h2>Datasets with tracks</h2>\n"
71  out += """<table border="1">
72  <tr>
73  <th>Dataset</th>
74  <th>Number of used tracks</th>
75  <tr>"""
76  for monitor in MonitorData.monitors:
77  out += """<tr>
78  <th>{0}</th>
79  <th>{1}</th>
80  </tr>""".format(monitor.name, monitor.ntracks)
81  try:
82  if (pedeDump.nrec):
83  out += """<tr>
84  <th>Number of records</th>
85  <th>{0}</th>
86  </tr>""".format(pedeDump.nrec)
87  except Exception as e:
88  logger.error("data not found - {0} {1}".format(type(e), e))
89  out += """</table>"""
90  out += "The information in this table is based on the monitor root files. Note that the number of tracks which where used in the pede step can differ from this table."
91 
92  # pede.dump.gz
93  try:
94  out += "<h2>Pede monitoring information</h2>\n"
95  if (pedeDump.sumValue != 0):
96  out += r"<b>Sum(Chi^2)/Sum(Ndf)</b> &= {0}<br> &= {1}".format(
97  pedeDump.sumSteps, pedeDump.sumValue)
98  else:
99  out += r"<b>Sum(W*Chi^2)/Sum(Ndf)/<W></b> &= {0}<br> &= {1}".format(
100  pedeDump.sumSteps, pedeDump.sumWValue)
101  out += r"<b>with correction for down-weighting:</b> {0}<br>".format(
102  pedeDump.correction)
103  out += r"<b>Peak dynamic memory allocation:</b> {0} GB<br>".format(
104  pedeDump.memory)
105  out += r"<b>Total time:</b> {0} h {1} m {2} s<br>".format(
106  pedeDump.time[0], pedeDump.time[1], pedeDump.time[2])
107  out += r"<b>Number of records:</b> {0}<br>".format(pedeDump.nrec)
108  out += r"<b>Total number of parameters:</b> {0}<br>".format(pedeDump.ntgb)
109  out += r"<b>Number of variable parameters:</b> {0}<br>".format(pedeDump.nvgb)
110  out += r"<b>Warning:</b><br>"
111  for line in pedeDump.warning:
112 
113  # check if line empty
114  if line.replace(r" ", r""):
115  out += "{0}<br>\n".format(line)
116  except Exception as e:
117  logger.error("data not found - {0} {1}".format(type(e), e))
118 
119  # high level structures
120 
121  big = [x for x in config.outputList if (x.plottype == "big")]
122 
123  if big:
124  out += "<h1>High-level parameters</h1>\n"
125  for i in big:
126  out += "<a href='plots/pdf/{0}.pdf'><img src='plots/png/{0}.png'></a>\n".format(
127  i.filename)
128 
129  # time (IOV) dependent plots
130 
131  time = [x for x in config.outputList if (x.plottype == "time")]
132 
133  if time:
134  out += "<h1>High-level parameters versus time (IOV)</h1>\n"
135  # get list with names of the structures
136  for structure in [x.name for x in time if x.parameter == "xyz"]:
137  out += "<h2>{0}<h2>\n".format(structure)
138  for mode in ["xyz", "rot"]:
139  if any([x.filename for x in time if (x.parameter == mode and x.name == structure)]):
140  filename = [x.filename for x in time if (x.parameter == mode and x.name == structure)][0]
141  out += "<a href='plots/pdf/{0}.pdf'><img src='plots/png/{0}.png'></a>\n".format(
142  filename)
143 
144  # hole modules
145 
146  # check if there are module plots
147  if any(x for x in config.outputList if (x.plottype == "mod" and x.number == "")):
148  out += "<h1>Module-level parameters</h1>\n"
149 
150  # loop over all structures
151  for moduleName in [x.name for x in alignables.structures]:
152 
153  # check if there is a plot for this module
154  if any(x for x in config.outputList if (x.plottype == "mod" and x.number == "" and x.name == moduleName)):
155  out += "<h2>{0}</h2>\n".format(moduleName)
156 
157  # loop over modes
158  for mode in ["xyz", "rot", "dist"]:
159 
160  # get module plot
161  module = [x for x in config.outputList if (
162  x.plottype == "mod" and x.number == "" and x.name == moduleName and x.parameter == mode)]
163  # get list of sub module plots
164  moduleSub = [x for x in config.outputList if (
165  x.plottype == "subMod" and x.number != "" and x.name == moduleName and x.parameter == mode)]
166 
167  # check if plot there is a plot in this mode
168  if module:
169  out += "<a href='plots/pdf/{0}.pdf'><img src='plots/png/{0}.png'></a>\n".format(module[
170  0].filename)
171 
172  # loop over submodules
173  for plot in moduleSub:
174  out += "<a href='plots/pdf/{0}.pdf'><img src='plots/png/{0}.png'></a>\n".format(
175  plot.filename)
176 
177  # plot taken from the millePedeMonitor_merge.root file
178 
179  if any(x for x in config.outputList if x.plottype == "monitor"):
180  out += "<h1>Monitor</h1>\n"
181  for plot in [x for x in config.outputList if x.plottype == "monitor"]:
182  out += "<h3>{0}</h3>\n".format(plot.name)
183  out += "<a href='plots/pdf/{0}.pdf'><img src='plots/png/{0}.png'></a>\n".format(
184  plot.filename)
185 
186  data = data.substitute(message=config.message, out=out)
187 
188  with open(os.path.join(config.outputPath, outputFile), "w") as output:
189  output.write(data)
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:34