File indexing completed on 2024-09-26 05:05:37
0001
0002
0003
0004
0005 from builtins import range
0006 import logging
0007 import os
0008 import string
0009 import Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.classes as mpsv_classes
0010
0011
0012
0013
0014
0015 class TexTemplate(string.Template):
0016 delimiter = "%%"
0017
0018
0019 class Out:
0020
0021 def __init__(self):
0022 self.text = ""
0023
0024 def addSlide(self, head, text):
0025 self.text += "\\begin{{frame}}[t]{{{0}}}\n".format(head)
0026 self.text += text
0027 self.text += """\\vfill
0028 \\rule{0.9\\paperwidth}{1pt}
0029 \\insertnavigation{0.89\\paperwidth}
0030 \\end{frame}\n"""
0031
0032 def addSlide_fragile(self, head, text):
0033 self.text += "\\begin{{frame}}[fragile=singleslide]{{{0}}}\n".format(head)
0034 self.text += text
0035 self.text += """\\vfill
0036 \\rule{0.9\\paperwidth}{1pt}
0037 \\insertnavigation{0.89\\paperwidth}
0038 \\end{frame}\n"""
0039
0040 def add(self, text):
0041 self.text += text + "\n"
0042
0043
0044 def create(alignables, pedeDump, additionalData, outputFile, config):
0045 logger = logging.getLogger("mpsvalidate")
0046
0047
0048 with open(os.path.join(config.mpspath, "templates",
0049 "mpsvalidate_beamer_template.tex")) as template:
0050 data = template.read()
0051 template.close()
0052
0053
0054 data = TexTemplate(data)
0055
0056
0057 out = Out()
0058 text = ""
0059
0060
0061 if (config.message):
0062 text += """\\centering
0063 \\vspace*{{4cm}}
0064 \\Huge\\bfseries Alignment Validation\\par
0065 \\vspace{{2cm}}
0066 \\scshape\\huge Alignment Campaign\\\\ {{{0}}}\\par
0067 \\vfill
0068 \\large \\today\\par""".format(config.message)
0069 else:
0070 text += """\\centering
0071 \\vspace*{4cm}
0072 \\Huge\\bfseries Alignment Validation\\par
0073 \\vfill
0074 \\large \\today\\par"""
0075 out.addSlide("", text)
0076
0077
0078 text = "\\tableofcontents"
0079 out.addSlide("Overview", text)
0080
0081
0082 out.add("\\section{General information}")
0083 text = ""
0084 if (config.message):
0085 text = "Project: {{{0}}}\\\\\n".format(config.message)
0086 text += "Input-Path:\n"
0087 text += "\\begin{verbatim}\n"
0088 text += config.jobDataPath+"\n"
0089 text += "\\end{verbatim}\n"
0090 out.addSlide_fragile("General information", text)
0091
0092
0093 try:
0094 out.add("\\subsection{Alignment Configuration}")
0095 text = "\\textbf{{PedeSteerer method:}} {{{0}}}\\\\\n".format(
0096 additionalData.pede_steerer_method)
0097 text += "\\textbf{{PedeSteerer options:}}\\\\\n"
0098 for line in additionalData.pede_steerer_options:
0099 text += "{{{0}}}\\\\\n".format(line)
0100 text += "\\textbf{{PedeSteerer command:}} {0}\\\\\n".format(
0101 additionalData.pede_steerer_command)
0102 out.addSlide("Alignment Configuration", text)
0103 except Exception as e:
0104 logger.error("data not found - {0} {1}".format(type(e), e))
0105
0106
0107 if config.showmonitor:
0108 out.add("\\subsection{Datasets with tracks}")
0109 text = """\\begin{table}[h]
0110 \\centering
0111 \\caption{Datasets with tracks}
0112 \\begin{tabular}{ccc}
0113 \\hline
0114 Dataset & Number of used tracks & Weight \\\\
0115 \\hline \n"""
0116 try:
0117 for monitor in mpsv_classes.MonitorData.monitors:
0118 text += "{0} & {1} & {2}\\\\\n".format(monitor.name, monitor.ntracks,
0119 monitor.weight if monitor.weight != None else "--")
0120 except Exception as e:
0121 logger.error("data not found - {0} {1}".format(type(e), e))
0122 if (pedeDump.nrec):
0123 text += "\\hline\nNumber of records & {0}\\\\\n".format(pedeDump.nrec)
0124 text += """\\hline
0125 \\end{tabular}\n
0126 \\end{table}\n"""
0127 text += "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"
0128 out.addSlide("Datasets with tracks", text)
0129
0130
0131 out.add("\\subsection{Pede monitoring information}")
0132 try:
0133 if (pedeDump.sumValue != 0):
0134 text = r"\begin{{align*}}Sum(Chi^2)/Sum(Ndf) &= {0}\\ &= {1}\end{{align*}}".format(
0135 pedeDump.sumSteps, pedeDump.sumValue)
0136 else:
0137 text = r"\begin{{align*}}Sum(W*Chi^2)/Sum(Ndf)/<W> &= {0}\\ &= {1}\end{{align*}}".format(
0138 pedeDump.sumSteps, pedeDump.sumWValue)
0139 text += r"with correction for down-weighting: {0}\\".format(
0140 pedeDump.correction)
0141 text += r"Peak dynamic memory allocation: {0} GB\\".format(pedeDump.memory)
0142 text += r"Total time: {0} h {1} m {2} s\\".format(
0143 pedeDump.time[0], pedeDump.time[1], pedeDump.time[2])
0144 text += r"Number of records: {0}\\".format(pedeDump.nrec)
0145 text += r"Total number of parameters: {0}\\".format(pedeDump.ntgb)
0146 text += r"Number of variable parameters: {0}\\".format(pedeDump.nvgb)
0147 out.addSlide("Pede monitoring information", text)
0148 except Exception as e:
0149 logger.error("data not found - {0} {1}".format(type(e), e))
0150
0151
0152 out.add("\\section{Parameter plots}")
0153
0154
0155 out.add("\\subsection{High-level parameters}")
0156 big = [x for x in config.outputList if (x.plottype == "big")]
0157
0158 for i in big:
0159 text = "\\includegraphics[height=0.85\\textheight]{{{0}/plots/pdf/{1}.pdf}}\n".format(
0160 config.outputPath, i.filename)
0161
0162 out.addSlide("High-level parameters", text)
0163
0164
0165 out.add("\\subsection{High-level parameters versus time (IOV)}")
0166 time = [x for x in config.outputList if (x.plottype == "time")]
0167
0168 if time:
0169
0170 for structure in [x.name for x in time if x.parameter == "xyz"]:
0171 for mode in ["xyz", "rot"]:
0172 text = "\\framesubtitle{{{0}}}\n".format(structure)
0173 if any([x.filename for x in time if (x.parameter == mode and x.name == structure)]):
0174 filename = [x.filename for x in time if (x.parameter == mode and x.name == structure)][0]
0175 text += "\\includegraphics[height=0.85\\textheight]{{{0}/plots/pdf/{1}.pdf}}\n".format(
0176 config.outputPath, filename)
0177
0178 out.addSlide("High-level parameters versus time (IOV)", text)
0179
0180
0181 out.add("\\subsection{Module-level parameters}")
0182
0183 if any(x for x in config.outputList if (x.plottype == "mod" and x.number == "")):
0184
0185
0186 for moduleName in [x.name for x in alignables.structures]:
0187
0188
0189 if any(x for x in config.outputList if (x.plottype == "mod" and x.number == "" and x.name == moduleName)):
0190
0191
0192 for mode in ["xyz", "rot", "dist"]:
0193
0194
0195 module = [x for x in config.outputList if (
0196 x.plottype == "mod" and x.number == "" and x.name == moduleName and x.parameter == mode)]
0197
0198 moduleSub = [x for x in config.outputList if (
0199 x.plottype == "subMod" and x.number != "" and x.name == moduleName and x.parameter == mode)]
0200
0201
0202 if module:
0203 text = "\\framesubtitle{{{0}}}\n".format(moduleName)
0204 text += "\\includegraphics[height=0.85\\textheight]{{{0}/plots/pdf/{1}.pdf}}\n".format(
0205 config.outputPath, module[0].filename)
0206
0207 out.addSlide("Module-level parameters", text)
0208
0209
0210 for plot in moduleSub:
0211 text = "\\framesubtitle{{{0}}}\n".format(
0212 moduleName)
0213 text += "\\includegraphics[height=0.85\\textheight]{{{0}/plots/pdf/{1}.pdf}}\n".format(
0214 config.outputPath, plot.filename)
0215
0216 out.addSlide("Module-level parameters", text)
0217
0218
0219 out.add("\\section{Monitor plots}")
0220 for plot in [x for x in config.outputList if x.plottype == "monitor"]:
0221 text = "\\framesubtitle{{{0}}}\n".format(plot.name)
0222 text += "\\includegraphics[height=0.85\\textheight]{{{0}/plots/pdf/{1}.pdf}}\n".format(
0223 config.outputPath, plot.filename)
0224 out.addSlide("Monitor", text)
0225
0226 data = data.substitute(out=out.text)
0227
0228 with open(os.path.join(config.outputPath, outputFile), "w") as output:
0229 output.write(data)
0230 output.close()
0231
0232
0233 for i in range(2):
0234 os.system("pdflatex -output-directory={0} {1}/{2}".format(
0235 config.outputPath, config.outputPath, outputFile))