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),
"Parameter {0}".
format(time.xyz[i]), len(listMillePedeUser), 0, len(listMillePedeUser)))
99 plots[-1].label = line.Id
100 plots[-1].objid = line.ObjId
102 plots[-1].histo[i].SetYTitle(time.unit)
103 plots[-1].histo[i].SetXTitle(
"IOV")
104 plots[-1].histo[i].SetStats(0)
105 plots[-1].histo[i].SetMarkerStyle(21)
107 plots[-1].histo[i].GetXaxis().SetLabelSize(0.06)
108 plots[-1].histo[i].GetYaxis().SetTitleOffset(1.6)
115 for treeNumber, tree
in enumerate(MillePedeUser):
117 if (line.ObjId != 1
and any(
abs(line.Par[time.data[i]]) != 999999
for i
in [0, 1, 2])):
120 if (plot.label == line.Id):
123 plot.histo[i].GetXaxis().SetBinLabel(
124 treeNumber + 1, str(listMillePedeUser[treeNumber]))
127 plot.histo[i].SetBinContent(
128 treeNumber + 1, 10000 * line.Par[plot.data[i]])
130 plot.histo[i].SetBinContent(
131 treeNumber + 1, line.Par[plot.data[i]])
137 maximum = [[0, 0, 0]
for x
in range(len(objids))]
138 minimum = [[0, 0, 0]
for x
in range(len(objids))]
140 for index, objid
in enumerate(objids):
142 if (plot.objid == objid):
145 if (plot.histo[i].GetMaximum() > maximum[index][i]):
146 maximum[index][i] = plot.histo[i].GetMaximum()
148 if (plot.histo[i].GetMinimum() < minimum[index][i]):
149 minimum[index][i] = plot.histo[i].GetMinimum()
156 for index, objid
in enumerate(objids):
158 canvas = TCanvas(
"canvasTimeBigStrucutres_{0}_{1}".
format(
159 mode, alignables.get_name_by_objid(objid)),
"Parameter", 300, 0, 800, 600)
163 title = TPaveLabel(0.1, 0.8, 0.9, 0.9,
"{0} over time {1}".
format(
164 alignables.get_name_by_objid(objid), mode))
166 legend = TLegend(0.05, 0.1, 0.95, 0.75)
183 if (plot.objid == objid):
185 if (config.rangemodeHL ==
"all"):
186 plot.usedRange[i] =
max(
187 abs(maximum[index][i]),
abs(minimum[index][i]))
190 if (config.rangemodeHL ==
"given"):
193 valuelist = config.rangexyzHL
195 valuelist = config.rangerotHL
198 for value
in valuelist:
200 if (
max(
abs(maximum[index][i]),
abs(minimum[index][i])) < value):
201 plot.usedRange[i] = value
204 if (
max(
abs(maximum[index][i]),
abs(minimum[index][i])) > valuelist[-1]):
205 plot.usedRange[i] = valuelist[-1]
214 if (plot.objid == objid):
216 if (config.samerangeHL == 1):
217 plot.usedRange[i] =
max(map(abs, plot.usedRange))
220 plot.histo[i].GetYaxis(
221 ).SetRangeUser(-1.2 *
abs(plot.usedRange[i]), 1.2 *
abs(plot.usedRange[i]))
223 plot.histo[i].SetLineColorAlpha(number + 2, 0.5)
224 plot.histo[i].SetMarkerColorAlpha(number + 2, 1)
227 plot.histo[i].SetLineColor(0)
228 plot.histo[i].Draw(
"PSAME")
231 copy.append(TGraph(plot.histo[i]))
233 copy[-1].SetMaximum(1.2 *
abs(plot.usedRange[i]))
234 copy[-1].SetMinimum(-1.2 *
abs(plot.usedRange[i]))
236 copy[-1].SetLineColorAlpha(number + 2, 0.5)
237 copy[-1].Draw(
"LPSAME")
241 plot.histo[i],
"{0}".
format(number))
250 canvas.Print(
"{0}/plots/pdf/timeStructures_{1}_{2}.pdf".
format(
251 config.outputPath, mode, alignables.get_name_by_objid(objid)))
254 image = TImage.Create()
255 image.FromPad(canvas)
256 image.WriteImage(
"{0}/plots/png/timeStructures_{1}_{2}.png".
format(
257 config.outputPath, mode, alignables.get_name_by_objid(objid)))
260 output = OutputData(plottype=
"time", name=alignables.get_name_by_objid(
261 objid), parameter=mode, filename=
"timeStructures_{0}_{1}".
format(mode, alignables.get_name_by_objid(objid)))
262 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)