Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:20:48

0001 #include "WeightedTrack.h"
0002 
0003 double
0004 WeightedTrack::get_squared_error (
0005     double const* parameters
0006 ) {
0007     set_parameters(parameters);
0008 
0009     double error{0};
0010     for (auto const& point : *this) {
0011         Eigen::Vector3d intersection = get_intersection(point.sensor_local_to_global_transform);
0012         Eigen::Vector2d weighted_residuals = point.get_weighted_residuals(intersection);
0013         error += weighted_residuals.squaredNorm();
0014     }
0015 
0016     if (m_use_vertex) {
0017         error += m_vertex_position.transpose() * m_vertex_covariance * m_vertex_position;
0018     }
0019 
0020     return error;
0021 }
0022 
0023 Eigen::Matrix<double, 2, 3>
0024 WeightedTrack::get_projection (
0025     Eigen::Affine3d const& plane
0026 ) const {
0027     Eigen::Matrix<double, 2, 3> projection = Eigen::Matrix<double, 2, 3>::Zero();
0028     double path_length = get_path_length_of_intersection(plane);
0029     Eigen::Vector3d slope = get_slope_at_path_length(path_length);
0030 
0031     Eigen::Vector3d z = plane.rotation().col(2);
0032     for (int i = 0; i < 2; ++i) {
0033         Eigen::Vector3d alpha = plane.rotation().col(i);
0034         /// See Eqn. 31 of "Global $\Chi^{2}$ approach to the Alignment of the ATLAS Silicon Tracking Detectors"
0035         projection.row(i) = alpha - (slope.dot(alpha) / slope.dot(z)) * z;
0036     }
0037 
0038     return projection;
0039 }
0040 
0041 Eigen::Vector2d
0042 WeightedTrack::get_residual_derivative (
0043     int index,
0044     Eigen::Affine3d const& plane
0045 ) const {
0046     double path_length = get_path_length_of_intersection(plane);
0047     return get_projection(plane) * get_partial_derivative(index, path_length);
0048 }
0049 
0050 Eigen::Vector2d
0051 ClusterFitPoint::get_residuals (
0052     Eigen::Vector3d const& intersection 
0053 ) const {
0054     Eigen::Vector3d displacement = intersection - cluster_position; // Defines the sign of the residual
0055     return Eigen::Vector2d {
0056         sensor_local_to_global_transform.rotation().col(0).dot(displacement),
0057         sensor_local_to_global_transform.rotation().col(1).dot(displacement),
0058     };
0059 }
0060 
0061 Eigen::Vector2d
0062 ClusterFitPoint::get_weighted_residuals (
0063     Eigen::Vector3d const& intersection 
0064 ) const {
0065     Eigen::Vector2d residuals = get_residuals(intersection);
0066     residuals(0) /= cluster_errors(0);
0067     residuals(1) /= cluster_errors(1);
0068     return residuals;
0069 }