ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHGenFitTrkFitter.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHGenFitTrkFitter.h
1 
8 #ifndef TRACKRECO_PHGENFITTRKFITTER_H
9 #define TRACKRECO_PHGENFITTRKFITTER_H
10 
11 #include <fun4all/SubsysReco.h>
12 
13 #if defined(__CLING__)
14 // needed, it crashes on Ubuntu using singularity with local cvmfs install
15 // shared pointer later on uses this, forward declaration does not cut it
16 #include <phgenfit/Track.h>
17 #else
18 namespace PHGenFit
19 {
20  class Track;
21 } /* namespace PHGenFit */
22 #endif
23 
24 #include <TMatrixFfwd.h> // for TMatrixF
25 #include <TVector3.h> // for TVector3
26 
27 #include <map>
28 #include <memory> // for shared_ptr
29 #include <set>
30 #include <string>
31 #include <vector>
32 
33 class TClonesArray;
34 
35 namespace genfit
36 {
37 class GFRaveVertex;
38 class GFRaveVertexFactory;
39 class Track;
40 } /* namespace genfit */
41 
42 class SvtxTrack;
43 namespace PHGenFit
44 {
45 class Fitter;
46 } /* namespace PHGenFit */
47 
48 class SvtxTrackMap;
49 class SvtxVertexMap;
50 class SvtxVertex;
51 class PHCompositeNode;
54 class TTree;
55 
58 {
59  public:
66  {
70  };
71 
73  {
74  MIE,
81  };
82 
84  PHGenFitTrkFitter(const std::string& name = "PHGenFitTrkFitter");
85 
87  int Init(PHCompositeNode*) override;
88 
90  int InitRun(PHCompositeNode*) override;
91 
93  int process_event(PHCompositeNode*) override;
94 
96  int End(PHCompositeNode*) override;
97 
100  void set_eval_filename(const char* file)
101  {
102  if (file)
104  }
105  std::string get_eval_filename() const
106  {
107  return _eval_outname;
108  }
109 
111  void init_eval_tree();
112  void reset_eval_variables();
113 
114  bool is_do_eval() const
115  {
116  return _do_eval;
117  }
118 
119  void set_do_eval(bool doEval)
120  {
121  _do_eval = doEval;
122  }
123 
124  bool is_do_evt_display() const
125  {
126  return _do_evt_display;
127  }
128 
129  void set_do_evt_display(bool doEvtDisplay)
130  {
131  _do_evt_display = doEvtDisplay;
132  }
133 
134  const std::string& get_vertexing_method() const
135  {
136  return _vertexing_method;
137  }
138 
139  void set_vertexing_method(const std::string& vertexingMethod)
140  {
141  _vertexing_method = vertexingMethod;
142  }
143 
145  {
146  return _fit_primary_tracks;
147  }
148 
149  void set_fit_primary_tracks(bool fitPrimaryTracks)
150  {
151  _fit_primary_tracks = fitPrimaryTracks;
152  }
153 
155  {
156  return _output_mode;
157  }
158 
162  void set_output_mode(OutPutMode outputMode)
163  {
164  _output_mode = outputMode;
165  }
166 
167  const std::string& get_track_fitting_alg_name() const
168  {
170  }
171 
172  void set_track_fitting_alg_name(const std::string& trackFittingAlgName)
173  {
174  _track_fitting_alg_name = trackFittingAlgName;
175  }
176 
178  {
179  return _primary_pid_guess;
180  }
181 
182  void set_primary_pid_guess(int primaryPidGuess)
183  {
184  _primary_pid_guess = primaryPidGuess;
185  }
186 
187  double get_fit_min_pT() const
188  {
189  return _fit_min_pT;
190  }
191 
192  void set_fit_min_pT(double cutMinPT)
193  {
194  _fit_min_pT = cutMinPT;
195  }
196 
197 
199  {
201  }
202 
203  void set_over_write_svtxtrackmap(bool overWriteSvtxtrackmap)
204  {
205  _over_write_svtxtrackmap = overWriteSvtxtrackmap;
206  }
207 
208  bool is_use_truth_vertex() const
209  {
210  return _use_truth_vertex;
211  }
212 
213  void set_use_truth_vertex(bool useTruthVertex)
214  {
215  _use_truth_vertex = useTruthVertex;
216  }
217 
218  double get_vertex_min_ndf() const
219  {
220  return _vertex_min_ndf;
221  }
222 
223  void set_vertex_min_ndf(double vertexMinPT)
224  {
225  _vertex_min_ndf = vertexMinPT;
226  }
227  void set_track_map_name(const std::string &map_name) { _track_map_name = map_name; }
228 
230 
231 
233  void disable_layer( int layer, bool disabled = true );
234 
236  void set_disabled_layers( const std::set<int>& );
237 
239  void clear_disabled_layers();
240 
242  const std::set<int>& get_disabled_layers() const;
243 
245 
246  private:
248  int _event = 0;
249 
252 
255 
256  /*
257  * fit track with SvtxTrack as input seed.
258  * \param intrack Input SvtxTrack
259  * \param invertex Input Vertex, if fit track as a primary vertex
260  */
261  std::shared_ptr<PHGenFit::Track> ReFitTrack(PHCompositeNode*, const SvtxTrack* intrack, const SvtxVertex* invertex = nullptr);
262 
264  std::shared_ptr<SvtxTrack> MakeSvtxTrack(const SvtxTrack* svtxtrack, const std::shared_ptr<PHGenFit::Track>& genfit_track, const SvtxVertex* vertex = nullptr);
265 
267  bool FillSvtxVertexMap(
268  const std::vector<genfit::GFRaveVertex*>& rave_vertices,
269  const std::vector<genfit::Track*>& gf_tracks);
270 
271  bool pos_cov_uvn_to_rz(
272  const TVector3& u,
273  const TVector3& v,
274  const TVector3& n,
275  const TMatrixF& pos_in,
276  const TMatrixF& cov_in,
277  TMatrixF& pos_out,
278  TMatrixF& cov_out) const;
279 
281  const TVector3& u,
282  const TVector3& v,
283  const TVector3& n,
284  const TMatrixF& cov_in,
285  TMatrixF& cov_out) const;
286 
287  bool pos_cov_XYZ_to_RZ(
288  const TVector3& n,
289  const TMatrixF& pos_in,
290  const TMatrixF& cov_in,
291  TMatrixF& pos_out,
292  TMatrixF& cov_out) const;
293 
298  TMatrixF get_rotation_matrix(
299  const TVector3 x,
300  const TVector3 y,
301  const TVector3 z,
302  const TVector3 xp = TVector3(1., 0., 0.),
303  const TVector3 yp = TVector3(0., 1., 0.),
304  const TVector3 zp = TVector3(0., 0., 1.)) const;
305 
306  //bool _make_separate_nodes;
308 
310 
311  bool _fit_primary_tracks = false;
312 
314  bool _use_truth_vertex = false;
315 
317 
318  std::set<int> _disabled_layers;
319 
321  std::string _track_fitting_alg_name = "DafRef";
322 
324  double _fit_min_pT = 0.1;
325  double _vertex_min_ndf = 20;
326 
327  /*
328  need to use shared_ptr and not unique_ptr because root5 cint
329  requires the existence of a copy constructor, which the unique_ptr forbids
330  */
331  std::shared_ptr<PHGenFit::Fitter> _fitter;
332  std::shared_ptr<genfit::GFRaveVertexFactory> _vertex_finder;
333 
335  std::string _vertexing_method = "avr-smoothing:1-minweight:0.5-primcut:9-seccut:9";
336 
337  //PHRaveVertexFactory* _vertex_finder;
338 
343  std::string _track_map_name;
345 
350 
353  bool _do_eval = false;
354 
356  std::string _eval_outname = "PHGenFitTrkFitter_eval.root";
357 
358  TTree* _eval_tree = nullptr;
359  TClonesArray* _tca_particlemap = nullptr;
360  TClonesArray* _tca_vtxmap = nullptr;
361  TClonesArray* _tca_trackmap = nullptr;
362  TClonesArray* _tca_vertexmap = nullptr;
363  TClonesArray* _tca_trackmap_refit = nullptr;
364  TClonesArray* _tca_primtrackmap = nullptr;
365  TClonesArray* _tca_vertexmap_refit = nullptr;
366 
367  TTree* _cluster_eval_tree = nullptr;
374 
375  bool _do_evt_display = false;
376 
377  std::map<unsigned int, unsigned int> _rave_vertex_gf_track_map;
378 
379 };
380 
381 #endif