11 from Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.classes
import MonitorData, PedeDumpData
12 from Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.geometry
import Alignables, Structure
22 def create(alignables, pedeDump, additionalData, outputFile, config):
23 logger = logging.getLogger(
"mpsvalidate")
26 with open(os.path.join(config.mpspath,
"tex_template.tex"),
"r") as template:
27 data = template.read()
38 out +=
"""\\begin{{titlepage}}
41 \Huge\\bfseries Alignment Validation\par
43 \scshape\huge Alignment Campaign\\\\ {{{0}}}\par
48 \\newpage""".
format(config.message)
50 out +=
"""\\begin{titlepage}
53 \Huge\\bfseries Alignment Validation\par
62 out +=
"\section{{General information}}\n"
65 out +=
"Project: {{{0}}}\\\\\n".
format(config.message)
66 out +=
"Input-Path:\n"
67 out +=
"\\begin{verbatim}\n"
68 out += config.jobDataPath+
"\n"
69 out +=
"\\end{verbatim}\n"
73 out +=
"\subsection{Alignment Configuration}\n"
74 out +=
"\\textbf{{PedeSteerer method:}} {{{0}}}\\\\\n".
format(
75 additionalData.pedeSteererMethod)
76 out +=
"\\textbf{{PedeSteerer options:}}\\\\\n"
77 for line
in additionalData.pedeSteererOptions:
78 out +=
"{{{0}}}\\\\\n".
format(line)
79 out +=
"\\textbf{{PedeSteerer command:}} {0}\\\\\n".
format(
80 additionalData.pedeSteererCommand)
82 for selector
in additionalData.pattern:
83 out +=
"\\textbf{{{0}:}}\\\\\n".
format(additionalData.pattern[selector][3])
84 for line
in additionalData.pattern[selector][0]:
88 for line
in additionalData.pattern[selector][2]:
89 out +=
"{0}\\\\\n".
format(line)
91 except Exception
as e:
92 logger.error(
"data not found - {0} {1}".
format(type(e), e))
95 if (config.showmonitor):
96 out +=
"\subsection{Datasets with tracks}\n"
97 out +=
"""\\begin{table}[h]
99 \caption{Datasets with tracks}
102 Dataset & Number of used tracks \\\\
104 for monitor
in MonitorData.monitors:
105 out +=
"{0} & {1}\\\\\n".
format(monitor.name, monitor.ntracks)
108 out +=
"Number of records & {0}\\\\\n".
format(pedeDump.nrec)
109 except Exception
as e:
110 logger.error(
"data not found - {0} {1}".
format(type(e), e))
114 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"
117 if (config.showdump == 1):
118 out +=
"\subsection{{Pede monitoring information}}\n"
119 if (pedeDump.sumValue != 0):
120 out +=
r"\begin{{align*}}Sum(Chi^2)/Sum(Ndf) &= {0}\\ &= {1}\end{{align*}}".
format(
121 pedeDump.sumSteps, pedeDump.sumValue)
123 out +=
r"\begin{{align*}}Sum(W*Chi^2)/Sum(Ndf)/<W> &= {0}\\ &= {1}\end{{align*}}".
format(
124 pedeDump.sumSteps, pedeDump.sumWValue)
125 out +=
r"with correction for down-weighting: {0}\\".
format(
127 out +=
r"Peak dynamic memory allocation: {0} GB\\".
format(
129 out +=
r"Total time: {0} h {1} m {2} s\\".
format(
130 pedeDump.time[0], pedeDump.time[1], pedeDump.time[2])
131 out +=
r"Number of records: {0}\\".
format(pedeDump.nrec)
132 out +=
r"Total number of parameters: {0}\\".
format(pedeDump.ntgb)
133 out +=
r"Number of variable parameters: {0}\\".
format(pedeDump.nvgb)
135 for line
in pedeDump.warning:
138 if line.replace(
r" ",
r""):
139 out +=
"\\begin{verbatim}\n"
141 out +=
"\\end{verbatim}\n"
143 out +=
"\section{{Parameter plots}}\n"
144 except Exception
as e:
145 logger.error(
"data not found - {0} {1}".
format(type(e), e))
148 if (config.showhighlevel == 1):
149 big = [x
for x
in config.outputList
if (x.plottype ==
"big")]
152 out +=
"\subsection{{High-level parameters}}\n"
154 out +=
"\includegraphics[width=\linewidth]{{{0}/plots/pdf/{1}.pdf}}\n".
format(
155 config.outputPath, i.filename)
158 if (config.showtime == 1):
159 time = [x
for x
in config.outputList
if (x.plottype ==
"time")]
162 out +=
"\subsection{{High-level parameters versus time (IOV)}}\n"
164 for structure
in [x.name
for x
in time
if x.parameter ==
"xyz"]:
165 out +=
"\subsubsection{{{0}}}\n".
format(structure)
166 for mode
in [
"xyz",
"rot"]:
167 if any([x.filename
for x
in time
if (x.parameter == mode
and x.name == structure)]):
168 filename = [x.filename
for x
in time
if (x.parameter == mode
and x.name == structure)][0]
169 out +=
"\includegraphics[width=\linewidth]{{{0}/plots/pdf/{1}.pdf}}\n".
format(
170 config.outputPath, filename)
173 if (config.showmodule == 1):
175 if any(x
for x
in config.outputList
if (x.plottype ==
"mod" and x.number ==
"")):
176 out +=
"\subsection{{Module-level parameters}}\n"
179 for moduleName
in [x.name
for x
in alignables.structures]:
182 if any(x
for x
in config.outputList
if (x.plottype ==
"mod" and x.number ==
"" and x.name == moduleName)):
183 out +=
"\subsubsection{{{0}}}\n".
format(moduleName)
185 for mode
in [
"xyz",
"rot",
"dist"]:
188 module = [x
for x
in config.outputList
if (
189 x.plottype ==
"mod" and x.number ==
"" and x.name == moduleName
and x.parameter == mode)]
191 moduleSub = [x
for x
in config.outputList
if (
192 x.plottype ==
"subMod" and x.number !=
"" and x.name == moduleName
and x.parameter == mode)]
196 out +=
"\includegraphics[width=\linewidth]{{{0}/plots/pdf/{1}.pdf}}\n".
format(
197 config.outputPath, module[0].filename)
198 if (config.showsubmodule):
200 for plot
in moduleSub:
201 out +=
"\includegraphics[width=\linewidth]{{{0}/plots/pdf/{1}.pdf}}\n".
format(
202 config.outputPath, plot.filename)
205 if (config.showmonitor):
206 if any(x
for x
in config.outputList
if x.plottype ==
"monitor"):
207 out +=
"\section{{Monitor plots}}\n"
210 for plot
in [x
for x
in config.outputList
if x.plottype ==
"monitor"]:
212 if (lastdataset != plot.name):
213 out +=
"\subsection{{{0}}}\n".
format(plot.name)
214 lastdataset = plot.name
215 out +=
"\includegraphics[width=\linewidth]{{{0}/plots/pdf/{1}.pdf}}\n".
format(
216 config.outputPath, plot.filename)
218 data = data.substitute(out=out)
220 with open(os.path.join(config.outputPath, outputFile),
"w")
as output:
226 os.system(
"pdflatex -output-directory={0} {1}/{2}".
format(
227 config.outputPath, config.outputPath, outputFile))
bool any(const std::vector< T > &v, const T &what)