8 import cPickle
as pickle
13 ROOT.PyConfig.IgnoreCommandLineOptions =
True
16 import Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.style
as mpsv_style
17 import Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.classes
as mpsv_classes
21 logger = logging.getLogger(
"mpsvalidate")
25 ROOT.gStyle.SetOptStat(
"emrs")
26 ROOT.gStyle.SetPadLeftMargin(0.07)
29 with open(os.path.join(config.jobDataPath,
".weights.pkl"),
"rb")
as f:
30 weight_conf = pickle.load(f)
33 for filename
in os.listdir(
"{0}".
format(config.jobDataPath)):
34 if (filename.endswith(
".root")
and filename.startswith(
"millepedemonitor_")):
36 inputname = os.path.splitext(filename.split(
"millepedemonitor_")[-1])[0]
39 rootfile = ROOT.TFile(os.path.join(config.jobDataPath, filename))
41 plotPaths = [
"usedTrackHists/usedptTrack",
"usedTrackHists/usedetaTrack",
42 "usedTrackHists/usedphiTrack",
"usedTrackHists/usednHitTrack"]
45 for plotNumber, plotPath
in enumerate(plotPaths):
47 plotName = plotPath.split(
"/")[1]
49 plot = rootfile.Get(plotPath)
53 ntracks = int(plot.GetEntries())
55 for item
in weight_conf
56 if item[0] == inputname][0]
57 mpsv_classes.MonitorData(inputname.replace(
"_",
" "), ntracks, weight)
60 canvas = ROOT.TCanvas(
"canvas{0}_{1}".
format(
61 inputname, plotName),
"Monitor", 300, 0, 800, 600)
65 mpsv_style.setstatsize(canvas, plot, config)
72 "{0}/plots/pdf/monitor_{1}_{2}.pdf".
format(config.outputPath, inputname.replace(
".",
"_"), plotName))
75 image = ROOT.TImage.Create()
78 "{0}/plots/png/monitor_{1}_{2}.png".
format(config.outputPath, inputname.replace(
".",
"_"), plotName))
81 output = mpsv_classes.OutputData(plottype=
"monitor", name=inputname.replace(
"_",
" "), number=plotName, filename=
"monitor_{1}_{2}".
format(
82 config.outputPath, inputname.replace(
".",
"_"), plotName))
83 config.outputList.append(output)
86 ROOT.gStyle.SetOptStat(0)
87 ROOT.gStyle.SetPadLeftMargin(0.17)