Belle II Software development
CDCWireTopology.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 <cdc/topology/CDCWireTopology.h>
10
11#include <tracking/trackingUtilities/utilities/Algorithms.h>
12
13#include <tracking/trackingUtilities/utilities/Common.h>
14
15#include <cdc/geometry/CDCGeometryPar.h>
16
17using namespace Belle2;
18using namespace CDC;
19using namespace TrackingUtilities;
20
22{
23 // Definition of the singleton instance
24 static CDCWireTopology instance;
25 return instance;
26}
27
29{
30 m_wires.clear();
31 m_wireLayers.clear();
32 m_wireSuperLayers.clear();
33
34 m_wires.reserve(c_NWires);
35 m_wireLayers.reserve(c_NLayers);
37
38 // create all wires
41
42 for (size_t iCLayer = 0; iCLayer < cdcGeo.nWireLayers() ; ++iCLayer) {
43 for (size_t iWire = 0; iWire < cdcGeo.nWiresInLayer(iCLayer); ++iWire) {
44 m_wires.push_back(CDCWire(WireID(iCLayer, iWire)));
45 }
46 }
47
48 // create all wire layers
49 std::vector<VectorRange<CDCWire>> wiresByILayer =
50 adjacent_groupby(m_wires.begin(), m_wires.end(), GetILayer());
51
52 for (VectorRange<CDCWire> wiresForILayer : wiresByILayer) {
53 m_wireLayers.push_back(CDCWireLayer(wiresForILayer));
54 }
55
56 // create all superlayers
57 std::vector<VectorRange<CDCWireLayer> > layersByISuperLayer =
58 adjacent_groupby(m_wireLayers.begin(), m_wireLayers.end(), Common<GetISuperLayer>());
59
60 if (cdcGeo.getOffsetOfFirstSuperLayer() > 0) {
61 for (uint superLayer = 0; superLayer < cdcGeo.getOffsetOfFirstSuperLayer(); ++superLayer) {
63 }
64 }
65
66 for (VectorRange<CDCWireLayer> layersForISuperLayer : layersByISuperLayer) {
67 m_wireSuperLayers.push_back(CDCWireSuperLayer(layersForISuperLayer));
68 }
69}
70
71void CDCWireTopology::reinitialize(EWirePosition wirePosition, bool ignoreWireSag)
72{
73 for (CDCWire& wire : m_wires) {
74 wire.initialize(wirePosition, ignoreWireSag);
75 }
76
77 for (CDCWireLayer& wireLayer : m_wireLayers) {
78 wireLayer.initialize();
79 }
80
81 for (CDCWireSuperLayer& wireSuperLayer : m_wireSuperLayers) {
82 wireSuperLayer.initialize();
83 }
84}
85
87{
88 const CDCWireTopology& cdcWireTopology = CDCWireTopology::getInstance();
89 const std::vector<CDCWireSuperLayer>& wireSuperLayers = cdcWireTopology.getWireSuperLayers();
90
91 if (std::isnan(cylindricalR) or cylindricalR < 0) {
93 }
94
95 if (cylindricalR < cdcWireTopology.getWireSuperLayer(0).getInnerCylindricalR()) {
97 }
98
99 for (const CDCWireSuperLayer& wireSuperLayer : wireSuperLayers) {
100 if (cylindricalR <= wireSuperLayer.getOuterCylindricalR()) {
101 return wireSuperLayer.getISuperLayer();
102 }
103 }
104
106}
107
108WireNeighborKind CDCWireTopology::getNeighborKind(const WireID& wireID, const WireID& otherWireID) const
109{
110 if (wireID.getISuperLayer() != otherWireID.getISuperLayer() and
112 return WireNeighborKind();
113 } else {
114 const CDCWireSuperLayer& superlayer = getWireSuperLayer(wireID.getISuperLayer());
115 return superlayer.getNeighborKind(wireID.getILayer(),
116 wireID.getIWire(),
117 otherWireID.getILayer(),
118 otherWireID.getIWire());
119 }
120}
The Class for CDC Geometry Parameters.
ushort getOffsetOfFirstLayer() const
Get the offset of the first layer.
unsigned nWiresInLayer(int layerId) const
Returns wire numbers in a layer.
static CDCGeometryPar & Instance(const CDCGeometry *=nullptr)
Static method to get a reference to the CDCGeometryPar instance.
ushort getOffsetOfFirstSuperLayer() const
Get the offset of the first super layer.
unsigned nWireLayers() const
Returns a number of wire layers.
Class representing a sense wire layer in the central drift chamber.
Class representing a sense wire superlayer in the central drift chamber.
double getInnerCylindricalR() const
Getter for the inner radius of the layer as retrieved from the CDCGeometryPar by the inner most layer...
WireNeighborKind getNeighborKind(ILayer iLayer, IWire iWire, ILayer iOtherLayer, IWire iOtherWire) const
Checks if two wires are closest neighbors.
static const ISuperLayer c_NSuperLayers
Total number of superlayers.
WireNeighborKind getNeighborKind(const WireID &wireID, const WireID &otherWireID) const
Checks if two wires are closest neighbors.
void initialize()
Create all wires, wire layers and wire superlayers and their interdependences with base geometry from...
std::vector< CDCWireSuperLayer > m_wireSuperLayers
Storage for all wire superlayers in the CDC.
static const ILayer c_NLayers
Total number of layers.
std::vector< CDCWire > m_wires
Storage for all wires in the CDC.
ISuperLayer getISuperLayerAtCylindricalR(double cylindricalR)
Returns the logical superlayer number at the given radius.
const CDCWireSuperLayer & getWireSuperLayer(const WireID &wireID) const
Getter for wire superlayer getter by wireID object.
void reinitialize(EWirePosition wirePosition, bool ignoreWireSag)
Reload all geometry parameters form the CDCGeometryPar to adjust to changes in geometry.
std::vector< CDCWireLayer > m_wireLayers
Storage for all wire layers in the CDC.
CDCWireTopology()
Default constructor for ROOT compatibility. Use rather getInstance to get the shared singleton instan...
static CDCWireTopology & getInstance()
Getter for the singleton instance of the wire topology.
ILayer m_FirstLayerOffset
Offset of first layer.
const std::vector< CDCWireSuperLayer > & getWireSuperLayers() const
Getter for the underlying storing superlayer vector.
static const IWire c_NWires
Total number of wires.
bool isValidISuperLayer(ISuperLayer iSuperLayer) const
Checks the validity of the superlayer id.
Class representing a sense wire in the central drift chamber.
Definition CDCWire.h:50
Type for the neighbor relationship from one wire to another.
Class to identify a wire inside the CDC.
Definition WireID.h:34
unsigned short getIWire() const
Getter for wire within the layer.
Definition WireID.h:145
unsigned short getISuperLayer() const
Getter for Super-Layer.
Definition WireID.h:130
unsigned short getILayer() const
Getter for layer within the Super-Layer.
Definition WireID.h:136
CDCGeometryPar::EWirePosition EWirePosition
For ease-of-use just create a new alias for CDCGeometryPar::EWirePosition.
signed short ISuperLayer
The type of the layer and superlayer ids.
Definition ISuperLayer.h:24
Abstract base class for different kinds of events.
Generic functor to get the superlayer id from an object.
Definition ILayer.h:21
static const ISuperLayer c_Invalid
Constant making an invalid superlayer id.
Definition ISuperLayer.h:65
static const ISuperLayer c_InnerVolume
Constant marking the subdetectors closer to the IP than the CDC.
Definition ISuperLayer.h:59
static const ISuperLayer c_OuterVolume
Constant marking the subdetectors further away from the IP than the CDC.
Definition ISuperLayer.h:62
Adapter of a category function to find the common category of several objects.
Definition Common.h:19