Analysis Software
Documentation for sPHENIX simulation 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
19 #include <trackbase/ActsGeometry.h>
20 
21 #include <phool/PHTimer.h> // for PHTimer
22 
23 #include <Eigen/Core>
24 #include <Eigen/Dense>
25 
26 #pragma GCC diagnostic push
27 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
28 #include <boost/geometry/geometries/box.hpp> // for box
29 #pragma GCC diagnostic pop
30 
31 #include <boost/geometry/geometries/point.hpp> // for point
32 #include <boost/geometry/index/rtree.hpp> // for ca
33 
34 #include <cmath> // for M_PI
35 #include <cstdint> // for uint64_t
36 #include <map> // for map
37 #include <memory>
38 #include <set>
39 #include <string> // for string
40 #include <utility> // for pair
41 #include <unordered_set>
42 #include <vector> // for vector
43 
44 class PHCompositeNode;
45 class PHTimer;
46 class SvtxTrack_v3;
48 class TrkrCluster;
49 
50 namespace bg = boost::geometry;
51 namespace bgi = boost::geometry::index;
52 
53 using point = bg::model::point<float, 3, bg::cs::cartesian>;
54 using box = bg::model::box<point>;
55 using pointKey = std::pair<point, TrkrDefs::cluskey>;
56 using coordKey = std::pair<std::array<float,3>, TrkrDefs::cluskey>;
57 using keylink = std::array<coordKey,2>;
58 using keylist = std::vector<TrkrDefs::cluskey>;
59 using PositionMap = std::map<TrkrDefs::cluskey, Acts::Vector3>;
60 
62 {
63  public:
65  const std::string &name = "PHCASeeding",
66  unsigned int start_layer = 7,
67  unsigned int end_layer = 55,
68  unsigned int min_nhits_per_cluster = 0,
69  unsigned int min_clusters_per_track = 5,
70  const unsigned int nlayers_maps = 3,
71  const unsigned int nlayers_intt = 4,
72  const unsigned int nlayers_tpc = 48,
73  float neighbor_phi_width = .02,
74  float neighbor_eta_width = .01,
75  float maxSinPhi = 0.999,
76  float cosTheta_limit = -0.8);
77 
78  ~PHCASeeding() override {}
79  void SetLayerRange(unsigned int layer_low, unsigned int layer_up) {_start_layer = layer_low; _end_layer = layer_up;}
80  void SetSearchWindow(float eta_width, float phi_width) {_neighbor_eta_width = eta_width; _neighbor_phi_width = phi_width;}
81  void SetMinHitsPerCluster(unsigned int minHits) {_min_nhits_per_cluster = minHits;}
82  void SetMinClustersPerTrack(unsigned int minClus) {_min_clusters_per_track = minClus;}
83 
84  void set_field_dir(const double rescale)
85  {
86  std::cout << "rescale: " << rescale << std::endl;
87  _fieldDir = 1;
88  if(rescale > 0)
89  _fieldDir = -1;
90  }
91 
92  void useConstBField(bool opt){_use_const_field = opt;}
93  void constBField(float b){_const_field = b;}
95  void setFixedClusterError(int i, double val){_fixed_clus_err.at(i) = val;}
96 
97  protected:
98  int Setup(PHCompositeNode *topNode) override;
99  int Process(PHCompositeNode *topNode) override;
100  int InitializeGeometry(PHCompositeNode *topNode);
101  int FindSeedsLayerSkip(double cosTheta_limit);
102  int End() override;
103 
104  private:
105 
106  enum skip_layers {on, off};
107 
110 
112 
117 
119  int FindSeedsWithMerger(const PositionMap&);
120  std::pair<std::vector<std::unordered_set<keylink>>,std::vector<std::unordered_set<keylink>>> CreateLinks(const std::vector<coordKey>& clusters, const PositionMap& globalPositions) const;
121  std::vector<std::vector<keylink>> FindBiLinks(const std::vector<std::unordered_set<keylink>>& belowLinks, const std::vector<std::unordered_set<keylink>>& aboveLinks) const;
122  std::vector<keylist> FollowBiLinks(const std::vector<std::vector<keylink>>& bidirectionalLinks, const PositionMap& globalPositions) const;
123  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;
124  std::vector<TrackSeed_v1> RemoveBadClusters(const std::vector<keylist>& seeds, const PositionMap& globalPositions) const;
126 
127  void publishSeeds(const std::vector<TrackSeed_v1>& seeds);
128 
129  //int _nlayers_all;
130  //unsigned int _nlayers_seeding;
131  //std::vector<int> _seeding_layer;
132 
133  const unsigned int _nlayers_maps;
134  const unsigned int _nlayers_intt;
135  const unsigned int _nlayers_tpc;
136  unsigned int _start_layer;
137  unsigned int _end_layer;
140 // float _cluster_z_error;
141 // float _cluster_alice_y_error;
146  double _rz_outlier_threshold = 0.1;
147  double _xy_outlier_threshold = 0.1;
148  double _fieldDir = -1;
149  bool _use_const_field = false;
150  float _const_field = 1.4;
151  bool _use_fixed_clus_err = false;
152  std::array<double,3> _fixed_clus_err = {.1,.1,.1};
153 
156 
159 
160  std::unique_ptr<ALICEKF> fitter;
161 
162  std::unique_ptr<PHTimer> t_seed;
163  std::unique_ptr<PHTimer> t_fill;
164  bgi::rtree<pointKey, bgi::quadratic<16>> _rtree;
165 };
166 
167 #endif