Belle II Software  release-05-02-19
CDCWireTopology.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2013 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <tracking/trackFindingCDC/topology/CDCWireTopology.h>
12 
13 #include <tracking/trackFindingCDC/utilities/Algorithms.h>
14 
15 #include <tracking/trackFindingCDC/utilities/Common.h>
16 
17 #include <cdc/geometry/CDCGeometryPar.h>
18 
19 using namespace Belle2;
20 using namespace TrackFindingCDC;
21 
23 {
24  // Definition of the singleton instance
25  static CDCWireTopology instance;
26  return instance;
27 }
28 
30 {
31  m_wires.clear();
32  m_wireLayers.clear();
33  m_wireSuperLayers.clear();
34 
35  m_wires.reserve(c_NWires);
36  m_wireLayers.reserve(c_NLayers);
38 
39  // create all wires
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  for (VectorRange<CDCWireLayer> layersForISuperLayer : layersByISuperLayer) {
60  m_wireSuperLayers.push_back(CDCWireSuperLayer(layersForISuperLayer));
61  }
62 }
63 
64 void CDCWireTopology::reinitialize(EWirePosition wirePosition, bool ignoreWireSag)
65 {
66  for (CDCWire& wire : m_wires) {
67  wire.initialize(wirePosition, ignoreWireSag);
68  }
69 
70  for (CDCWireLayer& wireLayer : m_wireLayers) {
71  wireLayer.initialize();
72  }
73 
74  for (CDCWireSuperLayer& wireSuperLayer : m_wireSuperLayers) {
75  wireSuperLayer.initialize();
76  }
77 }
78 
79 ISuperLayer CDCWireTopology::getISuperLayerAtCylindricalR(double cylindricalR)
80 {
81  const CDCWireTopology& cdcWireTopology = CDCWireTopology::getInstance();
82  const std::vector<CDCWireSuperLayer>& wireSuperLayers = cdcWireTopology.getWireSuperLayers();
83 
84  if (std::isnan(cylindricalR) or cylindricalR < 0) {
86  }
87 
88  if (cylindricalR < cdcWireTopology.getWireSuperLayer(0).getInnerCylindricalR()) {
90  }
91 
92  for (const CDCWireSuperLayer& wireSuperLayer : wireSuperLayers) {
93  if (cylindricalR <= wireSuperLayer.getOuterCylindricalR()) {
94  return wireSuperLayer.getISuperLayer();
95  }
96  }
97 
99 }
100 
101 WireNeighborKind CDCWireTopology::getNeighborKind(const WireID& wireID, const WireID& otherWireID) const
102 {
103  if (wireID.getISuperLayer() != otherWireID.getISuperLayer() and
105  return WireNeighborKind();
106  } else {
107  const CDCWireSuperLayer& superlayer = getWireSuperLayer(wireID.getISuperLayer());
108  return superlayer.getNeighborKind(wireID.getILayer(),
109  wireID.getIWire(),
110  otherWireID.getILayer(),
111  otherWireID.getIWire());
112  }
113 }
Belle2::WireID
Class to identify a wire inside the CDC.
Definition: WireID.h:44
Belle2::CDC::CDCGeometryPar::nWireLayers
unsigned nWireLayers() const
Returns a number of wire layers.
Definition: CDCGeometryPar.h:1311
Belle2::TrackFindingCDC::Common
Adapter of a category function to find the common category of several objects.
Definition: Common.h:31
Belle2::WireID::getILayer
unsigned short getILayer() const
Getter for layer within the Super-Layer.
Definition: WireID.h:146
Belle2::TrackFindingCDC::CDCWireTopology::m_wireLayers
std::vector< Belle2::TrackFindingCDC::CDCWireLayer > m_wireLayers
Storage for all wire layers in the CDC.
Definition: CDCWireTopology.h:493
Belle2::TrackFindingCDC::CDCWireTopology::m_wires
std::vector< Belle2::TrackFindingCDC::CDCWire > m_wires
Storage for all wires in the CDC.
Definition: CDCWireTopology.h:490
Belle2::TrackFindingCDC::ISuperLayerUtil::c_Invalid
static const ISuperLayer c_Invalid
Constant making an invalid superlayer id.
Definition: ISuperLayer.h:75
Belle2::TrackFindingCDC::CDCWireTopology::initialize
void initialize()
Create all wires, wire layers and wire superlayers and their interdependences with base geometry from...
Definition: CDCWireTopology.cc:29
Belle2::TrackFindingCDC::CDCWireTopology::getInstance
static CDCWireTopology & getInstance()
Getter for the singleton instance of the wire topology.
Definition: CDCWireTopology.cc:22
Belle2::WireID::getISuperLayer
unsigned short getISuperLayer() const
Getter for Super-Layer.
Definition: WireID.h:140
Belle2::TrackFindingCDC::CDCWireSuperLayer::getNeighborKind
WireNeighborKind getNeighborKind(ILayer iLayer, IWire iWire, ILayer iOtherLayer, IWire iOtherWire) const
Checks if two wires are closest neighbors.
Definition: CDCWireSuperLayer.cc:30
Belle2::TrackFindingCDC::CDCWireTopology::c_NLayers
static const ILayer c_NLayers
Total number of layers.
Definition: CDCWireTopology.h:76
Belle2::TrackFindingCDC::CDCWireTopology::c_NWires
static const IWire c_NWires
Total number of wires.
Definition: CDCWireTopology.h:73
Belle2::TrackFindingCDC::ISuperLayerUtil::c_OuterVolume
static const ISuperLayer c_OuterVolume
Constant marking the subdetectors further away from the IP than the CDC.
Definition: ISuperLayer.h:72
Belle2::TrackFindingCDC::CDCWireTopology::c_NSuperLayers
static const ISuperLayer c_NSuperLayers
Total number of superlayers.
Definition: CDCWireTopology.h:79
Belle2::CDC::CDCGeometryPar
The Class for CDC Geometry Parameters.
Definition: CDCGeometryPar.h:75
Belle2::CDC::CDCGeometryPar::Instance
static CDCGeometryPar & Instance(const CDCGeometry *=nullptr)
Static method to get a reference to the CDCGeometryPar instance.
Definition: CDCGeometryPar.cc:41
Belle2::TrackFindingCDC::CDCWireTopology::getWireSuperLayers
const std::vector< Belle2::TrackFindingCDC::CDCWireSuperLayer > & getWireSuperLayers() const
Getter for the underlying storing superlayer vector.
Definition: CDCWireTopology.h:191
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::CDCWireTopology::getISuperLayerAtCylindricalR
ISuperLayer getISuperLayerAtCylindricalR(double cylindricalR)
Returns the logical superlayer number at the given radius.
Definition: CDCWireTopology.cc:79
Belle2::TrackFindingCDC::CDCWireTopology::getWireSuperLayer
const CDCWireSuperLayer & getWireSuperLayer(const WireID &wireID) const
Getter for wire superlayer getter by wireID object.
Definition: CDCWireTopology.h:181
Belle2::TrackFindingCDC::Range
A pair of iterators usable with the range base for loop.
Definition: Range.h:35
Belle2::TrackFindingCDC::CDCWireLayer
Class representating a sense wire layer in the central drift chamber.
Definition: CDCWireLayer.h:51
Belle2::TrackFindingCDC::ISuperLayerUtil::c_InnerVolume
static const ISuperLayer c_InnerVolume
Constant marking the subdetectors closer to the IP than the CDC.
Definition: ISuperLayer.h:69
Belle2::TrackFindingCDC::CDCWireTopology::reinitialize
void reinitialize(EWirePosition wirePosition, bool ignoreWireSag)
Reload all geometry parameters form the CDCGeometryPar to adjust to changes in geometry.
Definition: CDCWireTopology.cc:64
Belle2::TrackFindingCDC::NWirePosition::EWirePosition
EWirePosition
Wire position set.
Definition: EWirePosition.h:40
Belle2::TrackFindingCDC::CDCWireSuperLayer
Class representating a sense wire superlayer in the central drift chamber.
Definition: CDCWireSuperLayer.h:53
Belle2::TrackFindingCDC::CDCWire
Class representing a sense wire in the central drift chamber.
Definition: CDCWire.h:60
Belle2::CDC::CDCGeometryPar::nWiresInLayer
unsigned nWiresInLayer(int layerId) const
Returns wire numbers in a layer.
Definition: CDCGeometryPar.h:1211
Belle2::TrackFindingCDC::CDCWireTopology::m_wireSuperLayers
std::vector< Belle2::TrackFindingCDC::CDCWireSuperLayer > m_wireSuperLayers
Storage for all wire superlayers in the CDC.
Definition: CDCWireTopology.h:496
Belle2::TrackFindingCDC::GetILayer
Generic functor to get the superlayer id from an object.
Definition: ILayer.h:31
Belle2::TrackFindingCDC::WireNeighborKind
Type for the neighbor relationship from one wire to another.
Definition: WireNeighborKind.h:35
Belle2::TrackFindingCDC::CDCWireSuperLayer::getInnerCylindricalR
double getInnerCylindricalR() const
Getter for the inner radius of the layer as retrived from the CDCGeometryPar by the inner most layer.
Definition: CDCWireSuperLayer.h:138
Belle2::WireID::getIWire
unsigned short getIWire() const
Getter for wire within the layer.
Definition: WireID.h:155
Belle2::TrackFindingCDC::CDCWireTopology
Class representating the sense wire arrangement in the whole of the central drift chamber.
Definition: CDCWireTopology.h:54
Belle2::TrackFindingCDC::CDCWireTopology::getNeighborKind
WireNeighborKind getNeighborKind(const WireID &wireID, const WireID &otherWireID) const
Checks if two wires are closest neighbors.
Definition: CDCWireTopology.cc:101
Belle2::TrackFindingCDC::CDCWireTopology::isValidISuperLayer
bool isValidISuperLayer(ISuperLayer iSuperLayer) const
Checks the validity of the superlayer id.
Definition: CDCWireTopology.h:174