16 from ROOT
import PyConfig
17 PyConfig.IgnoreCommandLineOptions =
True 19 from ROOT
import (TH1F, TCanvas, TFile, TImage, TPaveLabel, TPaveText, TTree,
22 from Alignment.MillePedeAlignmentAlgorithm.mpsvalidate
import (additionalparser, beamerCreator, bigModule,
23 bigStructure, dumpparser, htmlCreator, monitorPlot,
24 pdfCreator, subModule, timeStructure, trackerTree)
25 from Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.classes
import OutputData, PedeDumpData, PlotData
26 from Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.geometry
import Alignables, Structure
27 from Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.iniparser
import ConfigData
28 from Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.style
import setgstyle
33 logging.basicConfig(level=logging.INFO, format=
"%(levelname)s %(asctime)s (%(pathname)s line %(lineno)d): %(message)s", datefmt=
"%H:%M:%S")
34 logger = logging.getLogger(
"mpsvalidate")
42 "-j",
"--job", help=
"chose jobmX directory (default: ini-file)", default=-1, type=int)
44 "-t",
"--time", help=
"chose MillePedeUser_X Tree (default: ini-file)", default=-1, type=int)
45 parser.add_argument(
"-i",
"--ini", help=
"specify a ini file", default=
"-1")
46 parser.add_argument(
"-m",
"--message",
47 help=
"identification on every plot", default=
"")
48 parser.add_argument(
"-p",
"--jobdatapath",
49 help=
"path to the jobm directory", default=
"")
50 parser.add_argument(
"-o",
"--outputpath",
51 help=
"outputpath", default=
"")
52 parser.add_argument(
"-l",
"--logging",
53 help=
"if this argument is given a logging file (validation.log) is saved in the current directory", action=
"store_true")
54 parser.add_argument(
"-c",
"--copy",
55 help=
"creates a copy of the validation_user.ini file in the current directory", action=
"store_true")
56 args = parser.parse_args()
63 handler = logging.FileHandler(
"validation.log", mode=
"w")
64 handler.setLevel(logging.DEBUG)
65 formatter = logging.Formatter(
"%(levelname)s %(asctime)s (%(pathname)s line %(lineno)d): %(message)s",
67 handler.setFormatter(formatter)
68 logger.addHandler(handler)
71 logger.info(
"start to parse the default.ini")
72 config.parseConfig(os.path.join(config.mpspath,
"default.ini"))
76 logger.info(
"create copy of validation_user.ini in current directory")
77 shutil.copy2(os.path.join(config.mpspath,
"default.ini"),
"validation_user.ini")
82 if (args.ini !=
"-1"):
83 logger.info(
"start to parse the user ini: {0}".
format(args.ini))
84 config.parseConfig(args.ini)
87 config.parseParameter(args)
90 logger.info(
"create the output directories")
91 if not os.path.exists(os.path.join(config.outputPath,
"plots/pdf")):
92 os.makedirs(os.path.join(config.outputPath,
"plots/pdf"))
93 if not os.path.exists(os.path.join(config.outputPath,
"plots/png")):
94 os.makedirs(os.path.join(config.outputPath,
"plots/png"))
97 logger.info(
"try to open the root file: {0}".
format(os.path.join(config.jobDataPath,
"treeFile_merge.root")))
98 treeFile = TFile(os.path.join(config.jobDataPath,
"treeFile_merge.root"))
99 MillePedeUser = treeFile.Get(
"MillePedeUser_{0}".
format(config.jobTime))
100 if not MillePedeUser:
101 logger.error(
"Could not open TTree File MillePedeUser_{0} in {1}".
format(
102 config.jobTime, os.path.join(config.jobDataPath,
"treeFile_merge.root")))
118 if (config.showmonitor == 1):
120 logger.info(
"start to collect the plots of the millePedeMonitor_merge.root file")
122 except Exception
as e:
123 logging.error(
"millePedeMonitor_merge.root failure - {0} {1}".
format(type(e), e))
130 if (config.showadditional == 1):
131 logger.info(
"start to parse the alignment_merge.py file")
134 additionalData.parse(
135 config, os.path.join(config.jobDataPath,
"alignment_merge.py"))
136 except Exception
as e:
137 logging.error(
"alignment_merge.py parser failure - {0} {1}".
format(type(e), e))
144 if (config.showdump == 1):
146 logger.info(
"start to parse the pede.dump.gz file")
148 os.path.join(config.jobDataPath,
"pede.dump.gz"), config)
149 except Exception
as e:
150 logging.error(
"pede.dump.gz parser failure - {0} {1}".
format(type(e), e))
157 if (config.showtime == 1):
159 logger.info(
"create the time dependent plots")
161 except Exception
as e:
162 logging.error(
"time dependent plots failure - {0} {1}".
format(type(e), e))
169 if (config.showhighlevel == 1):
171 logger.info(
"create the high level plots")
173 except Exception
as e:
174 logging.error(
"high level plots failure - {0} {1}".
format(type(e), e))
182 if (config.showmodule == 1):
184 logger.info(
"create the module plots")
186 except Exception
as e:
187 logging.error(
"module plots failure - {0} {1}".
format(type(e), e))
194 if (config.showtex == 1):
196 logger.info(
"create the latex file")
198 additionalData, config.latexfile, config)
199 except Exception
as e:
200 logging.error(
"latex creation failure - {0} {1}".
format(type(e), e))
203 if (config.showbeamer == 1):
205 logger.info(
"create the latex beamer file")
207 except Exception
as e:
208 logging.error(
"beamer latex failure - {0} {1}".
format(type(e), e))
212 for extension
in [
"aux",
"log",
"nav",
"out",
"snm",
"toc"]:
213 extension =
"*." + extension
214 pattern = os.path.join(config.outputPath, extension)
215 logger.info(
"Remove temporary latex files: "+pattern)
216 map(os.remove, glob.glob(pattern))
218 if (config.showhtml == 1):
220 logger.info(
"create the HTML file")
222 except Exception
as e:
223 logging.error(
"HTML creation failure - {0} {1}".
format(type(e), e))
226 if __name__ ==
"__main__":
std::vector< Alignable * > Alignables
def create(alignables, pedeDump, additionalData, outputFile, config)
def create(alignables, pedeDump, additionalData, outputFile, config)
def plot(MillePedeUser, alignables, config)
def plot(MillePedeUser, alignables, config)
def plot(treeFile, alignables, config)
def create(alignables, pedeDump, additionalData, outputFile, config)
def setgstyle()
set gstyle by https://github.com/mschrode/AwesomePlots/blob/master/Style.cc