Skip to content

Commit 0c709fa

Browse files
authored
feat: little DC ClusterCleanupUtilities initialization cleanup, optimization (#1288)
* make local variable final for clarity * cleanup initialization * reduce calculations
1 parent 285a8ef commit 0c709fa

1 file changed

Lines changed: 15 additions & 20 deletions

File tree

‎reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterCleanerUtilities.java‎

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -74,34 +74,29 @@ public List<FittedCluster> ClusterSplitter(FittedCluster clus, int nextClsStartI
7474
/// determined.
7575
/// This is a preliminary pattern recognition method used to identify
7676
/// reconstructed hits belonging to the same track-segment.
77-
int N_t = 180;
77+
final int N_t = 180;
7878

7979
// From this calculate the bin size in the theta accumulator array
80-
double ThetaMin = 0.;
81-
double ThetaMax = 2. * Math.PI;
82-
double SizeThetaBin = (ThetaMax - ThetaMin) / ((double) N_t);
80+
final double ThetaMin = 0.;
81+
final double ThetaMax = 2. * Math.PI;
82+
final double SizeThetaBin = (ThetaMax - ThetaMin) / ((double) N_t);
8383

8484
// Define the dimension of the r accumulator array
85-
int N_r = 130;
85+
final int N_r = 130;
8686
// From this calculate the bin size in the theta accumulator array
87-
double RMin = -130;
88-
double RMax = 130;
87+
final double RMin = -130;
88+
final double RMax = 130;
89+
final double dR = RMax - RMin;
8990

90-
int[][] R_Phi_Accumul;
91-
R_Phi_Accumul = new int[N_r][N_t];
91+
int[][] R_Phi_Accumul = new int[N_r][N_t];
9292

9393
// cache the cos and sin theta values [for performance improvement]
94-
double[] cosTheta_RPhi_array;
95-
double[] sinTheta_RPhi_array;
94+
double[] cosTheta_RPhi_array = new double[N_t];
95+
double[] sinTheta_RPhi_array = new double[N_t];
9696

9797
// the values corresponding to the peaks in the array
98-
double[] binrMaxR_Phi;
99-
double[] bintMaxR_Phi;
100-
binrMaxR_Phi = new double[N_r * N_t];
101-
bintMaxR_Phi = new double[N_r * N_t];
102-
103-
cosTheta_RPhi_array = new double[N_t];
104-
sinTheta_RPhi_array = new double[N_t];
98+
double[] binrMaxR_Phi = new double[N_r * N_t];
99+
double[] bintMaxR_Phi = new double[N_r * N_t];
105100

106101
for (int j_t = 0; j_t < N_t; j_t++) {
107102
// theta_j in the middle of the bin :
@@ -123,7 +118,7 @@ public List<FittedCluster> ClusterSplitter(FittedCluster clus, int nextClsStartI
123118
// r_j corresponding to that theta_j:
124119
double r_j = rho * cosTheta_RPhi_array[j_t] + phi * sinTheta_RPhi_array[j_t];
125120
// this value of r_j falls into the following bin in the r array:
126-
int j_r = (int) Math.floor(N_r * (r_j - RMin) / (float) (RMax - RMin));
121+
int j_r = (int) Math.floor(N_r * (r_j - RMin) / dR);
127122

128123
// increase this accumulator cell:
129124
R_Phi_Accumul[j_r][j_t]++;
@@ -177,7 +172,7 @@ public List<FittedCluster> ClusterSplitter(FittedCluster clus, int nextClsStartI
177172
// r_j corresponding to that theta_j:
178173
double r_j = rho * cosTheta_RPhi_array[j_t] + phi * sinTheta_RPhi_array[j_t];
179174
// this value of r_j falls into the following bin in the r array:
180-
int j_r = (int) Math.floor(N_r * (r_j - RMin) / (float) (RMax - RMin));
175+
int j_r = (int) Math.floor(N_r * (r_j - RMin) / dR);
181176

182177
// match bins:
183178
if (j_r == binrMaxR_Phi[p] && j_t == bintMaxR_Phi[p]) {

0 commit comments

Comments
 (0)