8 import Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.classes
as mpsv_classes
18 def create(alignables, pedeDump, additionalData, outputFile, config):
19 logger = logging.getLogger(
"mpsvalidate")
22 with open(os.path.join(config.mpspath,
"templates",
23 "mpsvalidate_tex_template.tex"))
as template:
24 data = template.read()
35 out +=
"""\\begin{{titlepage}} 38 \Huge\\bfseries Alignment Validation\par 40 \scshape\huge Alignment Campaign\\\\ {{{0}}}\par 45 \\newpage""".
format(config.message)
47 out +=
"""\\begin{titlepage} 50 \Huge\\bfseries Alignment Validation\par 59 out +=
"\section{{General information}}\n" 62 out +=
"Project: {{{0}}}\\\\\n".
format(config.message)
63 out +=
"Input-Path:\n" 64 out +=
"\\begin{verbatim}\n" 65 out += config.jobDataPath+
"\n" 66 out +=
"\\end{verbatim}\n" 70 out +=
"\subsection{Alignment Configuration}\n" 71 out +=
"\\textbf{{PedeSteerer method:}} {{{0}}}\\\\\n".
format(
72 additionalData.pede_steerer_method)
73 out +=
"\\textbf{{PedeSteerer options:}}\\\\\n" 74 for line
in additionalData.pede_steerer_options:
75 out +=
"{{{0}}}\\\\\n".
format(line)
76 out +=
"\\textbf{{PedeSteerer command:}} {0}\\\\\n".
format(
77 additionalData.pede_steerer_command)
79 for i
in sorted(additionalData.selectors):
80 out +=
"\\textbf{{{0}:}}\n".
format(additionalData.selectors[i][
"name"])
81 out +=
"\\begin{verbatim}\n" 82 for line
in additionalData.selectors[i][
"selector"].
dumpPython().
split(
"\n"):
84 out +=
"\\end{verbatim}\n" 86 if len(additionalData.iov_definition) > 0:
87 out +=
"\\textbf{{IOV defintion:}}\n" 88 out +=
"\\begin{verbatim}\n" 89 for line
in additionalData.iov_definition.dumpPython().
split(
"\n"):
91 out +=
"\\end{verbatim}\n\n" 94 except Exception
as e:
95 logger.error(
"data not found - {0} {1}".
format(type(e), e))
98 if config.showmonitor:
99 out +=
"\subsection{Datasets with tracks}\n" 100 out +=
"""\\begin{table}[h] 102 \caption{Datasets with tracks} 103 \\begin{tabular}{ccc} 105 Dataset & Number of used tracks & Weight \\\\ 107 for monitor
in mpsv_classes.MonitorData.monitors:
108 out +=
"{0} & {1} & {2}\\\\\n".
format(monitor.name, monitor.ntracks,
109 monitor.weight
if monitor.weight !=
None else "--")
112 out +=
"\hline\nNumber of records & {0}\\\\\n".
format(pedeDump.nrec)
113 except Exception
as e:
114 logger.error(
"data not found - {0} {1}".
format(type(e), e))
118 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" 122 out +=
"\subsection{{Pede monitoring information}}\n" 123 if (pedeDump.sumValue != 0):
124 out +=
r"\begin{{align*}}Sum(Chi^2)/Sum(Ndf) &= {0}\\ &= {1}\end{{align*}}".
format(
125 pedeDump.sumSteps, pedeDump.sumValue)
127 out +=
r"\begin{{align*}}Sum(W*Chi^2)/Sum(Ndf)/<W> &= {0}\\ &= {1}\end{{align*}}".
format(
128 pedeDump.sumSteps, pedeDump.sumWValue)
129 out +=
r"with correction for down-weighting: {0}\\".
format(
131 out +=
r"Peak dynamic memory allocation: {0} GB\\".
format(
133 out +=
r"Total time: {0} h {1} m {2} s\\".
format(
134 pedeDump.time[0], pedeDump.time[1], pedeDump.time[2])
135 out +=
r"Number of records: {0}\\".
format(pedeDump.nrec)
136 out +=
r"Total number of parameters: {0}\\".
format(pedeDump.ntgb)
137 out +=
r"Number of variable parameters: {0}\\".
format(pedeDump.nvgb)
139 for line
in pedeDump.warning:
142 if line.replace(
r" ",
r""):
143 out +=
"\\begin{verbatim}\n" 145 out +=
"\\end{verbatim}\n" 147 out +=
"\section{{Parameter plots}}\n" 148 except Exception
as e:
149 logger.error(
"data not found - {0} {1}".
format(type(e), e))
152 if config.showhighlevel:
153 big = [x
for x
in config.outputList
if (x.plottype ==
"big")]
156 out +=
"\subsection{{High-level parameters}}\n" 158 out +=
"\includegraphics[width=\linewidth]{{{0}/plots/pdf/{1}.pdf}}\n".
format(
159 config.outputPath, i.filename)
163 time = [x
for x
in config.outputList
if (x.plottype ==
"time")]
166 out +=
"\subsection{{High-level parameters versus time (IOV)}}\n" 168 for structure
in [x.name
for x
in time
if x.parameter ==
"xyz"]:
169 out +=
"\subsubsection{{{0}}}\n".
format(structure)
170 for mode
in [
"xyz",
"rot"]:
171 if any([x.filename
for x
in time
if (x.parameter == mode
and x.name == structure)]):
172 filename = [x.filename
for x
in time
if (x.parameter == mode
and x.name == structure)][0]
173 out +=
"\includegraphics[width=\linewidth]{{{0}/plots/pdf/{1}.pdf}}\n".
format(
174 config.outputPath, filename)
177 if config.showmodule:
179 if any(x
for x
in config.outputList
if (x.plottype ==
"mod" and x.number ==
"")):
180 out +=
"\subsection{{Module-level parameters}}\n" 183 for moduleName
in [x.name
for x
in alignables.structures]:
186 if any(x
for x
in config.outputList
if (x.plottype ==
"mod" and x.number ==
"" and x.name == moduleName)):
187 out +=
"\subsubsection{{{0}}}\n".
format(moduleName)
189 for mode
in [
"xyz",
"rot",
"dist"]:
192 module = [x
for x
in config.outputList
if (
193 x.plottype ==
"mod" and x.number ==
"" and x.name == moduleName
and x.parameter == mode)]
195 moduleSub = [x
for x
in config.outputList
if (
196 x.plottype ==
"subMod" and x.number !=
"" and x.name == moduleName
and x.parameter == mode)]
200 out +=
"\includegraphics[width=\linewidth]{{{0}/plots/pdf/{1}.pdf}}\n".
format(
201 config.outputPath, module[0].filename)
202 if config.showsubmodule:
204 for plot
in moduleSub:
205 out +=
"\includegraphics[width=\linewidth]{{{0}/plots/pdf/{1}.pdf}}\n".
format(
206 config.outputPath, plot.filename)
209 if config.showmonitor:
210 if any(x
for x
in config.outputList
if x.plottype ==
"monitor"):
211 out +=
"\section{{Monitor plots}}\n" 214 for plot
in [x
for x
in config.outputList
if x.plottype ==
"monitor"]:
216 if (lastdataset != plot.name):
217 out +=
"\subsection{{{0}}}\n".
format(plot.name)
218 lastdataset = plot.name
219 out +=
"\includegraphics[width=\linewidth]{{{0}/plots/pdf/{1}.pdf}}\n".
format(
220 config.outputPath, plot.filename)
222 data = data.substitute(out=out)
224 with open(os.path.join(config.outputPath, outputFile),
"w")
as output:
230 os.system(
"pdflatex -output-directory={0} {1}/{2}".
format(
231 config.outputPath, config.outputPath, outputFile))
bool any(const std::vector< T > &v, const T &what)
def dumpPython(process, name)
def create(alignables, pedeDump, additionalData, outputFile, config)