Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PropagationAutodiffDenseConstant.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PropagationAutodiffDenseConstant.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/unit_test.hpp>
11 
25 
26 #include <limits>
27 
28 #include "../PropagationDatasets.hpp"
29 #include "../PropagationTests.hpp"
30 
31 namespace {
32 
33 namespace ds = ActsTests::PropagationDatasets;
34 using namespace Acts::UnitLiterals;
35 
37 using Extension = Acts::AutodiffExtensionWrapper<
41 using RiddersPropagator = Acts::RiddersPropagator<Propagator>;
42 
43 // absolute parameter tolerances for position, direction, and absolute momentum
44 constexpr auto epsPos = 10_um;
45 constexpr auto epsDir = 1_mrad;
46 constexpr auto epsMom = 5_MeV;
47 // relative covariance tolerance
48 constexpr auto epsCov = 0.07;
49 
52 
53 inline std::shared_ptr<const Acts::TrackingGeometry> makeDetector() {
54  using namespace Acts;
55 
56  // avoid rebuilding the tracking geometry for every propagator
57  static std::shared_ptr<const Acts::TrackingGeometry> detector;
58  if (not detector) {
60  vConf.position = {0., 0., 0.};
61  vConf.length = {4_m, 4_m, 4_m};
62  vConf.volumeMaterial = std::make_shared<const HomogeneousVolumeMaterial>(
65  conf.volumeCfg.push_back(vConf);
66  conf.position = {0., 0., 0.};
67  conf.length = {4_m, 4_m, 4_m};
68  CuboidVolumeBuilder cvb(conf);
70  tgbCfg.trackingVolumeBuilders.push_back(
71  [=](const auto& context, const auto& inner, const auto&) {
72  return cvb.trackingVolume(context, inner, nullptr);
73  });
75  }
76 
77  return detector;
78 }
79 
80 inline Propagator makePropagator(double bz) {
81  using namespace Acts;
82 
83  auto magField = std::make_shared<MagneticField>(Acts::Vector3(0.0, 0.0, bz));
84  Stepper stepper(std::move(magField));
85  return Propagator(std::move(stepper), Acts::Navigator({makeDetector()}));
86 }
87 
88 inline RiddersPropagator makeRiddersPropagator(double bz) {
89  using namespace Acts;
90 
91  auto magField = std::make_shared<MagneticField>(Acts::Vector3(0.0, 0.0, bz));
92  Stepper stepper(std::move(magField));
93  return RiddersPropagator(std::move(stepper),
94  Acts::Navigator({makeDetector()}));
95 }
96 
97 } // namespace
98 
99 BOOST_AUTO_TEST_SUITE(PropagationAutodiffDenseConstant)
100 
101 // check that the propagation is reversible and self-consistent
102 
103 // TODO does not seem to work as-is
104 BOOST_DATA_TEST_CASE(ForwardBackward,
105  ds::phi* ds::theta* ds::absMomentum* ds::chargeNonZero*
106  ds::pathLength* ds::magneticField,
107  phi, theta, p, q, s, bz) {
108  runForwardBackwardTest<Propagator, Acts::DenseStepperPropagatorOptions>(
109  makePropagator(bz), geoCtx, magCtx,
110  makeParametersCurvilinear(phi, theta, p, q), s, epsPos, epsDir, epsMom);
111 }
112 
113 // check that reachable surfaces are correctly reached
114 
115 // True forward/backward tracks do not work with z cylinders
116 BOOST_DATA_TEST_CASE(ToCylinderAlongZ,
119  phi, theta, p, q, s, bz) {
122  makePropagator(bz), geoCtx, magCtx,
123  makeParametersCurvilinear(phi, theta, p, q), s, ZCylinderSurfaceBuilder(),
124  epsPos, epsDir, epsMom);
125 }
126 
130  phi, theta, p, q, s, bz) {
133  makePropagator(bz), geoCtx, magCtx,
134  makeParametersCurvilinear(phi, theta, p, q), s, DiscSurfaceBuilder(),
135  epsPos, epsDir, epsMom);
136 }
137 
141  phi, theta, p, q, s, bz) {
144  makePropagator(bz), geoCtx, magCtx,
145  makeParametersCurvilinear(phi, theta, p, q), s, PlaneSurfaceBuilder(),
146  epsPos, epsDir, epsMom);
147 }
148 
149 // True forward/backward tracks do not work with z straws
150 BOOST_DATA_TEST_CASE(ToStrawAlongZ,
153  phi, theta, p, q, s, bz) {
156  makePropagator(bz), geoCtx, magCtx,
157  makeParametersCurvilinear(phi, theta, p, q), s, ZStrawSurfaceBuilder(),
158  epsPos, epsDir, epsMom);
159 }
160 
161 // check covariance transport using the ridders propagator for comparison
162 
163 BOOST_DATA_TEST_CASE(CovarianceCurvilinear,
166  phi, theta, p, q, s, bz) {
167  runForwardComparisonTest<Propagator, RiddersPropagator,
169  makePropagator(bz), makeRiddersPropagator(bz), geoCtx, magCtx,
171  epsDir, epsMom, epsCov);
172 }
173 
174 // limit theta to ignore the covariance mismatches at high theta for now
175 BOOST_DATA_TEST_CASE(CovarianceToCylinderAlongZ,
178  phi, theta, p, q, s, bz) {
179  runToSurfaceComparisonTest<Propagator, RiddersPropagator,
182  makePropagator(bz), makeRiddersPropagator(bz), geoCtx, magCtx,
184  ZCylinderSurfaceBuilder(), epsPos, epsDir, epsMom, epsCov);
185 }
186 
187 BOOST_DATA_TEST_CASE(CovarianceToDisc,
190  phi, theta, p, q, s, bz) {
193  makePropagator(bz), makeRiddersPropagator(bz), geoCtx, magCtx,
195  DiscSurfaceBuilder(), epsPos, epsDir, epsMom, epsCov);
196 }
197 
198 BOOST_DATA_TEST_CASE(CovarianceToPlane,
201  phi, theta, p, q, s, bz) {
204  makePropagator(bz), makeRiddersPropagator(bz), geoCtx, magCtx,
206  PlaneSurfaceBuilder(), epsPos, epsDir, epsMom, epsCov);
207 }
208 
209 // limit theta to ignore the covariance mismatches at high theta for now
210 BOOST_DATA_TEST_CASE(CovarianceToStrawAlongZ,
213  phi, theta, p, q, s, bz) {
214  runToSurfaceComparisonTest<Propagator, RiddersPropagator,
217  makePropagator(bz), makeRiddersPropagator(bz), geoCtx, magCtx,
219  ZStrawSurfaceBuilder(), epsPos, epsDir, epsMom, epsCov);
220 }
221 
222 BOOST_AUTO_TEST_SUITE_END()