11 m_overlapPresent(true),
12 m_cpCmxTool(
"LVL1::L1CPCMXTools/L1CPCMXTools"),
13 m_cpmTool(
"LVL1::L1CPMTools/L1CPMTools"),
14 m_errorTool(
"LVL1::TrigT1CaloMonErrorTool/TrigT1CaloMonErrorTool")
64 std::vector<std::reference_wrapper<Monitored::IMonitoredVariable>>
variables;
134 bool overlap =
false;
135 bool mismatchCoreEm =
false;
136 bool mismatchCoreHad =
false;
137 bool mismatchOverlapEm =
false;
138 bool mismatchOverlapHad =
false;
140 mismatchCoreEm =
compareEm(ttMapEm, cpMap, errorsCPM, overlap);
141 mismatchCoreHad =
compareHad(ttMapHad, cpMap, errorsCPM, overlap);
144 mismatchOverlapEm =
compareEm(ttMapEm, ovMap, errorsCPM, overlap);
145 mismatchOverlapHad =
compareHad(ttMapHad, ovMap, errorsCPM, overlap);
151 std::unique_ptr<xAOD::CPMTobRoIContainer> cpmRoiSIM = std::make_unique<xAOD::CPMTobRoIContainer>();
152 std::unique_ptr<xAOD::CPMTobRoIAuxContainer> cpmRoiSIMAux = std::make_unique<xAOD::CPMTobRoIAuxContainer>();
154 cpmRoiSIM.get()->setStore(cpmRoiSIMAux.get());
155 if (mismatchCoreEm || mismatchCoreHad || mismatchOverlapEm ||
156 mismatchOverlapHad) {
157 simulate(&cpMap, &ovMap, cpmRoiSIM.get(), ctx);
159 simulate(&cpMap, cpmRoiSIM.get(), ctx);
165 compare(crSimMap, crMap, errorsCPM, rodTESptr);
170 std::unique_ptr<xAOD::CMXCPTobContainer> cmxCpTobSIM = std::make_unique<xAOD::CMXCPTobContainer>();
171 std::unique_ptr<xAOD::CMXCPTobAuxContainer> cmxCpTobSIMAux = std::make_unique<xAOD::CMXCPTobAuxContainer>();
173 cmxCpTobSIM.get()->setStore(cmxCpTobSIMAux.get());
174 simulate(cpmRoiTESptr, cmxCpTobSIM.get());
178 compare(cbSimMap, cbMap, parityMap, errorsCPM, errorsCMX, rodTESptr);
183 std::unique_ptr<xAOD::CMXCPHitsContainer> cmxLocalSIM = std::make_unique<xAOD::CMXCPHitsContainer>();
184 std::unique_ptr<xAOD::CMXCPHitsAuxContainer> cmxLocalSIMAux = std::make_unique<xAOD::CMXCPHitsAuxContainer>();
185 cmxLocalSIM.get()->setStore(cmxLocalSIMAux.get());
191 cmxLocalSimMap.clear();
200 std::unique_ptr<xAOD::CMXCPHitsContainer> cmxTotalSIM = std::make_unique<xAOD::CMXCPHitsContainer>();
201 std::unique_ptr<xAOD::CMXCPHitsAuxContainer> cmxTotalSIMAux = std::make_unique<xAOD::CMXCPHitsAuxContainer>();
203 cmxTotalSIM->setStore(cmxTotalSIMAux.get());
204 simulate(cmxCpHitsTESptr, cmxTotalSIM.get());
209 cmxTotalSimMap.clear();
214 std::unique_ptr<xAOD::CMXCPHitsContainer> cmxTopoSIM = std::make_unique<xAOD::CMXCPHitsContainer>();
215 std::unique_ptr<xAOD::CMXCPHitsAuxContainer> cmxTopoSIMAux = std::make_unique<xAOD::CMXCPHitsAuxContainer>();
216 cmxTopoSIM.get()->setStore(cmxTopoSIMAux.get());
222 cmxTopoSimMap.clear();
240 const int maxErrorsPerLB=10;
241 bool error_tt{
false}, error_roi{
false}, error_tob{
false}, error_thresh{
false};
250 for (
int loc = 0; loc < cpmBins; ++loc) {
251 if ((errorsCPM[loc] >>
err) & 0
x1) {
256 const long long eventNumber = ctx.eventID().event_number();
257 if ((errorsCPM[loc + cpmBins] >>
err) & 0
x1) {
258 cpmErrorLoc_SimNeData=loc;
259 cpmError_SimNeData=
err;
267 std::lock_guard<std::mutex> lock(
m_mutex);
269 m_errorLB_tt_counter[
lb]+=1;
272 if (m_errorLB_tt_counter[
lb]<=maxErrorsPerLB) {
284 }
else if (
err==2 ||
err==3) {
287 std::lock_guard<std::mutex> lock(
m_mutex);
289 m_errorLB_roi_counter[
lb]+=1;
292 if (m_errorLB_roi_counter[
lb]<=maxErrorsPerLB) {
304 }
else if (
err==4 ||
err==5) {
307 std::lock_guard<std::mutex> lock(
m_mutex);
309 m_errorLB_tob_counter[
lb]+=1;
312 if(m_errorLB_tob_counter[
lb]<=maxErrorsPerLB) {
328 if ((errorsCMX[loc] >>
err) & 0
x1) {
329 cpmErrorLoc=loc+cpmBins;
333 if ((errorsCMX[loc + cmxBins] >>
err) & 0
x1) {
334 cpmErrorLoc_SimNeData=loc+cpmBins;
335 cpmError_SimNeData=
err;
349 std::lock_guard<std::mutex> lock(
m_mutex);
351 m_errorLB_thresh_counter[
lb]+=1;
354 if(m_errorLB_thresh_counter[
lb]<=maxErrorsPerLB) {
372 auto save = std::make_unique<ErrorVector>(crateErr);
376 return StatusCode::FAILURE;
384 return StatusCode::SUCCESS;
389 bool overlap)
const {
431 bool mismatch =
false;
433 TriggerTowerMapEm::const_iterator ttMapIter = ttMap.begin();
434 TriggerTowerMapEm::const_iterator ttMapIterEnd = ttMap.end();
435 CpmTowerMap::const_iterator cpMapIter = cpMap.begin();
436 CpmTowerMap::const_iterator cpMapIterEnd = cpMap.end();
438 while (ttMapIter != ttMapIterEnd || cpMapIter != cpMapIterEnd) {
448 if (ttMapIter != ttMapIterEnd)
449 ttKey = ttMapIter->first;
450 if (cpMapIter != cpMapIterEnd)
451 cpKey = cpMapIter->first;
453 if ((cpMapIter == cpMapIterEnd) ||
454 ((ttMapIter != ttMapIterEnd) && (cpKey > ttKey))) {
475 }
else if ((ttMapIter == ttMapIterEnd) ||
476 ((cpMapIter != cpMapIterEnd) && (ttKey > cpKey))) {
484 cpEm =
cp->emEnergy();
503 cpEm =
cp->emEnergy();
518 const int loc = crate *
m_modules + cpm - 1;
521 double phiFPGA = phi;
523 const double twoPi = 2. *
M_PI;
524 const double piByFour =
M_PI / 4.;
525 if (phi > 7. * piByFour)
527 else if (phi < piByFour)
530 const int loc2 =
fpga(crate, phiFPGA);
532 const double phiMod = phi * (32./
M_PI);
534 if (ttEm && ttEm == cpEm) {
537 eta_em_PpmEqOverlap=eta;
538 phi_em_PpmEqOverlap=phiMod;
542 phi_em_PpmEqCor=phiMod;
545 loc_PpmEqCpmFpga=loc;
546 loc_fpga_PpmEqCpmFpga=
loc2;
549 }
else if (ttEm != cpEm) {
551 errors[loc + cpmBins] |= bitEm;
554 eta_em_PpmNeOverlap=eta;
555 phi_em_PpmNeOverlap=phiMod;
559 phi_em_PpmNeCor=phiMod;
562 loc_PpmNeCpmFpga=loc;
563 loc_fpga_PpmNeCpmFpga=
loc2;
568 eta_em_PpmNoOverlap=eta;
569 phi_em_PpmNoOverlap=phiMod;
573 phi_em_PpmNoCor=phiMod;
576 loc_PpmNoCpmFpga=loc;
577 loc_fpga_PpmNoCpmFpga=
loc2;
583 eta_em_OverlapNoPpm=eta;
584 phi_em_OverlapNoPpm=phiMod;
587 eta_em_OverlapNoPpm=eta;
588 phi_em_OverlapNoPpm=phiMod;
591 loc_CpmNoPpmFpga=loc;
592 loc_fpga_CpmNoPpmFpga=
loc2;
596 ATH_MSG_DEBUG(
" EMTowerMismatch key/eta/phi/crate/cpm/tt/cp: "
597 <<
key <<
"/" << eta <<
"/" << phi <<
"/" << crate
598 <<
"/" << cpm <<
"/" << ttEm <<
"/" << cpEm);
607 bool overlap)
const {
651 bool mismatch =
false;
653 TriggerTowerMapHad::const_iterator ttMapIter = ttMap.begin();
654 TriggerTowerMapHad::const_iterator ttMapIterEnd = ttMap.end();
655 CpmTowerMap::const_iterator cpMapIter = cpMap.begin();
656 CpmTowerMap::const_iterator cpMapIterEnd = cpMap.end();
658 while (ttMapIter != ttMapIterEnd || cpMapIter != cpMapIterEnd) {
668 if (ttMapIter != ttMapIterEnd)
669 ttKey = ttMapIter->first;
670 if (cpMapIter != cpMapIterEnd)
671 cpKey = cpMapIter->first;
673 if ((cpMapIter == cpMapIterEnd) ||
674 ((ttMapIter != ttMapIterEnd) && (cpKey > ttKey))) {
699 }
else if ((ttMapIter == ttMapIterEnd) ||
700 ((cpMapIter != cpMapIterEnd) && (ttKey > cpKey))) {
708 cpHad =
cp->hadEnergy();
730 cpHad =
cp->hadEnergy();
734 if (!ttHad && !cpHad)
745 const int loc = crate *
m_modules + cpm - 1;
748 double phiFPGA = phi;
750 const double twoPi = 2. *
M_PI;
751 const double piByFour =
M_PI / 4.;
752 if (phi > 7. * piByFour)
754 else if (phi < piByFour)
757 const int loc2 =
fpga(crate, phiFPGA);
758 const int loc2Mod =
loc2+1;
760 const double phiMod = phi * (32./
M_PI);
761 if (ttHad && ttHad == cpHad) {
764 eta_had_PpmEqOverlap=eta;
765 phi_had_PpmEqOverlap=phiMod;
768 eta_had_PpmEqCor=eta;
769 phi_had_PpmEqCor=phiMod;
772 loc_PpmEqCpmFpga=loc;
773 loc_fpga_PpmEqCpmFpga=loc2Mod;
777 }
else if (ttHad != cpHad) {
779 errors[loc + cpmBins] |= bitHad;
780 if (ttHad && cpHad) {
782 eta_had_PpmNeOverlap=eta;
783 phi_had_PpmNeOverlap=phiMod;
786 eta_had_PpmNeCor=eta;
787 phi_had_PpmNeCor=phiMod;
790 loc_PpmNeCpmFpga=loc;
791 loc_fpga_PpmNeCpmFpga=loc2Mod;
795 eta_had_PpmNoOverlap=eta;
796 phi_had_PpmNoOverlap=phiMod;
799 eta_had_PpmNoCor=eta;
800 phi_had_PpmNoCor=phiMod;
803 loc_PpmNoCpmFpga=loc;
804 loc_fpga_PpmNoCpmFpga=loc2Mod;
809 eta_had_OverlapNoPpm=eta;
810 phi_had_OverlapNoPpm=phiMod;
813 eta_had_OverlapNoPpm=eta;
814 phi_had_OverlapNoPpm=phiMod;
817 loc_CpmNoPpmFpga=loc;
818 loc_fpga_CpmNoPpmFpga=loc2Mod;
822 ATH_MSG_DEBUG(
" HadTowerMismatch key/eta/phi/crate/cpm/tt/cp: "
823 <<
key <<
"/" << eta <<
"/" << phi <<
"/" << crate
824 <<
"/" << cpm <<
"/" << ttHad <<
"/" << cpHad);
841 CpmTobRoiMap::const_iterator simMapIter = roiSimMap.begin();
842 CpmTobRoiMap::const_iterator simMapIterEnd = roiSimMap.end();
843 CpmTobRoiMap::const_iterator datMapIter = roiMap.begin();
844 CpmTobRoiMap::const_iterator datMapIterEnd = roiMap.end();
899 while (simMapIter != simMapIterEnd || datMapIter != datMapIterEnd) {
903 unsigned int simEnergy = 0;
904 unsigned int datEnergy = 0;
905 unsigned int simIsol = 0;
906 unsigned int datIsol = 0;
909 if (simMapIter != simMapIterEnd)
910 simKey = simMapIter->first;
911 if (datMapIter != datMapIterEnd)
912 datKey = datMapIter->first;
914 if ((datMapIter == datMapIterEnd) ||
915 ((simMapIter != simMapIterEnd) && (datKey > simKey))) {
919 roi = simMapIter->second;
920 simEnergy = roi->
energy();
924 }
else if ((simMapIter == simMapIterEnd) ||
925 ((datMapIter != datMapIterEnd) && (simKey > datKey))) {
929 roi = datMapIter->second;
930 datEnergy = roi->
energy();
939 roi = datMapIter->second;
940 simEnergy = roiS->
energy();
942 datEnergy = roi->
energy();
948 if (!simEnergy && !simIsol && !datEnergy && !datIsol)
953 const int crate = roi->
crate();
959 const int cpm = roi->
cpm();
960 const int chip = roi->
chip();
970 const double eta =
coord.eta();
971 const double phi =
coord.phi();
973 if (simEnergy || datEnergy) {
974 if (simEnergy == datEnergy) {
977 tauEnerSimEqDataLocX=
locX;
978 tauEnerSimEqDataLocY=
locY;
981 emEnerSimEqDataLocX=
locX;
982 emEnerSimEqDataLocY=
locY;
987 if (simEnergy && datEnergy) {
989 tauEnerSimNeDataLocX=
locX;
990 tauEnerSimNeDataLocY=
locY;
993 emEnerSimNeDataLocX=
locX;
994 emEnerSimNeDataLocY=
locY;
997 }
else if (simEnergy && !datEnergy) {
999 tauEnerSimNoDataLocX=
locX;
1000 tauEnerSimNoDataLocY=
locY;
1003 emEnerSimNoDataLocX=
locX;
1004 emEnerSimNoDataLocY=
locY;
1009 tauEnerDataNoSimLocX=
locX;
1010 tauEnerDataNoSimLocY=
locY;
1013 emEnerDataNoSimLocX=
locX;
1014 emEnerDataNoSimLocY=
locY;
1020 if (simIsol || datIsol) {
1021 if (simIsol == datIsol) {
1024 tauIsolSimEqDataLocX=
locX;
1025 tauIsolSimEqDataLocY=
locY;
1028 emIsolSimEqDataLocX=
locX;
1029 emIsolSimEqDataLocY=
locY;
1035 if (simIsol && datIsol) {
1037 tauIsolSimNeDataLocX=
locX;
1038 tauIsolSimNeDataLocY=
locY;
1041 emIsolSimNeDataLocX=
locX;
1042 emIsolSimNeDataLocY=
locY;
1045 }
else if (simIsol && !datIsol) {
1047 tauIsolSimNoDataLocX=
locX;
1048 tauIsolSimNoDataLocY=
locY;
1051 emIsolSimNoDataLocX=
locX;
1052 emIsolSimNoDataLocY=
locY;
1057 tauIsolDataNoSimLocX=
locX;
1058 tauIsolDataNoSimLocY=
locY;
1061 emIsolDataNoSimLocX=
locX;
1062 emIsolDataNoSimLocY=
locY;
1068 const double phiMod = (phi * (32./
M_PI)) - 0.5;
1069 double etaMod = eta - 0.05;
1070 if (simEnergy == datEnergy && simIsol == datIsol) {
1072 roiPhiSimEqData=phiMod;
1075 if ((simEnergy || simIsol) && (datEnergy || datIsol)) {
1077 roiPhiSimNeData=phiMod;
1079 }
else if (!datEnergy && !datIsol) {
1081 roiPhiSimNoData=phiMod;
1085 roiPhiDataNoSim=phiMod;
1095 const std::vector<int> & parityMap,
ErrorVector &errorsCPM,
1162 CmxCpTobMap::const_iterator simMapIter = simMap.begin();
1163 CmxCpTobMap::const_iterator simMapIterEnd = simMap.end();
1164 CmxCpTobMap::const_iterator datMapIter = datMap.begin();
1165 CmxCpTobMap::const_iterator datMapIterEnd = datMap.end();
1167 while (simMapIter != simMapIterEnd || datMapIter != datMapIterEnd) {
1179 if (simMapIter != simMapIterEnd)
1180 simKey = simMapIter->first;
1181 if (datMapIter != datMapIterEnd)
1182 datKey = datMapIter->first;
1184 if ((datMapIter == datMapIterEnd) ||
1185 ((simMapIter != simMapIterEnd) && (datKey > simKey))) {
1189 tob = simMapIter->second;
1190 simEnergy = tob->
energy();
1195 }
else if ((simMapIter == simMapIterEnd) ||
1196 ((datMapIter != datMapIterEnd) && (simKey > datKey))) {
1200 tob = datMapIter->second;
1201 datEnergy = tob->
energy();
1211 tob = datMapIter->second;
1212 simEnergy = tobS->
energy();
1215 datEnergy = tob->
energy();
1222 if (!simEnergy && !simIsol && !datEnergy && !datIsol)
1227 const int crate = tob->
crate();
1230 const int cpm = tob->
cpm();
1231 const int cmx = tob->
cmx();
1232 if (!datEnergy && !datIsol) {
1234 if (parityMap[
index])
1240 const int chip = tob->
chip();
1243 const int locY = chip * 4 + loc;
1248 const uint32_t roiWord = ((((((crate << 4) + cpm) << 4) + chip) << 2) + loc)
1252 const double eta =
coord.eta();
1253 const double phi =
coord.phi();
1255 if (simEnergy || datEnergy) {
1256 if (simEnergy == datEnergy) {
1257 errorsCPM[
locX] |= bit;
1258 errorsCMX[
loc2] |= bit;
1260 cmxRightEnerSimEqDataLocX=
locX;
1261 cmxRightEnerSimEqDataLocY=
locY;
1264 cmxLeftEnerSimEqDataLocX=
locX;
1265 cmxLeftEnerSimEqDataLocY=
locY;
1269 errorsCPM[
locX + cpmBins] |= bit;
1270 errorsCMX[
loc2 + cmxBins] |= bit;
1271 if (simEnergy && datEnergy) {
1273 cmxRightEnerSimNeDataLocX=
locX;
1274 cmxRightEnerSimNeDataLocY=
locY;
1277 cmxLeftEnerSimNeDataLocX=
locX;
1278 cmxLeftEnerSimNeDataLocY=
locY;
1281 }
else if (simEnergy && !datEnergy) {
1283 cmxRightEnerSimNoDataLocX=
locX;
1284 cmxRightEnerSimNoDataLocY=
locY;
1287 cmxLeftEnerSimNoDataLocX=
locX;
1288 cmxLeftEnerSimNoDataLocY=
locY;
1293 cmxRightEnerDataNoSimLocX=
locX;
1294 cmxRightEnerDataNoSimLocY=
locY;
1297 cmxLeftEnerDataNoSimLocX=
locX;
1298 cmxLeftEnerDataNoSimLocY=
locY;
1304 if (simIsol || datIsol) {
1305 if (simIsol == datIsol) {
1306 errorsCPM[
locX] |= bit;
1307 errorsCMX[
loc2] |= bit;
1309 cmxRightIsolSimEqDataLocX=
locX;
1310 cmxRightIsolSimEqDataLocY=
locY;
1313 cmxLeftIsolSimEqDataLocX=
locX;
1314 cmxLeftIsolSimEqDataLocY=
locY;
1318 errorsCPM[
locX + cpmBins] |= bit;
1319 errorsCMX[
loc2 + cmxBins] |= bit;
1320 if (simIsol && datIsol) {
1322 cmxRightIsolSimNeDataLocX=
locX;
1323 cmxRightIsolSimNeDataLocY=
locY;
1326 cmxLeftIsolSimNeDataLocX=
locX;
1327 cmxLeftIsolSimNeDataLocY=
locY;
1330 }
else if (simIsol && !datIsol) {
1332 cmxRightIsolSimNoDataLocX=
locX;
1333 cmxRightIsolSimNoDataLocY=
locY;
1336 cmxLeftIsolSimNoDataLocX=
locX;
1337 cmxLeftIsolSimNoDataLocY=
locY;
1342 cmxRightIsolDataNoSimLocX=
locX;
1343 cmxRightIsolDataNoSimLocY=
locY;
1346 cmxLeftIsolDataNoSimLocX=
locX;
1347 cmxLeftIsolDataNoSimLocY=
locY;
1353 if (simOvf || datOvf) {
1354 if (simOvf == datOvf) {
1355 errorsCPM[
locX] |= bit;
1356 errorsCMX[
loc2] |= bit;
1357 cmxOverLocXSimEqData =
locX;
1358 cmxOverCmxSimEqData = cmx;
1361 errorsCPM[
locX + cpmBins] |= bit;
1362 errorsCMX[
loc2 + cmxBins] |= bit;
1363 cmxOverLocXSimNeData =
locX;
1364 cmxOverCmxSimNeData = cmx;
1368 const double phiMod = phi * (32./
M_PI) - 0.5;
1369 double etaMod = eta - 0.05;
1370 if (simEnergy == datEnergy && simIsol == datIsol) {
1372 cmxPhiSimEqData=phiMod;
1375 if ((simEnergy || simIsol) && (datEnergy || datIsol)) {
1377 cmxPhiSimNeData=phiMod;
1379 }
else if (!datEnergy && !datIsol) {
1381 cmxPhiSimNoData=phiMod;
1385 cmxPhiDataNoSim=phiMod;
1399 ATH_MSG_DEBUG(
"Compare Simulated CMX Hit Sums and Data CMX Hit Sums");
1444 CmxCpHitsMap::const_iterator cmxSimMapIter = cmxSimMap.begin();
1445 CmxCpHitsMap::const_iterator cmxSimMapIterEnd = cmxSimMap.end();
1446 CmxCpHitsMap::const_iterator cmxMapIter = cmxMap.begin();
1447 CmxCpHitsMap::const_iterator cmxMapIterEnd = cmxMap.end();
1449 while (cmxSimMapIter != cmxSimMapIterEnd || cmxMapIter != cmxMapIterEnd) {
1453 unsigned int cmxSimHits0 = 0;
1454 unsigned int cmxSimHits1 = 0;
1455 unsigned int cmxHits0 = 0;
1456 unsigned int cmxHits1 = 0;
1461 if (cmxSimMapIter != cmxSimMapIterEnd)
1462 cmxSimKey = cmxSimMapIter->first;
1463 if (cmxMapIter != cmxMapIterEnd)
1464 cmxKey = cmxMapIter->first;
1466 if ((cmxMapIter == cmxMapIterEnd) ||
1467 ((cmxSimMapIter != cmxSimMapIterEnd) && (cmxKey > cmxSimKey))) {
1484 cmxSimHits0 = cmxS->
hits0();
1485 cmxSimHits1 = cmxS->
hits1();
1486 crate = cmxS->
crate();
1489 }
else if ((cmxSimMapIter == cmxSimMapIterEnd) ||
1490 ((cmxMapIter != cmxMapIterEnd) && (cmxSimKey > cmxKey))) {
1509 cmxHits0 = cmxD->
hits0();
1510 cmxHits1 = cmxD->
hits1();
1511 crate = cmxD->
crate();
1536 cmxSimHits0 = cmxS->
hits0();
1537 cmxSimHits1 = cmxS->
hits1();
1538 cmxHits0 = cmxD->
hits0();
1539 cmxHits1 = cmxD->
hits1();
1540 crate = cmxS->
crate();
1544 if (!cmxSimHits0 && !cmxSimHits1 && !cmxHits0 && !cmxHits1)
1549 if (
local || total) {
1550 int loc = crate *
m_cmxs + cmx;
1555 int loc_fill = (
local) ? loc : 14 + cmx;
1556 if (cmxSimHits0 == cmxHits0 && cmxSimHits1 == cmxHits1) {
1558 cmx_sum_loc_SimEqData=loc_fill;
1561 errors[loc + cmxBins] |= bit;
1562 if ((cmxSimHits0 || cmxSimHits1) && (cmxHits0 || cmxHits1)) {
1563 cmx_sum_loc_SimNeData=loc_fill;
1565 }
else if (!cmxHits0 && !cmxHits1) {
1566 cmx_sum_loc_SimNoData=loc_fill;
1569 cmx_sum_loc_DataNoSim=loc_fill;
1574 loc = (
local) ? loc : 14 + cmx;
1577 const int nThresh = 8;
1578 const int thrLen = 3;
1579 int same0 =
thresholdsSame(cmxHits0, cmxSimHits0, nThresh, thrLen);
1580 int diff0 =
thresholdsDiff(cmxHits0, cmxSimHits0, nThresh, thrLen);
1581 int same1 =
thresholdsSame(cmxHits1, cmxSimHits1, nThresh, thrLen);
1582 int diff1 =
thresholdsDiff(cmxHits1, cmxSimHits1, nThresh, thrLen);
1584 fillXVsThresholds(cmx_x_rightsums_SimEqData,cmx_y_rightsums_SimEqData,cmx_w_rightsums_SimEqData,
1585 loc, same0, nThresh, 1);
1586 fillXVsThresholds(cmx_x_rightsums_SimNeData,cmx_y_rightsums_SimNeData,cmx_w_rightsums_SimNeData,
1587 loc, diff0, nThresh, 1);
1588 const int offset = nThresh;
1589 fillXVsThresholds(cmx_x_rightsums_SimEqData,cmx_y_rightsums_SimEqData,cmx_w_rightsums_SimEqData,
1590 loc, same1, nThresh, 1,
offset);
1591 fillXVsThresholds(cmx_x_rightsums_SimNeData,cmx_y_rightsums_SimNeData,cmx_w_rightsums_SimNeData,
1592 loc, diff1, nThresh, 1,
offset);
1594 fillXVsThresholds(cmx_x_leftsums_SimEqData,cmx_y_leftsums_SimEqData,cmx_w_leftsums_SimEqData,
1595 loc, same0, nThresh, 1);
1596 fillXVsThresholds(cmx_x_leftsums_SimNeData,cmx_y_leftsums_SimNeData,cmx_w_leftsums_SimNeData,
1597 loc, diff0, nThresh, 1);
1598 const int offset = nThresh;
1599 fillXVsThresholds(cmx_x_leftsums_SimEqData,cmx_y_leftsums_SimEqData,cmx_w_leftsums_SimEqData,
1600 loc, same1, nThresh, 1,
offset);
1601 fillXVsThresholds(cmx_x_leftsums_SimNeData,cmx_y_leftsums_SimNeData,cmx_w_leftsums_SimNeData,
1602 loc, diff1, nThresh, 1,
offset);
1607 hits0Sim[crate *
m_cmxs + cmx] = cmxSimHits0;
1608 hits1Sim[crate *
m_cmxs + cmx] = cmxSimHits1;
1612 hits0[remCrate *
m_cmxs + cmx] = cmxHits0;
1613 hits1[remCrate *
m_cmxs + cmx] = cmxHits1;
1620 if (cmxSimHits0 == cmxHits0 && cmxSimHits1 == cmxHits1) {
1622 cmxTopoLocXSimEqData=
locX;
1623 cmxTopoLocYSimEqData=
locY;
1627 if ((cmxSimHits0 || cmxSimHits1) && (cmxHits0 || cmxHits1)) {
1628 cmxTopoLocXSimNeData=
locX;
1629 cmxTopoLocYSimNeData=
locY;
1631 }
else if (!cmxHits0 && !cmxHits1) {
1632 cmxTopoLocXSimNoData=
locX;
1633 cmxTopoLocYSimNoData=
locY;
1636 cmxTopoLocXDataNoSim=
locX;
1637 cmxTopoLocYDataNoSim=
locY;
1644 for (
int crate = 0; crate <
m_crates - 1; ++crate) {
1645 for (
int cmx = 0; cmx <
m_cmxs; ++cmx) {
1646 int loc = crate *
m_cmxs + cmx;
1649 const unsigned int hd0 = hits0[loc];
1650 const unsigned int hd1 = hits1[loc];
1651 const unsigned int hs0 = hits0Sim[loc];
1652 const unsigned int hs1 = hits1Sim[loc];
1654 if (!hd0 && !hd1 && !hs0 && !hs1)
1657 int loc_fill = loc + 8;
1658 if (hs0 == hd0 && hs1 == hd1) {
1660 cmx_sum_loc_SimEqData=loc_fill;
1663 errors[loc + cmxBins] |= bit;
1664 if ((hs0 || hs1) && (hd0 || hd1)) {
1665 cmx_sum_loc_SimNeData=loc_fill;
1667 }
else if (!hd0 && !hd1) {
1668 cmx_sum_loc_SimNoData=loc_fill;
1671 cmx_sum_loc_DataNoSim=loc_fill;
1679 const int nThresh = 8;
1680 const int thrLen = 3;
1686 fillXVsThresholds(cmx_x_rightsums_SimEqData,cmx_y_rightsums_SimEqData,cmx_w_rightsums_SimEqData,
1687 loc, same0, nThresh, 1);
1688 fillXVsThresholds(cmx_x_rightsums_SimNeData,cmx_y_rightsums_SimNeData,cmx_w_rightsums_SimNeData,
1689 loc, diff0, nThresh, 1);
1690 const int offset = nThresh;
1691 fillXVsThresholds(cmx_x_rightsums_SimEqData,cmx_y_rightsums_SimEqData,cmx_w_rightsums_SimEqData,
1692 loc, same1, nThresh, 1,
offset);
1693 fillXVsThresholds(cmx_x_rightsums_SimNeData,cmx_y_rightsums_SimNeData,cmx_w_rightsums_SimNeData,
1694 loc, diff1, nThresh, 1,
offset);
1696 fillXVsThresholds(cmx_x_leftsums_SimEqData,cmx_y_leftsums_SimEqData,cmx_w_leftsums_SimEqData,
1697 loc, same0, nThresh, 1);
1698 fillXVsThresholds(cmx_x_leftsums_SimNeData,cmx_y_leftsums_SimNeData,cmx_w_leftsums_SimNeData,
1699 loc, diff0, nThresh, 1);
1700 const int offset = nThresh;
1701 fillXVsThresholds(cmx_x_leftsums_SimEqData,cmx_y_leftsums_SimEqData,cmx_w_leftsums_SimEqData,
1702 loc, same1, nThresh, 1,
offset);
1703 fillXVsThresholds(cmx_x_leftsums_SimNeData,cmx_y_leftsums_SimNeData,cmx_w_leftsums_SimNeData,
1704 loc, diff1, nThresh, 1,
offset);
1717 int x,
int val,
int nThresh,
int nBits,
int offset)
const
1720 const int mask = (1 << nBits) - 1;
1721 for (
int thr = 0; thr < nThresh; ++thr) {
1722 const int hit = (
val >> (nBits*thr)) &
mask;
1736 int nThresh,
int nBits)
const
1739 const int mask = (1 << nBits) - 1;
1740 for (
int thr = 0; thr < nThresh; ++thr) {
1741 const int hit1 = (val1 >> (nBits*thr)) &
mask;
1742 const int hit2 = (val2 >> (nBits*thr)) &
mask;
1743 if (hit1 && (hit1 == hit2))
result |= (1 << thr);
1751 int nThresh,
int nBits)
const
1754 const int mask = (1 << nBits) - 1;
1755 for (
int thr = 0; thr < nThresh; ++thr) {
1756 const int hit1 = (val1 >> (nBits*thr)) &
mask;
1757 const int hit2 = (val2 >> (nBits*thr)) &
mask;
1758 if (hit1 != hit2)
result |= (1 << thr);
1776 for (;
pos != posE; ++
pos) {
1778 const int layer = (*pos)->layer();
1780 emE = (*pos)->cpET();
1783 hadE = (*pos)->cpET();
1785 const double eta = (*pos)->eta();
1786 if (eta > -2.5 && eta < 2.5 && (emE > 0 || hadE > 0)) {
1787 const double phi = (*pos)->phi();
1788 const int key = towerKey.
ttKey(phi, eta);
1790 mapEm.insert(std::make_pair(
key,
tt));
1792 mapHad.insert(std::make_pair(
key,
tt));
1796 return StatusCode::SUCCESS;
1807 for (;
pos != posE; ++
pos) {
1808 CpmTowerMap::mapped_type
cp = (*pos);
1809 const double eta = (*pos)->eta();
1810 const double phi = (*pos)->phi();
1811 const int key = towerKey.
ttKey(phi, eta);
1812 map.insert(std::make_pair(
key,
cp));
1814 return StatusCode::SUCCESS;
1824 for (;
pos != posE; ++
pos) {
1825 const int crate = (*pos)->crate();
1826 const int cpm = (*pos)->cpm();
1827 const int chip = (*pos)->chip();
1828 const int loc = (*pos)->location();
1829 const int type = (*pos)->type();
1831 (((((((
type << 2) | crate) << 4) | cpm) << 3) | chip) << 3) | loc;
1832 map.insert(std::make_pair(
key, *
pos));
1835 return StatusCode::SUCCESS;
1841 std::vector<int> *parityMap)
const {
1845 for (;
pos != posE; ++
pos) {
1846 const int crate = (*pos)->crate();
1847 const int cpm = (*pos)->cpm();
1848 const int cmx = (*pos)->cmx();
1849 const int chip = (*pos)->chip();
1850 const int loc = (*pos)->location();
1852 (((((((crate << 1) | cmx) << 4) | cpm) << 4) | chip) << 2) | loc;
1853 map.insert(std::make_pair(
key, *
pos));
1859 (*parityMap)[
index] = parity;
1863 return StatusCode::SUCCESS;
1872 for (;
pos != posE; ++
pos) {
1873 const int crate = (*pos)->crate();
1874 const int cmx = (*pos)->cmx();
1875 const int source = (*pos)->sourceComponent();
1876 const int key = (crate * 2 + cmx) * 8 +
source;
1877 map.insert(std::make_pair(
key, *
pos));
1879 return StatusCode::SUCCESS;
1890 std::vector<CpmTowerMap> crateMaps(
m_crates);
1892 std::unique_ptr<xAOD::CPMTowerContainer> tempColl = std::make_unique<xAOD::CPMTowerContainer>();
1893 std::unique_ptr<xAOD::CPMTowerAuxContainer> tempCollAux = std::make_unique<xAOD::CPMTowerAuxContainer>();
1895 tempColl.get()->setStore(tempCollAux.get());
1896 for (
const auto& iter : *
towers) {
1897 CpmTowerMap::mapped_type
tt =
ttCheck(iter.second, tempColl.get());
1902 crateMaps[crate].insert(std::make_pair(iter.first,
tt));
1906 CpmTowerMap::mapped_type
tt =
ttCheck(iter.second, tempColl.get());
1911 crateMaps[crate].insert(std::make_pair(iter.first,
tt));
1914 for (
int crate = 0; crate <
m_crates; ++crate) {
1922 for (; roiIter != roiIterE; ++roiIter) {
1923 if ((*roiIter)->crate() == crate) {
1924 rois->push_back(*roiIter);
1956 const EventContext& ctx)
const {
1974 ATH_MSG_DEBUG(
"Simulate CMX Total Hit sums from Remote/Local");
1976 m_cpCmxTool->formCMXCPHitsSystem(hitsIn, hitsOut);
1981 const double phiGran =
M_PI / 32.;
1982 const double phiBase =
M_PI / 2. *
double(crate);
1983 const int phiBin =
int(floor((phi - phiBase) / phiGran)) + 2;
1990 CpmSimMonitorAlgorithm::CpmTowerMap::mapped_type
1997 if ((emParity &&
tt->emEnergy()) || (hadParity &&
tt->hadEnergy())) {
1998 const int peak =
tt->peak();
1999 std::vector<uint8_t> emEnergyVec(
tt->emEnergyVec());
2000 std::vector<uint8_t> hadEnergyVec(
tt->hadEnergyVec());
2001 std::vector<uint32_t> emErrorVec(
tt->emErrorVec());
2002 std::vector<uint32_t> hadErrorVec(
tt->hadErrorVec());
2004 emEnergyVec[peak] = 0;
2006 hadEnergyVec[peak] = 0;
2008 ct->makePrivateStore();
2009 ct->initialize(
tt->eta(),
tt->phi(), emEnergyVec, hadEnergyVec, emErrorVec,
2022 for (; rodIter != rodIterE; ++rodIter) {
2024 const int rodCrate =
rod->crate() - 8;
2025 if (rodCrate >= 0 && rodCrate < m_crates && rod->
dataType() == 1 &&
2026 rod->limitedRoISet()) {
2027 limitedRoi |= (1 << rodCrate);
2030 return (((limitedRoi >> crate) & 0
x1) == 1);
2038 for (; rodIter != rodIterE; ++rodIter) {
2040 const int rodCrate =
rod->crate() - 8;
2041 if (rodCrate >= 0 && rodCrate < m_crates && rod->
dataType() == 1 &&
2042 rod->limitedRoISet()) {
2043 limitedRoi |= (1 << rodCrate);
2046 return (((limitedRoi >> crate) & 0
x1) == 1);