Belle II Software  release-05-01-25
GeoTools.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Peter Kodys, Peter Kvasnicka *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <vxd/geometry/GeoTools.h>
12 #include <vxd/geometry/GeoCache.h>
13 
14 #include <numeric>
15 
16 using namespace Belle2;
17 using namespace Belle2::VXD;
18 
20 {
23  // The list comes from a map, and is NOT sorted!
24  std::sort(m_listOfSensors.begin(), m_listOfSensors.end());
25  m_firstSVDIndex = std::distance(
26  m_listOfSensors.begin(),
27  std::find_if(m_listOfSensors.begin(), m_listOfSensors.end(),
28  [](VxdID id)->bool { return (id.getLayerNumber() > 2); })
29  ); // works correctly even with no SVD sensors
33 }
34 
37 {
39  auto layerSet = geo.getLayers();
40  std::transform(
41  layerSet.begin(), layerSet.end(),
42  std::back_inserter(m_listOfLayers),
43  [](VxdID id)->int { return id.getLayerNumber(); }
44  );
45  // Better to sort this too, just in case.
46  std::sort(m_listOfLayers.begin(), m_listOfLayers.end());
47  m_firstSVDLayer = static_cast<unsigned short>(
48  std::distance(m_listOfLayers.begin(),
49  std::find(m_listOfLayers.begin(), m_listOfLayers.end(), 3)
50  ));
51 }
52 
55 {
56  // We set segment number to the number of chip.
57  std::vector<unsigned short> sensorChips(c_nPXDChipsU + c_nPXDChipsV);
58  std::iota(sensorChips.begin(), sensorChips.end(), 0);
59  for (auto sensorID : m_listOfSensors) {
60  if (sensorID.getLayerNumber() < getFirstPXDLayer() ||
61  sensorID.getLayerNumber() > getLastPXDLayer())
62  continue;
63  std::vector<VxdID> sensorIDs;
64  std::transform(
65  sensorChips.begin(), sensorChips.end(),
66  std::back_inserter(sensorIDs),
67  [sensorID](unsigned short i)->VxdID
68  { VxdID sID(sensorID); sID.setSegmentNumber(i); return sID; }
69  );
70  m_listOfPXDChips.insert(m_listOfPXDChips.end(), sensorIDs.begin(), sensorIDs.end());
71  }
72 }
73 
76 {
77  // We set segment number to the number of chip.
78  std::vector<unsigned short> sensorChipsL456(c_nSVDChipsLu + c_nSVDChipsLv);
79  std::iota(sensorChipsL456.begin(), sensorChipsL456.end(), 0);
80  std::vector<unsigned short> sensorChipsL3(2 * c_nSVDChipsL3);
81  std::iota(sensorChipsL3.begin(), sensorChipsL3.end(), 0);
82  for (auto sensorID : m_listOfSensors) {
83  if (sensorID.getLayerNumber() < getFirstSVDLayer() ||
84  sensorID.getLayerNumber() > getLastSVDLayer())
85  continue;
86  std::vector<VxdID> sensorIDs;
87  std::vector<unsigned short>& sensorChips =
88  sensorID.getLayerNumber() == 3 ? sensorChipsL3 : sensorChipsL456;
89  std::transform(
90  sensorChips.begin(), sensorChips.end(),
91  std::back_inserter(sensorIDs),
92  [sensorID](unsigned short i)->VxdID
93  { VxdID sID(sensorID); sID.setSegmentNumber(i); return sID; }
94  );
95  m_listOfSVDChips.insert(m_listOfSVDChips.end(), sensorIDs.begin(), sensorIDs.end());
96  }
97 }
Belle2::VXD::GeoTools::m_listOfSVDChips
std::vector< VxdID > m_listOfSVDChips
List of all SVD chips.
Definition: GeoTools.h:485
Belle2::VxdID
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:43
Belle2::VXD::GeoTools::c_nPXDChipsU
const unsigned short c_nPXDChipsU
Number of PXD chips per sensor in u (DCD) (=4) on Belle II.
Definition: GeoTools.h:488
Belle2::VXD::GeoTools::m_listOfSensors
std::vector< VxdID > m_listOfSensors
List of all VXD sesnros.
Definition: GeoTools.h:470
Belle2::VXD::GeoTools::createListOfLayers
void createListOfLayers()
Create list of VXD layers.
Definition: GeoTools.cc:36
Belle2::VXD::GeoTools::getFirstPXDLayer
short getFirstPXDLayer() const
Get first (innermost) PXD layer number.
Definition: GeoTools.h:106
Belle2::VXD::GeoTools::createListOfPXDChips
void createListOfPXDChips()
Create list of PXD chips.
Definition: GeoTools.cc:54
Belle2::VXD::GeoTools::m_listOfPXDChips
std::vector< VxdID > m_listOfPXDChips
List of all PXD chips.
Definition: GeoTools.h:482
Belle2::VXD::GeoCache::getLayers
const std::set< Belle2::VxdID > getLayers(SensorInfoBase::SensorType sensortype=SensorInfoBase::VXD)
Return a set of all known Layers.
Definition: GeoCache.cc:177
Belle2::VXD::GeoCache::getListOfSensors
const std::vector< VxdID > getListOfSensors() const
Get list of all sensors.
Definition: GeoCache.cc:60
Belle2::VXD::GeoTools::getLastSVDLayer
short getLastSVDLayer() const
Get last (outermost) SVD layer number.
Definition: GeoTools.h:130
Belle2::VXD
Namespace to provide code needed by both Vertex Detectors, PXD and SVD, and also testbeam telescopes.
Definition: GeoCache.h:36
Belle2::VXD::GeoCache::getInstance
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:215
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::VXD::GeoTools::c_nSVDChipsLu
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:496
Belle2::VXD::GeoTools::c_nPXDChipsV
const unsigned short c_nPXDChipsV
Number of PXD chips per sensor in v (Switchers) (=6) on Belle II.
Definition: GeoTools.h:490
Belle2::VXD::GeoTools::getLastPXDLayer
short getLastPXDLayer() const
Get last (outermost) PXD layer number.
Definition: GeoTools.h:114
Belle2::VXD::GeoTools::m_firstSVDIndex
size_t m_firstSVDIndex
Number of the first SVD sensor in the list.
Definition: GeoTools.h:473
Belle2::VXD::GeoTools::c_nSVDChipsL3
const unsigned short c_nSVDChipsL3
Number of SVD chips per sensor in u,v in layer 3 (=6) on Belle II.
Definition: GeoTools.h:494
Belle2::VXD::GeoTools::c_nSVDChipsLv
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:498
Belle2::VXD::GeoCache
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
Definition: GeoCache.h:41
Belle2::VXD::GeoTools::m_listOfLayers
std::vector< unsigned short > m_listOfLayers
List of all VXD layers.
Definition: GeoTools.h:476
Belle2::VXD::GeoTools::GeoTools
GeoTools()
Constructor builds lookup maps from GeoCache.
Definition: GeoTools.cc:19
Belle2::VXD::GeoTools::m_firstSVDLayer
unsigned short m_firstSVDLayer
List index of the first SVD layer.
Definition: GeoTools.h:479
Belle2::VXD::GeoTools::createListOfSVDChips
void createListOfSVDChips()
Create list of SVD chips.
Definition: GeoTools.cc:75
Belle2::VXD::GeoTools::getFirstSVDLayer
short getFirstSVDLayer() const
Get first (innermost) SVD layer number.
Definition: GeoTools.h:122