Skip to content

Commit 0bed432

Browse files
committed
update
1 parent 30f9f83 commit 0bed432

File tree

9 files changed

+241
-178
lines changed

9 files changed

+241
-178
lines changed

Core/include/Acts/Propagator/EigenStepper.ipp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ Acts::Result<double> Acts::EigenStepper<E, A>::step(
240240
return EigenStepperError::StepInvalid;
241241
}
242242
}
243+
244+
std::cout << "EigenStepper initial h: " << initialH << "\n";
245+
std::cout << "EigenStepper h: " << h << "\n";
243246

244247
// Update the track parameters according to the equations of motion
245248
state.stepping.pars.template segment<3>(eFreePos0) +=

Core/include/Acts/Propagator/MultiEigenStepperLoop.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "Acts/Propagator/detail/LoopStepperUtils.hpp"
2727
#include "Acts/Surfaces/Surface.hpp"
2828
#include "Acts/Utilities/GaussianMixtureReduction.hpp"
29+
#include "Acts/Propagator/detail/MultiStepperUtils.hpp"
2930
#include "Acts/Utilities/Intersection.hpp"
3031
#include "Acts/Utilities/Result.hpp"
3132

@@ -478,7 +479,7 @@ class MultiEigenStepperLoop
478479
}
479480
}
480481

481-
/// Updates the components in the multistepper
482+
/// Updates the components in the multistepper
482483
///
483484
/// @param [in,out] state The stepping state (thread-local cache)
484485
/// @param [in] surface The surface we are on

Core/include/Acts/Propagator/MultiEigenStepperLoop.ipp

Lines changed: 3 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "Acts/Propagator/MultiEigenStepperLoop.hpp"
1010
#include "Acts/Utilities/Logger.hpp"
11+
#include "Acts/Propagator/detail/MultiStepperUtils.hpp"
1112

