18 def plot(MillePedeUser, alignables, mode, struct, parentPlot, config):
19 logger = logging.getLogger(
"mpsvalidate")
24 if(parentPlot.histo[i].GetEntries() == 0):
40 for subStructNumber, subStruct
in enumerate(struct.get_children()):
41 plots.append(mpsv_classes.PlotData(mode))
44 plot = plots[subStructNumber]
48 plot.histo.append(ROOT.TH1F(
"{0} {1} {2}".
format(struct.get_name() +
" " + subStruct.get_name(), plot.xyz[
49 i], mode),
"Parameter {0}".
format(plot.xyz[i]), numberOfBins, -1000, 1000))
51 plot.histo.append(ROOT.TH1F(
"{0} {1} {2}".
format(struct.get_name() +
" " + subStruct.get_name(), plot.xyz[
52 i], mode),
"Parameter {0}".
format(plot.xyz[i]), numberOfBins, -0.1, 0.1))
54 plot.histo[i].SetLineColor(6)
55 plot.histo[i].SetStats(0)
58 plot.title = ROOT.TPaveLabel(
59 0.1, 0.8, 0.9, 0.9,
"Module: {0} {1}".
format(struct.get_name(), mode))
60 plot.text = ROOT.TPaveText(0.05, 0.1, 0.95, 0.75)
61 plot.text.SetTextAlign(12)
62 plot.text.SetTextSizePixels(20)
65 plots[subStructNumber] = plot
71 for line
in MillePedeUser:
74 for subStructNumber, subStruct
in enumerate(struct.get_children()):
76 plot = plots[subStructNumber]
79 if (subStruct.contains_detid(line.Id)):
81 if (
abs(line.Par[plot.data[i]]) != 999999):
85 10000 * line.Par[plot.data[i]])
87 plot.histo[i].
Fill(line.Par[plot.data[i]])
90 plots[subStructNumber] = plot
95 for subStructNumber, subStruct
in enumerate(struct.get_children()):
97 plot = plots[subStructNumber]
99 if (plot.histo[i].GetEntries() != 0
and plot.histo[i].GetStdDev() != 0):
101 binShift = parentPlot.usedRange[i]
105 for j
in range(1, numberOfBins // 2 - binShift):
106 plot.hiddenEntries[i] += plot.histo[i].GetBinContent(j)
108 for j
in range(numberOfBins // 2 + binShift, plot.histo[i].GetNbinsX()):
109 plot.hiddenEntries[i] += plot.histo[i].GetBinContent(j)
112 mergeNumberBins = binShift
114 if (mergeNumberBins != 0):
116 mergeNumberBins =
int(
117 2. * mergeNumberBins / config.numberofbins)
120 if (mergeNumberBins == 0):
122 while (numberOfBins % mergeNumberBins != 0
and mergeNumberBins != 1):
126 plot.histo[i] = plot.histo[i].
Rebin(mergeNumberBins)
131 plot.histo[i].GetXaxis().SetRange(
int(numberOfBins // (2 * mergeNumberBins) - binShift /
132 mergeNumberBins),
int(numberOfBins // (2 * mergeNumberBins) + binShift / mergeNumberBins))
135 plots[subStructNumber] = plot
141 canvas = ROOT.TCanvas(
"SubStruct_{0}_{1}".
format(
142 struct.get_name(), mode),
"Parameter", 300, 0, 800, 600)
146 parentPlot.title.Draw()
148 legend = ROOT.TLegend(0.05, 0.1, 0.95, 0.75)
156 if (parentPlot.histo[i].GetEntries() == 0):
160 parentPlot.histo[i].Scale(1. / parentPlot.histo[i].Integral())
161 maximum.append(parentPlot.histo[i].GetMaximum())
163 for subStructNumber, subStruct
in enumerate(struct.get_children()):
165 plot = plots[subStructNumber]
167 if (plot.histo[i].GetEntries() > 0):
168 plot.histo[i].Scale(1. / plot.histo[i].Integral())
169 maximum.append(plot.histo[i].GetMaximum())
172 plots[subStructNumber] = plot
175 parentPlot.histo[i].GetYaxis().SetRangeUser(0., 1.1 *
max(maximum))
176 parentPlot.histo[i].SetYTitle(
"normalized")
177 parentPlot.histo[i].Draw()
179 for subStructNumber, subStruct
in enumerate(struct.get_children()):
181 plot = plots[subStructNumber].histo[i]
183 plot.SetLineColorAlpha(subStructNumber + 2, 0.5)
186 legend.AddEntry(plot, subStruct.get_name(),
"l")
192 ident = mpsv_style.identification(config)
199 "{0}/plots/pdf/subModules_{1}_{2}.pdf".
format(config.outputPath, mode, struct.get_name()))
202 image = ROOT.TImage.Create()
203 image.FromPad(canvas)
205 "{0}/plots/png/subModules_{1}_{2}.png".
format(config.outputPath, mode, struct.get_name()))
208 output = mpsv_classes.OutputData(plottype=
"subMod", name=struct.get_name(), number=subStructNumber + 1,
209 parameter=mode, filename=
"subModules_{0}_{1}".
format(mode, struct.get_name()))
210 config.outputList.append(output)
211
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
Abs< T >::type abs(const T &t)
def plot(MillePedeUser, alignables, mode, struct, parentPlot, config)