1
2
3
4
5
6
7
8
9 package org.lcsim.fit.helicaltrack;
10
11 import hep.physics.matrix.SymmetricMatrix;
12 import java.util.Map;
13 import org.lcsim.constants.Constants;
14
15
16
17
18
19
20 public class HelicalTrackFit {
21
22
23
24 public static int dcaIndex = 0;
25
26
27
28 public static int phi0Index = 1;
29
30
31
32 public static int curvatureIndex = 2;
33
34
35
36 public static int z0Index = 3;
37
38
39
40 public static int slopeIndex = 4;
41
42
43 private double[] _chisq = new double[2];
44 private double _nhchisq;
45 private int[] _ndf = new int[2];
46 private double[] _parameters;
47 private SymmetricMatrix _covmatrix;
48 private Map<HelicalTrackHit, Double> _smap;
49 private Map<HelicalTrackHit, MultipleScatter> _msmap;
50
51
52
53
54 private double curveerror;
55
56 private double slopeerror;
57
58 private double dcaerror;
59
60 private double phi0error;
61
62 private double z0error;
63
64
65
66
67
68
69
70
71
72
73 public HelicalTrackFit(double[]pars, SymmetricMatrix cov, double[] chisq, int[] ndf,
74 Map<HelicalTrackHit, Double> smap, Map<HelicalTrackHit, MultipleScatter> msmap) {
75 _parameters = pars;
76 _covmatrix = cov;
77 _chisq = chisq;
78 _nhchisq = 0.;
79 _ndf = ndf;
80 _smap = smap;
81 _msmap = msmap;
82 }
83
84
85
86
87
88 public double[] parameters() {
89 return _parameters;
90 }
91
92
93
94
95
96 public double dca() {
97 return _parameters[dcaIndex];
98 }
99
100
101
102
103
104 public double phi0() {
105 return _parameters[phi0Index];
106 }
107
108
109
110
111
112 public double curvature() {
113 return _parameters[curvatureIndex];
114 }
115
116
117
118
119
120 public double z0() {
121 return _parameters[z0Index];
122 }
123
124
125
126
127
128 public double slope() {
129 return _parameters[slopeIndex];
130 }
131
132
133
134
135
136 public SymmetricMatrix covariance() {
137 return _covmatrix;
138 }
139
140
141
142
143
144
145 public double[] chisq() {
146 return _chisq;
147 }
148
149
150
151
152
153 public void setnhchisq(double nhchisq) {
154 _nhchisq = nhchisq;
155 return;
156 }
157
158
159
160
161
162 public double nhchisq() {
163 return _nhchisq;
164 }
165
166
167
168
169
170 public double chisqtot() {
171 return _chisq[0]+_chisq[1]+_nhchisq;
172 }
173
174
175
176
177
178
179 public int[] ndf() {
180 return _ndf;
181 }
182
183
184
185
186
187 public double cth() {
188 return slope() / Math.sqrt(1 + Math.pow(slope(), 2));
189 }
190
191
192
193
194
195 public double sth() {
196 return 1. / Math.sqrt(1 + Math.pow(slope(), 2));
197 }
198
199
200
201
202
203
204 public double pT(double bfield) {
205 return Constants.fieldConversion * bfield * Math.abs(R());
206 }
207
208
209
210
211
212
213 public double p(double bfield) {
214 return pT(bfield) / sth();
215 }
216
217
218
219
220
221 public double R() {
222 return 1. / curvature();
223 }
224
225
226
227
228
229 public double xc() {
230 return (R() - dca()) * Math.sin(phi0());
231 }
232
233
234
235
236
237 public double yc() {
238 return -(R() - dca()) * Math.cos(phi0());
239 }
240
241 public double x0() {
242 return -dca() * Math.sin(phi0());
243 }
244
245 public double y0() {
246 return dca() * Math.cos(phi0());
247 }
248
249
250
251
252
253 public Map<HelicalTrackHit, Double> PathMap() {
254 return _smap;
255 }
256
257
258
259
260
261 public Map<HelicalTrackHit, MultipleScatter> ScatterMap() {
262 return _msmap;
263 }
264
265
266
267
268 public double getCurveError()
269 {
270 curveerror = Math.sqrt(_covmatrix.e(HelicalTrackFit.curvatureIndex, HelicalTrackFit.curvatureIndex));
271 return curveerror;
272 }
273
274
275
276
277 public double getSlopeError()
278 {
279 slopeerror = Math.sqrt(_covmatrix.e(HelicalTrackFit.slopeIndex, HelicalTrackFit.slopeIndex));
280 return slopeerror;
281 }
282
283
284
285
286 public double getDcaError()
287 {
288 dcaerror = Math.sqrt(_covmatrix.e(HelicalTrackFit.dcaIndex, HelicalTrackFit.dcaIndex));
289 return dcaerror;
290 }
291
292
293
294
295 public double getPhi0Error()
296 {
297 phi0error = Math.sqrt(_covmatrix.e(HelicalTrackFit.phi0Index, HelicalTrackFit.phi0Index));
298 return phi0error;
299 }
300
301
302
303
304 public double getZ0Error()
305 {
306 z0error = Math.sqrt(_covmatrix.e(HelicalTrackFit.z0Index, HelicalTrackFit.z0Index));
307 return z0error;
308 }
309
310
311
312
313 public String toString() {
314 StringBuffer sb = new StringBuffer("HelicalTrackFit: \n");
315 sb.append("d0= "+dca()+"\n");
316 sb.append("phi0= "+phi0()+"\n");
317 sb.append("curvature: "+curvature()+"\n");
318 sb.append("z0= "+z0()+"\n");
319 sb.append("tanLambda= "+slope()+"\n");
320 return sb.toString();
321 }
322 }