ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4TrackFastSim.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4TrackFastSim.h
1 // Tell emacs that this is a C++ source
2 // -*- C++ -*-.
10 #ifndef G4TRACKFASTSIM_PHG4TRACKFASTSIM_H
11 #define G4TRACKFASTSIM_PHG4TRACKFASTSIM_H
12 
13 #include <fun4all/SubsysReco.h>
14 
15 #include <TMatrixDSymfwd.h> // for TMatrixDSym
16 #include <TVector3.h>
17 
18 // #include <phgenfit/Track.h> is needed, it crashes on Ubuntu using
19 // singularity with local cvmfs install
20 // shared pointer later on uses this, forward declaration does not cut it
21 #include <phgenfit/Track.h>
22 
23 #include <gsl/gsl_rng.h>
24 
25 #include <climits> // for UINT_MAX
26 #include <map>
27 #include <string>
28 #include <vector>
29 #include <memory>
30 
31 class PHG4Hit;
32 class PHG4HitContainer;
33 class PHG4Particle;
34 class SvtxTrack;
35 class SvtxTrackMap;
36 class SvtxVertexMap;
37 class PHCompositeNode;
39 class PHParameters;
40 
41 namespace PHGenFit
42 {
43  class Fitter;
44  class Measurement;
45  class PlanarMeasurement;
46  class Track;
47 } /* namespace PHGenFit */
48 namespace genfit
49 {
50  class GFRaveVertex;
51  class GFRaveVertexFactory;
52 } /* namespace genfit */
53 
55 {
56  public:
58  {
61  };
62 
64  explicit PHG4TrackFastSim(const std::string& name = "PHG4TrackFastSim");
65 
67  ~PHG4TrackFastSim() override;
68 
70  int InitRun(PHCompositeNode*) override;
71 
73  int process_event(PHCompositeNode*) override;
74 
76  int End(PHCompositeNode*) override;
77 
78  bool is_do_evt_display() const
79  {
80  return m_DoEvtDisplayFlag;
81  }
82 
83  void set_do_evt_display(bool doEvtDisplay)
84  {
85  m_DoEvtDisplayFlag = doEvtDisplay;
86  }
87 
88  const std::string& get_fit_alg_name() const
89  {
90  return m_FitAlgoName;
91  }
92 
93  void set_fit_alg_name(const std::string& fitAlgName)
94  {
95  m_FitAlgoName = fitAlgName;
96  }
97 
98  const std::vector<std::string>& get_phg4hits_names() const
99  {
100  return m_PHG4HitsNames;
101  }
102 
113  const std::string& phg4hitsNames,
114  const DETECTOR_TYPE phg4dettype,
115  const float radres,
116  const float phires,
117  const float lonres,
118  const float eff,
119  const float noise)
120  {
121  m_PHG4HitsNames.push_back(phg4hitsNames);
122  m_phg4_detector_type.push_back(phg4dettype);
123  m_phg4_detector_radres.push_back(radres);
124  m_phg4_detector_phires.push_back(phires);
125  m_phg4_detector_lonres.push_back(lonres);
126  m_phg4_detector_hitfindeff.push_back(eff);
127  m_phg4_detector_noise.push_back(noise);
128  }
129 
130  // legacy interface for Babar calorimeter projections
131  void add_state_name(const std::string& stateName);
132 
133  // add saving of state at plane in z
134  void add_zplane_state(const std::string& stateName, const double zplane);
135 
136  void add_cylinder_state(const std::string& stateName, const double radius);
137 
138  const std::string& get_trackmap_out_name() const
139  {
140  return m_TrackmapOutNodeName;
141  }
142 
143  void set_trackmap_out_name(const std::string& trackmapOutName)
144  {
145  m_TrackmapOutNodeName = trackmapOutName;
146  }
147 
148  const std::string& get_sub_top_node_name() const
149  {
150  return m_SubTopnodeName;
151  }
152 
153  void set_sub_top_node_name(const std::string& subTopNodeName)
154  {
155  m_SubTopnodeName = subTopNodeName;
156  }
157 
159  {
161  }
162 
163  void set_use_vertex_in_fitting(bool useVertexInFitting)
164  {
165  m_UseVertexInFittingFlag = useVertexInFitting;
166  }
167 
169  {
170  return m_VertexXYResolution;
171  }
172 
173  void set_vertex_xy_resolution(double vertexXyResolution)
174  {
175  m_VertexXYResolution = vertexXyResolution;
176  }
177 
178  double get_vertex_z_resolution() const
179  {
180  return m_VertexZResolution;
181  }
182 
183  void set_vertex_z_resolution(double vertexZResolution)
184  {
185  m_VertexZResolution = vertexZResolution;
186  }
187 
189  {
190  return m_PrimaryAssumptionPid;
191  }
192 
193  void set_primary_assumption_pid(int primaryAssumptionPid)
194  {
195  m_PrimaryAssumptionPid = primaryAssumptionPid;
196  }
197 
198  void set_primary_tracking(int pTrk)
199  {
200  m_PrimaryTrackingFlag = pTrk;
201  }
202 
204  const std::string& get_vertexing_method() const
205  {
206  return m_VertexingMethod;
207  }
208 
210  void set_vertexing_method(const std::string& vertexingMethod)
211  {
212  m_VertexingMethod = vertexingMethod;
213  }
214 
215  double get_vertex_min_ndf() const
216  {
217  return m_VertexMinNdf;
218  }
219 
220  void set_vertex_min_ndf(double vertexMinNdf)
221  {
222  m_VertexMinNdf = vertexMinNdf;
223  }
224 
225  void enable_vertexing(const bool& b = true)
226  {
228  }
229 
230  void DisplayEvent() const;
231 
232  void Smearing(const bool b) { m_SmearingFlag = b; }
233 
234  private:
235  typedef std::map<const genfit::Track*, unsigned int> GenFitTrackMap;
236 
241 
246 
251  std::vector<PHGenFit::Measurement*>& meas_out,
252  SvtxTrack* track_out,
253  TVector3& seed_pos,
254  TVector3& seed_mom,
255  TMatrixDSym& seed_cov,
256  const bool do_smearing = true);
257 
258  PHGenFit::PlanarMeasurement* PHG4HitToMeasurementVerticalPlane(const PHG4Hit* g4hit, const double phi_resolution, const double r_resolution);
259 
260  PHGenFit::PlanarMeasurement* PHG4HitToMeasurementCylinder(const PHG4Hit* g4hit, const double phi_resolution, const double z_resolution);
261 
262  PHGenFit::Measurement* VertexMeasurement(const TVector3& vtx, double dxy, double dz);
263 
267  bool MakeSvtxTrack(SvtxTrack* track_out, const PHGenFit::Track* phgf_track_in,
268  const unsigned int truth_track_id = UINT_MAX,
269  const unsigned int nmeas = 0, const TVector3& vtx = TVector3(0.0, 0.0, 0.0));
270 
271  /*
272  * Fill SvtxVertexMap from GFRaveVertexes and Tracks
273  */
274  bool FillSvtxVertexMap(const std::vector<genfit::GFRaveVertex*>& rave_vertices,
275  const GenFitTrackMap& gf_tracks);
276 
277  protected:
278  // Pointers first
281 
286  genfit::GFRaveVertexFactory* m_RaveVertexFactory;
287 
290 
293 
294  std::vector<PHG4HitContainer*> m_PHG4HitContainer;
295  std::vector<std::string> m_PHG4HitsNames;
296  std::vector<DETECTOR_TYPE> m_phg4_detector_type;
297  std::vector<float> m_phg4_detector_radres;
298  std::vector<float> m_phg4_detector_phires;
299  std::vector<float> m_phg4_detector_lonres;
300  std::vector<float> m_phg4_detector_hitfindeff;
301  std::vector<float> m_phg4_detector_noise;
302 
304  std::map<std::string, std::pair<int, double>> m_ProjectionsMap;
305 
306  std::string m_SubTopnodeName;
309  std::string m_VertexingMethod;
310 
318  std::string m_FitAlgoName;
319 
323 
326 
328 
330 
333 
339 
342 
344 
346 };
347 
348 #endif /*__PHG4TrackFastSim_H__*/