1
2
3
4
5
6
7
8
9
10 package org.lcsim.recon.tracking.digitization.sisim;
11
12 import hep.physics.matrix.SymmetricMatrix;
13 import hep.physics.vec.BasicHep3Vector;
14 import hep.physics.vec.Hep3Vector;
15 import java.util.HashSet;
16 import java.util.List;
17 import java.util.Set;
18 import org.lcsim.detector.IDetectorElement;
19 import org.lcsim.detector.ITransform3D;
20 import org.lcsim.detector.Transform3D;
21 import org.lcsim.detector.identifier.IIdentifierHelper;
22 import org.lcsim.event.MCParticle;
23 import org.lcsim.event.RawTrackerHit;
24 import org.lcsim.event.SimTrackerHit;
25 import org.lcsim.event.TrackerHit;
26
27
28
29
30
31 public class BaseTrackerHit implements TrackerHit
32 {
33
34
35 protected Hep3Vector _position_vector;
36 protected SymmetricMatrix _covariance_matrix;
37 private double _energy;
38 private double _time;
39 private List<RawTrackerHit> _raw_hits;
40 private int _type;
41 private long id;
42
43
44 private IIdentifierHelper _identifier_helper;
45 private IDetectorElement _sensor;
46 private Set<SimTrackerHit> _simulated_hits;
47 private Set<MCParticle> _mc_particles;
48
49
50
51
52
53
54 public BaseTrackerHit(Hep3Vector position_vector, SymmetricMatrix covariance_matrix, double energy, double time, List<RawTrackerHit> raw_hits, int type)
55 {
56 _position_vector = position_vector;
57 _covariance_matrix = covariance_matrix;
58 _energy = energy;
59 _time = time;
60 _raw_hits = raw_hits;
61 _type = type;
62 }
63
64
65 public BaseTrackerHit(TrackerHit hit)
66 {
67 this(
68 new BasicHep3Vector(hit.getPosition()[0],hit.getPosition()[1],hit.getPosition()[2]),
69 new SymmetricMatrix( 3, hit.getCovMatrix(), true),
70 hit.getdEdx(),
71 hit.getTime(),
72 hit.getRawHits(),
73 hit.getType()
74 );
75 }
76
77
78
79 public double[] getPosition()
80 {
81 return _position_vector.v();
82 }
83
84 public double[] getCovMatrix()
85 {
86 return ((SymmetricMatrix)_covariance_matrix).asPackedArray(true);
87 }
88
89 public double getdEdx()
90 {
91 return _energy;
92 }
93
94 public double getTime()
95 {
96 return _time;
97 }
98
99 public List<RawTrackerHit> getRawHits()
100 {
101 return _raw_hits;
102 }
103
104 public int getType()
105 {
106 return _type;
107 }
108
109 public double getEdepError()
110 {
111 return 0.;
112 }
113
114 public int getQuality()
115 {
116 return 0;
117 }
118
119
120 public Hep3Vector getPositionAsVector()
121 {
122 return _position_vector;
123 }
124
125 public SymmetricMatrix getCovarianceAsMatrix()
126 {
127 return _covariance_matrix;
128 }
129
130
131
132 public Set<SimTrackerHit> getSimHits()
133 {
134 if (_simulated_hits == null)
135 {
136 _simulated_hits = new HashSet<SimTrackerHit>();
137 for (RawTrackerHit raw_hit : _raw_hits)
138 {
139 _simulated_hits.addAll(raw_hit.getSimTrackerHits());
140 }
141 }
142 return _simulated_hits;
143 }
144
145 public Set<MCParticle> getMCParticles()
146 {
147 if (_mc_particles == null)
148 {
149 _mc_particles = new HashSet<MCParticle>();
150 for (SimTrackerHit sim_hit : getSimHits())
151 {
152 _mc_particles.add(sim_hit.getMCParticle());
153 }
154 }
155 return _mc_particles;
156 }
157
158 public IDetectorElement getSensor()
159 {
160 if (_sensor == null)
161 {
162 _sensor = this.getRawHits().get(0).getDetectorElement();
163 }
164 return _sensor;
165 }
166
167 public IIdentifierHelper getIdentifierHelper()
168 {
169 if (_identifier_helper == null)
170 {
171 _identifier_helper = getRawHits().get(0).getDetectorElement().getIdentifierHelper();
172 }
173 return _identifier_helper;
174 }
175
176 public long getCellID()
177 {
178 return id;
179 }
180 }