10 #include <gtest/gtest.h>
11 #include <tracking/trackFindingCDC/topology/CDCWireTopology.h>
13 #include <tracking/trackFindingCDC/eventdata/trajectories/CDCBFieldUtil.h>
14 #include <tracking/trackFindingCDC/testFixtures/TrackFindingCDCTestWithTopology.h>
15 #include <cdc/geometry/CDCGeometryPar.h>
16 #include <framework/logging/Logger.h>
19 using namespace TrackFindingCDC;
22 public ::testing::WithParamInterface<int> {
27 WireNeighborKind testNeighborKind(2, GetParam());
28 short oClockDirection = testNeighborKind.getOClockDirection();
29 short reverseOClockDirection = modulo(testNeighborKind.getOClockDirection() + 6, 12);
33 for (
const CDCWire& wire : theWireTopology.getWires()) {
34 MayBePtr<const CDCWire> neighbor = wire.getSecondaryNeighbor(oClockDirection);
35 if (neighbor !=
nullptr) {
36 MayBePtr<const CDCWire> neighbor_of_neighbor =
37 neighbor->getSecondaryNeighbor(reverseOClockDirection);
39 EXPECT_EQ(*neighbor_of_neighbor, wire);
41 WireNeighborKind neighborKind = wire.getNeighborKind(*neighbor);
42 EXPECT_TRUE(neighborKind.isValid());
43 EXPECT_EQ(testNeighborKind.getCellDistance(), neighborKind.getCellDistance());
44 EXPECT_EQ(oClockDirection, neighborKind.getOClockDirection());
45 EXPECT_EQ(neighbor->getILayer() - wire.getILayer(), neighborKind.getILayerDifference());
50 INSTANTIATE_TEST_CASE_P(SecondaryWireNeighborhoodTest_IsSymmetric,
52 ::testing::Range(0, 12));
55 TEST_F(TrackFindingCDCTestWithTopology, topology_WireNeighborSymmetry_CWInwards)
60 for (
const CDCWire& wire : theWireTopology.getWires()) {
61 MayBePtr<const CDCWire> neighbor = wire.getNeighborCWInwards();
62 if (neighbor !=
nullptr) {
63 MayBePtr<const CDCWire> neighbor_of_neighbor = neighbor->getNeighborCCWOutwards();
64 EXPECT_EQ(*neighbor_of_neighbor, wire);
66 WireNeighborKind neighborKind = wire.getNeighborKind(*neighbor);
67 EXPECT_EQ(1, neighborKind.getCellDistance());
68 EXPECT_EQ(5, neighborKind.getOClockDirection());
69 EXPECT_EQ(-1, neighborKind.getILayerDifference());
74 TEST_F(TrackFindingCDCTestWithTopology, topology_WireNeighborSymmetry_CCWInwards)
79 for (
const CDCWire& wire : theWireTopology.getWires()) {
80 MayBePtr<const CDCWire> neighbor = wire.getNeighborCCWInwards();
81 if (neighbor !=
nullptr) {
82 MayBePtr<const CDCWire> neighbor_of_neighbor = neighbor->getNeighborCWOutwards();
83 EXPECT_EQ(*neighbor_of_neighbor, wire);
85 WireNeighborKind neighborKind = wire.getNeighborKind(*neighbor);
86 EXPECT_EQ(1, neighborKind.getCellDistance());
87 EXPECT_EQ(7, neighborKind.getOClockDirection());
88 EXPECT_EQ(-1, neighborKind.getILayerDifference());
93 TEST_F(TrackFindingCDCTestWithTopology, topology_WireNeighborSymmetry_CWOutwards)
98 for (
const CDCWire& wire : theWireTopology.getWires()) {
99 MayBePtr<const CDCWire> neighbor = wire.getNeighborCWOutwards();
100 if (neighbor !=
nullptr) {
101 MayBePtr<const CDCWire> neighbor_of_neighbor = neighbor->getNeighborCCWInwards();
102 EXPECT_EQ(*neighbor_of_neighbor, wire);
104 WireNeighborKind neighborKind = wire.getNeighborKind(*neighbor);
105 EXPECT_EQ(1, neighborKind.getCellDistance());
106 EXPECT_EQ(1, neighborKind.getOClockDirection());
107 EXPECT_EQ(1, neighborKind.getILayerDifference());
112 TEST_F(TrackFindingCDCTestWithTopology, topology_WireNeighborSymmetry_CCWOutwards)
117 for (
const CDCWire& wire : theWireTopology.getWires()) {
118 MayBePtr<const CDCWire> neighbor = wire.getNeighborCCWOutwards();
119 if (neighbor !=
nullptr) {
120 MayBePtr<const CDCWire> neighbor_of_neighbor = neighbor->getNeighborCWInwards();
121 EXPECT_EQ(*neighbor_of_neighbor, wire);
123 WireNeighborKind neighborKind = wire.getNeighborKind(*neighbor);
124 EXPECT_EQ(1, neighborKind.getCellDistance());
125 EXPECT_EQ(11, neighborKind.getOClockDirection());
126 EXPECT_EQ(1, neighborKind.getILayerDifference());
131 TEST_F(TrackFindingCDCTestWithTopology, topology_WireNeighborSymmetry_CCW)
136 for (
const CDCWire& wire : theWireTopology.getWires()) {
137 MayBePtr<const CDCWire> neighbor = wire.getNeighborCCW();
138 if (neighbor !=
nullptr) {
139 MayBePtr<const CDCWire> neighbor_of_neighbor = neighbor->getNeighborCW();
140 EXPECT_EQ(*neighbor_of_neighbor, wire);
142 WireNeighborKind neighborKind = wire.getNeighborKind(*neighbor);
143 EXPECT_EQ(1, neighborKind.getCellDistance());
144 EXPECT_EQ(9, neighborKind.getOClockDirection());
145 EXPECT_EQ(0, neighborKind.getILayerDifference());
150 TEST_F(TrackFindingCDCTestWithTopology, topology_WireNeighborSymmetry_CW)
155 for (
const CDCWire& wire : theWireTopology.getWires()) {
156 MayBePtr<const CDCWire> neighbor = wire.getNeighborCW();
157 if (neighbor !=
nullptr) {
158 MayBePtr<const CDCWire> neighbor_of_neighbor = neighbor->getNeighborCCW();
159 EXPECT_EQ(*neighbor_of_neighbor, wire);
161 WireNeighborKind neighborKind = wire.getNeighborKind(*neighbor);
162 EXPECT_EQ(1, neighborKind.getCellDistance());
163 EXPECT_EQ(3, neighborKind.getOClockDirection());
164 EXPECT_EQ(0, neighborKind.getILayerDifference());
169 TEST_F(TrackFindingCDCTestWithTopology, topology_CDCWire_stereoAngle)
178 for (
const CDCWireLayer& wireLayer : theWireTopology.getWireLayers()) {
179 const ILayer iCLayer = wireLayer.getICLayer();
181 const CDCWire& firstWire = wireLayer.front();
182 tanThetaByICLayer[iCLayer] = firstWire.getTanStereoAngle();
183 stereoAngleByICLayer[iCLayer] = firstWire.getStereoAngle();
184 refCylindricalRByICLayer[iCLayer] = firstWire.getRefCylindricalR();
186 for (
const CDCWire& wire : wireLayer) {
190 EXPECT_NEAR(tanThetaByICLayer[iCLayer], wire.getTanStereoAngle(), 10e-2);
191 EXPECT_NEAR(stereoAngleByICLayer[iCLayer], wire.getStereoAngle(), 10e-2);
192 EXPECT_NEAR(refCylindricalRByICLayer[iCLayer], wire.getRefCylindricalR(), 10e-2);
195 B2INFO(
"ICLayer : " << iCLayer);
196 B2INFO(
" Tan Theta : " << tanThetaByICLayer[iCLayer]);
197 B2INFO(
" Stereo angle : " << stereoAngleByICLayer[iCLayer]);
198 B2INFO(
" Z range : " << wireLayer.getBackwardZ() <<
" to " << wireLayer.getForwardZ());
199 B2INFO(
" Ref. cylindricalR : " << refCylindricalRByICLayer[iCLayer]);
200 B2INFO(
" Max abs displacement : " << wireLayer.getWire(0).getWireVector().xy().norm());
207 TEST_F(TrackFindingCDCTestWithTopology, topology_RefCylindricalRVersusZInSuperLayers)
210 for (
const CDCWireSuperLayer& wireSuperLayer : theWireTopology.getWireSuperLayers()) {
211 if (wireSuperLayer.getStereoKind() == EStereoKind::c_Axial) {
212 EXPECT_EQ(0.0, wireSuperLayer.getRefTanLambda());
215 B2INFO(
"ISuperLayer : " << wireSuperLayer.getISuperLayer() <<
216 " Inner ref. z : " << wireSuperLayer.getInnerRefZ() <<
217 " Outer ref. z : " << wireSuperLayer.getOuterRefZ() <<
218 " CylindricalR Z slope : " << wireSuperLayer.getRefTanLambda()
224 TEST_F(TrackFindingCDCTestWithTopology, topology_ShowCurlCurv)
228 double outerR = theWireTopology.getOuterCylindricalR();
229 double innerR = theWireTopology.getInnerCylindricalR();
231 double innerOriginCurv = 1 / (innerR / 2);
232 double outerOriginCurv = 1 / (outerR / 2);
234 double innerCurlCurv = 1 / innerR;
235 double outerCurlCurv = 1 / outerR;
237 B2INFO(
"Maximal curvature still reaching the CDC from IP : " << innerOriginCurv);
240 B2INFO(
"Maximal curvature still leaving the CDC from IP : " << outerOriginCurv);
244 B2INFO(
"Minimal curvature not reaching the CDC from VXD : " << innerCurlCurv);
247 B2INFO(
"Minimal curvature not leaving the CDC from inside the CDC : " << outerCurlCurv);
251 for (
const CDCWireSuperLayer& wireSuperLayer : theWireTopology.getWireSuperLayers()) {
252 double innerSLCurv = 1 / wireSuperLayer.getInnerCylindricalR();
253 B2INFO(
"Maximal curvature still reaching SL " << wireSuperLayer.getISuperLayer() <<
" from IP : " << innerSLCurv);
254 B2INFO(
"Minimal momentum still reaching SL " << wireSuperLayer.getISuperLayer() <<
" from IP : " <<
259 TEST_F(TrackFindingCDCTestWithTopology, topology_ShowLayerLimits)
263 for (
const CDCWireLayer& wireLayer : theWireTopology.getWireLayers()) {
265 B2INFO(
"Layer " << iL <<
":");
266 B2INFO(
"z in " << wireLayer.getForwardZ() <<
", " << wireLayer.getBackwardZ());
267 B2INFO(
"r in " << wireLayer.getInnerCylindricalR() <<
", " << wireLayer.getOuterCylindricalR());
271 TEST_F(TrackFindingCDCTestWithTopology, topology_CDCGeometryPar_cellId)
275 unsigned iCLayer = 4;
278 TVector3 posInMiddle(0, 0, 20.8);
281 EXPECT_TRUE(iWireInFourthLayer < 160);
282 EXPECT_LT(iWireInFourthLayer, 160);
285 TEST_F(TrackFindingCDCTestWithTopology, topology_sag)
288 for (
const CDCWire& wire : theWireTopology.getWires()) {
289 const WireLine& wireLine = wire.getWireLine();
290 const double forwardZ = wireLine.forwardZ();
291 const double backwardZ = wireLine.backwardZ();
292 const double centerZ = (forwardZ + backwardZ) / 2;
294 EXPECT_LE(0, wireLine.sagCoeff());
296 EXPECT_EQ(wireLine.nominalPos2DAtZ(forwardZ).y(), wireLine.sagPos2DAtZ(forwardZ).y());
297 EXPECT_EQ(wireLine.nominalPos2DAtZ(backwardZ).y(), wireLine.sagPos2DAtZ(backwardZ).y());
298 EXPECT_GE(wireLine.nominalPos2DAtZ(centerZ).y(), wireLine.sagPos2DAtZ(centerZ).y());
300 EXPECT_LE(wireLine.nominalMovePerZ().y(), wireLine.sagMovePerZ(forwardZ).y());
301 EXPECT_GE(wireLine.nominalMovePerZ().y(), wireLine.sagMovePerZ(backwardZ).y());
302 EXPECT_EQ(wireLine.nominalMovePerZ().y(), wireLine.sagMovePerZ(centerZ).y());