19 def plot(treeFile, alignables, config):
20 logger = logging.getLogger(
"mpsvalidate")
22 for mode
in [
"xyz",
"rot"]:
24 time = mpsv_classes.PlotData(mode)
27 listMillePedeUser = []
29 for i
in range(config.firsttree, 101):
30 if (treeFile.GetListOfKeys().Contains(
"MillePedeUser_{0}".
format(i))):
31 listMillePedeUser.append(i)
34 for i
in listMillePedeUser:
35 MillePedeUser.append(treeFile.Get(
"MillePedeUser_{0}".
format(i)))
44 newlistMillePedeUser = []
46 for line
in MillePedeUser[0]:
47 if (line.ObjId != 1
and any(
abs(line.Par[time.data[i]]) != 999999
for i
in [0, 1, 2])):
49 newlistMillePedeUser.append(config.firsttree)
53 for ttreeNumber, ttree
in enumerate(MillePedeUser[1:]):
55 if (line.Id == first):
56 if (
any(
abs(line.Par[time.data[i]]) != 999999
for i
in [0, 1, 2])):
58 newlistMillePedeUser.append(
59 ttreeNumber + config.firsttree + 1)
62 listMillePedeUser = newlistMillePedeUser
66 for i
in listMillePedeUser:
67 MillePedeUser.append(treeFile.Get(
"MillePedeUser_{0}".
format(i)))
69 if not listMillePedeUser:
70 logger.error(
"Timeplots: no TTrees found")
74 logger.error(
"Timeplots: no TTree could be opened")
87 for line
in MillePedeUser[0]:
88 if (line.ObjId != 1
and any(
abs(line.Par[time.data[i]]) != 999999
for i
in [0, 1, 2])):
89 plots.append(mpsv_classes.PlotData(mode))
92 if (line.ObjId
not in objids):
93 objids.append(line.ObjId)
94 obj_names.append(
str(line.Name))
98 plots[-1].histo.append(ROOT.TH1F(
"Time Structure {0} {1} {2} {3}".
format(mode,
str(line.Name),
99 len(plots), i),
"", len(listMillePedeUser), 0, len(listMillePedeUser)))
100 plots[-1].label = line.Id
101 plots[-1].objid = line.ObjId
104 plots[-1].histo[i].SetYTitle(
"#Delta"+time.xyz[i]+
" ["+time.unit+
"]")
106 plots[-1].histo[i].SetYTitle(
"#Delta"+time.xyz[i])
107 plots[-1].histo[i].SetXTitle(
"IOV")
108 plots[-1].histo[i].SetStats(0)
109 plots[-1].histo[i].SetMarkerStyle(21)
111 plots[-1].histo[i].GetXaxis().SetLabelSize(0.08)
112 plots[-1].histo[i].GetYaxis().SetTitleOffset(1.6)
119 for treeNumber, tree
in enumerate(MillePedeUser):
121 if (line.ObjId != 1
and any(
abs(line.Par[time.data[i]]) != 999999
for i
in [0, 1, 2])):
124 if (plot.label == line.Id):
127 plot.histo[i].GetXaxis().SetBinLabel(
128 treeNumber + 1,
str(listMillePedeUser[treeNumber]))
131 plot.histo[i].SetBinContent(
132 treeNumber + 1, 10000 * line.Par[plot.data[i]])
134 plot.histo[i].SetBinContent(
135 treeNumber + 1, line.Par[plot.data[i]])
141 maximum = [[0, 0, 0]
for x
in range(len(objids))]
142 minimum = [[0, 0, 0]
for x
in range(len(objids))]
144 for index, objid
in enumerate(objids):
146 if (plot.objid == objid):
149 if (plot.histo[i].GetMaximum() > maximum[index][i]):
150 maximum[index][i] = plot.histo[i].GetMaximum()
152 if (plot.histo[i].GetMinimum() < minimum[index][i]):
153 minimum[index][i] = plot.histo[i].GetMinimum()
160 for index, objid
in enumerate(objids):
162 canvas = ROOT.TCanvas(
"canvasTimeBigStrucutres_{0}_{1}".
format(
163 mode, obj_names[index]),
"Parameter", 300, 0, 800, 600)
167 title = ROOT.TPaveLabel(0.1, 0.8, 0.9, 0.9,
"{0} over time {1}".
format(
168 obj_names[index], mode))
170 legend = ROOT.TLegend(0.05, 0.1, 0.95, 0.75)
177 ident = mpsv_style.identification(config)
187 if (plot.objid == objid):
189 if config.rangemodeHL ==
"all":
190 plot.usedRange[i] =
max(
191 abs(maximum[index][i]),
abs(minimum[index][i]))
194 if (config.rangemodeHL ==
"given"):
197 valuelist = config.rangexyzHL
199 valuelist = config.rangerotHL
202 for value
in valuelist:
204 if max(
abs(maximum[index][i]),
abs(minimum[index][i])) < value:
205 plot.usedRange[i] = value
208 if (
max(
abs(maximum[index][i]),
abs(minimum[index][i])) > valuelist[-1]):
209 plot.usedRange[i] = valuelist[-1]
218 if (plot.objid == objid):
220 if (config.samerangeHL == 1):
221 plot.usedRange[i] =
max(map(abs, plot.usedRange))
224 plot.histo[i].GetYaxis(
225 ).SetRangeUser(-1.2 *
abs(plot.usedRange[i]), 1.2 *
abs(plot.usedRange[i]))
227 plot.histo[i].SetLineColorAlpha(number + 2, 0.5)
228 plot.histo[i].SetMarkerColorAlpha(number + 2, 1)
231 plot.histo[i].SetLineColor(0)
232 plot.histo[i].Draw(
"PSAME")
235 copy.append(ROOT.TGraph(plot.histo[i]))
237 copy[-1].SetMaximum(1.2 *
abs(plot.usedRange[i]))
238 copy[-1].SetMinimum(-1.2 *
abs(plot.usedRange[i]))
240 copy[-1].SetLineColorAlpha(number + 2, 0.5)
241 copy[-1].Draw(
"LPSAME")
245 plot.histo[i],
"{0}".
format(number))
254 canvas.Print(
"{0}/plots/pdf/timeStructures_{1}_{2}.pdf".
format(
255 config.outputPath, mode, obj_names[index]))
258 image = ROOT.TImage.Create()
259 image.FromPad(canvas)
260 image.WriteImage(
"{0}/plots/png/timeStructures_{1}_{2}.png".
format(
261 config.outputPath, mode, obj_names[index]))
264 output = mpsv_classes.OutputData(plottype=
"time", name=obj_names[index],
265 parameter=mode, filename=
"timeStructures_{0}_{1}".
format(mode, obj_names[index]))
266 config.outputList.append(output)
bool any(const std::vector< T > &v, const T &what)
const uint16_t range(const Frame &aFrame)
Abs< T >::type abs(const T &t)