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