File indexing completed on 2025-12-17 09:20:55
0001 #ifndef ALICEKF_H
0002 #define ALICEKF_H
0003
0004 #include <phfield/PHField.h>
0005 #include <trackbase/ClusterErrorPara.h>
0006 #include <trackbase/TrkrCluster.h>
0007 #include <trackbase/TrkrClusterContainer.h>
0008 #include <trackbase/TrkrDefs.h>
0009 #include <trackbase_historic/TrackSeed_v2.h>
0010 #include "GPUTPCTrackParam.h"
0011
0012 #include <Acts/Definitions/Algebra.hpp>
0013
0014 #include <Eigen/Core>
0015 #include <Eigen/Dense>
0016
0017 #include <string>
0018 #include <utility>
0019 #include <vector>
0020
0021 using PositionMap = std::map<TrkrDefs::cluskey, Acts::Vector3>;
0022 using TrackSeedAliceSeedMap = std::pair<std::vector<TrackSeed_v2>, std::vector<GPUTPCTrackParam>>;
0023
0024 class ALICEKF
0025 {
0026 public:
0027 ALICEKF( TrkrClusterContainer* cmap, PHField* B, unsigned int min_clusters, double max_sin_phi, int verbosity);
0028
0029 ~ALICEKF() = default;
0030
0031 explicit ALICEKF(const ALICEKF&) = delete;
0032 ALICEKF& operator=(const ALICEKF&) = delete;
0033
0034 void setNeonFraction(double frac) { Ne_frac = frac; };
0035 void setArgonFraction(double frac) { Ar_frac = frac; };
0036 void setCF4Fraction(double frac) { CF4_frac = frac; };
0037 void setNitrogenFraction(double frac) { N2_frac = frac; };
0038 void setIsobutaneFraction(double frac) { isobutane_frac = frac; };
0039
0040 bool TransportAndRotate(double old_radius, double new_radius, double& phi, GPUTPCTrackParam& kftrack, GPUTPCTrackParam::GPUTPCTrackFitParam& fp) const;
0041 bool FilterStep(TrkrDefs::cluskey ckey, std::vector<TrkrDefs::cluskey>& keys, double& current_phi, GPUTPCTrackParam& kftrack, GPUTPCTrackParam::GPUTPCTrackFitParam& fp, const PositionMap& globalPositions) const;
0042
0043 TrackSeedAliceSeedMap ALICEKalmanFilter(const std::vector<std::vector<TrkrDefs::cluskey>>& chains, bool use_nhits_limit, const PositionMap& globalPositions, std::vector<float>& trackChi2) const;
0044 bool covIsPosDef(Eigen::Matrix<double, 6, 6>& cov) const;
0045 void repairCovariance(Eigen::Matrix<double, 6, 6>& cov) const;
0046 bool checknan(double val, const std::string& msg, int num) const;
0047 double get_Bz(double x, double y, double z) const;
0048
0049
0050
0051
0052
0053
0054 void setConstBField(float b) { _const_field = b; }
0055
0056 void useFixedClusterError(bool opt) { _use_fixed_clus_error = opt; }
0057 void setFixedClusterError(int i, double val) { _fixed_clus_error.at(i) = val; }
0058 double getClusterError(TrkrCluster* c, TrkrDefs::cluskey key, Acts::Vector3 global, int i, int j) const;
0059 std::vector<double> GetCircleClusterResiduals(const std::vector<std::pair<double, double>>& pts, double R, double X0, double Y0) const;
0060 std::vector<double> GetLineClusterResiduals(const std::vector<std::pair<double, double>>& pts, double A, double B) const;
0061 double get_Bzconst() const { return _Bzconst; }
0062
0063 private:
0064 int Verbosity() const
0065 { return _v; }
0066
0067
0068 PHField* _B = nullptr;
0069
0070
0071
0072
0073
0074
0075 float _const_field = 1.4;
0076
0077 size_t _min_clusters_per_track = 20;
0078 TrkrClusterContainer* _cluster_map = nullptr;
0079
0080 int _v = 0;
0081 static constexpr double _Bzconst = 10. * 0.000299792458f;
0082 double _max_sin_phi = 1.;
0083
0084
0085 std::unique_ptr<ClusterErrorPara> _ClusErrPara;
0086
0087
0088 bool _use_fixed_clus_error = true;
0089 std::array<double, 3> _fixed_clus_error = {.2, .2, .5};
0090
0091 double Ne_frac = 0.00;
0092 double Ar_frac = 0.75;
0093 double CF4_frac = 0.20;
0094 double N2_frac = 0.00;
0095 double isobutane_frac = 0.05;
0096 };
0097
0098 #endif