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 <tracking/trackFindingCDC/topology/CDCWireSuperLayer.h>
9
10#include <tracking/trackFindingCDC/numerics/Modulo.h>
11
12using namespace Belle2;
13using namespace TrackFindingCDC;
14
16 : Super(wireLayers)
17 , m_innerRefZ(0.0)
18 , m_outerRefZ(0.0)
19 , m_refTanLambda(0.0)
20{
21 initialize();
22}
23
25{
26}
27
29 IWire iWire,
30 ILayer iOtherLayer,
31 IWire iOtherWire) const
32{
33 if (not isValidILayer(iLayer)) return WireNeighborKind();
34 if (not isValidILayer(iOtherLayer)) return WireNeighborKind();
35
36 const ILayer iLayerDifference = iOtherLayer - iLayer;
37 const ILayer absILayerDifference = abs(iLayerDifference);
38 const CDCWireLayer& layer = getWireLayer(iLayer);
39 const CDCWireLayer& otherLayer = getWireLayer(iOtherLayer);
40 const ERotation deltaShift = otherLayer.getShiftDelta(layer);
41 const IWire nWires = layer.size();
42
43 int iRow = 2 * iWire;
44 int iOtherRow = 2 * iOtherWire + deltaShift;
45 int iRowDelta = symmetricModuloFast(iOtherRow - iRow, 2 * nWires);
46 int absIRowDelta = abs(iRowDelta);
47
48 if ((absILayerDifference + absIRowDelta) > 4 or absILayerDifference > 2) return WireNeighborKind(); // Invalid case
49 if (absILayerDifference + absIRowDelta == 0) return WireNeighborKind(0, 0);
50
51 int cellDistance = absILayerDifference == 2 ? 2 : (absILayerDifference + absIRowDelta) / 2;
52
53 int slope = 0;
54 if (iRowDelta == 0) {
55 slope = 3;
56 } else if (iLayerDifference == 0) {
57 slope = 0;
58 } else if (absIRowDelta == 3) {
59 slope = 1;
60 } else {
61 slope = 2;
62 }
63
64 if (iRowDelta > 0) {
65 slope = 6 - slope;
66 }
67
68 if (iLayerDifference > 0) {
69 slope = -slope;
70 }
71
72 int oClockDirection = moduloFast(slope + 3 , 12);
73 return WireNeighborKind(cellDistance, oClockDirection);
74}
75
77{
78 if (not isValidILayer(iLayer - 1)) return WireNeighborPair(nullptr, nullptr);
79
80 const CDCWireLayer& layer = getWireLayer(iLayer);
81 const CDCWireLayer& neighborLayer = getWireLayer(iLayer - 1);
82 const ERotation deltaShift = neighborLayer.getShiftDelta(layer);
83
84 if (deltaShift == ERotation::c_CounterClockwise) {
85 return WireNeighborPair(&(neighborLayer.getWireWrappedAround(iWire)),
86 &(neighborLayer.getWireWrappedAround(iWire - 1)));
87 } else if (deltaShift == ERotation::c_Clockwise) {
88 return WireNeighborPair(&(neighborLayer.getWireWrappedAround(iWire + 1)),
89 &(neighborLayer.getWireWrappedAround(iWire)));
90 } else {
91 B2WARNING("Wire numbering shift bigger than one in magnitude. Adjust getNeighbor functions " << static_cast<int>(deltaShift));
92 B2WARNING("From iLayer " << iLayer << " and wire " << iWire << " to iLayer " << iLayer - 1);
93 return WireNeighborPair(nullptr , nullptr);
94 }
95
96}
97
99{
100 if (not isValidILayer(iLayer + 1)) return WireNeighborPair(nullptr, nullptr);
101
102 const CDCWireLayer& layer = getWireLayer(iLayer);
103 const CDCWireLayer& neighborLayer = getWireLayer(iLayer + 1);
104 const ERotation deltaShift = neighborLayer.getShiftDelta(layer);
105
106 if (deltaShift == ERotation::c_CounterClockwise) {
107 return WireNeighborPair(&(neighborLayer.getWireWrappedAround(iWire)),
108 &(neighborLayer.getWireWrappedAround(iWire - 1)));
109 } else if (deltaShift == ERotation::c_Clockwise) {
110 return WireNeighborPair(&(neighborLayer.getWireWrappedAround(iWire + 1)),
111 &(neighborLayer.getWireWrappedAround(iWire)));
112 } else {
113 B2WARNING("Wire numbering shift bigger than one in magnitude. Adjust getNeighbor functions " << static_cast<int>(deltaShift));
114 B2WARNING("From iLayer " << iLayer << " and wire " << iWire << " to iLayer " << iLayer + 1);
115 return WireNeighborPair(nullptr , nullptr);
116 }
117
118}
Class representating a sense wire layer in the central drift chamber.
Definition: CDCWireLayer.h:42
const CDCWire & getWireWrappedAround(IWire iWire) const
Returns the wire by its id in the layer.
Definition: CDCWireLayer.h:161
ERotation getShiftDelta(const CDCWireLayer &baseLayer) const
Getter for the relative difference in wire numbering shift.
Definition: CDCWireLayer.h:124
void initialize()
Intializes the superlayer variables of according the layer range. Set the numbering shift of containe...
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.
WireNeighborPair getNeighborsInwards(ILayer iLayer, IWire iWire) const
Getter for the two closest neighbors in the layer inwards of the given on.
A pair of iterators usable with the range base for loop.
Definition: Range.h:25
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...
ERotation
Enumeration to represent the distinct possibilities of the right left passage information.
Definition: ERotation.h:25
Abstract base class for different kinds of events.