17 ROOT.PyConfig.IgnoreCommandLineOptions =
True 20 import Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.style
as mpsv_style
21 import Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.geometry
as mpsv_geometry
22 import Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.bigModule
as mpsv_bigModule
23 import Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.iniparser
as mpsv_iniparser
24 import Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.dumpparser
as mpsv_dumpparser
25 import Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.pdfCreator
as mpsv_pdfCreator
26 import Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.htmlCreator
as mpsv_htmlCreator
27 import Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.monitorPlot
as mpsv_monitorPlot
28 import Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.trackerTree
as mpsv_trackerTree
29 import Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.bigStructure
as mpsv_bigStructure
30 import Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.beamerCreator
as mpsv_beamerCreator
31 import Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.timeStructure
as mpsv_timeStructure
32 import Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.additionalparser
as mpsv_additionalparser
38 logging.basicConfig(level=logging.INFO, format=
"%(levelname)s %(asctime)s (%(pathname)s line %(lineno)d): %(message)s", datefmt=
"%H:%M:%S")
39 logger = logging.getLogger(
"mpsvalidate")
42 parser = argparse.ArgumentParser(description=
"Validate your Alignment.")
44 "-j",
"--job", help=
"chose jobmX directory (default: ini-file)", default=-1, type=int)
46 "-t",
"--time", help=
"chose MillePedeUser_X Tree (default: ini-file)", default=-1, type=int)
47 parser.add_argument(
"-i",
"--ini", help=
"specify a ini file")
48 parser.add_argument(
"-m",
"--message",
49 help=
"identification on every plot", default=
"")
50 parser.add_argument(
"-p",
"--jobdatapath",
51 help=
"path to the jobm directory", default=
"")
52 parser.add_argument(
"-o",
"--outputpath",
53 help=
"outputpath", default=
"")
54 parser.add_argument(
"-l",
"--logging",
55 help=
"if this argument is given a logging file (validation.log) is saved in the current directory", action=
"store_true")
56 parser.add_argument(
"-c",
"--copy",
57 help=
"creates a copy of the validation_user.ini file in the current directory", action=
"store_true")
58 args = parser.parse_args()
61 config = mpsv_iniparser.ConfigData()
65 handler = logging.FileHandler(
"validation.log", mode=
"w")
66 handler.setLevel(logging.DEBUG)
67 formatter = logging.Formatter(
"%(levelname)s %(asctime)s (%(pathname)s line %(lineno)d): %(message)s",
69 handler.setFormatter(formatter)
70 logger.addHandler(handler)
73 logger.info(
"start to parse the default.ini")
74 config.parseConfig(os.path.join(config.mpspath,
"templates",
75 "mpsvalidate_default.ini"))
79 logger.info(
"create copy of validation_user.ini in current directory")
80 shutil.copy2(os.path.join(config.mpspath,
"templates",
"mpsvalidate_default.ini"),
81 "validation_user.ini")
87 logger.info(
"start to parse the user ini: {0}".
format(args.ini))
88 config.parseConfig(args.ini)
91 config.parseParameter(args)
94 logger.info(
"create the output directories")
95 if not os.path.exists(os.path.join(config.outputPath,
"plots/pdf")):
96 os.makedirs(os.path.join(config.outputPath,
"plots/pdf"))
97 if not os.path.exists(os.path.join(config.outputPath,
"plots/png")):
98 os.makedirs(os.path.join(config.outputPath,
"plots/png"))
101 logger.info(
"try to open the root file: {0}".
format(os.path.join(config.jobDataPath,
"treeFile_merge.root")))
102 treeFile = ROOT.TFile(os.path.join(config.jobDataPath,
"treeFile_merge.root"))
103 MillePedeUser = treeFile.Get(
"MillePedeUser_{0}".
format(config.jobTime))
104 if not MillePedeUser:
105 logger.error(
"Could not open TTree File MillePedeUser_{0} in {1}".
format(
106 config.jobTime, os.path.join(config.jobDataPath,
"treeFile_merge.root")))
110 mpsv_style.setgstyle()
113 alignables = mpsv_geometry.Alignables(config)
116 mpsv_trackerTree.check(config)
122 if config.showmonitor:
124 logger.info(
"start to collect the plots of the millePedeMonitor_merge.root file")
125 mpsv_monitorPlot.plot(config)
126 except Exception
as e:
127 logging.error(
"millePedeMonitor_merge.root failure - {0} {1}".
format(type(e), e))
134 if config.showadditional:
135 logger.info(
"start to parse the alignment_merge.py file")
137 additionalData = mpsv_additionalparser.AdditionalData()
138 additionalData.parse(
139 config, os.path.join(config.jobDataPath,
"alignment_merge.py"))
140 except Exception
as e:
141 logging.error(
"alignment_merge.py parser failure - {0} {1}".
format(type(e), e))
150 logger.info(
"start to parse the pede.dump.gz file")
151 pedeDump = mpsv_dumpparser.parse(
152 os.path.join(config.jobDataPath,
"pede.dump.gz"), config)
153 except Exception
as e:
154 logging.error(
"pede.dump.gz parser failure - {0} {1}".
format(type(e), e))
163 logger.info(
"create the time dependent plots")
164 mpsv_timeStructure.plot(treeFile, alignables, config)
165 except Exception
as e:
166 logging.error(
"time dependent plots failure - {0} {1}".
format(type(e), e))
173 if config.showhighlevel:
175 logger.info(
"create the high level plots")
176 mpsv_bigStructure.plot(MillePedeUser, alignables, config)
177 except Exception
as e:
178 logging.error(
"high level plots failure - {0} {1}".
format(type(e), e))
186 if config.showmodule:
188 logger.info(
"create the module plots")
189 mpsv_bigModule.plot(MillePedeUser, alignables, config)
190 except Exception
as e:
191 logging.error(
"module plots failure - {0} {1}".
format(type(e), e))
200 logger.info(
"create the latex file")
201 mpsv_pdfCreator.create(alignables, pedeDump, additionalData,
202 config.latexfile, config)
203 except Exception
as e:
204 logging.error(
"latex creation failure - {0} {1}".
format(type(e), e))
207 if config.showbeamer:
209 logger.info(
"create the latex beamer file")
210 mpsv_beamerCreator.create(alignables, pedeDump, additionalData,
211 "beamer.tex", config)
212 except Exception
as e:
213 logging.error(
"beamer latex failure - {0} {1}".
format(type(e), e))
217 for extension
in [
"aux",
"log",
"nav",
"out",
"snm",
"toc"]:
218 extension =
"*." + extension
219 pattern = os.path.join(config.outputPath, extension)
220 logger.info(
"Remove temporary latex files: "+pattern)
221 map(os.remove, glob.glob(pattern))
225 logger.info(
"create the HTML file")
226 mpsv_htmlCreator.create(alignables, pedeDump, additionalData,
227 "html_file.html", config)
228 except Exception
as e:
229 logging.error(
"HTML creation failure - {0} {1}".
format(type(e), e))
232 if __name__ ==
"__main__":