20 def plot(MillePedeUser, alignables, config):
21 logger = logging.getLogger(
"mpsvalidate")
23 alignables.create_list(MillePedeUser)
35 for modeNumber, mode
in enumerate([
"xyz",
"rot",
"dist"]):
38 for structNumber, struct
in enumerate(alignables.structures):
39 plots[modeNumber].
append(PlotData(mode))
42 for modeNumber, mode
in enumerate([
"xyz",
"rot",
"dist"]):
43 for structNumber, struct
in enumerate(alignables.structures):
45 plot = plots[modeNumber][structNumber]
49 plot.histo.append(TH1F(
"{0} {1} {2}".
format(struct.get_name(), plot.xyz[
50 i], mode),
"", numberOfBins, -1000, 1000))
52 plot.histo.append(TH1F(
"{0} {1} {2}".
format(struct.get_name(), plot.xyz[
53 i], mode),
"", numberOfBins, -0.1, 0.1))
56 plot.histo[i].SetXTitle(
"#Delta"+plot.xyz[i]+
" ["+plot.unit+
"]")
58 plot.histo[i].SetXTitle(
"#Delta"+plot.xyz[i])
59 plot.histo[i].SetYTitle(
"number of alignables")
60 plot.histo[i].GetXaxis().SetTitleOffset(0.8)
61 plot.histoAxis.append(plot.histo[i].GetXaxis())
64 plot.title = TPaveLabel(
65 0.1, 0.8, 0.9, 0.9,
"Module: {0} {1}".
format(struct.get_name(), mode))
66 plot.text = TPaveText(0.05, 0.1, 0.95, 0.75)
67 plot.text.SetTextAlign(12)
68 plot.text.SetTextSizePixels(20)
71 plots[modeNumber][structNumber] = plot
77 for line
in MillePedeUser:
80 for modeNumber, mode
in enumerate([
"xyz",
"rot",
"dist"]):
81 for structNumber, struct
in enumerate(alignables.structures):
83 plot = plots[modeNumber][structNumber]
86 if (struct.contains_detid(line.Id)):
88 if (
abs(line.Par[plot.data[i]]) != 999999):
92 10000 * line.Par[plot.data[i]])
94 plot.histo[i].
Fill(line.Par[plot.data[i]])
97 plots[modeNumber][structNumber] = plot
103 for modeNumber, mode
in enumerate([
"xyz",
"rot",
"dist"]):
104 for structNumber, struct
in enumerate(alignables.structures):
106 plot = plots[modeNumber][structNumber]
111 if (
abs(numberOfBins / 2 - plot.histo[i].FindFirstBinAbove()) >
abs(plot.histo[i].FindLastBinAbove() - numberOfBins / 2)):
112 plot.maxBinShift[i] =
abs(
113 numberOfBins / 2 - plot.histo[i].FindFirstBinAbove())
115 plot.maxShift[i] = plot.histo[i].GetBinCenter(
116 plot.histo[i].FindFirstBinAbove())
118 plot.maxBinShift[i] =
abs(
119 plot.histo[i].FindLastBinAbove() - numberOfBins / 2)
121 plot.maxShift[i] = plot.histo[i].GetBinCenter(
122 plot.histo[i].FindLastBinAbove())
124 if (
abs(plot.maxBinShift[i]) == numberOfBins / 2 + 1):
125 plot.maxBinShift[i] = 0
130 if (config.rangemode ==
"stddev"):
132 if (plot.histo[i].GetEntries() != 0
and plot.histo[i].GetStdDev() != 0):
135 if (
max(plot.maxShift) / plot.histo[i].GetStdDev() > config.defpeak):
137 binShift = int(plot.histo[i].FindBin(
138 config.widthstddev * plot.histo[i].GetStdDev()) - numberOfBins / 2)
140 binShift =
max(plot.maxBinShift)
143 plot.binShift[i] = binShift
146 if (config.rangemode ==
"all"):
148 plot.binShift[i] = plot.maxBinShift[i]
151 if (config.rangemode ==
"given"):
154 valuelist = config.rangexyzM
156 valuelist = config.rangerotM
158 valuelist = config.rangedistM
160 for value
in valuelist:
162 if (
abs(plot.maxShift[i]) < value):
166 if (
abs(plot.maxShift[i]) > valuelist[-1]):
167 binShift = valuelist[-1]
169 plot.binShift[i] = int(
170 binShift / plot.histo[i].GetBinWidth(1))
173 if (config.samerange == 1):
175 plot.binShift[i] =
max(plot.binShift)
179 plot.usedRange[i] = plot.binShift[i]
184 for j
in range(1, numberOfBins / 2 - plot.binShift[i]):
185 plot.hiddenEntries[i] += plot.histo[i].GetBinContent(j)
187 for j
in range(numberOfBins / 2 + plot.binShift[i], plot.histo[i].GetNbinsX()):
188 plot.hiddenEntries[i] += plot.histo[i].GetBinContent(j)
192 if (plot.histo[i].GetEntries() != 0):
195 mergeNumberBins = plot.binShift[i]
197 if (mergeNumberBins != 0):
199 mergeNumberBins = int(
200 2. * mergeNumberBins / config.numberofbins)
203 if (mergeNumberBins == 0):
205 while (numberOfBins % mergeNumberBins != 0
and mergeNumberBins != 1):
209 plot.histo[i] = plot.histo[i].
Rebin(mergeNumberBins)
210 plot.histoAxis[i] = plot.histo[i].GetXaxis()
215 plot.histoAxis[i].SetRange(int(numberOfBins / (2 * mergeNumberBins) - plot.binShift[
216 i] / mergeNumberBins), int(numberOfBins / (2 * mergeNumberBins) + plot.binShift[i] / mergeNumberBins))
219 limit = config.limit[mode]
222 if (plot.histo[i].GetEntries() > 0):
224 plot.text.AddText(
"max. shift {0}: {1:.2} {2}".
format(plot.xyz[i], plot.maxShift[i], plot.unit))
225 if (
abs(plot.maxShift[i]) > limit):
226 plot.text.AddText(
"! {0} shift bigger than {1} {2}".
format(plot.xyz[i], limit, plot.unit))
228 plot.text.AddText(
"max. shift {0}: {1:.2}".
format(plot.xyz[i], plot.maxShift[i]))
229 if (
abs(plot.maxShift[i]) > limit):
230 plot.text.AddText(
"! {0} shift bigger than {1}".
format(plot.xyz[i], limit))
232 if (plot.hiddenEntries[i] != 0):
233 plot.text.AddText(
"! {0}: {1} outlier !".
format(
234 plot.xyz[i], int(plot.hiddenEntries[i])))
237 plots[modeNumber][structNumber] = plot
244 gStyle.SetOptStat(
"emrs")
246 for modeNumber, mode
in enumerate([
"xyz",
"rot",
"dist"]):
247 for structNumber, struct
in enumerate(alignables.structures):
249 plot = plots[modeNumber][structNumber]
251 canvas = TCanvas(
"canvasModules{0}_{1}".
format(
252 struct.get_name(), mode),
"Parameter", 300, 0, 800, 600)
268 if(plot.histo[i].GetEntries() > 0):
272 plot.histo[i].DrawCopy()
274 if (plotNumber == 0):
281 "{0}/plots/pdf/modules_{1}_{2}.pdf".
format(config.outputPath, mode, struct.get_name()))
284 image = TImage.Create()
285 image.FromPad(canvas)
287 "{0}/plots/png/modules_{1}_{2}.png".
format(config.outputPath, mode, struct.get_name()))
290 output = OutputData(plottype=
"mod", name=struct.get_name(),
291 parameter=mode, filename=
"modules_{0}_{1}".
format(mode, struct.get_name()))
292 config.outputList.append(output)
298 if (config.showsubmodule == 1):
299 alignables.create_children_list()
300 for modeNumber, mode
in enumerate([
"xyz",
"rot",
"dist"]):
301 for structNumber, struct
in enumerate(alignables.structures):
303 plot = plots[modeNumber][structNumber]
306 mode, struct, plot, config)
def identification
creates the identification text in the top left corner
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
Abs< T >::type abs(const T &t)
def setstatsize
statistics size