8 #include "GaudiKernel/MsgStream.h"
26 const std::string &
name,
29 m_jeTool(
"LVL1::L1JetElementTools/L1JetElementTools"),
30 m_etTool(
"LVL1::L1EtTools/L1EtTools")
32 declareInterface<IL1EnergyCMXTools>(
this);
55 return StatusCode::SUCCESS;
62 return StatusCode::SUCCESS;
80 for (; iter != iterE; ++iter)
82 if ((*iter)->emJetElementETVec().size() >
nslices)
84 nslices = (*iter)->emJetElementETVec().size();
85 peak = (*iter)->peak();
88 if ((*iter)->hadJetElementETVec().size() >
nslices)
90 nslices = (*iter)->hadJetElementETVec().size();
91 peak = (*iter)->peak();
97 m_jeTool->mapJetElements(jetElementVec, &jeMap);
109 for (; miter != miterE; ++miter)
130 for (; iter != iterE; ++iter)
135 m_etTool->crateSums(modules, crates);
136 systemVec.push_back(
new SystemEnergy(crates, &(*l1Menu)));
143 for (; citer != citerE; ++citer)
149 for (; siter != siterE; ++siter)
161 for (;
pos != pose; ++
pos)
166 item->makePrivateStore();
177 const float moduleEta[8] = {-4.,-2.,-1.2,-0.4,0.4,1.2,2.,4.};
180 bool maskXESet =
false;
181 bool maskTESet =
false;
185 std::vector<std::shared_ptr<TrigConf::L1Threshold>> allThresholds = l1Menu->thresholds();
186 for (
const auto&
thresh : allThresholds ) {
187 if ( (
thresh->type() == def.xeType() ||
thresh->type() == def.teType()) &&
thresh->mapping() > 7 ) {
191 if (maskXE > 0) maskXESet =
true;
192 if (maskTE > 0) maskTESet =
true;
193 if (tvcs.size() == 0) {
194 tvcs.
addRangeValue(thresh_Calo->thrValueCounts(),-49, 49, 1,
true);
196 for (
const auto& tVC : tvcs) {
198 if (tVC.value() >= 0x7fff)
continue;
200 if (
thresh->type() == def.xeType() && !maskXESet ) {
201 for (
unsigned int bin = 0;
bin < 8; ++
bin) {
202 if (moduleEta[
bin] > tVC.etaMin()*0.1 && moduleEta[
bin] < tVC.etaMax()*0.1)
206 else if (
thresh->type() == def.teType() && !maskTESet ) {
207 for (
unsigned int bin = 0;
bin < 8; ++
bin) {
208 if (moduleEta[
bin] > tVC.etaMin()*0.1 && moduleEta[
bin] < tVC.etaMax()*0.1)
222 ATH_MSG_DEBUG(
"Restricted eta masks: XE=" << MSG::hex << maskXE <<
", TE=" << maskTE << MSG::dec);
230 for (
auto iter : modulesVec)
236 cratesVecRestricted.push_back(cratesRestricted);
237 m_etTool->crateSums(modules, cratesFull);
238 m_etTool->crateSums(modules, cratesRestricted, maskXE, maskTE,
true);
246 for (
auto crate : cratesVecFull)
250 for (
auto crate : cratesVecRestricted)
271 for (
int i = 0;
i < 2;
i++)
278 for (; iter != iterE; ++iter)
290 for (
int i = 0;
i < 2;
i++)
295 for (; siter != siterE; ++siter)
315 for (; iter != iterE; ++iter)
329 for (;
pos != pose; ++
pos)
335 int crate = sums->
crate();
336 if (sums->
peak() > peak)
350 for (
unsigned int sl = 0; sl <
slices; ++sl)
354 et[sl], ex[sl], ey[sl]));
366 unsigned int nslicesFull = 0;
367 unsigned int nslicesRestricted = 0;
372 unsigned int *
nslices =
nullptr;
373 bool restricted =
false;
374 for (;
pos != pose; ++
pos)
377 int crate = sums->
crate();
387 crateVec = &crateVecRestricted;
391 crateVec = &crateVecFull;
395 if (sums->
peak() > peak)
413 for (
unsigned int sl = 0; sl <
slices; ++sl)
427 dumpCrateEnergies(
"Crates from restricted region (for total)", crateVecRestricted);
439 for (;
pos != pose; ++
pos)
445 if (sums->
peak() > peak)
455 for (
unsigned int sl = 0; sl <
slices; ++sl)
467 systemVec.push_back(systemEnergy);
478 std::map<int, xAOD::JEMEtSums *> etMap;
479 unsigned int nslices = modulesVec.size();
486 for (;
pos != pose; ++
pos)
492 unsigned int ex =
energy->ex();
493 unsigned int ey =
energy->ey();
495 if (ex == 0 && ey == 0 &&
et == 0)
497 int crate =
energy->crate();
502 if (iter == etMap.end())
507 etMap.insert(std::make_pair(
key, sums));
512 std::vector<uint16_t> exVec(sums->
exVec());
513 std::vector<uint16_t> eyVec(sums->
eyVec());
514 std::vector<uint16_t> etVec(sums->
etVec());
531 std::map<int, xAOD::CMXEtSums *> etMap;
532 unsigned int nslices = cratesVec.size();
540 for (;
pos != pose; ++
pos)
543 unsigned int ex =
energy->exTC();
544 unsigned int ey =
energy->eyTC();
546 int exOverflow =
energy->exOverflow();
547 int eyOverflow =
energy->eyOverflow();
548 int etOverflow =
energy->etOverflow();
549 if (ex == 0 && ey == 0 &&
et == 0 &&
550 exOverflow == 0 && eyOverflow == 0 && etOverflow == 0)
552 int crate =
energy->crate();
555 for (
int i = 0;
i < 2; ++
i)
557 for (
int j = 0; j < 2; ++j)
561 if (iter == etMap.end())
567 etMap.insert(std::make_pair(
key, sums));
572 std::vector<uint16_t> exVec(sums->
exVec());
573 std::vector<uint16_t> eyVec(sums->
eyVec());
574 std::vector<uint16_t> etVec(sums->
etVec());
575 std::vector<uint32_t> exErr(sums->
exErrorVec());
576 std::vector<uint32_t> eyErr(sums->
eyErrorVec());
577 std::vector<uint32_t> etErr(sums->
etErrorVec());
599 sums->
addEx(exVec, exErr);
600 sums->
addEy(eyVec, eyErr);
601 sums->
addEt(etVec, etErr);
624 std::map<int, xAOD::CMXEtSums *> etMap;
625 unsigned int nslices = cratesVecFull.size();
635 for (
unsigned int i = 0;
i < 2;
i++)
637 const auto *crates = (
i == 0 ? cratesVecFull[
slice] : cratesVecRestricted[
slice]);
640 for (
auto pos : *crates)
644 unsigned int ex =
energy->exTC();
645 unsigned int ey =
energy->eyTC();
647 int exOverflow =
energy->exOverflow();
648 int eyOverflow =
energy->eyOverflow();
649 int etOverflow =
energy->etOverflow();
650 if (ex == 0 && ey == 0 &&
et == 0 &&
651 exOverflow == 0 && eyOverflow == 0 && etOverflow == 0)
653 int crate =
energy->crate();
660 if (iter == etMap.end())
666 etMap.insert(std::make_pair(
key, sums));
671 std::vector<uint16_t> exVec(sums->
exVec());
672 std::vector<uint16_t> eyVec(sums->
eyVec());
673 std::vector<uint16_t> etVec(sums->
etVec());
674 std::vector<uint32_t> exErr(sums->
exErrorVec());
675 std::vector<uint32_t> eyErr(sums->
eyErrorVec());
676 std::vector<uint32_t> etErr(sums->
etErrorVec());
698 sums->
addEx(exVec, exErr);
699 sums->
addEy(eyVec, eyErr);
700 sums->
addEt(etVec, etErr);
743 unsigned int nslices = systemVec.size();
749 unsigned int ex =
energy->exTC();
750 unsigned int ey =
energy->eyTC();
752 int exOverflow =
energy->exOverflow();
753 int eyOverflow =
energy->eyOverflow();
754 int etOverflow =
energy->etOverflow();
757 if (ex == 0 && ey == 0 &&
et == 0 &&
758 exOverflow == 0 && eyOverflow == 0 && etOverflow == 0)
768 std::vector<uint16_t> exVec(sums->
exVec());
769 std::vector<uint16_t> eyVec(sums->
eyVec());
770 std::vector<uint16_t> etVec(sums->
etVec());
771 std::vector<uint32_t> exErr(sums->
exErrorVec());
772 std::vector<uint32_t> eyErr(sums->
eyErrorVec());
773 std::vector<uint32_t> etErr(sums->
etErrorVec());
797 sums->
addEx(exVec, exErr);
798 sums->
addEy(eyVec, eyErr);
799 sums->
addEt(etVec, etErr);
823 int nslicesRestricted = 0;
825 std::map<int, bool> isRestrictedMap;
828 for (
unsigned int i = 0;
i < systemVec.size(); ++
i)
830 bool isRestricted = (systemVec[
i]->roiWord0() >> 26) & 1;
831 isRestrictedMap[
i] = isRestricted;
841 std::vector<uint16_t> dataFull(nslicesFull);
842 std::vector<uint32_t> errorFull(nslicesFull);
844 std::vector<uint16_t> dataRestricted(nslicesRestricted);
845 std::vector<uint32_t> errorRestricted(nslicesRestricted);
848 int iSliceRestricted = 0;
851 for (
unsigned int i = 0;
i < systemVec.size(); ++
i)
854 bool restricted = isRestrictedMap[
i];
856 std::vector<uint16_t>*
data;
857 std::vector<uint32_t>*
error;
860 sumEt = &sumEtRestricted;
861 missEt = &missEtRestricted;
862 missEtSig = &missEtSigRestricted;
863 iSlice = &iSliceRestricted;
864 data = &dataRestricted;
865 error = &errorRestricted;
870 missEt = &missEtFull;
871 missEtSig = &missEtSigFull;
872 iSlice = &iSliceFull;
877 unsigned int slice = *iSlice;
880 unsigned int etSumHits =
energy->etSumHits();
887 (*sumEt)->initialize(1, restricted
893 std::vector<uint16_t> etVec((*sumEt)->etVec());
894 etVec[
slice] = etSumHits;
896 (*sumEt)->addEx(etVec, *
error);
897 (*sumEt)->addEy(etVec, *
error);
898 (*sumEt)->addEt(etVec, *
error);
902 unsigned int etMissHits =
energy->etMissHits();
909 (*missEt)->initialize(1, restricted
915 std::vector<uint16_t> etVec((*missEt)->etVec());
916 etVec[
slice] = etMissHits;
917 (*missEt)->addEx(etVec, *
error);
918 (*missEt)->addEy(etVec, *
error);
919 (*missEt)->addEt(etVec, *
error);
921 unsigned int etMissSigHits =
energy->metSigHits();
931 std::vector<uint16_t> etVec((*missEtSig)->etVec());
932 etVec[
slice] = etMissSigHits;
933 (*missEtSig)->addEx(etVec, *
error);
934 (*missEtSig)->addEy(etVec, *
error);
935 (*missEtSig)->addEt(etVec, *
error);
946 for (
const auto&
p : crates) {
948 ATH_MSG_DEBUG(
" CrateEnergy: crate " <<
c->crate() <<
" results ");