Belle II Software development
dumpGeometryParameters.py
1#!/usr/bin/env python3
2
3
10
11import basf2 as b2
12from ROOT import Belle2
13import math as m
14import ROOT as r
15
16
25
26
27class printSVDPitches(b2.Module):
28 '''class to print SVD pitches'''
29
30 def printPitch(self, layer, ladder, sensor):
31 '''print pitch function'''
32
34
35 vxdID = Belle2.VxdID(layer, 1, sensor)
36 sensorInfo = geoCache.getSensorInfo(vxdID)
37 print('pitches of sensor ' + str(layer) + '.' + str(ladder) + '.' + str(sensor) + ' at:')
38 print(' at other coordinate = 0')
39 print("U pitch = " + str(sensorInfo.getUPitch(0) * 10000) + ' mu')
40 print("V pitch = " + str(sensorInfo.getVPitch(0) * 10000) + ' mu')
41 print(' at other coordinate = +length/2')
42 print("U pitch = " + str(sensorInfo.getUPitch(sensorInfo.getLength() / 2) * 10000) + ' mu')
43 print("V pitch = " + str(sensorInfo.getVPitch(sensorInfo.getLength() / 2) * 10000) + ' mu')
44 print(' at other coordinate = -length/2')
45 print("U pitch = " + str(sensorInfo.getUPitch(-sensorInfo.getLength() / 2) * 10000) + ' mu')
46 print("V pitch = " + str(sensorInfo.getVPitch(-sensorInfo.getLength() / 2) * 10000) + ' mu')
47
48 def beginRun(self):
49 '''begin run'''
50
51 print('Layer 3')
52 self.printPitch(3, 1, 2)
53
54 print('Barrel')
55 self.printPitch(4, 1, 2)
56
57 print('Slanted')
58 self.printPitch(4, 1, 1)
59
60
61class printSVDSizes(b2.Module):
62 ''' class to print SVD sizes'''
63
64 def printSize(self, layer, ladder, sensor):
65 '''function to print the sizes'''
66
68
69 vxdID = Belle2.VxdID(layer, ladder, sensor)
70 sensorInfo = geoCache.getSensorInfo(vxdID)
71 print('sizes of sensor ' + str(layer) + '.' + str(ladder) + '.' + str(sensor) + ' at:')
72 print("W size = " + str(sensorInfo.getWSize() * 10000) + ' mu')
73 print("V size = " + str(sensorInfo.getVSize() * 10) + ' mm')
74 print("U size at V=-length/2 = " + str(sensorInfo.getUSize(-sensorInfo.getLength() / 2) * 10) + ' mm')
75 print("U size at V=0 = " + str(sensorInfo.getUSize(0) * 10) + ' mm')
76 print("U size at V=+length/2 = " + str(sensorInfo.getUSize(sensorInfo.getLength() / 2) * 10) + ' mm')
77
78 def beginRun(self):
79 '''begin run'''
80
81 print('Layer 3')
82 self.printSize(3, 1, 2)
83
84 print('Barrel')
85 self.printSize(4, 1, 2)
86
87 print('Slanted')
88 self.printSize(4, 1, 1)
89
90
91class printSVDStripLengths(b2.Module):
92 '''class to print strip length'''
93
94 def printStripLength(self, layer, ladder, sensor):
95 '''function to print strip length'''
96
98
99 vxdID = Belle2.VxdID(layer, ladder, sensor)
100 sensorInfo = geoCache.getSensorInfo(vxdID)
101 nUcells = sensorInfo.getUCells() - 1
102 nVcells = sensorInfo.getVCells() - 1
103 print('strip lengths ' + str(layer) + '.' + str(ladder) + '.' + str(sensor) + ' at:')
104 print(' V strips at uID=0 = ' + str(sensorInfo.getStripLengthV(0) * 10) + ' mm')
105 print(' V strips at uID=' + str(nUcells) + ' = ' + str(sensorInfo.getStripLengthV(nUcells) * 10) + ' mm')
106 print(' U strips at vID=0 = ' + str(sensorInfo.getStripLengthU(0) * 10) + ' mm')
107 print(' U strips at vID=' + str(nVcells) + ' = ' + str(sensorInfo.getStripLengthU(nVcells) * 10) + ' mm')
108
109 def beginRun(self):
110 '''begin run'''
111
112 print('Layer 3')
113 self.printStripLength(3, 1, 2)
114
115 print('Barrel')
116 self.printStripLength(4, 1, 2)
117
118 print('Slanted')
119 self.printStripLength(4, 1, 1)
120
121
122class printSVDStripPositions(b2.Module):
123 '''class to print strip positions'''
124
125 def printStripPosition(self, layer, ladder, sensor):
126 '''function to print strip positions'''
127
129
130 vxdID = Belle2.VxdID(layer, ladder, sensor)
131 sensorInfo = geoCache.getSensorInfo(vxdID)
132 nUcells = sensorInfo.getUCells() - 1
133 nVcells = sensorInfo.getVCells() - 1
134 print('strip positions ' + str(layer) + '.' + str(ladder) + '.' + str(sensor) + ' at:')
135 print(' vID=0 = ' + str(sensorInfo.getVCellPosition(0) * 10) + ' mm')
136 print(' vID=' + str(nVcells) + ' = ' + str(sensorInfo.getVCellPosition(nVcells) * 10) + ' mm')
137
138 print(' uID=0 at v=0 = ' + str(sensorInfo.getUCellPosition(0, 0) * 10) + ' mm')
139 print(' uID=0 at v=' + str(nVcells) + ' = ' + str(sensorInfo.getUCellPosition(0, nVcells) * 10) + ' mm')
140 print(' uID=' + str(nUcells) + ' at v=0 = ' + str(sensorInfo.getUCellPosition(nUcells, 0) * 10) + ' mm')
141 print(' uID=' + str(nUcells) + ' at v=' + str(nVcells) + ' = ' +
142 str(sensorInfo.getUCellPosition(nUcells, nVcells) * 10) + ' mm')
143
144 print('insideout')
145 print('U cellID at vID=nVcell (0) = ' +
146 str(sensorInfo.getUCellID(sensorInfo.getUCellPosition(0, nVcells), sensorInfo.getVCellPosition(nVcells))))
147 print('U cellID at vID=0 (0) = ' +
148 str(sensorInfo.getUCellID(sensorInfo.getUCellPosition(0, 0), sensorInfo.getVCellPosition(0))))
149
150 def beginRun(self):
151 '''begin run'''
152
153 print('Layer 3')
154 self.printStripPosition(3, 1, 2)
155
156 print('Barrel')
157 self.printStripPosition(4, 1, 2)
158
159 print('Slanted')
160 self.printStripPosition(4, 1, 1)
161
162
163class printSVDSensors(b2.Module):
164 '''class to print svd sensors'''
165
166 def beginRun(self):
167 '''begin run'''
169
170 print("printing all sensors of the SVD in the geometry:")
171 for layer in geoCache.getLayers(Belle2.VXD.SensorInfoBase.SVD):
172 layerNumber = layer.getLayerNumber()
173 for ladder in geoCache.getLadders(layer):
174 ladderNumber = ladder.getLadderNumber()
175 for sensor in geoCache.getSensors(ladder):
176 sensorNumber = sensor.getSensorNumber()
177 print(str(layerNumber) + "." + str(ladderNumber) + "." + str(sensorNumber))
178
179
180class printSVDLadders(b2.Module):
181 '''class to print svd ladders'''
182
183 def beginRun(self):
184 '''begin run'''
185
187
188 print("printing all L3 backward sensors position of the SVD in the geometry:")
189 print("format: sensorID X(cm) Y(cm) phi(rad) phi(deg)")
190 for layer in geoCache.getLayers(Belle2.VXD.SensorInfoBase.SVD):
191 layerNumber = layer.getLayerNumber()
192
193 if not layerNumber == 3:
194 continue
195
196 for ladder in geoCache.getLadders(layer):
197 ladderNumber = ladder.getLadderNumber()
198 for sensor in geoCache.getSensors(ladder):
199 sensorNumber = sensor.getSensorNumber()
200 if not(sensorNumber == layerNumber - 1):
201 continue
202 # sensor ID string
203 sensorID = str(layerNumber) + "." + str(ladderNumber)
204 # get global coordinates:
205 local = r.Math.XYZVector(0, 0, 0)
206 glob = geoCache.getSensorInfo(sensor).pointToGlobal(local)
207
208 angleRad = m.atan2(glob.Y(), glob.X())
209 print(angleRad)
210 if(angleRad < 0):
211 angleRad = 2 * m.pi + angleRad
212 print("second = " + str(angleRad))
213
214 angleDeg = m.degrees(angleRad)
215
216 xStr = f"{round(glob.X(), 2):.2f}"
217 yStr = f"{round(glob.Y(), 2):.2f}"
218 radStr = f"{round(angleRad, 4):.2f}"
219 degStr = f"{round(angleDeg, 2):.2f}"
220 print(sensorID + ' ' + xStr + ' ' + yStr + ' ' + radStr + ' ' + degStr)
221
222
223# add your GT here:
224# gt = ""
225# b2conditions.prepend_globaltag(gt)
226
227# Create paths
228main = b2.create_path()
229
230eventinfosetter = b2.register_module('EventInfoSetter')
231eventinfosetter.param('expList', [1003])
232eventinfosetter.param('runList', [0])
233eventinfosetter.param('evtNumList', [1])
234main.add_module(eventinfosetter)
235
236main.add_module("Gearbox")
237main.add_module('Geometry')
238
239main.add_module(printSVDSensors())
240main.add_module(printSVDLadders())
241main.add_module(printSVDPitches())
242main.add_module(printSVDSizes())
243main.add_module(printSVDStripLengths())
244main.add_module(printSVDStripPositions())
245
246b2.print_path(main)
247
248# Process events
249b2.process(main)
250
251print(b2.statistics)
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
def printPitch(self, layer, ladder, sensor)
def printSize(self, layer, ladder, sensor)
def printStripLength(self, layer, ladder, sensor)
def printStripPosition(self, layer, ladder, sensor)