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