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 <tracking/trackFindingCDC/topology/CDCWireTopology.h>
10
11#include <tracking/trackFindingCDC/utilities/Algorithms.h>
12
13#include <tracking/trackFindingCDC/utilities/Common.h>
14
15#include <cdc/geometry/CDCGeometryPar.h>
16
17using namespace Belle2;
18using namespace TrackFindingCDC;
19
21{
22 // Definition of the singleton instance
23 static CDCWireTopology instance;
24 return instance;
25}
26
28{
29 m_wires.clear();
30 m_wireLayers.clear();
31 m_wireSuperLayers.clear();
32
33 m_wires.reserve(c_NWires);
34 m_wireLayers.reserve(c_NLayers);
36
37 // create all wires
40
41 for (size_t iCLayer = 0; iCLayer < cdcGeo.nWireLayers() ; ++iCLayer) {
42 for (size_t iWire = 0; iWire < cdcGeo.nWiresInLayer(iCLayer); ++iWire) {
43 m_wires.push_back(CDCWire(WireID(iCLayer, iWire)));
44 }
45 }
46
47 // create all wire layers
48 std::vector<VectorRange<CDCWire>> wiresByILayer =
49 adjacent_groupby(m_wires.begin(), m_wires.end(), GetILayer());
50
51 for (VectorRange<CDCWire> wiresForILayer : wiresByILayer) {
52 m_wireLayers.push_back(CDCWireLayer(wiresForILayer));
53 }
54
55 // create all superlayers
56 std::vector<VectorRange<CDCWireLayer> > layersByISuperLayer =
57 adjacent_groupby(m_wireLayers.begin(), m_wireLayers.end(), Common<GetISuperLayer>());
58
59 if (cdcGeo.getOffsetOfFirstSuperLayer() > 0) {
60 for (uint superLayer = 0; superLayer < cdcGeo.getOffsetOfFirstSuperLayer(); ++superLayer) {
62 }
63 }
64
65 for (VectorRange<CDCWireLayer> layersForISuperLayer : layersByISuperLayer) {
66 m_wireSuperLayers.push_back(CDCWireSuperLayer(layersForISuperLayer));
67 }
68}
69
70void CDCWireTopology::reinitialize(EWirePosition wirePosition, bool ignoreWireSag)
71{
72 for (CDCWire& wire : m_wires) {
73 wire.initialize(wirePosition, ignoreWireSag);
74 }
75
76 for (CDCWireLayer& wireLayer : m_wireLayers) {
77 wireLayer.initialize();
78 }
79
80 for (CDCWireSuperLayer& wireSuperLayer : m_wireSuperLayers) {
81 wireSuperLayer.initialize();
82 }
83}
84
85ISuperLayer CDCWireTopology::getISuperLayerAtCylindricalR(double cylindricalR)
86{
87 const CDCWireTopology& cdcWireTopology = CDCWireTopology::getInstance();
88 const std::vector<CDCWireSuperLayer>& wireSuperLayers = cdcWireTopology.getWireSuperLayers();
89
90 if (std::isnan(cylindricalR) or cylindricalR < 0) {
92 }
93
94 if (cylindricalR < cdcWireTopology.getWireSuperLayer(0).getInnerCylindricalR()) {
96 }
97
98 for (const CDCWireSuperLayer& wireSuperLayer : wireSuperLayers) {
99 if (cylindricalR <= wireSuperLayer.getOuterCylindricalR()) {
100 return wireSuperLayer.getISuperLayer();
101 }
102 }
103
105}
106
107WireNeighborKind CDCWireTopology::getNeighborKind(const WireID& wireID, const WireID& otherWireID) const
108{
109 if (wireID.getISuperLayer() != otherWireID.getISuperLayer() and
111 return WireNeighborKind();
112 } else {
113 const CDCWireSuperLayer& superlayer = getWireSuperLayer(wireID.getISuperLayer());
114 return superlayer.getNeighborKind(wireID.getILayer(),
115 wireID.getIWire(),
116 otherWireID.getILayer(),
117 otherWireID.getIWire());
118 }
119}
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.
std::vector< Belle2::TrackFindingCDC::CDCWire > m_wires
Storage for all wires in the CDC.
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...
static const ILayer c_NLayers
Total number of layers.
const std::vector< Belle2::TrackFindingCDC::CDCWireSuperLayer > & getWireSuperLayers() const
Getter for the underlying storing superlayer vector.
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.
std::vector< Belle2::TrackFindingCDC::CDCWireLayer > m_wireLayers
Storage for all wire layers in the CDC.
void reinitialize(EWirePosition wirePosition, bool ignoreWireSag)
Reload all geometry parameters form the CDCGeometryPar to adjust to changes in geometry.
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.
static const IWire c_NWires
Total number of wires.
bool isValidISuperLayer(ISuperLayer iSuperLayer) const
Checks the validity of the superlayer id.
std::vector< Belle2::TrackFindingCDC::CDCWireSuperLayer > m_wireSuperLayers
Storage for all wire superlayers in the CDC.
Class representing a sense wire in the central drift chamber.
Definition CDCWire.h:58
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
Abstract base class for different kinds of events.
Adapter of a category function to find the common category of several objects.
Definition Common.h:19
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