55 std::array<int32_t, 4> & outTOB)
const {
61 throw std::runtime_error(
"Could not retrieve DB tool");
64 std::string fwVersion = myDBTool->get_FWVersion();
65 int major = std::stoi(fwVersion);
66 bool SumETfast = (major >= 1);
67 bool metRho = (major >= 2);
91 Ascaled[irow][jcolumn] = Atwr[irow][jcolumn] >> 2;
92 AgBlk[irow][jcolumn] = AgBlk[irow][jcolumn] >> 2;
94 Bscaled[irow][jcolumn] = Btwr[irow][jcolumn] >> 2;
95 BgBlk[irow][jcolumn] = BgBlk[irow][jcolumn] >> 2;
97 Cscaled[irow][jcolumn] = Ctwr[irow][jcolumn] >> 2;
98 CgBlk[irow][jcolumn] = CgBlk[irow][jcolumn] >> 2;
152 int total_sumEt = 0x0;
159 if (metRho)
metFPGA_rho(0, Ascaled, pucA_JWJ, AgBlk,
m_gBlockthresholdA,
m_aFPGA_A,
m_bFPGA_A, A_MHT_x, A_MHT_y, A_MST_x, A_MST_y, A_MET_x, A_MET_y);
160 else metFPGA(0, Ascaled, AgBlk,
m_gBlockthresholdA,
m_aFPGA_A,
m_bFPGA_A, A_MHT_x, A_MHT_y, A_MST_x, A_MST_y, A_MET_x, A_MET_y);
164 if (metRho)
metFPGA_rho(1, Bscaled, pucB_JWJ, BgBlk,
m_gBlockthresholdB,
m_aFPGA_B,
m_bFPGA_B, B_MHT_x, B_MHT_y, B_MST_x, B_MST_y, B_MET_x, B_MET_y);
165 else metFPGA(1, Bscaled, BgBlk,
m_gBlockthresholdB,
m_aFPGA_B,
m_bFPGA_B, B_MHT_x, B_MHT_y, B_MST_x, B_MST_y, B_MET_x, B_MET_y);
169 if (metRho)
metFPGA_rho(2, Cscaled, pucC_JWJ, CgBlk,
m_gBlockthresholdC,
m_aFPGA_C,
m_bFPGA_C, C_MHT_x, C_MHT_y, C_MST_x, C_MST_y, C_MET_x, C_MET_y);
170 else metFPGA(2, Cscaled, CgBlk,
m_gBlockthresholdC,
m_aFPGA_C,
m_bFPGA_C, C_MHT_x, C_MHT_y, C_MST_x, C_MST_y, C_MET_x, C_MET_y);
174 metTotal(A_MHT_x, A_MHT_y, B_MHT_x, B_MHT_y, C_MHT_x, C_MHT_y, MHT_x, MHT_y);
175 metTotal(A_MST_x, A_MST_y, B_MST_x, B_MST_y, C_MST_x, C_MST_y, MST_x, MST_y);
176 metTotal(A_MET_x, A_MET_y, B_MET_x, B_MET_y, C_MET_x, C_MET_y, MET_x, MET_y);
178 etTotal(A_eth, B_eth, C_eth, ETH);
179 etTotal(A_ets, B_ets, C_ets, ETS);
180 etTotal(A_etw, B_etw, C_etw, ETW);
184 int MET2 = MET_x * MET_x + MET_y * MET_y;
186 if (MET2 > 0x0FFFFFF) {
190 MET = std::sqrt(MET2);
202 std::vector<std::unique_ptr<gFEXJwoJTOB>> tobs_v;
210 outTOB[0] = (total_sumEt & 0x00000FFF) << 0;
211 outTOB[0] = outTOB[0] | (
MET & 0x00000FFF) << 12;
212 if (total_sumEt != 0) outTOB[0] = outTOB[0] | 0x00000001 << 24;
213 if (
MET != 0) outTOB[0] = outTOB[0] | 0x00000001 << 25;
214 outTOB[0] = outTOB[0] | (1 & 0x0000001F) << 26;
219 outTOB[1] = (MET_y & 0x00000FFF) << 0;
220 outTOB[1] = outTOB[1] | (MET_x & 0x00000FFF) << 12;
221 if (MET_y != 0) outTOB[1] = outTOB[1] | 0x00000001 << 24;
222 if (MET_x != 0) outTOB[1] = outTOB[1] | 0x00000001 << 25;
223 outTOB[1] = outTOB[1] | (2 & 0x0000001F) << 26;
226 outTOB[2] = (MHT_y & 0x00000FFF) << 0;
227 outTOB[2] = outTOB[2] | (MHT_x & 0x00000FFF) << 12;
228 if (MHT_y != 0) outTOB[2] = outTOB[2] | 0x00000001 << 24;
229 if (MHT_x != 0) outTOB[2] = outTOB[2] | 0x00000001 << 25;
230 outTOB[2] = outTOB[2] | (3 & 0x0000001F) << 26;
233 outTOB[3] = (MST_y & 0x00000FFF) << 0;
234 outTOB[3] = outTOB[3] | (MST_x & 0x00000FFF) << 12;
235 if (MST_y != 0) outTOB[3] = outTOB[3] | 0x00000001 << 24;
236 if (MST_x != 0) outTOB[3] = outTOB[3] | 0x00000001 << 25;
237 outTOB[3] = outTOB[3] | (4 & 0x0000001F) << 26;
240 tobs_v[0] = std::make_unique<gFEXJwoJTOB>();
241 tobs_v[0]->setWord(outTOB[0]);
242 tobs_v[0]->setQuantity1(
MET);
243 tobs_v[0]->setQuantity2(total_sumEt);
244 tobs_v[0]->setSaturation(0);
245 tobs_v[0]->setTobID(1);
246 if(
MET != 0 ) tobs_v[0]->setStatus1(1);
247 else tobs_v[0]->setStatus1(0);
248 if(total_sumEt!= 0) tobs_v[0]->setStatus2(1);
249 else tobs_v[0]->setStatus2(0);
251 tobs_v[1] = std::make_unique<gFEXJwoJTOB>();
252 tobs_v[1]->setWord(outTOB[1]);
253 tobs_v[1]->setQuantity1(MET_x);
254 tobs_v[1]->setQuantity2(MET_y);
255 tobs_v[1]->setSaturation(0);
256 tobs_v[1]->setTobID(2);
257 if( MET_x != 0 ) tobs_v[1]->setStatus1(1);
258 else tobs_v[1]->setStatus1(0);
259 if(MET_y!= 0) tobs_v[1]->setStatus2(1);
260 else tobs_v[1]->setStatus2(0);
262 tobs_v[2] = std::make_unique<gFEXJwoJTOB>();
263 tobs_v[2]->setWord(outTOB[2]);
264 tobs_v[2]->setQuantity1(MHT_x);
265 tobs_v[2]->setQuantity2(MHT_y);
266 tobs_v[2]->setSaturation(0);
267 tobs_v[2]->setTobID(3);
268 if( MHT_x != 0 ) tobs_v[2]->setStatus1(1);
269 else tobs_v[2]->setStatus1(0);
270 if(MHT_y!= 0) tobs_v[2]->setStatus2(1);
271 else tobs_v[2]->setStatus2(0);
273 tobs_v[3] = std::make_unique<gFEXJwoJTOB>();
274 tobs_v[3]->setWord(outTOB[3]);
275 tobs_v[3]->setQuantity1(MST_x);
276 tobs_v[3]->setQuantity2(MST_y);
277 tobs_v[3]->setSaturation(0);
278 tobs_v[3]->setTobID(4);
279 if( MST_x != 0 ) tobs_v[3]->setStatus1(1);
280 else tobs_v[2]->setStatus1(0);
281 if(MST_y!= 0) tobs_v[3]->setStatus2(1);
282 else tobs_v[3]->setStatus2(0);
337 int aFPGA,
int bFPGA,
338 int & MHT_x,
int & MHT_y,
339 int & MST_x,
int & MST_y,
340 int & MET_x,
int & MET_y)
const {
341 gBlockthreshold = gBlockthreshold * 200 / 800;
354 int64_t RHO_SUM_OF_COS_h_tx_hi = 0;
355 int64_t RHO_SUM_OF_SIN_h_ty_hi = 0;
356 int64_t RHO_SUM_OF_COS_h_tx_lw = 0;
357 int64_t RHO_SUM_OF_SIN_h_ty_lw = 0;
359 int64_t RHO_SUM_OF_COS_e_tx_hi = 0;
360 int64_t RHO_SUM_OF_SIN_e_ty_hi = 0;
361 int64_t RHO_SUM_OF_COS_e_tx_lw = 0;
362 int64_t RHO_SUM_OF_SIN_e_ty_lw = 0;
366 for(
int jcolumn = 6; jcolumn<12; jcolumn++){
368 int frow = 2*(irow/2) + 1;
370 if(gBlkSum[irow][jcolumn] > gBlockthreshold){
371 h_tx_hi += (twrs[irow][jcolumn])*(
cosLUT(frow, 5));
372 h_ty_hi += (twrs[irow][jcolumn])*(
sinLUT(frow, 5));
373 RHO_SUM_OF_COS_h_tx_hi += (
cosLUT(frow, 5));
374 RHO_SUM_OF_SIN_h_ty_hi += (
sinLUT(frow, 5));
377 e_tx_hi += (twrs[irow][jcolumn])*(
cosLUT(frow, 5));
378 e_ty_hi += (twrs[irow][jcolumn])*(
sinLUT(frow, 5));
379 RHO_SUM_OF_COS_e_tx_hi += (
cosLUT(frow, 5));
380 RHO_SUM_OF_SIN_e_ty_hi += (
sinLUT(frow, 5));
385 if(gBlkSum[irow][jcolumn] > gBlockthreshold){
386 h_tx_hi += (twrs[irow][jcolumn])*(
cosLUT(irow, 5));
387 h_ty_hi += (twrs[irow][jcolumn])*(
sinLUT(irow, 5));
388 RHO_SUM_OF_COS_h_tx_hi += (
cosLUT(irow, 5));
389 RHO_SUM_OF_SIN_h_ty_hi += (
sinLUT(irow, 5));
391 e_tx_hi += (twrs[irow][jcolumn])*(
cosLUT(irow, 5));
392 e_ty_hi += (twrs[irow][jcolumn])*(
sinLUT(irow, 5));
393 RHO_SUM_OF_COS_e_tx_hi += (
cosLUT(irow, 5));
394 RHO_SUM_OF_SIN_e_ty_hi += (
sinLUT(irow, 5));
399 for(
int jcolumn = 0; jcolumn<6; jcolumn++){
401 int frow = 2*(irow/2) + 1;
403 if(gBlkSum[irow][jcolumn] > gBlockthreshold){
404 h_tx_lw += (twrs[irow][jcolumn])*(
cosLUT(frow, 5));
405 h_ty_lw += (twrs[irow][jcolumn])*(
sinLUT(frow, 5));
406 RHO_SUM_OF_COS_h_tx_lw += (
cosLUT(frow, 5));
407 RHO_SUM_OF_SIN_h_ty_lw += (
sinLUT(frow, 5));
409 e_tx_lw += (twrs[irow][jcolumn])*(
cosLUT(frow, 5));
410 e_ty_lw += (twrs[irow][jcolumn])*(
sinLUT(frow, 5));
411 RHO_SUM_OF_COS_e_tx_lw += (
cosLUT(frow, 5));
412 RHO_SUM_OF_SIN_e_ty_lw += (
sinLUT(frow, 5));
416 if(gBlkSum[irow][jcolumn] > gBlockthreshold){
417 h_tx_lw += (twrs[irow][jcolumn])*(
cosLUT(irow, 5));
418 h_ty_lw += (twrs[irow][jcolumn])*(
sinLUT(irow, 5));
419 RHO_SUM_OF_COS_h_tx_lw += (
cosLUT(irow, 5));
420 RHO_SUM_OF_SIN_h_ty_lw += (
sinLUT(irow, 5));
422 e_tx_lw += (twrs[irow][jcolumn])*(
cosLUT(irow, 5));
423 e_ty_lw += (twrs[irow][jcolumn])*(
sinLUT(irow, 5));
424 RHO_SUM_OF_COS_e_tx_lw += (
cosLUT(irow, 5));
425 RHO_SUM_OF_SIN_e_ty_lw += (
sinLUT(irow, 5));
433 long int fMHT_x = (h_tx_hi + h_tx_lw) ;
434 long int fMHT_y = (h_ty_hi + h_ty_lw) ;
435 long int fMST_x = (e_tx_hi + e_tx_lw) ;
436 long int fMST_y = (e_ty_hi + e_ty_lw) ;
438 long int RHO_MULTIPLIED_BY_SUM_OF_COS_HARD_RESULT_hi = ( puc_jwj * (RHO_SUM_OF_COS_h_tx_hi) ) >> 4 ;
439 long int RHO_MULTIPLIED_BY_SUM_OF_SIN_HARD_RESULT_hi = ( puc_jwj * (RHO_SUM_OF_SIN_h_ty_hi) ) >> 4 ;
440 long int RHO_MULTIPLIED_BY_SUM_OF_COS_SOFT_RESULT_hi = ( puc_jwj * (RHO_SUM_OF_COS_e_tx_hi) ) >> 4 ;
441 long int RHO_MULTIPLIED_BY_SUM_OF_SIN_SOFT_RESULT_hi = ( puc_jwj * (RHO_SUM_OF_SIN_e_ty_hi) ) >> 4 ;
444 long int RHO_MULTIPLIED_BY_SUM_OF_COS_HARD_RESULT_lw = ( puc_jwj * (RHO_SUM_OF_COS_h_tx_lw) ) >> 4 ;
445 long int RHO_MULTIPLIED_BY_SUM_OF_SIN_HARD_RESULT_lw = ( puc_jwj * (RHO_SUM_OF_SIN_h_ty_lw) ) >> 4 ;
446 long int RHO_MULTIPLIED_BY_SUM_OF_COS_SOFT_RESULT_lw = ( puc_jwj * (RHO_SUM_OF_COS_e_tx_lw) ) >> 4 ;
447 long int RHO_MULTIPLIED_BY_SUM_OF_SIN_SOFT_RESULT_lw = ( puc_jwj * (RHO_SUM_OF_SIN_e_ty_lw) ) >> 4 ;
449 long int RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_tx_hi = (h_tx_hi - RHO_MULTIPLIED_BY_SUM_OF_COS_HARD_RESULT_hi) ;
450 long int RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_ty_hi = (h_ty_hi - RHO_MULTIPLIED_BY_SUM_OF_SIN_HARD_RESULT_hi) ;
451 long int RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_tx_hi = (e_tx_hi - RHO_MULTIPLIED_BY_SUM_OF_COS_SOFT_RESULT_hi) ;
452 long int RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_ty_hi = (e_ty_hi - RHO_MULTIPLIED_BY_SUM_OF_SIN_SOFT_RESULT_hi) ;
454 long int RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_tx_lw = (h_tx_lw - RHO_MULTIPLIED_BY_SUM_OF_COS_HARD_RESULT_lw) ;
455 long int RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_ty_lw = (h_ty_lw - RHO_MULTIPLIED_BY_SUM_OF_SIN_HARD_RESULT_lw) ;
456 long int RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_tx_lw = (e_tx_lw - RHO_MULTIPLIED_BY_SUM_OF_COS_SOFT_RESULT_lw) ;
457 long int RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_ty_lw = (e_ty_lw - RHO_MULTIPLIED_BY_SUM_OF_SIN_SOFT_RESULT_lw) ;
459 MHT_x = (RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_tx_hi + RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_tx_lw) >> 3;
460 MHT_y = (RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_ty_hi + RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_ty_lw) >> 3;
461 MST_x = (RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_tx_hi + RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_tx_lw) >> 3;
462 MST_y = (RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_ty_hi + RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_ty_lw) >> 3;
464 fMHT_x = (RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_tx_hi + RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_tx_lw) ;
465 fMHT_y = (RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_ty_hi + RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_ty_lw) ;
466 fMST_x = (RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_tx_hi + RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_tx_lw) ;
467 fMST_y = (RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_ty_hi + RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_ty_lw) ;
469 long int fMET_x = ( aFPGA * (fMHT_x) + bFPGA * (fMST_x) ) >> 13 ;
470 long int fMET_y = ( aFPGA * (fMHT_y) + bFPGA * (fMST_y) ) >> 13 ;
480 int aFPGA,
int bFPGA,
481 int & MHT_x,
int & MHT_y,
482 int & MST_x,
int & MST_y,
483 int & MET_x,
int & MET_y)
const {
485 gBlockthreshold = gBlockthreshold * 200 / 800;
498 for(
int jcolumn = 6; jcolumn<12; jcolumn++){
500 int frow = 2*(irow/2) + 1;
502 if(gBlkSum[irow][jcolumn] > gBlockthreshold){
503 h_tx_hi += (twrs[irow][jcolumn])*(
cosLUT(frow, 5));
504 h_ty_hi += (twrs[irow][jcolumn])*(
sinLUT(frow, 5));
506 e_tx_hi += (twrs[irow][jcolumn])*(
cosLUT(frow, 5));
507 e_ty_hi += (twrs[irow][jcolumn])*(
sinLUT(frow, 5));
512 if(gBlkSum[irow][jcolumn] > gBlockthreshold){
513 h_tx_hi += (twrs[irow][jcolumn])*(
cosLUT(irow, 5));
514 h_ty_hi += (twrs[irow][jcolumn])*(
sinLUT(irow, 5));
516 e_tx_hi += (twrs[irow][jcolumn])*(
cosLUT(irow, 5));
517 e_ty_hi += (twrs[irow][jcolumn])*(
sinLUT(irow, 5));
522 for(
int jcolumn = 0; jcolumn<6; jcolumn++){
524 int frow = 2*(irow/2) + 1;
526 if(gBlkSum[irow][jcolumn] > gBlockthreshold){
527 h_tx_lw += (twrs[irow][jcolumn])*(
cosLUT(frow, 5));
528 h_ty_lw += (twrs[irow][jcolumn])*(
sinLUT(frow, 5));
530 e_tx_lw += (twrs[irow][jcolumn])*(
cosLUT(frow, 5));
531 e_ty_lw += (twrs[irow][jcolumn])*(
sinLUT(frow, 5));
535 if(gBlkSum[irow][jcolumn] > gBlockthreshold){
536 h_tx_lw += (twrs[irow][jcolumn])*(
cosLUT(irow, 5));
537 h_ty_lw += (twrs[irow][jcolumn])*(
sinLUT(irow, 5));
539 e_tx_lw += (twrs[irow][jcolumn])*(
cosLUT(irow, 5));
540 e_ty_lw += (twrs[irow][jcolumn])*(
sinLUT(irow, 5));
551 long int fMHT_x = (h_tx_hi + h_tx_lw) ;
552 long int fMHT_y = (h_ty_hi + h_ty_lw) ;
553 long int fMST_x = (e_tx_hi + e_tx_lw) ;
554 long int fMST_y = (e_ty_hi + e_ty_lw) ;
556 MHT_x = (h_tx_hi + h_tx_lw) >> 3;
557 MHT_y = (h_ty_hi + h_ty_lw) >> 3;
558 MST_x = (e_tx_hi + e_tx_lw) >> 3;
559 MST_y = (e_ty_hi + e_ty_lw) >> 3;
567 long int fMET_x = ( aFPGA * (fMHT_x) + bFPGA * (fMST_x) ) >> 13 ;
568 long int fMET_y = ( aFPGA * (fMHT_y) + bFPGA * (fMST_y) ) >> 13 ;