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