File indexing completed on 2025-12-16 09:20:35
0001 #ifndef TRACKBASE_TRACKFITUTILS_H
0002 #define TRACKBASE_TRACKFITUTILS_H
0003
0004 #include "ActsSurfaceMaps.h"
0005 #include "TrkrDefs.h"
0006 #include "MvtxDefs.h"
0007
0008 #include <Acts/Definitions/Algebra.hpp>
0009
0010 #include <tuple>
0011 #include <utility>
0012 #include <vector>
0013
0014 class ActsGeometry;
0015 class TrkrClusterContainer;
0016
0017 namespace TrackFitUtils
0018 {
0019 using position_t = std::pair<double, double>;
0020 using position_vector_t = std::vector<position_t>;
0021
0022
0023 using circle_fit_output_t = std::tuple<double, double, double>;
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 circle_fit_output_t circle_fit_by_taubin(const position_vector_t&);
0038
0039
0040 circle_fit_output_t circle_fit_by_taubin(const std::vector<Acts::Vector3>&);
0041
0042
0043 using line_fit_output_t = std::tuple<double, double>;
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055 line_fit_output_t line_fit(const position_vector_t&);
0056
0057
0058
0059
0060
0061
0062 double line_dist_to_pca (const double slope, const double intercept,
0063 const Acts::Vector2& pca, const Acts::Vector3& global);
0064
0065
0066 line_fit_output_t line_fit(const std::vector<Acts::Vector3>&);
0067
0068 line_fit_output_t line_fit_xy(const std::vector<Acts::Vector3>& positions);
0069 line_fit_output_t line_fit_xz(const std::vector<Acts::Vector3>& positions);
0070
0071
0072 using line_circle_intersection_output_t = std::tuple<double, double, double, double>;
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083 line_circle_intersection_output_t line_circle_intersection(double r, double m, double b);
0084
0085
0086 using circle_circle_intersection_output_t = std::tuple<double, double, double, double>;
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101 circle_circle_intersection_output_t circle_circle_intersection(double r1, double r2, double x2, double y2);
0102
0103 unsigned int addClusters(std::vector<float>& fitpars,
0104 double dca_cut,
0105 ActsGeometry* _tGeometry,
0106 TrkrClusterContainer* _cluster_map,
0107 std::vector<Acts::Vector3>& global_vec,
0108 std::vector<TrkrDefs::cluskey>& cluskey_vec,
0109 unsigned int startLayer,
0110 unsigned int endLayer);
0111
0112 unsigned int addClustersOnLine(TrackFitUtils::line_fit_output_t& fitpars,
0113 const bool& isXY,
0114 const double& dca_cut,
0115 ActsGeometry* tGeometry,
0116 TrkrClusterContainer* clusterContainer,
0117 std::vector<Acts::Vector3>& global_vec,
0118 std::vector<TrkrDefs::cluskey>& cluskey_vec,
0119 const unsigned int& startLayer,
0120 const unsigned int& endLayer);
0121
0122 std::pair<Acts::Vector3, Acts::Vector3> get_helix_tangent(const std::vector<float>& fitpars, Acts::Vector3& global);
0123
0124 Acts::Vector3 get_helix_pca(std::vector<float>& fitpars, const Acts::Vector3& global);
0125
0126 Acts::Vector2 get_circle_point_pca(float radius, float x0, float y0, Acts::Vector3 global);
0127
0128 std::vector<float> fitClusters(std::vector<Acts::Vector3>& global_vec,
0129 const std::vector<TrkrDefs::cluskey> &cluskey_vec,
0130 bool use_intt = false);
0131 void getTrackletClusters(ActsGeometry* _tGeometry,
0132 TrkrClusterContainer* _cluster_map,
0133 std::vector<Acts::Vector3>& global_vec,
0134 const std::vector<TrkrDefs::cluskey>& cluskey_vec);
0135 Acts::Vector3 surface_3Dline_intersection(const TrkrDefs::cluskey& key,
0136 TrkrCluster* cluster, ActsGeometry* geometry, float& xyslope, float& xyint, float& yzslope, float& yzint);
0137
0138 Acts::Vector3 getPCALinePoint(const Acts::Vector3& global, const Acts::Vector3& tangent, const Acts::Vector3& posref);
0139 Acts::Vector3 get_helix_surface_intersection(const Surface& surf,
0140 std::vector<float>& fitpars, Acts::Vector3& global, ActsGeometry* _tGeometry);
0141 Acts::Vector3 get_line_plane_intersection(const Acts::Vector3& pca, const Acts::Vector3& tangent,
0142 const Acts::Vector3& sensorCenter, const Acts::Vector3& sensorNormal);
0143
0144 std::vector<double> getLineClusterResiduals(position_vector_t& rz_pts, float slope, float intercept);
0145 std::vector<double> getCircleClusterResiduals(position_vector_t& xy_pts, float R, float X0, float Y0);
0146
0147 Acts::Vector2 get_line_point_pca(double slope, double intercept, Acts::Vector3 global);
0148 std::vector<float> fitClustersZeroField(const std::vector<Acts::Vector3>& global_vec,
0149 const std::vector<TrkrDefs::cluskey>& cluskey_vec, bool use_intt, bool mvtx_east = false, bool mvtx_west=false);
0150
0151
0152 float get_helix_pathlength(std::vector<float>& fitpars, const Acts::Vector3& start_point, const Acts::Vector3& end_point);
0153 float get_helix_surface_pathlength(const Surface& surf, std::vector<float>& fitpars, const Acts::Vector3& start_point, ActsGeometry* tGeometry);
0154
0155
0156
0157 std::tuple<bool, double, double, double, Acts::Vector3, Acts::Vector3>
0158 zero_field_track_params(
0159 ActsGeometry* _tGeometry,
0160 TrkrClusterContainer* _cluster_map,
0161 const std::vector<TrkrDefs::cluskey>& clusters
0162 );
0163
0164 double z_fit_to_pca(const double slope, const double intercept,
0165 const std::vector<Acts::Vector3>& glob_pts);
0166 bool isTrackCrossMvtxHalf(const std::vector<TrkrDefs::cluskey> &cluskey_vec);
0167 bool includeMvtxHit(TrkrDefs::cluskey clus_key, bool mvtx_east, bool mvtx_west);
0168 bool isMvtxEast(uint32_t hitsetkey);
0169 };
0170
0171 #endif