10 from ROOT
import (TH1F, TCanvas, TGraph, TImage, TPaveLabel, TPaveText, TTree,
13 from Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.classes
import OutputData, PlotData
14 from Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.geometry
import Alignables, Structure
15 from Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.style
import identification
18 def plot(MillePedeUser, alignables, config):
19 logger = logging.getLogger(
"mpsvalidate")
22 gStyle.SetPadBottomMargin(0.25)
23 gStyle.SetOptStat(
"emrs")
25 for mode
in [
"xyz",
"rot"]:
29 for line
in MillePedeUser:
32 if (
abs(line.Par[big.data[i]]) != 999999):
34 line.Par[big.data[i]] *= 10000
35 big.numberOfBins[i] += 1
36 if (
abs(line.Par[big.data[i]]) >
abs(big.maxShift[i])):
37 big.maxShift[i] = line.Par[big.data[i]]
41 big.histo.append(TH1F(
"Big Structure {0} {1}".
format(big.xyz[i], mode),
"Parameter {0}".
format(
42 big.xyz[i]), big.numberOfBins[i], 0, big.numberOfBins[i]))
43 big.histo[i].SetYTitle(big.unit)
44 big.histo[i].SetStats(0)
45 big.histo[i].SetMarkerStyle(21)
46 big.histoAxis.append(big.histo[i].GetXaxis())
48 big.histoAxis[i].SetLabelSize(0.06)
49 big.histo[i].GetYaxis().SetTitleOffset(1.6)
52 big.title = TPaveLabel(
53 0.1, 0.8, 0.9, 0.9,
"High Level Structures {0}".
format(mode))
54 big.text = TPaveText(0.05, 0.1, 0.95, 0.75)
55 big.text.SetTextAlign(12)
58 limit = config.limit[mode]
60 big.text.AddText(
"max. shift {0}: {1:.2}".
format(
61 big.xyz[i], float(big.maxShift[i])))
62 if (
abs(big.maxShift[i]) > limit):
64 "! {0} shift bigger than {1} !".
format(big.xyz[i], limit))
67 for line
in MillePedeUser:
70 if (
abs(line.Par[big.data[i]]) != 999999):
72 big.histoAxis[i].SetBinLabel(
73 big.binPosition[i], alignables.get_name_by_objid(line.ObjId))
77 big.histo[i].SetBinContent(
78 big.binPosition[i], 10000 * line.Par[big.data[i]])
80 big.histo[i].SetBinContent(
81 big.binPosition[i], line.Par[big.data[i]])
82 big.binPosition[i] += 1
86 big.histoAxis[i].LabelsOption(
"v")
92 if (config.rangemodeHL ==
"all"):
94 big.usedRange[i] = big.maxShift[i]
97 if (config.rangemodeHL ==
"given"):
101 valuelist = config.rangexyzHL
103 valuelist = config.rangerotHL
106 for value
in valuelist:
108 if (
abs(big.maxShift[i]) < value):
109 big.usedRange[i] = value
112 if (
abs(big.maxShift[i]) > valuelist[-1]):
113 big.usedRange[i] = valuelist[-1]
116 if (config.samerangeHL == 1):
119 big.usedRange[i] =
max(map(abs, big.usedRange))
122 if (config.rangemodeHL ==
"given"):
124 for binNumber
in range(1, big.numberOfBins[i] + 1):
125 if (
abs(big.histo[i].GetBinContent(binNumber)) > big.usedRange[i]):
126 big.hiddenEntries[i] += 1
130 if (big.hiddenEntries[i] != 0):
131 big.text.AddText(
"! {0} {1} outlier !".
format(
132 big.xyz[i], int(big.hiddenEntries[i])))
135 cBig = TCanvas(
"canvasBigStrucutres_{0}".
format(
136 mode),
"Parameter", 300, 0, 800, 600)
155 big.histo[i].SetLineColor(0)
156 big.histo[i].Draw(
"P")
158 big.histo[i].GetYaxis().SetRangeUser(-1.1 *
159 abs(big.usedRange[i]), 1.1 *
abs(big.usedRange[i]))
162 copy[i] = TGraph(big.histo[i])
164 copy[i].SetMaximum(1.1 *
abs(big.usedRange[i]))
165 copy[i].SetMinimum(-1.1 *
abs(big.usedRange[i]))
167 copy[i].Draw(
"PSAME")
173 "{0}/plots/pdf/structures_{1}.pdf".
format(config.outputPath, mode))
176 image = TImage.Create()
179 "{0}/plots/png/structures_{1}.png".
format(config.outputPath, mode))
182 output = OutputData(plottype=
"big", parameter=mode,
183 filename=
"structures_{0}".
format(mode))
184 config.outputList.append(output)
187 gStyle.SetPadBottomMargin(0.1)
def identification
creates the identification text in the top left corner
Abs< T >::type abs(const T &t)