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;
310 bool fiberSaturation = (bool)(gfexFiberTower->isSaturated());
311 if (fiberSaturation) {
312 saturationData[ntower] = fiberSaturation;
316 unsigned int Toweret_mle = (
unsigned int)(gfexFiberTower->towerEt());
322 etowerData[ntower] = Toweret_mle;
324 etowerDataF[ntower] = etowerData[ntower];
327 htowerData[ntower] = Toweret_mle;
331 htowerData[ntower] = 20*htowerData[ntower];
332 htowerDataF[ntower] = htowerData[ntower];
336 xetowerData[ntower] = Toweret_mle;
337 undoMLE( xetowerData[ntower] );
338 xetowerDataF[ntower] = xetowerData[ntower];
342 xhtowerData[ntower] = Toweret_mle;
343 undoMLE( xhtowerData[ntower] );
344 xhtowerDataF[ntower] = xhtowerData[ntower];
348 ohtowerData[ntower] = Toweret_mle;
349 undoMLE( ohtowerData[ntower] );
350 ohtowerDataF[ntower] = ohtowerData[ntower];
354 htowerData[ntower] = Toweret_mle;
356 htowerDataF[ntower] = htowerData[ntower];
366 etowerData[ntower] = Toweret_mle;
368 etowerDataF[ntower] = etowerData[ntower];
373 htowerData[ntower] = Toweret_mle;
375 htowerDataF[ntower] = htowerData[ntower];
387 return StatusCode::FAILURE;
392 ATH_MSG_DEBUG(
" end of loop: " << XFPGA <<
" tower: " << ntower <<
" e " << etowerDataF[ntower] <<
" h " << htowerData[ntower] <<
" fibertower " << fiberTowerId);
398 for(
int itower=0;itower<384;itower++){
399 int icolumn = itower%12;
400 int irow = itower/12;
403 Xsaturation[irow][icolumn] = saturationData[itower];
407 int xF = etowerDataF[itower] + htowerDataF[itower];
409 int x = ( (etowerData[itower]>>2) + (htowerData[itower]>>2) );
411 ATH_MSG_DEBUG(
"sss1 " << icolumn <<
" " << irow <<
" " << xF <<
" " <<
x <<
" " << etowerDataF[itower] <<
" " << htowerDataF[itower]);
416 ATH_MSG_DEBUG(
"sss2 " << icolumn <<
" " << irow <<
" " << xF <<
" " <<
x);
418 Xgt[irow][icolumn] =
x;
419 XgtF[irow][icolumn] = xF;
421 ATH_MSG_DEBUG(
"sss3 " << icolumn <<
" " << irow <<
" " << XgtF[irow][icolumn] <<
" " << Xgt[irow][icolumn]);
425 int xx = ( (xetowerData[irow]>>2) + (xhtowerData[irow]>>2) );
427 Xgt[irow][icolumn] = Xgt[irow][icolumn] + xx;
428 ATH_MSG_DEBUG(
"sss4 " << icolumn <<
" " << irow <<
" " << XgtF[irow][icolumn] <<
" " << Xgt[irow][icolumn]);
433 int ox = (ohtowerData[irow] >> 2 ) ;
435 Xgt[irow][icolumn] = Xgt[irow][icolumn] + ox ;
436 ATH_MSG_DEBUG(
"sss5 " << icolumn <<
" " << irow <<
" " << XgtF[irow][icolumn] <<
" " << Xgt[irow][icolumn]);
439 ATH_MSG_DEBUG(
"sss filling standard " << Xgt[irow][icolumn] <<
" fiber " << XgtF[irow][icolumn]);
442 else if ( XFPGA == 1 ) {
443 for(
int itower=0;itower<384;itower++){
444 int icolumn = itower%12;
445 int irow = itower/12;
448 Xsaturation[irow][icolumn] = saturationData[itower];
451 int xF = etowerDataF[itower] + htowerDataF[itower] ;
453 int x = ( (etowerData[itower]>>2) + (htowerData[itower] >> 2) );
458 Xgt[irow][icolumn] =
x;
459 XgtF[irow][icolumn] = xF;
462 if ( icolumn == 11) {
464 int xx = ( (xetowerData[irow]>>2) + (xhtowerData[irow]>>2) );
466 Xgt[irow][icolumn] = Xgt[irow][icolumn] + xx;
468 if ( icolumn == 7 ) {
470 int xo = ohtowerData[irow]>>2;
472 Xgt[irow][icolumn] = Xgt[irow][icolumn] + xo;
476 else if ( XFPGA == 2 ) {
477 for(
int itower=0;itower<384;itower++){
478 int icolumn = itower%12;
479 int irow = itower/12;
482 Xsaturation[irow][icolumn] = saturationData[itower];
485 int xF = etowerDataF[itower] + htowerDataF[itower] ;
487 int x = ( (etowerData[itower]>>2 ) + (htowerData[itower]>>2));
491 Xgt[irow][icolumn] =
x;
492 XgtF[irow][icolumn] = xF;
496 return StatusCode::SUCCESS;
502 int din = (0x00000FFF & datumPtr );
505 if( (din > 0) && ( din < 962 ) ) din = 962;
507 if( din == 0) din = 0x4EE;
511 int FPGA_CONVLIN_TH1 = 5;
512 int FPGA_CONVLIN_TH2 = 749;
513 int FPGA_CONVLIN_TH3 = 1773;
514 int FPGA_CONVLIN_TH4 = 2541;
515 int FPGA_CONVLIN_TH5 = 4029;
516 int FPGA_CONVLIN_TH6 = 4062;
521 int FPGA_CONVLIN_OF2 = -1262;
522 int FPGA_CONVLIN_OF3 = -3036;
523 int FPGA_CONVLIN_OF4 = -8120;
524 int FPGA_CONVLIN_OF5 = -4118720;
552 r3shv = (din & 0x00000FFF) ;
553 r4shv = ((din & 0x00000FFF) << 1 ) & 0x00001FFE ;
554 r5shv = ((din & 0x00000FFF) << 2 ) & 0x00003FFC ;
555 r6shv = ((din & 0x00000FFF) << 10 ) & 0x003FFC00 ;
560 r3conv = r3shv + FPGA_CONVLIN_OF2;
561 r4conv = r4shv + FPGA_CONVLIN_OF3;
562 r5conv = r5shv + FPGA_CONVLIN_OF4;
563 r6conv = r6shv + FPGA_CONVLIN_OF5;
571 if ( din > FPGA_CONVLIN_TH1 ){
577 if ( din > FPGA_CONVLIN_TH2 ){
582 if ( din > FPGA_CONVLIN_TH3 ){
587 if ( din > FPGA_CONVLIN_TH4 ){
592 if ( din > FPGA_CONVLIN_TH5 ){
598 if ( din > FPGA_CONVLIN_TH6 ){
608 if( (! oth0) & (! oth1 ) & (! oth2 ) & (! oth3 ) & (! oth4 ) & (! oth5 ) & (! oth6 ) ) {
620 else if( ( oth0) & ( oth1 ) & ( oth2 ) & (! oth3 ) & (! oth4 ) & (! oth5 ) & (! oth6 ) ) {
623 else 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 ) ) {
666 int gFEXtowerID)
const {
668 float s_centralPhiWidth =
670 float s_forwardPhiWidth =
674 const std::vector<float> s_EtaCenter = {
675 -4.5, -3.8, -3.38, -3.18, -3.15, -3, -2.8, -2.6, -2.35, -2.1,
676 -1.9, -1.7, -1.5, -1.3, -1.1, -0.9, -0.7, -0.5, -0.3, -0.1,
677 0.1, 0.3, 0.5, 0.7, 0.9, 1.1, 1.3, 1.5, 1.7, 1.9,
678 2.1, 2.35, 2.6, 2.8, 3.0, 3.15, 3.18, 3.38, 3.8, 4.5};
687 int towerID_base = 20000;
688 int iEtaOld = 0, iPhiOld = 0;
691 if (iPhi == ((gFEXtowerID - towerID_base) / 24) * 2) {
695 if (iPhi == (((gFEXtowerID - towerID_base - 12) / 24) * 2) + 1) {
697 iPhiOld = (iPhi - 1) / 2;
701 else if (iEta == 3) {
702 if (iPhi == ((gFEXtowerID - towerID_base - 1) / 24) * 2) {
706 if (iPhi == (((gFEXtowerID - towerID_base - 13) / 24) * 2) + 1) {
708 iPhiOld = (iPhi - 1) / 2;
712 else if (iEta == 36) {
713 if (iPhi == (((gFEXtowerID - towerID_base - 22) / 24) * 2) + 1) {
715 iPhiOld = (iPhi - 1) / 2;
717 if (iPhi == ((gFEXtowerID - towerID_base - 10) / 24) * 2) {
723 else if (iEta == 37) {
724 if (iPhi == (((gFEXtowerID - towerID_base - 23) / 24) * 2) + 1) {
726 iPhiOld = (iPhi - 1) / 2;
728 if (iPhi == ((gFEXtowerID - towerID_base - 11) / 24) * 2) {
739 Eta = s_EtaCenter[iEtaOld];
741 float Phi_gFex = -99;
743 if ((iEtaOld <= 3) || ((iEtaOld >= 36))) {
744 Phi_gFex = ((iPhiOld * s_forwardPhiWidth) + s_forwardPhiWidth / 2);
746 Phi_gFex = ((iPhiOld * s_centralPhiWidth) + s_centralPhiWidth / 2);
749 if (Phi_gFex <
M_PI) {
752 Phi = (Phi_gFex - 2 *
M_PI);