1213
namespace Acts {
1314

@@ -17,76 +18,15 @@ auto MultiEigenStepperLoop<E, R, A>::boundState(
1718
const FreeToBoundCorrection& freeToBoundCorrection) const
1819
-> Result<BoundState> {
1920
assert(!state.components.empty());
20-
21-
std::vector<std::tuple<double, BoundVector, Covariance>> cmps;
22-
cmps.reserve(numberComponents(state));
23-
double accumulatedPathLength = 0.0;
24-
25-
for (auto i = 0ul; i < numberComponents(state); ++i) {
26-
auto& cmpState = state.components[i].state;
27-
28-
// Force the component to be on the surface
29-
// This needs to be done because of the `averageOnSurface`-option of the
30-
// `MultiStepperSurfaceReached`-Aborter, which can be configured to end the
31-
// propagation when the mean of all components reached the destination
32-
// surface. Thus, it is not garantueed that all states are actually
33-
// onSurface.
34-
cmpState.pars.template segment<3>(eFreePos0) =
35-
surface
36-
.intersect(state.geoContext,
37-
cmpState.pars.template segment<3>(eFreePos0),
38-
cmpState.pars.template segment<3>(eFreeDir0), false)
39-
.closest()
40-
.position();
41-
42-
auto bs = SingleStepper::boundState(cmpState, surface, transportCov,
43-
freeToBoundCorrection);
44-
45-
if (bs.ok()) {
46-
const auto& btp = std::get<BoundTrackParameters>(*bs);
47-
cmps.emplace_back(
48-
state.components[i].weight, btp.parameters(),
49-
btp.covariance().value_or(Acts::BoundSquareMatrix::Zero()));
50-
accumulatedPathLength +=
51-
std::get<double>(*bs) * state.components[i].weight;
52-
}
53-
}
54-
55-
if (cmps.empty()) {
56-
return MultiStepperError::AllComponentsConversionToBoundFailed;
57-
}
58-
59-
return BoundState{MultiComponentBoundTrackParameters(
60-
surface.getSharedPtr(), cmps, state.particleHypothesis),
61-
Jacobian::Zero(), accumulatedPathLength};
21+
return detail::multiComponentBoundState(*this, state, surface, transportCov, freeToBoundCorrection);
6222
}
6323

6424
template <typename E, typename R, typename A>
6525
auto MultiEigenStepperLoop<E, R, A>::curvilinearState(State& state,
6626
bool transportCov) const
6727
-> CurvilinearState {
6828
assert(!state.components.empty());
69-
70-
std::vector<
71-
std::tuple<double, Vector4, Vector3, ActsScalar, BoundSquareMatrix>>
72-
cmps;
73-
cmps.reserve(numberComponents(state));
74-
double accumulatedPathLength = 0.0;
75-
76-
for (auto i = 0ul; i < numberComponents(state); ++i) {
77-
const auto [cp, jac, pl] = SingleStepper::curvilinearState(
78-
state.components[i].state, transportCov);
79-
80-
cmps.emplace_back(state.components[i].weight,
81-
cp.fourPosition(state.geoContext), cp.direction(),
82-
(cp.charge() / cp.absoluteMomentum()),
83-
cp.covariance().value_or(BoundSquareMatrix::Zero()));
84-
accumulatedPathLength += state.components[i].weight * pl;
85-
}
86-
87-
return CurvilinearState{
88-
MultiComponentCurvilinearTrackParameters(cmps, state.particleHypothesis),
89-
Jacobian::Zero(), accumulatedPathLength};
29+
return detail::multiComponentCurvilinearState(*this, state, transportCov);
9030
}
9131

9232
template <typename E, typename R, typename A>

Core/include/Acts/Propagator/MultiEigenStepperSIMD.hpp

Lines changed: 15 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "Acts/Propagator/detail/SimdHelpers.hpp"
1515
#include "Acts/Definitions/Algebra.hpp"
1616
#include "Acts/Definitions/Units.hpp"
17-
#include "Acts/EventData/MultiComponentBoundTrackParameters.hpp"
17+
#include "Acts/EventData/MultiComponentTrackParameters.hpp"
1818
#include "Acts/EventData/TrackParameters.hpp"
1919
#include "Acts/MagneticField/MagneticFieldProvider.hpp"
2020
#include "Acts/Propagator/DefaultExtension.hpp"
@@ -27,6 +27,7 @@
2727
#include "Acts/Propagator/detail/SimdHelpers.hpp"
2828
#include "Acts/Propagator/detail/SimdStepperUtils.hpp"
2929
#include "Acts/Propagator/detail/SteppingHelper.hpp"
30+
#include "Acts/Propagator/detail/MultiStepperUtils.hpp"
3031
#include "Acts/Utilities/Intersection.hpp"
3132
#include "Acts/Utilities/Result.hpp"
3233

@@ -124,16 +125,17 @@ class MultiEigenStepperSIMD
124125
using SingleState = typename SingleStepper::State;
125126

126127
/// @brief Use the definitions from the Single-stepper
127-
using typename SingleStepper::BoundState;
128128
using typename SingleStepper::Covariance;
129-
using typename SingleStepper::CurvilinearState;
130129
using typename SingleStepper::Jacobian;
131130

132131
/// @brief The reducer type
133132
using Reducer = component_reducer_t;
134133

135134
/// @brief How many components can this stepper manage?
136135
static constexpr int maxComponents = NComponents;
136+
137+
using BoundState = detail::MultiStepperBoundState;
138+
using CurvilinearState = detail::MultiStepperCurvilinearState;
137139

138140
/// @brief SIMD typedefs
139141
using SimdScalar = SimdType<NComponents>;
@@ -369,11 +371,13 @@ class MultiEigenStepperSIMD
369371
void update(State& state, const Surface& /*surface*/, iterator_t begin,
370372
iterator_t end, const copy_t& copy) const {
371373
assert(std::distance(begin, end) <= NComponents);
374+
ACTS_VERBOSE("distance " << std::distance(begin, end));
372375

373376
std::size_t i = 0;
374377
auto it = begin;
375378
for (; it != end; ++i, ++it) {
376379
auto proxy = ComponentProxy{state, i};
380+
ACTS_VERBOSE("copy to component " << i);
377381
copy(*it, proxy);
378382
}
379383

@@ -499,9 +503,9 @@ class MultiEigenStepperSIMD
499503
/// @param surface [in] The surface provided
500504
/// @param bcheck [in] The boundary check for this status update
501505
Intersection3D::Status updateSurfaceStatus(
502-
State& state, const Surface& /*surface*/, Direction /*navDir*/,
503-
const BoundaryCheck& /*bcheck*/,
504-
const Logger& /*logger*/ = getDummyLogger()) const;
506+
State& state, const Surface& surface, std::uint8_t index, Direction navDir,
507+
const BoundaryCheck& bcheck,
508+
const Logger& logger = getDummyLogger()) const;
505509

506510
/// Update step size
507511
///
@@ -608,13 +612,10 @@ class MultiEigenStepperSIMD
608612
/// - the stepwise jacobian towards it (from last bound)
609613
/// - and the path length (from start - for ordering)
610614
Result<BoundState> boundState(
611-
State& /*state*/, const Surface& /*surface*/,
612-
bool /*transportCov*/ = true,
613-
const FreeToBoundCorrection& /*freeToBoundCorrection*/ =
614-
FreeToBoundCorrection(false)) const {
615-
throw std::runtime_error(
616-
"'boundState' not yet implemented for MultiEigenStepper");
617-
}
615+
State& state, const Surface& surface,
616+
bool transportCov = true,
617+
const FreeToBoundCorrection& freeToBoundCorrection =
618+
FreeToBoundCorrection(false)) const;
618619

