Skip to content

Commit

Permalink
chore: Some magnetic field code cleanup (#3982)
Browse files Browse the repository at this point in the history
- cleanup includes
- cleanup some `using namespace`

pulled out of #3951

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

## Release Notes

- **New Features**
	- Introduced new classes for enhanced magnetic field handling in Python.
	- Added methods for creating magnetic field maps from files.

- **Bug Fixes**
	- Improved error handling in `getField` function to provide clearer feedback on failures.

- **Documentation**
	- Enhanced comments for clarity in several files.

- **Chores**
	- Removed unused include directives across multiple files to streamline code.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
andiwand authored Dec 13, 2024
1 parent 2d5ed72 commit 9a2b74d
Show file tree
Hide file tree
Showing 16 changed files with 4 additions and 49 deletions.
1 change: 0 additions & 1 deletion Core/include/Acts/MagneticField/InterpolatedBFieldMap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "Acts/MagneticField/MagneticFieldContext.hpp"
#include "Acts/MagneticField/MagneticFieldError.hpp"
#include "Acts/MagneticField/MagneticFieldProvider.hpp"
#include "Acts/Utilities/Grid.hpp"
#include "Acts/Utilities/Interpolation.hpp"
#include "Acts/Utilities/Result.hpp"

Expand Down
3 changes: 0 additions & 3 deletions Core/include/Acts/MagneticField/MagneticFieldProvider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
#include "Acts/Utilities/Any.hpp"
#include "Acts/Utilities/Result.hpp"

#include <array>
#include <memory>

namespace Acts {

/// @defgroup MagneticField Magnetic field
Expand Down
4 changes: 1 addition & 3 deletions Core/include/Acts/Material/SurfaceMaterialMapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@
#include "Acts/Material/AccumulatedSurfaceMaterial.hpp"
#include "Acts/Material/ISurfaceMaterial.hpp"
#include "Acts/Material/MaterialInteraction.hpp"
#include "Acts/Propagator/MaterialInteractor.hpp"
#include "Acts/Propagator/Navigator.hpp"
#include "Acts/Propagator/Propagator.hpp"
#include "Acts/Propagator/StraightLineStepper.hpp"
#include "Acts/Propagator/SurfaceCollector.hpp"
#include "Acts/Propagator/VolumeCollector.hpp"
#include "Acts/Surfaces/Surface.hpp"
#include "Acts/Utilities/Logger.hpp"

Expand Down Expand Up @@ -225,4 +222,5 @@ class SurfaceMaterialMapper {
/// The logging instance
std::unique_ptr<const Logger> m_logger;
};

} // namespace Acts
5 changes: 0 additions & 5 deletions Core/include/Acts/Navigation/DetectorNavigator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,19 @@

#pragma once

#include "Acts/Definitions/Units.hpp"
#include "Acts/Detector/Detector.hpp"
#include "Acts/Detector/DetectorVolume.hpp"
#include "Acts/Detector/Portal.hpp"
#include "Acts/Geometry/BoundarySurfaceT.hpp"
#include "Acts/Geometry/GeometryIdentifier.hpp"
#include "Acts/Geometry/Layer.hpp"
#include "Acts/Navigation/NavigationState.hpp"
#include "Acts/Propagator/NavigatorOptions.hpp"
#include "Acts/Propagator/NavigatorStatistics.hpp"
#include "Acts/Propagator/Propagator.hpp"
#include "Acts/Surfaces/BoundaryTolerance.hpp"
#include "Acts/Surfaces/Surface.hpp"
#include "Acts/Utilities/Logger.hpp"

#include <algorithm>
#include <iomanip>
#include <iterator>
#include <sstream>
#include <string>

Expand Down
1 change: 0 additions & 1 deletion Core/include/Acts/Propagator/StraightLineStepper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "Acts/Utilities/MathHelpers.hpp"
#include "Acts/Utilities/Result.hpp"

#include <algorithm>
#include <cmath>
#include <functional>
#include <limits>
Expand Down
1 change: 0 additions & 1 deletion Core/src/MagneticField/SolenoidBField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include "Acts/Utilities/VectorHelpers.hpp"

#include <algorithm>
#include <cmath>
#include <numbers>

Expand Down
1 change: 0 additions & 1 deletion Core/src/Propagator/SympyStepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "Acts/Propagator/detail/SympyJacobianEngine.hpp"

#include <cmath>
#include <cstdint>

#include "codegen/sympy_stepper_math.hpp"

Expand Down
1 change: 0 additions & 1 deletion Core/src/Vertexing/HelicalTrackLinearizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "Acts/Vertexing/HelicalTrackLinearizer.hpp"

#include "Acts/Propagator/PropagatorOptions.hpp"
#include "Acts/Surfaces/PerigeeSurface.hpp"
#include "Acts/Utilities/MathHelpers.hpp"
#include "Acts/Vertexing/LinearizerTrackParameters.hpp"

Expand Down
10 changes: 0 additions & 10 deletions Examples/Io/Root/include/ActsExamples/Io/Root/RootBFieldWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,19 @@

#pragma once

#include "Acts/Definitions/Units.hpp"
#include "Acts/MagneticField/InterpolatedBFieldMap.hpp"
#include "Acts/Utilities/Logger.hpp"
#include "ActsExamples/Framework/ProcessCode.hpp"

#include <array>
#include <cstddef>
#include <ios>
#include <memory>
#include <mutex>
#include <optional>
#include <sstream>
#include <stdexcept>
#include <string>

#include <TFile.h>
#include <TTree.h>
#include <boost/optional.hpp>

namespace Acts {
class InterpolatedMagneticField;
} // namespace Acts

namespace ActsExamples {

/// @class RootBFieldWriter
Expand Down
9 changes: 3 additions & 6 deletions Examples/Io/Root/src/RootBFieldWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Definitions/Units.hpp"
#include "Acts/MagneticField/InterpolatedBFieldMap.hpp"
#include "Acts/MagneticField/MagneticFieldContext.hpp"
#include "Acts/Utilities/VectorHelpers.hpp"

Expand All @@ -30,9 +29,6 @@ namespace ActsExamples {
void RootBFieldWriter::run(const Config& config,
std::unique_ptr<const Acts::Logger> p_logger) {
// Set up (local) logging
// @todo Remove dangerous using declaration once the logger macro
// tolerates it
using namespace Acts;
ACTS_LOCAL_LOGGER(std::move(p_logger))

Acts::MagneticFieldContext bFieldContext;
Expand Down Expand Up @@ -179,7 +175,7 @@ void RootBFieldWriter::run(const Config& config,
for (std::size_t k = 0; k < nBinsZ; k++) {
double raw_z = minZ + k * stepZ;
Acts::Vector3 position(raw_x, raw_y, raw_z);
Vector3 bField = config.bField->getFieldUnchecked(position);
Acts::Vector3 bField = config.bField->getFieldUnchecked(position);

x = raw_x / Acts::UnitConstants::mm;
y = raw_y / Acts::UnitConstants::mm;
Expand Down Expand Up @@ -268,7 +264,7 @@ void RootBFieldWriter::run(const Config& config,
z = raw_z / Acts::UnitConstants::mm;
r = raw_r / Acts::UnitConstants::mm;
Bz = bField.z() / Acts::UnitConstants::T;
Br = VectorHelpers::perp(bField) / Acts::UnitConstants::T;
Br = Acts::VectorHelpers::perp(bField) / Acts::UnitConstants::T;
outputTree->Fill();
} // for R
} // for z
Expand All @@ -278,4 +274,5 @@ void RootBFieldWriter::run(const Config& config,
ACTS_INFO("Closing and Writing ROOT output File : " << config.fileName);
outputTree->Write();
}

} // namespace ActsExamples
1 change: 0 additions & 1 deletion Examples/Python/src/MagneticField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <stdexcept>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>

#include <pybind11/pybind11.h>
Expand Down
2 changes: 0 additions & 2 deletions Tests/UnitTests/Core/MagneticField/ConstantBFieldTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
#include "Acts/MagneticField/MagneticFieldContext.hpp"
#include "Acts/Utilities/Result.hpp"

#include <utility>

namespace bdata = boost::unit_test::data;
using namespace Acts::UnitLiterals;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,17 @@
#include "Acts/Definitions/Algebra.hpp"
#include "Acts/MagneticField/InterpolatedBFieldMap.hpp"
#include "Acts/MagneticField/MagneticFieldContext.hpp"
#include "Acts/MagneticField/MagneticFieldProvider.hpp"
#include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
#include "Acts/Utilities/Axis.hpp"
#include "Acts/Utilities/AxisFwd.hpp"
#include "Acts/Utilities/Grid.hpp"
#include "Acts/Utilities/Result.hpp"
#include "Acts/Utilities/VectorHelpers.hpp"
#include "Acts/Utilities/detail/grid_helper.hpp"

#include <array>
#include <cstddef>
#include <functional>
#include <optional>
#include <tuple>
#include <utility>
#include <vector>

using Acts::VectorHelpers::perp;

Expand Down
1 change: 0 additions & 1 deletion Tests/UnitTests/Core/MagneticField/SolenoidBFieldTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "Acts/Utilities/Result.hpp"

#include <cstddef>
#include <fstream>

using namespace Acts::UnitLiterals;

Expand Down
7 changes: 0 additions & 7 deletions Tests/UnitTests/Core/Propagator/ExtrapolatorTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <boost/test/unit_test.hpp>

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Definitions/Direction.hpp"
#include "Acts/Definitions/TrackParametrization.hpp"
#include "Acts/Definitions/Units.hpp"
#include "Acts/EventData/GenericCurvilinearTrackParameters.hpp"
Expand All @@ -23,25 +22,19 @@
#include "Acts/Propagator/MaterialInteractor.hpp"
#include "Acts/Propagator/Navigator.hpp"
#include "Acts/Propagator/Propagator.hpp"
#include "Acts/Propagator/StandardAborters.hpp"
#include "Acts/Propagator/SurfaceCollector.hpp"
#include "Acts/Surfaces/Surface.hpp"
#include "Acts/Tests/CommonHelpers/CylindricalTrackingGeometry.hpp"
#include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
#include "Acts/Utilities/Result.hpp"

#include <algorithm>
#include <array>
#include <cmath>
#include <cstdint>
#include <map>
#include <memory>
#include <numbers>
#include <optional>
#include <random>
#include <tuple>
#include <utility>
#include <vector>

namespace bdata = boost::unit_test::data;
using namespace Acts::UnitLiterals;
Expand Down
1 change: 0 additions & 1 deletion Tests/UnitTests/Core/Utilities/BFieldMapUtilsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <array>
#include <cstddef>
#include <random>
#include <utility>
#include <vector>

namespace bdata = boost::unit_test::data;
Expand Down

0 comments on commit 9a2b74d

Please sign in to comment.