~christopher-hunt08/maus/maus_integrated_kalman

« back to all changes in this revision

Viewing changes to src/common_cpp/DataStructure/SciFiTrackPoint.cc

  • Committer: Durga Rajaram
  • Date: 2014-07-16 15:13:05 UTC
  • mfrom: (659.1.92 cand)
  • Revision ID: durga@fnal.gov-20140716151305-q27rv1y9p03v9lks
Tags: MAUS-v0.9, MAUS-v0.9.0
MAUS-v0.9.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
namespace MAUS {
21
21
 
22
 
SciFiTrackPoint::SciFiTrackPoint() : _tracker(-1),
 
22
SciFiTrackPoint::SciFiTrackPoint() : _spill(-1),
 
23
                                     _event(-1),
 
24
                                     _tracker(-1),
23
25
                                     _station(-1),
24
26
                                     _plane(-1),
25
27
                                     _channel(666),
26
28
                                     _f_chi2(-1),
27
29
                                     _s_chi2(-1),
28
 
                                     _x(0.),
29
 
                                     _px(0.),
30
 
                                     _y(0.),
31
 
                                     _py(0.),
32
 
                                     _pz(0.),
 
30
                                     _pos(ThreeVector(0, 0, 0)),
 
31
                                     _mom(ThreeVector(0, 0, 0)),
33
32
                                     _pull(-1),
34
33
                                     _residual(-1),
35
 
                                     _smoothed_residual(-1),
36
 
                                     _mc_x(0.),
37
 
                                     _mc_px(0.),
38
 
                                     _mc_y(0.),
39
 
                                     _mc_py(0.),
40
 
