diff --git a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/IndexSourceLink.h b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/IndexSourceLink.h index 2e6a2a7885be8c3aa8c3ee884ffdc9968360e298..68097833c8943ec9b1ff3026819ba584760adb3a 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/IndexSourceLink.h +++ b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/IndexSourceLink.h @@ -9,9 +9,13 @@ #pragma once #include "Acts/Geometry/GeometryIdentifier.hpp" +#include "Acts/Geometry/TrackingGeometry.hpp" +#include "Acts/EventData/SourceLink.hpp" +#include "Acts/Surfaces/Surface.hpp" #include <cassert> +//toberemoved #include <boost/container/flat_map.hpp> #include "FaserActsGeometryContainers.h" @@ -58,9 +62,19 @@ public: /// Access the Tracker::FaserSCT_Cluster hit constexpr const Tracker::FaserSCT_Cluster* hit() const { return m_hit; } + struct SurfaceAccessor { + const Acts::TrackingGeometry& trackingGeometry; + + const Acts::Surface* operator()(const Acts::SourceLink& sourceLink) const { + const auto& indexSourceLink = sourceLink.get<IndexSourceLink>(); + return trackingGeometry.findSurface(indexSourceLink.geometryId()); + } + }; + + private: Acts::GeometryIdentifier m_geometryId; - Index m_index; + Index m_index = 0; const Tracker::FaserSCT_Cluster* m_hit; friend constexpr bool operator==(const IndexSourceLink& lhs, diff --git a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/Measurement.h b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/Measurement.h index 3defe818047153794f33d86af76cb2592e882797..5b6ed7e15cbf00ec52b313b9fbb821030a486a73 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/Measurement.h +++ b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/Measurement.h @@ -9,45 +9,89 @@ #pragma once #include "Acts/EventData/Measurement.hpp" +#include "Acts/Geometry/GeometryContext.hpp" +#include "Acts/Utilities/CalibrationContext.hpp" +#include "Acts/EventData/MultiTrajectory.hpp" +#include "Acts/EventData/SourceLink.hpp" +#include "Acts/EventData/VectorMultiTrajectory.hpp" + #include "FaserActsKalmanFilter/IndexSourceLink.h" #include <cassert> #include <vector> +#include <variant> /// Variable measurement type that can contain all possible combinations. -using Measurement = Acts::BoundVariantMeasurement<IndexSourceLink>; +using Measurement = Acts::BoundVariantMeasurement; /// Container of measurements. /// /// In contrast to the source links, the measurements themself must not be /// orderable. The source links stored in the measurements are treated /// as opaque here and no ordering is enforced on the stored measurements. using MeasurementContainer = std::vector<Measurement>; +//@todo: just for testing for now. Use SCT_clusters for it +using ClusterContainer = std::vector<Measurement>; /// Calibrator to convert an index source link to a measurement. class MeasurementCalibrator { public: /// Construct an invalid calibrator. Required to allow copying. MeasurementCalibrator() = default; - /// Construct using a user-provided container to chose measurements from. - MeasurementCalibrator(const MeasurementContainer& measurements) - : m_measurements(&measurements) {} /// Find the measurement corresponding to the source link. /// - /// @tparam parameters_t Track parameters type + /// @param measurements The measurements container + /// @param clusters The clusters container + /// @param gctx The geometry context + /// @param cctx The calbiration context /// @param sourceLink Input source link - /// @param parameters Input track parameters (unused) - template <typename parameters_t> - const Measurement& operator()(const IndexSourceLink& sourceLink, - const parameters_t& ) const { - assert(m_measurements and - "Undefined measurement container in DigitizedCalibrator"); - assert((sourceLink.index() < m_measurements->size()) and + /// @param trackState The track state to calibrate + void calibrate( + const MeasurementContainer& measurements, + const ClusterContainer* /*clusters*/, + const Acts::GeometryContext& /*gctx*/, + const Acts::CalibrationContext& /*cctx*/, + const Acts::SourceLink& sourceLink, + Acts::VectorMultiTrajectory::TrackStateProxy& trackState) const { + + trackState.setUncalibratedSourceLink(sourceLink); + + const IndexSourceLink& idxSourceLink = sourceLink.get<IndexSourceLink>(); + assert((idxSourceLink.index() < measurements.size()) and "Source link index is outside the container bounds"); - return (*m_measurements)[sourceLink.index()]; + + std::visit( + [&trackState](const auto& meas) { + trackState.allocateCalibrated(meas.size()); + trackState.setCalibrated(meas); + }, + (measurements)[idxSourceLink.index()]); } -private: - // use pointer so the calibrator is copyable and default constructible. - const MeasurementContainer* m_measurements = nullptr; }; + +// Adapter class that wraps a MeasurementCalibrator to conform to the +// core ACTS calibration interface +class MeasurementCalibratorAdapter { + public: + MeasurementCalibratorAdapter(const MeasurementCalibrator& calibrator, + const MeasurementContainer& measurements, + const ClusterContainer* clusters = nullptr) + : m_calibrator{calibrator}, m_measurements{measurements}, m_clusters{clusters} {} + + MeasurementCalibratorAdapter() = delete; + + void calibrate(const Acts::GeometryContext& gctx, + const Acts::CalibrationContext& cctx, + const Acts::SourceLink& sourceLink, + Acts::VectorMultiTrajectory::TrackStateProxy trackState) const { + return m_calibrator.calibrate(m_measurements, m_clusters, gctx, cctx, + sourceLink, trackState); + } + + private: + const MeasurementCalibrator& m_calibrator; + const MeasurementContainer& m_measurements; + const ClusterContainer* m_clusters; +}; +