EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
B0TrackFastSim.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file B0TrackFastSim.h
1 // Tell emacs that this is a C++ source
2 // -*- C++ -*-.
10 #ifndef G4TRACKFASTSIM_B0TRACKFASTSIM_H
11 #define G4TRACKFASTSIM_B0TRACKFASTSIM_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/Fitter.h>
22 #include <phgenfit/Measurement.h> // for Measurement
23 #include <phgenfit/PlanarMeasurement.h>
24 #include <phgenfit/SpacepointMeasurement.h>
25 #include <phgenfit/Track.h>
26 
27 #include <gsl/gsl_rng.h>
28 
29 #include <climits> // for UINT_MAX
30 #include <map>
31 #include <memory>
32 #include <set>
33 #include <string>
34 #include <vector>
35 
36 class PHG4Hit;
37 class PHG4HitContainer;
38 class PHG4Particle;
39 class SvtxTrack;
40 class SvtxTrackMap;
41 class SvtxVertexMap;
42 class PHCompositeNode;
44 class PHParameters;
45 
46 namespace PHGenFit
47 {
48 class Fitter;
49 class Measurement;
50 class PlanarMeasurement;
51 class Track;
52 } /* namespace PHGenFit */
53 namespace genfit
54 {
55 class GFRaveVertex;
56 class GFRaveVertexFactory;
57 } /* namespace genfit */
58 
59 class B0TrackFastSim : public SubsysReco
60 {
61  public:
63  {
66  };
67 
69  explicit B0TrackFastSim(const std::string& name = "B0TrackFastSim");
70 
72  ~B0TrackFastSim() override;
73 
75  int InitRun(PHCompositeNode*) override;
76 
78  int process_event(PHCompositeNode*) override;
79 
81  int End(PHCompositeNode*) override;
82 
83  bool is_do_evt_display() const
84  {
85  return m_DoEvtDisplayFlag;
86  }
87 
88  void set_do_evt_display(bool doEvtDisplay)
89  {
90  m_DoEvtDisplayFlag = doEvtDisplay;
91  }
92 
93  const std::string& get_fit_alg_name() const
94  {
95  return m_FitAlgoName;
96  }
97 
98  void set_fit_alg_name(const std::string& fitAlgName)
99  {
100  m_FitAlgoName = fitAlgName;
101  }
102 
103  const std::vector<std::string>& get_phg4hits_names() const
104  {
105  return m_PHG4HitsNames;
106  }
107 
118  const std::string& phg4hitsNames,
119  const DETECTOR_TYPE phg4dettype,
120  const float radres,
121  const float phires,
122  const float lonres,
123  const float eff,
124  const float noise)
125  {
126  m_PHG4HitsNames.push_back(phg4hitsNames);
127  m_phg4_detector_type.push_back(phg4dettype);
128  m_phg4_detector_radres.push_back(radres);
129  m_phg4_detector_phires.push_back(phires);
130  m_phg4_detector_lonres.push_back(lonres);
131  m_phg4_detector_hitfindeff.push_back(eff);
132  m_phg4_detector_noise.push_back(noise);
133  }
134 
135  // legacy interface for Babar calorimeter projections
136  void add_state_name(const std::string& stateName);
137 
138  // add saving of state at plane in z
139  void add_zplane_state(const std::string& stateName, const double zplane);
140 
141  void add_cylinder_state(const std::string& stateName, const double radius);
142 
143  const std::string& get_trackmap_out_name() const
144  {
145  return m_TrackmapOutNodeName;
146  }
147 
148  void set_trackmap_out_name(const std::string& trackmapOutName)
149  {
150  m_TrackmapOutNodeName = trackmapOutName;
151  }
152 
153  const std::string& get_sub_top_node_name() const
154  {
155  return m_SubTopnodeName;
156  }
157 
158  void set_sub_top_node_name(const std::string& subTopNodeName)
159  {
160  m_SubTopnodeName = subTopNodeName;
161  }
162 
164  {
166  }
167 
168  void set_use_vertex_in_fitting(bool useVertexInFitting)
169  {
170  m_UseVertexInFittingFlag = useVertexInFitting;
171  }
172 
174  {
175  return m_VertexXYResolution;
176  }
177 
178  void set_vertex_xy_resolution(double vertexXyResolution)
179  {
180  m_VertexXYResolution = vertexXyResolution;
181  }
182 
183  double get_vertex_z_resolution() const
184  {
185  return m_VertexZResolution;
186  }
187 
188  void set_vertex_z_resolution(double vertexZResolution)
189  {
190  m_VertexZResolution = vertexZResolution;
191  }
192 
194  {
195  return m_PrimaryAssumptionPid;
196  }
197 
198  void set_primary_assumption_pid(int primaryAssumptionPid)
199  {
200  m_PrimaryAssumptionPid = primaryAssumptionPid;
201  }
202 
203  void set_primary_tracking(int pTrk)
204  {
205  m_PrimaryTrackingFlag = pTrk;
206  }
207 
209  const std::string& get_vertexing_method() const
210  {
211  return m_VertexingMethod;
212  }
213 
215  void set_vertexing_method(const std::string& vertexingMethod)
216  {
217  m_VertexingMethod = vertexingMethod;
218  }
219 
220  double get_vertex_min_ndf() const
221  {
222  return m_VertexMinNdf;
223  }
224 
225  void set_vertex_min_ndf(double vertexMinNdf)
226  {
227  m_VertexMinNdf = vertexMinNdf;
228  }
229 
230  void enable_vertexing(const bool& b = true)
231  {
232  m_DoVertexingFlag = b;
233  }
234 
235  void DisplayEvent() const;
236 
237  void Smearing(const bool b) { m_SmearingFlag = b; }
238 
239  private:
240  typedef std::map<const genfit::Track*, unsigned int> GenFitTrackMap;
241 
246 
251 
256  std::vector<PHGenFit::Measurement*>& meas_out,
257  SvtxTrack* track_out,
258  TVector3& seed_pos,
259  TVector3& seed_mom,
260  TMatrixDSym& seed_cov,
261  const bool do_smearing = true);
262 
263  PHGenFit::PlanarMeasurement* PHG4HitToMeasurementVerticalPlane(const PHG4Hit* g4hit, const double phi_resolution, const double r_resolution);
264 
265  PHGenFit::PlanarMeasurement* PHG4HitToMeasurementCylinder(const PHG4Hit* g4hit, const double phi_resolution, const double z_resolution);
266 
267  PHGenFit::Measurement* VertexMeasurement(const TVector3& vtx, double dxy, double dz);
268 
272  bool MakeSvtxTrack(SvtxTrack* track_out, const PHGenFit::Track* phgf_track_in,
273  const unsigned int truth_track_id = UINT_MAX,
274  const unsigned int nmeas = 0, const TVector3& vtx = TVector3(0.0, 0.0, 0.0));
275 
276  /*
277  * Fill SvtxVertexMap from GFRaveVertexes and Tracks
278  */
279  bool FillSvtxVertexMap(const std::vector<genfit::GFRaveVertex*>& rave_vertices,
280  const GenFitTrackMap& gf_tracks);
281 
282  protected:
283  // Pointers first
286 
292 
295 
298 
299  std::vector<PHG4HitContainer*> m_PHG4HitContainer;
300  std::vector<std::string> m_PHG4HitsNames;
301  std::vector<DETECTOR_TYPE> m_phg4_detector_type;
302  std::vector<float> m_phg4_detector_radres;
303  std::vector<float> m_phg4_detector_phires;
304  std::vector<float> m_phg4_detector_lonres;
305  std::vector<float> m_phg4_detector_hitfindeff;
306  std::vector<float> m_phg4_detector_noise;
307 
309  std::map<std::string, std::pair<int, double>> m_ProjectionsMap;
310 
311  std::string m_SubTopnodeName;
314  std::string m_VertexingMethod;
315 
323  std::string m_FitAlgoName;
324 
328 
331 
333 
335 
338 
344 
347 
349 
351 
352  static const std::set<std::string> reserved_cylinder_projection_names;
353  static const std::set<std::string> reserved_zplane_projection_names;
354 };
355 
356 #endif /*__PHG4TrackFastSim_H__*/