CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 18 of file htmlCreator.py.

References any(), ConfigBuilder.dumpPython(), and submitPVValidationJobs.split().

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