39 logging.basicConfig(level=logging.INFO, format=
"%(levelname)s %(asctime)s (%(pathname)s line %(lineno)d): %(message)s", datefmt=
"%H:%M:%S")
40 logger = logging.getLogger(
"mpsvalidate")
43 parser = argparse.ArgumentParser(description=
"Validate your Alignment.")
45 "-j",
"--job", help=
"chose jobmX directory (default: ini-file)", default=-1, type=int)
47 "-t",
"--time", help=
"chose MillePedeUser_X Tree (default: ini-file)", default=-1, type=int)
48 parser.add_argument(
"-i",
"--ini", help=
"specify a ini file")
49 parser.add_argument(
"-m",
"--message",
50 help=
"identification on every plot", default=
"")
51 parser.add_argument(
"-p",
"--jobdatapath",
52 help=
"path to the jobm directory", default=
"")
53 parser.add_argument(
"-o",
"--outputpath",
54 help=
"outputpath", default=
"")
55 parser.add_argument(
"-l",
"--logging",
56 help=
"if this argument is given a logging file (validation.log) is saved in the current directory", action=
"store_true")
57 parser.add_argument(
"-c",
"--copy",
58 help=
"creates a copy of the validation_user.ini file in the current directory", action=
"store_true")
59 args = parser.parse_args()
62 config = mpsv_iniparser.ConfigData()
66 handler = logging.FileHandler(
"validation.log", mode=
"w")
67 handler.setLevel(logging.DEBUG)
68 formatter = logging.Formatter(
"%(levelname)s %(asctime)s (%(pathname)s line %(lineno)d): %(message)s",
70 handler.setFormatter(formatter)
71 logger.addHandler(handler)
74 logger.info(
"start to parse the default.ini")
75 config.parseConfig(os.path.join(config.mpspath,
"templates",
76 "mpsvalidate_default.ini"))
80 logger.info(
"create copy of validation_user.ini in current directory")
81 shutil.copy2(os.path.join(config.mpspath,
"templates",
"mpsvalidate_default.ini"),
82 "validation_user.ini")
88 logger.info(
"start to parse the user ini: {0}".
format(args.ini))
89 config.parseConfig(args.ini)
92 config.parseParameter(args)
95 logger.info(
"create the output directories")
96 if not os.path.exists(os.path.join(config.outputPath,
"plots/pdf")):
97 os.makedirs(os.path.join(config.outputPath,
"plots/pdf"))
98 if not os.path.exists(os.path.join(config.outputPath,
"plots/png")):
99 os.makedirs(os.path.join(config.outputPath,
"plots/png"))
102 logger.info(
"try to open the root file: {0}".
format(os.path.join(config.jobDataPath,
"treeFile_merge.root")))
103 treeFile = ROOT.TFile(os.path.join(config.jobDataPath,
"treeFile_merge.root"))
104 MillePedeUser = treeFile.Get(
"MillePedeUser_{0}".
format(config.jobTime))
105 if not MillePedeUser:
106 logger.error(
"Could not open TTree File MillePedeUser_{0} in {1}".
format(
107 config.jobTime, os.path.join(config.jobDataPath,
"treeFile_merge.root")))
111 mpsv_style.setgstyle()
114 alignables = mpsv_geometry.Alignables(config)
117 mpsv_trackerTree.check(config)
123 if config.showmonitor:
125 logger.info(
"start to collect the plots of the millePedeMonitor_merge.root file")
126 mpsv_monitorPlot.plot(config)
127 except Exception
as e:
128 logging.error(
"millePedeMonitor_merge.root failure - {0} {1}".
format(type(e), e))
135 if config.showadditional:
136 logger.info(
"start to parse the alignment_merge.py file")
138 additionalData = mpsv_additionalparser.AdditionalData()
139 additionalData.parse(
140 config, os.path.join(config.jobDataPath,
"alignment_merge.py"))
141 except Exception
as e:
142 logging.error(
"alignment_merge.py parser failure - {0} {1}".
format(type(e), e))
151 logger.info(
"start to parse the pede.dump.gz file")
152 pedeDump = mpsv_dumpparser.parse(
153 os.path.join(config.jobDataPath,
"pede.dump.gz"), config)
154 except Exception
as e:
155 logging.error(
"pede.dump.gz parser failure - {0} {1}".
format(type(e), e))
164 logger.info(
"create the time dependent plots")
165 mpsv_timeStructure.plot(treeFile, alignables, config)
166 except Exception
as e:
167 logging.error(
"time dependent plots failure - {0} {1}".
format(type(e), e))
174 if config.showhighlevel:
176 logger.info(
"create the high level plots")
177 mpsv_bigStructure.plot(MillePedeUser, alignables, config)
178 except Exception
as e:
179 logging.error(
"high level plots failure - {0} {1}".
format(type(e), e))
187 if config.showmodule:
189 logger.info(
"create the module plots")
190 mpsv_bigModule.plot(MillePedeUser, alignables, config)
191 except Exception
as e:
192 logging.error(
"module plots failure - {0} {1}".
format(type(e), e))
201 logger.info(
"create the latex file")
202 mpsv_pdfCreator.create(alignables, pedeDump, additionalData,
203 config.latexfile, config)
204 except Exception
as e:
205 logging.error(
"latex creation failure - {0} {1}".
format(type(e), e))
208 if config.showbeamer:
210 logger.info(
"create the latex beamer file")
211 mpsv_beamerCreator.create(alignables, pedeDump, additionalData,
212 "beamer.tex", config)
213 except Exception
as e:
214 logging.error(
"beamer latex failure - {0} {1}".
format(type(e), e))
218 for extension
in [
"aux",
"log",
"nav",
"out",
"snm",
"toc"]:
219 extension =
"*." + extension
220 pattern = os.path.join(config.outputPath, extension)
221 logger.info(
"Remove temporary latex files: "+pattern)
222 map(os.remove, glob.glob(pattern))
226 logger.info(
"create the HTML file")
227 mpsv_htmlCreator.create(alignables, pedeDump, additionalData,
228 "html_file.html", config)
229 except Exception
as e:
230 logging.error(
"HTML creation failure - {0} {1}".
format(type(e), e))