Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HelicalFitter.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file HelicalFitter.h
1 // Tell emacs that this is a C++ source
2 // -*- C++ -*-.
3 #ifndef HELICALFITTER_H
4 #define HELICALFITTER_H
5 
6 #include "AlignmentDefs.h"
7 
8 #include <fun4all/SubsysReco.h>
12 #include <phparameter/PHParameterInterface.h>
13 
16 
17 #include <string>
18 #include <map>
19 
20 class PHCompositeNode;
21 class TrackSeedContainer;
22 class TrackSeed;
24 class TF1;
25 class TNtuple;
26 class TFile;
28 class Mille;
29 class SvtxTrackSeed;
30 class SvtxTrackMap;
32 class SvtxTrack;
33 
35 {
36  public:
37 
38  HelicalFitter(const std::string &name = "HelicalFitter");
39 
40  ~HelicalFitter() override;
41 
42  void SetDefaultParameters() override;
43 
44  void set_field_dir(const double rescale)
45  {
46  _fieldDir = -1;
47  if(rescale > 0)
48  _fieldDir = 1;
49  }
50  void set_field(const std::string &field) { _field = field;}
51 
52  int InitRun(PHCompositeNode* topNode) override;
53 
54  int process_event(PHCompositeNode*) override;
55 
56  int End(PHCompositeNode*) override;
57 
58  void set_silicon_track_map_name(const std::string &map_name) { _silicon_track_map_name = map_name; }
59  void set_track_map_name(const std::string &map_name) { _track_map_name = map_name; }
60 
61  void set_use_event_vertex(bool flag){ use_event_vertex = flag; }
69  void set_intt_layer_fixed(unsigned int layer);
70  void set_mvtx_layer_fixed(unsigned int layer, unsigned int clamshell);
71  void set_tpc_sector_fixed(unsigned int region, unsigned int sector, unsigned int side);
72  void set_layer_param_fixed(unsigned int layer, unsigned int param);
74 
75  void set_fitted_subsystems(bool si, bool tpc, bool full) { fitsilicon = si; fittpc = tpc; fitfulltrack = full; }
76 
77  void set_error_inflation_factor(unsigned int layer, float factor)
78  {
79  _layerMisalignment.insert(std::make_pair(layer,factor));
80  }
81 
82  void set_vertex(Acts::Vector3 inVertex, Acts::Vector3 inVertex_uncertainty)
83  {
84  vertexPosition = inVertex;
85  vertexPosUncertainty = inVertex_uncertainty;
86  }
87 
88  void set_vtx_sigma(float x_sigma, float y_sigma)
89  {
90  vtx_sigma(0)= x_sigma;
91  vtx_sigma(1)= y_sigma;
92  }
93 
94 
95  // utility functions for analysis modules
96  std::vector<float> fitClusters(std::vector<Acts::Vector3>& global_vec, std::vector<TrkrDefs::cluskey> cluskey_vec);
97  void getTrackletClusters(TrackSeed *_track, std::vector<Acts::Vector3>& global_vec, std::vector<TrkrDefs::cluskey>& cluskey_vec);
98  Acts::Vector3 get_helix_pca(std::vector<float>& fitpars, Acts::Vector3 global);
99  void correctTpcGlobalPositions(std::vector<Acts::Vector3> global_vec, std::vector<TrkrDefs::cluskey> cluskey_vec);
100  unsigned int addSiliconClusters(std::vector<float>& fitpars, std::vector<Acts::Vector3>& global_vec, std::vector<TrkrDefs::cluskey>& cluskey_vec);
101 
102  void set_dca_cut(float dca) {dca_cut = dca;}
103 
104  private:
105 
107 
108  int GetNodes(PHCompositeNode* topNode);
109  int CreateNodes(PHCompositeNode* topNode);
110  void getTrackletClusterList(TrackSeed *tracklet, std::vector<TrkrDefs::cluskey>& cluskey_vec);
111 
114  Acts::Vector3 sensor_center, Acts::Vector3 sensor_normal);
115  std::pair<Acts::Vector3, Acts::Vector3> get_helix_tangent(const std::vector<float>& fitpars, Acts::Vector3 global);
116  Acts::Vector3 get_helix_surface_intersection(Surface surf, std::vector<float>& fitpars, Acts::Vector3 global);
117  Acts::Vector3 get_helix_surface_intersection(Surface surf, std::vector<float>& fitpars, Acts::Vector3 global, Acts::Vector3& pca, Acts::Vector3& tangent);
118 
119  Acts::Vector3 get_helix_vtx(Acts::Vector3 event_vtx, const std::vector<float>& fitpars);
120 
121  float convertTimeToZ(TrkrDefs::cluskey cluster_key, TrkrCluster *cluster);
122  void makeTpcGlobalCorrections(TrkrDefs::cluskey cluster_key, short int crossing, Acts::Vector3& global);
123 
125 
126  bool is_tpc_sector_fixed(unsigned int layer, unsigned int sector, unsigned int side);
127  bool is_mvtx_layer_fixed(unsigned int layer, unsigned int stave);
128  bool is_intt_layer_fixed(unsigned int layer);
129  bool is_layer_param_fixed(unsigned int layer, unsigned int param);
130 
131  void getLocalDerivativesXY(Surface surf, Acts::Vector3 global, const std::vector<float>& fitpars, float lcl_derivativeX[5], float lcl_derivativeY[5], unsigned int layer);
132 
133  void getLocalVtxDerivativesXY(SvtxTrack& track, Acts::Vector3 track_vtx, const std::vector<float>& fitpars, float lcl_derivativeX[5], float lcl_derivativeY[5]);
134 
135  void getGlobalDerivativesXY(Surface surf, Acts::Vector3 global, Acts::Vector3 fitpoint, const std::vector<float>& fitpars, float glb_derivativeX[6], float glbl_derivativeY[6], unsigned int layer);
136 
137  void getGlobalVtxDerivativesXY(SvtxTrack& track, Acts::Vector3 track_vtx, float glbl_derivativeX[3], float glbl_derivativeY[3]);
138 
139  void get_projectionXY(Surface surf, std::pair<Acts::Vector3, Acts::Vector3> tangent, Acts::Vector3& projX, Acts::Vector3& projY);
140  void get_projectionVtxXY(SvtxTrack& track, Acts::Vector3 event_vtx, Acts::Vector3& projX, Acts::Vector3& projY);
141 
142  float getVertexResidual(Acts::Vector3 vtx);
143 
144  void get_dca(SvtxTrack& track, float& dca3dxy, float& dca3dz, float& dca3dxysigma, float& dca3dzsigma, Acts::Vector3 vertex);
148 
149 
150 
155 
156  bool test_output = false;
157 
159 
160  std::set<std::pair<unsigned int,unsigned int>> fixed_mvtx_layers;
161  std::set<unsigned int> fixed_intt_layers;
162  std::set<unsigned int> fixed_sectors;
163  std::set<std::pair<unsigned int,unsigned int>> fixed_layer_params;
164 
165  // set default groups to lowest level
170 
173 
174  // TrackSeedContainer *_svtx_seed_map{nullptr};
179 
180  std::string data_outfilename = ("mille_helical_output_data_file.bin");
181  std::string steering_outfilename = ("steer_helical.txt");
182  std::string ntuple_outfilename = ("HF_ntuple.root");
183 
184  bool fitsilicon = true;
185  bool fittpc = false;
186  bool fitfulltrack = false;
187 
188  float dca_cut = 0.19; // cm
189 
192 
194  int _fieldDir = -1;
195  std::map<unsigned int, float> _layerMisalignment;
196 
197  std::string _track_map_name = "TpcTrackSeedContainer";
198  std::string _silicon_track_map_name = "SiliconTrackSeedContainer";
199 
200  bool make_ntuple = true;
201  TNtuple *ntp{nullptr};
202  TNtuple *track_ntp{nullptr};
203  TFile *fout{nullptr};
204 
205  bool use_event_vertex = false;
206 
207  int event = 0;
208 
212 
213 };
214 
215 #endif // HELICALFITTER_H