11package org .jlab .clas .swimtools ;
22
3- import org .apache .commons .math3 .util .FastMath ;
4-
53import org .jlab .geom .prim .Vector3D ;
64import org .jlab .geom .prim .Point3D ;
75import org .jlab .geom .prim .Line3D ;
3331 *
3432 * @author ziegler
3533 */
36- public class Swim {
37-
38- final double SWIMZMINMOM = 0.75 ; // GeV/c
39- final double MINTRKMOM = 0.05 ; // GeV/c
40-
41- private double _x0 ;
42- private double _y0 ;
43- private double _z0 ;
44- private double _phi ;
45- private double _theta ;
46- private double _pTot ;
47- private final double _rMax = 5 + 3 ;
48- private double _maxPathLength = 9 ;
49- private boolean SwimUnPhys = false ; //Flag to indicate if track is swimmable
50- private int _charge ;
51- double accuracy = 20e-6 ; // 20 microns
52- public double stepSize = 5.00 * 1.e-4 ; // 500 microns
53- public double distanceBetweenSaves = 100 *stepSize ;
54-
55- private ProbeCollection PC ;
56-
34+ public class Swim extends SwimPars implements ISwim {
35+
5736 /**
5837 * Class for swimming to various surfaces. The input and output units are cm and GeV/c
5938 */
@@ -65,157 +44,13 @@ public Swim() {
6544 }
6645 }
6746
68- /**
69- * Set max swimming path length
70- *
71- * @param _maxPathLength
72- */
73- public void setMaxPathLength (double _maxPathLength ) {
74- this ._maxPathLength = _maxPathLength ;
75- }
76-
77- /**
78- *
79- * @param direction +1 for out -1 for in
80- * @param x0 (cm)
81- * @param y0 (cm)
82- * @param z0 (cm)
83- * @param thx (units?)
84- * @param thy (units?)
85- * @param p (units?)
86- * @param charge
87- */
88- public void SetSwimParameters (int direction , double x0 , double y0 , double z0 ,
89- double thx , double thy , double p , int charge ) {
90- _x0 = x0 / 100 ; // convert to meters
91- _y0 = y0 / 100 ;
92- _z0 = z0 / 100 ;
93- this .checkR (_x0 , _y0 , _z0 );
94- double pz = direction * p / Math .sqrt (thx * thx + thy * thy + 1 );
95- double px = thx * pz ;
96- double py = thy * pz ;
97- _phi = Math .toDegrees (FastMath .atan2 (py , px ));
98- _pTot = Math .sqrt (px * px + py * py + pz * pz );
99- _theta = Math .toDegrees (Math .acos (pz / _pTot ));
100- _charge = direction * charge ;
101- }
102-
103- /**
104- * Sets the parameters used by swimmer based on the input track state vector
105- * parameters swimming outwards
106- *
107- * // z at a given DC plane in the tilted coordinate system
108- *
109- * @param superlayerIdx
110- * @param layerIdx
111- * @param x0 (cm)
112- * @param y0 (cm)
113- * @param z0 (cm)
114- * @param thx
115- * @param thy
116- * @param p
117- * @param charge
118- */
119- public void SetSwimParameters (int superlayerIdx , int layerIdx ,
120- double x0 , double y0 , double z0 ,
121- double thx , double thy , double p , int charge ) {
122- _x0 = x0 / 100 ; // convert to meters
123- _y0 = y0 / 100 ;
124- _z0 = z0 / 100 ;
125- this .checkR (_x0 , _y0 , _z0 );
126- double pz = p / Math .sqrt (thx * thx + thy * thy + 1 );
127- double px = thx * pz ;
128- double py = thy * pz ;
129- _phi = Math .toDegrees (FastMath .atan2 (py , px ));
130- _pTot = Math .sqrt (px * px + py * py + pz * pz );
131- _theta = Math .toDegrees (Math .acos (pz / _pTot ));
132- _charge = charge ;
133- }
134-
135- /**
136- * Sets the parameters used by swimmer based on the input track parameters
137- *
138- * @param x0 (cm)
139- * @param y0 (cm)
140- * @param z0 (cm)
141- * @param px
142- * @param py
143- * @param pz
144- * @param charge
145- */
146- public void SetSwimParameters (double x0 , double y0 , double z0 ,
147- double px , double py , double pz , int charge ) {
148- _x0 = x0 / 100 ; // convert to meters
149- _y0 = y0 / 100 ;
150- _z0 = z0 / 100 ;
151- this .checkR (_x0 , _y0 , _z0 );
152- _phi = Math .toDegrees (FastMath .atan2 (py , px ));
153- _pTot = Math .sqrt (px * px + py * py + pz * pz );
154- _theta = Math .toDegrees (Math .acos (pz / _pTot ));
155- _charge = charge ;
156- }
157-
158- /**
159- *
160- * @param xcm
161- * @param ycm
162- * @param zcm
163- * @param phiDeg
164- * @param thetaDeg
165- * @param p
166- * @param charge
167- * @param maxPathLength
168- */
169- public void SetSwimParameters (double xcm , double ycm , double zcm ,
170- double phiDeg , double thetaDeg ,
171- double p , int charge , double maxPathLength ) {
172- _maxPathLength = maxPathLength ;
173- _charge = charge ;
174- _phi = phiDeg ;
175- _theta = thetaDeg ;
176- _pTot = p ;
177- _x0 = xcm / 100 ;
178- _y0 = ycm / 100 ;
179- _z0 = zcm / 100 ;
180- this .checkR (_x0 , _y0 , _z0 );
181- }
182-
183- /**
184- *
185- * @param xcm
186- * @param ycm
187- * @param zcm
188- * @param phiDeg
189- * @param thetaDeg
190- * @param p
191- * @param charge
192- * @param maxPathLength
193- * @param Accuracy
194- * @param StepSize
195- */
196- public void SetSwimParameters (double xcm , double ycm , double zcm ,
197- double phiDeg , double thetaDeg ,
198- double p , int charge ,
199- double maxPathLength , double Accuracy , double StepSize ) {
200- _maxPathLength = maxPathLength ;
201- accuracy = Accuracy /100 ;
202- stepSize = StepSize /100 ;
203- _charge = charge ;
204- _phi = phiDeg ;
205- _theta = thetaDeg ;
206- _pTot = p ;
207- _x0 = xcm / 100 ;
208- _y0 = ycm / 100 ;
209- _z0 = zcm / 100 ;
210- this .checkR (_x0 , _y0 , _z0 );
211- }
212-
21347 /**
21448 *
21549 * @param sector
21650 * @param z_cm
21751 * @return
21852 */
53+ @ Override
21954 public double [] SwimToPlaneTiltSecSys (int sector , double z_cm ) {
22055
22156 // Fiducial Cut:
@@ -282,6 +117,7 @@ public double[] SwimToPlaneTiltSecSys(int sector, double z_cm) {
282117 * @param z_cm
283118 * @return
284119 */
120+ @ Override
285121 public double [] SwimToPlaneTiltSecSysBdlXZPlane (int sector , double z_cm ) {
286122
287123 // Fiducial Cut:
@@ -346,6 +182,7 @@ public double[] SwimToPlaneTiltSecSysBdlXZPlane(int sector, double z_cm) {
346182 * @param z_cm
347183 * @return state x,y,z,px,py,pz, pathlength, iBdl at the plane surface
348184 */
185+ @ Override
349186 public double [] SwimToPlaneLab (double z_cm ) {
350187
351188 // Fiducial Cut:
@@ -406,24 +243,12 @@ public double[] SwimToPlaneLab(double z_cm) {
406243 return value ;
407244 }
408245
409- /**
410- *
411- * @param _x0
412- * @param _y0
413- * @param _z0
414- */
415- private void checkR (double _x0 , double _y0 , double _z0 ) {
416- this .SwimUnPhys =false ;
417- if (Math .sqrt (_x0 *_x0 + _y0 *_y0 )>this ._rMax ||
418- Math .sqrt (_x0 *_x0 + _y0 *_y0 + _z0 *_z0 )>this ._maxPathLength )
419- this .SwimUnPhys =true ;
420- }
421-
422246 /**
423247 *
424248 * @param Rad
425249 * @return state x,y,z,px,py,pz, pathlength, iBdl at the surface
426250 */
251+ @ Override
427252 public double [] SwimToCylinder (double Rad ) {
428253
429254 if (this .SwimUnPhys ) return null ;
@@ -463,6 +288,7 @@ public double[] SwimRho(double radius) {
463288 * @param accuracy in cm
464289 * @return state x,y,z,px,py,pz, pathlength, iBdl at the surface
465290 */
291+ @ Override
466292 public double [] SwimRho (double radius , double accuracy ) {
467293
468294 if (this .SwimUnPhys ) return null ;
@@ -510,6 +336,7 @@ public double[] SwimGenCylinder(Point3D axisPoint1, Point3D axisPoint2, double r
510336 * @param accuracy in cm
511337 * @return swam trajectory to the cylinder
512338 */
339+ @ Override
513340 public double [] SwimGenCylinder (Point3D axisPoint1 , Point3D axisPoint2 , double radius , double accuracy ) {
514341
515342 if (this .SwimUnPhys ) return null ;
@@ -556,6 +383,7 @@ public double[] SwimGenCylinder(Point3D axisPoint1, Point3D axisPoint2, double r
556383 * @param accuracy
557384 * @return
558385 */
386+ @ Override
559387 public double [] SwimPlane (Vector3D n , Point3D p , double accuracy ) {
560388
561389 if (this .SwimUnPhys ) return null ;
@@ -592,6 +420,7 @@ public double[] SwimPlane(Vector3D n, Point3D p, double accuracy) {
592420 * @param Rad
593421 * @return state x,y,z,px,py,pz, pathlength, iBdl at the surface
594422 */
423+ @ Override
595424 public double [] SwimToSphere (double Rad ) {
596425
597426 if (this .SwimUnPhys ==true ) return null ;
@@ -623,6 +452,7 @@ public double[] SwimToSphere(double Rad) {
623452 * @param dir
624453 * @return return state x,y,z,px,py,pz, pathlength, iBdl at the plane surface in the lab frame
625454 */
455+ @ Override
626456 public double [] SwimToPlaneBoundary (double d_cm , Vector3D n , int dir ) {
627457
628458 if (this .SwimUnPhys ) return null ;
@@ -657,6 +487,7 @@ public double[] SwimToPlaneBoundary(double d_cm, Vector3D n, int dir) {
657487 return value ;
658488 }
659489
490+ @ Override
660491 public double [] SwimToBeamLine (double xB , double yB ) {
661492
662493 if (this .SwimUnPhys ==true ) return null ;
@@ -682,6 +513,7 @@ public double[] SwimToBeamLine(double xB, double yB) {
682513 return value ;
683514 }
684515
516+ @ Override
685517 public double [] SwimToLine (Line3D l ) {
686518
687519 if (this .SwimUnPhys ==true ) return null ;
@@ -707,43 +539,7 @@ public double[] SwimToLine(Line3D l) {
707539 return value ;
708540 }
709541
710- private void printV (String pfx , double v []) {
711- double x = v [0 ] / 100 ;
712- double y = v [1 ] / 100 ;
713- double z = v [2 ] / 100 ;
714- double r = Math .sqrt (x * x + y * y + z * z );
715- System .out .println (String .format ("%s: (%-8.5f, %-8.5f, %-8.5f) R: %-8.5f" , pfx , z , y , z , r ));
716- }
717-
718- /**
719- *
720- * @param sector
721- * @param x_cm
722- * @param y_cm
723- * @param z_cm
724- * @param result B field components in T in the tilted sector system
725- */
726- public void Bfield (int sector , double x_cm , double y_cm , double z_cm , float [] result ) {
727- PC .RCP .field (sector , (float ) x_cm , (float ) y_cm , (float ) z_cm , result );
728- result [0 ] = result [0 ] / 10 ;
729- result [1 ] = result [1 ] / 10 ;
730- result [2 ] = result [2 ] / 10 ;
731- }
732-
733- /**
734- *
735- * @param x_cm
736- * @param y_cm
737- * @param z_cm
738- * @param result B field components in T in the lab frame
739- */
740- public void BfieldLab (double x_cm , double y_cm , double z_cm , float [] result ) {
741- PC .CP .field ((float ) x_cm , (float ) y_cm , (float ) z_cm , result );
742- result [0 ] = result [0 ] / 10 ;
743- result [1 ] = result [1 ] / 10 ;
744- result [2 ] = result [2 ] / 10 ;
745- }
746-
542+ @ Override
747543 public double [] AdaptiveSwimPlane (double px , double py , double pz , double nx , double ny , double nz , double accuracy ) {
748544
749545 if (this .SwimUnPhys ) return null ;
@@ -781,6 +577,7 @@ public double[] AdaptiveSwimPlane(double px, double py, double pz, double nx, do
781577 return value ;
782578 }
783579
580+ @ Override
784581 public double [] AdaptiveSwimCylinder (double a1x , double a1y , double a1z , double a2x , double a2y , double a2z , double radius , double accuracy ) {
785582
786583 if (this .SwimUnPhys ) return null ;
@@ -821,6 +618,7 @@ public double[] AdaptiveSwimCylinder(double a1x, double a1y, double a1z, double
821618 return value ;
822619 }
823620
621+ @ Override
824622 public double [] AdaptiveSwimRho (double radius , double accuracy ) {
825623 System .out .println ("Don't use yet" );
826624 if (this .SwimUnPhys ) return null ;
@@ -859,6 +657,7 @@ public double[] AdaptiveSwimRho(double radius, double accuracy) {
859657 * @param dir
860658 * @return state x,y,z,px,py,pz, pathlength, iBdl at the surface
861659 */
660+ @ Override
862661 public double [] SwimToZ (double Z , int dir ) {
863662 double [] value = new double [8 ];
864663 ZSwimStopper stopper = new ZSwimStopper (Z , dir );
@@ -895,6 +694,7 @@ public void setSwimTraj(SwimTrajectory swimTraj) {
895694 this .swimTraj = swimTraj ;
896695 }
897696
697+ @ Override
898698 public double [] SwimToDCA (SwimTrajectory trk2 ) { //use for both traj to get doca for each track
899699
900700 double [] value = new double [6 ];
0 commit comments