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