Belle II Software  release-05-01-25
CDCWireSuperLayer.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2012 - 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 #include <tracking/trackFindingCDC/topology/CDCWireSuperLayer.h>
11 
12 #include <tracking/trackFindingCDC/numerics/Modulo.h>
13 
14 using namespace Belle2;
15 using namespace TrackFindingCDC;
16 
18  : Super(wireLayers)
19  , m_innerRefZ(0.0)
20  , m_outerRefZ(0.0)
21  , m_refTanLambda(0.0)
22 {
23  initialize();
24 }
25 
27 {
28 }
29 
31  IWire iWire,
32  ILayer iOtherLayer,
33  IWire iOtherWire) const
34 {
35  if (not isValidILayer(iLayer)) return WireNeighborKind();
36  if (not isValidILayer(iOtherLayer)) return WireNeighborKind();
37 
38  const ILayer iLayerDifference = iOtherLayer - iLayer;
39  const ILayer absILayerDifference = abs(iLayerDifference);
40  const CDCWireLayer& layer = getWireLayer(iLayer);
41  const CDCWireLayer& otherLayer = getWireLayer(iOtherLayer);
42  const ERotation deltaShift = otherLayer.getShiftDelta(layer);
43  const IWire nWires = layer.size();
44 
45  int iRow = 2 * iWire;
46  int iOtherRow = 2 * iOtherWire + deltaShift;
47  int iRowDelta = symmetricModuloFast(iOtherRow - iRow, 2 * nWires);
48  int absIRowDelta = abs(iRowDelta);
49 
50  if ((absILayerDifference + absIRowDelta) > 4 or absILayerDifference > 2) return WireNeighborKind(); // Invalid case
51  if (absILayerDifference + absIRowDelta == 0) return WireNeighborKind(0, 0);
52 
53  int cellDistance = absILayerDifference == 2 ? 2 : (absILayerDifference + absIRowDelta) / 2;
54 
55  int slope = 0;
56  if (iRowDelta == 0) {
57  slope = 3;
58  } else if (iLayerDifference == 0) {
59  slope = 0;
60  } else if (absIRowDelta == 3) {
61  slope = 1;
62  } else {
63  slope = 2;
64  }
65 
66  if (iRowDelta > 0) {
67  slope = 6 - slope;
68  }
69 
70  if (iLayerDifference > 0) {
71  slope = -slope;
72  }
73 
74  int oClockDirection = moduloFast(slope + 3 , 12);
75  return WireNeighborKind(cellDistance, oClockDirection);
76 }
77 
79 {
80  if (not isValidILayer(iLayer - 1)) return WireNeighborPair(nullptr, nullptr);
81 
82  const CDCWireLayer& layer = getWireLayer(iLayer);
83  const CDCWireLayer& neighborLayer = getWireLayer(iLayer - 1);
84  const ERotation deltaShift = neighborLayer.getShiftDelta(layer);
85 
86  if (deltaShift == ERotation::c_CounterClockwise) {
87  return WireNeighborPair(&(neighborLayer.getWireWrappedAround(iWire)),
88  &(neighborLayer.getWireWrappedAround(iWire - 1)));
89  } else if (deltaShift == ERotation::c_Clockwise) {
90  return WireNeighborPair(&(neighborLayer.getWireWrappedAround(iWire + 1)),
91  &(neighborLayer.getWireWrappedAround(iWire)));
92  } else {
93  B2WARNING("Wire numbering shift bigger than one in magnitude. Adjust getNeighbor functions " << static_cast<int>(deltaShift));
94  B2WARNING("From iLayer " << iLayer << " and wire " << iWire << " to iLayer " << iLayer - 1);
95  return WireNeighborPair(nullptr , nullptr);
96  }
97 
98 }
99 
101 {
102  if (not isValidILayer(iLayer + 1)) return WireNeighborPair(nullptr, nullptr);
103 
104  const CDCWireLayer& layer = getWireLayer(iLayer);
105  const CDCWireLayer& neighborLayer = getWireLayer(iLayer + 1);
106  const ERotation deltaShift = neighborLayer.getShiftDelta(layer);
107 
108  if (deltaShift == ERotation::c_CounterClockwise) {
109  return WireNeighborPair(&(neighborLayer.getWireWrappedAround(iWire)),
110  &(neighborLayer.getWireWrappedAround(iWire - 1)));
111  } else if (deltaShift == ERotation::c_Clockwise) {
112  return WireNeighborPair(&(neighborLayer.getWireWrappedAround(iWire + 1)),
113  &(neighborLayer.getWireWrappedAround(iWire)));
114  } else {
115  B2WARNING("Wire numbering shift bigger than one in magnitude. Adjust getNeighbor functions " << static_cast<int>(deltaShift));
116  B2WARNING("From iLayer " << iLayer << " and wire " << iWire << " to iLayer " << iLayer + 1);
117  return WireNeighborPair(nullptr , nullptr);
118  }
119 
120 }
Belle2::TrackFindingCDC::CDCWireSuperLayer::getNeighborsOutwards
WireNeighborPair getNeighborsOutwards(ILayer iLayer, IWire iWire) const
Getter for the two closest neighbors in the layer outwards of the given on.
Definition: CDCWireSuperLayer.cc:100
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::CDCWireSuperLayer::CDCWireSuperLayer
CDCWireSuperLayer(const ConstVectorRange< CDCWireLayer > &wireLayers)
Constructor taking the range of layers the superlayer shall contain. Use rather getInstance() to avoi...
Definition: CDCWireSuperLayer.cc:17
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::CDCWireLayer::getWireWrappedAround
const CDCWire & getWireWrappedAround(IWire iWire) const
Returns the wire by its id in the layer.
Definition: CDCWireLayer.h:171
Belle2::TrackFindingCDC::NRotation::ERotation
ERotation
Enumeration to represent the distinct possibilities of the right left passage information.
Definition: ERotation.h:35
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::CDCWireSuperLayer::getNeighborsInwards
WireNeighborPair getNeighborsInwards(ILayer iLayer, IWire iWire) const
Getter for the two closest neighbors in the layer inwards of the given on.
Definition: CDCWireSuperLayer.cc:78
Belle2::TrackFindingCDC::CDCWireSuperLayer::isValidILayer
bool isValidILayer(ILayer iLayer) const
Checks if the given layer id belongs to a valid layer in this superlayer.
Definition: CDCWireSuperLayer.h:92
Belle2::TrackFindingCDC::CDCWireSuperLayer::getWireLayer
const CDCWireLayer & getWireLayer(ILayer iLayer) const
Gives the layer by its layer id within the superlayer.
Definition: CDCWireSuperLayer.h:96
Belle2::TrackFindingCDC::WireNeighborKind
Type for the neighbor relationship from one wire to another.
Definition: WireNeighborKind.h:35
Belle2::TrackFindingCDC::CDCWireSuperLayer::initialize
void initialize()
Intializes the superlayer variables of according the layer range. Set the numbering shift of containe...
Definition: CDCWireSuperLayer.cc:26
Belle2::TrackFindingCDC::WireNeighborPair
Class representing a pair of neighbors in the CDC in a single layer For certain circumstances it is a...
Definition: WireNeighborPair.h:39
Belle2::TrackFindingCDC::CDCWireLayer::getShiftDelta
ERotation getShiftDelta(const CDCWireLayer &baseLayer) const
Getter for the relative difference in wire numbering shift.
Definition: CDCWireLayer.h:134