1 package org.lcsim.mc.fast.tracking;
2
3 import Jama.*;
4 import hep.physics.matrix.SymmetricMatrix;
5 import org.lcsim.util.aida.AIDA;
6 import hep.physics.particle.Particle;
7 import hep.physics.vec.Hep3Vector;
8 import org.lcsim.event.Track;
9 import org.lcsim.event.TrackState;
10 import org.lcsim.event.base.BaseTrackState;
11
12 import java.io.*;
13 import java.util.ArrayList;
14 import java.util.Collections;
15 import java.util.List;
16 import java.util.Random;
17 import org.lcsim.mc.fast.tracking.SimpleTables;
18
19
20
21
22
23
24
25
26 public class ReconTrack implements Track {
27 private static final String[][] matrixI = { { "(1,1):", "(1,2):", "(1,3):", "(1,4):", "(1,5):" }, { "(2,1):", "(2,2):", "(2,3):", "(2,4):", "(2,5):" }, { "(3,1):", "(3,2):", "(3,3):", "(3,4):", "(3,5):" }, { "(4,1):", "(4,2):", "(4,3):", "(4,4):", "(4,5):" }, { "(5,1):", "(5,2):", "(5,3):", "(5,4):", "(5,5):" } };
28
29
30
31
32
33
34 private DocaTrackParameters m_nosmear = null;
35 private DocaTrackParameters m_smear = null;
36 transient private Particle mc;
37 private int m_tcharge;
38 private double[] _refpoint = { 0, 0, 0 };
39 private List<TrackState> _trackStates;
40
41 ReconTrack(double bField, TrackResolutionTables parm, SimpleTables SmTbl, Random rand, Particle mc, boolean hist, boolean simple) {
42 this.mc = mc;
43
44
45
46 m_nosmear = new DocaTrackParameters(bField, mc);
47
48 double pt = m_nosmear.getPt();
49
50 if (hist) {
51
52 double r = Math.abs(m_nosmear.getD0());
53
54 AIDA aida = AIDA.defaultInstance();
55 aida.cloud1D("ptsqr").fill(pt * pt);
56 aida.cloud1D("pt").fill(pt);
57 aida.cloud1D("phi").fill(m_nosmear.getPhi0());
58 aida.cloud1D("theta").fill(m_nosmear.getTheta());
59 aida.cloud1D("tanL").fill(m_nosmear.getTanL());
60 aida.cloud1D("r").fill(r);
61 aida.cloud1D("z").fill(mc.getOriginZ());
62 }
63
64 double abscth = Math.abs(m_nosmear.getCosTheta());
65 double ptot = m_nosmear.getPtot();
66 ResolutionTable table = (abscth < parm.getPolarInner()) ? parm.getBarrelTable() : parm.getEndcapTable();
67
68
69 m_nosmear.setErrorMatrix(getErrorMatrixFromTable(table, abscth, ptot));
70
71
72 if (simple == true) {
73 m_smear = (DocaTrackParameters) SmearTrackSimple.smearTrackSimple(bField, m_nosmear, rand, SmTbl, pt, hist);
74
75
76 } else {
77 m_smear = (DocaTrackParameters) SmearTrack.smearTrack(bField, m_nosmear, rand);
78 }
79
80 if (hist) {
81 AIDA aida = AIDA.defaultInstance();
82 aida.cloud1D("ptNew").fill(m_smear.getPt());
83 aida.cloud1D("tanLNew").fill(m_smear.getTanL());
84 aida.cloud1D("rNew").fill(Math.abs(m_smear.getD0()));
85 aida.cloud1D("phiNew").fill(m_smear.getPhi0());
86 aida.cloud1D("zNew").fill(m_smear.getZ0());
87 }
88 m_tcharge = (int) (m_smear.getUnitCharge() * Math.abs(mc.getType().getCharge()));
89 _trackStates = new ArrayList<TrackState>();
90 _trackStates.add(new BaseTrackState(m_smear.getTrackParameters(), bField));
91 }
92
93
94
95
96 public int getCharge() {
97 return m_tcharge;
98 }
99
100
101
102
103 public double getChi2() {
104 return m_smear.getChi2();
105 }
106
107
108
109
110
111
112 public double[] getDoca() {
113 return m_smear.getDoca();
114 }
115
116 public double[] getDocaMomentum(double[] refPoint) {
117 return m_smear.getDocaMomentum(refPoint);
118 }
119
120
121
122
123
124
125 public double[] getDocaMomentum() {
126 return m_smear.getMomentum();
127 }
128
129 public Hep3Vector getDocaMomentumVec(Hep3Vector refPoint) {
130 return m_smear.getDocaMomentumVec(refPoint);
131 }
132
133
134
135
136 public Hep3Vector getDocaMomentumVec(double[] refPoint) {
137 return m_smear.getDocaMomentumVec(refPoint);
138 }
139
140
141
142
143 public double getDocaMomentumX() {
144 return m_smear.getPX();
145 }
146
147
148
149
150 public double getDocaMomentumY() {
151 return m_smear.getPY();
152 }
153
154
155
156
157 public double getDocaMomentumZ() {
158 return m_smear.getPZ();
159 }
160
161 public double[] getDocaPosition(double[] refPoint) {
162 return m_smear.getDocaPosition(refPoint);
163 }
164
165
166
167
168 public Hep3Vector getDocaPositionVec(Hep3Vector refPoint) {
169 return m_smear.getDocaPositionVec(refPoint);
170 }
171
172 public Hep3Vector getDocaPositionVec(double[] refPoint) {
173 return m_smear.getDocaPositionVec(refPoint);
174 }
175
176
177
178
179 public double getDocaPt() {
180 return m_smear.getPt();
181 }
182
183
184
185
186
187
188 public double getDocaTransversePathLength(Hep3Vector refPoint) {
189 return m_smear.getDocaTransversePathLength(refPoint);
190 }
191
192 public double getDocaTransversePathLength(double[] refPoint) {
193 return m_smear.getDocaTransversePathLength(refPoint);
194 }
195
196
197
198
199 public double getDocaX() {
200 return m_smear.getDocaX();
201 }
202
203
204
205
206 public double getDocaY() {
207 return m_smear.getDocaY();
208 }
209
210
211
212
213 public double getDocaZ() {
214 return m_smear.getDocaZ();
215 }
216
217
218
219
220
221 public SymmetricMatrix getErrorMatrix() {
222 return m_smear.getErrorMatrix();
223 }
224
225
226
227
228 public Particle getMCParticle() {
229 return mc;
230 }
231
232 public double[] getMomentum(double l) {
233 return m_smear.getMomentum(l);
234 }
235
236
237
238
239
240
241 public double[] getMomentum() {
242 return m_smear.getMomentum(m_smear.getL0());
243 }
244
245
246
247
248 public Hep3Vector getMomentumVec(double l) {
249 return m_smear.getMomentumVec(l);
250 }
251
252 public Hep3Vector getMomentumVec() {
253 return m_smear.getMomentumVec(m_smear.getL0());
254 }
255
256
257
258
259 public double getMomentumX() {
260 return m_smear.getMomentum(m_smear.getL0())[0];
261 }
262
263
264
265
266 public double getMomentumY() {
267 return m_smear.getMomentum(m_smear.getL0())[1];
268 }
269
270
271
272
273 public double getMomentumZ() {
274 return m_smear.getMomentum(m_smear.getL0())[2];
275 }
276
277
278
279
280 public int getNDF() {
281 return m_smear.getNDF();
282 }
283
284
285
286
287 public DocaTrackParameters getNotSmearedTrack() {
288 return m_nosmear;
289 }
290
291
292
293
294 public double getPX() {
295 return getMomentumX();
296 }
297
298
299
300
301 public double getPY() {
302 return getMomentumY();
303 }
304
305
306
307
308 public double getPZ() {
309 return getMomentumZ();
310 }
311
312 public double[] getPosition(double l) {
313 return m_smear.getPosition(l);
314 }
315
316
317
318
319 public Hep3Vector getPositionVec(double l) {
320 return m_smear.getPositionVec(l);
321 }
322
323
324
325
326 public double getPt() {
327 double[] p = getMomentum();
328
329 return Math.sqrt((p[0] * p[0]) + (p[1] * p[1]));
330 }
331
332 public double getRadiusOfInnermostHit() {
333 return 0;
334 }
335
336
337
338
339
340
341
342 public double[] getReferencePoint() {
343 return _refpoint;
344 }
345
346 public boolean isReferencePointPCA() {
347 return true;
348 }
349
350
351
352
353 public double getReferencePointX() {
354 return getReferencePoint()[0];
355 }
356
357
358
359
360 public double getReferencePointY() {
361 return getReferencePoint()[1];
362 }
363
364
365
366
367 public double getReferencePointZ() {
368 return getReferencePoint()[2];
369 }
370
371
372
373
374 public DocaTrackParameters getSmearedTrack() {
375 return m_smear;
376 }
377
378 public int[] getSubdetectorHitNumbers() {
379 return new int[0];
380 }
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419 public double getTrackParameter(int i) {
420 return m_smear.getTrackParameter(i);
421 }
422
423
424
425
426
427 public double[] getTrackParameters() {
428 return m_smear.getTrackParameters();
429 }
430
431 public List getTrackerHits() {
432 return Collections.EMPTY_LIST;
433 }
434
435 public List getTracks() {
436 return Collections.EMPTY_LIST;
437 }
438
439 public int getType() {
440 return 0;
441 }
442
443
444
445
446 public SymmetricMatrix calcMomentumErrorMatrix(double l) {
447 return m_smear.calcMomentumErrorMatrix(l);
448 }
449
450
451
452
453 public double[][] calcPositionErrorMatrix(double l) {
454 return m_smear.calcPositionErrorMatrix(l);
455 }
456
457 public boolean fitSuccess() {
458
459 return false;
460 }
461
462 public double getdEdx() {
463 return 0;
464 }
465
466 public double getdEdxError() {
467 return 0;
468 }
469
470 public String toString() {
471 java.io.StringWriter buffer = new java.io.StringWriter();
472 java.io.PrintWriter out = new java.io.PrintWriter(buffer);
473
474 java.text.NumberFormat pf = java.text.NumberFormat.getInstance();
475 pf.setMinimumFractionDigits(12);
476 pf.setMaximumFractionDigits(12);
477 pf.setMinimumIntegerDigits(1);
478 pf.setMaximumIntegerDigits(3);
479 pf.setGroupingUsed(false);
480
481 Matrix mHlxPar = new Matrix(m_smear.getTrackParameters(), 1);
482
483 out.println("ReconTrack Parameters: d0 phi0 omega z0 tan(lambda)");
484 mHlxPar.print(out, pf, 16);
485 out.println("Error Matrix:");
486 out.println(m_smear.getErrorMatrix());
487
488 return (buffer.toString());
489 }
490
491 private SymmetricMatrix getErrorMatrixFromTable(ResolutionTable table, double abscth, double ptot) {
492 SymmetricMatrix errMatrix = new SymmetricMatrix(5);
493 for (int i = 0; i < 5; i++) {
494 for (int j = 0; j <= i; j++) {
495 errMatrix.setElement(i, j, table.findTable(matrixI[i][j]).interpolateVal(abscth, ptot));
496 }
497 }
498 return errMatrix;
499 }
500
501 public List<TrackState> getTrackStates() {
502 return _trackStates;
503 }
504 }