325def do_step(c, tree, outdir, events, geom_graph):
326 hm = HistManager()
327
328 hists = {}
329
330 def mkprofile(name, xlab, ylab, *args):
331 hists[name] = ROOT.TProfile(name, name, *args)
332 axislabels(hists[name], xlab, ylab)
333
334 mkprofile("theta_x0", '\\theta', "X_{0}", 40, 0, math.pi)
335 mkprofile("theta_dInX0", '\\theta', "t/X_{0}", 40, 0, math.pi)
336 mkprofile("theta_t", '\\theta', "t", 40, 0, math.pi)
337 mkprofile("theta_tTot", '\\theta', "t_{tot}", 40, 0, math.pi)
338
339 mkprofile("phi_x0", "\\phi", "X_{0}", 40, -math.pi, math.pi)
340 mkprofile("phi_dInX0", '\\phi', "t/X_{0}", 40, -math.pi, math.pi)
341 mkprofile("phi_t", '\\phi', 't', 40, -math.pi, math.pi)
342 mkprofile("phi_tTot", '\\phi', 't_{tot}', 40, -math.pi, math.pi)
343
344 mkprofile("eta_x0", '\\eta', 'X_{0}', 40, -4, 4)
345 mkprofile("eta_dInX0", '\\eta', 't/X_{0}', 40, -4, 4)
346 mkprofile("eta_t", '\\eta', 't', 40, -4, 4)
347 mkprofile("eta_tTot", '\\eta', 't_{tot}', 40, -4, 4)
348
349 nBinsEta = 80
350 nBinsPhi = 80
351 nBinsR = 200
352 nBinsZ = 500
353
354
355 hm.addHist2D("eta_phi/eta_phi_x0", nBinsEta, -4, 4, nBinsPhi, -math.pi, math.pi, "\\eta", "\\phi", average=True)
356 hm.addHist2D("eta_phi/eta_phi_dInX0", nBinsEta, -4, 4, nBinsPhi, -math.pi, math.pi, "\\eta", "\\phi", average=True)
357 hm.addHist2D("eta_phi/eta_phi_tTot", nBinsEta, -4, 4, nBinsPhi, -math.pi, math.pi, "\\eta", "\\phi", average=True)
358
359 hm.addHist2D("z_r/z_r_x0", nBinsZ, -3000, 3000, nBinsR, 0, 1200, "z [mm]", "r [mm]", "X_{0}", average=True)
360
361 for k, v in hists.iteritems():
362 style(v)
363
364 layers = {}
365
366
367 for idx, event in enumerate(tree):
368
369 if events:
370 if idx > events: break
371 if idx % 1000 == 0:
372 print(
"{} / {}".format(idx, tree.GetEntries()))
373
374
375 theta = event.theta
376 phi = event.phi
377
378 eta = - math.log(math.tan(theta/2))
379
380
381 tTot = 0
382
383 dInX0_tot = event.dInX0
384
385 totalX0 = 0
386
387 zipped = zip(event.step_t,
388 event.step_X0,
389 event.step_dInX0,
390 event.step_z,
391 event.step_r,
392 event.step_geo_id)
393 for t, x0, dInX0, z, r, _geo_id in zipped:
394 geo_id = GeometryID(_geo_id)
395
396 tTot += t
397 totalX0 += x0
398
399
400
401
402 lay_str = "vol_{}_lay_{}_app_{}".format(geo_id.vol_id, geo_id.lay_id, geo_id.app_id)
403 if _geo_id not in layers:
404 hname = lay_str+"_"+outdir+"_z_r"
405 layers[_geo_id] = ROOT.TH2D(hname, hname, nBinsZ/2, -3000, 3000, nBinsR/2, 0, 1200)
406
407 h2 = layers[_geo_id]
408
409 h2.Fill(z, r)
410
411 hm.fillHist2D("z_r/z_r_x0", z, r, x0)
412
413
414
415
416
417
418 hists["theta_x0"].Fill(theta, totalX0)
419 hists["phi_x0"].Fill(phi, totalX0)
420 hists["eta_x0"].Fill(eta, totalX0)
421
422 hm.fillHist2D("eta_phi/eta_phi_x0", eta, phi, totalX0)
423 hm.fillHist2D("eta_phi/eta_phi_tTot", eta, phi, tTot)
424 hm.fillHist2D("eta_phi/eta_phi_dInX0", eta, phi, dInX0_tot)
425
426 hists["theta_dInX0"].Fill(theta, dInX0_tot)
427 hists["phi_dInX0"].Fill(phi, dInX0_tot)
428 hists["eta_dInX0"].Fill(eta, dInX0_tot)
429
430 hists["theta_tTot"].Fill(theta, tTot)
431 hists["phi_tTot"].Fill(phi, tTot)
432 hists["eta_tTot"].Fill(eta, tTot)
433
434
435 hists["phi_dInX0"].GetYaxis().SetRangeUser(0, hists["phi_dInX0"].GetMaximum()*1.2)
436 hists["phi_x0"].GetYaxis().SetRangeUser(0, hists["phi_x0"].GetMaximum()*1.2)
437 hists["phi_t"].GetYaxis().SetRangeUser(0, hists["phi_t"].GetMaximum()*1.2)
438 hists["phi_tTot"].GetYaxis().SetRangeUser(0, hists["phi_tTot"].GetMaximum()*1.2)
439
440 os.system("mkdir -p {}".format(outdir))
441
442 for k, v in hists.iteritems():
443 v.Draw("hist")
444 c.SaveAs("{}/{}.pdf".format(outdir, k))
445
446 c.SetRightMargin(0.2)
447 c.SetTopMargin(0.1)
448
449 for name, h2 in hm.hist2Diter():
450
451 parts = name.split("/")
453 if "z_r" in parts:
454 h2.Draw("colz")
455 draw_eta_lines(h2)
456 filename = "{}.pdf".format(os.path.join(outdir, name))
457 mkdir(os.path.dirname(filename))
458 c.SaveAs(filename)
459
460 h2.Draw("colz")
461 geom_graph.Draw("p+same")
462 draw_eta_lines(h2)
463 filename = "{}_geom.pdf".format(os.path.join(outdir, name))
464 mkdir(os.path.dirname(filename))
465 c.SaveAs(filename)
466
467 else:
468 h2.Draw("colz")
469 filename = "{}.pdf".format(os.path.join(outdir, name))
470 mkdir(os.path.dirname(filename))
471 c.SaveAs(filename)
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491 return layers
492
493
void print(char *figname, TCanvas *c1)