-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHTCCCluster.java
More file actions
254 lines (197 loc) · 6.78 KB
/
HTCCCluster.java
File metadata and controls
254 lines (197 loc) · 6.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
package org.jlab.rec.htcc;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
*
* @author J. Hankins
* @author A. Puckett
* @author G. Gavalian
*/
class HTCCCluster {
private int nhitclust;
private int nthetaclust;
private int nphiclust;
private int ithetamin;
private int ithetamax;
private int iphimin;
private int iphimax;
private int nphetot;
private double theta;
private double dtheta;
private double phi;
private double dphi;
private double time;
private final List<Integer> hitnphe;
private final List<Integer> hititheta;
private final List<Integer> hitiphi;
private final Set<Integer> setitheta;
private final Set<Integer> setiphi;
private final List<Double> hittheta;
private final List<Double> hitphi;
private final List<Double> hitdtheta;
private final List<Double> hitdphi;
private final List<Double> hittime;
HTCCCluster() {
nhitclust = 0;
nthetaclust = 0;
nphiclust = 0;
ithetamin = 0;
ithetamax = 0;
iphimin = 0;
iphimax = 0;
nphetot = 0;
theta = 0.0;
dtheta = 0.0;
phi = 0.0;
dphi = 0.0;
time = 0.0;
hitnphe = new ArrayList<Integer>();
hititheta = new ArrayList<Integer>();
hitiphi = new ArrayList<Integer>();
hittheta = new ArrayList<Double>();
hitphi = new ArrayList<Double>();
hitdtheta = new ArrayList<Double>();
hitdphi = new ArrayList<Double>();
hittime = new ArrayList<Double>();
setitheta = new HashSet<Integer>();
setiphi = new HashSet<Integer>();
}
void addHit(int itheta, int iphi, int nphe, double time, double theta, double phi, double dtheta, double dphi) {
// TODO remove after testing
if (!(0 <= itheta && itheta < 4)) {
throw new IllegalArgumentException("itheta");
}
if (!(0 <= iphi && iphi < 12)) {
throw new IllegalArgumentException("iphi");
}
if (!(0 <= nphe)) {
throw new IllegalArgumentException("nphe");
}
setitheta.add(itheta);
setiphi.add(iphi);
hititheta.add(itheta);
hitiphi.add(iphi);
hitnphe.add(nphe);
hittime.add(time);
hittheta.add(theta);
hitphi.add(phi);
hitdtheta.add(Math.abs(dtheta)); // force errors to be positive
hitdphi.add(Math.abs(dphi)); // force errors to be positive
calcSums();
}
void calcSums() {
time = 0.0;
theta = 0.0;
phi = 0.0;
dtheta = 0.0;
dphi = 0.0;
double thetaTemp = 0.0;
double phiTemp = 0.0;
nphetot = 0;
nhitclust = hitnphe.size();
double cosphi = 0.0;
double sinphi = 0.0;
System.out.printf("n hits in da cluster " + nhitclust + "\n");
for (int i = 0; i < nhitclust; i++) {
thetaTemp = +hittheta.get(i);
phiTemp = +hitphi.get(i);
System.out.printf("theta temp calc" + i + " : " + thetaTemp + "\n");
}
thetaTemp /= nhitclust;
phiTemp /= nhitclust;
for (int i = 0; i < nhitclust; i++) {
if (i == 0 || hititheta.get(i) > ithetamax) {
ithetamax = hititheta.get(i);
}
if (i == 0 || hititheta.get(i) < ithetamin) {
ithetamin = hititheta.get(i);
}
if (i == 0 || hitiphi.get(i) > iphimax) {
iphimax = hitiphi.get(i);
}
if (i == 0 || hitiphi.get(i) < iphimin) {
iphimin = hitiphi.get(i);
}
nphetot += hitnphe.get(i);
time += hittime.get(i) * hitnphe.get(i);
System.out.printf("hittime.get(i) " + hittime.get(i) + "\n");
System.out.printf("npe " + i + " : " + hitnphe.get(i) + "\n");
System.out.printf("sum npe " + i + " : " + nphetot + "\n");
theta += (hittheta.get(i) + hitdtheta.get(i)*Math.signum(hittheta.get(i) - thetaTemp))* hitnphe.get(i);
System.out.printf("theta temp " + i + " : " + thetaTemp + "\n");
System.out.printf("theta " + i + " : " + hittheta.get(i) + "\n");
System.out.printf("hititheta " + i + " : " + hititheta.get(i) + "\n");
System.out.printf("dtheta " + hitdtheta.get(i) + "\n");
System.out.printf("coeff theta" + i + " : " + Math.signum(hittheta.get(i) - thetaTemp)+ "\n");
System.out.printf("sum theta " + i + " : " + theta + "\n");
cosphi += Math.cos(hitphi.get(i) + hitdphi.get(i)*Math.signum(hitphi.get(i) - phiTemp)) * hitnphe.get(i);
sinphi += Math.sin(hitphi.get(i) + hitdphi.get(i)*Math.signum(hitphi.get(i) - phiTemp)) * hitnphe.get(i);
System.out.printf("phi " + i + " : " + hitphi.get(i) + "\n");
System.out.printf("dphi " + hitdphi.get(i) + "\n");
System.out.printf("coeff phi" + i + " : " + Math.signum(hitphi.get(i) - phiTemp)+ "\n");
System.out.printf("hitiphi " + i + " : " + hitiphi.get(i) + "\n");
System.out.printf("phi temp " + i + " : " + phiTemp + "\n");
System.out.printf("sum cosphi " + i + " : " + cosphi + "\n");
}
time /= nphetot; // weighted average
// theta /= dtheta; //include dtheta weight
theta /= nphetot; //include npe weight
System.out.printf("res theta " + theta + "\n");
// cosphi /= dphi;
// sinphi /= dphi;
cosphi /= nphetot;
sinphi /= nphetot;
phi = Math.atan2(sinphi, cosphi);
dtheta = Math.pow(dtheta, -0.5);
dphi = Math.pow(dphi, -0.5);
nthetaclust = setitheta.size();
nphiclust = setiphi.size();
}
public int getNPheTot() {
return nphetot;
}
public int getNThetaClust() {
return nthetaclust;
}
public int getNPhiClust() {
return nphiclust;
}
public int getNHitClust() {
return nhitclust;
}
public int getIThetaMin() {
return ithetamin;
}
public int getIThetaMax() {
return ithetamax;
}
public int getIPhiMin() {
return iphimin;
}
public int getIPhiMax() {
return iphimax;
}
public double getTime() {
return time;
}
public double getTheta() {
return theta;
}
public double getPhi() {
return phi;
}
public double getDTheta() {
return dtheta;
}
public double getDPhi() {
return dphi;
}
public int getHitITheta(int hit) {
return hititheta.get(hit);
}
public int getHitIPhi(int hit) {
return hitiphi.get(hit);
}
}