20 def plot(treeFile, alignables, config):
21 logger = logging.getLogger(
"mpsvalidate")
23 for mode
in [
"xyz",
"rot"]:
28 listMillePedeUser = []
30 for i
in range(config.firsttree, 101):
31 if (treeFile.GetListOfKeys().Contains(
"MillePedeUser_{0}".
format(i))):
32 listMillePedeUser.append(i)
35 for i
in listMillePedeUser:
36 MillePedeUser.append(treeFile.Get(
"MillePedeUser_{0}".
format(i)))
45 newlistMillePedeUser = []
47 for line
in MillePedeUser[0]:
48 if (line.ObjId != 1
and any(
abs(line.Par[time.data[i]]) != 999999
for i
in [0, 1, 2])):
50 newlistMillePedeUser.append(config.firsttree)
54 for ttreeNumber, ttree
in enumerate(MillePedeUser[1:]):
56 if (line.Id == first):
57 if (
any(
abs(line.Par[time.data[i]]) != 999999
for i
in [0, 1, 2])):
59 newlistMillePedeUser.append(
60 ttreeNumber + config.firsttree + 1)
63 listMillePedeUser = newlistMillePedeUser
67 for i
in listMillePedeUser:
68 MillePedeUser.append(treeFile.Get(
"MillePedeUser_{0}".
format(i)))
70 if not listMillePedeUser:
71 logger.error(
"Timeplots: no TTrees found")
75 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(PlotData(mode))
92 if (line.ObjId
not in objids):
93 objids.append(line.ObjId)
97 plots[-1].histo.append(TH1F(
"Time Structure {0} {1} {2} {3}".
format(mode, alignables.get_name_by_objid(
98 line.ObjId), 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 = TCanvas(
"canvasTimeBigStrucutres_{0}_{1}".
format(
162 mode, alignables.get_name_by_objid(objid)),
"Parameter", 300, 0, 800, 600)
166 title = TPaveLabel(0.1, 0.8, 0.9, 0.9,
"{0} over time {1}".
format(
167 alignables.get_name_by_objid(objid), mode))
169 legend = TLegend(0.05, 0.1, 0.95, 0.75)
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(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, alignables.get_name_by_objid(objid)))
257 image = TImage.Create()
258 image.FromPad(canvas)
259 image.WriteImage(
"{0}/plots/png/timeStructures_{1}_{2}.png".
format(
260 config.outputPath, mode, alignables.get_name_by_objid(objid)))
263 output = OutputData(plottype=
"time", name=alignables.get_name_by_objid(
264 objid), parameter=mode, filename=
"timeStructures_{0}_{1}".
format(mode, alignables.get_name_by_objid(objid)))
265 config.outputList.append(output)
def identification
creates the identification text in the top left corner
bool any(const std::vector< T > &v, const T &what)
Abs< T >::type abs(const T &t)