Skip to content
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

chore: SonarCloud fixes, part 0 #3942

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Alignment/include/ActsAlignment/Kernel/Alignment.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ void ActsAlignment::Alignment<fitter_t>::calculateAlignmentParameters(
alignResult.measurementDim += alignState.measurementDim;
sumChi2ONdf += alignState.chi2 / alignState.measurementDim;
}
alignResult.averageChi2ONdf = sumChi2ONdf / alignResult.numTracks;
alignResult.averageChi2ONdf =
sumChi2ONdf / static_cast<double>(alignResult.numTracks);

// Get the inverse of chi2 second derivative matrix (we need this to
// calculate the covariance of the alignment parameters)
Expand Down
4 changes: 2 additions & 2 deletions Core/include/Acts/Definitions/Units.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,10 @@ constexpr double mol = 1.0;
namespace UnitLiterals {
// define user literal functions for the given unit constant
#define ACTS_DEFINE_UNIT_LITERAL(name) \
constexpr double operator"" _##name(long double x) { \
inline consteval double operator"" _##name(long double x) { \
return ::Acts::UnitConstants::name * x; \
} \
constexpr double operator"" _##name(unsigned long long x) { \
inline consteval double operator"" _##name(unsigned long long x) { \
return ::Acts::UnitConstants::name * x; \
}
ACTS_DEFINE_UNIT_LITERAL(fm)
Expand Down
3 changes: 2 additions & 1 deletion Core/include/Acts/Geometry/TrapezoidVolumeBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ class TrapezoidVolumeBounds : public VolumeBounds {
/// Constructor - from a fixed size array
///
/// @param values The bound values
TrapezoidVolumeBounds(const std::array<double, eSize>& values) noexcept(false)
explicit TrapezoidVolumeBounds(
const std::array<double, eSize>& values) noexcept(false)
: m_values(values) {
checkConsistency();
buildSurfaceBounds();
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/MagneticField/ConstantBField.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ConstantBField final : public MagneticFieldProvider {
public:
struct Cache {
/// @brief constructor with context
Cache(const MagneticFieldContext& /*mcfg*/) {}
explicit Cache(const MagneticFieldContext& /*mcfg*/) {}
};

/// Construct constant magnetic field from field vector.
Expand Down
5 changes: 3 additions & 2 deletions Core/include/Acts/MagneticField/InterpolatedBFieldMap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class InterpolatedBFieldMap : public InterpolatedMagneticField {

struct Cache {
/// @brief Constructor with magnetic field context
Cache(const MagneticFieldContext& /*mctx*/) {}
explicit Cache(const MagneticFieldContext& /*mctx*/) {}

std::optional<FieldCell> fieldCell;
bool initialized = false;
Expand Down Expand Up @@ -175,7 +175,8 @@ class InterpolatedBFieldMap : public InterpolatedMagneticField {

/// @brief default constructor
///
InterpolatedBFieldMap(Config cfg) : m_cfg{std::move(cfg)} {
/// @param cfg the configuration struct
explicit InterpolatedBFieldMap(Config cfg) : m_cfg{std::move(cfg)} {
typename Grid::index_t minBin{};
minBin.fill(1);
m_lowerLeft = m_cfg.grid.lowerLeftBinEdge(minBin);
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/MagneticField/NullBField.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class NullBField final : public MagneticFieldProvider {
public:
struct Cache {
/// @brief constructor with context
Cache(const MagneticFieldContext& /*mcfg*/) {}
explicit Cache(const MagneticFieldContext& /*mcfg*/) {}
};

/// @brief Default constructor
Expand Down
4 changes: 2 additions & 2 deletions Core/include/Acts/MagneticField/SolenoidBField.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class SolenoidBField final : public MagneticFieldProvider {
public:
struct Cache {
/// @brief Constructor with magnetic field context
Cache(const MagneticFieldContext& /*mctx*/) {}
explicit Cache(const MagneticFieldContext& /*mctx*/) {}
};

/// Config struct for the SolenoidBfield.
Expand All @@ -91,7 +91,7 @@ class SolenoidBField final : public MagneticFieldProvider {
/// @brief the constructor with a shared pointer
/// @note since it is a shared field, we enforce it to be const
/// @tparam bField is the shared BField to be stored
SolenoidBField(Config config);
explicit SolenoidBField(Config config);

/// @brief Retrieve magnetic field value in local (r,z) coordinates
///
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Material/AccumulatedSurfaceMaterial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class AccumulatedSurfaceMaterial {
/// Default Constructor - for homogeneous material
///
/// @param splitFactor is the pre/post splitting directive
AccumulatedSurfaceMaterial(double splitFactor = 0.);
explicit AccumulatedSurfaceMaterial(double splitFactor = 0.);

/// Explicit constructor with only full MaterialSlab,
/// for one-dimensional binning.
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Material/HomogeneousVolumeMaterial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class HomogeneousVolumeMaterial : public IVolumeMaterial {
/// Explicit constructor
///
/// @param material is the material held by this
HomogeneousVolumeMaterial(const Material& material);
explicit HomogeneousVolumeMaterial(const Material& material);

/// Copy Constructor
///
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Material/ISurfaceMaterial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ISurfaceMaterial {
/// Constructor
///
/// @param splitFactor is the splitting ratio between pre/post update
ISurfaceMaterial(double splitFactor) : m_splitFactor(splitFactor) {}
explicit ISurfaceMaterial(double splitFactor) : m_splitFactor(splitFactor) {}

/// Constructor
///
Expand Down
3 changes: 2 additions & 1 deletion Core/include/Acts/Surfaces/AnnulusBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ class AnnulusBounds : public DiscBounds {
/// Constructor - from parameters array
///
/// @param values The parameter array
AnnulusBounds(const std::array<double, eSize>& values) noexcept(false);
explicit AnnulusBounds(const std::array<double, eSize>& values) noexcept(
false);

AnnulusBounds(const AnnulusBounds& source) = default;

Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Surfaces/ConeBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class ConeBounds : public SurfaceBounds {
/// Constructor - from parameters array
///
/// @param values The parameter array
ConeBounds(const std::array<double, eSize>& values) noexcept(false);
explicit ConeBounds(const std::array<double, eSize>& values) noexcept(false);

~ConeBounds() override = default;

Expand Down
7 changes: 4 additions & 3 deletions Core/include/Acts/Surfaces/ConvexPolygonBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,18 @@ class ConvexPolygonBounds : public ConvexPolygonBoundsBase {
/// This will throw if the vector size does not match `num_vertices`.
/// This will throw if the vertices do not form a convex polygon.
/// @param vertices The list of vertices.
ConvexPolygonBounds(const std::vector<Vector2>& vertices) noexcept(false);
explicit ConvexPolygonBounds(const std::vector<Vector2>& vertices) noexcept(
false);

/// Constructor from a fixed size array of vertices.
/// This will throw if the vertices do not form a convex polygon.
/// @param vertices The vertices
ConvexPolygonBounds(const vertex_array& vertices) noexcept(false);
explicit ConvexPolygonBounds(const vertex_array& vertices) noexcept(false);

/// Constructor from a fixed size array of parameters
/// This will throw if the vertices do not form a convex polygon.
/// @param values The values to build up the vertices
ConvexPolygonBounds(const value_array& values) noexcept(false);
explicit ConvexPolygonBounds(const value_array& values) noexcept(false);

~ConvexPolygonBounds() override = default;

Expand Down
3 changes: 2 additions & 1 deletion Core/include/Acts/Surfaces/CylinderBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ class CylinderBounds : public SurfaceBounds {
/// Constructor - from fixed size array
///
/// @param values The parameter values
CylinderBounds(const std::array<double, eSize>& values) noexcept(false)
explicit CylinderBounds(const std::array<double, eSize>& values) noexcept(
false)
: m_values(values),
m_closed(std::abs(values[eHalfPhiSector] - std::numbers::pi) <
s_epsilon) {
Expand Down
3 changes: 2 additions & 1 deletion Core/include/Acts/Surfaces/DiamondBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class DiamondBounds : public PlanarBounds {
/// Constructor - from fixed size array
///
/// @param values The parameter values
DiamondBounds(const std::array<double, eSize>& values) noexcept(false)
explicit DiamondBounds(const std::array<double, eSize>& values) noexcept(
false)
: m_values(values),
m_boundingBox(
Vector2{-(*std::max_element(values.begin(), values.begin() + 2)),
Expand Down
3 changes: 2 additions & 1 deletion Core/include/Acts/Surfaces/DiscTrapezoidBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ class DiscTrapezoidBounds : public DiscBounds {
/// Constructor - from fixed size array
///
/// @param values The parameter values
DiscTrapezoidBounds(const std::array<double, eSize>& values) noexcept(false)
explicit DiscTrapezoidBounds(
const std::array<double, eSize>& values) noexcept(false)
: m_values(values) {
checkConsistency();
}
Expand Down
3 changes: 2 additions & 1 deletion Core/include/Acts/Surfaces/EllipseBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ class EllipseBounds : public PlanarBounds {
/// Constructor - from fixed size array
///
/// @param values The parameter values
EllipseBounds(const std::array<double, eSize>& values) noexcept(false)
explicit EllipseBounds(const std::array<double, eSize>& values) noexcept(
false)
: m_values(values), m_boundingBox(values[eInnerRy], values[eOuterRy]) {
checkConsistency();
}
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Surfaces/LineBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class LineBounds : public SurfaceBounds {
/// Constructor - from fixed size array
///
/// @param values The parameter values
LineBounds(const std::array<double, eSize>& values) noexcept(false)
explicit LineBounds(const std::array<double, eSize>& values) noexcept(false)
: m_values(values) {
checkConsistency();
}
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Surfaces/RadialBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class RadialBounds : public DiscBounds {
/// Constructor from array values
///
/// @param values The bound values
RadialBounds(const std::array<double, eSize>& values) noexcept(false)
explicit RadialBounds(const std::array<double, eSize>& values) noexcept(false)
: m_values(values) {
checkConsistency();
}
Expand Down
19 changes: 10 additions & 9 deletions Core/include/Acts/Surfaces/RectangleBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,6 @@ class RectangleBounds : public PlanarBounds {
checkConsistency();
}

/// Constructor - from fixed size array - generic
///
/// @param values The parameter values
RectangleBounds(const std::array<double, eSize>& values) noexcept(false)
: m_min({values[eMinX], values[eMinY]}),
m_max({values[eMaxX], values[eMaxY]}) {
checkConsistency();
}

/// Constructor - from min/max - generic
///
/// @param min The left bottom corner
Expand All @@ -68,6 +59,16 @@ class RectangleBounds : public PlanarBounds {
checkConsistency();
}

/// Constructor - from fixed size array - generic
///
/// @param values The parameter values
explicit RectangleBounds(const std::array<double, eSize>& values) noexcept(
false)
: m_min({values[eMinX], values[eMinY]}),
m_max({values[eMaxX], values[eMaxY]}) {
checkConsistency();
}

~RectangleBounds() override = default;

BoundsType type() const final;
Expand Down
7 changes: 4 additions & 3 deletions Core/include/Acts/Surfaces/SurfaceArray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,13 @@ class SurfaceArray {
struct SingleElementLookup : ISurfaceGridLookup {
/// @brief Default constructor.
/// @param element the one and only element.
SingleElementLookup(SurfaceVector::value_type element)
explicit SingleElementLookup(SurfaceVector::value_type element)
: m_element({element}) {}

/// @brief Default constructor.
/// @param elements the surfaces that are provided through a single lookup
SingleElementLookup(const SurfaceVector& elements) : m_element(elements) {}
explicit SingleElementLookup(const SurfaceVector& elements)
: m_element(elements) {}

/// @brief Lookup, always returns @c element
/// @return reference to vector containing only @c element
Expand Down Expand Up @@ -442,7 +443,7 @@ class SurfaceArray {

/// @brief Constructor with a single surface
/// @param srf The one and only surface
SurfaceArray(std::shared_ptr<const Surface> srf);
explicit SurfaceArray(std::shared_ptr<const Surface> srf);

/// @brief Get all surfaces in bin given by position.
/// @param position the lookup position
Expand Down
3 changes: 2 additions & 1 deletion Core/include/Acts/Utilities/Axis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class NeighborHoodIndices {
iterator() = default;

// Specialized constructor for end() iterator
iterator(std::size_t current) : m_current(current), m_wrapped(true) {}
explicit iterator(std::size_t current)
: m_current(current), m_wrapped(true) {}

iterator(std::size_t begin1, std::size_t end1, std::size_t begin2)
: m_current(begin1),
Expand Down
13 changes: 7 additions & 6 deletions Core/include/Acts/Utilities/Grid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,38 +98,39 @@ class Grid final : public IGrid {
/// grid object.
///
/// @param axes
Grid(const std::tuple<Axes...>& axes) : m_axes(axes) {
explicit Grid(const std::tuple<Axes...>& axes) : m_axes(axes) {
m_values.resize(size());
}

/// @brief Move constructor from axis tuple
/// @param axes
Grid(std::tuple<Axes...>&& axes) : m_axes(std::move(axes)) {
explicit Grid(std::tuple<Axes...>&& axes) : m_axes(std::move(axes)) {
m_values.resize(size());
}

/// @brief constructor from parameters pack of axes
/// @param axes
Grid(Axes&&... axes) : m_axes(std::forward_as_tuple(axes...)) {
explicit Grid(Axes&&... axes) : m_axes(std::forward_as_tuple(axes...)) {
m_values.resize(size());
}

/// @brief constructor from parameters pack of axes
/// @param axes
Grid(const Axes&... axes) : m_axes(std::tuple(axes...)) {
explicit Grid(const Axes&... axes) : m_axes(std::tuple(axes...)) {
m_values.resize(size());
}

/// @brief constructor from parameters pack of axes and type tag
/// @param axes
Grid(TypeTag<T> /*tag*/, Axes&&... axes)
explicit Grid(TypeTag<T> /*tag*/, Axes&&... axes)
: m_axes(std::forward_as_tuple(axes...)) {
m_values.resize(size());
}

/// @brief constructor from parameters pack of axes and type tag
/// @param axes
Grid(TypeTag<T> /*tag*/, const Axes&... axes) : m_axes(std::tuple(axes...)) {
explicit Grid(TypeTag<T> /*tag*/, const Axes&... axes)
: m_axes(std::tuple(axes...)) {
m_values.resize(size());
}

Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Utilities/KDTree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class KDTree {
///
/// @param d The vector of position-value pairs to construct the k-d tree
/// from.
KDTree(vector_t &&d) : m_elems(d) {
explicit KDTree(vector_t &&d) : m_elems(d) {
// To start out, we need to check whether we need to construct a leaf node
// or an internal node. We create a leaf only if we have at most as many
// elements as the number of elements that can fit into a leaf node.
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Utilities/RangeXD.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class RangeXD {
/// @brief Construct a range from a pair of minimum and maximum values
/// @note Only available for one-dimensional ranges
/// @param p The pair of minimum and maximum values
RangeXD(const std::pair<Type, Type>& p)
explicit RangeXD(const std::pair<Type, Type>& p)
requires(Dims == 1)
: m_minima({p.first}), m_maxima({p.second}) {}

Expand Down
4 changes: 2 additions & 2 deletions Examples/Algorithms/Fatras/src/FatrasSimulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ ActsExamples::ProcessCode ActsExamples::FatrasSimulation::execute(
std::vector<ActsFatras::Particle> particlesInput;
particlesInput.reserve(inputParticles.size());
for (const auto &p : inputParticles) {
particlesInput.push_back(p.initial());
particlesInput.push_back(p.initialState());
}

// prepare output containers
Expand Down Expand Up @@ -302,7 +302,7 @@ ActsExamples::ProcessCode ActsExamples::FatrasSimulation::execute(

if (auto it = particlesFinal.find(particleInitial.particleId());
it != particlesFinal.end()) {
particleSimulated.final() = *it;
particleSimulated.finalState() = *it;
} else {
ACTS_ERROR("particle " << particleInitial.particleId()
<< " has no final state");
Expand Down
2 changes: 1 addition & 1 deletion Examples/Algorithms/Geant4/src/ParticleTrackingAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void ParticleTrackingAction::PostUserTrackingAction(const G4Track* aTrack) {
return;
}
SimParticle particle = *particleIt;
particle.final() = convert(*aTrack, barcode);
particle.finalState() = convert(*aTrack, barcode);

auto [it, success] = eventStore().particlesSimulated.insert(particle);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ ProcessCode EventGenerator::read(const AlgorithmContext& ctx) {
ACTS_VERBOSE(" - particle at " << pos4.transpose());
// `withParticleId` returns a copy because it changes the identity
particle = particle.withParticleId(pid);
particle.initial().setPosition4(pos4);
particle.final().setPosition4(pos4);
particle.initialState().setPosition4(pos4);
particle.finalState().setPosition4(pos4);
};
for (auto& vertexParticle : newParticles) {
updateParticleInPlace(vertexParticle);
Expand Down
2 changes: 1 addition & 1 deletion Examples/Algorithms/HepMC/src/HepMCProcessExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void setPassedMaterial(const HepMC3::ConstGenVertexPtr& vertex, const int id,
currentVertex = currentParticle->production_vertex();
}
// Assign the passed material to the particle
particle.final().setMaterialPassed(x0, l0);
particle.finalState().setMaterialPassed(x0, l0);
}

/// @brief This function collects outgoing particles from a vertex while keeping
Expand Down
Loading
Loading