Skip to content

Commit

Permalink
try fix neural calibrator
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwand committed Aug 27, 2024
1 parent 6e8ec54 commit 6936462
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
30 changes: 16 additions & 14 deletions Examples/Framework/ML/src/NeuralCalibrator.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of the Acts project.
//
// Copyright (C) 2023 CERN for the benefit of the Acts project
// Copyright (C) 2023-2024 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down Expand Up @@ -106,7 +106,8 @@ void ActsExamples::NeuralCalibrator::calibrate(
const Acts::Surface& referenceSurface = trackState.referenceSurface();
auto trackParameters = trackState.parameters();

const auto& measurement = measurements[idxSourceLink.index()];
const ConstVariableBoundMeasurementProxy measurement =
measurements.getMeasurement(idxSourceLink.index());

assert(measurement.contains(Acts::eBoundLoc0) &&
"Measurement does not contain the required bound loc0");
Expand Down Expand Up @@ -171,21 +172,22 @@ void ActsExamples::NeuralCalibrator::calibrate(
std::size_t iLoc0 = m_nComponents + iMax * 2;
std::size_t iVar0 = 3 * m_nComponents + iMax * 2;

Measurement measurementCopy = measurement;
measurementCopy.parameters()[boundLoc0] = output[iLoc0];
measurementCopy.parameters()[boundLoc1] = output[iLoc0 + 1];
measurementCopy.covariance()(boundLoc0, boundLoc0) = output[iVar0];
measurementCopy.covariance()(boundLoc1, boundLoc1) = output[iVar0 + 1];

Acts::visit_measurement(measurement.size(), [&](auto N) -> void {
constexpr std::size_t kMeasurementSize = decltype(N)::value;

Acts::ActsVector<kMeasurementSize> calibratedParameters =
fixedMeasurement.parameters();
Acts::ActsSquareMatrix<kMeasurementSize> calibratedCovariance =
fixedMeasurement.covariance();

calibratedParameters[boundLoc0] = output[iLoc0];
calibratedParameters[boundLoc1] = output[iLoc0 + 1];
calibratedCovariance(boundLoc0, boundLoc0) = output[iVar0];
calibratedCovariance(boundLoc1, boundLoc1) = output[iVar0 + 1];

trackState.allocateCalibrated(kMeasurementSize);
trackState.calibrated<kMeasurementSize>() =
measurementCopy.parameters<kMeasurementSize>();
trackState.calibratedCovariance<kMeasurementSize>() =
measurementCopy.covariance<kMeasurementSize>();
trackState.setSubspaceIndices(
measurementCopy.subspaceIndices<kMeasurementSize>());
trackState.calibrated<kMeasurementSize>() = calibratedParameters;
trackState.calibratedCovariance<kMeasurementSize>() = calibratedCovariance;
trackState.setSubspaceIndices(fixedMeasurement.subspaceIndices());
});
}
2 changes: 1 addition & 1 deletion Examples/Framework/src/EventData/ScalingCalibrator.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of the Acts project.
//
// Copyright (C) 2023 CERN for the benefit of the Acts project
// Copyright (C) 2023-2024 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down

0 comments on commit 6936462

Please sign in to comment.