-
Notifications
You must be signed in to change notification settings - Fork 270
feat: Write track parameter performance from track states in a geometry region #5882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
andiwand
merged 11 commits into
acts-project:main
from
andiwand:track-state-parameter-performance
Aug 25, 2026
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b4de5d8
feat: Add TrackExtrapolationAlgorithm
andiwand ff390e0
feat: Write seed parameter performance from addSeeding
andiwand 0353023
feat: Configure the residual binning of the track parameter performance
andiwand 6c24a5e
refactor: Fill ResPlotTool from truth bound parameters
andiwand 575cf07
feat: Add truth and reco parameters on a surface
andiwand af65c24
feat: Write track parameter performance from track states
andiwand 078224a
Merge remote-tracking branch 'upstream/main' into track-state-paramet…
andiwand c9151f3
refactor: Qualify the parameters-on-surface definitions
andiwand 11c5938
Merge remote-tracking branch 'upstream/main' into track-state-paramet…
andiwand a322f08
docs: Answer the review questions in the comments
andiwand 809f2c8
Merge branch 'main' of github.com:acts-project/acts into track-state-…
andiwand File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
Examples/Framework/include/ActsExamples/Validation/ParametersOnSurface.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| // This file is part of the ACTS project. | ||
| // | ||
| // Copyright (C) 2016 CERN for the benefit of the ACTS project | ||
| // | ||
| // This Source Code Form is subject to the terms of the Mozilla Public | ||
| // License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| // file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "Acts/EventData/BoundTrackParameters.hpp" | ||
| #include "Acts/Geometry/GeometryContext.hpp" | ||
| #include "Acts/Utilities/Logger.hpp" | ||
| #include "ActsExamples/EventData/Index.hpp" | ||
| #include "ActsExamples/EventData/SimHit.hpp" | ||
| #include "ActsExamples/EventData/SimParticle.hpp" | ||
| #include "ActsExamples/EventData/Track.hpp" | ||
| #include "ActsExamples/EventData/TruthMatching.hpp" | ||
|
|
||
| #include <optional> | ||
|
|
||
| namespace Acts { | ||
| class Surface; | ||
| } | ||
|
|
||
| namespace ActsExamples { | ||
|
|
||
| /// The track-state parameters to extract. | ||
| enum class TrackParameterType { | ||
| /// Parameters before the measurement update | ||
| Predicted, | ||
| /// Parameters after the measurement update | ||
| Filtered, | ||
| /// Smoothed parameters | ||
| Smoothed, | ||
| /// Smoothed parameters with the state's own measurement removed | ||
| Unbiased, | ||
| }; | ||
|
|
||
| /// Compute the truth bound track parameters on a surface from the simulated | ||
| /// hits of a measurement. | ||
| /// | ||
| /// Position, direction, and time are averaged over the simulated hits, the | ||
| /// momentum is taken from the first one, and charge and hypothesis from the | ||
| /// given particle. | ||
| /// | ||
| /// @note The hits are averaged regardless of which particle produced them, so | ||
| /// a merged cluster gives a mixture. Same as `RootTrackParameterWriter`. | ||
| /// | ||
| /// @param gctx The geometry context | ||
| /// @param surface The surface to express the truth parameters on | ||
| /// @param measurementIndex The index of the measurement on the surface | ||
| /// @param particle The truth particle | ||
| /// @param simHits The simulated hits container | ||
| /// @param measurementSimHitsMap Map from measurement index to simulated hits | ||
| /// @param logger A logger for messages | ||
| /// @return The parameters without covariance, or nullopt without truth hits | ||
| std::optional<Acts::BoundTrackParameters> truthParametersOnSurface( | ||
| const Acts::GeometryContext& gctx, const Acts::Surface& surface, | ||
| Index measurementIndex, const SimParticle& particle, | ||
| const SimHitContainer& simHits, | ||
| const MeasurementSimHitsMap& measurementSimHitsMap, | ||
| const Acts::Logger& logger); | ||
|
|
||
| /// Extract the reconstructed bound track parameters on the reference surface | ||
| /// of a track state. | ||
| /// | ||
| /// @param state The track state to extract the parameters from | ||
| /// @param parameterType Which parameters; if not set, the best available ones | ||
| /// (smoothed, filtered, or predicted). `Unbiased` is never picked | ||
| /// implicitly and has to be requested | ||
| /// @param hypothesis The particle hypothesis for the parameters | ||
| /// @return The parameters with covariance, or nullopt without a reference | ||
| /// surface or matching parameters | ||
| std::optional<Acts::BoundTrackParameters> recoParametersOnSurface( | ||
| const ConstTrackStateProxy& state, | ||
| std::optional<TrackParameterType> parameterType, | ||
| const Acts::ParticleHypothesis& hypothesis); | ||
|
|
||
| } // namespace ActsExamples |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
Examples/Framework/src/Validation/ParametersOnSurface.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| // This file is part of the ACTS project. | ||
| // | ||
| // Copyright (C) 2016 CERN for the benefit of the ACTS project | ||
| // | ||
| // This Source Code Form is subject to the terms of the Mozilla Public | ||
| // License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| // file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
|
||
| #include "ActsExamples/Validation/ParametersOnSurface.hpp" | ||
|
|
||
| #include "Acts/Utilities/TrackHelpers.hpp" | ||
| #include "Acts/Utilities/VectorHelpers.hpp" | ||
| #include "ActsExamples/EventData/AverageSimHits.hpp" | ||
| #include "ActsExamples/Utilities/Range.hpp" | ||
|
|
||
| #include <utility> | ||
|
|
||
| std::optional<Acts::BoundTrackParameters> | ||
| ActsExamples::truthParametersOnSurface( | ||
| const Acts::GeometryContext& gctx, const Acts::Surface& surface, | ||
| Index measurementIndex, const SimParticle& particle, | ||
| const SimHitContainer& simHits, | ||
| const MeasurementSimHitsMap& measurementSimHitsMap, | ||
| const Acts::Logger& logger) { | ||
| using Acts::VectorHelpers::phi; | ||
| using Acts::VectorHelpers::theta; | ||
|
|
||
| using enum Acts::BoundIndices; | ||
|
|
||
| const auto indices = | ||
| makeRange(measurementSimHitsMap.equal_range(measurementIndex)); | ||
| if (indices.empty()) { | ||
| ACTS_WARNING("No truth hits associated to measurement " << measurementIndex | ||
| << " found"); | ||
| return std::nullopt; | ||
| } | ||
|
|
||
| const auto [truthLocal, truthPos4, truthUnitDir] = | ||
| averageSimHits(gctx, surface, simHits, indices, logger); | ||
|
|
||
| // position, direction, and time are averaged over the hits above. the | ||
| // momentum is not: an average over hits of different particles is not the | ||
| // momentum of any of them. take the first hit instead, which exists because | ||
| // the range was checked to be non-empty. | ||
| const auto simHitIdx0 = indices.begin()->second; | ||
| const auto& simHit0 = *simHits.nth(simHitIdx0); | ||
| const auto momentum = simHit0.momentum4Before().segment<3>(Acts::eMom0); | ||
|
|
||
| Acts::BoundVector params = Acts::BoundVector::Zero(); | ||
| params[eBoundLoc0] = truthLocal[Acts::ePos0]; | ||
| params[eBoundLoc1] = truthLocal[Acts::ePos1]; | ||
| params[eBoundPhi] = phi(truthUnitDir); | ||
| params[eBoundTheta] = theta(truthUnitDir); | ||
| params[eBoundQOverP] = | ||
| particle.hypothesis().qOverP(momentum.norm(), particle.charge()); | ||
| params[eBoundTime] = truthPos4[Acts::eTime]; | ||
|
|
||
| return Acts::BoundTrackParameters(surface.getSharedPtr(), params, | ||
| std::nullopt, particle.hypothesis()); | ||
| } | ||
|
|
||
| std::optional<Acts::BoundTrackParameters> ActsExamples::recoParametersOnSurface( | ||
| const ConstTrackStateProxy& state, | ||
| std::optional<TrackParameterType> parameterType, | ||
| const Acts::ParticleHypothesis& hypothesis) { | ||
| using enum TrackParameterType; | ||
|
|
||
| if (!state.hasReferenceSurface()) { | ||
| return std::nullopt; | ||
| } | ||
|
|
||
| const auto stateParameters = | ||
| [&]() -> std::optional<std::pair<Acts::BoundVector, Acts::BoundMatrix>> { | ||
| if (!parameterType.has_value()) { | ||
| if (!state.hasSmoothed() && !state.hasFiltered() && | ||
| !state.hasPredicted()) { | ||
| return std::nullopt; | ||
| } | ||
| // the choice is the proxy's: `parameters()` returns smoothed, else | ||
| // filtered, else predicted. `Unbiased` is not among them and has to be | ||
| // requested explicitly. | ||
| return std::pair(state.parameters(), state.covariance()); | ||
| } | ||
|
AJPfleger marked this conversation as resolved.
|
||
| if (parameterType == Predicted && state.hasPredicted()) { | ||
| return std::pair(state.predicted(), state.predictedCovariance()); | ||
| } | ||
| if (parameterType == Filtered && state.hasFiltered()) { | ||
| return std::pair(state.filtered(), state.filteredCovariance()); | ||
| } | ||
| if (parameterType == Smoothed && state.hasSmoothed()) { | ||
| return std::pair(state.smoothed(), state.smoothedCovariance()); | ||
| } | ||
| if (parameterType == Unbiased && state.hasSmoothed() && | ||
| state.hasProjector() && state.hasCalibrated()) { | ||
| return Acts::calculateUnbiasedParametersCovariance( | ||
| Acts::AnyConstTrackStateProxy{state}); | ||
| } | ||
| return std::nullopt; | ||
| }(); | ||
|
|
||
| if (!stateParameters.has_value()) { | ||
| return std::nullopt; | ||
| } | ||
|
|
||
| return Acts::BoundTrackParameters(state.referenceSurface().getSharedPtr(), | ||
| stateParameters->first, | ||
| stateParameters->second, hypothesis); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.