ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHSimpleKFProp.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHSimpleKFProp.h
1 
7 #ifndef TRACKRECO_PHSIMPLEKFPROP_H
8 #define TRACKRECO_PHSIMPLEKFPROP_H
9 
10 #include "ALICEKF.h"
11 #include "nanoflann.hpp"
12 
13 // PHENIX includes
14 #include <fun4all/SubsysReco.h>
16 #include <trackbase/TrkrDefs.h>
18 
19 #include <Eigen/Core>
20 
21 // STL includes
22 #include <memory>
23 #include <string>
24 #include <vector>
25 
26 // forward declarations
27 struct ActsSurfaceMaps;
29 class PHCompositeNode;
30 class PHField;
31 class SvtxTrack;
32 class SvtxTrack_v2;
37 class SvtxTrackMap;
38 
39 using PositionMap = std::map<TrkrDefs::cluskey, Acts::Vector3F>;
40 
41 class PHSimpleKFProp : public SubsysReco
42 {
43  public:
44  PHSimpleKFProp(const std::string &name = "PHSimpleKFProp");
45  ~PHSimpleKFProp() override = default;
46 
47  int InitRun(PHCompositeNode *topNode) override;
48  int process_event(PHCompositeNode *topNode) override;
49  int End(PHCompositeNode *topNode) override;
50  //void set_track_map_name(const std::string &map_name) { _track_map_name = map_name; }
51  //void SetUseTruthClusters(bool setit){_use_truth_clusters = setit;}
52  void set_field_dir(const double rescale)
53  {
54  std::cout << "rescale: " << rescale << std::endl;
55  _fieldDir = 1;
56  if(rescale > 0)
57  _fieldDir = -1;
58  }
59  void set_max_window(double s){_max_dist = s;}
60  void useConstBField(bool opt){_use_const_field = opt;}
62  void setFixedClusterError(int i, double val){_fixed_clus_err.at(i) = val;}
63  void use_truth_clusters(bool truth)
64  { _use_truth_clusters = truth; }
65  void set_track_map_name(const std::string &map_name) { _track_map_name = map_name; }
66  void SetIteration(int iter){_n_iteration = iter;}
67 
68  private:
69 
72 
75 
76  bool _use_truth_clusters = false;
77 
79  int get_nodes(PHCompositeNode *topNode);
80  std::vector<double> radii;
81  std::vector<double> _vertex_x;
82  std::vector<double> _vertex_y;
83  std::vector<double> _vertex_z;
84  std::vector<double> _vertex_xerr;
85  std::vector<double> _vertex_yerr;
86  std::vector<double> _vertex_zerr;
87  std::vector<double> _vertex_ids;
88  double _Bzconst = 10*0.000299792458f;
89  //double _Bz = 1.4*_Bzconst;
90  double _max_dist = .05;
92  double _fieldDir = -1;
93  double _max_sin_phi = 1.;
94  double _rz_outlier_threshold = .1;
95  double _xy_outlier_threshold = .1;
96 
100  PHField* _field_map = nullptr;
101 
104 
107 
110 
112 
117 
119 
120  void MoveToFirstTPCCluster(const PositionMap&);
121 
122  std::vector<TrkrDefs::cluskey> PropagateTrack(SvtxTrack* track, const PositionMap& globalPositions) const;
123  std::vector<std::vector<TrkrDefs::cluskey>> RemoveBadClusters(const std::vector<std::vector<TrkrDefs::cluskey>>& seeds, const PositionMap& globalPositions) const;
124  template <typename T>
126  {
128  std::vector<std::vector<T>> pts;
129  inline size_t kdtree_get_point_count() const
130  {
131  return pts.size();
132  }
133  inline T kdtree_distance(const T* p1, const size_t idx_p2, size_t /*size*/) const
134  {
135  const T d0 = p1[0] - pts[idx_p2][0];
136  const T d1 = p1[1] - pts[idx_p2][1];
137  const T d2 = p1[2] - pts[idx_p2][2];
138  return d0 * d0 + d1 * d1 + d2 * d2;
139  }
140  inline T kdtree_get_pt(const size_t idx, int dim) const
141  {
142  if (dim == 0)
143  return pts[idx][0];
144  else if (dim == 1)
145  return pts[idx][1];
146  else
147  return pts[idx][2];
148  }
149  template <class BBOX>
150  bool kdtree_get_bbox(BBOX& /*bb*/) const
151  {
152  return false;
153  }
154  };
155  std::vector<std::shared_ptr<KDPointCloud<double>>> _ptclouds;
156  std::vector<std::shared_ptr<nanoflann::KDTreeSingleIndexAdaptor<nanoflann::L2_Simple_Adaptor<double, KDPointCloud<double>>, KDPointCloud<double>,3>>> _kdtrees;
157  std::unique_ptr<ALICEKF> fitter;
158  double get_Bz(double x, double y, double z) const;
159  void publishSeeds(const std::vector<SvtxTrack_v2>&);
160  void publishSeeds(const std::vector<SvtxTrack>&);
161 // void MoveToVertex();
162 
163  bool _use_const_field = false;
164  bool _use_fixed_clus_err = false;
165  std::array<double,3> _fixed_clus_err = {.1,.1,.1};
167  int _n_iteration = 0;
168  std::string _track_map_name = "SvtxTrackMap";
169 
170 };
171 
172 #endif