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