ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHPatternReco.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHPatternReco.h
1 #ifndef TRACKRECO_PHPATTERNRECO_H
2 #define TRACKRECO_PHPATTERNRECO_H
3 
4 #include "VertexFitter.h"
5 
6 #include <trackbase/TrkrDefs.h>
7 
8 // Helix Hough includes
9 #include <HelixHough/SimpleHit3D.h>
10 #include <HelixHough/SimpleTrack3D.h>
11 #include <HelixHough/HelixKalmanState.h>
12 
13 #include <fun4all/SubsysReco.h>
14 
15 #include <Eigen/Core> // for Matrix
16 
17 #include <map>
18 #include <string> // for string
19 #include <vector>
20 
21 
22 // forward declarations
23 class BbcVertexMap;
24 //class CellularAutomaton;
25 class HelixHoughBin;
26 class HelixHoughSpace;
27 class HelixHoughFuncs;
28 class PHCompositeNode;
29 class PHTimer;
32 class SvtxTrackMap;
33 class SvtxVertexMap;
34 
35 class TFile;
36 class TH2D;
37 class TH3D;
38 class TNtuple;
39 
41 class PHPatternReco: public SubsysReco {
42 
43 public:
44 
45  PHPatternReco(unsigned int nlayers = 7, unsigned int min_nlayers = 7,
46  const std::string &name = "PHPatternReco");
47  ~PHPatternReco() override ;
48 
49  int Init(PHCompositeNode *topNode) override;
50  int InitRun(PHCompositeNode *topNode) override;
51  int process_event(PHCompositeNode *topNode) override;
52  int End(PHCompositeNode *topNode) override;
53 
54 
55  void set_file_name(const std::string &fname){_fname = fname;}
56  void set_mag_field(float mag_field) {
57  _mag_field = mag_field;
58  }
59  float get_mag_field() const {
60  return _mag_field;
61  }
62 
63  void set_min_pT(float pt) {
64  _min_pt = pt;
65  }
66 
67  void set_max_kappa(float kappa_max);
68  void set_min_d(float d_min) {_min_d = d_min;}
69  void set_max_d(float d_max) {_max_d = d_max;}
70  void set_min_dzdl(float dzdl_min) {_min_dzdl = dzdl_min; }
71  void set_max_dzdl(float dzdl_max) {_max_dzdl = dzdl_max;}
72  void set_min_z0(float z0_min) { _min_z0 = z0_min;}
73  void set_max_z0(float z0_max) { _max_z0 = z0_max;}
74  float get_max_kappa() const {return _max_kappa;}
75  float get_min_z0() const {return _min_z0;}
76  float get_max_z0() const {return _max_z0;}
77 
79  void set_material(int layer, float value);
80 
82  void setCutOnDCA(bool cod) {
83  _cut_on_dca = cod;
84  }
86  void set_dcaxy_cut(float dcut) {
87  _dcaxy_cut = dcut;
88  }
90  void set_dcaz_cut(float dzcut) {
91  _dcaz_cut = dzcut;
92  }
94  void set_chi2_cut(float chi2_cut) {
95  _ca_chi2 = chi2_cut;
96  }
97 
98  void set_ca_z_cut(float z_cut) {
99  _ca_z_cut = z_cut;
100  }
101 
102 
105  void setPtRescaleFactor(float pt_rescale) {
106  _pt_rescale = pt_rescale;
107  }
108 
109  void set_ca_phi_cut(float phi_cut)
110  {
111  _ca_phi_cut = phi_cut;
112  }
113 
114  void set_mult_onebin(float mult)
115  {
116  _mult_onebin = mult;
117  }
118 
119  void set_mult_twobins(float mult)
120  {
121  _mult_twobins = mult;
122  }
123 
124  void set_mult_threebins(float mult)
125  {
126  _mult_threebins= mult;
127  }
128 
129  void set_min_zvtx_tracks(unsigned int min_zvtx_tracks)
130  {
131  _min_zvtx_tracks = min_zvtx_tracks;
132  }
133 
134  const std::vector<int>& get_seeding_layer() const {
135  return _seeding_layer;
136  }
137 
138  void set_seeding_layer(const int* seedingLayer, const int n) {
139  _seeding_layer.assign(seedingLayer, seedingLayer + n);
140  }
141 
142 
143  void add_zoom(unsigned int n_kappa, unsigned int n_phi, unsigned int n_d, unsigned int n_dzdl, unsigned int n_z0);
144  void set_nzooms() {nzooms = zooms_vec.size();}
145  void reset_zooms() {zooms_vec.clear();}
146 
147 
148 private:
149 
150  //--------------
151  // InitRun Calls
152  //--------------
153  int create_nodes(PHCompositeNode *topNode);
154  int initialize_geometry(PHCompositeNode *topNode);
155 
156  //--------------------
157  // Process Event Calls
158  //--------------------
159  int get_nodes(PHCompositeNode *topNode);
160  int translate_input(PHCompositeNode *topNode);
161 
162  void set_nbins(unsigned int izoom);
163  void initialize_houghbin();
164  void vote_z_init(unsigned int zoomlevel);
165 
166  void find_track_candidates_z_init(unsigned int zoomlevel);
167  void vote_z(unsigned int zoomlevel);
168  void find_track_candidates_z(unsigned int zoomlevel);
169  void vote_xy(unsigned int zoomlevel);
170  void find_track_candidates_xy(unsigned int zoomlevel);
171 
172  void prune_z(unsigned int zoomlevel);
173  void prune_xy(unsigned int zoomlevel);
174 
175  void reset_hits_used();
176 
177  int export_output();
178 
179 
180  //------------------
181  // Subfunction Calls
182  //------------------
184  float kappa_to_pt(float kappa);
185 
187  float pt_to_kappa(float pt);
188 
189  void bins_to_SimpleTrack3D(std::vector<SimpleTrack3D>& temp_tracks, int imap, unsigned int zoomlevel);
190  int build_triplets_to_SimpleTrack3D(std::vector<SimpleTrack3D>& new_tracks, bool forward);
192  int cellular_automaton_zvtx_init(std::vector<SimpleTrack3D>& temp_tracks);
193  int fit_vertex();
194 
197  float d, float kappa, float z0, float dzdl,
198  Eigen::Matrix<float, 5, 5> const& input,
199  Eigen::Matrix<float, 6, 6>& output);
200 
201  void shift_coordinate_system(double dx, double dy, double dz);
202  float shift_phi_range(float phi);
203 
204  int _event;
206 
207  std::vector<int> _seeding_layer; //layer numbers that are used for seeding
208 
209  unsigned int _nlayers;
210  unsigned int _min_nlayers;
211  unsigned int _ca_nlayers;
212  unsigned int _ca_min_nlayers;
213 
214  float _ca_chi2;
215  std::vector<float> _radii;
216  std::vector<float> _material;
217  std::map<int, float> _user_material;
218 
219  float _mag_field;
220 
221 // bool _reject_ghosts;
225 
226  float _min_pt;
227  float _max_kappa;
228  float _min_d;
229  float _max_d;
230  float _min_dzdl;
231  float _max_dzdl;
232  float _min_z0;
233  float _max_z0;
234 
236  float _dcaxy_cut;
237  float _dcaz_cut;
238  float _pt_rescale;
239  float _ca_phi_cut;
240  float _ca_z_cut;
241  float _z_cut;
245  unsigned int _min_zvtx_tracks;
246 
247 
248  unsigned int bin;
249 
250  unsigned int ik;
251  unsigned int ip;
252  unsigned int id;
253  unsigned int il;
254  unsigned int iz;
255 
256  unsigned int nkappa;
257  unsigned int nphi;
258  unsigned int nd;
259  unsigned int ndzdl;
260  unsigned int nz0;
261 
262  unsigned int cluster_id;
263 
265  std::map<int, unsigned int> _layer_ilayer_map;
266 
267  // object storage
268  std::vector<SimpleTrack3D> _temp_tracks;
269  std::vector<SimpleTrack3D> _tracks;
270  std::vector<HelixKalmanState> _track_states;
271  std::vector<double> _track_errors;
272  std::vector<Eigen::Matrix<float, 5, 5> > _track_covars;
273  std::vector<float> _vertex;
274  std::vector<std::vector<float> > _vertex_list;
275 
276  // node pointers
283 
286 
287 // CellularAutomaton* ca;
288 
289  int _mode;
292  TH2D* _z0_dzdl;
293  TH2D* _kappa_phi;
294  TH2D* _d_phi;
296  TFile* _ofile;
297  TFile* _ofile2;
298 
299  std::string _fname;
301  std::map<int, unsigned int> _layer_ilayer_map_all;
302  std::vector<float> _radii_all;
303  std::vector<std::vector<unsigned int> > zooms_vec;
304 
305  std::map<unsigned int, bool> hits_used;
306  std::map<unsigned int, SimpleHit3D> hits_map;
307  std::map<unsigned int, HelixHoughBin* > bins_map;
308  std::map<unsigned int, HelixHoughBin* > bins_map_prev;
309  std::map<unsigned int, HelixHoughBin* > bins_map_cur;
310  std::map<unsigned int, HelixHoughBin* > bins_map_sel;
311 
312  std::map<unsigned int, unsigned int> kappa_phi_map;
313  std::map<unsigned int, unsigned int> d_phi_map;
314  std::map<unsigned int, unsigned int> kappa_d_phi_map;
315 
316  float hit[50][3];
317  float hitpos3d[3];
318  unsigned int nzooms;
319 
321  int helicity;
323 
324 };
325 
326 #endif // __PHPATTERNRECO_H__