619620
/// Create and return a curvilinear state at the current position
620621
///
@@ -630,57 +631,7 @@ class MultiEigenStepperSIMD
630631
/// - and the path length (from start - for ordering)
631632
/// TODO reformulate with reducer functions
632633
CurvilinearState curvilinearState(State& /*state*/,
633-
bool /*transportCov*/ = true) const {
634-
throw std::runtime_error("not implemented in Multi Stepper");
635-
// // std optional because CurvilinearState is not default constructable
636-
// std::array<std::optional<CurvilinearState>, NComponents> states;
637-
//
638-
// // Compute all states
639-
// for (auto i = 0ul; i < NComponents; ++i) {
640-
// FreeVector pars, derivative;
641-
// FreeMatrix jacTransport;
642-
//
643-
// for (auto j = 0ul; j < eFreeSize; ++j) {
644-
// pars[j] = state.pars[j][i];
645-
// }
646-
//
647-
// for (auto j = 0ul; j < eFreeSize; ++j)
648-
// for (auto k = 0ul; k < eFreeSize; ++k) {
649-
// jacTransport(j, k) = state.jacTransport(j, k)[i];
650-
// }
651-
//
652-
// states[i] = detail::curvilinearState(
653-
// state.covs[i], state.jacobians[i], jacTransport, derivative,
654-
// state.jacToGlobals[i], pars, state.covTransport && transportCov,
655-
// state.pathAccumulated);
656-
// }
657-
//
658-
// // Sum everything up
659-
// Vector4 pos = Vector4::Zero();
660-
// Vector3 dir = Vector3::Zero();
661-
// double p = 0., pathlen = 0.;
662-
// Jacobian jac = Jacobian::Zero();
663-
//
664-
// for (const auto& curvstate : states) {
665-
// const auto& curvpars =
666-
// std::get<CurvilinearTrackParameters>(*curvstate); pos +=
667-
// curvpars.fourPosition(state.geoContext); dir +=
668-
// curvpars.unitDirection(); p += curvpars.absoluteabsoluteMomentum();
669-
// pathlen += std::get<double>(*curvstate);
670-
// jac += std::get<Jacobian>(*curvstate);
671-
// }
672-
//
673-
// // Average over all
674-
// double q = std::get<double>(*states.front());
675-
// pos /= NComponents;
676-
// dir.normalize();
677-
// p /= NComponents;
678-
// pathlen /= NComponents;
679-
// jac /= NComponents;
680-
//
681-
// return CurvilinearState{CurvilinearTrackParameters(pos, dir, p, q), jac,
682-
// pathlen};
683-
}
634+
bool /*transportCov*/ = true) const;
684635

