-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor!: B field access returns Result (#825)
Previously, we didn't have a mechanism to communicate that a field query failed. This is problematic, because it's not clear what to do when for instance our interpolated field goes out of bounds (see #784). This PR makes `MagneticFieldProvider` require the `getField` and `getFieldGradient` methods to return `Result<Vector3>` instead of the bare vector. This changes the public interface slightly, and all clients need to be adjusted. Additionally, the `InterpolatedBFieldMap` now checks each time a field cell is created or if the field is queried directly, whether the query position is out of bounds of the map, and will return a new `MagneticFieldError::OutOfBounds` if that happens. BREAKING CHANGE: - The signature of field query methods in `MagneticFieldProvider` changes from ```cpp virtual Vector3 getField(const Vector3& position, Cache& cache) const = 0; virtual Vector3 getFieldGradient(const Vector3& position, ActsMatrix<3, 3>& derivative, Cache& cache) const = 0; ``` to ```cpp virtual Result<Vector3> getField(const Vector3& position, Cache& cache) const = 0; virtual Result<Vector3> getFieldGradient(const Vector3& position, ActsMatrix<3, 3>& derivative, Cache& cache) const = 0; ``` - `InterpolatedBFieldMap::getMin` and `InterpolatedBFieldMap::getMax` now return the extent of the valid **interpolation domain**, rather than the raw grid extent.
- Loading branch information
1 parent
bdd59e0
commit b6371e2
Showing
32 changed files
with
381 additions
and
180 deletions.
There are no files selected for viewing
This file contains 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 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 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,27 @@ | ||
// This file is part of the Acts project. | ||
// | ||
// Copyright (C) 2021 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 http://mozilla.org/MPL/2.0/. | ||
|
||
#pragma once | ||
|
||
#include <system_error> | ||
|
||
namespace Acts { | ||
|
||
enum class MagneticFieldError { | ||
OutOfBounds = 1, | ||
}; | ||
|
||
std::error_code make_error_code(Acts::MagneticFieldError e); | ||
|
||
} // namespace Acts | ||
|
||
namespace std { | ||
// register with STL | ||
template <> | ||
struct is_error_code_enum<Acts::MagneticFieldError> : std::true_type {}; | ||
} // namespace std |
This file contains 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 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 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 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
Oops, something went wrong.