9 #include <boost/test/unit_test.hpp>
39 namespace tt = boost::test_tools;
40 using namespace Acts::UnitLiterals;
55 template <
typename stepper_state_t>
58 PropState(stepper_state_t sState) : stepping(sState) {}
65 double stepSizeCutOff = 0.;
66 unsigned int maxRungeKuttaStepTrials = 10000;
87 template <
typename propagator_state_t,
typename stepper_t>
89 const double tolerance = state.options.targetTolerance;
90 if (maxX -
std::abs(stepper.position(state.stepping).x()) <= tolerance ||
91 std::abs(stepper.position(state.stepping).y()) >= 0.5_m ||
92 std::abs(stepper.position(state.stepping).z()) >= 0.5_m)
122 template <
typename propagator_state_t,
typename stepper_t>
123 void operator()(propagator_state_t& state,
const stepper_t&
stepper,
125 result.
position.push_back(stepper.position(state.stepping));
126 result.
momentum.push_back(stepper.momentum(state.stepping) *
127 stepper.direction(state.stepping));
148 stepSize, tolerance);
151 BOOST_CHECK_EQUAL(esState.
jacToGlobal, BoundToFreeMatrix::Zero());
152 BOOST_CHECK_EQUAL(esState.
jacTransport, FreeMatrix::Identity());
153 BOOST_CHECK_EQUAL(esState.
derivative, FreeVector::Zero());
155 BOOST_CHECK_EQUAL(esState.
cov, Covariance::Zero());
159 BOOST_CHECK_EQUAL(esState.
q, charge);
161 BOOST_CHECK_EQUAL(esState.
navDir, ndir);
163 BOOST_CHECK_EQUAL(esState.
stepSize, ndir * stepSize);
165 BOOST_CHECK_EQUAL(esState.
tolerance, tolerance);
171 stepSize, tolerance);
172 BOOST_CHECK_EQUAL(esState.
q, 0.);
179 stepSize, tolerance);
180 BOOST_CHECK_NE(esState.
jacToGlobal, BoundToFreeMatrix::Zero());
182 BOOST_CHECK_EQUAL(esState.
cov, cov);
206 stepSize, tolerance);
210 BOOST_CHECK_EQUAL(es.position(esState), esState.
pos);
211 BOOST_CHECK_EQUAL(es.direction(esState), esState.
dir);
212 BOOST_CHECK_EQUAL(es.momentum(esState), esState.
p);
213 BOOST_CHECK_EQUAL(es.charge(esState), esState.
q);
214 BOOST_CHECK_EQUAL(es.time(esState), esState.
t);
216 BOOST_CHECK_EQUAL(es.getField(esState, pos), bField.
getField(pos));
221 es.setStepSize(esState, 1337.);
223 BOOST_CHECK_EQUAL(esState.
stepSize, 1337.);
225 es.releaseStepSize(esState);
226 BOOST_CHECK_EQUAL(esState.
stepSize, -123.);
227 BOOST_CHECK_EQUAL(es.outputStepSize(esState), originalStepSize);
230 auto curvState = es.curvilinearState(esState);
231 auto curvPars = std::get<0>(curvState);
236 BOOST_CHECK(curvPars.covariance().has_value());
237 BOOST_CHECK_NE(*curvPars.covariance(),
cov);
245 double newTime(321.);
246 es.update(esState, newPos, newMom.normalized(), newMom.norm(), newTime);
247 BOOST_CHECK_EQUAL(esState.
pos, newPos);
248 BOOST_CHECK_EQUAL(esState.
dir, newMom.normalized());
249 BOOST_CHECK_EQUAL(esState.
p, newMom.norm());
250 BOOST_CHECK_EQUAL(esState.
q, charge);
251 BOOST_CHECK_EQUAL(esState.
t, newTime);
255 es.covarianceTransport(esState);
256 BOOST_CHECK_NE(esState.
cov, cov);
257 BOOST_CHECK_NE(esState.
jacToGlobal, BoundToFreeMatrix::Zero());
258 BOOST_CHECK_EQUAL(esState.
jacTransport, FreeMatrix::Identity());
259 BOOST_CHECK_EQUAL(esState.
derivative, FreeVector::Zero());
266 double h = es.step(ps).value();
267 BOOST_CHECK_EQUAL(ps.
stepping.stepSize, h);
269 BOOST_CHECK_NE(ps.
stepping.pos.norm(), newPos.norm());
270 BOOST_CHECK_NE(ps.
stepping.dir, newMom.normalized());
271 BOOST_CHECK_EQUAL(ps.
stepping.q, charge);
272 BOOST_CHECK_LT(ps.
stepping.t, newTime);
273 BOOST_CHECK_EQUAL(ps.
stepping.derivative, FreeVector::Zero());
274 BOOST_CHECK_EQUAL(ps.
stepping.jacTransport, FreeMatrix::Identity());
277 double h2 = es.step(ps).value();
278 BOOST_CHECK_EQUAL(h2, h);
280 BOOST_CHECK_NE(ps.
stepping.pos.norm(), newPos.norm());
281 BOOST_CHECK_NE(ps.
stepping.dir, newMom.normalized());
282 BOOST_CHECK_EQUAL(ps.
stepping.q, charge);
283 BOOST_CHECK_LT(ps.
stepping.t, newTime);
284 BOOST_CHECK_NE(ps.
stepping.derivative, FreeVector::Zero());
285 BOOST_CHECK_NE(ps.
stepping.jacTransport, FreeMatrix::Identity());
292 double absMom2 = 8.5;
307 BOOST_CHECK_NE(esStateCopy.
jacToGlobal, BoundToFreeMatrix::Zero());
309 BOOST_CHECK_EQUAL(esStateCopy.
jacTransport, FreeMatrix::Identity());
310 BOOST_CHECK_EQUAL(esStateCopy.
derivative, FreeVector::Zero());
312 BOOST_CHECK_EQUAL(esStateCopy.
cov, cov2);
313 BOOST_CHECK_EQUAL(esStateCopy.
pos, freeParams.template segment<3>(
eFreePos0));
314 BOOST_CHECK_EQUAL(esStateCopy.
dir,
315 freeParams.template segment<3>(
eFreeDir0).normalized());
317 BOOST_CHECK_EQUAL(esStateCopy.
q, ps.
stepping.q);
318 BOOST_CHECK_EQUAL(esStateCopy.
t, freeParams[
eFreeTime]);
319 BOOST_CHECK_EQUAL(esStateCopy.
navDir, ndir);
321 BOOST_CHECK_EQUAL(esStateCopy.
stepSize, ndir * stepSize2);
330 BOOST_CHECK_NE(esStateCopy.
jacToGlobal, BoundToFreeMatrix::Zero());
332 BOOST_CHECK_EQUAL(esStateCopy.
jacTransport, FreeMatrix::Identity());
333 BOOST_CHECK_EQUAL(esStateCopy.
derivative, FreeVector::Zero());
335 BOOST_CHECK_EQUAL(esStateCopy.
cov, cov2);
336 BOOST_CHECK_EQUAL(esStateCopy.
pos, freeParams.template segment<3>(
eFreePos0));
337 BOOST_CHECK_EQUAL(esStateCopy.
dir,
338 freeParams.template segment<3>(
eFreeDir0).normalized());
339 BOOST_CHECK_EQUAL(esStateCopy.
p,
std::abs(1. / freeParams[eFreeQOverP]));
340 BOOST_CHECK_EQUAL(esStateCopy.
q, ps.
stepping.q);
341 BOOST_CHECK_EQUAL(esStateCopy.
t, freeParams[eFreeTime]);
342 BOOST_CHECK_EQUAL(esStateCopy.
navDir, ndir);
344 BOOST_CHECK_EQUAL(esStateCopy.
stepSize,
354 BOOST_CHECK_NE(esStateCopy.
jacToGlobal, BoundToFreeMatrix::Zero());
356 BOOST_CHECK_EQUAL(esStateCopy.
jacTransport, FreeMatrix::Identity());
357 BOOST_CHECK_EQUAL(esStateCopy.
derivative, FreeVector::Zero());
359 BOOST_CHECK_EQUAL(esStateCopy.
cov, cov2);
360 BOOST_CHECK_EQUAL(esStateCopy.
pos, freeParams.template segment<3>(
eFreePos0));
361 BOOST_CHECK_EQUAL(esStateCopy.
dir,
362 freeParams.template segment<3>(
eFreeDir0).normalized());
363 BOOST_CHECK_EQUAL(esStateCopy.
p,
std::abs(1. / freeParams[eFreeQOverP]));
364 BOOST_CHECK_EQUAL(esStateCopy.
q, ps.
stepping.q);
365 BOOST_CHECK_EQUAL(esStateCopy.
t, freeParams[eFreeTime]);
373 auto plane = Surface::makeShared<PlaneSurface>(
pos, dir.normalized());
375 charge / absMom, cov);
377 stepSize, tolerance);
381 Surface::makeShared<PlaneSurface>(pos + ndir * 2. * dir, dir);
382 es.updateSurfaceStatus(esState, *targetSurface,
BoundaryCheck(
false));
408 BOOST_CHECK(boundPars.covariance().has_value());
409 BOOST_CHECK_NE(*boundPars.covariance(),
cov);
415 es.covarianceTransport(esState, *
plane);
416 BOOST_CHECK_NE(esState.
cov, cov);
417 BOOST_CHECK_NE(esState.
jacToGlobal, BoundToFreeMatrix::Zero());
418 BOOST_CHECK_EQUAL(esState.
jacTransport, FreeMatrix::Identity());
419 BOOST_CHECK_EQUAL(esState.
derivative, FreeVector::Zero());
423 bp.referenceSurface(),
tgContext, bp.parameters());
429 es.update(esState, freeParams, 2 * (*bp.covariance()));
434 BOOST_CHECK_EQUAL(esState.
q, 1. * charge);
448 stepSize, tolerance);
453 auto res = nes.step(nps);
454 BOOST_CHECK(!res.ok());
455 BOOST_CHECK_EQUAL(res.error(), EigenStepperError::StepSizeStalled);
461 BOOST_CHECK(!res.ok());
462 BOOST_CHECK_EQUAL(res.error(), EigenStepperError::StepSizeAdjustmentFailed);
480 vConf.
length = {1_m, 1_m, 1_m};
484 conf.
length = {1_m, 1_m, 1_m};
490 [=](
const auto& context,
const auto& inner,
const auto& vb) {
494 std::shared_ptr<const TrackingGeometry> vacuum =
506 const Vector3D startMom = 1_GeV * startDir;
538 const auto& result = prop.propagate(sbtp, propOpts).value();
569 propDef(esDef, naviVac);
572 const auto& resultDef = propDef.propagate(sbtp, propOptsDef).value();
578 BOOST_CHECK_EQUAL(stepResult.
position.size(), stepResultDef.
position.size());
579 for (
unsigned int i = 0; i < stepResult.
position.size(); i++) {
582 BOOST_CHECK_EQUAL(stepResult.
momentum.size(), stepResultDef.
momentum.size());
583 for (
unsigned int i = 0; i < stepResult.
momentum.size(); i++) {
592 vConf.
length = {1_m, 1_m, 1_m};
594 std::make_shared<HomogeneousVolumeMaterial>(
makeBeryllium());
597 conf.position = {0.5_m, 0., 0.};
598 conf.length = {1_m, 1_m, 1_m};
604 [=](
const auto& context,
const auto& inner,
const auto& vb) {
608 std::shared_ptr<const TrackingGeometry>
material =
620 const Vector3D startMom = 5_GeV * startDir;
652 const auto& result = prop.propagate(sbtp, propOpts).value();
672 BOOST_CHECK_LT(
mom.x(), 5_GeV);
692 propDense(esDense, naviMat);
695 const auto& resultDense = propDense.propagate(sbtp, propOptsDense).value();
701 BOOST_CHECK_EQUAL(stepResult.
position.size(),
703 for (
unsigned int i = 0; i < stepResult.
position.size(); i++) {
706 BOOST_CHECK_EQUAL(stepResult.
momentum.size(),
708 for (
unsigned int i = 0; i < stepResult.
momentum.size(); i++) {
718 StepperExtensionList<DefaultExtension, DenseEnvironmentExtension>,
719 detail::HighestValidAuctioneer>
723 DenseEnvironmentExtension>,
724 detail::HighestValidAuctioneer>,
728 const auto& resultB = propB.propagate(sbtp, propOptsDense).value();
746 BOOST_CHECK_NE(
mom.x(), 5_GeV);
748 BOOST_CHECK_NE(
mom.z(), 0.);
756 vConfVac1.
position = {0.5_m, 0., 0.};
757 vConfVac1.
length = {1_m, 1_m, 1_m};
758 vConfVac1.
name =
"First vacuum volume";
760 vConfMat.
position = {1.5_m, 0., 0.};
761 vConfMat.
length = {1_m, 1_m, 1_m};
763 std::make_shared<const HomogeneousVolumeMaterial>(
makeBeryllium());
764 vConfMat.
name =
"Material volume";
766 vConfVac2.
position = {2.5_m, 0., 0.};
767 vConfVac2.
length = {1_m, 1_m, 1_m};
768 vConfVac2.
name =
"Second vacuum volume";
770 conf.
volumeCfg = {vConfVac1, vConfMat, vConfVac2};
772 conf.
length = {3_m, 1_m, 1_m};
778 [=](
const auto& context,
const auto& inner,
const auto& vb) {
792 1_e, Covariance::Identity());
802 propOpts.abortList = abortList;
803 propOpts.maxSteps = 1000;
804 propOpts.maxStepSize = 1.5_m;
821 const auto& result = prop.propagate(sbtp, propOpts).value();
828 std::vector<Surface const*> surs;
829 std::vector<std::shared_ptr<const BoundarySurfaceT<TrackingVolume>>>
831 ->boundarySurfaces();
832 for (
auto& b : boundaries) {
833 if (b->surfaceRepresentation().center(
tgContext).x() == 1_m) {
834 surs.push_back(&(b->surfaceRepresentation()));
839 det->lowestTrackingVolume(
tgContext, {1.5_m, 0., 0.})->boundarySurfaces();
840 for (
auto& b : boundaries) {
841 if (b->surfaceRepresentation().center(
tgContext).x() == 2_m) {
842 surs.push_back(&(b->surfaceRepresentation()));
847 det->lowestTrackingVolume(
tgContext, {2.5_m, 0., 0.})->boundarySurfaces();
848 for (
auto& b : boundaries) {
849 if (b->surfaceRepresentation().center(
tgContext).x() == 3_m) {
850 surs.push_back(&(b->surfaceRepresentation()));
871 propDef(esDef, naviDet);
874 const auto& resultDef =
875 propDef.propagate(sbtp, *(surs[0]), propOptsDef).value();
880 std::pair<Vector3D, Vector3D> endParams, endParamsControl;
881 for (
unsigned int i = 0; i < stepResultDef.
position.size(); i++) {
882 if (1_m - stepResultDef.
position[i].x() < 1
e-4) {
888 for (
unsigned int i = 0; i < stepResult.
position.size(); i++) {
889 if (1_m - stepResult.
position[i].x() < 1
e-4) {
911 1 / endParams.second.norm());
914 DenseStepperPropagatorOptions<ActionList<StepCollector>,
918 propOptsDense.abortList = abortList;
919 propOptsDense.maxSteps = 1000;
920 propOptsDense.maxStepSize = 1.5_m;
928 propDense(esDense, naviDet);
931 const auto& resultDense =
932 propDense.propagate(sbtpPiecewise, *(surs[1]), propOptsDense).value();
937 for (
unsigned int i = 0; i < stepResultDense.
position.size(); i++) {
938 if (2_m - stepResultDense.
position[i].x() < 1
e-4) {
939 endParams = std::make_pair(stepResultDense.
position[i],
944 for (
unsigned int i = 0; i < stepResult.
position.size(); i++) {
945 if (2_m - stepResult.
position[i].x() < 1
e-4) {
959 double rotationAngle =
M_PI * 0.5;
960 Vector3D xPos(
cos(rotationAngle), 0., sin(rotationAngle));
962 Vector3D zPos(-sin(rotationAngle), 0.,
cos(rotationAngle));
972 std::make_shared<const RectangleBounds>(
RectangleBounds(0.5_m, 0.5_m));
973 sConf1.
surMat = std::shared_ptr<const ISurfaceMaterial>(
985 std::make_shared<const RectangleBounds>(
RectangleBounds(0.5_m, 0.5_m));
986 sConf2.
surMat = std::shared_ptr<const ISurfaceMaterial>(
994 muConf1.
length = {20._cm, 20._cm, 20._cm};
996 std::make_shared<HomogeneousVolumeMaterial>(
makeBeryllium());
997 muConf1.
name =
"MDT1";
1000 muConf2.
length = {20._cm, 20._cm, 20._cm};
1002 std::make_shared<HomogeneousVolumeMaterial>(
makeBeryllium());
1003 muConf2.
name =
"MDT2";
1007 vConf1.
length = {1._m, 1._m, 1._m};
1008 vConf1.
layerCfg = {lConf1, lConf2};
1009 vConf1.
name =
"Tracker";
1012 vConf2.
length = {1._m, 1._m, 1._m};
1014 std::make_shared<HomogeneousVolumeMaterial>(
makeBeryllium());
1015 vConf2.
name =
"Calorimeter";
1018 vConf3.
length = {1._m, 1._m, 1._m};
1020 vConf3.
name =
"Muon system";
1022 conf.
volumeCfg = {vConf1, vConf2, vConf3};
1024 conf.
length = {3._m, 1._m, 1._m};
1030 [=](
const auto& context,
const auto& inner,
const auto& vb) {
1034 std::shared_ptr<const TrackingGeometry>
detector =
1045 1_e / 1_GeV, Covariance::Identity());
1069 const auto& result = prop.propagate(sbtp, propOpts).value();
1074 double lastMomentum = stepResult.
momentum[0].x();
1075 for (
unsigned int i = 0; i < stepResult.
position.size(); i++) {
1077 if ((stepResult.
position[i].x() > 0.3_m &&
1078 stepResult.
position[i].x() < 0.6_m) ||
1079 (stepResult.
position[i].x() > 0.6_m &&
1080 stepResult.
position[i].x() <= 1._m) ||
1081 (stepResult.
position[i].x() > 1._m &&
1082 stepResult.
position[i].x() <= 2._m) ||
1083 (stepResult.
position[i].x() > 2.2_m &&
1084 stepResult.
position[i].x() <= 2.4_m) ||
1085 (stepResult.
position[i].x() > 2.6_m &&
1086 stepResult.
position[i].x() <= 2.8_m)) {
1087 BOOST_CHECK_LE(stepResult.
momentum[i].x(), lastMomentum);
1088 lastMomentum = stepResult.
momentum[i].x();
1092 if (stepResult.
position[i].x() < 0.3_m ||
1093 (stepResult.
position[i].x() > 2._m &&
1094 stepResult.
position[i].x() <= 2.2_m) ||
1095 (stepResult.
position[i].x() > 2.4_m &&
1096 stepResult.
position[i].x() <= 2.6_m) ||
1097 (stepResult.
position[i].x() > 2.8_m &&
1098 stepResult.
position[i].x() <= 3._m)) {
1099 BOOST_CHECK_EQUAL(stepResult.
momentum[i].x(), lastMomentum);