Belle II Software development
CDCWireSuperLayer.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#include <cdc/topology/CDCWireSuperLayer.h>
9
10#include <tracking/trackingUtilities/numerics/Modulo.h>
11
12using namespace Belle2;
13using namespace CDC;
14using namespace TrackingUtilities;
15
16CDCWireSuperLayer::CDCWireSuperLayer(const ConstVectorRange<CDCWireLayer>& wireLayers)
17 : Super(wireLayers)
18 , m_innerRefZ(0.0)
19 , m_outerRefZ(0.0)
20 , m_refTanLambda(0.0)
21{
22 initialize();
23}
24
28
30 IWire iWire,
31 ILayer iOtherLayer,
32 IWire iOtherWire) const
33{
34 if (not isValidILayer(iLayer)) return WireNeighborKind();
35 if (not isValidILayer(iOtherLayer)) return WireNeighborKind();
36
37 const ILayer iLayerDifference = iOtherLayer - iLayer;
38 const ILayer absILayerDifference = abs(iLayerDifference);
39 const CDCWireLayer& layer = getWireLayer(iLayer);
40 const CDCWireLayer& otherLayer = getWireLayer(iOtherLayer);
41 const ERotation deltaShift = otherLayer.getShiftDelta(layer);
42 const IWire nWires = layer.size();
43
44 int iRow = 2 * iWire;
45 int iOtherRow = 2 * iOtherWire + deltaShift;
46 int iRowDelta = symmetricModuloFast(iOtherRow - iRow, 2 * nWires);
47 int absIRowDelta = abs(iRowDelta);
48
49 if ((absILayerDifference + absIRowDelta) > 4 or absILayerDifference > 2) return WireNeighborKind(); // Invalid case
50 if (absILayerDifference + absIRowDelta == 0) return WireNeighborKind(0, 0);
51
52 int cellDistance = absILayerDifference == 2 ? 2 : (absILayerDifference + absIRowDelta) / 2;
53
54 int slope = 0;
55 if (iRowDelta == 0) {
56 slope = 3;
57 } else if (iLayerDifference == 0) {
58 slope = 0;
59 } else if (absIRowDelta == 3) {
60 slope = 1;
61 } else {
62 slope = 2;
63 }
64
65 if (iRowDelta > 0) {
66 slope = 6 - slope;
67 }
68
69 if (iLayerDifference > 0) {
70 slope = -slope;
71 }
72
73 int oClockDirection = moduloFast(slope + 3, 12);
74 return WireNeighborKind(cellDistance, oClockDirection);
75}
76
78{
79 if (not isValidILayer(iLayer - 1)) return WireNeighborPair(nullptr, nullptr);
80
81 const CDCWireLayer& layer = getWireLayer(iLayer);
82 const CDCWireLayer& neighborLayer = getWireLayer(iLayer - 1);
83 const ERotation deltaShift = neighborLayer.getShiftDelta(layer);
84
85 if (deltaShift == ERotation::c_CounterClockwise) {
86 return WireNeighborPair(&(neighborLayer.getWireWrappedAround(iWire)),
87 &(neighborLayer.getWireWrappedAround(iWire - 1)));
88 } else if (deltaShift == ERotation::c_Clockwise) {
89 return WireNeighborPair(&(neighborLayer.getWireWrappedAround(iWire + 1)),
90 &(neighborLayer.getWireWrappedAround(iWire)));
91 } else {
92 B2WARNING("Wire numbering shift bigger than one in magnitude. Adjust getNeighbor functions " << static_cast<int>(deltaShift));
93 B2WARNING("From iLayer " << iLayer << " and wire " << iWire << " to iLayer " << iLayer - 1);
94 return WireNeighborPair(nullptr, nullptr);
95 }
96
97}
98
100{
101 if (not isValidILayer(iLayer + 1)) return WireNeighborPair(nullptr, nullptr);
102
103 const CDCWireLayer& layer = getWireLayer(iLayer);
104 const CDCWireLayer& neighborLayer = getWireLayer(iLayer + 1);
105 const ERotation deltaShift = neighborLayer.getShiftDelta(layer);
106
107 if (deltaShift == ERotation::c_CounterClockwise) {
108 return WireNeighborPair(&(neighborLayer.getWireWrappedAround(iWire)),
109 &(neighborLayer.getWireWrappedAround(iWire - 1)));
110 } else if (deltaShift == ERotation::c_Clockwise) {
111 return WireNeighborPair(&(neighborLayer.getWireWrappedAround(iWire + 1)),
112 &(neighborLayer.getWireWrappedAround(iWire)));
113 } else {
114 B2WARNING("Wire numbering shift bigger than one in magnitude. Adjust getNeighbor functions " << static_cast<int>(deltaShift));
115 B2WARNING("From iLayer " << iLayer << " and wire " << iWire << " to iLayer " << iLayer + 1);
116 return WireNeighborPair(nullptr, nullptr);
117 }
118
119}
Class representing a sense wire layer in the central drift chamber.
TrackingUtilities::ERotation getShiftDelta(const CDCWireLayer &baseLayer) const
Getter for the relative difference in wire numbering shift.
const CDCWire & getWireWrappedAround(IWire iWire) const
Returns the wire by its id in the layer.
double m_refTanLambda
Memory for (fitted) proportionality factor between the increasing cylindrical radius and the referenc...
void initialize()
Initializes the superlayer variables of according the layer range. Set the numbering shift of contain...
double m_outerRefZ
Memory for the (fitted) z of the reference wire reference points at the outer cylindricalR of this su...
double m_innerRefZ
Memory for the (fitted) z of the reference wire reference points at the inner cylindricalR of this su...
WireNeighborPair getNeighborsOutwards(ILayer iLayer, IWire iWire) const
Getter for the two closest neighbors in the layer outwards of the given on.
CDCWireSuperLayer()
Empty constructor for creating an empty dummy CDCWireSuperLayer for studies with a CDC with missing s...
bool isValidILayer(ILayer iLayer) const
Checks if the given layer id belongs to a valid layer in this superlayer.
const CDCWireLayer & getWireLayer(ILayer iLayer) const
Gives the layer by its layer id within the superlayer.
WireNeighborKind getNeighborKind(ILayer iLayer, IWire iWire, ILayer iOtherLayer, IWire iOtherWire) const
Checks if two wires are closest neighbors.
TrackingUtilities::ConstVectorRange< CDCWireLayer > Super
Type of the base class.
WireNeighborPair getNeighborsInwards(ILayer iLayer, IWire iWire) const
Getter for the two closest neighbors in the layer inwards of the given on.
Type for the neighbor relationship from one wire to another.
Class representing a pair of neighbors in the CDC in a single layer For certain circumstances it is a...
signed short IWire
The type of the wire ids enumerating wires within a given layer.
Definition IWire.h:20
signed short ILayer
The type of the layer ids enumerating layers within a superlayer.
Definition ILayer.h:18
Abstract base class for different kinds of events.