21 static thread_local
int s_corrections[3][25] = {
22 {0,0,0,0,0,0,0,0x8,0,0,0xb,0x4,0x8,0x9,0x34,0x7e,0x7b,0x6b,0,0,0,0,0,0,0xc},
23 {0xe,0x12,0x12,0x12,0x12,0x13,0x18,0x17,0x42,0x40,0x38,0x3d,0x3b,0x4e,0x2d,0xc,0x10,0x4,0x27,0x19,0x19,0x16,0x12,0x10,0xc},
24 {0xb,0x8,0x8,0x8,0x8,0x8,0x7,0x9,0x8,0x8,0x8,0x7,0x8,0x8,0x21,0x2,0x2,0x4,0x6,0x8,0x8,0x8,0x9,0x10,0x12}
33 declareInterface<IeFEXegAlgo>(
this);
46 return StatusCode::SUCCESS;
55 return StatusCode::FAILURE;
58 return StatusCode::SUCCESS;
106 unsigned int coresum = 0;
107 unsigned int totalsum = 0;
108 unsigned int envsum = 0;
128 for (
int i=iTotalStart;
i<=iTotalEnd; ++
i) {
129 for(
int j=0; j<=2; ++j) {
130 if (
i>=iCoreStart && i <= iCoreEnd && j>=phiStart && j<=phiEnd) {
136 totalsum += tmptot_et;
141 envsum = totalsum - coresum;
144 if (coresum > 0xffff) coresum = 0xffff;
145 if (envsum > 0xffff) envsum = 0xffff;
148 retavec.push_back(coresum);
149 retavec.push_back(envsum);
155 unsigned int hadsum = 0;
156 unsigned int emsum = 0;
167 for (
int i=0;
i<3; ++
i) {
168 for (
int j=0; j<=2; ++j) {
182 for (
int i=iCoreStart;
i<=iCoreEnd; ++
i) {
183 for(
int j=0; j<=2; ++j) {
184 unsigned int tmp_et_a, tmp_et_b;
187 emsum += ( tmp_et_a + tmp_et_b );
199 for (
int i = 0;
i < 3; ++
i) {
200 for (
int j = 0; j <= 2; ++j) {
208 if (j == 1 && (
i == 1 ||
i == phi2)) {
222 for (
int i = iCoreStart;
i <= iCoreEnd; ++
i) {
223 for (
int j = phiStart; j <= phiEnd; ++j) {
224 unsigned int tmp_et_a, tmp_et_b;
227 emsum += (tmp_et_a + tmp_et_b);
232 if (emsum > 0xffff) emsum = 0xffff;
233 if (hadsum > 0xffff) hadsum = 0xffff;
236 rhadvec.push_back(emsum);
237 rhadvec.push_back(hadsum);
242 unsigned int numer = 0;
243 unsigned int den = 0;
247 int iStart = m_seedID - 2;
248 int iEnd = m_seedID + 2;
250 for (
int i = iStart;
i <= iEnd; ++
i) {
251 int diff =
i - m_seedID;
253 for (
int j = 0; j <= 2; ++j) {
255 getWindowET(1, j,
i,
eT);
266 if (numer > 0xffff) numer = 0xffff;
269 output.push_back(den);
270 output.push_back(numer);
279 if (m_seed_UnD) phiUpDownID = 2;
282 cellETs.resize(16,0);
285 getWindowET(0, 1, 0, cellETs[0]);
286 getWindowET(0, phiUpDownID, 0, cellETs[1]);
288 getWindowET(1, 1, m_seedID, cellETs[2]);
289 getWindowET(1, 1, m_seedID - 1, cellETs[3]);
290 getWindowET(1, 1, m_seedID + 1, cellETs[4]);
292 getWindowET(1, phiUpDownID, m_seedID, cellETs[5]);
293 getWindowET(1, phiUpDownID, m_seedID - 1, cellETs[6]);
294 getWindowET(1, phiUpDownID, m_seedID + 1, cellETs[7]);
296 getWindowET(2, 1, m_seedID, cellETs[8]);
297 getWindowET(2, 1, m_seedID - 1, cellETs[9]);
298 getWindowET(2, 1, m_seedID + 1, cellETs[10]);
300 getWindowET(2, phiUpDownID, m_seedID, cellETs[11]);
301 getWindowET(2, phiUpDownID, m_seedID - 1, cellETs[12]);
302 getWindowET(2, phiUpDownID, m_seedID + 1, cellETs[13]);
304 getWindowET(3, 1, 0, cellETs[14]);
305 getWindowET(3, phiUpDownID, 0, cellETs[15]);
314 std::vector<unsigned int> clusterCells;
315 getClusterCells(clusterCells);
319 unsigned int PS_ET = 0;
321 if(m_algoVersion==0) {
322 PS_ET = dmCorrection(clusterCells[0], 0)
323 + dmCorrection(clusterCells[1], 0);
326 PS_ET = dmCorrection(clusterCells[0], 0);
327 if ( ((m_efexid%3) == 0 && m_fpgaid == 0) || ((m_efexid%3) == 2 && m_fpgaid == 3)) {
328 PS_ET += dmCorrection(clusterCells[1], 0);
331 unsigned int L1_ET = dmCorrection(clusterCells[2], 1)
332 + dmCorrection(clusterCells[3], 1)
333 + dmCorrection(clusterCells[4], 1)
334 + dmCorrection(clusterCells[5], 1)
335 + dmCorrection(clusterCells[6], 1)
336 + dmCorrection(clusterCells[7], 1);
337 unsigned int L2_ET = dmCorrection(clusterCells[8], 2)
338 + dmCorrection(clusterCells[9], 2)
339 + dmCorrection(clusterCells[10], 2)
340 + dmCorrection(clusterCells[11], 2)
341 + dmCorrection(clusterCells[12], 2)
342 + dmCorrection(clusterCells[13], 2);
343 unsigned int L3_ET = clusterCells[14] + clusterCells[15];
346 unsigned int totET = PS_ET + L1_ET + L2_ET + L3_ET;
349 if (totET > 0xffff) totET = 0xffff;
357 if ( !m_dmCorr ||
layer > 2 )
return ET;
361 int efexEta = m_efexid%3;
365 ieta = 8 + m_fpgaid*4 + m_central_eta - 1;
367 else if (efexEta == 1 && m_fpgaid > 1) {
369 ieta = (m_fpgaid-2)*4 + m_central_eta - 1;
371 else if (efexEta == 1) {
373 ieta = (1-m_fpgaid)*4 + (4-m_central_eta);
377 ieta = 8 + 4*(3-m_fpgaid) + (4-m_central_eta);
380 if (!s_dmCorrectionsLoaded) {
381 std::lock_guard<std::mutex> lk(m_dmCorrectionsMutex);
382 if (!m_dmCorrectionsKey.empty()) {
385 if (dmCorrections.isValid()) {
386 if(dmCorrections->size()==0 && Gaudi::Hive::currentContext().eventID().time_stamp()>1672527600) {
387 ATH_MSG_ERROR(
"No dead material corrections found in conditions database for this event in folder " << m_dmCorrectionsKey.key());
388 throw std::runtime_error(
"No dead material corrections found in database for this event");
390 for (
auto itr = dmCorrections->begin(); itr != dmCorrections->end(); ++itr) {
391 if (itr->first < 25 || itr->first >= 50)
continue;
392 s_corrections[0][itr->first - 25] = itr->second[
"EmPS"].data<
int>();
393 s_corrections[1][itr->first - 25] = itr->second[
"EmFR"].data<
int>();
394 s_corrections[2][itr->first - 25] = itr->second[
"EmMD"].data<
int>();
395 ATH_MSG_DEBUG(
"DM Correction for etaIdx=" << (itr->first - 25) <<
" : [" << s_corrections[0][itr->first - 25] <<
","
396 << s_corrections[1][itr->first - 25] <<
"," << s_corrections[2][itr->first - 25] <<
"]" );
401 s_dmCorrectionsLoaded =
true;
405 unsigned int factor = s_corrections[
layer][ieta];
413 for (
int bit = 6; bit >= 0; bit--) {
415 if (factor & (1<<bit))
425 std::unique_ptr<eFEXegTOB>
out = std::make_unique<eFEXegTOB>();
428 std::vector<unsigned int> temvector;
433 out->setWstotNum(temvector[1]);
434 out->setWstotDen(temvector[0]);
436 out->setRhadEM(temvector[0]);
437 out->setRhadHad(temvector[1]);
439 out->setRetaCore(temvector[0]);
440 out->setRetaEnv(temvector[1]);
441 out->setSeedUnD(m_seed_UnD);
442 out->setSeed(m_seedID);
451 if ((m_efexid%3 == 0) && (m_fpgaid == 0) && (m_central_eta == 0)) {
462 }
else if (SCID>=0 && SCID<4) {
470 if ((m_efexid%3 == 2) && (m_fpgaid == 3) && (m_central_eta == 5)) {
484 if (outET > 0xffff) outET = 0xffff;
492 std::vector<unsigned int> & RetaSums,
493 std::vector<unsigned int> & RhadSums,
494 std::vector<unsigned int> & WstotSums)
514 unsigned int tmpID = 999;
515 unsigned int maxET = 0;
517 for (
int i=0;
i<4 ; ++
i) {
524 unsigned int iSeedET;
526 unsigned int cETDown;
534 unsigned int lETDown;
542 unsigned int rETDown;
546 if (iSeedET>=lET && iSeedET>rET
547 && iSeedET>=lETUp && iSeedET>cETUp && iSeedET>rETUp
548 && iSeedET>=lETDown && iSeedET>=cETDown && iSeedET>rETDown) {
549 if (iSeedET>=maxET) {
559 unsigned int tmp_et_up, tmp_et_down;
562 if (tmp_et_up >= tmp_et_down) {