19 def create(alignables, pedeDump, additionalData, outputFile, config):
20 logger = logging.getLogger(
"mpsvalidate")
23 with open(os.path.join(config.mpspath,
"templates",
24 "mpsvalidate_tex_template.tex"))
as template:
25 data = template.read()
29 data = TexTemplate(data)
36 out +=
"""\\begin{{titlepage}}
39 \Huge\\bfseries Alignment Validation\par
41 \scshape\huge Alignment Campaign\\\\ {{{0}}}\par
46 \\newpage""".
format(config.message)
48 out +=
"""\\begin{titlepage}
51 \Huge\\bfseries Alignment Validation\par
60 out +=
"\section{{General information}}\n"
63 out +=
"Project: {{{0}}}\\\\\n".
format(config.message)
64 out +=
"Input-Path:\n"
65 out +=
"\\begin{verbatim}\n"
66 out += config.jobDataPath+
"\n"
67 out +=
"\\end{verbatim}\n"
71 out +=
"\subsection{Alignment Configuration}\n"
72 out +=
"\\textbf{{PedeSteerer method:}} {{{0}}}\\\\\n".
format(
73 additionalData.pede_steerer_method)
74 out +=
"\\textbf{{PedeSteerer options:}}\\\\\n"
75 for line
in additionalData.pede_steerer_options:
76 out +=
"{{{0}}}\\\\\n".
format(line)
77 out +=
"\\textbf{{PedeSteerer command:}} {0}\\\\\n".
format(
78 additionalData.pede_steerer_command)
80 for i
in sorted(additionalData.selectors):
81 out +=
"\\textbf{{{0}:}}\n".
format(additionalData.selectors[i][
"name"])
82 out +=
"\\begin{verbatim}\n"
83 for line
in additionalData.selectors[i][
"selector"].
dumpPython().
split(
"\n"):
85 out +=
"\\end{verbatim}\n"
87 if len(additionalData.iov_definition) > 0:
88 out +=
"\\textbf{{IOV defintion:}}\n"
89 out +=
"\\begin{verbatim}\n"
90 for line
in additionalData.iov_definition.dumpPython().
split(
"\n"):
92 out +=
"\\end{verbatim}\n\n"
95 except Exception
as e:
96 logger.error(
"data not found - {0} {1}".
format(type(e), e))
99 if config.showmonitor:
100 out +=
"\subsection{Datasets with tracks}\n"
101 out +=
"""\\begin{table}[h]
103 \caption{Datasets with tracks}
104 \\begin{tabular}{ccc}
106 Dataset & Number of used tracks & Weight \\\\
108 for monitor
in mpsv_classes.MonitorData.monitors:
109 out +=
"{0} & {1} & {2}\\\\\n".
format(monitor.name, monitor.ntracks,
110 monitor.weight
if monitor.weight !=
None else "--")
113 out +=
"\hline\nNumber of records & {0}\\\\\n".
format(pedeDump.nrec)
114 except Exception
as e:
115 logger.error(
"data not found - {0} {1}".
format(type(e), e))
119 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.\n"
123 out +=
"\subsection{{Pede monitoring information}}\n"
124 if (pedeDump.sumValue != 0):
125 out +=
r"\begin{{align*}}Sum(Chi^2)/Sum(Ndf) &= {0}\\ &= {1}\end{{align*}}".
format(
126 pedeDump.sumSteps, pedeDump.sumValue)
128 out +=
r"\begin{{align*}}Sum(W*Chi^2)/Sum(Ndf)/<W> &= {0}\\ &= {1}\end{{align*}}".
format(
129 pedeDump.sumSteps, pedeDump.sumWValue)
130 out +=
r"with correction for down-weighting: {0}\\".
format(
132 out +=
r"Peak dynamic memory allocation: {0} GB\\".
format(
134 out +=
r"Total time: {0} h {1} m {2} s\\".
format(
135 pedeDump.time[0], pedeDump.time[1], pedeDump.time[2])
136 out +=
r"Number of records: {0}\\".
format(pedeDump.nrec)
137 out +=
r"Total number of parameters: {0}\\".
format(pedeDump.ntgb)
138 out +=
r"Number of variable parameters: {0}\\".
format(pedeDump.nvgb)
140 for line
in pedeDump.warning:
143 if line.replace(
r" ",
r""):
144 out +=
"\\begin{verbatim}\n"
146 out +=
"\\end{verbatim}\n"
148 out +=
"\section{{Parameter plots}}\n"
149 except Exception
as e:
150 logger.error(
"data not found - {0} {1}".
format(type(e), e))
153 if config.showhighlevel:
154 big = [x
for x
in config.outputList
if (x.plottype ==
"big")]
157 out +=
"\subsection{{High-level parameters}}\n"
159 out +=
"\includegraphics[width=\linewidth]{{{0}/plots/pdf/{1}.pdf}}\n".
format(
160 config.outputPath, i.filename)
164 time = [x
for x
in config.outputList
if (x.plottype ==
"time")]
167 out +=
"\subsection{{High-level parameters versus time (IOV)}}\n"
169 for structure
in [x.name
for x
in time
if x.parameter ==
"xyz"]:
170 out +=
"\subsubsection{{{0}}}\n".
format(structure)
171 for mode
in [
"xyz",
"rot"]:
172 if any([x.filename
for x
in time
if (x.parameter == mode
and x.name == structure)]):
173 filename = [x.filename
for x
in time
if (x.parameter == mode
and x.name == structure)][0]
174 out +=
"\includegraphics[width=\linewidth]{{{0}/plots/pdf/{1}.pdf}}\n".
format(
175 config.outputPath, filename)
178 if config.showmodule:
180 if any(x
for x
in config.outputList
if (x.plottype ==
"mod" and x.number ==
"")):
181 out +=
"\subsection{{Module-level parameters}}\n"
184 for moduleName
in [x.name
for x
in alignables.structures]:
187 if any(x
for x
in config.outputList
if (x.plottype ==
"mod" and x.number ==
"" and x.name == moduleName)):
188 out +=
"\subsubsection{{{0}}}\n".
format(moduleName)
190 for mode
in [
"xyz",
"rot",
"dist"]:
193 module = [x
for x
in config.outputList
if (
194 x.plottype ==
"mod" and x.number ==
"" and x.name == moduleName
and x.parameter == mode)]
196 moduleSub = [x
for x
in config.outputList
if (
197 x.plottype ==
"subMod" and x.number !=
"" and x.name == moduleName
and x.parameter == mode)]
201 out +=
"\includegraphics[width=\linewidth]{{{0}/plots/pdf/{1}.pdf}}\n".
format(
202 config.outputPath, module[0].filename)
203 if config.showsubmodule:
205 for plot
in moduleSub:
206 out +=
"\includegraphics[width=\linewidth]{{{0}/plots/pdf/{1}.pdf}}\n".
format(
207 config.outputPath, plot.filename)
210 if config.showmonitor:
211 if any(x
for x
in config.outputList
if x.plottype ==
"monitor"):
212 out +=
"\section{{Monitor plots}}\n"
215 for plot
in [x
for x
in config.outputList
if x.plottype ==
"monitor"]:
217 if (lastdataset != plot.name):
218 out +=
"\subsection{{{0}}}\n".
format(plot.name)
219 lastdataset = plot.name
220 out +=
"\includegraphics[width=\linewidth]{{{0}/plots/pdf/{1}.pdf}}\n".
format(
221 config.outputPath, plot.filename)
223 data = data.substitute(out=out)
225 with open(os.path.join(config.outputPath, outputFile),
"w")
as output:
231 os.system(
"pdflatex -output-directory={0} {1}/{2}".
format(
232 config.outputPath, config.outputPath, outputFile))