Skip to content

Commit d9c9755

Browse files
committed
cleanup
1 parent b69d9b4 commit d9c9755

File tree

1 file changed

+15
-25
lines changed

1 file changed

+15
-25
lines changed

common-tools/swim-tools/src/main/java/org/jlab/clas/swimtools/AdaptiveSwim.java

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
public class AdaptiveSwim extends ASwim {
2121

2222
private static double[] convert(AdaptiveSwimResult result, double p) {
23+
2324
double[] value = null;
25+
2426
if (result.getStatus() == AdaptiveSwimmer.SWIM_SUCCESS) {
2527
value = new double[8];
2628
value[0] = result.getUf()[0] * 100; // convert back to cm
@@ -32,6 +34,7 @@ private static double[] convert(AdaptiveSwimResult result, double p) {
3234
value[6] = result.getFinalS() * 100;
3335
value[7] = 0; // Conversion from kG.m to T.cm
3436
}
37+
3538
return value;
3639
}
3740

@@ -43,13 +46,11 @@ public double[] SwimRho(double radius, double accuracy) {
4346

4447
try {
4548
AdaptiveSwimResult result = new AdaptiveSwimResult(false);
46-
4749
PC.AS.swimRho(_charge, _x0, _y0, _z0, _pTot, _theta, _phi, radius,
4850
accuracy/100, _rMax, stepSize, cnuphys.swim.Swimmer.getEps(), result);
49-
5051
return convert(result, _pTot);
51-
52-
} catch (AdaptiveSwimException e) {
52+
}
53+
catch (AdaptiveSwimException e) {
5354
e.printStackTrace();
5455
}
5556
return null;
@@ -62,19 +63,15 @@ public double[] SwimGenCylinder(Point3D axisPoint1, Point3D axisPoint2, double r
6263
radius = radius/100;
6364
Point a1 = new Point(axisPoint1.x()/100, axisPoint1.y()/100, axisPoint1.z()/100);
6465
Point a2 = new Point(axisPoint2.x()/100, axisPoint2.y()/100, axisPoint2.z()/100);
65-
Line centerLine = new Line(a1, a2);
66-
67-
Cylinder targetCylinder = new Cylinder(centerLine, radius);
66+
Cylinder targetCylinder = new Cylinder(new Line(a1,a2), radius);
6867

6968
try {
7069
AdaptiveSwimResult result = new AdaptiveSwimResult(false);
71-
7270
PC.AS.swimCylinder(_charge, _x0, _y0, _z0, _pTot, _theta, _phi, targetCylinder,
7371
accuracy/100, _rMax, stepSize, cnuphys.swim.Swimmer.getEps(), result);
74-
7572
return convert(result, _pTot);
76-
77-
} catch (AdaptiveSwimException e) {
73+
}
74+
catch (AdaptiveSwimException e) {
7875
e.printStackTrace();
7976
}
8077
return null;
@@ -86,18 +83,15 @@ public double[] SwimPlane(Vector3D n, Point3D p, double accuracy) {
8683
// convert to meters:
8784
Vector norm = new Vector(n.asUnit().x(), n.asUnit().y(), n.asUnit().z());
8885
Point point = new Point(p.x()/100, p.y()/100, p.z()/100);
89-
9086
Plane targetPlane = new Plane(norm, point);
9187

9288
try {
9389
AdaptiveSwimResult result = new AdaptiveSwimResult(false);
94-
9590
PC.AS.swimPlane(_charge, _x0, _y0, _z0, _pTot, _theta, _phi, targetPlane,
9691
accuracy/100, _rMax, stepSize, cnuphys.swim.Swimmer.getEps(), result);
97-
9892
return convert(result, _pTot);
99-
100-
} catch (AdaptiveSwimException e) {
93+
}
94+
catch (AdaptiveSwimException e) {
10195
e.printStackTrace();
10296
}
10397
return null;
@@ -111,13 +105,11 @@ public double[] SwimToSphere(double Rad) {
111105

112106
try {
113107
AdaptiveSwimResult result = new AdaptiveSwimResult(false);
114-
115108
PC.AS.swimSphere(_charge, _x0, _y0, _z0, _pTot, _theta, _phi, targetSphere,
116109
accuracy/100, _rMax, stepSize, cnuphys.swim.Swimmer.getEps(), result);
117-
118110
return convert(result, _pTot);
119-
120-
} catch (AdaptiveSwimException e) {
111+
}
112+
catch (AdaptiveSwimException e) {
121113
e.printStackTrace();
122114
}
123115
return null;
@@ -130,16 +122,14 @@ public double[] SwimToLine(Line3D l) {
130122
Point a1 = new Point(l.origin().x()/100, l.origin().y()/100, l.origin().z()/100);
131123
Point a2 = new Point(l.end().x()/100, l.end().y()/100, l.end().z()/100);
132124
Line targetLine = new Line(a1, a2);
133-
125+
134126
try {
135127
AdaptiveSwimResult result = new AdaptiveSwimResult(false);
136-
137128
PC.AS.swimLine(_charge, _x0, _y0, _z0, _pTot, _theta, _phi, targetLine,
138129
accuracy/100, _rMax, stepSize, cnuphys.swim.Swimmer.getEps(), result);
139-
140130
return convert(result, _pTot);
141-
142-
} catch (AdaptiveSwimException e) {
131+
}
132+
catch (AdaptiveSwimException e) {
143133
e.printStackTrace();
144134
}
145135
return null;

0 commit comments

Comments
 (0)