Skip to content

Commit

Permalink
feat: Allow copy of measurements in Examples
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwand committed Nov 27, 2024
1 parent 93d8781 commit 53c4c26
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
30 changes: 21 additions & 9 deletions Examples/Framework/include/ActsExamples/EventData/Measurement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,16 @@

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Definitions/TrackParametrization.hpp"
#include "Acts/EventData/MeasurementHelpers.hpp"
#include "Acts/EventData/SubspaceHelpers.hpp"
#include "Acts/EventData/Types.hpp"
#include "Acts/EventData/detail/ParameterTraits.hpp"
#include "Acts/EventData/detail/PrintParameters.hpp"
#include "Acts/Geometry/GeometryIdentifier.hpp"
#include "Acts/Utilities/Iterator.hpp"
#include "ActsExamples/EventData/GeometryContainers.hpp"
#include "ActsExamples/EventData/IndexSourceLink.hpp"
#include "ActsExamples/EventData/MeasurementConcept.hpp"

#include <array>
#include <compare>
#include <concepts>
#include <cstddef>
#include <iosfwd>
#include <iterator>
#include <type_traits>
#include <variant>
#include <vector>

#include <boost/container/static_vector.hpp>
Expand Down Expand Up @@ -138,6 +129,11 @@ class MeasurementContainer {
return getMeasurement<Size>(addMeasurement(Size, geometryId));
}

template <MeasurementConcept OtherDerived>
VariableProxy copyMeasurement(const OtherDerived& other);
template <MeasurementConcept OtherDerived, std::size_t Size>
FixedProxy<Size> copyMeasurement(const OtherDerived& other);

template <typename... Args>
VariableProxy emplaceMeasurement(std::uint8_t size,
Acts::GeometryIdentifier geometryId,
Expand Down Expand Up @@ -494,6 +490,22 @@ class VariableMeasurementProxy
}
};

template <MeasurementConcept OtherDerived>
MeasurementContainer::VariableProxy MeasurementContainer::copyMeasurement(
const OtherDerived& other) {
VariableProxy meas = makeMeasurement(other.size(), other.geometryId());
meas.copyFrom(other);
return meas;
}

template <MeasurementConcept OtherDerived, std::size_t Size>
MeasurementContainer::FixedProxy<Size> MeasurementContainer::copyMeasurement(
const OtherDerived& other) {
FixedProxy<Size> meas = makeMeasurement<Size>(other.geometryId());
meas.copyFrom(other);
return meas;
}

template <typename... Args>
MeasurementContainer::VariableProxy MeasurementContainer::emplaceMeasurement(
std::uint8_t size, Acts::GeometryIdentifier geometryId, Args&&... args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#pragma once

#include "Acts/EventData/SourceLink.hpp"
#include "Acts/Geometry/GeometryIdentifier.hpp"

#include <concepts>
Expand All @@ -23,4 +22,5 @@ concept MeasurementConcept = requires(const T& m) {
{ m.parameters() };
{ m.covariance() };
};

} // namespace ActsExamples

0 comments on commit 53c4c26

Please sign in to comment.