Analysis Software
Documentation for sPHENIX simulation 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 class ActsGeometry;
27 class PHCompositeNode;
28 class PHField;
32 class SvtxTrackMap;
33 class TrackSeedContainer;
34 class TrackSeed;
35 
36 using PositionMap = std::map<TrkrDefs::cluskey, Acts::Vector3>;
37 
38 class PHSimpleKFProp : public SubsysReco
39 {
40  public:
41  PHSimpleKFProp(const std::string &name = "PHSimpleKFProp");
42  ~PHSimpleKFProp() override = default;
43 
44  int InitRun(PHCompositeNode *topNode) override;
45  int process_event(PHCompositeNode *topNode) override;
46  int End(PHCompositeNode *topNode) override;
47 
48  void set_field_dir(const double rescale)
49  {
50  _fieldDir = 1;
51  if(rescale > 0)
52  { _fieldDir = -1; }
53  }
54  void set_max_window(double s){_max_dist = s;}
55  void useConstBField(bool opt){_use_const_field = opt;}
56  void setConstBField(float b) { _const_field = b; }
58  void setFixedClusterError(int i, double val){_fixed_clus_err.at(i) = val;}
59  void use_truth_clusters(bool truth)
60  { _use_truth_clusters = truth; }
61  void SetIteration(int iter){_n_iteration = iter;}
62 
63  private:
64 
67 
68  bool _use_truth_clusters = false;
69 
71  int get_nodes(PHCompositeNode *topNode);
72  std::vector<double> radii;
73  std::vector<double> _vertex_x;
74  std::vector<double> _vertex_y;
75  std::vector<double> _vertex_z;
76  std::vector<double> _vertex_xerr;
77  std::vector<double> _vertex_yerr;
78  std::vector<double> _vertex_zerr;
79  std::vector<double> _vertex_ids;
80  double _Bzconst = 10*0.000299792458f;
81  //double _Bz = 1.4*_Bzconst;
82  double _max_dist = .05;
84  double _fieldDir = -1;
85  double _max_sin_phi = 1.;
86  double _rz_outlier_threshold = .1;
87  double _xy_outlier_threshold = .1;
88 
90 
92 
93  std::unique_ptr<PHField> _field_map = nullptr;
94 
97 
100 
102 
107 
109 
110  std::vector<TrkrDefs::cluskey> PropagateTrack(TrackSeed* track, Eigen::Matrix<double,6,6>& xyzCov, const PositionMap& globalPositions) const;
111  std::vector<std::vector<TrkrDefs::cluskey>> RemoveBadClusters(const std::vector<std::vector<TrkrDefs::cluskey>>& seeds, const PositionMap& globalPositions) const;
112  template <typename T>
114  {
116  std::vector<std::vector<T>> pts;
117  inline size_t kdtree_get_point_count() const
118  {
119  return pts.size();
120  }
121  inline T kdtree_distance(const T* p1, const size_t idx_p2, size_t /*size*/) const
122  {
123  const T d0 = p1[0] - pts[idx_p2][0];
124  const T d1 = p1[1] - pts[idx_p2][1];
125  const T d2 = p1[2] - pts[idx_p2][2];
126  return d0 * d0 + d1 * d1 + d2 * d2;
127  }
128  inline T kdtree_get_pt(const size_t idx, int dim) const
129  {
130  if (dim == 0)
131  return pts[idx][0];
132  else if (dim == 1)
133  return pts[idx][1];
134  else
135  return pts[idx][2];
136  }
137  template <class BBOX>
138  bool kdtree_get_bbox(BBOX& /*bb*/) const
139  {
140  return false;
141  }
142  };
143  std::vector<std::shared_ptr<KDPointCloud<double>>> _ptclouds;
144  std::vector<std::shared_ptr<nanoflann::KDTreeSingleIndexAdaptor<nanoflann::L2_Simple_Adaptor<double, KDPointCloud<double>>, KDPointCloud<double>,3>>> _kdtrees;
145  std::unique_ptr<ALICEKF> fitter;
146  double get_Bz(double x, double y, double z) const;
147  void publishSeeds(std::vector<TrackSeed_v1>& seeds, PositionMap &positions);
148  void publishSeeds(const std::vector<TrackSeed_v1>&);
149 // void MoveToVertex();
150 
151  bool _use_const_field = false;
152  float _const_field = 1.4;
153  bool _use_fixed_clus_err = false;
154  std::array<double,3> _fixed_clus_err = {.1,.1,.1};
156  int _n_iteration = 0;
157 
158 };
159 
160 #endif