Belle II Software development
GeoTools.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <vxd/dataobjects/VxdID.h>
12#include <vector>
13#include <algorithm>
14
15namespace Belle2 {
20 namespace VXD {
21
25 class GeoTools {
26
27 public:
32 GeoTools();
33
34 /*********************************************************************
35 * General geometry parameters
36 ********************************************************************/
37
41 unsigned short getNumberOfLayers() const { return m_listOfLayers.size(); }
42
46 unsigned short getNumberOfPXDLayers() const { return m_firstSVDLayer; }
47
51 unsigned short getNumberOfSVDLayers() const
52 { return m_listOfLayers.size() - m_firstSVDLayer; }
53
57 std::vector<unsigned short> getLayers() const { return m_listOfLayers; }
58
62 std::vector<unsigned short> getPXDLayers() const
63 {
64 std::vector<unsigned short> pxdLayers;
65 std::copy_if(m_listOfLayers.begin(), m_listOfLayers.end(),
66 std::back_inserter(pxdLayers),
67 [](unsigned short l)->bool {return l < 3;});
68 return pxdLayers;
69 }
70
74 std::vector<unsigned short> getSVDLayers() const
75 {
76 std::vector<unsigned short> svdLayers;
77 std::copy_if(m_listOfLayers.begin(), m_listOfLayers.end(),
78 std::back_inserter(svdLayers),
79 [](unsigned short l)->bool {return l > 2;});
80 return svdLayers;
81 }
82
86 unsigned short getFirstLayer() const { return *m_listOfLayers.begin(); }
87
91 unsigned short getLastLayer() const { return *m_listOfLayers.rbegin(); }
92
96 short getFirstPXDLayer() const
97 {
98 return (m_firstSVDLayer > 0 ? *m_listOfLayers.begin() : -1);
99 }
100
104 short getLastPXDLayer() const
105 {
106 return (m_firstSVDLayer > 0 ? m_listOfLayers[m_firstSVDLayer - 1] : -1);
107 }
108
112 short getFirstSVDLayer() const
113 {
115 }
116
120 short getLastSVDLayer() const
121 {
122 return (m_firstSVDLayer < m_listOfLayers.size() ? *m_listOfLayers.rbegin() : -1);
123 }
124
128 unsigned short getNumberOfSensors() const { return m_listOfSensors.size(); }
129
133 unsigned short getNumberOfPXDSensors() const { return m_firstSVDIndex; }
134
138 unsigned short getNumberOfSVDSensors() const
139 { return m_listOfSensors.size() - m_firstSVDIndex; }
140
141 /*********************************************************************
142 * Chip-related parameters
143 *********************************************************************/
147 size_t getTotalPXDChips() const { return m_listOfPXDChips.size(); }
148
152 unsigned short getNumberOfPXDUSideChips() const
153 { return c_nPXDChipsU; }
154
158 unsigned short getNumberOfPXDVSideChips() const
159 { return c_nPXDChipsV; }
160
164 unsigned short getNumberOfPXDReadoutGates() const
165 { return c_nPXDReadoutGates; }
166
170 size_t getTotalSVDChips() const { return m_listOfSVDChips.size(); }
171
175 unsigned short getNumberOfSVDUSideChips() const
176 { return c_nSVDChipsLu; }
177
182 unsigned short getNumberOfSVDVSideChips(unsigned short layer) const
183 { return (layer == 3 ? c_nSVDChipsL3 : c_nSVDChipsLv); }
184
188 unsigned short getSVDChannelsPerChip() const
189 { return c_nSVDChannelsPerChip; }
190
191 /*********************************************************************
192 * General sensor indexing
193 *********************************************************************/
198 int getSensorIndex(VxdID sensorID) const
199 {
200 return std::distance(
201 m_listOfSensors.begin(),
202 find(m_listOfSensors.begin(), m_listOfSensors.end(), sensorID)
203 );
204 }
205
211 VxdID getSensorIDFromIndex(int vxdIndex) const
212 {
213 return m_listOfSensors[vxdIndex];
214 }
215
216 /*********************************************************************
217 * PXD sensor indexing
218 *********************************************************************/
224 int getPXDSensorIndex(VxdID sensorID) const
225 {
226 return getSensorIndex(sensorID);
227 }
235 int getPXDSensorIndex(int layer, int ladder, int sensor) const
236 {
237 return getSensorIndex(VxdID(layer, ladder, sensor));
238 }
239
244 VxdID getSensorIDFromPXDIndex(int pxdIndex) const
245 {
246 return m_listOfSensors[pxdIndex];
247 }
248
249 /*********************************************************************
250 * PXD chip indexing
251 ********************************************************************/
259 int getPXDChipIndex(VxdID sensorID, bool isU, int chip) const
260 {
261 VxdID chipID(sensorID);
262 chip = isU ? chip - 1 : chip - 1 + c_nPXDChipsU;
263 chipID.setSegmentNumber(static_cast<unsigned short>(chip));
264 return std::distance(
265 m_listOfPXDChips.begin(),
266 std::find(m_listOfPXDChips.begin(), m_listOfPXDChips.end(), chipID));
267 }
268
277 int getPXDChipIndex(int layer, int ladder, int sensor, bool isU, int chip) const
278 {
279 return getPXDChipIndex(VxdID(layer, ladder, sensor), isU, chip);
280 }
281
286 VxdID getChipIDFromPXDIndex(int pxdChipIndex) const
287 {
288 return m_listOfPXDChips[pxdChipIndex];
289 }
290
295 bool isPXDSideU(VxdID chipID) const
296 {
297 return (chipID.getSegmentNumber() < c_nPXDChipsU);
298 }
299
304 unsigned short getPXDChipNumber(VxdID chipID) const
305 {
306 unsigned short chipNo = chipID.getSegmentNumber();
307 return (chipNo < c_nPXDChipsU ? chipNo + 1 : (chipNo + 1 - c_nPXDChipsU));
308 }
309
310 /*********************************************************************
311 * SVD sensor indexing
312 *********************************************************************/
318 int getSVDSensorIndex(VxdID sensorID) const
319 {
320 return (getSensorIndex(sensorID) - m_firstSVDIndex);
321 }
322
330 int getSVDSensorIndex(int layer, int ladder, int sensor) const
331 {
332 return getSVDSensorIndex(VxdID(layer, ladder, sensor));
333 }
334
339 VxdID getSensorIDFromSVDIndex(int svdIndex) const
340 {
341 return m_listOfSensors[m_firstSVDIndex + svdIndex];
342 }
343
344 /*********************************************************************
345 * SVD chip indexing
346 ********************************************************************/
347
354 int getSVDChipIndex(VxdID sensorID, bool isU, int chip) const
355 {
356 VxdID chipID(sensorID);
357 if (sensorID.getLayerNumber() == 3)
358 chip = isU ? chip - 1 : chip - 1 + c_nSVDChipsL3;
359 else
360 chip = isU ? chip - 1 : chip - 1 + c_nSVDChipsLu;
361 chipID.setSegmentNumber(static_cast<unsigned short>(chip));
362 return std::distance(
363 m_listOfSVDChips.begin(),
364 std::find(m_listOfSVDChips.begin(), m_listOfSVDChips.end(), chipID));
365 }
366
375 int getSVDChipIndex(int layer, int ladder, int sensor, bool isU, int chip) const
376 {
377 return getSVDChipIndex(VxdID(layer, ladder, sensor), isU, chip);
378 }
379
384 VxdID getChipIDFromSVDIndex(int svdChipIndex) const
385 {
386 return m_listOfSVDChips[svdChipIndex];
387 }
388
393 bool isSVDSideU(VxdID chipID) const
394 {
395 /* cppcheck-suppress duplicateExpressionTernary */
396 return (chipID.getLayerNumber() == 3 ? chipID.getSegmentNumber() < c_nSVDChipsL3 : chipID.getSegmentNumber() < c_nSVDChipsLu);
397 }
398
403 unsigned short getSVDChipNumber(VxdID chipID) const
404 {
405 unsigned short chipNo = chipID.getSegmentNumber();
406 if (chipID.getLayerNumber() == 3) {
407 if (chipNo < c_nSVDChipsL3)
408 return chipNo + 1;
409 else
410 return (chipNo + 1 - c_nSVDChipsL3);
411 } else {
412 if (chipNo < c_nSVDChipsLu)
413 return chipNo + 1;
414 else
415 return (chipNo + 1 - c_nSVDChipsLu);
416 }
417 }
418
419 /*********************************************************************
420 * Layer indexing
421 ********************************************************************/
426 int getLayerIndex(unsigned short layer) const
427 {
428 return std::distance(
429 m_listOfLayers.begin(),
430 std::find(m_listOfLayers.begin(), m_listOfLayers.end(), layer)
431 );
432 }
433
438 unsigned short getLayerNumberFromLayerIndex(int index) const
439 {
440 return m_listOfLayers[index];
441 }
442
443
444 private:
445
447 void createListOfLayers();
448
451
454
456 std::vector<VxdID> m_listOfSensors;
457
460
462 std::vector<unsigned short> m_listOfLayers;
463
465 unsigned short m_firstSVDLayer;
466
468 std::vector<VxdID> m_listOfPXDChips;
469
471 std::vector<VxdID> m_listOfSVDChips;
472
474 const unsigned short c_nPXDChipsU = 4;
476 const unsigned short c_nPXDChipsV = 6;
478 const unsigned short c_nPXDReadoutGates = 192;
480 const unsigned short c_nSVDChipsL3 = 6;
482 const unsigned short c_nSVDChipsLu = 6;
484 const unsigned short c_nSVDChipsLv = 4;
486 const unsigned short c_nSVDChannelsPerChip = 128;
487 };
488 } // VXD namespace
490} // Belle2 namespace
The class collects utility functions for numbering layers, sensors snd chips based on current VXD geo...
Definition: GeoTools.h:25
short getLastSVDLayer() const
Get last (outermost) SVD layer number.
Definition: GeoTools.h:120
bool isPXDSideU(VxdID chipID) const
Decode sensor side from a PXD ChipID.
Definition: GeoTools.h:295
bool isSVDSideU(VxdID chipID) const
Decode sensor side from a SVD ChipID.
Definition: GeoTools.h:393
unsigned short getNumberOfSensors() const
Get total number of sensors.
Definition: GeoTools.h:128
void createListOfLayers()
Create list of VXD layers.
Definition: GeoTools.cc:34
unsigned short getLastLayer() const
Get last (outermost) layer number.
Definition: GeoTools.h:91
VxdID getSensorIDFromSVDIndex(int svdIndex) const
Return VxdID for SVD index of sensor in plots.
Definition: GeoTools.h:339
short getLastPXDLayer() const
Get last (outermost) PXD layer number.
Definition: GeoTools.h:104
VxdID getChipIDFromPXDIndex(int pxdChipIndex) const
Return chipID (VxdID + side and chipNo) for index in the list.
Definition: GeoTools.h:286
int getSVDSensorIndex(int layer, int ladder, int sensor) const
Return index of SVD sensor in plots.
Definition: GeoTools.h:330
unsigned short getNumberOfPXDLayers() const
Get number of PXD layers.
Definition: GeoTools.h:46
unsigned short getNumberOfSVDUSideChips() const
Get number of u-side SVD chips.
Definition: GeoTools.h:175
std::vector< VxdID > m_listOfSVDChips
List of all SVD chips.
Definition: GeoTools.h:471
int getPXDSensorIndex(VxdID sensorID) const
Return index of sensor in plots.
Definition: GeoTools.h:224
int getLayerIndex(unsigned short layer) const
Return index of layer in plots.
Definition: GeoTools.h:426
size_t m_firstSVDIndex
Number of the first SVD sensor in the list.
Definition: GeoTools.h:459
VxdID getSensorIDFromIndex(int vxdIndex) const
Reverse lookup VxdID from list index.
Definition: GeoTools.h:211
std::vector< unsigned short > getSVDLayers() const
Get numbers of SVD layers.
Definition: GeoTools.h:74
unsigned short getSVDChannelsPerChip() const
Get number of strips per APV chip in SVD.
Definition: GeoTools.h:188
unsigned short getNumberOfPXDVSideChips() const
Get number of v-side PXD chips.
Definition: GeoTools.h:158
unsigned short getNumberOfSVDSensors() const
Get number of SVD sensors.
Definition: GeoTools.h:138
short getFirstSVDLayer() const
Get first (innermost) SVD layer number.
Definition: GeoTools.h:112
void createListOfPXDChips()
Create list of PXD chips.
Definition: GeoTools.cc:52
const unsigned short c_nPXDChipsV
Number of PXD chips per sensor in v (Switchers) (=6) on Belle II.
Definition: GeoTools.h:476
void createListOfSVDChips()
Create list of SVD chips.
Definition: GeoTools.cc:73
VxdID getChipIDFromSVDIndex(int svdChipIndex) const
Return chipID (VxdID with side and chipNo) for index in the list.
Definition: GeoTools.h:384
std::vector< unsigned short > getLayers() const
Get numbers of VXD layers.
Definition: GeoTools.h:57
int getSVDChipIndex(VxdID sensorID, bool isU, int chip) const
Return SVD chip index in the list of SVD chips.
Definition: GeoTools.h:354
VxdID getSensorIDFromPXDIndex(int pxdIndex) const
Return index of a PXD sensor in plots.
Definition: GeoTools.h:244
const unsigned short c_nSVDChipsL3
Number of SVD chips per sensor in u,v in layer 3 (=6) on Belle II.
Definition: GeoTools.h:480
unsigned short getLayerNumberFromLayerIndex(int index) const
Return layer number for list index.
Definition: GeoTools.h:438
unsigned short getNumberOfLayers() const
Get number of VXD layers.
Definition: GeoTools.h:41
int getSVDChipIndex(int layer, int ladder, int sensor, bool isU, int chip) const
Return SVD chip index in the list of SVD chips.
Definition: GeoTools.h:375
unsigned short getPXDChipNumber(VxdID chipID) const
Decode (1-based) chip number from a PXD ChipID.
Definition: GeoTools.h:304
size_t getTotalSVDChips() const
Get total number of chips in SVD.
Definition: GeoTools.h:170
unsigned short getNumberOfPXDUSideChips() const
Get number of u-side PXD chips.
Definition: GeoTools.h:152
std::vector< VxdID > m_listOfPXDChips
List of all PXD chips.
Definition: GeoTools.h:468
std::vector< unsigned short > m_listOfLayers
List of all VXD layers.
Definition: GeoTools.h:462
int getSensorIndex(VxdID sensorID) const
Return index of s VXD sensor for plotting.
Definition: GeoTools.h:198
unsigned short getNumberOfPXDSensors() const
Get number of PXD sensors.
Definition: GeoTools.h:133
GeoTools()
Constructor builds lookup maps from GeoCache.
Definition: GeoTools.cc:17
size_t getTotalPXDChips() const
Get total number of chips in PXD.
Definition: GeoTools.h:147
const unsigned short c_nPXDChipsU
Number of PXD chips per sensor in u (DCD) (=4) on Belle II.
Definition: GeoTools.h:474
const unsigned short c_nSVDChannelsPerChip
Number of SVD strips per chip on Belle II.
Definition: GeoTools.h:486
int getPXDChipIndex(int layer, int ladder, int sensor, bool isU, int chip) const
Return PXD chip index in the list of PXD chips.
Definition: GeoTools.h:277
const unsigned short c_nSVDChipsLv
Number of SVD chips per sensor in v in layers 4,5,6 (=4) on Belle II.
Definition: GeoTools.h:484
std::vector< unsigned short > getPXDLayers() const
Get numbers of PXD layers.
Definition: GeoTools.h:62
std::vector< VxdID > m_listOfSensors
List of all VXD sesnros.
Definition: GeoTools.h:456
int getPXDChipIndex(VxdID sensorID, bool isU, int chip) const
Return PXD chip index in the list of PXD chips.
Definition: GeoTools.h:259
int getPXDSensorIndex(int layer, int ladder, int sensor) const
Return index of sensor in plots.
Definition: GeoTools.h:235
const unsigned short c_nSVDChipsLu
Number of SVD chips per sensor in u in layers 4,5,6 (=6) on Belle II.
Definition: GeoTools.h:482
unsigned short getNumberOfPXDReadoutGates() const
Get number of PXD readout gates.
Definition: GeoTools.h:164
unsigned short getNumberOfSVDVSideChips(unsigned short layer) const
Get number of v-side SVD chips.
Definition: GeoTools.h:182
short getFirstPXDLayer() const
Get first (innermost) PXD layer number.
Definition: GeoTools.h:96
unsigned short getNumberOfSVDLayers() const
Get number of SVD layers.
Definition: GeoTools.h:51
int getSVDSensorIndex(VxdID sensorID) const
Return index of SVD sensor in plots.
Definition: GeoTools.h:318
unsigned short getSVDChipNumber(VxdID chipID) const
Decode (1-based) chip number from a SVD ChipID.
Definition: GeoTools.h:403
const unsigned short c_nPXDReadoutGates
Number of PXD readout gates (or total number of Switcher channels) on Belle II.
Definition: GeoTools.h:478
unsigned short getFirstLayer() const
Get first (innermost) layer number.
Definition: GeoTools.h:86
unsigned short m_firstSVDLayer
List index of the first SVD layer.
Definition: GeoTools.h:465
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
void setSegmentNumber(baseType segment)
Set the sensor segment.
Definition: VxdID.h:113
baseType getSegmentNumber() const
Get the sensor segment.
Definition: VxdID.h:102
baseType getLayerNumber() const
Get the layer id.
Definition: VxdID.h:96
Abstract base class for different kinds of events.