Skip to content

Commit

Permalink
feat: Angles of incidence in neural calibrator (#2494)
Browse files Browse the repository at this point in the history
As stated in #2493, angles of incidence are more useful than global frame direction for calibration purposes, so in the PR we add feed these to the neural calibrator instead.

depends on #2493
  • Loading branch information
gagnonlg committed Oct 19, 2023
1 parent fd80ca7 commit 5035479
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions Examples/Framework/ML/src/NeuralCalibrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "Acts/EventData/SourceLink.hpp"
#include "Acts/Utilities/CalibrationContext.hpp"
#include "Acts/Utilities/UnitVectors.hpp"
#include <ActsExamples/EventData/NeuralCalibrator.hpp>

#include <TFile.h>
Expand Down Expand Up @@ -96,8 +97,8 @@ void ActsExamples::NeuralCalibrator::calibrate(

input[iInput++] = idxSourceLink.geometryId().volume();
input[iInput++] = idxSourceLink.geometryId().layer();
input[iInput++] = trackState.parameters()[Acts::eBoundPhi];
input[iInput++] = trackState.parameters()[Acts::eBoundTheta];

const Acts::Surface& referenceSurface = trackState.referenceSurface();

std::visit(
[&](const auto& measurement) {
Expand All @@ -107,6 +108,24 @@ void ActsExamples::NeuralCalibrator::calibrate(
Acts::ActsSquareMatrix<Acts::eBoundSize> fcov =
E * measurement.covariance() * E.transpose();

Acts::Vector3 dir = Acts::makeDirectionFromPhiTheta(
fpar[Acts::eBoundPhi], fpar[Acts::eBoundTheta]);
Acts::Vector3 globalPosition = referenceSurface.localToGlobal(
gctx, fpar.segment<2>(Acts::eBoundLoc0), dir);

// Rotation matrix. When applied to global coordinates, they
// are rotated into the local reference frame of the
// surface. Note that this such a rotation can be found by
// inverting a matrix whose columns correspond to the
// coordinate axes of the local coordinate system.
Acts::RotationMatrix3 rot =
referenceSurface.referenceFrame(gctx, globalPosition, dir)
.inverse();
std::pair<double, double> angles =
Acts::VectorHelpers::incidentAngles(dir, rot);

input[iInput++] = angles.first;
input[iInput++] = angles.second;
input[iInput++] = fpar[Acts::eBoundLoc0];
input[iInput++] = fpar[Acts::eBoundLoc1];
input[iInput++] = fcov(Acts::eBoundLoc0, Acts::eBoundLoc0);
Expand Down

0 comments on commit 5035479

Please sign in to comment.