                                     _mc_pz(0.) {
 
34
                                     _smoothed_residual(-1) {
 
35
  _cluster = new TRef();
41
36
}
42
37
 
43
 
SciFiTrackPoint::~SciFiTrackPoint() {}
 
38
SciFiTrackPoint::~SciFiTrackPoint() {
 
39
  delete _cluster;
 
40
}
44
41
 
45
42
SciFiTrackPoint::SciFiTrackPoint(const KalmanState *kalman_site) {
46
43
  int id = kalman_site->id();
49
46
  } else {
50
47
    _tracker = 1;
51
48
  }
 
49
  _spill = kalman_site->spill();
 
50
  _event = kalman_site->event();
 
51
 
52
52
  id = abs(id);
53
53
  _station = ((id-1)/3)+1;
54
54
  _plane   = (id-1)%3;
61
61
  int dimension = state_vector.GetNrows();
62
62
 
63
63
  if ( dimension == 4 ) {
64
 
    _pz = 200; // MeV/c
65
 
    _x  = state_vector(0, 0);
66
 
    _px = state_vector(1, 0);
67
 
    _y  = state_vector(2, 0);
68
 
    _py = state_vector(3, 0);
 
64
    _pos.setZ(kalman_site->z());
 
65
    _mom.setZ(200.0); // MeV/c
 
66
    _pos.setX(state_vector(0, 0));
 
67
    _mom.setX(state_vector(1, 0));
 
68
    _pos.setY(state_vector(2, 0));
 
69
    _mom.setY(state_vector(3, 0));
69
70
  } else if ( dimension == 5 ) {
70
 
    _x  = state_vector(0, 0);
71
 
    _px = state_vector(1, 0)/fabs(state_vector(4, 0));
72
 
    _y  = state_vector(2, 0);
73
 
    _py = state_vector(3, 0)/fabs(state_vector(4, 0));
74
 
    _pz = 1./fabs(state_vector(4, 0));
 
71
    _pos.setX(state_vector(0, 0));
 
72
    _mom.setX(state_vector(1, 0)/fabs(state_vector(4, 0)));
 
73
    _pos.setY(state_vector(2, 0));
 
74
    _mom.setY(state_vector(3, 0)/fabs(state_vector(4, 0)));
 
75
    _pos.setZ(kalman_site->z());
 
76
    _mom.setZ(1./fabs(state_vector(4, 0)));
75
77
  }
76
78
 
77
 
  ThreeVector mc_mom = kalman_site->true_momentum();
78
 
  ThreeVector mc_pos = kalman_site->true_position();
79
 
  _mc_x  = mc_pos.x();
80
 
  _mc_px = mc_mom.x();
81
 
  _mc_y  = mc_pos.y();
82
 
  _mc_py = mc_mom.y();
83
 
  _mc_pz = mc_mom.z();
84
 
 
85
79
  _pull              = kalman_site->residual(KalmanState::Projected)(0, 0);
86
80
  _residual          = kalman_site->residual(KalmanState::Filtered)(0, 0);
87
81
  _smoothed_residual = kalman_site->residual(KalmanState::Smoothed)(0, 0);
92
86
  double* matrix_elements = C.GetMatrixArray();
93
87
  std::vector<double> covariance(matrix_elements, matrix_elements+num_elements);
94
88
  _covariance = covariance;
 
89
 
 
90
  // std::cerr << "Adding cluster with address " << kalman_site->cluster() << " to track point\n";
 
91
  _cluster = new TRef(kalman_site->cluster());
95
92
}
96
93
 
97
94
SciFiTrackPoint::SciFiTrackPoint(const SciFiTrackPoint &point) {
 
95
  _spill = point.spill();
 
96
  _event = point.event();
 
97
 
98
98
  _tracker = point.tracker();
99
99
  _station = point.station();
100
100
  _plane   = point.plane();
103
103
  _f_chi2 = point.f_chi2();
104
104
  _s_chi2 = point.s_chi2();
105
105
 
106
 
  _x  = point.x();
107
 
  _px = point.px();
108
 
  _y  = point.y();
109
 
  _py = point.py();
110
 
  _pz = point.pz();
111
 
 
112
 
  _mc_x  = point.mc_x();
113
 
  _mc_px = point.mc_px();
114
 
  _mc_y  = point.mc_y();
115
 
  _mc_py = point.mc_py();
116
 
  _mc_pz = point.mc_pz();
 
106
  _pos = point.pos();
 
107
  _mom = point.mom();
117
108
 
118
109
  _pull              = point.pull();
119
110
  _residual          = point.residual();
120
111
  _smoothed_residual = point.smoothed_residual();
121
112
 
122
113
  _covariance = point.covariance();
 
114
  _cluster = new TRef(*point.get_cluster());
123
115
}
124
116
 
125
117
SciFiTrackPoint& SciFiTrackPoint::operator=(const SciFiTrackPoint &rhs) {
126
118
  if ( this == &rhs ) {
127
119
    return *this;
128
120
  }
 
121
  _spill   = rhs.spill();
 
122
  _event   = rhs.event();
129
123
  _tracker = rhs.tracker();
130
124
  _station = rhs.station();
131
125
  _plane   = rhs.plane();
134
128
  _f_chi2 = rhs.f_chi2();
135
129
  _s_chi2 = rhs.s_chi2();
136
130
 
137
 
  _x  = rhs.x();
138
 
  _px = rhs.px();
139
 
  _y  = rhs.y();
140
 
  _py = rhs.py();
141
 
  _pz = rhs.pz();
142
 
 
143
 
  _mc_x  = rhs.mc_x();
144
 
  _mc_px = rhs.mc_px();
145
 
  _mc_y  = rhs.mc_y();
146
 
  _mc_py = rhs.mc_py();
147
 
  _mc_pz = rhs.mc_pz();
 
131
  _pos = rhs.pos();
 
132
  _mom = rhs.mom();
148
133
 
149
134
  _pull              = rhs.pull();
150
135
  _residual          = rhs.residual();
152
137
 
153
138
  _covariance= rhs.covariance();
154
139
 
 
140
  if (_cluster) delete _cluster;
 
141
  _cluster = new TRef(*rhs.get_cluster());
 
142
 
155
143
  return *this;
156
144
}
157
145