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