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),
"", big.numberOfBins[i], 0, big.numberOfBins[i]))
43 big.histo[i].SetYTitle(
"#Delta"+big.xyz[i]+
" ["+big.unit+
"]")
45 big.histo[i].SetYTitle(
"#Delta"+big.xyz[i])
46 big.histo[i].SetStats(0)
47 big.histo[i].SetMarkerStyle(21)
48 big.histoAxis.append(big.histo[i].GetXaxis())
50 big.histoAxis[i].SetLabelSize(0.06)
51 big.histo[i].GetYaxis().SetTitleOffset(1.6)
54 big.title = TPaveLabel(
55 0.1, 0.8, 0.9, 0.9,
"High Level Structures {0}".
format(mode))
56 big.text = TPaveText(0.05, 0.1, 0.95, 0.75)
57 big.text.SetTextAlign(12)
60 limit = config.limit[mode]
63 big.text.AddText(
"max. shift {0}: {1:.2} {2}".
format(big.xyz[i],
float(big.maxShift[i]), big.unit))
64 if (
abs(big.maxShift[i]) > limit):
65 big.text.AddText(
"! {0} shift bigger than {1} {2}".
format(big.xyz[i], limit, big.unit))
67 big.text.AddText(
"max. shift {0}: {1:.2}".
format(big.xyz[i],
float(big.maxShift[i])))
68 if (
abs(big.maxShift[i]) > limit):
69 big.text.AddText(
"! {0} shift bigger than {1}".
format(big.xyz[i], limit))
72 for line
in MillePedeUser:
75 if (
abs(line.Par[big.data[i]]) != 999999):
77 big.histoAxis[i].SetBinLabel(
78 big.binPosition[i], alignables.get_name_by_objid(line.ObjId))
82 big.histo[i].SetBinContent(
83 big.binPosition[i], 10000 * line.Par[big.data[i]])
85 big.histo[i].SetBinContent(
86 big.binPosition[i], line.Par[big.data[i]])
87 big.binPosition[i] += 1
91 big.histoAxis[i].LabelsOption(
"v")
97 if (config.rangemodeHL ==
"all"):
99 big.usedRange[i] = big.maxShift[i]
102 if (config.rangemodeHL ==
"given"):
106 valuelist = config.rangexyzHL
108 valuelist = config.rangerotHL
111 for value
in valuelist:
113 if (
abs(big.maxShift[i]) < value):
114 big.usedRange[i] = value
117 if (
abs(big.maxShift[i]) > valuelist[-1]):
118 big.usedRange[i] = valuelist[-1]
121 if (config.samerangeHL == 1):
124 big.usedRange[i] =
max(
map(abs, big.usedRange))
127 if (config.rangemodeHL ==
"given"):
129 for binNumber
in range(1, big.numberOfBins[i] + 1):
130 if (
abs(big.histo[i].GetBinContent(binNumber)) > big.usedRange[i]):
131 big.hiddenEntries[i] += 1
135 if (big.hiddenEntries[i] != 0):
136 big.text.AddText(
"! {0}: {1} outlier !".
format(
137 big.xyz[i],
int(big.hiddenEntries[i])))
140 cBig = TCanvas(
"canvasBigStrucutres_{0}".
format(
141 mode),
"Parameter", 300, 0, 800, 600)
160 big.histo[i].SetLineColor(0)
161 big.histo[i].Draw(
"AXIS")
163 big.histo[i].GetYaxis().SetRangeUser(-1.1 *
164 abs(big.usedRange[i]), 1.1 *
abs(big.usedRange[i]))
167 copy[i] = TGraph(big.histo[i])
169 copy[i].SetMaximum(1.1 *
abs(big.usedRange[i]))
170 copy[i].SetMinimum(-1.1 *
abs(big.usedRange[i]))
172 copy[i].Draw(
"PSAME")
178 "{0}/plots/pdf/structures_{1}.pdf".
format(config.outputPath, mode))
181 image = TImage.Create()
184 "{0}/plots/png/structures_{1}.png".
format(config.outputPath, mode))
187 output = OutputData(plottype=
"big", parameter=mode,
188 filename=
"structures_{0}".
format(mode))
189 config.outputList.append(output)
192 gStyle.SetPadBottomMargin(0.1)
def plot(MillePedeUser, alignables, config)
Abs< T >::type abs(const T &t)
def identification(config)
creates the identification text in the top left corner