Belle II Software  release-08-01-10
GeoTools.cc
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 #include <vxd/geometry/GeoTools.h>
10 #include <vxd/geometry/GeoCache.h>
11 
12 #include <numeric>
13 
14 using namespace Belle2;
15 using namespace Belle2::VXD;
16 
18 {
21  // The list comes from a map, and is NOT sorted!
22  std::sort(m_listOfSensors.begin(), m_listOfSensors.end());
23  m_firstSVDIndex = std::distance(
24  m_listOfSensors.begin(),
25  std::find_if(m_listOfSensors.begin(), m_listOfSensors.end(),
26  [](VxdID id)->bool { return (id.getLayerNumber() > 2); })
27  ); // works correctly even with no SVD sensors
31 }
32 
35 {
37  auto layerSet = geo.getLayers();
38  std::transform(
39  layerSet.begin(), layerSet.end(),
40  std::back_inserter(m_listOfLayers),
41  [](VxdID id)->int { return id.getLayerNumber(); }
42  );
43  // Better to sort this too, just in case.
44  std::sort(m_listOfLayers.begin(), m_listOfLayers.end());
45  m_firstSVDLayer = static_cast<unsigned short>(
46  std::distance(m_listOfLayers.begin(),
47  std::find(m_listOfLayers.begin(), m_listOfLayers.end(), 3)
48  ));
49 }
50 
53 {
54  // We set segment number to the number of chip.
55  std::vector<unsigned short> sensorChips(c_nPXDChipsU + c_nPXDChipsV);
56  std::iota(sensorChips.begin(), sensorChips.end(), 0);
57  for (auto sensorID : m_listOfSensors) {
58  if (sensorID.getLayerNumber() < getFirstPXDLayer() ||
59  sensorID.getLayerNumber() > getLastPXDLayer())
60  continue;
61  std::vector<VxdID> sensorIDs;
62  std::transform(
63  sensorChips.begin(), sensorChips.end(),
64  std::back_inserter(sensorIDs),
65  [sensorID](unsigned short i)->VxdID
66  { VxdID sID(sensorID); sID.setSegmentNumber(i); return sID; }
67  );
68  m_listOfPXDChips.insert(m_listOfPXDChips.end(), sensorIDs.begin(), sensorIDs.end());
69  }
70 }
71 
74 {
75  // We set segment number to the number of chip.
76  std::vector<unsigned short> sensorChipsL456(c_nSVDChipsLu + c_nSVDChipsLv);
77  std::iota(sensorChipsL456.begin(), sensorChipsL456.end(), 0);
78  std::vector<unsigned short> sensorChipsL3(2 * c_nSVDChipsL3);
79  std::iota(sensorChipsL3.begin(), sensorChipsL3.end(), 0);
80  for (auto sensorID : m_listOfSensors) {
81  if (sensorID.getLayerNumber() < getFirstSVDLayer() ||
82  sensorID.getLayerNumber() > getLastSVDLayer())
83  continue;
84  std::vector<VxdID> sensorIDs;
85  std::vector<unsigned short>& sensorChips =
86  sensorID.getLayerNumber() == 3 ? sensorChipsL3 : sensorChipsL456;
87  std::transform(
88  sensorChips.begin(), sensorChips.end(),
89  std::back_inserter(sensorIDs),
90  [sensorID](unsigned short i)->VxdID
91  { VxdID sID(sensorID); sID.setSegmentNumber(i); return sID; }
92  );
93  m_listOfSVDChips.insert(m_listOfSVDChips.end(), sensorIDs.begin(), sensorIDs.end());
94  }
95 }
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
Definition: GeoCache.h:39
const std::set< Belle2::VxdID > getLayers(SensorInfoBase::SensorType sensortype=SensorInfoBase::VXD)
Return a set of all known Layers.
Definition: GeoCache.cc:176
const std::vector< VxdID > getListOfSensors() const
Get list of all sensors.
Definition: GeoCache.cc:59
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214
short getLastSVDLayer() const
Get last (outermost) SVD layer number.
Definition: GeoTools.h:120
void createListOfLayers()
Create list of VXD layers.
Definition: GeoTools.cc:34
short getLastPXDLayer() const
Get last (outermost) PXD layer number.
Definition: GeoTools.h:104
std::vector< VxdID > m_listOfSVDChips
List of all SVD chips.
Definition: GeoTools.h:471
size_t m_firstSVDIndex
Number of the first SVD sensor in the list.
Definition: GeoTools.h:459
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
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
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
GeoTools()
Constructor builds lookup maps from GeoCache.
Definition: GeoTools.cc:17
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_nSVDChipsLv
Number of SVD chips per sensor in v in layers 4,5,6 (=4) on Belle II.
Definition: GeoTools.h:484
std::vector< VxdID > m_listOfSensors
List of all VXD sesnros.
Definition: GeoTools.h:456
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
short getFirstPXDLayer() const
Get first (innermost) PXD layer number.
Definition: GeoTools.h:96
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
Namespace to provide code needed by both Vertex Detectors, PXD and SVD, and also testbeam telescopes.
Definition: GeoCache.h:34
Abstract base class for different kinds of events.