Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SvtxTrack_v2.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SvtxTrack_v2.h
1 #ifndef TRACKBASEHISTORIC_SVTXTRACKV2_H
2 #define TRACKBASEHISTORIC_SVTXTRACKV2_H
3 
4 #include "SvtxTrack.h"
5 #include "SvtxTrackState.h"
6 
7 #include <trackbase/TrkrDefs.h>
8 
9 #include <cmath>
10 #include <cstddef> // for size_t
11 #include <iostream>
12 #include <map>
13 #include <utility> // for pair
14 
15 class PHObject;
16 
17 class SvtxTrack_v2: public SvtxTrack
18 {
19  public:
20  SvtxTrack_v2();
21 
22  //* base class copy constructor
23  SvtxTrack_v2( const SvtxTrack& );
24 
25  //* copy constructor
26  SvtxTrack_v2(const SvtxTrack_v2& );
27 
28  //* assignment operator
29  SvtxTrack_v2& operator=(const SvtxTrack_v2& track);
30 
31  //* destructor
32  ~SvtxTrack_v2() override;
33 
34  // The "standard PHObject response" functions...
35  void identify(std::ostream& os = std::cout) const override;
36  void Reset() override { *this = SvtxTrack_v2(); }
37  int isValid() const override;
38  PHObject* CloneMe() const override { return new SvtxTrack_v2(*this); }
39 
41  using PHObject::CopyFrom;
42  // copy content from base class
43  void CopyFrom( const SvtxTrack& ) override;
44  void CopyFrom( SvtxTrack* source ) override
45  { CopyFrom( *source ); }
46 
47  //
48  // basic track information ---------------------------------------------------
49  //
50 
51  unsigned int get_id() const override { return _track_id; }
52  void set_id(unsigned int id) override { _track_id = id; }
53 
54  unsigned int get_vertex_id() const override { return _vertex_id; }
55  void set_vertex_id(unsigned int id) override { _vertex_id = id; }
56 
57  bool get_positive_charge() const override { return _is_positive_charge; }
58  void set_positive_charge(bool ispos) override { _is_positive_charge = ispos; }
59 
60  int get_charge() const override { return (get_positive_charge()) ? 1 : -1; }
61  void set_charge(int charge) override { (charge > 0) ? set_positive_charge(true) : set_positive_charge(false); }
62 
63  float get_chisq() const override { return _chisq; }
64  void set_chisq(float chisq) override { _chisq = chisq; }
65 
66  unsigned int get_ndf() const override { return _ndf; }
67  void set_ndf(int ndf) override { _ndf = ndf; }
68 
69  float get_quality() const override { return (_ndf != 0) ? _chisq / _ndf : NAN; }
70 
71  float get_dca() const override { return _dca; }
72  void set_dca(float dca) override { _dca = dca; }
73 
74  float get_dca_error() const override { return _dca_error; }
75  void set_dca_error(float dca_error) override { _dca_error = dca_error; }
76 
77  float get_dca2d() const override { return _dca2d; }
78  void set_dca2d(float dca2d) override { _dca2d = dca2d; }
79 
80  float get_dca2d_error() const override { return _dca2d_error; }
81  void set_dca2d_error(float error) override { _dca2d_error = error; }
82 
83  float get_dca3d_xy() const override { return _dca3d_xy; }
84  void set_dca3d_xy(float dcaxy) override { _dca3d_xy = dcaxy; }
85 
86  float get_dca3d_xy_error() const override { return _dca3d_xy_error; }
87  void set_dca3d_xy_error(float error) override { _dca3d_xy_error = error; }
88 
89  float get_dca3d_z() const override { return _dca3d_z; }
90  void set_dca3d_z(float dcaz) override { _dca3d_z = dcaz; }
91 
92  float get_dca3d_z_error() const override { return _dca3d_z_error; }
93  void set_dca3d_z_error(float error) override { _dca3d_z_error = error; }
94 
95  float get_x() const override { return _states.find(0.0)->second->get_x(); }
96  void set_x(float x) override { _states[0.0]->set_x(x); }
97 
98  float get_y() const override { return _states.find(0.0)->second->get_y(); }
99  void set_y(float y) override { _states[0.0]->set_y(y); }
100 
101  float get_z() const override { return _states.find(0.0)->second->get_z(); }
102  void set_z(float z) override { _states[0.0]->set_z(z); }
103 
104  float get_pos(unsigned int i) const override { return _states.find(0.0)->second->get_pos(i); }
105 
106  float get_px() const override { return _states.find(0.0)->second->get_px(); }
107  void set_px(float px) override { _states[0.0]->set_px(px); }
108 
109  float get_py() const override { return _states.find(0.0)->second->get_py(); }
110  void set_py(float py) override { _states[0.0]->set_py(py); }
111 
112  float get_pz() const override { return _states.find(0.0)->second->get_pz(); }
113  void set_pz(float pz) override { _states[0.0]->set_pz(pz); }
114 
115  float get_mom(unsigned int i) const override { return _states.find(0.0)->second->get_mom(i); }
116 
117  float get_p() const override { return sqrt(pow(get_px(), 2) + pow(get_py(), 2) + pow(get_pz(), 2)); }
118  float get_pt() const override { return sqrt(pow(get_px(), 2) + pow(get_py(), 2)); }
119  float get_eta() const override { return asinh(get_pz() / get_pt()); }
120  float get_phi() const override { return atan2(get_py(), get_px()); }
121 
122  float get_error(int i, int j) const override { return _states.find(0.0)->second->get_error(i, j); }
123  void set_error(int i, int j, float value) override { return _states[0.0]->set_error(i, j, value); }
124 
125  //
126  // state methods -------------------------------------------------------------
127  //
128  bool empty_states() const override { return _states.empty(); }
129  size_t size_states() const override { return _states.size(); }
130  size_t count_states(float pathlength) const override { return _states.count(pathlength); }
131  // cppcheck-suppress virtualCallInConstructor
132  void clear_states() override;
133 
134  const SvtxTrackState* get_state(float pathlength) const override;
135  SvtxTrackState* get_state(float pathlength) override;
137  size_t erase_state(float pathlength) override;
138 
139  ConstStateIter begin_states() const override { return _states.begin(); }
140  ConstStateIter find_state(float pathlength) const override { return _states.find(pathlength); }
141  ConstStateIter end_states() const override { return _states.end(); }
142 
143  StateIter begin_states() override { return _states.begin(); }
144  StateIter find_state(float pathlength) override { return _states.find(pathlength); }
145  StateIter end_states() override { return _states.end(); }
146 
147  //
148  // associated cluster ids methods --------------------------------------------
149  //
150 
151  // needed by old tracking
152  void clear_clusters() override { _cluster_ids.clear(); }
153  bool empty_clusters() const override { return _cluster_ids.empty(); }
154  size_t size_clusters() const override { return _cluster_ids.size(); }
155 
156  void insert_cluster(unsigned int clusterid) override { _cluster_ids.insert(clusterid); }
157  size_t erase_cluster(unsigned int clusterid) override { return _cluster_ids.erase(clusterid); }
158  ConstClusterIter begin_clusters() const override { return _cluster_ids.begin(); }
159  ConstClusterIter find_cluster(unsigned int clusterid) const override { return _cluster_ids.find(clusterid); }
160  ConstClusterIter end_clusters() const override { return _cluster_ids.end(); }
161  ClusterIter find_cluster(unsigned int clusterid) override { return _cluster_ids.find(clusterid); }
162  ClusterIter begin_clusters() override { return _cluster_ids.begin(); }
163  ClusterIter end_clusters() override { return _cluster_ids.end(); }
164 
165  // needed by new tracking
166  void clear_cluster_keys() override { _cluster_keys.clear(); }
167  bool empty_cluster_keys() const override { return _cluster_keys.empty(); }
168  size_t size_cluster_keys() const override { return _cluster_keys.size(); }
169 
170  void insert_cluster_key(TrkrDefs::cluskey clusterid) override { _cluster_keys.insert(clusterid); }
171  size_t erase_cluster_key(TrkrDefs::cluskey clusterid) override { return _cluster_keys.erase(clusterid); }
172  ConstClusterKeyIter find_cluster_key(TrkrDefs::cluskey clusterid) const override { return _cluster_keys.find(clusterid); }
173  ConstClusterKeyIter begin_cluster_keys() const override { return _cluster_keys.begin(); }
174  ConstClusterKeyIter end_cluster_keys() const override { return _cluster_keys.end(); }
175  ClusterKeyIter find_cluster_keys(unsigned int clusterid) override { return _cluster_keys.find(clusterid); }
176  ClusterKeyIter begin_cluster_keys() override { return _cluster_keys.begin(); }
177  ClusterKeyIter end_cluster_keys() override { return _cluster_keys.end(); }
178 
179  //
180  // calo projection methods ---------------------------------------------------
181  //
182  float get_cal_dphi(CAL_LAYER layer) const override;
183  void set_cal_dphi(CAL_LAYER layer, float dphi) override { _cal_dphi[layer] = dphi; }
184 
185  float get_cal_deta(CAL_LAYER layer) const override;
186  void set_cal_deta(CAL_LAYER layer, float deta) override { _cal_deta[layer] = deta; }
187 
188  float get_cal_energy_3x3(CAL_LAYER layer) const override;
189  void set_cal_energy_3x3(CAL_LAYER layer, float energy_3x3) override { _cal_energy_3x3[layer] = energy_3x3; }
190 
191  float get_cal_energy_5x5(CAL_LAYER layer) const override;
192  void set_cal_energy_5x5(CAL_LAYER layer, float energy_5x5) override { _cal_energy_5x5[layer] = energy_5x5; }
193 
194  unsigned int get_cal_cluster_id(CAL_LAYER layer) const override;
195  void set_cal_cluster_id(CAL_LAYER layer, unsigned int id) override { _cal_cluster_id[layer] = id; }
196 
199 
200  float get_cal_cluster_e(CAL_LAYER layer) const override;
201  void set_cal_cluster_e(CAL_LAYER layer, float e) override { _cal_cluster_e[layer] = e; }
202 
203  // ACTS track information for use by ACTS modules only
204  float get_acts_covariance(unsigned int i, unsigned int j) const override {return _acts_trajectory_covariance[i][j]; }
205  void set_acts_covariance(unsigned int i, unsigned int j, float value) override { _acts_trajectory_covariance[i][j] = value; }
206 
207  private:
208 
210  float _acts_trajectory_covariance[6][6] = {};
211 
212  // track information
213  unsigned int _track_id = UINT_MAX;
214  unsigned int _vertex_id = UINT_MAX;
215  bool _is_positive_charge = false;
216  float _chisq = NAN;
217  unsigned int _ndf = 0;
218 
219  // extended track information (non-primary tracks only)
220  float _dca = NAN;
221  float _dca_error = NAN;
222  float _dca2d = NAN;
223  float _dca2d_error = NAN;
224  float _dca3d_xy = NAN;
225  float _dca3d_xy_error = NAN;
226  float _dca3d_z = NAN;
227  float _dca3d_z_error = NAN;
228 
229  // extended track information (primary tracks only)
230 
231  // track state information
232  StateMap _states; //< path length => state object
233 
234  // cluster contents
237 
238  // calorimeter matches
239  std::map<CAL_LAYER, float> _cal_dphi;
240  std::map<CAL_LAYER, float> _cal_deta;
241  std::map<CAL_LAYER, float> _cal_energy_3x3;
242  std::map<CAL_LAYER, float> _cal_energy_5x5;
243  std::map<CAL_LAYER, int> _cal_cluster_id;
244  std::map<CAL_LAYER, TrkrDefs::cluskey> _cal_cluster_key;
245  std::map<CAL_LAYER, float> _cal_cluster_e;
246 
248 };
249 
250 #endif