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: fix more sonarcloud issues #4017

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
89 changes: 46 additions & 43 deletions Alignment/include/ActsAlignment/Kernel/detail/AlignmentEngine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

namespace ActsAlignment::detail {

using namespace Acts;
///
///@brief struct to store info needed for track-based alignment
///
Expand All @@ -36,35 +35,35 @@ struct TrackAlignmentState {
std::size_t alignmentDof = 0;

// The measurements covariance
ActsDynamicMatrix measurementCovariance;
Acts::ActsDynamicMatrix measurementCovariance;

// The track parameters covariance
ActsDynamicMatrix trackParametersCovariance;
Acts::ActsDynamicMatrix trackParametersCovariance;

// The projection matrix
ActsDynamicMatrix projectionMatrix;
Acts::ActsDynamicMatrix projectionMatrix;

// The residual
ActsDynamicVector residual;
Acts::ActsDynamicVector residual;

// The covariance of residual
ActsDynamicMatrix residualCovariance;
Acts::ActsDynamicMatrix residualCovariance;

// The chi2
double chi2 = 0;

// The derivative of residual w.r.t. alignment parameters
ActsDynamicMatrix alignmentToResidualDerivative;
Acts::ActsDynamicMatrix alignmentToResidualDerivative;

// The derivative of chi2 w.r.t. alignment parameters
ActsDynamicVector alignmentToChi2Derivative;
Acts::ActsDynamicVector alignmentToChi2Derivative;

// The second derivative of chi2 w.r.t. alignment parameters
ActsDynamicMatrix alignmentToChi2SecondDerivative;
Acts::ActsDynamicMatrix alignmentToChi2SecondDerivative;

// The alignable surfaces on the track and their indices in both the global
// alignable surfaces pool and those relevant with this track
std::unordered_map<const Surface*, std::pair<std::size_t, std::size_t>>
std::unordered_map<const Acts::Surface*, std::pair<std::size_t, std::size_t>>
alignedSurfaces;
};

Expand Down Expand Up @@ -101,14 +100,15 @@ void resetAlignmentDerivative(Acts::AlignmentToBoundMatrix& alignToBound,
///
/// @return The track alignment state containing fundamental alignment
/// ingredients
template <typename traj_t, typename parameters_t = BoundTrackParameters>
template <typename traj_t, typename parameters_t = Acts::BoundTrackParameters>
TrackAlignmentState trackAlignmentState(
const GeometryContext& gctx, const traj_t& multiTraj,
const Acts::GeometryContext& gctx, const traj_t& multiTraj,
const std::size_t& entryIndex,
const std::pair<ActsDynamicMatrix,
const std::pair<Acts::ActsDynamicMatrix,
std::unordered_map<std::size_t, std::size_t>>&
globalTrackParamsCov,
const std::unordered_map<const Surface*, std::size_t>& idxedAlignSurfaces,
const std::unordered_map<const Acts::Surface*, std::size_t>&
idxedAlignSurfaces,
const AlignmentMask& alignMask) {
using CovMatrix = typename parameters_t::CovarianceMatrix;

Expand Down Expand Up @@ -136,7 +136,7 @@ TrackAlignmentState trackAlignmentState(

// Only measurement states matter (we can't align non-measurement states,
// no?)
if (!ts.typeFlags().test(TrackStateFlag::MeasurementFlag)) {
if (!ts.typeFlags().test(Acts::TrackStateFlag::MeasurementFlag)) {
return true;
}
// Check if the reference surface is to be aligned
Expand All @@ -163,26 +163,27 @@ TrackAlignmentState trackAlignmentState(
}

// The alignment degree of freedom
alignState.alignmentDof = eAlignmentSize * nAlignSurfaces;
alignState.alignmentDof = Acts::eAlignmentSize * nAlignSurfaces;
// Dimension of global track parameters (from only measurement states)
alignState.trackParametersDim = eBoundSize * measurementStates.size();
alignState.trackParametersDim = Acts::eBoundSize * measurementStates.size();

// Initialize the alignment matrices with components from the measurement
// states
// The measurement covariance
alignState.measurementCovariance = ActsDynamicMatrix::Zero(
alignState.measurementCovariance = Acts::ActsDynamicMatrix::Zero(
alignState.measurementDim, alignState.measurementDim);
// The bound parameters to measurement projection matrix
alignState.projectionMatrix = ActsDynamicMatrix::Zero(
alignState.projectionMatrix = Acts::ActsDynamicMatrix::Zero(
alignState.measurementDim, alignState.trackParametersDim);
// The derivative of residual w.r.t. alignment parameters
alignState.alignmentToResidualDerivative = ActsDynamicMatrix::Zero(
alignState.alignmentToResidualDerivative = Acts::ActsDynamicMatrix::Zero(
alignState.measurementDim, alignState.alignmentDof);
// The track parameters covariance
alignState.trackParametersCovariance = ActsDynamicMatrix::Zero(
alignState.trackParametersCovariance = Acts::ActsDynamicMatrix::Zero(
alignState.trackParametersDim, alignState.trackParametersDim);
// The residual
alignState.residual = ActsDynamicVector::Zero(alignState.measurementDim);
alignState.residual =
Acts::ActsDynamicVector::Zero(alignState.measurementDim);

// Unpack global track parameters covariance and the starting row/column for
// all smoothed states.
Expand All @@ -200,19 +201,19 @@ TrackAlignmentState trackAlignmentState(
const std::size_t measdim = state.calibratedSize();
// Update index of current measurement and parameter
iMeasurement -= measdim;
iParams -= eBoundSize;
iParams -= Acts::eBoundSize;
// (a) Get and fill the measurement covariance matrix
const ActsDynamicMatrix measCovariance =
const Acts::ActsDynamicMatrix measCovariance =
state.effectiveCalibratedCovariance();
alignState.measurementCovariance.block(iMeasurement, iMeasurement, measdim,
measdim) = measCovariance;

// (b) Get and fill the bound parameters to measurement projection matrix
const ActsDynamicMatrix H =
const Acts::ActsDynamicMatrix H =
state.projectorSubspaceHelper().fullProjector().topLeftCorner(
measdim, eBoundSize);
measdim, Acts::eBoundSize);
alignState.projectionMatrix.block(iMeasurement, iParams, measdim,
eBoundSize) = H;
Acts::eBoundSize) = H;
// (c) Get and fill the residual
alignState.residual.segment(iMeasurement, measdim) =
state.effectiveCalibrated() - H * state.smoothed();
Expand All @@ -224,30 +225,31 @@ TrackAlignmentState trackAlignmentState(
const auto surface = &state.referenceSurface();
alignState.alignedSurfaces.at(surface).second = iSurface;
// The free parameters transformed from the smoothed parameters
const FreeVector freeParams =
const Acts::FreeVector freeParams =
Acts::MultiTrajectoryHelpers::freeSmoothed(gctx, state);
// The position
const Vector3 position = freeParams.segment<3>(eFreePos0);
const Acts::Vector3 position = freeParams.segment<3>(Acts::eFreePos0);
// The direction
const Vector3 direction = freeParams.segment<3>(eFreeDir0);
const Acts::Vector3 direction = freeParams.segment<3>(Acts::eFreeDir0);
// The derivative of free parameters w.r.t. path length. @note Here, we
// assume a linear track model, i.e. neglecting the change of track
// direction. Otherwise, we need to know the magnetic field at the free
// parameters
FreeVector pathDerivative = FreeVector::Zero();
Acts::FreeVector pathDerivative = Acts::FreeVector::Zero();
pathDerivative.head<3>() = direction;
// Get the derivative of bound parameters w.r.t. alignment parameters
AlignmentToBoundMatrix alignToBound = surface->alignmentToBoundDerivative(
gctx, position, direction, pathDerivative);
Acts::AlignmentToBoundMatrix alignToBound =
surface->alignmentToBoundDerivative(gctx, position, direction,
pathDerivative);
// Set the degree of freedom per surface.
// @Todo: don't allocate memory for fixed degree of freedom and consider surface/layer/volume wise align mask (instead of using global mask as now)
resetAlignmentDerivative(alignToBound, alignMask);

// Residual is calculated as the (measurement - parameters), thus we need
// a minus sign below
alignState.alignmentToResidualDerivative.block(
iMeasurement, iSurface * eAlignmentSize, measdim, eAlignmentSize) =
-H * (alignToBound);
iMeasurement, iSurface * Acts::eAlignmentSize, measdim,
Acts::eAlignmentSize) = -H * (alignToBound);
}

// (e) Extract and fill the track parameters covariance matrix for only
Expand All @@ -258,14 +260,15 @@ TrackAlignmentState trackAlignmentState(
std::size_t colStateIndex = measurementStates.at(iColState).first;
// Retrieve the block from the source covariance matrix
CovMatrix correlation =
sourceTrackParamsCov.block<eBoundSize, eBoundSize>(
sourceTrackParamsCov.block<Acts::eBoundSize, Acts::eBoundSize>(
stateRowIndices.at(rowStateIndex),
stateRowIndices.at(colStateIndex));
// Fill the block of the target covariance matrix
std::size_t iCol =
alignState.trackParametersDim - (iColState + 1) * eBoundSize;
alignState.trackParametersCovariance.block<eBoundSize, eBoundSize>(
iParams, iCol) = correlation;
alignState.trackParametersDim - (iColState + 1) * Acts::eBoundSize;
alignState.trackParametersCovariance
.block<Acts::eBoundSize, Acts::eBoundSize>(iParams, iCol) =
correlation;
}
}

Expand All @@ -274,11 +277,11 @@ TrackAlignmentState trackAlignmentState(
alignState.measurementCovariance.inverse() *
alignState.residual;
alignState.alignmentToChi2Derivative =
ActsDynamicVector::Zero(alignState.alignmentDof);
alignState.alignmentToChi2SecondDerivative =
ActsDynamicMatrix::Zero(alignState.alignmentDof, alignState.alignmentDof);
Acts::ActsDynamicVector::Zero(alignState.alignmentDof);
alignState.alignmentToChi2SecondDerivative = Acts::ActsDynamicMatrix::Zero(
alignState.alignmentDof, alignState.alignmentDof);
// The covariance of residual
alignState.residualCovariance = ActsDynamicMatrix::Zero(
alignState.residualCovariance = Acts::ActsDynamicMatrix::Zero(
alignState.measurementDim, alignState.measurementDim);
alignState.residualCovariance = alignState.measurementCovariance -
alignState.projectionMatrix *
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Detector/DetectorVolume.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class DetectorVolume : public std::enable_shared_from_this<DetectorVolume> {
/// Store constructor
///
/// @param objects are the ones copied into the internal store
ObjectStore(std::vector<internal_type> objects)
explicit ObjectStore(std::vector<internal_type> objects)
: internal(std::move(objects)) {
external = unpack_shared_const_vector(internal);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class IndexedRootVolumeFinderBuilder final : public IRootVolumeFinderBuilder {
public:
/// @brief Constructor with binning casts
/// @param binning the cast values for the grid binning
IndexedRootVolumeFinderBuilder(std::vector<Acts::BinningValue> binning);
explicit IndexedRootVolumeFinderBuilder(
std::vector<Acts::BinningValue> binning);

/// The virtual interface definition for root volume finder builders
///
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Detector/LayerStructureBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class LayerStructureBuilder : public IInternalStructureBuilder {
public:
/// Constructor with predefined surfaces
/// @param isurfaces is the vector of surfaces
SurfacesHolder(std::vector<std::shared_ptr<Surface>> isurfaces)
explicit SurfacesHolder(std::vector<std::shared_ptr<Surface>> isurfaces)
: m_surfaces(std::move(isurfaces)) {}

/// Return the surfaces from the holder
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Detector/Portal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Portal {
/// Constructor from surface w/o portal links
///
/// @param surface is the representing surface
Portal(std::shared_ptr<RegularSurface> surface);
explicit Portal(std::shared_ptr<RegularSurface> surface);

/// The vector of attached volumes forward/backward, this is useful in the
/// geometry building
Expand Down
6 changes: 3 additions & 3 deletions Core/include/Acts/EventData/GenericBoundTrackParameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ class GenericBoundTrackParameters {
/// Parameters are not default constructible due to the charge type.
GenericBoundTrackParameters() = delete;
GenericBoundTrackParameters(const GenericBoundTrackParameters&) = default;
GenericBoundTrackParameters(GenericBoundTrackParameters&&) = default;
GenericBoundTrackParameters(GenericBoundTrackParameters&&) noexcept = default;
~GenericBoundTrackParameters() = default;
GenericBoundTrackParameters& operator=(const GenericBoundTrackParameters&) =
default;
GenericBoundTrackParameters& operator=(GenericBoundTrackParameters&&) =
default;
GenericBoundTrackParameters& operator=(
GenericBoundTrackParameters&&) noexcept = default;

/// Parameters vector.
ParametersVector& parameters() { return m_params; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ class GenericCurvilinearTrackParameters
GenericCurvilinearTrackParameters() = delete;
GenericCurvilinearTrackParameters(const GenericCurvilinearTrackParameters&) =
default;
GenericCurvilinearTrackParameters(GenericCurvilinearTrackParameters&&) =
default;
GenericCurvilinearTrackParameters(
GenericCurvilinearTrackParameters&&) noexcept = default;
~GenericCurvilinearTrackParameters() = default;
GenericCurvilinearTrackParameters& operator=(
const GenericCurvilinearTrackParameters&) = default;
GenericCurvilinearTrackParameters& operator=(
GenericCurvilinearTrackParameters&&) = default;
GenericCurvilinearTrackParameters&&) noexcept = default;

using GenericBoundTrackParameters<ParticleHypothesis>::fourPosition;
using GenericBoundTrackParameters<ParticleHypothesis>::position;
Expand Down
5 changes: 3 additions & 2 deletions Core/include/Acts/EventData/GenericFreeTrackParameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,12 @@ class GenericFreeTrackParameters {
/// Parameters are not default constructible due to the charge type.
GenericFreeTrackParameters() = delete;
GenericFreeTrackParameters(const GenericFreeTrackParameters&) = default;
GenericFreeTrackParameters(GenericFreeTrackParameters&&) = default;
GenericFreeTrackParameters(GenericFreeTrackParameters&&) noexcept = default;
~GenericFreeTrackParameters() = default;
GenericFreeTrackParameters& operator=(const GenericFreeTrackParameters&) =
default;
GenericFreeTrackParameters& operator=(GenericFreeTrackParameters&&) = default;
GenericFreeTrackParameters& operator=(GenericFreeTrackParameters&&) noexcept =
default;

/// Parameters vector.
const ParametersVector& parameters() const { return m_params; }
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/EventData/MultiTrajectory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class TrackStateRange {
ProxyType operator*() { return *proxy; }
};

TrackStateRange(ProxyType _begin) : m_begin{_begin} {}
explicit TrackStateRange(ProxyType _begin) : m_begin{_begin} {}
TrackStateRange() : m_begin{std::nullopt} {}

Iterator begin() { return m_begin; }
Expand Down
4 changes: 2 additions & 2 deletions Core/include/Acts/EventData/ProxyAccessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ struct ProxyAccessorBase {

/// Create the accessor from an already-hashed string key
/// @param _key the key
constexpr ProxyAccessorBase(HashedString _key) : key{_key} {}
explicit constexpr ProxyAccessorBase(HashedString _key) : key{_key} {}

/// Create the accessor from a string key
/// @param _key the key
constexpr ProxyAccessorBase(const std::string& _key)
explicit constexpr ProxyAccessorBase(const std::string& _key)
: key{hashStringDynamic(_key)} {}

/// Access the stored key on the proxy given as an argument. Mutable version
Expand Down
4 changes: 2 additions & 2 deletions Core/include/Acts/EventData/SourceLink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class SourceLink final {

public:
SourceLink(const SourceLink& other) = default;
SourceLink(SourceLink&& other) = default;
SourceLink(SourceLink&& other) noexcept = default;
SourceLink& operator=(const SourceLink& other) = default;
SourceLink& operator=(SourceLink&& other) = default;
SourceLink& operator=(SourceLink&& other) noexcept = default;

/// Constructor from concrete source link
/// @tparam T The source link type
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/EventData/TrackStateProxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ template <typename T>
class TransitiveConstPointer {
public:
TransitiveConstPointer() = default;
TransitiveConstPointer(T* ptr) : m_ptr{ptr} {}
explicit TransitiveConstPointer(T* ptr) : m_ptr{ptr} {}

template <typename U>
TransitiveConstPointer(const TransitiveConstPointer<U>& other)
Expand Down
4 changes: 2 additions & 2 deletions Core/include/Acts/EventData/VectorMultiTrajectory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,10 +569,10 @@ class ConstVectorMultiTrajectory final
ConstVectorMultiTrajectory(const ConstVectorMultiTrajectory& other)
: VectorMultiTrajectoryBase{other} {}

ConstVectorMultiTrajectory(const VectorMultiTrajectory& other)
explicit ConstVectorMultiTrajectory(const VectorMultiTrajectory& other)
: VectorMultiTrajectoryBase{other} {}

ConstVectorMultiTrajectory(VectorMultiTrajectory&& other)
explicit ConstVectorMultiTrajectory(VectorMultiTrajectory&& other)
: VectorMultiTrajectoryBase{std::move(other)} {}

ConstVectorMultiTrajectory(ConstVectorMultiTrajectory&&) = default;
Expand Down
4 changes: 2 additions & 2 deletions Core/include/Acts/EventData/VectorTrackContainer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,13 @@ class ConstVectorTrackContainer final
ConstVectorTrackContainer() : VectorTrackContainerBase{} {}

ConstVectorTrackContainer(const ConstVectorTrackContainer& other) = default;
ConstVectorTrackContainer(const VectorTrackContainer& other)
explicit ConstVectorTrackContainer(const VectorTrackContainer& other)
: VectorTrackContainerBase{other} {
assert(checkConsistency());
}

ConstVectorTrackContainer(ConstVectorTrackContainer&&) = default;
ConstVectorTrackContainer(VectorTrackContainer&& other)
explicit ConstVectorTrackContainer(VectorTrackContainer&& other)
: VectorTrackContainerBase{std::move(other)} {
assert(checkConsistency());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct CorrectedFreeToBoundTransformer {
/// Construct from a FreeToBoundCorrection
///
/// @param freeToBoundCorrection The freeToBoundCorrection object
CorrectedFreeToBoundTransformer(
explicit CorrectedFreeToBoundTransformer(
const FreeToBoundCorrection& freeToBoundCorrection);

/// Default constructors
Expand Down
2 changes: 1 addition & 1 deletion Tests/UnitTests/Core/EventData/MultiTrajectoryTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ BOOST_AUTO_TEST_CASE(ConstCorrectness) {
}

// is this something we actually want?
ConstVectorMultiTrajectory ct = t;
ConstVectorMultiTrajectory ct(t);
BOOST_CHECK_EQUAL(ct.size(), t.size());

ConstVectorMultiTrajectory ctm{std::move(t)};
Expand Down
Loading