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;
166 for (
int i=0;
i<3; ++
i) {
167 for (
int j=0; j<=2; ++j) {
181 for (
int i=iCoreStart;
i<=iCoreEnd; ++
i) {
182 for(
int j=0; j<=2; ++j) {
183 unsigned int tmp_et_a, tmp_et_b;
186 emsum += ( tmp_et_a + tmp_et_b );
191 if (emsum > 0xffff) emsum = 0xffff;
192 if (hadsum > 0xffff) hadsum = 0xffff;
195 rhadvec.push_back(emsum);
196 rhadvec.push_back(hadsum);
201 unsigned int numer = 0;
202 unsigned int den = 0;
206 int iStart = m_seedID - 2;
207 int iEnd = m_seedID + 2;
209 for (
int i = iStart;
i <= iEnd; ++
i) {
210 int diff =
i - m_seedID;
212 for (
int j = 0; j <= 2; ++j) {
214 getWindowET(1, j,
i,
eT);
225 if (numer > 0xffff) numer = 0xffff;
238 if (m_seed_UnD) phiUpDownID = 2;
241 cellETs.resize(16,0);
244 getWindowET(0, 1, 0, cellETs[0]);
245 getWindowET(0, phiUpDownID, 0, cellETs[1]);
247 getWindowET(1, 1, m_seedID, cellETs[2]);
248 getWindowET(1, 1, m_seedID - 1, cellETs[3]);
249 getWindowET(1, 1, m_seedID + 1, cellETs[4]);
251 getWindowET(1, phiUpDownID, m_seedID, cellETs[5]);
252 getWindowET(1, phiUpDownID, m_seedID - 1, cellETs[6]);
253 getWindowET(1, phiUpDownID, m_seedID + 1, cellETs[7]);
255 getWindowET(2, 1, m_seedID, cellETs[8]);
256 getWindowET(2, 1, m_seedID - 1, cellETs[9]);
257 getWindowET(2, 1, m_seedID + 1, cellETs[10]);
259 getWindowET(2, phiUpDownID, m_seedID, cellETs[11]);
260 getWindowET(2, phiUpDownID, m_seedID - 1, cellETs[12]);
261 getWindowET(2, phiUpDownID, m_seedID + 1, cellETs[13]);
263 getWindowET(3, 1, 0, cellETs[14]);
264 getWindowET(3, phiUpDownID, 0, cellETs[15]);
273 std::vector<unsigned int> clusterCells;
274 getClusterCells(clusterCells);
277 unsigned int PS_ET = dmCorrection(clusterCells[0], 0)
278 + dmCorrection(clusterCells[1], 0);
279 unsigned int L1_ET = dmCorrection(clusterCells[2], 1)
280 + dmCorrection(clusterCells[3], 1)
281 + dmCorrection(clusterCells[4], 1)
282 + dmCorrection(clusterCells[5], 1)
283 + dmCorrection(clusterCells[6], 1)
284 + dmCorrection(clusterCells[7], 1);
285 unsigned int L2_ET = dmCorrection(clusterCells[8], 2)
286 + dmCorrection(clusterCells[9], 2)
287 + dmCorrection(clusterCells[10], 2)
288 + dmCorrection(clusterCells[11], 2)
289 + dmCorrection(clusterCells[12], 2)
290 + dmCorrection(clusterCells[13], 2);
291 unsigned int L3_ET = clusterCells[14] + clusterCells[15];
294 unsigned int totET = PS_ET + L1_ET + L2_ET + L3_ET;
297 if (totET > 0xffff) totET = 0xffff;
305 if ( !m_dmCorr ||
layer > 2 )
return ET;
309 int efexEta = m_efexid%3;
313 ieta = 8 + m_fpgaid*4 + m_central_eta - 1;
315 else if (efexEta == 1 && m_fpgaid > 1) {
317 ieta = (m_fpgaid-2)*4 + m_central_eta - 1;
319 else if (efexEta == 1) {
321 ieta = (1-m_fpgaid)*4 + (4-m_central_eta);
325 ieta = 8 + 4*(3-m_fpgaid) + (4-m_central_eta);
328 if (!s_dmCorrectionsLoaded) {
329 std::lock_guard<std::mutex> lk(m_dmCorrectionsMutex);
330 if (!m_dmCorrectionsKey.empty()) {
333 if (dmCorrections.isValid()) {
334 if(dmCorrections->size()==0 && Gaudi::Hive::currentContext().eventID().time_stamp()>1672527600) {
335 ATH_MSG_ERROR(
"No dead material corrections found in conditions database for this event in folder " << m_dmCorrectionsKey.key());
336 throw std::runtime_error(
"No dead material corrections found in database for this event");
338 for (
auto itr = dmCorrections->begin(); itr != dmCorrections->end(); ++itr) {
339 if (itr->first < 25 || itr->first >= 50)
continue;
340 s_corrections[0][itr->first - 25] = itr->second[
"EmPS"].data<
int>();
341 s_corrections[1][itr->first - 25] = itr->second[
"EmFR"].data<
int>();
342 s_corrections[2][itr->first - 25] = itr->second[
"EmMD"].data<
int>();
343 ATH_MSG_DEBUG(
"DM Correction for etaIdx=" << (itr->first - 25) <<
" : [" << s_corrections[0][itr->first - 25] <<
","
344 << s_corrections[1][itr->first - 25] <<
"," << s_corrections[2][itr->first - 25] <<
"]" );
349 s_dmCorrectionsLoaded =
true;
353 unsigned int factor = s_corrections[
layer][ieta];
361 for (
int bit = 6; bit >= 0; bit--) {
363 if (factor & (1<<bit))
373 std::unique_ptr<eFEXegTOB>
out = std::make_unique<eFEXegTOB>();
376 std::vector<unsigned int> temvector;
381 out->setWstotNum(temvector[1]);
382 out->setWstotDen(temvector[0]);
384 out->setRhadEM(temvector[0]);
385 out->setRhadHad(temvector[1]);
387 out->setRetaCore(temvector[0]);
388 out->setRetaEnv(temvector[1]);
389 out->setSeedUnD(m_seed_UnD);
390 out->setSeed(m_seedID);
399 if ((m_efexid%3 == 0) && (m_fpgaid == 0) && (m_central_eta == 0)) {
410 }
else if (SCID>=0 && SCID<4) {
418 if ((m_efexid%3 == 2) && (m_fpgaid == 3) && (m_central_eta == 5)) {
432 if (outET > 0xffff) outET = 0xffff;
440 std::vector<unsigned int> & RetaSums,
441 std::vector<unsigned int> & RhadSums,
442 std::vector<unsigned int> & WstotSums)
462 unsigned int tmpID = 999;
463 unsigned int maxET = 0;
465 for (
int i=0;
i<4 ; ++
i) {
472 unsigned int iSeedET;
474 unsigned int cETDown;
482 unsigned int lETDown;
490 unsigned int rETDown;
494 if (iSeedET>=lET && iSeedET>rET
495 && iSeedET>=lETUp && iSeedET>cETUp && iSeedET>rETUp
496 && iSeedET>=lETDown && iSeedET>=cETDown && iSeedET>rETDown) {
497 if (iSeedET>=maxET) {
507 unsigned int tmp_et_up, tmp_et_down;
510 if (tmp_et_up >= tmp_et_down) {