12 float f1, f2, f3, f4, f5, Y, chi2;
14 for (Int_t
i = 0;
i < 4;
i++) {
17 for (Int_t j = 0; j < 4; j++) {
22 const int N = triplet.
N();
28 cout <<
" **************** Param before Refit_1 ************ " << endl;
32 cout <<
" param.Tx()[0] " << param.Tx()[0] <<
" param.Ty()[0] " << param.Ty()[0] <<
" param.QP()[0] " << param.QP()[0] <<
" param.X()[0] " << param.
X()[0] <<
" param.Y()[0] " 33 << param.
Y()[0] <<
" param.Z()[0] " << param.
Z()[0] <<
" param.Chi2()[0] " << param.
Chi2()[0] <<
" param.NDF()[0] " << param.
NDF()[0] << endl;
37 Bx = param.
X()[0] - param.Tx()[0] * param.
Z()[0];
38 By = param.
Y()[0] - param.Ty()[0] * param.
Z()[0];
45 cout <<
" **************** Before Refit_1 ************ " << endl;
46 cout <<
" Tx " << Tx << endl;
47 cout <<
" Ty " << Ty << endl;
48 cout <<
" Bx " << Bx << endl;
49 cout <<
" By " << By << endl;
53 for (
int it = 0; it < 3; it++) {
55 for (Int_t
i = 0;
i < 4;
i++) {
58 for (Int_t j = 0; j < 4; j++) {
63 for (
int ihit = 0; ihit < N; ihit++) {
64 const TESV &index = triplet.
IHit(ihit);
65 cout <<
"index.s station " << index.
s <<
" index.e " << index.
e << endl;
68 const FTSCAHit &hit = hits_st[index.
e[0]];
71 cout <<
"chtck hit.IStation()" << ISta << endl;
78 cout <<
" ************************************************* " << endl;
84 cout <<
" hit.R() " << hit.R() <<
" hit.ErrR() " <<
sqrt(hit.Err2R()) << endl;
85 cout <<
" X " << hit.
X1() <<
" Y " << hit.
X2() <<
" Z " << hit.
X0() << endl;
88 const float s = station.
f.
sin;
90 const float c = station.
f.
cos;
92 cout <<
" s " << s <<
" c " << c << endl;
98 float R_MC = (c * (Tx_MC * hit.
X0() + Bx_MC - hit.
X1()) + s * (Ty_MC * hit.
X0() + By_MC - hit.
X2())) /
sqrt(1.
f + (c * Tx_MC + s * Ty_MC) * (c * Tx_MC + s * Ty_MC));
103 float Diff_D_R = D2_mc_hit - hit.R();
104 cout <<
" D2_mc_hit " << D2_mc_hit <<
" hit.R() " << hit.R() <<
" Diff_D_R " << Diff_D_R << endl;
110 diff_R = R_MC - hit.R();
112 diff_R = R_MC + hit.R();
114 cout <<
" diff_R " << diff_R << endl;
117 (c * (Tx_MC * hit_1.
point_Z + Bx_MC - hit.
X1()) + s * (Ty_MC * hit_1.
point_Z + By_MC - hit.
X2())) /
sqrt(1.
f + (c * Tx_MC + s * Ty_MC) * (c * Tx_MC + s * Ty_MC));
121 diff_R_1 = R_MC_1 - hit.R();
123 diff_R_1 = R_MC_1 + hit.R();
125 cout <<
" diff_R_1 " << diff_R_1 << endl;
127 float R_MC_2 = (c * (hit_1.
point_X - hit.
X1()) + s * (hit_1.
point_Y - hit.
X2())) /
sqrt(1.
f + (c * Tx_MC + s * Ty_MC) * (c * Tx_MC + s * Ty_MC));
129 cout <<
" R_MC_2 " << R_MC_2 <<
" hit.R()" << hit.R() << endl;
133 diff_R_2 = R_MC_2 + hit.R();
135 diff_R_2 = R_MC_2 - hit.R();
137 cout <<
" diff_R_2 " << diff_R_2 << endl;
150 float Y_point_of_wire = 0.f;
153 float fX = Tx * hit.
X0() + Bx;
154 float fY = Ty * hit.
X0() + By;
156 cout <<
" Tx " << Tx <<
" Bx " << Bx <<
" Ty " << Ty <<
" By " << By << endl;
158 float tx = c * Tx + s * Ty;
159 float rCorrection =
sqrt(1.
f + tx * tx);
161 float Diff = c * (fX - hit.
X1()) + s * (fY - hit.
X2());
168 cout <<
" Diff " << Diff <<
" Diff_mc " << Diff_mc << endl;
170 cout <<
" ************************************************* " << endl;
181 float err =
sqrt(hit.Err2R());
184 Y = (R - (Diff / rCorrection)) / err;
187 f1 = (c * hit.
X0() / rCorrection - c * Diff * tx / (rCorrection * rCorrection * rCorrection)) / err;
192 f2 = c / (rCorrection * err);
195 f3 = (s * hit.
X0() / rCorrection - s * Diff * tx / (rCorrection * rCorrection * rCorrection)) / err;
198 f4 = s / (rCorrection * err);
204 H(0, 0) = H(0, 0) + f1 * f1;
205 H(0, 1) = H(0, 1) + f1 * f2;
206 H(0, 2) = H(0, 2) + f1 * f3;
207 H(0, 3) = H(0, 3) + f1 * f4;
209 H(1, 1) = H(1, 1) + f2 * f2;
210 H(1, 2) = H(1, 2) + f2 * f3;
211 H(1, 3) = H(1, 3) + f2 * f4;
214 H(2, 2) = H(2, 2) + f3 * f3;
215 H(2, 3) = H(2, 3) + f3 * f4;
219 H(3, 3) = H(2, 3) + f4 * f4;
221 HY(0, 0) = HY(0, 0) + Y * f1;
222 HY(1, 0) = HY(1, 0) + Y * f2;
223 HY(2, 0) = HY(2, 0) + Y * f3;
224 HY(3, 0) = HY(3, 0) + Y * f4;
233 cout <<
"det= " << det << endl;
238 cout <<
"DTx= " << HC(0, 0) <<
" +- " <<
sqrt(Cov(0, 0)) << endl;
239 cout <<
"DBx= " << HC(1, 0) <<
" +- " <<
sqrt(Cov(1, 1)) << endl;
240 cout <<
"DTy= " << HC(2, 0) <<
" +- " <<
sqrt(Cov(2, 2)) << endl;
241 cout <<
"DBy= " << HC(3, 0) <<
" +- " <<
sqrt(Cov(3, 3)) << endl;
248 cout <<
"Tx= " << Tx << endl;
249 cout <<
"Ty= " << Ty << endl;
250 cout <<
"Bx= " << Bx << endl;
251 cout <<
"By= " << By << endl;
257 param.
SetX(Tx * param.
Z()[0] + Bx);
258 param.
SetY(Ty * param.
Z()[0] + By);
263 float Tx_1 = param.Tx()[0];
264 float Ty_1 = param.Ty()[0];
265 float Bx_1 = param.Bx()[0];
270 for (
int ihit = 0; ihit < N; ihit++) {
271 const TESV &index = triplet.
IHit(ihit);
272 cout <<
"index.s station " << index.
s <<
" index.e " << index.
e << endl;
275 const FTSCAHit &hit = hits_st[index.
e[0]];
278 cout <<
"chtck hit.IStation()" << ISta << endl;
281 const float s_1 = station.
f.
sin;
283 const float c_1 = station.
f.
cos;
285 cout <<
" s_1 " << s_1 <<
" c_1 " << c_1 << endl;
287 float tx_1 = c_1 * Tx_1 + s_1 * Ty_1;
288 float rCorrection_1 =
sqrt(1.
f + tx_1 * tx_1);
289 float fX_1 = Tx_1 * hit.
X0() + Bx_1;
290 float fY_1 = Ty_1 * hit.
X0() + By_1;
292 float Diff_1 = c_1 * (fX_1 - hit.
X1()) + s_1 * (fY_1 - hit.
X2());
294 float tx_k = c_1 * Tx_K + s_1 * Ty_K;
295 float rCorrection_k =
sqrt(1.
f + tx_k * tx_k);
296 float fX_k = Tx_K * hit.
X0() + Bx_K;
297 float fY_k = Ty_K * hit.
X0() + By_K;
299 float Diff_k = c_1 * (fX_k - hit.
X1()) + s_1 * (fY_k - hit.
X2());
305 float Y_point_of_wire_1 = 0.f;
312 float err_1 =
sqrt(hit.Err2R());
322 Mes = (Diff_1 / rCorrection_1 - R_1) /
sqrt(hit.Err2R());
323 Mes_k = (Diff_k / rCorrection_k - R_k) /
sqrt(hit.Err2R());
325 float Mes1 = (Diff_1 - R_1 * rCorrection_1) / (err_1 * rCorrection_1);
327 cout <<
" change sighn for hit " << ihit << endl;
329 cout <<
" Mes " << Mes <<
" Mes1 " << Mes1 << endl;
330 chi2 = chi2 + Mes * Mes;
331 chi2_k = chi2_k + Mes_k * Mes_k;
332 cout <<
" Mes*Mes " << Mes * Mes << endl;
334 cout <<
" chi2 " << chi2 <<
" chi2_k " << chi2_k << endl;
void SetY(const float_v &v)
const PndFTSCATrackParamVector & Param() const
void SetX(const float_v &v)
friend F32vec4 sqrt(const F32vec4 &a)
const PndFTSCAParam & GetParameters() const
void SetChi2(const float_v &v)
const FTSCAStation & Station(short i) const
PndFTSResizableArray< PndFTSCAGBHit > fHits
const TESV & IHit(int IH) const
const FTSCAElementsOnStation< T > & OnStationConst(char i) const
TMatrixT< double > TMatrixD
void Refit_1(FTSCANPletV &triplet, const FTSCAHits &hits)