File indexing completed on 2026-08-31 08:21:26
0001
0002
0003 #ifndef TPCTRACKRECO_TPCTRACKHELIXFITTER_H
0004 #define TPCTRACKRECO_TPCTRACKHELIXFITTER_H
0005
0006 #include "TpcTrackFit.h"
0007
0008 #include <cstddef>
0009 #include <string>
0010 #include <utility>
0011 #include <vector>
0012
0013 class TpcTrackHelixFitter
0014 {
0015 public:
0016 static bool parse_point_order(const std::string &mode, TpcTrackPointOrder &order);
0017 static void order_points(std::vector<TpcTrackPoint> &points, TpcTrackPointOrder order);
0018
0019 static bool fit_circle_least_squares(const std::vector<TpcTrackPoint> &points,
0020 std::size_t nfit,
0021 double &cx,
0022 double &cy,
0023 double &radius);
0024 static bool fit_circle_curvature_refined(const std::vector<TpcTrackPoint> &points,
0025 std::size_t nfit,
0026 double &cx,
0027 double &cy,
0028 double &radius);
0029 static bool fit(const std::vector<TpcTrackPoint> &points,
0030 int fit_first_points,
0031 double bfield_t,
0032 TpcTrackHelix &helix);
0033 static bool from_state(const TpcTrackVec3 &position,
0034 const TpcTrackVec3 &momentum,
0035 int charge,
0036 double bfield_t,
0037 TpcTrackHelix &helix);
0038 static bool orient_to_charge(TpcTrackHelix &helix, int charge);
0039
0040 static TpcTrackVec3 point(const TpcTrackHelix &helix, double theta);
0041 static TpcTrackVec3 tangent(const TpcTrackHelix &helix, double theta);
0042 static TpcTrackVec3 momentum(const TpcTrackHelix &helix, double theta);
0043
0044 static std::pair<double, double> theta_search_range(const TpcTrackHelix &helix,
0045 double theta_extension,
0046 double downstream_margin);
0047 static bool measurement_anchored_search_range(
0048 const TpcTrackHelix &helix,
0049 const std::vector<TpcTrackPoint> &points,
0050 double max_upstream_cm,
0051 double downstream_margin_cm,
0052 TpcTrackHelixSearchRange &range);
0053 static bool line_line_pca(const TpcTrackVec3 &pos1,
0054 const TpcTrackVec3 &dir1,
0055 const TpcTrackVec3 &pos2,
0056 const TpcTrackVec3 &dir2,
0057 TpcTrackLinePca &pca,
0058 bool normalize_dirs);
0059 static TpcTrackHelixPca refine_pair(const TpcTrackHelix &helix1,
0060 const TpcTrackHelix &helix2,
0061 double theta1,
0062 double theta2,
0063 double min1,
0064 double max1,
0065 double min2,
0066 double max2,
0067 double max_step);
0068 static std::vector<TpcTrackHelixPca> pca_candidates(const TpcTrackHelix &helix1,
0069 const TpcTrackHelix &helix2,
0070 double theta_extension,
0071 int coarse_steps,
0072 double downstream_margin,
0073 int max_candidates);
0074 static std::vector<TpcTrackHelixPca> pca_candidates_in_ranges(
0075 const TpcTrackHelix &helix1,
0076 const TpcTrackHelix &helix2,
0077 const TpcTrackHelixSearchRange &range1,
0078 const TpcTrackHelixSearchRange &range2,
0079 int coarse_steps,
0080 int max_candidates);
0081
0082 static std::pair<double, double> helix_dca_to_vertex(const TpcTrackHelix &helix,
0083 const TpcTrackVec3 &vertex);
0084 static std::pair<double, double> line_dca_to_vertex(const TpcTrackVec3 &pos,
0085 const TpcTrackVec3 &mom,
0086 const TpcTrackVec3 &vertex);
0087
0088 static bool finite(const TpcTrackVec3 &value);
0089 static TpcTrackVec3 add(const TpcTrackVec3 &lhs, const TpcTrackVec3 &rhs);
0090 static TpcTrackVec3 subtract(const TpcTrackVec3 &lhs, const TpcTrackVec3 &rhs);
0091 static TpcTrackVec3 scale(const TpcTrackVec3 &value, double factor);
0092 static double dot(const TpcTrackVec3 &lhs, const TpcTrackVec3 &rhs);
0093 static double norm(const TpcTrackVec3 &value);
0094 static TpcTrackVec3 unit(const TpcTrackVec3 &value);
0095 static double pt(const TpcTrackVec3 &value);
0096 static double distance(const TpcTrackVec3 &lhs, const TpcTrackVec3 &rhs);
0097 static double vector_cosine(const TpcTrackVec3 &lhs, const TpcTrackVec3 &rhs);
0098 };
0099
0100 #endif