Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:18:23

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