~chris-rogers/maus/xboa

« back to all changes in this revision

Viewing changes to bin/utilities/geometry_validation.py

  • Committer: Chris Rogers
  • Date: 2014-10-18 08:06:10 UTC
  • mfrom: (782.1.8 1567)
  • Revision ID: chris.rogers@stfc.ac.uk-20141018080610-ch2fy1jlfc4mxqf7
Closes 1569 - geometry download fails from bad geometry

Show diffs side-by-side

added added

removed removed

Lines of Context:
225
225
        draw_list = step_data.keys()
226
226
        draw_list = self.move(draw_list, "G4_AIR", 0)
227
227
        draw_list = self.move(draw_list, "G4_Galactic", 1)
228
 
        x_list, z_list = [], []
 
228
        black_x_list, black_y_list = [], []
 
229
        grey_x_list, grey_y_list = [], []
229
230
        canvas = common.make_root_canvas("Material vs z")
230
231
        hist = ROOT.TH2D("name", "Material vs z", 30000, z_range[0], z_range[1],
231
232
                         len(draw_list)+1, -0.5, len(draw_list)+0.5)
232
233
        common._hist_persistent.append(hist) #pylint: disable=W0212
233
234
        for material in draw_list:
234
 
            hist.Fill(0., material, 1.)
 
235
            hist.Fill(z_range[0], material, 1.)
235
236
        hist.SetBit(ROOT.TH1.kCanRebin)
236
237
        hist.SetStats(0)
237
238
        hist.LabelsDeflate("Y")
238
239
        hist.LabelsOption("v")
239
240
        hist.Draw()
240
 
        for material in draw_list:
241
 
            x_list += [step["r"] for step in step_data[material] \
242
 
                                                            if step["r"] < 1e-9]
243
 
            z_list += [step["z"] for step in step_data[material] \
244
 
                                                            if step["r"] < 1e-9]
245
 
        if len(x_list) != len(z_list) or len(x_list) == 0:
246
 
            print "Detected no steps on axis, aborting 1d plot"
247
 
        hist, graph = common.make_root_graph("", z_list, "z [mm]",
248
 
                                               x_list, "r [mm]")
249
 
        common._graph_persistent.append(graph) #pylint: disable=W0212
 
241
        for i, material in enumerate(draw_list):
 
242
            grey_x_list += [i+0.1 for step in step_data[material]]
 
243
            grey_y_list += [step["z"] for step in step_data[material]]
 
244
            black_x_list += [i for step in step_data[material] \
 
245
                                                        if step["r"] < 1e-9]
 
246
            black_y_list += [step["z"] for step in step_data[material] \
 
247
                                                        if step["r"] < 1e-9]
 
248
 
 
249
        if len(grey_x_list) == 0:
 
250
            return
 
251
        hist, graph = common.make_root_graph("", grey_y_list, "z [mm]",
 
252
                                               grey_x_list, "material index")
 
253
        graph.SetMarkerColor(ROOT.TColor.GetColor(0.5, 0.5, 0.5))
250
254
        graph.SetMarkerStyle(7)
251
255
        graph.Draw('p')
 
256
        if len(black_x_list) != 0:
 
257
            hist, graph = common.make_root_graph("", black_y_list, "z [mm]",
 
258
                                                 black_x_list, "material index")
 
259
            graph.SetMarkerStyle(7)
 
260
            graph.Draw('p')
252
261
        canvas.Update()
253
262
        for _format in self.formats:
254
263
            canvas.Print(self.mat_1d+"."+_format)
277
286
                        self.volume_data[volume]["z_max"]]
278
287
            y_list = [i+0.1, i+0.1]
279
288
            hist, graph = common.make_root_graph("", x_list, "z [mm]",
280
 
                                                   y_list, "material index")
 
289
                                                   y_list, "volume index")
281
290
            graph.SetLineColor(ROOT.TColor.GetColor(0.5, 0.5, 0.5))
282
291
            graph.Draw('l')
283
292
            if self.volume_data[volume]["r_min"] < 1e-9: