1
2
3
4
5
6
7
8 package org.lcsim.fit.helicaltrack;
9
10 import java.util.ArrayList;
11 import java.util.List;
12
13 import hep.physics.matrix.SymmetricMatrix;
14 import hep.physics.vec.Hep3Vector;
15
16 import org.lcsim.event.MCParticle;
17 import org.lcsim.event.RawTrackerHit;
18 import org.lcsim.event.TrackerHit;
19 import org.lcsim.geometry.subdetector.BarrelEndcapFlag;
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 public class HelicalTrackHit implements Comparable, TrackerHit {
37
38 private double[] _pos;
39 private Hep3Vector _poscor;
40 private SymmetricMatrix _cov;
41 private SymmetricMatrix _covcor;
42 private double _dEdx;
43 private double _time;
44 private int _type;
45 private List<RawTrackerHit> _rawhits;
46 private String _detname;
47 private int _layer;
48 private BarrelEndcapFlag _beflag;
49 private List<MCParticle> _mcplist;
50 private double _r;
51 private double _phi;
52 private double _drphi;
53 private double _dr;
54 private double _chisq;
55 protected double _eps = 1e-2;
56 protected double _epsParallel;
57 protected double _epsStereoAngle = 1e-2;
58 protected long id;
59
60
61
62
63 public HelicalTrackHit() {
64 }
65
66
67
68
69 public HelicalTrackHit(Hep3Vector pos, SymmetricMatrix cov, double dEdx, double time, int type,
70 List rawhits, String detname, int layer, BarrelEndcapFlag beflag) {
71
72 init(pos, cov, dEdx, time, type, rawhits, detname, layer, beflag);
73
74 }
75
76
77
78
79 public void init(Hep3Vector pos, SymmetricMatrix cov, double dEdx, double time, int type,
80 List rawhits, String detname, int layer, BarrelEndcapFlag beflag) {
81 _pos = pos.v();
82 _poscor = pos;
83 _cov = cov;
84 _covcor = cov;
85 _dEdx = dEdx;
86 _time = time;
87 _type = type;
88
89 if (rawhits != null) {
90 _rawhits = rawhits;
91 }
92 else {
93 _rawhits = new ArrayList<RawTrackerHit>();
94 }
95 _detname = detname;
96 _layer = layer;
97 _beflag = beflag;
98 _mcplist = new ArrayList<MCParticle>();
99 _chisq = 0.;
100 setPolarVariables();
101 }
102
103 public void setEpsParallel(double _epsParallel) {
104 this._epsParallel = _epsParallel;
105 }
106
107 public double getEpsParallel(){
108 return _epsParallel;
109 }
110
111 public void setEpsStereoAngle(double _epsStereoAngle) {
112 this._epsStereoAngle = _epsStereoAngle;
113 }
114
115
116
117
118
119 public double x() {
120 return _poscor.x();
121 }
122
123
124
125
126
127 public double y() {
128 return _poscor.y();
129 }
130
131
132
133
134
135 public double z() {
136 return _poscor.z();
137 }
138
139
140
141
142
143 public double r() {
144 return _r;
145 }
146
147
148
149
150
151 public double phi() {
152 return _phi;
153 }
154
155
156
157
158
159 public double drphi() {
160 return _drphi;
161 }
162
163
164
165
166
167 public double dr() {
168 return _dr;
169 }
170
171
172
173
174
175
176 public double chisq() {
177 return _chisq;
178 }
179
180
181
182
183
184 public BarrelEndcapFlag BarrelEndcapFlag() {
185 return _beflag;
186 }
187
188
189
190
191
192
193
194 public int compareTo(Object hit2) {
195 double zhit = ((HelicalTrackHit) hit2).z();
196 if (_poscor.z() < zhit) return -1;
197 if (_poscor.z() == zhit) return 0;
198 return 1;
199 }
200
201
202
203
204
205 public void addMCParticle(MCParticle mcp) {
206 if (!_mcplist.contains(mcp)) _mcplist.add(mcp);
207 return;
208 }
209
210
211
212
213
214
215 public List<MCParticle> getMCParticles(){
216 return _mcplist;
217 }
218
219
220
221
222
223 public double[] getPosition() {
224 return _pos;
225 }
226
227
228
229
230
231 public Hep3Vector getCorrectedPosition() {
232 return _poscor;
233 }
234
235
236
237
238
239 public double[] getCovMatrix() {
240 return _cov.asPackedArray(true);
241 }
242
243
244
245
246
247 public SymmetricMatrix getCorrectedCovMatrix() {
248 return _covcor;
249 }
250
251
252
253
254
255 public double getdEdx() {
256 return _dEdx;
257 }
258
259
260
261
262
263 public double getTime() {
264 return _time;
265 }
266
267
268
269
270
271 public int getType() {
272 return _type;
273 }
274
275 public int getQuality()
276 {
277 return 0;
278 }
279
280 public double getEdepError()
281 {
282 return 0.;
283 }
284
285
286
287
288
289 public List getRawHits() {
290 return _rawhits;
291 }
292
293 public String Detector() {
294 return _detname;
295 }
296
297 public int Layer() {
298 return _layer;
299 }
300
301
302
303
304
305 public String getLayerIdentifier() {
306 return _detname+_layer+_beflag;
307 }
308
309
310
311
312
313 public String toString() {
314 StringBuffer sb = new StringBuffer("HelicalTrackHit: \n");
315 sb.append("Layer Identifier= "+getLayerIdentifier()+"\n");
316 sb.append("Position= "+_poscor.toString()+"\n");
317 sb.append("Covariane= "+_covcor.toString()+"\n");
318 sb.append("dE/dx= "+this.getdEdx()+"\n");
319 sb.append("Time= "+this.getTime()+"\n");
320 return sb.toString();
321 }
322
323
324
325
326
327
328 public void setPosition(double[] position){
329 _pos = position;
330 }
331
332
333
334
335
336 protected void setCorrectedPosition(Hep3Vector poscor) {
337 _poscor = poscor;
338 setPolarVariables();
339 return;
340 }
341
342
343
344
345
346 protected void setCorrectedCovMatrix(SymmetricMatrix covcor) {
347 _covcor = covcor;
348 setPolarVariables();
349 return;
350 }
351
352 protected void addRawHit(RawTrackerHit rawhit) {
353 if (!_rawhits.contains(rawhit)) _rawhits.add(rawhit);
354 return;
355 }
356
357
358
359
360
361
362 protected void setChisq(double chisq) {
363 _chisq = chisq;
364 return;
365 }
366
367 protected double drphicalc(Hep3Vector pos, SymmetricMatrix cov) {
368 double x = pos.x();
369 double y = pos.y();
370 double r2 = x*x + y*y;
371 return Math.sqrt((y*y * cov.e(0,0) + x*x * cov.e(1,1) - 2. * x * y * cov.e(0,1)) / r2);
372 }
373
374 protected double drcalc(Hep3Vector pos, SymmetricMatrix cov) {
375 double x = pos.x();
376 double y = pos.y();
377 double r2 = x*x + y*y;
378 return Math.sqrt((x*x * cov.e(0,0) + y*y * cov.e(1,1) + 2. * x * y * cov.e(0,1)) / r2);
379 }
380
381
382
383
384
385
386 private void setPolarVariables() {
387 double x = _poscor.x();
388 double y = _poscor.y();
389 _r = Math.sqrt(x*x + y*y);
390 _phi = Math.atan2(y, x);
391 if (_phi < 0.) _phi += 2. * Math.PI;
392 _drphi = drphicalc(_poscor, _covcor);
393 _dr = drcalc(_poscor, _covcor);
394
395
396 if (! (_dr>_eps))
397 _dr = _eps;
398
399 if (! (_drphi>_eps))
400 _drphi = _eps;
401
402 return;
403 }
404
405 public long getCellID()
406 {
407 return id;
408 }
409 }