Skip to content

Commit a1f2359

Browse files
Merge branch 'main' into feat-index-grid-navigation-policy
2 parents 58006f5 + b22a0d1 commit a1f2359

File tree

8 files changed

+171
-26
lines changed

8 files changed

+171
-26
lines changed

CI/physmon/workflows/physmon_trackrefitting_kf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
field=setup.field,
2525
digiConfigFile=setup.digiConfig,
2626
outputDir=tp,
27-
reverseFilteringMomThreshold=float("inf"),
27+
reverseFilteringMomThreshold=float("inf"), # use reverse kf smoothing
2828
reverseFilteringCovarianceScaling=100.0,
2929
s=s,
3030
)

Core/include/Acts/Propagator/DirectNavigator.hpp

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -296,26 +296,33 @@ class DirectNavigator {
296296
// Move the sequence to the next surface
297297
state.nextSurface();
298298

299-
if (!state.endOfSurfaces()) {
300-
ACTS_VERBOSE("Next surface candidate is "
299+
while (!state.endOfSurfaces()) {
300+
ACTS_VERBOSE("Next surface candidate is "
301301
<< state.navSurface().geometryId() << ". "
302302
<< state.remainingSurfaces() << " out of "
303303
<< state.options.surfaces.size()
304304
<< " surfaces remain to try.");
305-
} else {
306-
ACTS_VERBOSE("End of surfaces reached, navigation break.");
307-
state.navigationBreak = true;
308-
return NavigationTarget::None();
305+
306+
// Establish & update the surface status
307+
// TODO we do not know the intersection index - passing the closer one
308+
const Surface& surface = state.navSurface();
309+
const double farLimit = std::numeric_limits<double>::max();
310+
const NavigationTarget target = chooseIntersection(
311+
state.options.geoContext, surface, position, direction,
312+
BoundaryTolerance::Infinite(), state.options.nearLimit, farLimit,
313+
state.options.surfaceTolerance);
314+
if (target.isValid()) {
315+
return target;
316+
}
317+
318+
ACTS_VERBOSE("No valid intersection found with surface "
319+
<< surface.geometryId() << ", trying next surface.");
320+
state.nextSurface();
309321
}
310322

311-
// Establish & update the surface status
312-
// TODO we do not know the intersection index - passing the closer one
313-
const Surface& surface = state.navSurface();
314-
const double farLimit = std::numeric_limits<double>::max();
315-
return chooseIntersection(state.options.geoContext, surface, position,
316-
direction, BoundaryTolerance::Infinite(),
317-
state.options.nearLimit, farLimit,
318-
state.options.surfaceTolerance);
323+
ACTS_VERBOSE("End of surfaces reached, navigation break.");
324+
state.navigationBreak = true;
325+
return NavigationTarget::None();
319326
}
320327

321328
/// @brief Check if the current target is still valid
@@ -361,7 +368,7 @@ class DirectNavigator {
361368

362369
// Set the current surface
363370
state.currentSurface = &state.navSurface();
364-
ACTS_VERBOSE("Current surface set to "
371+
ACTS_VERBOSE("Current surface set to "
365372
<< state.currentSurface->geometryId());
366373
}
367374

@@ -376,7 +383,8 @@ class DirectNavigator {
376383

377384
for (auto [intersectionIndex, intersection] :
378385
Acts::enumerate(intersections)) {
379-
if (detail::checkPathLength(intersection.pathLength(), nearLimit,
386+
if (intersection.isValid() &&
387+
detail::checkPathLength(intersection.pathLength(), nearLimit,
380388
farLimit, logger())) {
381389
return NavigationTarget(intersection, intersectionIndex, surface,
382390
boundaryTolerance);
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
// This file is part of the ACTS project.
2+
//
3+
// Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/.
8+
#pragma once
9+
10+
#include "Acts/Definitions/Algebra.hpp"
11+
#include "Acts/Utilities/BinningData.hpp"
12+
#include "Acts/Utilities/ProtoAxis.hpp"
13+
14+
#include <span>
15+
#include <string>
16+
#include <vector>
17+
18+
namespace Acts::ProtoAxisHelpers {
19+
20+
/// @brief Get the number of bins from a ProtoAxis
21+
/// @param axis DirectedProtoAxis object
22+
/// @return Number of bins in the axis
23+
inline std::size_t binsOfProtoAxis(const Acts::DirectedProtoAxis& axis) {
24+
return axis.getAxis().getNBins();
25+
}
26+
27+
/// @brief Get the total number of bins from multiple ProtoAxes
28+
/// @param axes Span of DirectedProtoAxis objects
29+
/// @return Total number of bins across all axes
30+
inline std::size_t totalBinsFromProtoAxes(
31+
std::span<const Acts::DirectedProtoAxis> axes) {
32+
if (axes.empty() || axes.size() > 3) {
33+
throw std::runtime_error(
34+
"Unsupported number of axes, must be 1-3, instead got " +
35+
std::to_string(axes.size()) + ")");
36+
}
37+
return axes[0].getAxis().getNBins() *
38+
(axes.size() > 1 ? axes[1].getAxis().getNBins() : 1) *
39+
(axes.size() > 2 ? axes[2].getAxis().getNBins() : 1);
40+
}
41+
42+
/// @brief Get the number of bins from a specific ProtoAxis in a collection
43+
/// @param axes DirectedProtoAxis span
44+
/// @param ba Bin axis index
45+
/// @return Number of bins in the specified axis
46+
inline std::size_t binsFromProtoAxes(
47+
std::span<const Acts::DirectedProtoAxis> axes, std::size_t ba) {
48+
if (axes.empty() || axes.size() > 3) {
49+
throw std::runtime_error(
50+
"Unsupported number of axes, must be 1-3, instead got " +
51+
std::to_string(axes.size()) + ")");
52+
}
53+
Acts::BinningData bd(axes[ba]);
54+
return bd.bins();
55+
}
56+
57+
/// @brief Get the bin index from a ProtoAxis using local coordinates
58+
/// @param axis DirectedProtoAxis object
59+
/// @param lp Local position vector
60+
/// @return Bin index corresponding to the local position
61+
inline std::size_t binFromProtoAxis(const Acts::DirectedProtoAxis& axis,
62+
const Acts::Vector2& lp) {
63+
Acts::BinningData bd(axis);
64+
return bd.searchLocal(lp);
65+
}
66+
67+
/// @brief Get the bin index from a ProtoAxis using global coordinates
68+
/// @param axis DirectedProtoAxis object
69+
/// @param gp Global position vector
70+
/// @return Bin index corresponding to the global position
71+
inline std::size_t binFromProtoAxis(const Acts::DirectedProtoAxis& axis,
72+
const Acts::Vector3& gp) {
73+
Acts::BinningData bd(axis);
74+
return bd.searchGlobal(gp);
75+
}
76+
77+
/// @brief Get the bin triple from multiple ProtoAxes using global coordinates
78+
/// @param axes Span of DirectedProtoAxis objects
79+
/// @param gp Global position vector
80+
/// @return Array of bin indices corresponding to the global position for each axis
81+
inline std::array<std::size_t, 3> binTripleFromProtoAxes(
82+
std::span<const Acts::DirectedProtoAxis> axes, const Acts::Vector3& gp) {
83+
const Acts::Vector3& bPosition = gp;
84+
std::array<std::size_t, 3> bTriple = {0, 0, 0};
85+
if (axes.empty() || axes.size() > 3) {
86+
throw std::runtime_error(
87+
"Unsupported number of axes, must be 1-3, instead got " +
88+
std::to_string(axes.size()) + ")");
89+
}
90+
if (axes.size() == 1) {
91+
Acts::BinningData bd0(axes[0]);
92+
bTriple[0] = bd0.searchGlobal(bPosition);
93+
}
94+
if (axes.size() == 2) {
95+
Acts::BinningData bd1(axes[1]);
96+
bTriple[1] = bd1.searchGlobal(bPosition);
97+
}
98+
if (axes.size() == 3) {
99+
Acts::BinningData bd2(axes[2]);
100+
bTriple[2] = bd2.searchGlobal(bPosition);
101+
}
102+
return bTriple;
103+
}
104+
105+
/// @brief Get the maximum bin index from a specific ProtoAxis in a collection
106+
/// @param axes DirectedProtoAxis span
107+
/// @param ba Bin axis index
108+
/// @return Maximum bin index in the specified axis
109+
inline std::size_t maxBin(std::span<const Acts::DirectedProtoAxis> axes,
110+
std::size_t ba = 0) {
111+
if (axes.empty() || axes.size() > 3) {
112+
throw std::runtime_error(
113+
"Unsupported number of axes, must be 1-3, instead got " +
114+
std::to_string(axes.size()) + ")");
115+
}
116+
std::vector<Acts::BinningData> binningDataVec;
117+
binningDataVec.reserve(axes.size());
118+
for (const auto& axis : axes) {
119+
binningDataVec.emplace_back(axis);
120+
}
121+
if (ba >= binningDataVec.size()) {
122+
return 0;
123+
}
124+
return (binningDataVec.at(ba).bins() - 1);
125+
}
126+
127+
} // namespace Acts::ProtoAxisHelpers

Core/src/Material/AccumulatedSurfaceMaterial.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include "Acts/Material/BinnedSurfaceMaterial.hpp"
1212
#include "Acts/Material/HomogeneousSurfaceMaterial.hpp"
13+
#include "Acts/Utilities/ProtoAxisHelpers.hpp"
1314

1415
#include <utility>
1516

Examples/Algorithms/TrackFitting/src/RefittingAlgorithm.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ ProcessCode RefittingAlgorithm::execute(const AlgorithmContext& ctx) const {
124124
if (refittedTrack.hasReferenceSurface()) {
125125
ACTS_VERBOSE("Refitted parameters for track " << itrack);
126126
ACTS_VERBOSE(" " << track.parameters().transpose());
127+
ACTS_VERBOSE("Measurements: " << refittedTrack.nMeasurements());
128+
ACTS_VERBOSE("Outliers: " << refittedTrack.nOutliers());
127129
} else {
128130
ACTS_DEBUG("No refitted parameters for track " << itrack);
129131
}
@@ -135,9 +137,13 @@ ProcessCode RefittingAlgorithm::execute(const AlgorithmContext& ctx) const {
135137
++itrack;
136138
}
137139

138-
std::stringstream ss;
139-
trackStateContainer->statistics().toStream(ss);
140-
ACTS_DEBUG(ss.str());
140+
ACTS_DEBUG("Fitted tracks: " << trackContainer->size());
141+
142+
if (logger().doPrint(Acts::Logging::DEBUG)) {
143+
std::stringstream ss;
144+
trackStateContainer->statistics().toStream(ss);
145+
ACTS_DEBUG(ss.str());
146+
}
141147

142148
ConstTrackContainer constTracks{
143149
std::make_shared<Acts::ConstVectorTrackContainer>(

Examples/Algorithms/TrackFitting/src/TrackFittingAlgorithm.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ ProcessCode TrackFittingAlgorithm::execute(const AlgorithmContext& ctx) const {
171171
}
172172
}
173173

174+
ACTS_DEBUG("Fitted tracks: " << trackContainer->size());
175+
174176
if (logger().doPrint(Acts::Logging::DEBUG)) {
175177
std::stringstream ss;
176178
trackStateContainer->statistics().toStream(ss);

Examples/Scripts/Python/truth_tracking_gsf_refitting.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def runRefittingGsf(
2121
field: acts.MagneticFieldProvider,
2222
digiConfigFile: Path,
2323
outputDir: Path,
24+
reverseFilteringCovarianceScaling=100.0,
2425
inputParticlePath: Optional[Path] = None,
2526
inputSimHitsPath: Optional[Path] = None,
2627
decorators=[],
@@ -38,8 +39,8 @@ def runRefittingGsf(
3839
inputHitsPath=inputSimHitsPath,
3940
decorators=decorators,
4041
generatedParticleType=acts.PdgParticle.eElectron,
41-
reverseFilteringMomThreshold=0.0,
42-
reverseFilteringCovarianceScaling=1.0,
42+
reverseFilteringMomThreshold=0 * u.GeV, # use direct smoothing
43+
reverseFilteringCovarianceScaling=reverseFilteringCovarianceScaling,
4344
s=s,
4445
)
4546

@@ -54,7 +55,7 @@ def runRefittingGsf(
5455
"componentMergeMethod": acts.examples.ComponentMergeMethod.maxWeight,
5556
"mixtureReductionAlgorithm": acts.examples.MixtureReductionAlgorithm.KLDistance,
5657
"weightCutoff": 1.0e-4,
57-
"reverseFilteringCovarianceScaling": 100.0,
58+
"reverseFilteringCovarianceScaling": reverseFilteringCovarianceScaling,
5859
"level": acts.logging.INFO,
5960
}
6061

Examples/Scripts/Python/truth_tracking_kalman_refitting.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ def runRefittingKf(
2222
outputDir: Path,
2323
multipleScattering: bool = True,
2424
energyLoss: bool = True,
25-
reverseFilteringMomThreshold=0 * u.GeV,
26-
reverseFilteringCovarianceScaling=1.0,
25+
reverseFilteringMomThreshold=float("inf"),
26+
reverseFilteringCovarianceScaling=100.0,
2727
s: acts.examples.Sequencer = None,
2828
):
2929
s = runTruthTrackingKalman(
3030
trackingGeometry,
3131
field,
3232
digiConfigFile=digiConfigFile,
3333
outputDir=outputDir,
34-
reverseFilteringMomThreshold=reverseFilteringMomThreshold,
34+
reverseFilteringMomThreshold=0 * u.GeV, # use direct smoothing
3535
reverseFilteringCovarianceScaling=reverseFilteringCovarianceScaling,
3636
s=s,
3737
)

0 commit comments

Comments
 (0)