Belle II Software  release-05-02-19
plotCDCAlignmentPayload.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 """
5 Plot content of dbstore_CDCAlignment...root DB payload file
6 """
7 import sys
8 
9 import ROOT
10 from ROOT import Belle2
11 
12 ROOT.gROOT.SetBatch(1)
13 
14 if len(sys.argv) < 2:
15  sys.exit("No input .root file specified!")
16 
17 inputroot = str(sys.argv[1])
18 file = ROOT.TFile(inputroot, "OPEN")
19 cdc = file.Get("CDCAlignment")
20 
21 wires_in_layer = [
22  160, 160, 160, 160, 160, 160, 160, 160,
23  160, 160, 160, 160, 160, 160,
24  192, 192, 192, 192, 192, 192,
25  224, 224, 224, 224, 224, 224,
26  256, 256, 256, 256, 256, 256,
27  288, 288, 288, 288, 288, 288,
28  320, 320, 320, 320, 320, 320,
29  352, 352, 352, 352, 352, 352,
30  384, 384, 384, 384, 384, 384]
31 
32 n_wires = sum(wires_in_layer)
33 
34 # CDC - Alignment of layers -----------------------------------------------------
35 
36 params = [1, 2, 6, 11, 12, 16]
37 param_names = ['X', 'Y', 'Phi', 'dX', 'dY', 'dPhi']
38 param_scales = [0.02, 0.02, 0.001, 0.02, 0.02, 0.001]
39 
40 histosL = []
41 for i in range(0, len(params)):
42  histosL.append(ROOT.TGraph(56))
43  histosL[-1].SetName("g{}".format(i))
44  histosL[-1].SetTitle(param_names[i])
45 
46 for ipar in range(0, len(params)):
47  for layer in range(0, 56):
48  param = params[ipar]
49  val = cdc.getGlobalParam(Belle2.WireID(layer, 511).getEWire(), param)
50  histosL[ipar].SetPoint(layer, layer, val)
51 
52 cL = ROOT.TCanvas("cL", "CDCAlignment - Layers", 1600, 1200)
53 cL.Divide(3, 2)
54 
55 for i, h in enumerate(histosL):
56  cL.cd(i+1)
57  h.SetMarkerStyle(34)
58  if params[i] in [1, 2, 11, 12]:
59  h.GetHistogram().SetMaximum(0.02)
60  h.GetHistogram().SetMinimum(-0.02)
61  else:
62  h.GetHistogram().SetMaximum(0.0005)
63  h.GetHistogram().SetMinimum(-0.0005)
64  h.Draw("AP")
65 
66 cL.SaveAs(inputroot + ".png")
67 
68 # CDC - Alignment of wires -----------------------------------------------------
69 params = [0, 1, 2, 4, 5, 6, 21]
70 param_names = ['bX', 'bY', 'bZ', 'fX', 'fY', 'fZ', 'sagging']
71 scales = [0.03, 0.03, 0.3, 0.03, 0.03, 0.3, 200]
72 histosW = [ROOT.TH2F("histo_wire_{}".format(ipar), "histo_{}".format(param_names[ipar]), n_wires, 0,
73  n_wires, 2000, -scales[ipar], scales[ipar]) for ipar in range(0, len(params))]
74 
75 for ipar in range(0, len(params)):
76  wireindex = 0
77  for layer in range(0, 56):
78  for wire in range(0, wires_in_layer[layer]):
79  param = params[ipar]
80  val = cdc.getGlobalParam(Belle2.WireID(layer, wire).getEWire(), param)
81  histosW[ipar].Fill(wireindex, val)
82  wireindex += 1
83 
84 cW = ROOT.TCanvas("cW", "CDCAlignment - Wires", 1600, 1200)
85 cW.Divide(3, 3)
86 
87 for i, h in enumerate(histosW):
88  cW.cd(i+1)
89  h.Draw("prof")
90 
91 cW.SaveAs(inputroot + "_wires.png")
Belle2::WireID
Class to identify a wire inside the CDC.
Definition: WireID.h:44