41 std::array<uint32_t, 4> & outTOB)
const {
46 int A_MET_x_rms = 0x0;
47 int A_MET_y_rms = 0x0;
50 int A_sumEt_rms = 0x0;
55 int B_MET_x_rms = 0x0;
56 int B_MET_y_rms = 0x0;
59 int B_sumEt_rms = 0x0;
64 int C_MET_x_rms = 0x0;
65 int C_MET_y_rms = 0x0;
68 int C_sumEt_rms = 0x0;
79 int total_sumEt_nc = 0x0;
80 int total_sumEt_rms = 0x0;
82 metFPGA(Atwr, A_MET_x_nc, A_MET_y_nc, 0);
83 metFPGA(Btwr, B_MET_x_nc, B_MET_y_nc, 1);
84 metFPGA(Ctwr, C_MET_x_nc, C_MET_y_nc, 2);
86 metTotal(A_MET_x_nc, A_MET_y_nc, B_MET_x_nc, B_MET_y_nc, C_MET_x_nc, C_MET_y_nc, MET_x_nc, MET_y_nc, MET_nc);
95 rho_MET(Atwr, A_MET_x_rms, A_MET_y_rms, A_rho, A_sigma);
96 rho_MET(Btwr, B_MET_x_rms, B_MET_y_rms, B_rho, B_sigma);
97 rho_MET(Ctwr, C_MET_x_rms, C_MET_y_rms, C_rho, C_sigma);
99 metTotal(A_MET_x_rms, A_MET_y_rms, B_MET_x_rms, B_MET_y_rms, C_MET_x_rms, C_MET_y_rms, MET_x_rms, MET_y_rms, MET_rms);
104 total_sumEt_nc =
sumEt(A_sumEt_nc, B_sumEt_nc, C_sumEt_nc);
105 total_sumEt_nc = total_sumEt_nc/4;
110 total_sumEt_rms =
sumEt(A_sumEt_rms, B_sumEt_rms, C_sumEt_rms);
111 total_sumEt_rms = total_sumEt_rms/4;
124 outTOB[0] = (MET_y_nc& 0x00000FFF) << 0;
125 outTOB[0] = outTOB[0] | (MET_x_nc & 0x00000FFF) << 12;
126 if (MET_y_nc != 0) outTOB[0] = outTOB[0] | 0x00000001 << 24;
127 if (MET_x_nc != 0) outTOB[0] = outTOB[0] | 0x00000001 << 25;
128 outTOB[0] = outTOB[0] | (2 & 0x0000001F) << 26;
131 outTOB[1] = (MET_y_rms& 0x00000FFF) << 0;
132 outTOB[1] = outTOB[1] | (MET_x_rms & 0x00000FFF) << 12;
133 if (MET_y_rms != 0) outTOB[1] = outTOB[1] | 0x00000001 << 24;
134 if (MET_x_rms != 0) outTOB[1] = outTOB[1] | 0x00000001 << 25;
135 outTOB[1] = outTOB[1] | (2 & 0x0000001F) << 26;
138 outTOB[2] = (total_sumEt_nc& 0x00000FFF) << 0;
139 outTOB[2] = outTOB[2] | (MET_nc & 0x00000FFF) << 12;
140 if (total_sumEt_nc != 0) outTOB[2] = outTOB[2] | 0x00000001 << 24;
141 if (MET_nc != 0) outTOB[2] = outTOB[2] | 0x00000001 << 25;
142 outTOB[2] = outTOB[2] | (1 & 0x0000001F) << 26;
145 outTOB[3] = (total_sumEt_rms& 0x00000FFF) << 0;
146 outTOB[3] = outTOB[3] | (MET_rms & 0x00000FFF) << 12;
147 if (total_sumEt_rms != 0) outTOB[3] = outTOB[3] | 0x00000001 << 24;
148 if (MET_rms != 0) outTOB[3] = outTOB[3] | 0x00000001 << 25;
149 outTOB[3] = outTOB[3] | (1 & 0x0000001F) << 26;
155 static const int s_cosLUT[32] = {
156 31, 30, 29, 26, 22, 17, 12, 6,
157 0, -6,-12,-17,-22,-26,-29,-30,
158 -31,-30,-29,-26,-22,-17,-12, -6,
159 0, 6, 12, 17, 22, 26, 29, 30
161 static const int s_sinLUT[32] = {
162 0, 6, 12, 17, 22, 26, 29, 30,
163 31, 30, 29, 26, 22, 17, 12, 6,
164 0, -6,-12,-17,-22,-26,-29,-30,
165 -31,-30,-29,-26,-22,-17,-12, -6
168 int rows = twrs.size();
169 int cols = twrs[0].size();
171 for (
int irow = 0; irow < rows; irow++) {
173 for (
int jcolumn = 0; jcolumn < cols; jcolumn++) {
174 int tower_et = twrs[irow][jcolumn] & ~3;
175 if (tower_et >
m_etaThr[FPGA_NO][jcolumn]) {
179 MET_x += etasum * s_cosLUT[irow];
180 MET_y += etasum * s_sinLUT[irow];
189 const int B_MET_x,
const int B_MET_y,
190 const int C_MET_x,
const int C_MET_y,
191 int & MET_x,
int & MET_y,
int &
MET)
const {
193 MET_x = A_MET_x + B_MET_x + C_MET_x;
194 MET_y = A_MET_y + B_MET_y + C_MET_y;
196 if (MET_x < -0x0007FF) MET_x = -0x0007FF;
197 if (MET_y < -0x0007FF) MET_y = -0x0007FF;
199 if (MET_x > 0x0007FF) MET_x = 0x0007FF;
200 if (MET_y > 0x0007FF) MET_y = 0x0007FF;
202 int MET2 = MET_x * MET_x + MET_y * MET_y;
204 if (MET2 > 0x000FFF)
MET = 0x000FFF;
205 else if (MET2 < 0)
MET = 0x000FFF;
206 else MET = std::sqrt(MET2);