34 logging.basicConfig(level=logging.INFO, format=
"%(levelname)s %(asctime)s (%(pathname)s line %(lineno)d): %(message)s", datefmt=
"%H:%M:%S")
35 logger = logging.getLogger(
"mpsvalidate")
43 "-j",
"--job", help=
"chose jobmX directory (default: ini-file)", default=-1, type=int)
45 "-t",
"--time", help=
"chose MillePedeUser_X Tree (default: ini-file)", default=-1, type=int)
46 parser.add_argument(
"-i",
"--ini", help=
"specify a ini file", default=
"-1")
47 parser.add_argument(
"-m",
"--message",
48 help=
"identification on every plot", default=
"")
49 parser.add_argument(
"-p",
"--jobdatapath",
50 help=
"path to the jobm directory", default=
"")
51 parser.add_argument(
"-o",
"--outputpath",
52 help=
"outputpath", default=
"")
53 parser.add_argument(
"-l",
"--logging",
54 help=
"if this argument is given a logging file (validation.log) is saved in the current directory", action=
"store_true")
55 parser.add_argument(
"-c",
"--copy",
56 help=
"creates a copy of the validation_user.ini file in the current directory", action=
"store_true")
57 args = parser.parse_args()
64 handler = logging.FileHandler(
"validation.log", mode=
"w")
65 handler.setLevel(logging.DEBUG)
66 formatter = logging.Formatter(
"%(levelname)s %(asctime)s (%(pathname)s line %(lineno)d): %(message)s",
68 handler.setFormatter(formatter)
69 logger.addHandler(handler)
72 logger.info(
"start to parse the default.ini")
73 config.parseConfig(os.path.join(config.mpspath,
"default.ini"))
77 logger.info(
"create copy of validation_user.ini in current directory")
78 shutil.copy2(os.path.join(config.mpspath,
"default.ini"),
"validation_user.ini")
83 if (args.ini !=
"-1"):
84 logger.info(
"start to parse the user ini: {0}".
format(args.ini))
85 config.parseConfig(args.ini)
88 config.parseParameter(args)
91 logger.info(
"create the output directories")
92 if not os.path.exists(os.path.join(config.outputPath,
"plots/pdf")):
93 os.makedirs(os.path.join(config.outputPath,
"plots/pdf"))
94 if not os.path.exists(os.path.join(config.outputPath,
"plots/png")):
95 os.makedirs(os.path.join(config.outputPath,
"plots/png"))
98 logger.info(
"try to open the root file: {0}".
format(os.path.join(config.jobDataPath,
"treeFile_merge.root")))
99 treeFile = TFile(os.path.join(config.jobDataPath,
"treeFile_merge.root"))
100 MillePedeUser = treeFile.Get(
"MillePedeUser_{0}".
format(config.jobTime))
101 if not MillePedeUser:
102 logger.error(
"Could not open TTree File MillePedeUser_{0} in {1}".
format(
103 config.jobTime, os.path.join(config.jobDataPath,
"treeFile_merge.root")))
119 if (config.showmonitor == 1):
121 logger.info(
"start to collect the plots of the millePedeMonitor_merge.root file")
123 except Exception
as e:
124 logging.error(
"millePedeMonitor_merge.root failure - {0} {1}".
format(type(e), e))
131 if (config.showadditional == 1):
132 logger.info(
"start to parse the alignment_merge.py file")
135 additionalData.parse(
136 config, os.path.join(config.jobDataPath,
"alignment_merge.py"))
137 except Exception
as e:
138 logging.error(
"alignment_merge.py parser failure - {0} {1}".
format(type(e), e))
145 if (config.showdump == 1):
147 logger.info(
"start to parse the pede.dump.gz file")
149 os.path.join(config.jobDataPath,
"pede.dump.gz"), config)
150 except Exception
as e:
151 logging.error(
"pede.dump.gz parser failure - {0} {1}".
format(type(e), e))
158 if (config.showtime == 1):
160 logger.info(
"create the time dependent plots")
162 except Exception
as e:
163 logging.error(
"time dependent plots failure - {0} {1}".
format(type(e), e))
170 if (config.showhighlevel == 1):
172 logger.info(
"create the high level plots")
174 except Exception
as e:
175 logging.error(
"high level plots failure - {0} {1}".
format(type(e), e))
183 if (config.showmodule == 1):
185 logger.info(
"create the module plots")
187 except Exception
as e:
188 logging.error(
"module plots failure - {0} {1}".
format(type(e), e))
195 if (config.showtex == 1):
197 logger.info(
"create the latex file")
199 additionalData, config.latexfile, config)
200 except Exception
as e:
201 logging.error(
"latex creation failure - {0} {1}".
format(type(e), e))
204 if (config.showbeamer == 1):
206 logger.info(
"create the latex beamer file")
208 except Exception
as e:
209 logging.error(
"beamer latex failure - {0} {1}".
format(type(e), e))
213 for extension
in [
"aux",
"log",
"nav",
"out",
"snm",
"toc"]:
214 extension =
"*." + extension
215 pattern = os.path.join(config.outputPath, extension)
216 logger.info(
"Remove temporary latex files: "+pattern)
217 map(os.remove, glob.glob(pattern))
219 if (config.showhtml == 1):
221 logger.info(
"create the HTML file")
223 except Exception
as e:
224 logging.error(
"HTML creation failure - {0} {1}".
format(type(e), e))