Skip to content

Commit 32e3887

Browse files
authored
fix: reduce CVT atan calculations (#1243)
* reduce atan calculations * restore
1 parent c7c550a commit 32e3887

1 file changed

Lines changed: 19 additions & 14 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: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -616,33 +616,38 @@ 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 {
626-
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();
624+
}
625+
else {
626+
629627
int thisreg = this.getOrderedRegion();
630628
int argreg = arg.getOrderedRegion();
631629
int RegComp = thisreg < argreg ? -1 : thisreg == argreg ? 0 : 1;
632-
// int RegComp = this.getRegion() < arg.getRegion() ? -1 : this.getRegion() == arg.getRegion() ? 0 : 1;
633630

634631
// check that is not BMTC for phi comparison
635632
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);
633+
if (RegComp == 0) {
634+
double phi0 = this.getPoint0().toVector3D().phi();
635+
double phi1 = arg.getPoint0().toVector3D().phi();
636+
return_val = phi0 < phi1 ? -1 : phi0 == phi1 ? 0 : 1;
637+
}
638+
else {
639+
return_val = RegComp;
640+
}
639641
}
640642
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);
643+
if (RegComp == 0) {
644+
return_val = this.getPoint0().z() < arg.getPoint0().z() ? -1 : this.getPoint0().z() == arg.getPoint0().z() ? 0 : 1;
645+
}
646+
else {
647+
return_val = RegComp;
648+
}
643649
}
644650
}
645-
646651
return return_val;
647652
}
648653

0 commit comments

Comments
 (0)