685636
/// Method for on-demand transport of the covariance
686637
/// to a new curvilinear frame at current position,

Core/include/Acts/Propagator/MultiEigenStepperSIMD.ipp

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
88

99
#include "Acts/Utilities/Zip.hpp"
10+
#include "Acts/Propagator/detail/MultiStepperUtils.hpp"
1011

1112
namespace Acts {
1213

@@ -65,8 +66,8 @@ void MultiEigenStepperSIMD<N, AA, BB, CC, DD>::transportCovarianceToCurvilinear(
6566
template <int N, typename AA, typename BB, typename CC, typename DD>
6667
Intersection3D::Status
6768
MultiEigenStepperSIMD<N, AA, BB, CC, DD>::updateSurfaceStatus(
68-
State& state, const Surface& surface, Direction navDir,
69-
const BoundaryCheck& bcheck, const Logger& l) const {
69+
State& state, const Surface& surface, std::uint8_t index, Direction navDir,
70+
const BoundaryCheck& bcheck, const Logger& /*l*/) const {
7071
ACTS_DEBUG("MultiEigenStepperSIMD::updateSurfaceStatus");
7172

7273
std::array<int, 4> counts = {0, 0, 0, 0};
@@ -80,7 +81,7 @@ MultiEigenStepperSIMD<N, AA, BB, CC, DD>::updateSurfaceStatus(
8081
const auto prevStatus = cmp.status();
8182

8283
cmp.status() = detail::updateSingleSurfaceStatus<SingleProxyStepper>(
83-
cmp.singleStepper(*this), state, surface, navDir, bcheck,
84+
cmp.singleStepper(*this), state, surface, index, navDir, bcheck,
8485
s_onSurfaceTolerance, logger() /*Acts::getDummyLogger()*/);
8586

8687
ACTS_VERBOSE(" cmp" << cmp.index() << ": " << prevStatus << " -> " << cmp.status());
@@ -103,6 +104,21 @@ MultiEigenStepperSIMD<N, AA, BB, CC, DD>::updateSurfaceStatus(
103104
return Status::missed;
104105
}
105106

107+
template <int N, typename AA, typename BB, typename CC, typename DD>
108+
auto MultiEigenStepperSIMD<N, AA, BB, CC, DD>::boundState(
109+
State& state, const Surface& surface,
110+
bool transportCov,
111+
const FreeToBoundCorrection& freeToBoundCorrection) const -> Result<BoundState> {
112+
return detail::multiComponentBoundState(*this, state, surface, transportCov, freeToBoundCorrection);
113+
}
114+
115+
template <int N, typename AA, typename BB, typename CC, typename DD>
116+
auto MultiEigenStepperSIMD<N, AA, BB, CC, DD>::curvilinearState(
117+
State& state,
118+
bool transportCov) const -> CurvilinearState {
119+
return detail::multiComponentCurvilinearState(*this, state, transportCov);
120+
}
121+
106122
// Seperated stepsize estimate from Single eigen stepper
107123
/// TODO state should be constant, but then magne
108124
template <int N, typename AA, typename BB, typename CC, typename DD>
@@ -184,7 +200,7 @@ Result<double> MultiEigenStepperSIMD<N, AA, BB, CC, DD>::estimate_step_size(
184200
0.25)),
185201
4.);
186202

187-
current_estimate.setValue(current_estimate.value() * stepSizeScaling);
203+
current_estimate.update(current_estimate.value() * stepSizeScaling, ConstrainedStep::actor);
188204

189205
// If step size becomes too small the particle remains at the initial
190206
// place
@@ -219,9 +235,15 @@ Result<double> MultiEigenStepperSIMD<N, AA, BB, CC, DD>::step(
219235
const auto dir = multiDirection(stepping);
220236

221237
ACTS_VERBOSE("Pos before step:");
222-
ACTS_VERBOSE(" x = " << multiPosition(stepping)[0]);
223-
ACTS_VERBOSE(" y = " << multiPosition(stepping)[1]);
224-
ACTS_VERBOSE(" z = " << multiPosition(stepping)[2]);
238+
ACTS_VERBOSE(" x = " << pos[0]);
239+
ACTS_VERBOSE(" y = " << pos[1]);
240+
ACTS_VERBOSE(" z = " << pos[2]);
241+
242+
243+
ACTS_VERBOSE("Dir before step:");
244+
ACTS_VERBOSE(" dx = " << dir[0]);
245+
ACTS_VERBOSE(" dy = " << dir[1]);
246+
ACTS_VERBOSE(" dz = " << dir[2]);
225247

226248
// First Runge-Kutta point
227249
sd.B_first = getMultiField(stepping, pos);
@@ -270,7 +292,7 @@ Result<double> MultiEigenStepperSIMD<N, AA, BB, CC, DD>::step(
270292
// }();
271293

272294
SimdScalar h = 0;
273-
for (int i = 0; i < stepping.stepSizes.size(); ++i) {
295+
for (auto i = 0ul; i < stepping.stepSizes.size(); ++i) {
274296
h[i] = stepping.stepSizes[i].value();
275297
}
276298

@@ -285,13 +307,23 @@ Result<double> MultiEigenStepperSIMD<N, AA, BB, CC, DD>::step(
285307
const SimdScalar half_h = h * SimdScalar(0.5);
286308

287309
// Second Runge-Kutta point
288-
const SimdVector3 pos1 = pos + half_h * dir + h2 * 0.125 * sd.k1;
310+
const SimdVector3 pos1 = pos + half_h * dir + h2 * SimdScalar(0.125) * sd.k1;
289311
sd.B_middle = getMultiField(stepping, pos1);
312+
313+
ACTS_VERBOSE("Runge-Kutta k1:");
314+
ACTS_VERBOSE(" x = " << sd.k1[0]);
315+
ACTS_VERBOSE(" y = " << sd.k1[1]);
316+
ACTS_VERBOSE(" z = " << sd.k1[2]);
290317

291318
if (!stepping.extension.k2(state, MultiProxyStepper{}, navigator, sd.k2,
292319
sd.B_middle, sd.kQoP, half_h, sd.k1)) {
293320
return EigenStepperError::StepInvalid;
294321
}
322+
323+
ACTS_VERBOSE("Runge-Kutta k2:");
324+
ACTS_VERBOSE(" x = " << sd.k2[0]);
325+
ACTS_VERBOSE(" y = " << sd.k2[1]);
326+
ACTS_VERBOSE(" z = " << sd.k2[2]);
295327

296328
// check for nan
297329
for (int i = 0; i < 3; ++i) {
@@ -312,12 +344,22 @@ Result<double> MultiEigenStepperSIMD<N, AA, BB, CC, DD>::step(
312344
// Last Runge-Kutta point
313345
const SimdVector3 pos2 = pos + h * dir + h2 * 0.5 * sd.k3;
314346
sd.B_last = getMultiField(stepping, pos2);
347+
348+
ACTS_VERBOSE("Runge-Kutta k3:");
349+
ACTS_VERBOSE(" x = " << sd.k3[0]);
350+
ACTS_VERBOSE(" y = " << sd.k3[1]);
351+
ACTS_VERBOSE(" z = " << sd.k3[2]);
315352

316353
if (!stepping.extension.k4(state, MultiProxyStepper{}, navigator, sd.k4,
317354
sd.B_last, sd.kQoP, h, sd.k3)) {
318355
return EigenStepperError::StepInvalid;
319356
}
320-
357+
358+
ACTS_VERBOSE("Runge-Kutta k4:");
359+
ACTS_VERBOSE(" x = " << sd.k4[0]);
360+
ACTS_VERBOSE(" y = " << sd.k4[1]);
361+
ACTS_VERBOSE(" z = " << sd.k4[2]);
362+
321363
// check for nan
322364
for (int i = 0; i < 3; ++i) {
323365
assert(!sd.k4[i].isNaN().any() && "k4 contains nan");

0 commit comments

Comments
 (0)