ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHCASeeding.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHCASeeding.h
1 #ifndef TRACKRECO_PHCASEEDING_H
2 #define TRACKRECO_PHCASEEDING_H
3 
11 //begin
12 
13 #include "PHTrackSeeding.h" // for PHTrackSeeding
14 #include "ALICEKF.h"
15 
17 
18 #include <trackbase/TrkrDefs.h> // for cluskey
20 
21 #include <Eigen/Core>
22 #include <Eigen/Dense>
23 
24 #include <boost/geometry/geometries/box.hpp> // for box
25 #include <boost/geometry/geometries/point.hpp> // for point
26 #include <boost/geometry/index/rtree.hpp> // for ca
27 
28 #include <cmath> // for M_PI
29 #include <cstdint> // for uint64_t
30 #include <map> // for map
31 #include <memory>
32 #include <set>
33 #include <string> // for string
34 #include <utility> // for pair
35 #include <unordered_set>
36 #include <vector> // for vector
37 
38 struct ActsSurfaceMaps;
40 class PHCompositeNode;
41 class PHTimer;
42 class SvtxTrack_v2;
44 class TrkrCluster;
45 
46 namespace bg = boost::geometry;
47 namespace bgi = boost::geometry::index;
48 
49 using point = bg::model::point<float, 3, bg::cs::cartesian>;
50 using box = bg::model::box<point>;
51 using pointKey = std::pair<point, TrkrDefs::cluskey>;
52 using coordKey = std::pair<std::array<float,3>, TrkrDefs::cluskey>;
53 using keylink = std::array<coordKey,2>;
54 using keylist = std::vector<TrkrDefs::cluskey>;
55 using PositionMap = std::map<TrkrDefs::cluskey, Acts::Vector3F>;
56 
58 {
59  public:
61  const std::string &name = "PHCASeeding",
62  unsigned int start_layer = 7,
63  unsigned int end_layer = 55,
64  unsigned int min_nhits_per_cluster = 0,
65  unsigned int min_clusters_per_track = 5,
66  const unsigned int nlayers_maps = 3,
67  const unsigned int nlayers_intt = 4,
68  const unsigned int nlayers_tpc = 48,
69  float neighbor_phi_width = .02,
70  float neighbor_eta_width = .01,
71  float maxSinPhi = 0.999,
72  float cosTheta_limit = -0.8);
73 
74  ~PHCASeeding() override {}
75  void SetLayerRange(unsigned int layer_low, unsigned int layer_up) {_start_layer = layer_low; _end_layer = layer_up;}
76  void SetSearchWindow(float eta_width, float phi_width) {_neighbor_eta_width = eta_width; _neighbor_phi_width = phi_width;}
77  void SetMinHitsPerCluster(unsigned int minHits) {_min_nhits_per_cluster = minHits;}
78  void SetMinClustersPerTrack(unsigned int minClus) {_min_clusters_per_track = minClus;}
79 
80  void set_field_dir(const double rescale)
81  {
82  std::cout << "rescale: " << rescale << std::endl;
83  _fieldDir = 1;
84  if(rescale > 0)
85  _fieldDir = -1;
86  }
87 
88  void useConstBField(bool opt){_use_const_field = opt;}
90  void setFixedClusterError(int i, double val){_fixed_clus_err.at(i) = val;}
91 
92  protected:
93  int Setup(PHCompositeNode *topNode) override;
94  int Process(PHCompositeNode *topNode) override;
95  int InitializeGeometry(PHCompositeNode *topNode);
96  int FindSeedsLayerSkip(double cosTheta_limit);
97  int End() override;
98 
99  private:
100 
101  enum skip_layers {on, off};
102 
105 
108 
110 
115 
117  int FindSeedsWithMerger(const PositionMap&);
118  std::pair<std::vector<std::unordered_set<keylink>>,std::vector<std::unordered_set<keylink>>> CreateLinks(const std::vector<coordKey>& clusters, const PositionMap& globalPositions, int mode = skip_layers::off) const;
119  std::vector<std::vector<keylink>> FindBiLinks(const std::vector<std::unordered_set<keylink>>& belowLinks, const std::vector<std::unordered_set<keylink>>& aboveLinks) const;
120  std::vector<keylist> FollowBiLinks(const std::vector<std::vector<keylink>>& bidirectionalLinks, const PositionMap& globalPositions) const;
121  void QueryTree(const bgi::rtree<pointKey, bgi::quadratic<16>> &rtree, double phimin, double etamin, double lmin, double phimax, double etamax, double lmax, std::vector<pointKey> &returned_values) const;
122  std::vector<keylist> RemoveBadClusters(const std::vector<keylist>& seeds, const PositionMap& globalPositions) const;
123 
124  void publishSeeds(const std::vector<SvtxTrack_v2>& seeds);
125 
126  //int _nlayers_all;
127  //unsigned int _nlayers_seeding;
128  //std::vector<int> _seeding_layer;
129 
130  const unsigned int _nlayers_maps;
131  const unsigned int _nlayers_intt;
132  const unsigned int _nlayers_tpc;
133  unsigned int _start_layer;
134  unsigned int _end_layer;
137 // float _cluster_z_error;
138 // float _cluster_alice_y_error;
143  double _rz_outlier_threshold = 0.1;
144  double _xy_outlier_threshold = 0.1;
145  double _fieldDir = -1;
146  bool _use_const_field = false;
147  bool _use_fixed_clus_err = false;
148  std::array<double,3> _fixed_clus_err = {.1,.1,.1};
149 
152 
155 
158 
159  std::unique_ptr<ALICEKF> fitter;
160 
161  std::unique_ptr<PHTimer> t_seed;
162  std::unique_ptr<PHTimer> t_fill;
163  bgi::rtree<pointKey, bgi::quadratic<16>> _rtree;
164 };
165 
166 #endif