CbmRoot
Loading...
Searching...
No Matches
CbmHelix.cxx
Go to the documentation of this file.
1/* Copyright (C) 2023-2023 Warsaw University of Technology, Warsaw
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Daniel Wielanek [committer] */
4#include "CbmHelix.h"
5
6#include <TMath.h>
7
8#include <vector>
9
10#include <Hal/Field.h>
11// matrix x, y, tx,ty, qp, z
12Hal::MagField* CbmHelix::fgField = NULL;
14
16{
17 const FairTrackParam* parameters = tr->GetParamVertex();
18 SetParameters(parameters);
19}
20
21void CbmHelix::Build(const CbmStsTrack* tr, Bool_t firstPoint)
22{
23 if (firstPoint) {
25 }
26 else {
28 }
29}
30
31TVector3 CbmHelix::Eval(Double_t z)
32{
33 Propagate(z);
34 return TVector3(GetTrack()[0], GetTrack()[1], GetTrack()[5]);
35}
36
37TVector3 CbmHelix::Eval(Double_t z, TVector3& mom)
38{
39 Propagate(z);
40 Double_t p = (TMath::Abs(Qp()) > 1.e-4) ? 1. / TMath::Abs(Qp()) : 1.e4;
41 Double_t pz = TMath::Sqrt(p * p / (Tx() * Tx() + Ty() * Ty() + 1));
42 Double_t px = Tx() * pz;
43 Double_t py = Ty() * pz;
44 mom.SetXYZ(px, py, pz);
45 return TVector3(GetTrack()[0], GetTrack()[1], GetTrack()[5]);
46}
47
48void CbmHelix::SetParameters(const FairTrackParam* param)
49{
50 fTb[0] = param->GetX();
51 fTb[1] = param->GetY();
52 fTb[2] = param->GetTx();
53 fTb[3] = param->GetTy();
54 fTb[4] = param->GetQp();
55 fTb[5] = param->GetZ();
56}
57
58void CbmHelix::Build(const TVector3& pos, const TVector3& mom, Double_t charge)
59{
60 fTb[0] = pos.X();
61 fTb[1] = pos.Y();
62 Double_t p = mom.Mag();
63 fTb[2] = mom.Px() / mom.Pz();
64 fTb[3] = mom.Py() / mom.Pz();
65 fTb[4] = charge / p;
66 fTb[5] = pos.Z();
67}
68
70
71CbmHelix::CbmHelix(const CbmHelix& other) : TObject()
72{
73 for (int i = 0; i < 6; i++) {
74 fT[i] = other.fT[i];
75 fTb[i] = other.fTb[i];
76 }
77}
78
80{
81 if (&other == this) return *this;
82 for (int i = 0; i < 6; i++) {
83 fT[i] = other.fT[i];
84 fTb[i] = other.fTb[i];
85 }
86 return *this;
87}
88
89Int_t CbmHelix::Propagate(Double_t z)
90{
91 Bool_t err = 0;
92 for (int i = 0; i < 6; i++) {
93 fT[i] = fTb[i];
94 }
95 if (fabs(fT[5] - z) < 1.e-5) return 0;
96
97 Double_t zz = z;
98 if (z < 300. && 300 <= fT[5]) ExtrapolateLine(300.);
99
100 if (fT[5] < 300. && 300. < z) {
101 zz = 300.;
102 }
103 Bool_t repeat = 1;
104 while (!err && repeat) {
105 const Double_t max_step = 5.;
106 Double_t zzz;
107 if (fabs(fT[5] - zz) > max_step)
108 zzz = fT[5] + ((zz > fT[5]) ? max_step : -max_step);
109 else {
110 zzz = zz;
111 repeat = 0;
112 }
113 err = err || ExtrapolateALight(zzz);
114 }
115 if (fT[5] != z) ExtrapolateLine(z);
116 return err;
117}
118
119void CbmHelix::ExtrapolateLine(Double_t z_out)
120{
121 Double_t dz = z_out - fT[5];
122
123 fT[0] += dz * fT[2];
124 fT[1] += dz * fT[3];
125 fT[5] = z_out;
126}
127
128Int_t CbmHelix::ExtrapolateALight(Double_t z_out)
129{
130 //
131 // Part of the analytic extrapolation formula with error (c_light*B*dz)^4/4!
132 //
133 {
134 bool ok = 1;
135 for (int i = 0; i < 6; i++)
136 ok = ok && !TMath::IsNaN(fT[i]) && (fT[i] < 1.e5);
137 }
138 const Double_t c_light = 0.000299792458;
139
140 //Double_t qp_in = fT[4];
141 Double_t z_in = fT[5];
142 Double_t dz = z_out - z_in;
143
144 // construct coefficients
145
146 Double_t x = fT[2], // tx !!
147 y = fT[3], // ty !!
148
149 xx = x * x, xy = x * y, yy = y * y, xx31 = xx * 3 + 1, xx159 = xx * 15 + 9;
150
151 const Double_t Ax = xy, Ay = -xx - 1, Az = y, Ayy = x * (xx * 3 + 3), Ayz = -2 * xy,
152 Ayyy = -(15 * xx * xx + 18 * xx + 3), Bx = yy + 1, By = -xy, Bz = -x, Byy = y * xx31, Byz = 2 * xx + 1,
153 Byyy = -xy * xx159;
154
155 // end of coefficients calculation
156
157 Double_t t2 = 1. + xx + yy;
158 if (t2 > 1.e4) return 1;
159 Double_t t = sqrt(t2), h = Qp() * c_light, ht = h * t;
160
161 Double_t sx = 0, sy = 0, sz = 0, syy = 0, syz = 0, syyy = 0, Sx = 0, Sy = 0, Sz = 0, Syy = 0, Syz = 0, Syyy = 0;
162
163 { // get field integrals
164
165 Double_t B[3][3];
166 Double_t r0[3], r1[3], r2[3];
167
168 // first order track approximation
169
170 r0[0] = fT[0];
171 r0[1] = fT[1];
172 r0[2] = fT[5];
173
174 r2[0] = fT[0] + fT[2] * dz;
175 r2[1] = fT[1] + fT[3] * dz;
176 r2[2] = z_out;
177
178 r1[0] = 0.5 * (r0[0] + r2[0]);
179 r1[1] = 0.5 * (r0[1] + r2[1]);
180 r1[2] = 0.5 * (r0[2] + r2[2]);
181
182 fgField->GetFieldValue(r0, B[0]);
183 fgField->GetFieldValue(r1, B[1]);
184 fgField->GetFieldValue(r2, B[2]);
185
186 Sy = (7 * B[0][1] + 6 * B[1][1] - B[2][1]) * dz * dz / 96.;
187 r1[0] = fT[0] + x * dz / 2 + ht * Sy * Ay;
188 r1[1] = fT[1] + y * dz / 2 + ht * Sy * By;
189
190 Sy = (B[0][1] + 2 * B[1][1]) * dz * dz / 6.;
191 r2[0] = fT[0] + x * dz + ht * Sy * Ay;
192 r2[1] = fT[1] + y * dz + ht * Sy * By;
193
194 Sy = 0;
195
196 // integrals
197
198 fgField->GetFieldValue(r0, B[0]);
199 fgField->GetFieldValue(r1, B[1]);
200 fgField->GetFieldValue(r2, B[2]);
201
202 sx = (B[0][0] + 4 * B[1][0] + B[2][0]) * dz / 6.;
203 sy = (B[0][1] + 4 * B[1][1] + B[2][1]) * dz / 6.;
204 sz = (B[0][2] + 4 * B[1][2] + B[2][2]) * dz / 6.;
205
206 Sx = (B[0][0] + 2 * B[1][0]) * dz * dz / 6.;
207 Sy = (B[0][1] + 2 * B[1][1]) * dz * dz / 6.;
208 Sz = (B[0][2] + 2 * B[1][2]) * dz * dz / 6.;
209
210 Double_t c2[3][3] = {{5, -4, -1}, {44, 80, -4}, {11, 44, 5}}; // /=360.
211 Double_t C2[3][3] = {{38, 8, -4}, {148, 208, -20}, {3, 36, 3}}; // /=2520.
212 for (Int_t n = 0; n < 3; n++)
213 for (Int_t m = 0; m < 3; m++) {
214 syz += c2[n][m] * B[n][1] * B[m][2];
215 Syz += C2[n][m] * B[n][1] * B[m][2];
216 }
217
218 syz *= dz * dz / 360.;
219 Syz *= dz * dz * dz / 2520.;
220
221 syy = (B[0][1] + 4 * B[1][1] + B[2][1]) * dz;
222 syyy = syy * syy * syy / 1296;
223 syy = syy * syy / 72;
224
225 Syy = (B[0][1] * (38 * B[0][1] + 156 * B[1][1] - B[2][1]) + B[1][1] * (208 * B[1][1] + 16 * B[2][1])
226 + B[2][1] * (3 * B[2][1]))
227 * dz * dz * dz / 2520.;
228 Syyy = (B[0][1]
229 * (B[0][1] * (85 * B[0][1] + 526 * B[1][1] - 7 * B[2][1]) + B[1][1] * (1376 * B[1][1] + 84 * B[2][1])
230 + B[2][1] * (19 * B[2][1]))
231 + B[1][1] * (B[1][1] * (1376 * B[1][1] + 256 * B[2][1]) + B[2][1] * (62 * B[2][1]))
232 + B[2][1] * B[2][1] * (3 * B[2][1]))
233 * dz * dz * dz * dz / 90720.;
234 }
235
236 const Double_t
237
238 sA1 = sx * Ax + sy * Ay + sz * Az,
239
240 sB1 = sx * Bx + sy * By + sz * Bz,
241
242 SA1 = Sx * Ax + Sy * Ay + Sz * Az,
243
244 SB1 = Sx * Bx + Sy * By + Sz * Bz,
245
246 sA2 = syy * Ayy + syz * Ayz, sB2 = syy * Byy + syz * Byz,
247
248 SA2 = Syy * Ayy + Syz * Ayz, SB2 = Syy * Byy + Syz * Byz,
249
250 sA3 = syyy * Ayyy, sB3 = syyy * Byyy,
251
252 SA3 = Syyy * Ayyy, SB3 = Syyy * Byyy;
253 fT[0] = fT[0] + x * dz + ht * (SA1 + ht * (SA2 + ht * SA3));
254 fT[1] = fT[1] + y * dz + ht * (SB1 + ht * (SB2 + ht * SB3));
255 fT[2] = fT[2] + ht * (sA1 + ht * (sA2 + ht * sA3));
256 fT[3] = fT[3] + ht * (sB1 + ht * (sB2 + ht * sB3));
257 fT[5] = z_out;
258 return 0;
259}
friend fvec sqrt(const fvec &a)
const CbmTrackParam * GetParamVertex() const
void SetParameters(const FairTrackParam *param)
Definition CbmHelix.cxx:48
Int_t Propagate(Double_t Z)
Definition CbmHelix.cxx:89
void Build(const FairTrackParam *params)
Definition CbmHelix.h:44
Double_t fTb[15]
Definition CbmHelix.h:24
Double_t fT[6]
Definition CbmHelix.h:24
Double_t Qp() const
Definition CbmHelix.h:25
Double_t * GetTrack()
Definition CbmHelix.h:55
Int_t ExtrapolateALight(Double_t z_out)
Definition CbmHelix.cxx:128
static Hal::MagField * fgField
Definition CbmHelix.h:32
Double_t Tx() const
Definition CbmHelix.h:30
TVector3 Eval(Double_t z)
Definition CbmHelix.cxx:31
Double_t Ty() const
Definition CbmHelix.h:31
CbmHelix & operator=(const CbmHelix &other)
Definition CbmHelix.cxx:79
virtual ~CbmHelix()
Definition CbmHelix.cxx:69
void ExtrapolateLine(Double_t z_out)
Definition CbmHelix.cxx:119
Data class with information on a STS local track.
const FairTrackParam * GetParamLast() const
Definition CbmTrack.h:69
const FairTrackParam * GetParamFirst() const
Definition CbmTrack.h:68