49 ATH_CHECK( gTowersContainer.
record(std::make_unique<xAOD::gFexTowerContainer>(), std::make_unique<xAOD::gFexTowerAuxContainer>()));
50 ATH_MSG_DEBUG(
"Recorded gFexEmulatedTower 200 MeV container with key "<< gTowersContainer.
key());
53 ATH_CHECK( gTowers50Container.
record(std::make_unique<xAOD::gFexTowerContainer>(), std::make_unique<xAOD::gFexTowerAuxContainer>()));
54 ATH_MSG_DEBUG(
"Recorded gFexEmulatedTower 50 MeV container with key "<< gTowers50Container.
key());
62 ATH_CHECK( gTowersEMContainer.
record(std::make_unique<xAOD::gFexTowerContainer>(), std::make_unique<xAOD::gFexTowerAuxContainer>()));
64 gTowersEMContainerPtr = &*gTowersEMContainer;
67 ATH_CHECK( gTowersHADContainer.
record(std::make_unique<xAOD::gFexTowerContainer>(), std::make_unique<xAOD::gFexTowerAuxContainer>()));
69 gTowersHADContainerPtr = &*gTowersHADContainer;
100 char IsSaturated = 0;
105 int twr_rows = Atwr.size();
106 int twr_cols = Atwr[0].size();
111 for (
int irow = 0; irow < twr_rows; irow++){
112 for (
int icol = 0; icol < twr_cols; icol++){
115 Et = Atwr[irow][icol];
116 EtF = AtwrF[irow][icol];
117 IsSaturated = Asatur[irow][icol];
118 getEtaPhi(Eta, Phi, iEta, iPhi, towerID);
119 gTowersContainer->push_back( std::make_unique<xAOD::gFexTower>() );
120 gTowersContainer->back()->initialize(iEta, iPhi, Eta, Phi, Et, Fpga, IsSaturated, towerID);
121 gTowers50Container->push_back( std::make_unique<xAOD::gFexTower>() );
122 gTowers50Container->back()->initialize(iEta, iPhi, Eta, Phi, EtF, Fpga, IsSaturated, towerID);
123 if (gTowersEMContainerPtr) {
124 gTowersEMContainerPtr->
push_back( std::make_unique<xAOD::gFexTower>() );
125 gTowersEMContainerPtr->
back()->
initialize(iEta, iPhi, Eta, Phi, Et, Fpga, IsSaturated, towerID);
127 if (gTowersHADContainerPtr) {
128 gTowersHADContainerPtr->
push_back( std::make_unique<xAOD::gFexTower>() );
129 gTowersHADContainerPtr->
back()->
initialize(iEta, iPhi, Eta, Phi, Et, Fpga, IsSaturated, towerID);
140 for (
int irow = 0; irow < twr_rows; irow++){
141 for (
int icol = 0; icol < twr_cols; icol++){
144 Et = Btwr[irow][icol];
145 EtF = BtwrF[irow][icol];
146 IsSaturated = Bsatur[irow][icol];
147 getEtaPhi(Eta, Phi, iEta, iPhi, towerID);
148 gTowersContainer->push_back( std::make_unique<xAOD::gFexTower>() );
149 gTowersContainer->back()->initialize(iEta, iPhi, Eta, Phi, Et, Fpga, IsSaturated, towerID);
150 gTowers50Container->push_back( std::make_unique<xAOD::gFexTower>() );
151 gTowers50Container->back()->initialize(iEta, iPhi, Eta, Phi, EtF, Fpga, IsSaturated, towerID);
152 if (gTowersEMContainerPtr) {
153 gTowersEMContainerPtr->
push_back( std::make_unique<xAOD::gFexTower>() );
154 gTowersEMContainerPtr->
back()->
initialize(iEta, iPhi, Eta, Phi, Et, Fpga, IsSaturated, towerID);
156 if (gTowersHADContainerPtr) {
157 gTowersHADContainerPtr->
push_back( std::make_unique<xAOD::gFexTower>() );
158 gTowersHADContainerPtr->
back()->
initialize(iEta, iPhi, Eta, Phi, Et, Fpga, IsSaturated, towerID);
167 for (
int irow = 0; irow < twr_rows; irow++){
168 for (
int icol = 0; icol < twr_cols/2; icol++){
171 Et = Ctwr[irow][icol];
172 EtF = CtwrF[irow][icol];
173 IsSaturated = Csatur[irow][icol];
174 getEtaPhi(Eta, Phi, iEta, iPhi, towerID);
175 gTowersContainer->push_back( std::make_unique<xAOD::gFexTower>() );
176 gTowersContainer->back()->initialize(iEta, iPhi, Eta, Phi, Et, Fpga, IsSaturated, towerID);
177 gTowers50Container->push_back( std::make_unique<xAOD::gFexTower>() );
178 gTowers50Container->back()->initialize(iEta, iPhi, Eta, Phi, EtF, Fpga, IsSaturated, towerID);
179 if (gTowersEMContainerPtr) {
180 gTowersEMContainerPtr->
push_back( std::make_unique<xAOD::gFexTower>() );
181 gTowersEMContainerPtr->
back()->
initialize(iEta, iPhi, Eta, Phi, Et, Fpga, IsSaturated, towerID);
183 if (gTowersHADContainerPtr) {
184 gTowersHADContainerPtr->
push_back( std::make_unique<xAOD::gFexTower>() );
185 gTowersHADContainerPtr->
back()->
initialize(iEta, iPhi, Eta, Phi, Et, Fpga, IsSaturated, towerID);
189 for (
int icol = twr_cols/2; icol < twr_cols; icol++){
192 Et = Ctwr[irow][icol];
193 EtF = CtwrF[irow][icol];
194 IsSaturated = Csatur[irow][icol];
195 getEtaPhi(Eta, Phi, iEta, iPhi, towerID);
196 gTowersContainer->push_back( std::make_unique<xAOD::gFexTower>() );
197 gTowersContainer->back()->initialize(iEta, iPhi, Eta, Phi, Et, Fpga, IsSaturated, towerID);
198 gTowers50Container->push_back( std::make_unique<xAOD::gFexTower>() );
199 gTowers50Container->back()->initialize(iEta, iPhi, Eta, Phi, EtF, Fpga, IsSaturated, towerID);
200 if (gTowersEMContainerPtr) {
201 gTowersEMContainerPtr->
push_back( std::make_unique<xAOD::gFexTower>() );
202 gTowersEMContainerPtr->
back()->
initialize(iEta, iPhi, Eta, Phi, Et, Fpga, IsSaturated, towerID);
204 if (gTowersHADContainerPtr) {
205 gTowersHADContainerPtr->
push_back( std::make_unique<xAOD::gFexTower>() );
206 gTowersHADContainerPtr->
back()->
initialize(iEta, iPhi, Eta, Phi, Et, Fpga, IsSaturated, towerID);
212 return StatusCode::SUCCESS;
219 gtFPGA &Xsaturation)
const{
225 if (!gFexFiberTowerContainer.
isValid()) {
227 << gFexFiberTowerContainer.
key());
228 return StatusCode::FAILURE;
231 if (gFexFiberTowerContainer->empty()) {
233 << gFexFiberTowerContainer->size());
234 return StatusCode::SUCCESS;
240 Xgt[irow][icolumn] = 0;
241 XgtF[irow][icolumn] = 0;
242 Xsaturation[irow][icolumn] = 0;
248 std::array<int, LVL1::gFEXPos::AB_TOWERS> etowerData{};
249 std::array<int, LVL1::gFEXPos::AB_TOWERS> htowerData{};
250 std::array<int, LVL1::gFEXPos::ABC_ROWS> xetowerData{};
251 std::array<int, LVL1::gFEXPos::ABC_ROWS> xhtowerData{};
252 std::array<int, LVL1::gFEXPos::ABC_ROWS> ohtowerData{};
255 std::array<int, LVL1::gFEXPos::AB_TOWERS> etowerDataF{};
256 std::array<int, LVL1::gFEXPos::AB_TOWERS> htowerDataF{};
257 std::array<int, LVL1::gFEXPos::ABC_ROWS> xetowerDataF{};
258 std::array<int, LVL1::gFEXPos::ABC_ROWS> xhtowerDataF{};
259 std::array<int, LVL1::gFEXPos::ABC_ROWS> ohtowerDataF{};
262 std::array<bool, LVL1::gFEXPos::AB_TOWERS> saturationData{};
267 unsigned int fiberTowerFpga = gfexFiberTower->fpga();
268 if (fiberTowerFpga != XFPGA)
continue;
271 unsigned int fiberTowerId = gfexFiberTower->gFEXtowerID();
272 unsigned int offset = (XFPGA == 2) ? 20000 : (XFPGA == 1) ? 10000 : 0;
273 unsigned int iFiber = (fiberTowerId - offset)/16;
277 if (iFiber >= maxFiberN)
continue;
279 ATH_MSG_DEBUG(
" accessing " << fiberTowerId <<
" " << XFPGA <<
" " << offset <<
" " << iFiber);
281 unsigned int iDatum = fiberTowerId%16;
320 bool fiberSaturation = (bool)(gfexFiberTower->isSaturated());
321 if (fiberSaturation) {
327 saturationData[ntower] =
true;
332 saturationData[ntower] =
true;
338 int extCol = (XFPGA == 0) ? 0 : 11;
339 int extTower = ntower * 12 + extCol;
340 if (extTower >= 0 && extTower < 384) {
341 saturationData[extTower] =
true;
347 int olapCol = (XFPGA == 0) ? 4 : 7;
348 int olapTower = ntower * 12 + olapCol;
349 if (olapTower >= 0 && olapTower < 384) {
350 saturationData[olapTower] =
true;
359 saturationData[ntower] =
true;
364 unsigned int Toweret_mle = (
unsigned int)(gfexFiberTower->towerEt());
370 etowerData[ntower] = Toweret_mle;
372 etowerDataF[ntower] = etowerData[ntower];
375 htowerData[ntower] = Toweret_mle;
379 htowerData[ntower] = 20*htowerData[ntower];
380 htowerDataF[ntower] = htowerData[ntower];
384 xetowerData[ntower] = Toweret_mle;
385 undoMLE( xetowerData[ntower] );
386 xetowerDataF[ntower] = xetowerData[ntower];
390 xhtowerData[ntower] = Toweret_mle;
391 undoMLE( xhtowerData[ntower] );
392 xhtowerDataF[ntower] = xhtowerData[ntower];
396 ohtowerData[ntower] = Toweret_mle;
397 undoMLE( ohtowerData[ntower] );
398 ohtowerDataF[ntower] = ohtowerData[ntower];
402 htowerData[ntower] = Toweret_mle;
404 htowerDataF[ntower] = htowerData[ntower];
414 etowerData[ntower] = Toweret_mle;
416 etowerDataF[ntower] = etowerData[ntower];
421 htowerData[ntower] = Toweret_mle;
423 htowerDataF[ntower] = htowerData[ntower];
435 return StatusCode::FAILURE;
440 ATH_MSG_DEBUG(
" end of loop: " << XFPGA <<
" tower: " << ntower <<
" e " << etowerDataF[ntower] <<
" h " << htowerData[ntower] <<
" fibertower " << fiberTowerId);
446 for(
int itower=0;itower<384;itower++){
447 int icolumn = itower%12;
448 int irow = itower/12;
451 Xsaturation[irow][icolumn] = saturationData[itower];
455 int xF = etowerDataF[itower] + htowerDataF[itower];
457 int x = ( (etowerData[itower]>>2) + (htowerData[itower]>>2) );
459 ATH_MSG_DEBUG(
"sss1 " << icolumn <<
" " << irow <<
" " << xF <<
" " <<
x <<
" " << etowerDataF[itower] <<
" " << htowerDataF[itower]);
464 ATH_MSG_DEBUG(
"sss2 " << icolumn <<
" " << irow <<
" " << xF <<
" " <<
x);
466 Xgt[irow][icolumn] =
x;
467 XgtF[irow][icolumn] = xF;
469 ATH_MSG_DEBUG(
"sss3 " << icolumn <<
" " << irow <<
" " << XgtF[irow][icolumn] <<
" " << Xgt[irow][icolumn]);
473 int xx = ( (xetowerData[irow]>>2) + (xhtowerData[irow]>>2) );
475 Xgt[irow][icolumn] = Xgt[irow][icolumn] + xx;
476 ATH_MSG_DEBUG(
"sss4 " << icolumn <<
" " << irow <<
" " << XgtF[irow][icolumn] <<
" " << Xgt[irow][icolumn]);
481 int ox = (ohtowerData[irow] >> 2 ) ;
483 Xgt[irow][icolumn] = Xgt[irow][icolumn] + ox ;
484 ATH_MSG_DEBUG(
"sss5 " << icolumn <<
" " << irow <<
" " << XgtF[irow][icolumn] <<
" " << Xgt[irow][icolumn]);
487 ATH_MSG_DEBUG(
"sss filling standard " << Xgt[irow][icolumn] <<
" fiber " << XgtF[irow][icolumn]);
490 else if ( XFPGA == 1 ) {
491 for(
int itower=0;itower<384;itower++){
492 int icolumn = itower%12;
493 int irow = itower/12;
496 Xsaturation[irow][icolumn] = saturationData[itower];
499 int xF = etowerDataF[itower] + htowerDataF[itower] ;
501 int x = ( (etowerData[itower]>>2) + (htowerData[itower] >> 2) );
506 Xgt[irow][icolumn] =
x;
507 XgtF[irow][icolumn] = xF;
510 if ( icolumn == 11) {
512 int xx = ( (xetowerData[irow]>>2) + (xhtowerData[irow]>>2) );
514 Xgt[irow][icolumn] = Xgt[irow][icolumn] + xx;
516 if ( icolumn == 7 ) {
518 int xo = ohtowerData[irow]>>2;
520 Xgt[irow][icolumn] = Xgt[irow][icolumn] + xo;
524 else if ( XFPGA == 2 ) {
525 for(
int itower=0;itower<384;itower++){
526 int icolumn = itower%12;
527 int irow = itower/12;
530 Xsaturation[irow][icolumn] = saturationData[itower];
533 int xF = etowerDataF[itower] + htowerDataF[itower] ;
535 int x = ( (etowerData[itower]>>2 ) + (htowerData[itower]>>2));
539 Xgt[irow][icolumn] =
x;
540 XgtF[irow][icolumn] = xF;
544 return StatusCode::SUCCESS;
550 int din = (0x00000FFF & datumPtr );
553 if( (din > 0) && ( din < 962 ) ) din = 962;
555 if( din == 0) din = 0x4EE;
559 int FPGA_CONVLIN_TH1 = 5;
560 int FPGA_CONVLIN_TH2 = 749;
561 int FPGA_CONVLIN_TH3 = 1773;
562 int FPGA_CONVLIN_TH4 = 2541;
563 int FPGA_CONVLIN_TH5 = 4029;
564 int FPGA_CONVLIN_TH6 = 4062;
569 int FPGA_CONVLIN_OF2 = -1262;
570 int FPGA_CONVLIN_OF3 = -3036;
571 int FPGA_CONVLIN_OF4 = -8120;
572 int FPGA_CONVLIN_OF5 = -4118720;
600 r3shv = (din & 0x00000FFF) ;
601 r4shv = ((din & 0x00000FFF) << 1 ) & 0x00001FFE ;
602 r5shv = ((din & 0x00000FFF) << 2 ) & 0x00003FFC ;
603 r6shv = ((din & 0x00000FFF) << 10 ) & 0x003FFC00 ;
608 r3conv = r3shv + FPGA_CONVLIN_OF2;
609 r4conv = r4shv + FPGA_CONVLIN_OF3;
610 r5conv = r5shv + FPGA_CONVLIN_OF4;
611 r6conv = r6shv + FPGA_CONVLIN_OF5;
619 if ( din > FPGA_CONVLIN_TH1 ){
625 if ( din > FPGA_CONVLIN_TH2 ){
630 if ( din > FPGA_CONVLIN_TH3 ){
635 if ( din > FPGA_CONVLIN_TH4 ){
640 if ( din > FPGA_CONVLIN_TH5 ){
646 if ( din > FPGA_CONVLIN_TH6 ){
656 if( (! oth0) & (! oth1 ) & (! oth2 ) & (! oth3 ) & (! oth4 ) & (! oth5 ) & (! oth6 ) ) {
668 else if( ( oth0) & ( oth1 ) & ( oth2 ) & (! oth3 ) & (! oth4 ) & (! oth5 ) & (! oth6 ) ) {
672 else if( ( oth0) & ( oth1 ) & ( oth2 ) & ( oth3 ) & (! oth4 ) & (! oth5 ) & (! oth6 ) ) {
676 else if( ( oth0) & ( oth1 ) & ( oth2 ) & ( oth3 ) & ( oth4 ) & (! oth5 ) & (! oth6 ) ) {
680 else if( ( oth0) & ( oth1 ) & ( oth2 ) & ( oth3 ) & ( oth4 ) & ( oth5 ) & (! oth6 ) ) {
684 else if( ( oth0) & ( oth1 ) & ( oth2 ) & ( oth3 ) & ( oth4 ) & ( oth5 ) & ( oth6 ) ) {
718 int gFEXtowerID)
const {
720 float s_centralPhiWidth =
722 float s_forwardPhiWidth =
726 const std::vector<float> s_EtaCenter = {
727 -4.5, -3.8, -3.38, -3.18, -3.15, -3, -2.8, -2.6, -2.35, -2.1,
728 -1.9, -1.7, -1.5, -1.3, -1.1, -0.9, -0.7, -0.5, -0.3, -0.1,
729 0.1, 0.3, 0.5, 0.7, 0.9, 1.1, 1.3, 1.5, 1.7, 1.9,
730 2.1, 2.35, 2.6, 2.8, 3.0, 3.15, 3.18, 3.38, 3.8, 4.5};
739 int towerID_base = 20000;
740 int iEtaOld = 0, iPhiOld = 0;
743 if (iPhi == ((gFEXtowerID - towerID_base) / 24) * 2) {
747 if (iPhi == (((gFEXtowerID - towerID_base - 12) / 24) * 2) + 1) {
749 iPhiOld = (iPhi - 1) / 2;
753 else if (iEta == 3) {
754 if (iPhi == ((gFEXtowerID - towerID_base - 1) / 24) * 2) {
758 if (iPhi == (((gFEXtowerID - towerID_base - 13) / 24) * 2) + 1) {
760 iPhiOld = (iPhi - 1) / 2;
764 else if (iEta == 36) {
765 if (iPhi == (((gFEXtowerID - towerID_base - 22) / 24) * 2) + 1) {
767 iPhiOld = (iPhi - 1) / 2;
769 if (iPhi == ((gFEXtowerID - towerID_base - 10) / 24) * 2) {
775 else if (iEta == 37) {
776 if (iPhi == (((gFEXtowerID - towerID_base - 23) / 24) * 2) + 1) {
778 iPhiOld = (iPhi - 1) / 2;
780 if (iPhi == ((gFEXtowerID - towerID_base - 11) / 24) * 2) {
791 Eta = s_EtaCenter[iEtaOld];
793 float Phi_gFex = -99;
795 if ((iEtaOld <= 3) || ((iEtaOld >= 36))) {
796 Phi_gFex = ((iPhiOld * s_forwardPhiWidth) + s_forwardPhiWidth / 2);
798 Phi_gFex = ((iPhiOld * s_centralPhiWidth) + s_centralPhiWidth / 2);
801 if (Phi_gFex <
M_PI) {
804 Phi = (Phi_gFex - 2 *
M_PI);