10 ROOT.PyConfig.IgnoreCommandLineOptions =
True 13 import Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.style
as mpsv_style
14 import Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.classes
as mpsv_classes
17 def plot(MillePedeUser, alignables, mode, struct, parentPlot, config):
18 logger = logging.getLogger(
"mpsvalidate")
23 if(parentPlot.histo[i].GetEntries() == 0):
39 for subStructNumber, subStruct
in enumerate(struct.get_children()):
40 plots.append(mpsv_classes.PlotData(mode))
43 plot = plots[subStructNumber]
47 plot.histo.append(ROOT.TH1F(
"{0} {1} {2}".
format(struct.get_name() +
" " + subStruct.get_name(), plot.xyz[
48 i], mode),
"Parameter {0}".
format(plot.xyz[i]), numberOfBins, -1000, 1000))
50 plot.histo.append(ROOT.TH1F(
"{0} {1} {2}".
format(struct.get_name() +
" " + subStruct.get_name(), plot.xyz[
51 i], mode),
"Parameter {0}".
format(plot.xyz[i]), numberOfBins, -0.1, 0.1))
53 plot.histo[i].SetLineColor(6)
54 plot.histo[i].SetStats(0)
57 plot.title = ROOT.TPaveLabel(
58 0.1, 0.8, 0.9, 0.9,
"Module: {0} {1}".
format(struct.get_name(), mode))
59 plot.text = ROOT.TPaveText(0.05, 0.1, 0.95, 0.75)
60 plot.text.SetTextAlign(12)
61 plot.text.SetTextSizePixels(20)
64 plots[subStructNumber] = plot
70 for line
in MillePedeUser:
73 for subStructNumber, subStruct
in enumerate(struct.get_children()):
75 plot = plots[subStructNumber]
78 if (subStruct.contains_detid(line.Id)):
80 if (
abs(line.Par[plot.data[i]]) != 999999):
84 10000 * line.Par[plot.data[i]])
86 plot.histo[i].
Fill(line.Par[plot.data[i]])
89 plots[subStructNumber] = plot
94 for subStructNumber, subStruct
in enumerate(struct.get_children()):
96 plot = plots[subStructNumber]
98 if (plot.histo[i].GetEntries() != 0
and plot.histo[i].GetStdDev() != 0):
100 binShift = parentPlot.usedRange[i]
104 for j
in range(1, numberOfBins / 2 - binShift):
105 plot.hiddenEntries[i] += plot.histo[i].GetBinContent(j)
107 for j
in range(numberOfBins / 2 + binShift, plot.histo[i].GetNbinsX()):
108 plot.hiddenEntries[i] += plot.histo[i].GetBinContent(j)
111 mergeNumberBins = binShift
113 if (mergeNumberBins != 0):
115 mergeNumberBins =
int(
116 2. * mergeNumberBins / config.numberofbins)
119 if (mergeNumberBins == 0):
121 while (numberOfBins % mergeNumberBins != 0
and mergeNumberBins != 1):
125 plot.histo[i] = plot.histo[i].
Rebin(mergeNumberBins)
130 plot.histo[i].GetXaxis().SetRange(
int(numberOfBins / (2 * mergeNumberBins) - binShift /
131 mergeNumberBins),
int(numberOfBins / (2 * mergeNumberBins) + binShift / mergeNumberBins))
134 plots[subStructNumber] = plot
140 canvas = ROOT.TCanvas(
"SubStruct_{0}_{1}".
format(
141 struct.get_name(), mode),
"Parameter", 300, 0, 800, 600)
145 parentPlot.title.Draw()
147 legend = ROOT.TLegend(0.05, 0.1, 0.95, 0.75)
155 if (parentPlot.histo[i].GetEntries() == 0):
159 parentPlot.histo[i].Scale(1. / parentPlot.histo[i].Integral())
160 maximum.append(parentPlot.histo[i].GetMaximum())
162 for subStructNumber, subStruct
in enumerate(struct.get_children()):
164 plot = plots[subStructNumber]
166 if (plot.histo[i].GetEntries() > 0):
167 plot.histo[i].Scale(1. / plot.histo[i].Integral())
168 maximum.append(plot.histo[i].GetMaximum())
171 plots[subStructNumber] = plot
174 parentPlot.histo[i].GetYaxis().SetRangeUser(0., 1.1 *
max(maximum))
175 parentPlot.histo[i].SetYTitle(
"normalized")
176 parentPlot.histo[i].Draw()
178 for subStructNumber, subStruct
in enumerate(struct.get_children()):
180 plot = plots[subStructNumber].histo[i]
182 plot.SetLineColorAlpha(subStructNumber + 2, 0.5)
185 legend.AddEntry(plot, subStruct.get_name(),
"l")
191 ident = mpsv_style.identification(config)
198 "{0}/plots/pdf/subModules_{1}_{2}.pdf".
format(config.outputPath, mode, struct.get_name()))
201 image = ROOT.TImage.Create()
202 image.FromPad(canvas)
204 "{0}/plots/png/subModules_{1}_{2}.png".
format(config.outputPath, mode, struct.get_name()))
207 output = mpsv_classes.OutputData(plottype=
"subMod", name=struct.get_name(), number=subStructNumber + 1,
208 parameter=mode, filename=
"subModules_{0}_{1}".
format(mode, struct.get_name()))
209 config.outputList.append(output)
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)