37 TVector3 rd_dir = convert3vector(tot_rp_geom.
localToGlobalDirection(det_id, rp_topology_.GetStripReadoutAxisDir()));
39 TVector2
v(rd_dir.X(), rd_dir.Y());
46 return det_algebra_obj;
53 auto it = det_data_map_.find(det_id);
54 if (it != det_data_map_.end()) {
57 det_data_map_[det_id] = prepareReconstAlgebraData(det_id, tot_rp_geom);
58 return &det_data_map_[det_id];
77 vector<HitWithAlg> applicable_hits;
79 for (
auto &ds :
hits) {
80 unsigned int detId = ds.detId();
85 applicable_hits.push_back({detId, &
h, alg});
89 if (applicable_hits.size() < 5)
92 TMatrixD
H(applicable_hits.size(), 4);
93 TVectorD
V(applicable_hits.size());
94 TVectorD V_inv(applicable_hits.size());
95 TVectorD
U(applicable_hits.size());
97 for (
unsigned int i = 0;
i < applicable_hits.size(); ++
i) {
105 double var = applicable_hits[
i].hit->sigma();
108 V_inv[
i] = 1.0 /
var;
109 U[
i] = applicable_hits[
i].hit->position() - alg_obj->
rec_u_0_;
112 TMatrixD H_T_V_inv(TMatrixD::kTransposed,
H);
113 multiplyByDiagonalInPlace(H_T_V_inv, V_inv);
114 TMatrixD V_a(H_T_V_inv);
119 LogError(
"TotemRPLocalTrackFitterAlgorithm") <<
"Error in TotemRPLocalTrackFitterAlgorithm::fitTrack > "
120 <<
"Fit matrix is singular. Skipping.";
128 fitted_track.
setZ0(z_0);
133 for (
unsigned int i = 0;
i < applicable_hits.size(); ++
i) {
137 double sigma_str = applicable_hits[
i].hit->sigma();
138 double sigma_str_2 = sigma_str * sigma_str;
139 TVector2 fited_det_xy_point = fitted_track.
trackPoint(det_z);
140 double U_readout = applicable_hits[
i].hit->position() - alg_obj->
rec_u_0_;
141 double U_fited = (readout_dir *= fited_det_xy_point);
142 double residual = U_fited - U_readout;
143 TMatrixD V_T_Cov_X_Y(1, 2);
144 V_T_Cov_X_Y(0, 0) = readout_dir.X();
145 V_T_Cov_X_Y(0, 1) = readout_dir.Y();
147 double fit_strip_var = V_T_Cov_X_Y_mult(0, 0) * readout_dir.X() + V_T_Cov_X_Y_mult(0, 1) * readout_dir.Y();
148 double pull_normalization =
sqrt(sigma_str_2 - fit_strip_var);
149 double pull = residual / pull_normalization;
151 Chi_2 += residual * residual / sigma_str_2;
154 *(applicable_hits[
i].
hit), TVector3(fited_det_xy_point.X(), fited_det_xy_point.Y(), det_z), residual, pull);
155 fitted_track.
addHit(applicable_hits[
i].detId, hit_point);
166 for (
int i = 0;
i <
mt.GetNrows(); ++
i) {
167 for (
int j = 0;
j <
mt.GetNcols(); ++
j) {