56 std::array<int32_t, 4> & outTOB)
const {
62 throw std::runtime_error(
"Could not retrieve DB tool");
65 std::string fwVersion = myDBTool->get_FWVersion();
66 int major = std::stoi(fwVersion);
67 bool SumETfast = (major >= 1);
68 bool metRho = (major >= 2);
92 Ascaled[irow][jcolumn] = Atwr[irow][jcolumn] >> 2;
93 AgBlk[irow][jcolumn] = AgBlk[irow][jcolumn] >> 2;
95 Bscaled[irow][jcolumn] = Btwr[irow][jcolumn] >> 2;
96 BgBlk[irow][jcolumn] = BgBlk[irow][jcolumn] >> 2;
98 Cscaled[irow][jcolumn] = Ctwr[irow][jcolumn] >> 2;
99 CgBlk[irow][jcolumn] = CgBlk[irow][jcolumn] >> 2;
153 int total_sumEt = 0x0;
160 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);
161 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);
165 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);
166 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);
170 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);
171 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);
175 metTotal(A_MHT_x, A_MHT_y, B_MHT_x, B_MHT_y, C_MHT_x, C_MHT_y, MHT_x, MHT_y);
176 metTotal(A_MST_x, A_MST_y, B_MST_x, B_MST_y, C_MST_x, C_MST_y, MST_x, MST_y);
177 metTotal(A_MET_x, A_MET_y, B_MET_x, B_MET_y, C_MET_x, C_MET_y, MET_x, MET_y);
179 etTotal(A_eth, B_eth, C_eth, ETH);
180 etTotal(A_ets, B_ets, C_ets, ETS);
181 etTotal(A_etw, B_etw, C_etw, ETW);
185 int MET2 = MET_x * MET_x + MET_y * MET_y;
187 if (MET2 > 0x0FFFFFF) {
191 MET = std::sqrt(MET2);
203 std::vector<std::unique_ptr<gFEXJwoJTOB>> tobs_v;
211 outTOB[0] = (total_sumEt & 0x00000FFF) << 0;
212 outTOB[0] = outTOB[0] | (
MET & 0x00000FFF) << 12;
213 if (total_sumEt != 0) outTOB[0] = outTOB[0] | 0x00000001 << 24;
214 if (
MET != 0) outTOB[0] = outTOB[0] | 0x00000001 << 25;
215 outTOB[0] = outTOB[0] | (1 & 0x0000001F) << 26;
220 outTOB[1] = (MET_y & 0x00000FFF) << 0;
221 outTOB[1] = outTOB[1] | (MET_x & 0x00000FFF) << 12;
222 if (MET_y != 0) outTOB[1] = outTOB[1] | 0x00000001 << 24;
223 if (MET_x != 0) outTOB[1] = outTOB[1] | 0x00000001 << 25;
224 outTOB[1] = outTOB[1] | (2 & 0x0000001F) << 26;
227 outTOB[2] = (MHT_y & 0x00000FFF) << 0;
228 outTOB[2] = outTOB[2] | (MHT_x & 0x00000FFF) << 12;
229 if (MHT_y != 0) outTOB[2] = outTOB[2] | 0x00000001 << 24;
230 if (MHT_x != 0) outTOB[2] = outTOB[2] | 0x00000001 << 25;
231 outTOB[2] = outTOB[2] | (3 & 0x0000001F) << 26;
234 outTOB[3] = (MST_y & 0x00000FFF) << 0;
235 outTOB[3] = outTOB[3] | (MST_x & 0x00000FFF) << 12;
236 if (MST_y != 0) outTOB[3] = outTOB[3] | 0x00000001 << 24;
237 if (MST_x != 0) outTOB[3] = outTOB[3] | 0x00000001 << 25;
238 outTOB[3] = outTOB[3] | (4 & 0x0000001F) << 26;
241 tobs_v[0] = std::make_unique<gFEXJwoJTOB>();
242 tobs_v[0]->setWord(outTOB[0]);
243 tobs_v[0]->setQuantity1(
MET);
244 tobs_v[0]->setQuantity2(total_sumEt);
245 tobs_v[0]->setSaturation(0);
246 tobs_v[0]->setTobID(1);
247 if(
MET != 0 ) tobs_v[0]->setStatus1(1);
248 else tobs_v[0]->setStatus1(0);
249 if(total_sumEt!= 0) tobs_v[0]->setStatus2(1);
250 else tobs_v[0]->setStatus2(0);
252 tobs_v[1] = std::make_unique<gFEXJwoJTOB>();
253 tobs_v[1]->setWord(outTOB[1]);
254 tobs_v[1]->setQuantity1(MET_x);
255 tobs_v[1]->setQuantity2(MET_y);
256 tobs_v[1]->setSaturation(0);
257 tobs_v[1]->setTobID(2);
258 if( MET_x != 0 ) tobs_v[1]->setStatus1(1);
259 else tobs_v[1]->setStatus1(0);
260 if(MET_y!= 0) tobs_v[1]->setStatus2(1);
261 else tobs_v[1]->setStatus2(0);
263 tobs_v[2] = std::make_unique<gFEXJwoJTOB>();
264 tobs_v[2]->setWord(outTOB[2]);
265 tobs_v[2]->setQuantity1(MHT_x);
266 tobs_v[2]->setQuantity2(MHT_y);
267 tobs_v[2]->setSaturation(0);
268 tobs_v[2]->setTobID(3);
269 if( MHT_x != 0 ) tobs_v[2]->setStatus1(1);
270 else tobs_v[2]->setStatus1(0);
271 if(MHT_y!= 0) tobs_v[2]->setStatus2(1);
272 else tobs_v[2]->setStatus2(0);
274 tobs_v[3] = std::make_unique<gFEXJwoJTOB>();
275 tobs_v[3]->setWord(outTOB[3]);
276 tobs_v[3]->setQuantity1(MST_x);
277 tobs_v[3]->setQuantity2(MST_y);
278 tobs_v[3]->setSaturation(0);
279 tobs_v[3]->setTobID(4);
280 if( MST_x != 0 ) tobs_v[3]->setStatus1(1);
281 else tobs_v[2]->setStatus1(0);
282 if(MST_y!= 0) tobs_v[3]->setStatus2(1);
283 else tobs_v[3]->setStatus2(0);
339 int aFPGA,
int bFPGA,
340 int & MHT_x,
int & MHT_y,
341 int & MST_x,
int & MST_y,
342 int & MET_x,
int & MET_y)
const {
343 gBlockthreshold = gBlockthreshold * 200 / 800;
356 int64_t RHO_SUM_OF_COS_h_tx_hi = 0;
357 int64_t RHO_SUM_OF_SIN_h_ty_hi = 0;
358 int64_t RHO_SUM_OF_COS_h_tx_lw = 0;
359 int64_t RHO_SUM_OF_SIN_h_ty_lw = 0;
361 int64_t RHO_SUM_OF_COS_e_tx_hi = 0;
362 int64_t RHO_SUM_OF_SIN_e_ty_hi = 0;
363 int64_t RHO_SUM_OF_COS_e_tx_lw = 0;
364 int64_t RHO_SUM_OF_SIN_e_ty_lw = 0;
368 for(
int jcolumn = 6; jcolumn<12; jcolumn++){
370 int frow = 2*(irow/2) + 1;
372 if(gBlkSum[irow][jcolumn] > gBlockthreshold){
373 h_tx_hi += (twrs[irow][jcolumn])*(
cosLUT(frow, 5));
374 h_ty_hi += (twrs[irow][jcolumn])*(
sinLUT(frow, 5));
375 RHO_SUM_OF_COS_h_tx_hi += (
cosLUT(frow, 5));
376 RHO_SUM_OF_SIN_h_ty_hi += (
sinLUT(frow, 5));
379 e_tx_hi += (twrs[irow][jcolumn])*(
cosLUT(frow, 5));
380 e_ty_hi += (twrs[irow][jcolumn])*(
sinLUT(frow, 5));
381 RHO_SUM_OF_COS_e_tx_hi += (
cosLUT(frow, 5));
382 RHO_SUM_OF_SIN_e_ty_hi += (
sinLUT(frow, 5));
387 if(gBlkSum[irow][jcolumn] > gBlockthreshold){
388 h_tx_hi += (twrs[irow][jcolumn])*(
cosLUT(irow, 5));
389 h_ty_hi += (twrs[irow][jcolumn])*(
sinLUT(irow, 5));
390 RHO_SUM_OF_COS_h_tx_hi += (
cosLUT(irow, 5));
391 RHO_SUM_OF_SIN_h_ty_hi += (
sinLUT(irow, 5));
393 e_tx_hi += (twrs[irow][jcolumn])*(
cosLUT(irow, 5));
394 e_ty_hi += (twrs[irow][jcolumn])*(
sinLUT(irow, 5));
395 RHO_SUM_OF_COS_e_tx_hi += (
cosLUT(irow, 5));
396 RHO_SUM_OF_SIN_e_ty_hi += (
sinLUT(irow, 5));
401 for(
int jcolumn = 0; jcolumn<6; jcolumn++){
403 int frow = 2*(irow/2) + 1;
405 if(gBlkSum[irow][jcolumn] > gBlockthreshold){
406 h_tx_lw += (twrs[irow][jcolumn])*(
cosLUT(frow, 5));
407 h_ty_lw += (twrs[irow][jcolumn])*(
sinLUT(frow, 5));
408 RHO_SUM_OF_COS_h_tx_lw += (
cosLUT(frow, 5));
409 RHO_SUM_OF_SIN_h_ty_lw += (
sinLUT(frow, 5));
411 e_tx_lw += (twrs[irow][jcolumn])*(
cosLUT(frow, 5));
412 e_ty_lw += (twrs[irow][jcolumn])*(
sinLUT(frow, 5));
413 RHO_SUM_OF_COS_e_tx_lw += (
cosLUT(frow, 5));
414 RHO_SUM_OF_SIN_e_ty_lw += (
sinLUT(frow, 5));
418 if(gBlkSum[irow][jcolumn] > gBlockthreshold){
419 h_tx_lw += (twrs[irow][jcolumn])*(
cosLUT(irow, 5));
420 h_ty_lw += (twrs[irow][jcolumn])*(
sinLUT(irow, 5));
421 RHO_SUM_OF_COS_h_tx_lw += (
cosLUT(irow, 5));
422 RHO_SUM_OF_SIN_h_ty_lw += (
sinLUT(irow, 5));
424 e_tx_lw += (twrs[irow][jcolumn])*(
cosLUT(irow, 5));
425 e_ty_lw += (twrs[irow][jcolumn])*(
sinLUT(irow, 5));
426 RHO_SUM_OF_COS_e_tx_lw += (
cosLUT(irow, 5));
427 RHO_SUM_OF_SIN_e_ty_lw += (
sinLUT(irow, 5));
435 long int fMHT_x = (h_tx_hi + h_tx_lw) ;
436 long int fMHT_y = (h_ty_hi + h_ty_lw) ;
437 long int fMST_x = (e_tx_hi + e_tx_lw) ;
438 long int fMST_y = (e_ty_hi + e_ty_lw) ;
440 long int RHO_MULTIPLIED_BY_SUM_OF_COS_HARD_RESULT_hi = ( puc_jwj * (RHO_SUM_OF_COS_h_tx_hi) ) >> 4 ;
441 long int RHO_MULTIPLIED_BY_SUM_OF_SIN_HARD_RESULT_hi = ( puc_jwj * (RHO_SUM_OF_SIN_h_ty_hi) ) >> 4 ;
442 long int RHO_MULTIPLIED_BY_SUM_OF_COS_SOFT_RESULT_hi = ( puc_jwj * (RHO_SUM_OF_COS_e_tx_hi) ) >> 4 ;
443 long int RHO_MULTIPLIED_BY_SUM_OF_SIN_SOFT_RESULT_hi = ( puc_jwj * (RHO_SUM_OF_SIN_e_ty_hi) ) >> 4 ;
446 long int RHO_MULTIPLIED_BY_SUM_OF_COS_HARD_RESULT_lw = ( puc_jwj * (RHO_SUM_OF_COS_h_tx_lw) ) >> 4 ;
447 long int RHO_MULTIPLIED_BY_SUM_OF_SIN_HARD_RESULT_lw = ( puc_jwj * (RHO_SUM_OF_SIN_h_ty_lw) ) >> 4 ;
448 long int RHO_MULTIPLIED_BY_SUM_OF_COS_SOFT_RESULT_lw = ( puc_jwj * (RHO_SUM_OF_COS_e_tx_lw) ) >> 4 ;
449 long int RHO_MULTIPLIED_BY_SUM_OF_SIN_SOFT_RESULT_lw = ( puc_jwj * (RHO_SUM_OF_SIN_e_ty_lw) ) >> 4 ;
451 long int RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_tx_hi = (h_tx_hi - RHO_MULTIPLIED_BY_SUM_OF_COS_HARD_RESULT_hi) ;
452 long int RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_ty_hi = (h_ty_hi - RHO_MULTIPLIED_BY_SUM_OF_SIN_HARD_RESULT_hi) ;
453 long int RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_tx_hi = (e_tx_hi - RHO_MULTIPLIED_BY_SUM_OF_COS_SOFT_RESULT_hi) ;
454 long int RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_ty_hi = (e_ty_hi - RHO_MULTIPLIED_BY_SUM_OF_SIN_SOFT_RESULT_hi) ;
456 long int RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_tx_lw = (h_tx_lw - RHO_MULTIPLIED_BY_SUM_OF_COS_HARD_RESULT_lw) ;
457 long int RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_ty_lw = (h_ty_lw - RHO_MULTIPLIED_BY_SUM_OF_SIN_HARD_RESULT_lw) ;
458 long int RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_tx_lw = (e_tx_lw - RHO_MULTIPLIED_BY_SUM_OF_COS_SOFT_RESULT_lw) ;
459 long int RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_ty_lw = (e_ty_lw - RHO_MULTIPLIED_BY_SUM_OF_SIN_SOFT_RESULT_lw) ;
461 MHT_x = (RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_tx_hi + RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_tx_lw) >> 3;
462 MHT_y = (RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_ty_hi + RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_ty_lw) >> 3;
463 MST_x = (RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_tx_hi + RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_tx_lw) >> 3;
464 MST_y = (RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_ty_hi + RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_ty_lw) >> 3;
466 fMHT_x = (RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_tx_hi + RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_tx_lw) ;
467 fMHT_y = (RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_ty_hi + RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_ty_lw) ;
468 fMST_x = (RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_tx_hi + RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_tx_lw) ;
469 fMST_y = (RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_ty_hi + RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_ty_lw) ;
471 long int fMET_x = ( aFPGA * (fMHT_x) + bFPGA * (fMST_x) ) >> 13 ;
472 long int fMET_y = ( aFPGA * (fMHT_y) + bFPGA * (fMST_y) ) >> 13 ;
482 int aFPGA,
int bFPGA,
483 int & MHT_x,
int & MHT_y,
484 int & MST_x,
int & MST_y,
485 int & MET_x,
int & MET_y)
const {
487 gBlockthreshold = gBlockthreshold * 200 / 800;
500 for(
int jcolumn = 6; jcolumn<12; jcolumn++){
502 int frow = 2*(irow/2) + 1;
504 if(gBlkSum[irow][jcolumn] > gBlockthreshold){
505 h_tx_hi += (twrs[irow][jcolumn])*(
cosLUT(frow, 5));
506 h_ty_hi += (twrs[irow][jcolumn])*(
sinLUT(frow, 5));
508 e_tx_hi += (twrs[irow][jcolumn])*(
cosLUT(frow, 5));
509 e_ty_hi += (twrs[irow][jcolumn])*(
sinLUT(frow, 5));
514 if(gBlkSum[irow][jcolumn] > gBlockthreshold){
515 h_tx_hi += (twrs[irow][jcolumn])*(
cosLUT(irow, 5));
516 h_ty_hi += (twrs[irow][jcolumn])*(
sinLUT(irow, 5));
518 e_tx_hi += (twrs[irow][jcolumn])*(
cosLUT(irow, 5));
519 e_ty_hi += (twrs[irow][jcolumn])*(
sinLUT(irow, 5));
524 for(
int jcolumn = 0; jcolumn<6; jcolumn++){
526 int frow = 2*(irow/2) + 1;
528 if(gBlkSum[irow][jcolumn] > gBlockthreshold){
529 h_tx_lw += (twrs[irow][jcolumn])*(
cosLUT(frow, 5));
530 h_ty_lw += (twrs[irow][jcolumn])*(
sinLUT(frow, 5));
532 e_tx_lw += (twrs[irow][jcolumn])*(
cosLUT(frow, 5));
533 e_ty_lw += (twrs[irow][jcolumn])*(
sinLUT(frow, 5));
537 if(gBlkSum[irow][jcolumn] > gBlockthreshold){
538 h_tx_lw += (twrs[irow][jcolumn])*(
cosLUT(irow, 5));
539 h_ty_lw += (twrs[irow][jcolumn])*(
sinLUT(irow, 5));
541 e_tx_lw += (twrs[irow][jcolumn])*(
cosLUT(irow, 5));
542 e_ty_lw += (twrs[irow][jcolumn])*(
sinLUT(irow, 5));
553 long int fMHT_x = (h_tx_hi + h_tx_lw) ;
554 long int fMHT_y = (h_ty_hi + h_ty_lw) ;
555 long int fMST_x = (e_tx_hi + e_tx_lw) ;
556 long int fMST_y = (e_ty_hi + e_ty_lw) ;
558 MHT_x = (h_tx_hi + h_tx_lw) >> 3;
559 MHT_y = (h_ty_hi + h_ty_lw) >> 3;
560 MST_x = (e_tx_hi + e_tx_lw) >> 3;
561 MST_y = (e_ty_hi + e_ty_lw) >> 3;
569 long int fMET_x = ( aFPGA * (fMHT_x) + bFPGA * (fMST_x) ) >> 13 ;
570 long int fMET_y = ( aFPGA * (fMHT_y) + bFPGA * (fMST_y) ) >> 13 ;