Skip to content

Commit 69c16c1

Browse files
committed
reduce atan calculations
1 parent 446b54d commit 69c16c1

1 file changed

Lines changed: 20 additions & 16 deletions

File tree

  • reconstruction/cvt/src/main/java/org/jlab/rec/cvt/cross

‎reconstruction/cvt/src/main/java/org/jlab/rec/cvt/cross/Cross.java‎

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -616,33 +616,37 @@ public int getSVTCosmicsRegion() {
616616
@Override
617617
public int compareTo(Cross arg) {
618618

619-
int return_val = 0;
620-
if(Constants.getInstance().isCosmics) {
619+
int return_val;
620+
if (Constants.getInstance().isCosmics) {
621621
int RegComp = this.getSVTCosmicsRegion() < arg.getSVTCosmicsRegion() ? -1 : this.getSVTCosmicsRegion() == arg.getSVTCosmicsRegion() ? 0 : 1;
622622
int IDComp = this.getId() < arg.getId() ? -1 : this.getId() == arg.getId() ? 0 : 1;
623-
624623
return_val = ((RegComp == 0) ? IDComp : RegComp);
625-
} else {
624+
}
625+
else {
626626

627-
//int thisreg = (this.getDetector().equalsIgnoreCase("BMT")) ? 3 + bgeom.getLayer( this.getRegion(), this.getDetectorType()) : this.getRegion();
628-
//int argreg = (arg.getDetector().equalsIgnoreCase("BMT")) ? 3 + bgeom.getLayer( arg.getRegion(), arg.getDetectorType()) : arg.getRegion();
629-
int thisreg = this.getOrderedRegion();
630-
int argreg = arg.getOrderedRegion();
631-
int RegComp = thisreg < argreg ? -1 : thisreg == argreg ? 0 : 1;
632-
// int RegComp = this.getRegion() < arg.getRegion() ? -1 : this.getRegion() == arg.getRegion() ? 0 : 1;
627+
int RegComp = this.getOrderedRegion() < arg.getOrderedRegion() ? -1 :
628+
this.getOrderedRegion() == arg.getOrderedRegion() ? 0 : 1;
633629

634630
// check that is not BMTC for phi comparison
635631
if( Double.isNaN(arg.getPoint().x())==false && Double.isNaN(this.getPoint().x())==false ) {
636-
int PhiComp = this.getPoint0().toVector3D().phi() < arg.getPoint0().toVector3D().phi() ? -1 : this.getPoint0().toVector3D().phi() == arg.getPoint0().toVector3D().phi() ? 0 : 1;
637-
638-
return_val = ((RegComp == 0) ? PhiComp : RegComp);
632+
if (RegComp == 0) {
633+
double phi0 = this.getPoint0().toVector3D().phi();
634+
double phi1 = arg.getPoint0().toVector3D().phi();
635+
return_val = phi0 < phi1 ? -1 : phi0 == phi1 ? 0 : 1;
636+
}
637+
else {
638+
return_val = RegComp;
639+
}
639640
}
640641
else {
641-
int ZComp = this.getPoint0().z() < arg.getPoint0().z() ? -1 : this.getPoint0().z() == arg.getPoint0().z() ? 0 : 1;
642-
return_val = ((RegComp == 0) ? ZComp : RegComp);
642+
if (RegComp == 0) {
643+
return_val = this.getPoint0().z() < arg.getPoint0().z() ? -1 : this.getPoint0().z() == arg.getPoint0().z() ? 0 : 1;
644+
}
645+
else {
646+
return_val = RegComp;
647+
}
643648
}
644649
}
645-
646650
return return_val;
647651
}
648652

0 commit comments

Comments
 (0)