Belle II Software prerelease-11-00-00a
PXDDataBaseImporter.py
1#!/usr/bin/env python3
2
3
10
11
12
17
18
19import basf2 as b2
20from ROOT import Belle2
21import ROOT
22
23# set some random seed
24b2.set_random_seed(10346)
25
26
27def importEmptyHotPixelMask(expLow=0, runLow=0, expHigh=-1, runHigh=-1):
28 """
29 This function imports an empty payloads for the PXD
30 hot pixel masking.
31
32 This function works for every Belle 2 geometry
33 """
34
35 # Create an empty hot pixel mask
36 HotPixelMask = Belle2.PXDMaskedPixelPar()
37
38 # Set the iov for the mask
39 iov = Belle2.IntervalOfValidity(expLow, runLow, expHigh, runHigh)
40 Belle2.Database.Instance().storeData('PXDMaskedPixelPar', HotPixelMask, iov)
41
42
43def importEmptyDeadPixelMask(expLow=0, runLow=0, expHigh=-1, runHigh=-1):
44 """
45 This function imports an empty payloads for the PXD
46 dead pixel masking.
47
48 This function works for every Belle 2 geometry
49 """
50
51 # Create an empty mask
52 DeadPixelMask = Belle2.PXDDeadPixelPar()
53
54 # Set the iov for the mask
55 iov = Belle2.IntervalOfValidity(expLow, runLow, expHigh, runHigh)
56 Belle2.Database.Instance().storeData('PXDDeadPixelPar', DeadPixelMask, iov)
57
58
59def importEmptyOccupancyInfo(expLow=0, runLow=0, expHigh=-1, runHigh=-1):
60 """
61 This function imports an empty payloads for the PXD
62 pixel masking.
63
64 This function works for every Belle 2 geometry
65 """
66
67 # Create a dummy occupancy info
68 OccupancyInfo = Belle2.PXDOccupancyInfoPar()
69
70 # Set the iov for the mask
71 iov = Belle2.IntervalOfValidity(expLow, runLow, expHigh, runHigh)
72 Belle2.Database.Instance().storeData('PXDOccupancyInfoPar', OccupancyInfo, iov)
73
74
75def importEmptyClusterChargeMap(expLow=0, runLow=0, expHigh=-1, runHigh=-1):
76 """
77 This function imports an empty payloads for the PXD
78 gain calibration.
79
80 This function works for every Belle 2 geometry
81 """
82
83 # Create a dummy payload
85
86 # Set the iov for the mask
87 iov = Belle2.IntervalOfValidity(expLow, runLow, expHigh, runHigh)
88 Belle2.Database.Instance().storeData('PXDClusterChargeMapPar', ChargeMap, iov)
89
90
91def importEmptyGainMap(expLow=0, runLow=0, expHigh=-1, runHigh=-1):
92 """
93 This function imports an empty payloads for the PXD
94 gain calibration.
95
96 This function works for every Belle 2 geometry
97 """
98
99 # Create a dummy payload
100 GainMap = Belle2.PXDGainMapPar()
101
102 # Set the iov for the mask
103 iov = Belle2.IntervalOfValidity(expLow, runLow, expHigh, runHigh)
104 Belle2.Database.Instance().storeData('PXDGainMapPar', GainMap, iov)
105
106
107def importEmptyPixelThresholdMap(expLow=0, runLow=0, expHigh=-1, runHigh=-1):
108 """
109 This function imports an empty payloads for the PXD
110 charge threshold.
111
112 This function works for every Belle 2 geometry
113 """
114
115 # Create an empty pixel threshold set
116 PixelThreshold = Belle2.PXDPixelThresholdPar()
117
118 # Set the iov for the mask
119 iov = Belle2.IntervalOfValidity(expLow, runLow, expHigh, runHigh)
120 Belle2.Database.Instance().storeData('PXDPixelThresholdPar', PixelThreshold, iov)
121
122
123def importRandomPixelMaskPhase2(HotPixelFraction=0.001, expLow=0, runLow=0, expHigh=-1, runHigh=-1):
124 """
125 This function imports payloads for the PXD
126 pixel masking with random hot pixels
127
128 This function works for Phase 2
129 """
130
131 # Create an empty mask
132 pixelMask = Belle2.PXDMaskedPixelPar()
133
134 # Create a list of sensors
135 sensorIDList = [
136 Belle2.VxdID("1.1.1"), Belle2.VxdID("1.1.2"),
137 Belle2.VxdID("1.2.1"), Belle2.VxdID("1.2.2"),
138 Belle2.VxdID("1.3.1"), Belle2.VxdID("1.3.2"),
139 Belle2.VxdID("1.4.1"), Belle2.VxdID("1.4.2"),
140 Belle2.VxdID("1.5.1"), Belle2.VxdID("1.5.2"),
141 Belle2.VxdID("1.6.1"), Belle2.VxdID("1.6.2"),
142 Belle2.VxdID("1.7.1"), Belle2.VxdID("1.7.2"),
143 Belle2.VxdID("1.8.1"), Belle2.VxdID("1.8.2"),
144 Belle2.VxdID("2.4.1"), Belle2.VxdID("2.4.2"),
145 Belle2.VxdID("2.5.1"), Belle2.VxdID("2.5.2")]
146
147 # Mean number of hot pixels per sensor
148 AverageHotPixels = HotPixelFraction * 250 * 768
149
150 # ... and mask some random pixels
151 for sensorID in sensorIDList:
152 # Randomized number of hot pixels
153 nHotPixels = ROOT.gRandom.Poisson(AverageHotPixels)
154
155 for i in range(nHotPixels):
156 uid = ROOT.gRandom.Integer(250)
157 vid = ROOT.gRandom.Integer(768)
158 print(f"mask pixel uid={uid}, vid={vid}, id={uid * 768 + vid}")
159 pixelMask.maskSinglePixel(sensorID.getID(), uid * 768 + vid)
160
161 # Print the final mask before committing to db
162 for sensorMask in pixelMask.getMaskedPixelMap():
163 sensorID = Belle2.VxdID(sensorMask.first)
164 print(f"Mask for sensor {sensorID} contains {sensorMask.second.size()} pixels")
165
166 iov = Belle2.IntervalOfValidity(expLow, runLow, expHigh, runHigh)
167 Belle2.Database.Instance().storeData('PXDMaskedPixelPar', pixelMask, iov)
168
169
170if __name__ == "__main__":
171
172 importEmptyHotPixelMask()
173 importEmptyDeadPixelMask()
174 importEmptyOccupancyInfo()
175 importEmptyGainMap()
176 importEmptyClusterChargeMap()
A class that describes the interval of experiments/runs for which an object in the database is valid.
The payload class for PXD cluster charge calibrations.
The payload telling which PXD pixel is dead (=Readout system does not receive signals)
The payload class for PXD gain corrections.
The payload telling which PXD pixel to mask (ignore)
The payload collecting some meta information from running the masking algorithm.
The payload telling which charge threshold to use for PXD pixel.
Class to uniquely identify a any structure of the PXD and SVD.
Definition VxdID.h:32
static Database & Instance()
Instance of a singleton Database.
Definition Database.cc:42