34 "Initializing L1CaloFEXAlgos/gFexEmulatedTowers algorithm with name: "
46 return StatusCode::SUCCESS;
53 ATH_CHECK( gTowersContainer.
record(std::make_unique<xAOD::gFexTowerContainer>(), std::make_unique<xAOD::gFexTowerAuxContainer>()));
54 ATH_MSG_DEBUG(
"Recorded gFexEmulatedTower 200 MeV container with key "<< gTowersContainer.
key());
57 ATH_CHECK( gTowers50Container.
record(std::make_unique<xAOD::gFexTowerContainer>(), std::make_unique<xAOD::gFexTowerAuxContainer>()));
58 ATH_MSG_DEBUG(
"Recorded gFexEmulatedTower 50 MeV container with key "<< gTowers50Container.
key());
66 ATH_CHECK( gTowersEMContainer.
record(std::make_unique<xAOD::gFexTowerContainer>(), std::make_unique<xAOD::gFexTowerAuxContainer>()));
68 gTowersEMContainerPtr = &*gTowersEMContainer;
71 ATH_CHECK( gTowersHADContainer.
record(std::make_unique<xAOD::gFexTowerContainer>(), std::make_unique<xAOD::gFexTowerAuxContainer>()));
73 gTowersHADContainerPtr = &*gTowersHADContainer;
91 Atwr[irow][icolumn] = 0;
92 AtwrF[irow][icolumn] = 0;
93 Asatur[irow][icolumn] = 0;
94 Btwr[irow][icolumn] = 0;
95 BtwrF[irow][icolumn] = 0;
96 Bsatur[irow][icolumn] = 0;
97 Ctwr[irow][icolumn] = 0;
98 CtwrF[irow][icolumn] = 0;
99 Csatur[irow][icolumn] = 0;
117 char IsSaturated = 0;
122 int twr_rows = Atwr.size();
123 int twr_cols = Atwr[0].size();
128 for (
int irow = 0; irow < twr_rows; irow++){
132 Et = Atwr[irow][
icol];
133 EtF = AtwrF[irow][
icol];
134 IsSaturated = Asatur[irow][
icol];
136 gTowersContainer->
push_back( std::make_unique<xAOD::gFexTower>() );
137 gTowersContainer->
back()->initialize(
iEta,
iPhi,
Eta,
Phi, Et, Fpga, IsSaturated, towerID);
138 gTowers50Container->
push_back( std::make_unique<xAOD::gFexTower>() );
139 gTowers50Container->
back()->initialize(
iEta,
iPhi,
Eta,
Phi, EtF, Fpga, IsSaturated, towerID);
140 if (gTowersEMContainerPtr) {
141 gTowersEMContainerPtr->
push_back( std::make_unique<xAOD::gFexTower>() );
142 gTowersEMContainerPtr->
back()->initialize(
iEta,
iPhi,
Eta,
Phi, Et, Fpga, IsSaturated, towerID);
144 if (gTowersHADContainerPtr) {
145 gTowersHADContainerPtr->
push_back( std::make_unique<xAOD::gFexTower>() );
146 gTowersHADContainerPtr->
back()->initialize(
iEta,
iPhi,
Eta,
Phi, Et, Fpga, IsSaturated, towerID);
157 for (
int irow = 0; irow < twr_rows; irow++){
161 Et = Btwr[irow][
icol];
162 EtF = BtwrF[irow][
icol];
163 IsSaturated = Bsatur[irow][
icol];
165 gTowersContainer->
push_back( std::make_unique<xAOD::gFexTower>() );
166 gTowersContainer->
back()->initialize(
iEta,
iPhi,
Eta,
Phi, Et, Fpga, IsSaturated, towerID);
167 gTowers50Container->
push_back( std::make_unique<xAOD::gFexTower>() );
168 gTowers50Container->
back()->initialize(
iEta,
iPhi,
Eta,
Phi, EtF, Fpga, IsSaturated, towerID);
169 if (gTowersEMContainerPtr) {
170 gTowersEMContainerPtr->
push_back( std::make_unique<xAOD::gFexTower>() );
171 gTowersEMContainerPtr->
back()->initialize(
iEta,
iPhi,
Eta,
Phi, Et, Fpga, IsSaturated, towerID);
173 if (gTowersHADContainerPtr) {
174 gTowersHADContainerPtr->
push_back( std::make_unique<xAOD::gFexTower>() );
175 gTowersHADContainerPtr->
back()->initialize(
iEta,
iPhi,
Eta,
Phi, Et, Fpga, IsSaturated, towerID);
184 for (
int irow = 0; irow < twr_rows; irow++){
188 Et = Ctwr[irow][
icol];
189 EtF = CtwrF[irow][
icol];
190 IsSaturated = Csatur[irow][
icol];
192 gTowersContainer->
push_back( std::make_unique<xAOD::gFexTower>() );
193 gTowersContainer->
back()->initialize(
iEta,
iPhi,
Eta,
Phi, Et, Fpga, IsSaturated, towerID);
194 gTowers50Container->
push_back( std::make_unique<xAOD::gFexTower>() );
195 gTowers50Container->
back()->initialize(
iEta,
iPhi,
Eta,
Phi, EtF, Fpga, IsSaturated, towerID);
196 if (gTowersEMContainerPtr) {
197 gTowersEMContainerPtr->
push_back( std::make_unique<xAOD::gFexTower>() );
198 gTowersEMContainerPtr->
back()->initialize(
iEta,
iPhi,
Eta,
Phi, Et, Fpga, IsSaturated, towerID);
200 if (gTowersHADContainerPtr) {
201 gTowersHADContainerPtr->
push_back( std::make_unique<xAOD::gFexTower>() );
202 gTowersHADContainerPtr->
back()->initialize(
iEta,
iPhi,
Eta,
Phi, Et, Fpga, IsSaturated, towerID);
209 Et = Ctwr[irow][
icol];
210 EtF = CtwrF[irow][
icol];
211 IsSaturated = Csatur[irow][
icol];
213 gTowersContainer->
push_back( std::make_unique<xAOD::gFexTower>() );
214 gTowersContainer->
back()->initialize(
iEta,
iPhi,
Eta,
Phi, Et, Fpga, IsSaturated, towerID);
215 gTowers50Container->
push_back( std::make_unique<xAOD::gFexTower>() );
216 gTowers50Container->
back()->initialize(
iEta,
iPhi,
Eta,
Phi, EtF, Fpga, IsSaturated, towerID);
217 if (gTowersEMContainerPtr) {
218 gTowersEMContainerPtr->
push_back( std::make_unique<xAOD::gFexTower>() );
219 gTowersEMContainerPtr->
back()->initialize(
iEta,
iPhi,
Eta,
Phi, Et, Fpga, IsSaturated, towerID);
221 if (gTowersHADContainerPtr) {
222 gTowersHADContainerPtr->
push_back( std::make_unique<xAOD::gFexTower>() );
223 gTowersHADContainerPtr->
back()->initialize(
iEta,
iPhi,
Eta,
Phi, Et, Fpga, IsSaturated, towerID);
229 return StatusCode::SUCCESS;
236 gtFPGA &Xsaturation)
const{
242 if (!gFexFiberTowerContainer.
isValid()) {
244 << gFexFiberTowerContainer.
key());
245 return StatusCode::FAILURE;
248 if (gFexFiberTowerContainer->
empty()) {
250 << gFexFiberTowerContainer->
size());
251 return StatusCode::SUCCESS;
257 Xgt[irow][icolumn] = 0;
258 XgtF[irow][icolumn] = 0;
259 Xsaturation[irow][icolumn] = 0;
265 std::array<int, LVL1::gFEXPos::AB_TOWERS> etowerData{};
266 std::array<int, LVL1::gFEXPos::AB_TOWERS> htowerData{};
267 std::array<int, LVL1::gFEXPos::ABC_ROWS> xetowerData{};
268 std::array<int, LVL1::gFEXPos::ABC_ROWS> xhtowerData{};
269 std::array<int, LVL1::gFEXPos::ABC_ROWS> ohtowerData{};
272 std::array<int, LVL1::gFEXPos::AB_TOWERS> etowerDataF{};
273 std::array<int, LVL1::gFEXPos::AB_TOWERS> htowerDataF{};
274 std::array<int, LVL1::gFEXPos::ABC_ROWS> xetowerDataF{};
275 std::array<int, LVL1::gFEXPos::ABC_ROWS> xhtowerDataF{};
276 std::array<int, LVL1::gFEXPos::ABC_ROWS> ohtowerDataF{};
279 std::array<bool, LVL1::gFEXPos::AB_TOWERS> saturationData{};
284 unsigned int fiberTowerFpga = gfexFiberTower->fpga();
285 if (fiberTowerFpga != XFPGA)
continue;
288 unsigned int fiberTowerId = gfexFiberTower->gFEXtowerID();
289 unsigned int offset = (XFPGA == 2) ? 20000 : (XFPGA == 1) ? 10000 : 0;
290 unsigned int iFiber = (fiberTowerId -
offset)/16;
294 if (iFiber >= maxFiberN)
continue;
296 ATH_MSG_DEBUG(
" accessing " << fiberTowerId <<
" " << XFPGA <<
" " <<
offset <<
" " << iFiber);
298 unsigned int iDatum = fiberTowerId%16;
327 bool fiberSaturation = (
bool)(gfexFiberTower->isSaturated());
328 if (fiberSaturation) {
329 saturationData[ntower] = fiberSaturation;
333 unsigned int Toweret_mle = (
unsigned int)(gfexFiberTower->towerEt());
339 etowerData[ntower] = Toweret_mle;
341 etowerDataF[ntower] = etowerData[ntower];
344 htowerData[ntower] = Toweret_mle;
348 htowerData[ntower] = 20*htowerData[ntower];
349 htowerDataF[ntower] = htowerData[ntower];
353 xetowerData[ntower] = Toweret_mle;
354 undoMLE( xetowerData[ntower] );
355 xetowerDataF[ntower] = xetowerData[ntower];
359 xhtowerData[ntower] = Toweret_mle;
360 undoMLE( xhtowerData[ntower] );
361 xhtowerDataF[ntower] = xhtowerData[ntower];
365 ohtowerData[ntower] = Toweret_mle;
366 undoMLE( ohtowerData[ntower] );
367 ohtowerDataF[ntower] = ohtowerData[ntower];
371 htowerData[ntower] = Toweret_mle;
373 htowerDataF[ntower] = htowerData[ntower];
383 etowerData[ntower] = Toweret_mle;
385 etowerDataF[ntower] = etowerData[ntower];
390 htowerData[ntower] = Toweret_mle;
392 htowerDataF[ntower] = htowerData[ntower];
404 return StatusCode::FAILURE;
409 ATH_MSG_DEBUG(
" end of loop: " << XFPGA <<
" tower: " << ntower <<
" e " << etowerDataF[ntower] <<
" h " << htowerData[ntower] <<
" fibertower " << fiberTowerId);
415 for(
int itower=0;itower<384;itower++){
416 int icolumn = itower%12;
417 int irow = itower/12;
420 Xsaturation[irow][icolumn] = saturationData[itower];
424 int xF = etowerDataF[itower] + htowerDataF[itower];
426 int x = ( (etowerData[itower]>>2) + (htowerData[itower]>>2) );
428 ATH_MSG_DEBUG(
"sss1 " << icolumn <<
" " << irow <<
" " << xF <<
" " <<
x <<
" " << etowerDataF[itower] <<
" " << htowerDataF[itower]);
433 ATH_MSG_DEBUG(
"sss2 " << icolumn <<
" " << irow <<
" " << xF <<
" " <<
x);
435 Xgt[irow][icolumn] =
x;
436 XgtF[irow][icolumn] = xF;
438 ATH_MSG_DEBUG(
"sss3 " << icolumn <<
" " << irow <<
" " << XgtF[irow][icolumn] <<
" " << Xgt[irow][icolumn]);
442 int xx = ( (xetowerData[irow]>>2) + (xhtowerData[irow]>>2) );
444 Xgt[irow][icolumn] = Xgt[irow][icolumn] +
xx;
445 ATH_MSG_DEBUG(
"sss4 " << icolumn <<
" " << irow <<
" " << XgtF[irow][icolumn] <<
" " << Xgt[irow][icolumn]);
450 int ox = (ohtowerData[irow] >> 2 ) ;
452 Xgt[irow][icolumn] = Xgt[irow][icolumn] + ox ;
453 ATH_MSG_DEBUG(
"sss5 " << icolumn <<
" " << irow <<
" " << XgtF[irow][icolumn] <<
" " << Xgt[irow][icolumn]);
456 ATH_MSG_DEBUG(
"sss filling standard " << Xgt[irow][icolumn] <<
" fiber " << XgtF[irow][icolumn]);
459 else if ( XFPGA == 1 ) {
460 for(
int itower=0;itower<384;itower++){
461 int icolumn = itower%12;
462 int irow = itower/12;
465 Xsaturation[irow][icolumn] = saturationData[itower];
468 int xF = etowerDataF[itower] + htowerDataF[itower] ;
470 int x = ( (etowerData[itower]>>2) + (htowerData[itower] >> 2) );
475 Xgt[irow][icolumn] =
x;
476 XgtF[irow][icolumn] = xF;
479 if ( icolumn == 11) {
481 int xx = ( (xetowerData[irow]>>2) + (xhtowerData[irow]>>2) );
483 Xgt[irow][icolumn] = Xgt[irow][icolumn] +
xx;
485 if ( icolumn == 7 ) {
487 int xo = ohtowerData[irow]>>2;
489 Xgt[irow][icolumn] = Xgt[irow][icolumn] + xo;
493 else if ( XFPGA == 2 ) {
494 for(
int itower=0;itower<384;itower++){
495 int icolumn = itower%12;
496 int irow = itower/12;
499 Xsaturation[irow][icolumn] = saturationData[itower];
502 int xF = etowerDataF[itower] + htowerDataF[itower] ;
504 int x = ( (etowerData[itower]>>2 ) + (htowerData[itower]>>2));
508 Xgt[irow][icolumn] =
x;
509 XgtF[irow][icolumn] = xF;
513 return StatusCode::SUCCESS;
519 int din = (0x00000FFF & datumPtr );
522 if( (din > 0) && ( din < 962 ) ) din = 962;
524 if( din == 0) din = 0x4EE;
528 int FPGA_CONVLIN_TH1 = 5;
529 int FPGA_CONVLIN_TH2 = 749;
530 int FPGA_CONVLIN_TH3 = 1773;
531 int FPGA_CONVLIN_TH4 = 2541;
532 int FPGA_CONVLIN_TH5 = 4029;
533 int FPGA_CONVLIN_TH6 = 4062;
535 int FPGA_CONVLIN_OF0 = -5072;
536 int FPGA_CONVLIN_OF1 = -2012;
537 int FPGA_CONVLIN_OF2 = -1262;
538 int FPGA_CONVLIN_OF3 = -3036;
539 int FPGA_CONVLIN_OF4 = -8120;
540 int FPGA_CONVLIN_OF5 = -4118720;
566 r1shv = ((din & 0x0000007F) << 9 ) & 0x0000FE00 ;
567 r2shv = ((din & 0x00000FFF) << 1 ) & 0x00001FFE ;
568 r3shv = (din & 0x00000FFF) ;
569 r4shv = ((din & 0x00000FFF) << 1 ) & 0x00001FFE ;
570 r5shv = ((din & 0x00000FFF) << 2 ) & 0x00003FFC ;
571 r6shv = ((din & 0x00000FFF) << 10 ) & 0x003FFC00 ;
573 r1conv = r1shv + FPGA_CONVLIN_OF0;
574 r2conv = r2shv + FPGA_CONVLIN_OF1;
575 r3conv = r3shv + FPGA_CONVLIN_OF2;
576 r4conv = r4shv + FPGA_CONVLIN_OF3;
577 r5conv = r5shv + FPGA_CONVLIN_OF4;
578 r6conv = r6shv + FPGA_CONVLIN_OF5;
586 if ( din > FPGA_CONVLIN_TH1 ){
592 if ( din > FPGA_CONVLIN_TH2 ){
597 if ( din > FPGA_CONVLIN_TH3 ){
602 if ( din > FPGA_CONVLIN_TH4 ){
607 if ( din > FPGA_CONVLIN_TH5 ){
613 if ( din > FPGA_CONVLIN_TH6 ){
623 if( (! oth0) & (! oth1 ) & (! oth2 ) & (! oth3 ) & (! oth4 ) & (! oth5 ) & (! oth6 ) ) {
626 else if( ( oth0) & (! oth1 ) & (! oth2 ) & (! oth3 ) & (! oth4 ) & (! oth5 ) & (! oth6 ) ) {
629 else if( ( oth0) & ( oth1 ) & (! oth2 ) & (! oth3 ) & (! oth4 ) & (! oth5 ) & (! oth6 ) ) {
632 else if( ( oth0) & ( oth1 ) & ( oth2 ) & (! oth3 ) & (! oth4 ) & (! oth5 ) & (! oth6 ) ) {
635 else if( ( oth0) & ( oth1 ) & ( oth2 ) & ( oth3 ) & (! oth4 ) & (! oth5 ) & (! oth6 ) ) {
638 else if( ( oth0) & ( oth1 ) & ( oth2 ) & ( oth3 ) & ( oth4 ) & (! oth5 ) & (! oth6 ) ) {
641 else if( ( oth0) & ( oth1 ) & ( oth2 ) & ( oth3 ) & ( oth4 ) & ( oth5 ) & (! oth6 ) ) {
644 else if( ( oth0) & ( oth1 ) & ( oth2 ) & ( oth3 ) & ( oth4 ) & ( oth5 ) & ( oth6 ) ) {
665 if(
x & (0x00000001<<upto) ) {
666 x = (
x | (0xFFFFFFFF<<(upto+1)) );
669 x = (
x & 0x000FFFF);
676 int gFEXtowerID)
const {
678 float s_centralPhiWidth =
680 float s_forwardPhiWidth =
684 const std::vector<float> s_EtaCenter = {
685 -4.5, -3.8, -3.38, -3.18, -3.15, -3, -2.8, -2.6, -2.35, -2.1,
686 -1.9, -1.7, -1.5, -1.3, -1.1, -0.9, -0.7, -0.5, -0.3, -0.1,
687 0.1, 0.3, 0.5, 0.7, 0.9, 1.1, 1.3, 1.5, 1.7, 1.9,
688 2.1, 2.35, 2.6, 2.8, 3.0, 3.15, 3.18, 3.38, 3.8, 4.5};
697 int towerID_base = 20000;
698 int iEtaOld = 0, iPhiOld = 0;
701 if (
iPhi == ((gFEXtowerID - towerID_base) / 24) * 2) {
705 if (
iPhi == (((gFEXtowerID - towerID_base - 12) / 24) * 2) + 1) {
707 iPhiOld = (
iPhi - 1) / 2;
711 else if (
iEta == 3) {
712 if (
iPhi == ((gFEXtowerID - towerID_base - 1) / 24) * 2) {
716 if (
iPhi == (((gFEXtowerID - towerID_base - 13) / 24) * 2) + 1) {
718 iPhiOld = (
iPhi - 1) / 2;
722 else if (
iEta == 36) {
723 if (
iPhi == (((gFEXtowerID - towerID_base - 22) / 24) * 2) + 1) {
725 iPhiOld = (
iPhi - 1) / 2;
727 if (
iPhi == ((gFEXtowerID - towerID_base - 10) / 24) * 2) {
733 else if (
iEta == 37) {
734 if (
iPhi == (((gFEXtowerID - towerID_base - 23) / 24) * 2) + 1) {
736 iPhiOld = (
iPhi - 1) / 2;
738 if (
iPhi == ((gFEXtowerID - towerID_base - 11) / 24) * 2) {
749 Eta = s_EtaCenter[iEtaOld];
751 float Phi_gFex = -99;
753 if ((iEtaOld <= 3) || ((iEtaOld >= 36))) {
754 Phi_gFex = ((iPhiOld * s_forwardPhiWidth) + s_forwardPhiWidth / 2);
756 Phi_gFex = ((iPhiOld * s_centralPhiWidth) + s_centralPhiWidth / 2);
759 if (Phi_gFex <
M_PI) {