42 std::array<int32_t, 4> & outTOB)
const {
48 throw std::runtime_error(
"Could not retrieve DB tool");
51 std::string fwVersion = myDBTool->get_FWVersion();
52 int major = std::stoi(fwVersion);
53 bool SumETfast = (major >= 1);
54 bool metRho = (major >= 2);
60 throw std::runtime_error(
"Could not retrieve L1Menu");
64 const auto & thr_gXE = l1Menu->thrExtraInfo().gXE();
65 int gBlockthresholdA = thr_gXE.seedThr(
'A');
66 int gBlockthresholdB = thr_gXE.seedThr(
'B');
67 int gBlockthresholdC = thr_gXE.seedThr(
'C');
68 int aFPGA_A = thr_gXE.JWOJ_param(
'A',
'a');
69 int bFPGA_A = thr_gXE.JWOJ_param(
'A',
'b');
70 int aFPGA_B = thr_gXE.JWOJ_param(
'B',
'a');
71 int bFPGA_B = thr_gXE.JWOJ_param(
'B',
'b');
72 int aFPGA_C = thr_gXE.JWOJ_param(
'C',
'a');
73 int bFPGA_C = thr_gXE.JWOJ_param(
'C',
'b');
87 gBlockAB(Atwr, AgBlk, hasSeed, gBlockthresholdA);
88 gBlockAB(Btwr, BgBlk, hasSeed, gBlockthresholdB);
89 gBlockAB(Ctwr, CgBlk, hasSeed, gBlockthresholdC);
97 Ascaled[irow][jcolumn] = Atwr[irow][jcolumn] >> 2;
98 AgBlk[irow][jcolumn] = AgBlk[irow][jcolumn] >> 2;
100 Bscaled[irow][jcolumn] = Btwr[irow][jcolumn] >> 2;
101 BgBlk[irow][jcolumn] = BgBlk[irow][jcolumn] >> 2;
103 Cscaled[irow][jcolumn] = Ctwr[irow][jcolumn] >> 2;
104 CgBlk[irow][jcolumn] = CgBlk[irow][jcolumn] >> 2;
158 int total_sumEt = 0x0;
164 if (metRho)
metFPGA_rho(0, Ascaled, pucA_JWJ, AgBlk, gBlockthresholdA, aFPGA_A, bFPGA_A, A_MHT_x, A_MHT_y, A_MST_x, A_MST_y, A_MET_x, A_MET_y);
165 else metFPGA(0, Ascaled, AgBlk, gBlockthresholdA, aFPGA_A, bFPGA_A, A_MHT_x, A_MHT_y, A_MST_x, A_MST_y, A_MET_x, A_MET_y);
166 if (SumETfast)
etFastFPGA(0, Ascaled, AgBlk, gBlockthresholdA, aFPGA_A, etBprime, A_eth, A_ets, A_etw);
167 else etFPGA(0, Ascaled, AgBlk, gBlockthresholdA, aFPGA_A, etBprime, A_eth, A_ets, A_etw);
169 if (metRho)
metFPGA_rho(1, Bscaled, pucB_JWJ, BgBlk, gBlockthresholdB, aFPGA_B, bFPGA_B, B_MHT_x, B_MHT_y, B_MST_x, B_MST_y, B_MET_x, B_MET_y);
170 else metFPGA(1, Bscaled, BgBlk, gBlockthresholdB, aFPGA_B, bFPGA_B, B_MHT_x, B_MHT_y, B_MST_x, B_MST_y, B_MET_x, B_MET_y);
171 if (SumETfast)
etFastFPGA(1, Bscaled, BgBlk, gBlockthresholdB, aFPGA_B, etBprime, B_eth, B_ets, B_etw);
172 else etFPGA(1, Bscaled, BgBlk, gBlockthresholdB, aFPGA_B, etBprime, B_eth, B_ets, B_etw);
174 if (metRho)
metFPGA_rho(2, Cscaled, pucC_JWJ, CgBlk, gBlockthresholdC, aFPGA_C, bFPGA_C, C_MHT_x, C_MHT_y, C_MST_x, C_MST_y, C_MET_x, C_MET_y);
175 else metFPGA(2, Cscaled, CgBlk, gBlockthresholdC, aFPGA_C, bFPGA_C, C_MHT_x, C_MHT_y, C_MST_x, C_MST_y, C_MET_x, C_MET_y);
176 if (SumETfast)
etFastFPGA(2, Cscaled, CgBlk, gBlockthresholdC, aFPGA_C, etBprime, C_eth, C_ets, C_etw);
177 else etFPGA(2, Cscaled, CgBlk, gBlockthresholdC, aFPGA_C, etBprime, C_eth, C_ets, C_etw);
179 metTotal(A_MHT_x, A_MHT_y, B_MHT_x, B_MHT_y, C_MHT_x, C_MHT_y, MHT_x, MHT_y);
180 metTotal(A_MST_x, A_MST_y, B_MST_x, B_MST_y, C_MST_x, C_MST_y, MST_x, MST_y);
181 metTotal(A_MET_x, A_MET_y, B_MET_x, B_MET_y, C_MET_x, C_MET_y, MET_x, MET_y);
183 etTotal(A_eth, B_eth, C_eth, ETH);
184 etTotal(A_ets, B_ets, C_ets, ETS);
185 etTotal(A_etw, B_etw, C_etw, ETW);
189 int MET2 = MET_x * MET_x + MET_y * MET_y;
191 if (MET2 > 0x0FFFFFF) {
195 MET = std::sqrt(MET2);
207 std::vector<std::unique_ptr<gFEXJwoJTOB>> tobs_v;
215 outTOB[0] = (total_sumEt & 0x00000FFF) << 0;
216 outTOB[0] = outTOB[0] | (
MET & 0x00000FFF) << 12;
217 if (total_sumEt != 0) outTOB[0] = outTOB[0] | 0x00000001 << 24;
218 if (
MET != 0) outTOB[0] = outTOB[0] | 0x00000001 << 25;
219 outTOB[0] = outTOB[0] | (1 & 0x0000001F) << 26;
224 outTOB[1] = (MET_y & 0x00000FFF) << 0;
225 outTOB[1] = outTOB[1] | (MET_x & 0x00000FFF) << 12;
226 if (MET_y != 0) outTOB[1] = outTOB[1] | 0x00000001 << 24;
227 if (MET_x != 0) outTOB[1] = outTOB[1] | 0x00000001 << 25;
228 outTOB[1] = outTOB[1] | (2 & 0x0000001F) << 26;
231 outTOB[2] = (MHT_y & 0x00000FFF) << 0;
232 outTOB[2] = outTOB[2] | (MHT_x & 0x00000FFF) << 12;
233 if (MHT_y != 0) outTOB[2] = outTOB[2] | 0x00000001 << 24;
234 if (MHT_x != 0) outTOB[2] = outTOB[2] | 0x00000001 << 25;
235 outTOB[2] = outTOB[2] | (3 & 0x0000001F) << 26;
238 outTOB[3] = (MST_y & 0x00000FFF) << 0;
239 outTOB[3] = outTOB[3] | (MST_x & 0x00000FFF) << 12;
240 if (MST_y != 0) outTOB[3] = outTOB[3] | 0x00000001 << 24;
241 if (MST_x != 0) outTOB[3] = outTOB[3] | 0x00000001 << 25;
242 outTOB[3] = outTOB[3] | (4 & 0x0000001F) << 26;
245 tobs_v[0] = std::make_unique<gFEXJwoJTOB>();
246 tobs_v[0]->setWord(outTOB[0]);
247 tobs_v[0]->setQuantity1(
MET);
248 tobs_v[0]->setQuantity2(total_sumEt);
249 tobs_v[0]->setSaturation(0);
250 tobs_v[0]->setTobID(1);
251 if(
MET != 0 ) tobs_v[0]->setStatus1(1);
252 else tobs_v[0]->setStatus1(0);
253 if(total_sumEt!= 0) tobs_v[0]->setStatus2(1);
254 else tobs_v[0]->setStatus2(0);
256 tobs_v[1] = std::make_unique<gFEXJwoJTOB>();
257 tobs_v[1]->setWord(outTOB[1]);
258 tobs_v[1]->setQuantity1(MET_x);
259 tobs_v[1]->setQuantity2(MET_y);
260 tobs_v[1]->setSaturation(0);
261 tobs_v[1]->setTobID(2);
262 if( MET_x != 0 ) tobs_v[1]->setStatus1(1);
263 else tobs_v[1]->setStatus1(0);
264 if(MET_y!= 0) tobs_v[1]->setStatus2(1);
265 else tobs_v[1]->setStatus2(0);
267 tobs_v[2] = std::make_unique<gFEXJwoJTOB>();
268 tobs_v[2]->setWord(outTOB[2]);
269 tobs_v[2]->setQuantity1(MHT_x);
270 tobs_v[2]->setQuantity2(MHT_y);
271 tobs_v[2]->setSaturation(0);
272 tobs_v[2]->setTobID(3);
273 if( MHT_x != 0 ) tobs_v[2]->setStatus1(1);
274 else tobs_v[2]->setStatus1(0);
275 if(MHT_y!= 0) tobs_v[2]->setStatus2(1);
276 else tobs_v[2]->setStatus2(0);
278 tobs_v[3] = std::make_unique<gFEXJwoJTOB>();
279 tobs_v[3]->setWord(outTOB[3]);
280 tobs_v[3]->setQuantity1(MST_x);
281 tobs_v[3]->setQuantity2(MST_y);
282 tobs_v[3]->setSaturation(0);
283 tobs_v[3]->setTobID(4);
284 if( MST_x != 0 ) tobs_v[3]->setStatus1(1);
285 else tobs_v[2]->setStatus1(0);
286 if(MST_y!= 0) tobs_v[3]->setStatus2(1);
287 else tobs_v[3]->setStatus2(0);
343 int aFPGA,
int bFPGA,
344 int & MHT_x,
int & MHT_y,
345 int & MST_x,
int & MST_y,
346 int & MET_x,
int & MET_y)
const {
347 gBlockthreshold = gBlockthreshold * 200 / 800;
360 int64_t RHO_SUM_OF_COS_h_tx_hi = 0;
361 int64_t RHO_SUM_OF_SIN_h_ty_hi = 0;
362 int64_t RHO_SUM_OF_COS_h_tx_lw = 0;
363 int64_t RHO_SUM_OF_SIN_h_ty_lw = 0;
365 int64_t RHO_SUM_OF_COS_e_tx_hi = 0;
366 int64_t RHO_SUM_OF_SIN_e_ty_hi = 0;
367 int64_t RHO_SUM_OF_COS_e_tx_lw = 0;
368 int64_t RHO_SUM_OF_SIN_e_ty_lw = 0;
372 for(
int jcolumn = 6; jcolumn<12; jcolumn++){
374 int frow = 2*(irow/2) + 1;
376 if(gBlkSum[irow][jcolumn] > gBlockthreshold){
377 h_tx_hi += (twrs[irow][jcolumn])*(
cosLUT(frow, 5));
378 h_ty_hi += (twrs[irow][jcolumn])*(
sinLUT(frow, 5));
379 RHO_SUM_OF_COS_h_tx_hi += (
cosLUT(frow, 5));
380 RHO_SUM_OF_SIN_h_ty_hi += (
sinLUT(frow, 5));
383 e_tx_hi += (twrs[irow][jcolumn])*(
cosLUT(frow, 5));
384 e_ty_hi += (twrs[irow][jcolumn])*(
sinLUT(frow, 5));
385 RHO_SUM_OF_COS_e_tx_hi += (
cosLUT(frow, 5));
386 RHO_SUM_OF_SIN_e_ty_hi += (
sinLUT(frow, 5));
391 if(gBlkSum[irow][jcolumn] > gBlockthreshold){
392 h_tx_hi += (twrs[irow][jcolumn])*(
cosLUT(irow, 5));
393 h_ty_hi += (twrs[irow][jcolumn])*(
sinLUT(irow, 5));
394 RHO_SUM_OF_COS_h_tx_hi += (
cosLUT(irow, 5));
395 RHO_SUM_OF_SIN_h_ty_hi += (
sinLUT(irow, 5));
397 e_tx_hi += (twrs[irow][jcolumn])*(
cosLUT(irow, 5));
398 e_ty_hi += (twrs[irow][jcolumn])*(
sinLUT(irow, 5));
399 RHO_SUM_OF_COS_e_tx_hi += (
cosLUT(irow, 5));
400 RHO_SUM_OF_SIN_e_ty_hi += (
sinLUT(irow, 5));
405 for(
int jcolumn = 0; jcolumn<6; jcolumn++){
407 int frow = 2*(irow/2) + 1;
409 if(gBlkSum[irow][jcolumn] > gBlockthreshold){
410 h_tx_lw += (twrs[irow][jcolumn])*(
cosLUT(frow, 5));
411 h_ty_lw += (twrs[irow][jcolumn])*(
sinLUT(frow, 5));
412 RHO_SUM_OF_COS_h_tx_lw += (
cosLUT(frow, 5));
413 RHO_SUM_OF_SIN_h_ty_lw += (
sinLUT(frow, 5));
415 e_tx_lw += (twrs[irow][jcolumn])*(
cosLUT(frow, 5));
416 e_ty_lw += (twrs[irow][jcolumn])*(
sinLUT(frow, 5));
417 RHO_SUM_OF_COS_e_tx_lw += (
cosLUT(frow, 5));
418 RHO_SUM_OF_SIN_e_ty_lw += (
sinLUT(frow, 5));
422 if(gBlkSum[irow][jcolumn] > gBlockthreshold){
423 h_tx_lw += (twrs[irow][jcolumn])*(
cosLUT(irow, 5));
424 h_ty_lw += (twrs[irow][jcolumn])*(
sinLUT(irow, 5));
425 RHO_SUM_OF_COS_h_tx_lw += (
cosLUT(irow, 5));
426 RHO_SUM_OF_SIN_h_ty_lw += (
sinLUT(irow, 5));
428 e_tx_lw += (twrs[irow][jcolumn])*(
cosLUT(irow, 5));
429 e_ty_lw += (twrs[irow][jcolumn])*(
sinLUT(irow, 5));
430 RHO_SUM_OF_COS_e_tx_lw += (
cosLUT(irow, 5));
431 RHO_SUM_OF_SIN_e_ty_lw += (
sinLUT(irow, 5));
439 long int fMHT_x = (h_tx_hi + h_tx_lw) ;
440 long int fMHT_y = (h_ty_hi + h_ty_lw) ;
441 long int fMST_x = (e_tx_hi + e_tx_lw) ;
442 long int fMST_y = (e_ty_hi + e_ty_lw) ;
444 long int RHO_MULTIPLIED_BY_SUM_OF_COS_HARD_RESULT_hi = ( puc_jwj * (RHO_SUM_OF_COS_h_tx_hi) ) >> 4 ;
445 long int RHO_MULTIPLIED_BY_SUM_OF_SIN_HARD_RESULT_hi = ( puc_jwj * (RHO_SUM_OF_SIN_h_ty_hi) ) >> 4 ;
446 long int RHO_MULTIPLIED_BY_SUM_OF_COS_SOFT_RESULT_hi = ( puc_jwj * (RHO_SUM_OF_COS_e_tx_hi) ) >> 4 ;
447 long int RHO_MULTIPLIED_BY_SUM_OF_SIN_SOFT_RESULT_hi = ( puc_jwj * (RHO_SUM_OF_SIN_e_ty_hi) ) >> 4 ;
450 long int RHO_MULTIPLIED_BY_SUM_OF_COS_HARD_RESULT_lw = ( puc_jwj * (RHO_SUM_OF_COS_h_tx_lw) ) >> 4 ;
451 long int RHO_MULTIPLIED_BY_SUM_OF_SIN_HARD_RESULT_lw = ( puc_jwj * (RHO_SUM_OF_SIN_h_ty_lw) ) >> 4 ;
452 long int RHO_MULTIPLIED_BY_SUM_OF_COS_SOFT_RESULT_lw = ( puc_jwj * (RHO_SUM_OF_COS_e_tx_lw) ) >> 4 ;
453 long int RHO_MULTIPLIED_BY_SUM_OF_SIN_SOFT_RESULT_lw = ( puc_jwj * (RHO_SUM_OF_SIN_e_ty_lw) ) >> 4 ;
455 long int RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_tx_hi = (h_tx_hi - RHO_MULTIPLIED_BY_SUM_OF_COS_HARD_RESULT_hi) ;
456 long int RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_ty_hi = (h_ty_hi - RHO_MULTIPLIED_BY_SUM_OF_SIN_HARD_RESULT_hi) ;
457 long int RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_tx_hi = (e_tx_hi - RHO_MULTIPLIED_BY_SUM_OF_COS_SOFT_RESULT_hi) ;
458 long int RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_ty_hi = (e_ty_hi - RHO_MULTIPLIED_BY_SUM_OF_SIN_SOFT_RESULT_hi) ;
460 long int RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_tx_lw = (h_tx_lw - RHO_MULTIPLIED_BY_SUM_OF_COS_HARD_RESULT_lw) ;
461 long int RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_ty_lw = (h_ty_lw - RHO_MULTIPLIED_BY_SUM_OF_SIN_HARD_RESULT_lw) ;
462 long int RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_tx_lw = (e_tx_lw - RHO_MULTIPLIED_BY_SUM_OF_COS_SOFT_RESULT_lw) ;
463 long int RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_ty_lw = (e_ty_lw - RHO_MULTIPLIED_BY_SUM_OF_SIN_SOFT_RESULT_lw) ;
465 MHT_x = (RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_tx_hi + RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_tx_lw) >> 3;
466 MHT_y = (RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_ty_hi + RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_ty_lw) >> 3;
467 MST_x = (RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_tx_hi + RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_tx_lw) >> 3;
468 MST_y = (RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_ty_hi + RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_ty_lw) >> 3;
470 fMHT_x = (RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_tx_hi + RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_tx_lw) ;
471 fMHT_y = (RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_ty_hi + RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_h_ty_lw) ;
472 fMST_x = (RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_tx_hi + RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_tx_lw) ;
473 fMST_y = (RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_ty_hi + RHO_SUBTRACTED_BEFORE_FINAL_MULTIPLY_e_ty_lw) ;
475 long int fMET_x = ( aFPGA * (fMHT_x) + bFPGA * (fMST_x) ) >> 13 ;
476 long int fMET_y = ( aFPGA * (fMHT_y) + bFPGA * (fMST_y) ) >> 13 ;
486 int aFPGA,
int bFPGA,
487 int & MHT_x,
int & MHT_y,
488 int & MST_x,
int & MST_y,
489 int & MET_x,
int & MET_y)
const {
491 gBlockthreshold = gBlockthreshold * 200 / 800;
504 for(
int jcolumn = 6; jcolumn<12; jcolumn++){
506 int frow = 2*(irow/2) + 1;
508 if(gBlkSum[irow][jcolumn] > gBlockthreshold){
509 h_tx_hi += (twrs[irow][jcolumn])*(
cosLUT(frow, 5));
510 h_ty_hi += (twrs[irow][jcolumn])*(
sinLUT(frow, 5));
512 e_tx_hi += (twrs[irow][jcolumn])*(
cosLUT(frow, 5));
513 e_ty_hi += (twrs[irow][jcolumn])*(
sinLUT(frow, 5));
518 if(gBlkSum[irow][jcolumn] > gBlockthreshold){
519 h_tx_hi += (twrs[irow][jcolumn])*(
cosLUT(irow, 5));
520 h_ty_hi += (twrs[irow][jcolumn])*(
sinLUT(irow, 5));
522 e_tx_hi += (twrs[irow][jcolumn])*(
cosLUT(irow, 5));
523 e_ty_hi += (twrs[irow][jcolumn])*(
sinLUT(irow, 5));
528 for(
int jcolumn = 0; jcolumn<6; jcolumn++){
530 int frow = 2*(irow/2) + 1;
532 if(gBlkSum[irow][jcolumn] > gBlockthreshold){
533 h_tx_lw += (twrs[irow][jcolumn])*(
cosLUT(frow, 5));
534 h_ty_lw += (twrs[irow][jcolumn])*(
sinLUT(frow, 5));
536 e_tx_lw += (twrs[irow][jcolumn])*(
cosLUT(frow, 5));
537 e_ty_lw += (twrs[irow][jcolumn])*(
sinLUT(frow, 5));
541 if(gBlkSum[irow][jcolumn] > gBlockthreshold){
542 h_tx_lw += (twrs[irow][jcolumn])*(
cosLUT(irow, 5));
543 h_ty_lw += (twrs[irow][jcolumn])*(
sinLUT(irow, 5));
545 e_tx_lw += (twrs[irow][jcolumn])*(
cosLUT(irow, 5));
546 e_ty_lw += (twrs[irow][jcolumn])*(
sinLUT(irow, 5));
557 long int fMHT_x = (h_tx_hi + h_tx_lw) ;
558 long int fMHT_y = (h_ty_hi + h_ty_lw) ;
559 long int fMST_x = (e_tx_hi + e_tx_lw) ;
560 long int fMST_y = (e_ty_hi + e_ty_lw) ;
562 MHT_x = (h_tx_hi + h_tx_lw) >> 3;
563 MHT_y = (h_ty_hi + h_ty_lw) >> 3;
564 MST_x = (e_tx_hi + e_tx_lw) >> 3;
565 MST_y = (e_ty_hi + e_ty_lw) >> 3;
573 long int fMET_x = ( aFPGA * (fMHT_x) + bFPGA * (fMST_x) ) >> 13 ;
574 long int fMET_y = ( aFPGA * (fMHT_y) + bFPGA * (fMST_y) ) >> 13 ;