1 package org.lcsim.recon.tracking.trfcyl;
2 import org.lcsim.recon.tracking.spacegeom.SpacePoint;
3 import org.lcsim.recon.tracking.spacegeom.CylindricalPoint;
4 import org.lcsim.recon.tracking.spacegeom.SpacePath;
5 import org.lcsim.recon.tracking.spacegeom.CylindricalPath;
6 import org.lcsim.recon.tracking.trfutil.TRFMath;
7 import org.lcsim.recon.tracking.trfutil.Assert;
8
9 import org.lcsim.recon.tracking.trfbase.Surface;
10 import org.lcsim.recon.tracking.trfbase.VTrack;
11 import org.lcsim.recon.tracking.trfbase.CrossStat;
12 import org.lcsim.recon.tracking.trfbase.PureStat;
13 import org.lcsim.recon.tracking.trfbase.TrackSurfaceDirection;
14 import org.lcsim.recon.tracking.trfbase.TrackVector;
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 public class SurfCylinder extends Surface
41 {
42
43
44
45
46
47
48
49
50
51
52
53 public static String typeName()
54 { return "SurfCylinder"; }
55
56
57
58
59
60
61
62
63 public static String staticType()
64 { return typeName(); }
65
66
67
68
69
70
71 public static final int RADIUS = 0;
72
73
74 public static final int IPHI=0;
75 public static final int IZ = 1;
76 public static final int IALF=2;
77 public static final int ITLM=3;
78 public static final int IQPT=4;
79
80
81
82 protected double _radius;
83
84
85
86 protected boolean safePureEqual( Surface srf)
87 {
88 return _radius == ((SurfCylinder) srf)._radius;
89 }
90
91
92
93
94 protected boolean safePureLessThan( Surface srf)
95 {
96 return _radius < ((SurfCylinder) srf)._radius;
97 }
98
99
100
101
102
103
104
105
106 public SurfCylinder(double radius)
107 {
108 _radius = radius;
109 }
110
111
112
113
114
115
116
117 public SurfCylinder( SurfCylinder srf)
118 {
119 _radius = srf._radius;
120 }
121
122
123
124
125
126
127
128
129
130 public String pureType()
131 {
132 return staticType();
133 }
134
135
136
137
138
139
140
141
142 public Surface newPureSurface()
143 {
144 return new SurfCylinder(_radius);
145 }
146
147
148
149
150
151
152
153 public Surface newSurface()
154 {
155 return new SurfCylinder(_radius);
156 }
157
158
159
160
161
162
163
164
165
166 public CrossStat pureStatus( VTrack trv)
167 {
168
169 Surface srf = trv.surface();
170
171 if ( srf.equals(this) || pureEqual(srf) ) return new CrossStat(PureStat.AT);
172
173 double rtrk = trv.spacePoint().rxy();
174 double rsrf = _radius;
175 double prec = CrossStat.staticPrecision();
176 if ( Math.abs(rtrk-rsrf) < prec ) return new CrossStat(PureStat.ON);
177 if ( rtrk > rsrf ) return new CrossStat(PureStat.OUTSIDE);
178 return new CrossStat(PureStat.INSIDE);
179 }
180
181
182
183
184
185
186
187
188
189 public double parameter(int ipar)
190 {
191 if( ipar != RADIUS)
192 {
193 throw new IllegalArgumentException("Wrong SurfCylinder surface parameter!");
194 }
195 if ( ipar == RADIUS ) return _radius;
196 return 0.0;
197 }
198
199
200
201
202
203
204
205
206 public double radius()
207 { return _radius; }
208
209
210
211
212
213
214
215
216
217
218 public SpacePoint spacePoint( TrackVector vec)
219 {
220 return new CylindricalPoint( _radius, vec.vector()[0], vec.vector()[1] );
221 }
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236 public SpacePath spacePath( TrackVector vec, TrackSurfaceDirection dir)
237 {
238 double r = _radius;
239 double phi = vec.vector()[0];
240 double z = vec.vector()[1];
241 double alf = vec.vector()[2];
242 double tlam = vec.vector()[3];
243 double salf = Math.sin(alf);
244 double calf = Math.cos(alf);
245 double slam = tlam/Math.sqrt(1.0+tlam*tlam);
246 double clam = 1.0;
247 if ( tlam != 0.0 ) clam = slam/tlam;
248 double dr_ds = clam*calf;
249 double r_dphi_ds = clam*salf;
250 double dz_ds = slam;
251 return new CylindricalPath(r, phi, z, dr_ds, r_dphi_ds, dz_ds);
252 }
253
254
255
256
257
258
259
260
261
262 public double qOverP( TrackVector vec)
263 {
264 double tlam = vec.vector()[ITLM];
265 double clam = 1.0/Math.sqrt(1.0+tlam*tlam);
266
267 return vec.vector()[IQPT]*clam;
268 }
269
270
271
272
273
274
275
276
277
278
279 public TrackSurfaceDirection direction( TrackVector vec)
280 {
281 double aalf = Math.abs( TRFMath.fmod2( vec.get(IALF), TRFMath.TWOPI ) );
282 Assert.assertTrue( aalf <= Math.PI );
283 if ( aalf <= TRFMath.PI2 ) return TrackSurfaceDirection.TSD_FORWARD;
284 else return TrackSurfaceDirection.TSD_BACKWARD;
285 }
286
287
288
289
290
291
292
293 public String toString()
294 {
295 return super.toString() + ": radius= "+_radius;
296 }
297
298
299
300
301
302
303
304
305
306 public TrackVector vecDiff( TrackVector vec1,
307 TrackVector vec2)
308 {
309 TrackVector diff = new TrackVector(vec1);
310 diff = diff.minus(vec2);
311 double tmp = TRFMath.fmod2( diff.get(SurfCylinder.IPHI), TRFMath.TWOPI );
312 diff.set(SurfCylinder.IPHI, tmp);
313 return diff;
314 }
315
316
317 }