18 def plot(treeFile, alignables, config):
19 logger = logging.getLogger(
"mpsvalidate")
21 for mode
in [
"xyz",
"rot"]:
23 time = mpsv_classes.PlotData(mode)
26 listMillePedeUser = []
28 for i
in range(config.firsttree, 101):
29 if (treeFile.GetListOfKeys().Contains(
"MillePedeUser_{0}".
format(i))):
30 listMillePedeUser.append(i)
33 for i
in listMillePedeUser:
34 MillePedeUser.append(treeFile.Get(
"MillePedeUser_{0}".
format(i)))
43 newlistMillePedeUser = []
45 for line
in MillePedeUser[0]:
46 if (line.ObjId != 1
and any(
abs(line.Par[time.data[i]]) != 999999
for i
in [0, 1, 2])):
48 newlistMillePedeUser.append(config.firsttree)
52 for ttreeNumber, ttree
in enumerate(MillePedeUser[1:]):
54 if (line.Id == first):
55 if (
any(
abs(line.Par[time.data[i]]) != 999999
for i
in [0, 1, 2])):
57 newlistMillePedeUser.append(
58 ttreeNumber + config.firsttree + 1)
61 listMillePedeUser = newlistMillePedeUser
65 for i
in listMillePedeUser:
66 MillePedeUser.append(treeFile.Get(
"MillePedeUser_{0}".
format(i)))
68 if not listMillePedeUser:
69 logger.error(
"Timeplots: no TTrees found")
73 logger.error(
"Timeplots: no TTree could be opened")
86 for line
in MillePedeUser[0]:
87 if (line.ObjId != 1
and any(
abs(line.Par[time.data[i]]) != 999999
for i
in [0, 1, 2])):
88 plots.append(mpsv_classes.PlotData(mode))
91 if (line.ObjId
not in objids):
92 objids.append(line.ObjId)
93 obj_names.append(
str(line.Name))
97 plots[-1].histo.append(ROOT.TH1F(
"Time Structure {0} {1} {2} {3}".
format(mode,
str(line.Name),
98 len(plots), i),
"", len(listMillePedeUser), 0, len(listMillePedeUser)))
99 plots[-1].label = line.Id
100 plots[-1].objid = line.ObjId
103 plots[-1].histo[i].SetYTitle(
"#Delta"+time.xyz[i]+
" ["+time.unit+
"]")
105 plots[-1].histo[i].SetYTitle(
"#Delta"+time.xyz[i])
106 plots[-1].histo[i].SetXTitle(
"IOV")
107 plots[-1].histo[i].SetStats(0)
108 plots[-1].histo[i].SetMarkerStyle(21)
110 plots[-1].histo[i].GetXaxis().SetLabelSize(0.08)
111 plots[-1].histo[i].GetYaxis().SetTitleOffset(1.6)
118 for treeNumber, tree
in enumerate(MillePedeUser):
120 if (line.ObjId != 1
and any(
abs(line.Par[time.data[i]]) != 999999
for i
in [0, 1, 2])):
123 if (plot.label == line.Id):
126 plot.histo[i].GetXaxis().SetBinLabel(
127 treeNumber + 1,
str(listMillePedeUser[treeNumber]))
130 plot.histo[i].SetBinContent(
131 treeNumber + 1, 10000 * line.Par[plot.data[i]])
133 plot.histo[i].SetBinContent(
134 treeNumber + 1, line.Par[plot.data[i]])
140 maximum = [[0, 0, 0]
for x
in range(len(objids))]
141 minimum = [[0, 0, 0]
for x
in range(len(objids))]
143 for index, objid
in enumerate(objids):
145 if (plot.objid == objid):
148 if (plot.histo[i].GetMaximum() > maximum[index][i]):
149 maximum[index][i] = plot.histo[i].GetMaximum()
151 if (plot.histo[i].GetMinimum() < minimum[index][i]):
152 minimum[index][i] = plot.histo[i].GetMinimum()
159 for index, objid
in enumerate(objids):
161 canvas = ROOT.TCanvas(
"canvasTimeBigStrucutres_{0}_{1}".
format(
162 mode, obj_names[index]),
"Parameter", 300, 0, 800, 600)
166 title = ROOT.TPaveLabel(0.1, 0.8, 0.9, 0.9,
"{0} over time {1}".
format(
167 obj_names[index], mode))
169 legend = ROOT.TLegend(0.05, 0.1, 0.95, 0.75)
176 ident = mpsv_style.identification(config)
186 if (plot.objid == objid):
188 if config.rangemodeHL ==
"all":
189 plot.usedRange[i] =
max(
190 abs(maximum[index][i]),
abs(minimum[index][i]))
193 if (config.rangemodeHL ==
"given"):
196 valuelist = config.rangexyzHL
198 valuelist = config.rangerotHL
201 for value
in valuelist:
203 if max(
abs(maximum[index][i]),
abs(minimum[index][i])) < value:
204 plot.usedRange[i] = value
207 if (
max(
abs(maximum[index][i]),
abs(minimum[index][i])) > valuelist[-1]):
208 plot.usedRange[i] = valuelist[-1]
217 if (plot.objid == objid):
219 if (config.samerangeHL == 1):
220 plot.usedRange[i] =
max(
map(abs, plot.usedRange))
223 plot.histo[i].GetYaxis(
224 ).SetRangeUser(-1.2 *
abs(plot.usedRange[i]), 1.2 *
abs(plot.usedRange[i]))
226 plot.histo[i].SetLineColorAlpha(number + 2, 0.5)
227 plot.histo[i].SetMarkerColorAlpha(number + 2, 1)
230 plot.histo[i].SetLineColor(0)
231 plot.histo[i].Draw(
"PSAME")
234 copy.append(ROOT.TGraph(plot.histo[i]))
236 copy[-1].SetMaximum(1.2 *
abs(plot.usedRange[i]))
237 copy[-1].SetMinimum(-1.2 *
abs(plot.usedRange[i]))
239 copy[-1].SetLineColorAlpha(number + 2, 0.5)
240 copy[-1].Draw(
"LPSAME")
244 plot.histo[i],
"{0}".
format(number))
253 canvas.Print(
"{0}/plots/pdf/timeStructures_{1}_{2}.pdf".
format(
254 config.outputPath, mode, obj_names[index]))
257 image = ROOT.TImage.Create()
258 image.FromPad(canvas)
259 image.WriteImage(
"{0}/plots/png/timeStructures_{1}_{2}.png".
format(
260 config.outputPath, mode, obj_names[index]))
263 output = mpsv_classes.OutputData(plottype=
"time", name=obj_names[index],
264 parameter=mode, filename=
"timeStructures_{0}_{1}".
format(mode, obj_names[index]))
265 config.outputList.append(output)
266 bool any(const std::vector< T > &v, const T &what)
Abs< T >::type abs(const T &t)
def plot(treeFile, alignables, config)