26from ROOT
import Belle2
27from array
import array
30parser = argparse.ArgumentParser(description=
"Plot gain maps")
31parser.add_argument(
'--maps', dest=
'maps', action=
"store_true", help=
'Create maps from payloads. This can be slow!')
32args = parser.parse_args()
48histofile = ROOT.TFile(
'gain_histos.root',
'RECREATE')
50histofile.mkdir(
"maps")
53rfile = ROOT.TFile(
"gain_payloads.root",
"READ")
54b2.conditions = rfile.Get(
"conditions")
57for sensorID
in sensor_list:
58 gain_table[sensorID.getID()] = list()
61for condition
in b2.conditions:
62 if condition.PXDGainMapPar_valid:
63 run_list.append(condition.run)
64 for sensorID
in sensor_list:
66 nBinsU = condition.PXDGainMapPar.getBinsU()
67 nBinsV = condition.PXDGainMapPar.getBinsV()
69 layer = sensorID.getLayerNumber()
70 ladder = sensorID.getLadderNumber()
71 sensor = sensorID.getSensorNumber()
74 for guID
in range(nBinsU):
75 for gvID
in range(nBinsV):
76 mean_gain += condition.PXDGainMapPar.getContent(sensorID.getID(), guID, gvID)
78 mean_gain /= (nBinsU * nBinsV)
79 gain_table[sensorID.getID()].append(mean_gain)
82 name = f
"Gains_{layer:d}_{ladder:d}_{sensor:d}_run_{condition.run:d}"
83 title = f
"Relative energy calibration Sensor={layer:d}.{ladder:d}.{sensor:d} run={condition.run:d}"
84 gain_map = ROOT.TH2F(name, title, nBinsU, 0, nBinsU, nBinsV, 0, nBinsV)
85 gain_map.GetXaxis().SetTitle(
"uBin")
86 gain_map.GetYaxis().SetTitle(
"vBin")
87 gain_map.GetZaxis().SetTitle(
"rel. gain factor")
90 for guID
in range(nBinsU):
91 for gvID
in range(nBinsV):
92 gain = condition.PXDGainMapPar.getContent(sensorID.getID(), guID, gvID)
93 gain_map.SetBinContent(int(guID + 1), int(gvID + 1), gain)
99c = ROOT.TCanvas(
'gain_vs_runno',
'Gain evolution vs. run number', 200, 10, 700, 500)
102for sensorID
in sensor_list:
105 x, y = array(
'd'), array(
'd')
106 for value
in gain_table[sensorID.getID()]:
111 gr = ROOT.TGraph(n, x, y)
112 gr.SetLineColor(ROOT.kBlue)
114 gr.SetName(f
"graph_{sensorID.getID()}")
115 gr.SetMarkerColor(ROOT.kBlue)
116 gr.SetMarkerStyle(21)
117 gr.SetTitle(f
'Gain evolution Sensor={sensorID}')
118 gr.GetXaxis().SetTitle(
'run number')
119 gr.GetYaxis().SetTitle(
'gain')
124 c.Print(f
'gains_vs_runno_{sensorID.getID()}.png')
Class to uniquely identify a any structure of the PXD and SVD.