69 m_firstEvLumiSegment(
true),
98 delete m_candL1External;
118 m_candL1Mu->setBXRange(m_bxFirst_, m_bxLast_);
119 m_candL1EG->setBXRange(m_bxFirst_, m_bxLast_);
120 m_candL1Tau->setBXRange(m_bxFirst_, m_bxLast_);
121 m_candL1Jet->setBXRange(m_bxFirst_, m_bxLast_);
122 m_candL1EtSum->setBXRange(m_bxFirst_, m_bxLast_);
123 m_candL1External->setBXRange(m_bxFirst_, m_bxLast_);
127 LogDebug(
"L1TGlobal") <<
"\t Initializing Board with bxFirst = " << m_bxFirst_ <<
", bxLast = " << m_bxLast_
137 const bool receiveEG,
139 const bool receiveTau,
141 const bool receiveJet,
143 const bool receiveEtSums) {
145 LogDebug(
"L1TGlobal") <<
"\n**** Board receiving Calo Data "
155 iEvent.getByToken(egInputToken, egData);
159 edm::LogWarning(
"L1TGlobal") <<
"\nWarning: BXVector<l1t::EGamma> with input tag "
161 <<
"\nrequested in configuration, but not found in the event.\n"
166 for (
int i = egData->getFirstBX();
i <= egData->getLastBX(); ++
i) {
168 if (i < m_bxFirst_ || i > m_bxLast_)
173 for (std::vector<l1t::EGamma>::const_iterator eg = egData->begin(
i); eg != egData->end(
i); ++eg) {
175 (*m_candL1EG).push_back(
i, &(*eg));
177 edm::LogWarning(
"L1TGlobal") <<
" Too many EG (" << nObj <<
") for uGT Configuration maxEG =" << nrL1EG
180 LogDebug(
"L1TGlobal") <<
"EG Pt " << eg->hwPt() <<
" Eta " << eg->hwEta() <<
" Phi " << eg->hwPhi()
181 <<
" Qual " << eg->hwQual() <<
" Iso " << eg->hwIso() << std::endl;
193 iEvent.getByToken(tauInputToken, tauData);
197 edm::LogWarning(
"L1TGlobal") <<
"\nWarning: BXVector<l1t::Tau> with input tag "
199 <<
"\nrequested in configuration, but not found in the event.\n"
204 for (
int i = tauData->getFirstBX();
i <= tauData->getLastBX(); ++
i) {
206 if (i < m_bxFirst_ || i > m_bxLast_)
211 for (std::vector<l1t::Tau>::const_iterator
tau = tauData->begin(
i);
tau != tauData->end(
i); ++
tau) {
212 if (nObj < nrL1Tau) {
213 (*m_candL1Tau).push_back(
i, &(*
tau));
215 LogTrace(
"L1TGlobal") <<
" Too many Tau (" << nObj <<
") for uGT Configuration maxTau =" << nrL1Tau
219 LogDebug(
"L1TGlobal") <<
"tau Pt " <<
tau->hwPt() <<
" Eta " <<
tau->hwEta() <<
" Phi " <<
tau->hwPhi()
220 <<
" Qual " <<
tau->hwQual() <<
" Iso " <<
tau->hwIso() << std::endl;
236 edm::LogWarning(
"L1TGlobal") <<
"\nWarning: BXVector<l1t::Jet> with input tag "
238 <<
"\nrequested in configuration, but not found in the event.\n"
245 if (i < m_bxFirst_ || i > m_bxLast_)
251 if (nObj < nrL1Jet) {
252 (*m_candL1Jet).push_back(
i, &(*
jet));
254 edm::LogWarning(
"L1TGlobal") <<
" Too many Jets (" << nObj <<
") for uGT Configuration maxJet =" << nrL1Jet
258 LogDebug(
"L1TGlobal") <<
"Jet Pt " <<
jet->hwPt() <<
" Eta " <<
jet->hwEta() <<
" Phi " <<
jet->hwPhi()
259 <<
" Qual " <<
jet->hwQual() <<
" Iso " <<
jet->hwIso() << std::endl;
270 iEvent.getByToken(sumInputToken, etSumData);
274 edm::LogWarning(
"L1TGlobal") <<
"\nWarning: BXVector<l1t::EtSum> with input tag "
276 <<
"\nrequested in configuration, but not found in the event.\n"
280 for (
int i = etSumData->getFirstBX();
i <= etSumData->getLastBX(); ++
i) {
282 if (i < m_bxFirst_ || i > m_bxLast_)
286 for (std::vector<l1t::EtSum>::const_iterator etsum = etSumData->begin(
i); etsum != etSumData->end(
i); ++etsum) {
287 (*m_candL1EtSum).push_back(
i, &(*etsum));
336 const bool receiveMu,
339 LogDebug(
"L1TGlobal") <<
"\n**** GlobalBoard receiving muon data = "
349 iEvent.getByToken(muInputToken, muonData);
353 edm::LogWarning(
"L1TGlobal") <<
"\nWarning: BXVector<l1t::Muon> with input tag "
355 <<
"\nrequested in configuration, but not found in the event.\n"
360 for (
int i = muonData->getFirstBX();
i <= muonData->getLastBX(); ++
i) {
362 if (i < m_bxFirst_ || i > m_bxLast_)
367 for (std::vector<l1t::Muon>::const_iterator
mu = muonData->begin(
i);
mu != muonData->end(
i); ++
mu) {
369 (*m_candL1Mu).push_back(
i, &(*
mu));
371 edm::LogWarning(
"L1TGlobal") <<
" Too many Muons (" << nObj <<
") for uGT Configuration maxMu =" << nrL1Mu
375 LogDebug(
"L1TGlobal") <<
"Muon Pt " <<
mu->hwPt() <<
" EtaAtVtx " <<
mu->hwEtaAtVtx() <<
" PhiAtVtx "
376 <<
mu->hwPhiAtVtx() <<
" Qual " <<
mu->hwQual() <<
" Iso " <<
mu->hwIso()
390 const bool receiveExt) {
392 LogDebug(
"L1TGlobal") <<
"\n**** GlobalBoard receiving external data = "
402 iEvent.getByToken(extInputToken, extData);
406 edm::LogWarning(
"L1TGlobal") <<
"\nWarning: BXVector<GlobalExtBlk> with input tag "
408 <<
"\nrequested in configuration, but not found in the event.\n"
413 for (
int i = extData->getFirstBX();
i <= extData->getLastBX(); ++
i) {
415 if (i < m_bxFirst_ || i > m_bxLast_)
419 for (std::vector<GlobalExtBlk>::const_iterator
ext = extData->begin(
i);
ext != extData->end(
i); ++
ext) {
420 (*m_candL1External).push_back(
i, &(*
ext));
433 const bool produceL1GtObjectMapRecord,
434 const int iBxInEvent,
435 std::unique_ptr<GlobalObjectMapRecord>& gtObjectMapRecord,
436 const unsigned int numberPhysTriggers,
441 const std::vector<ConditionMap>& conditionMap = m_l1GtMenu->
gtConditionMap();
445 LogDebug(
"L1TGlobal") <<
" L1 Menu Scales -- Set Name: " << scaleSetName << std::endl;
449 m_algInitialOr =
false;
450 m_algPrescaledOr =
false;
451 m_algIntermOr =
false;
452 m_algFinalOr =
false;
453 m_algFinalOrVeto =
false;
455 const std::vector<std::vector<MuonTemplate>>& corrMuon = m_l1GtMenu->
corMuonTemplate();
458 const std::vector<std::vector<CaloTemplate>>& corrCalo = m_l1GtMenu->
corCaloTemplate();
460 const std::vector<std::vector<EnergySumTemplate>>& corrEnergySum = m_l1GtMenu->
corEnergySumTemplate();
462 LogDebug(
"L1TGlobal") <<
"Size corrMuon " << corrMuon.size() <<
"\nSize corrCalo " << corrCalo.size()
463 <<
"\nSize corrSums " << corrEnergySum.size() << std::endl;
470 if (m_conditionResultMaps.size() != conditionMap.size()) {
471 m_conditionResultMaps.clear();
472 m_conditionResultMaps.resize(conditionMap.size());
477 for (std::vector<ConditionMap>::const_iterator itCondOnChip = conditionMap.begin();
478 itCondOnChip != conditionMap.end();
484 for (
CItCond itCond = itCondOnChip->begin(); itCond != itCondOnChip->end(); itCond++) {
486 switch ((itCond->second)->condCategory()) {
489 const int ifMuEtaNumberBits = 0;
498 cMapResults[itCond->first] = muCondition;
500 if (m_verbosity && m_isDebugEnabled) {
501 std::ostringstream myCout;
502 muCondition->
print(myCout);
504 LogTrace(
"L1TGlobal") << myCout.str() << std::endl;
511 const int ifCaloEtaNumberBits = 0;
514 new CaloCondition(itCond->second,
this, nrL1EG, nrL1Jet, nrL1Tau, ifCaloEtaNumberBits);
520 cMapResults[itCond->first] = caloCondition;
522 if (m_verbosity && m_isDebugEnabled) {
523 std::ostringstream myCout;
524 caloCondition->
print(myCout);
526 LogTrace(
"L1TGlobal") << myCout.str() << std::endl;
537 cMapResults[itCond->first] = eSumCondition;
539 if (m_verbosity && m_isDebugEnabled) {
540 std::ostringstream myCout;
541 eSumCondition->
print(myCout);
543 LogTrace(
"L1TGlobal") << myCout.str() << std::endl;
555 cMapResults[itCond->first] = extCondition;
557 if (m_verbosity && m_isDebugEnabled) {
558 std::ostringstream myCout;
559 extCondition->
print(myCout);
561 LogTrace(
"L1TGlobal") << myCout.str() << std::endl;
568 const CorrelationTemplate* corrTemplate = static_cast<const CorrelationTemplate*>(itCond->second);
571 const int cond0Ind = corrTemplate->
cond0Index();
572 const int cond1Ind = corrTemplate->
cond1Index();
578 int cond0NrL1Objects = 0;
579 int cond1NrL1Objects = 0;
580 LogDebug(
"L1TGlobal") <<
" cond0NrL1Objects" << cond0NrL1Objects <<
" cond1NrL1Objects " << cond1NrL1Objects
583 switch (cond0Categ) {
585 cond0Condition = &((corrMuon[iChip])[cond0Ind]);
588 cond0Condition = &((corrCalo[iChip])[cond0Ind]);
591 cond0Condition = &((corrEnergySum[iChip])[cond0Ind]);
598 switch (cond1Categ) {
600 cond1Condition = &((corrMuon[iChip])[cond1Ind]);
603 cond1Condition = &((corrCalo[iChip])[cond1Ind]);
606 cond1Condition = &((corrEnergySum[iChip])[cond1Ind]);
619 cMapResults[itCond->first] = correlationCond;
621 if (m_verbosity && m_isDebugEnabled) {
622 std::ostringstream myCout;
623 correlationCond->
print(myCout);
625 LogTrace(
"L1TGlobal") << myCout.str() << std::endl;
634 static_cast<const CorrelationThreeBodyTemplate*>(itCond->second);
638 const int cond0Ind = corrTemplate->
cond0Index();
639 const int cond1Ind = corrTemplate->
cond1Index();
640 const int cond2Ind = corrTemplate->
cond2Index();
647 int cond0NrL1Objects = 0;
648 int cond1NrL1Objects = 0;
649 int cond2NrL1Objects = 0;
650 LogDebug(
"L1TGlobal") <<
" cond0NrL1Objects " << cond0NrL1Objects <<
" cond1NrL1Objects "
651 << cond1NrL1Objects <<
" cond2NrL1Objects " << cond2NrL1Objects << std::endl;
653 cond0Condition = &((corrMuon[iChip])[cond0Ind]);
655 LogDebug(
"L1TGlobal") <<
"No muon0 to evaluate three-body correlation condition";
658 cond1Condition = &((corrMuon[iChip])[cond1Ind]);
660 LogDebug(
"L1TGlobal") <<
"No muon1 to evaluate three-body correlation condition";
663 cond2Condition = &((corrMuon[iChip])[cond2Ind]);
665 LogDebug(
"L1TGlobal") <<
"No muon2 to evaluate three-body correlation condition";
672 correlationThreeBodyCond->
setScales(>Scales);
674 cMapResults[itCond->first] = correlationThreeBodyCond;
676 if (m_verbosity && m_isDebugEnabled) {
677 std::ostringstream myCout;
678 correlationThreeBodyCond->
print(myCout);
680 LogTrace(
"L1TGlobal") << myCout.str() << std::endl;
688 static_cast<const CorrelationWithOverlapRemovalTemplate*>(itCond->second);
692 const int cond0Ind = corrTemplate->
cond0Index();
693 const int cond1Ind = corrTemplate->
cond1Index();
694 const int cond2Ind = corrTemplate->
cond2Index();
701 int cond0NrL1Objects = 0;
702 int cond1NrL1Objects = 0;
703 int cond2NrL1Objects = 0;
704 LogDebug(
"L1TGlobal") <<
" cond0NrL1Objects" << cond0NrL1Objects <<
" cond1NrL1Objects " << cond1NrL1Objects
705 <<
" cond2NrL1Objects " << cond2NrL1Objects << std::endl;
707 switch (cond0Categ) {
709 cond0Condition = &((corrMuon[iChip])[cond0Ind]);
712 cond0Condition = &((corrCalo[iChip])[cond0Ind]);
715 cond0Condition = &((corrEnergySum[iChip])[cond0Ind]);
722 switch (cond1Categ) {
724 cond1Condition = &((corrMuon[iChip])[cond1Ind]);
727 cond1Condition = &((corrCalo[iChip])[cond1Ind]);
730 cond1Condition = &((corrEnergySum[iChip])[cond1Ind]);
737 switch (cond2Categ) {
739 cond2Condition = &((corrMuon[iChip])[cond2Ind]);
742 cond2Condition = &((corrCalo[iChip])[cond2Ind]);
745 cond2Condition = &((corrEnergySum[iChip])[cond2Ind]);
756 correlationCondWOR->
setScales(>Scales);
759 cMapResults[itCond->first] = correlationCondWOR;
761 if (m_verbosity && m_isDebugEnabled) {
762 std::ostringstream myCout;
763 correlationCondWOR->
print(myCout);
765 LogTrace(
"L1TGlobal") << myCout.str() << std::endl;
786 std::vector<GlobalObjectMap> objMapVec;
787 if (produceL1GtObjectMapRecord && (iBxInEvent == 0))
788 objMapVec.reserve(numberPhysTriggers);
790 for (
CItAlgo itAlgo = algorithmMap.begin(); itAlgo != algorithmMap.end(); itAlgo++) {
792 gtAlg.
evaluateAlgorithm((itAlgo->second).algoChipNumber(), m_conditionResultMaps);
794 int algBitNumber = (itAlgo->second).algoBitNumber();
797 LogDebug(
"L1TGlobal") <<
" ===> for iBxInEvent = " << iBxInEvent <<
":\t algBitName = " << itAlgo->first
798 <<
",\t algBitNumber = " << algBitNumber <<
",\t algResult = " << algResult << std::endl;
802 m_uGtAlgBlk.setAlgoDecisionInitial(algBitNumber, algResult);
803 m_algInitialOr =
true;
806 if (m_verbosity && m_isDebugEnabled) {
807 std::ostringstream myCout;
808 (itAlgo->second).
print(myCout);
811 LogTrace(
"L1TGlobal") << myCout.str() << std::endl;
815 if (produceL1GtObjectMapRecord && (iBxInEvent == 0)) {
816 std::vector<L1TObjectTypeInCond> otypes;
822 for (
auto imap = conditionMap.begin(); imap != conditionMap.end(); imap++) {
824 auto match = imap->find(iop->tokenName);
826 if (
match != imap->end()) {
832 for (
auto itype =
otype.begin(); itype !=
otype.end(); itype++) {
838 edm::LogWarning(
"L1TGlobal") <<
"\n Failed to find match for operand token " << iop->tokenName <<
"\n";
840 otypes.push_back(
otype);
855 if (m_verbosity && m_isDebugEnabled) {
856 std::ostringstream myCout1;
857 objMap.
print(myCout1);
859 LogTrace(
"L1TGlobal") << myCout1.str() << std::endl;
862 objMapVec.push_back(objMap);
867 if (produceL1GtObjectMapRecord && (iBxInEvent == 0)) {
868 gtObjectMapRecord->swapGtObjectMap(objMapVec);
874 for (std::vector<AlgorithmEvaluation::ConditionEvaluationMap>::iterator itCondOnChip = m_conditionResultMaps.begin();
875 itCondOnChip != m_conditionResultMaps.end();
878 delete itCond->second;
879 itCond->second =
nullptr;
886 const int iBxInEvent,
887 const int totalBxInEvent,
888 const unsigned int numberPhysTriggers,
889 const std::vector<double>& prescaleFactorsAlgoTrig,
890 const std::vector<unsigned int>& triggerMaskAlgoTrig,
891 const std::vector<int>& triggerMaskVetoAlgoTrig,
892 const bool algorithmTriggersUnprescaled,
893 const bool algorithmTriggersUnmasked) {
895 LogDebug(
"L1TGlobal") <<
"\n**** GlobalBoard apply Final Decision Logic " << std::endl;
901 m_prescaleCounterAlgoTrig.reserve(numberPhysTriggers * totalBxInEvent);
903 for (
int iBxInEvent = 0; iBxInEvent <= totalBxInEvent; ++iBxInEvent) {
904 m_prescaleCounterAlgoTrig.push_back(prescaleFactorsAlgoTrig);
907 m_currentLumi =
iEvent.luminosityBlock();
911 if (m_firstEvLumiSegment || m_currentLumi !=
iEvent.luminosityBlock()) {
912 m_prescaleCounterAlgoTrig.clear();
913 for (
int iBxInEvent = 0; iBxInEvent <= totalBxInEvent; ++iBxInEvent) {
914 m_prescaleCounterAlgoTrig.push_back(prescaleFactorsAlgoTrig);
917 m_firstEvLumiSegment =
false;
918 m_currentLumi =
iEvent.luminosityBlock();
923 m_uGtAlgBlk.copyInitialToInterm();
928 if (!algorithmTriggersUnprescaled) {
930 int inBxInEvent = totalBxInEvent / 2 + iBxInEvent;
932 bool temp_algPrescaledOr =
false;
933 bool alreadyReported =
false;
934 for (
unsigned int iBit = 0; iBit < numberPhysTriggers; ++iBit) {
935 bool bitValue = m_uGtAlgBlk.getAlgoDecisionInitial(iBit);
938 if (iBit < prescaleFactorsAlgoTrig.size()) {
939 if (prescaleFactorsAlgoTrig.at(iBit) != 1) {
940 (m_prescaleCounterAlgoTrig.at(inBxInEvent).at(iBit))--;
941 if (m_prescaleCounterAlgoTrig.at(inBxInEvent).at(iBit) == 0) {
943 m_prescaleCounterAlgoTrig.at(inBxInEvent).at(iBit) = prescaleFactorsAlgoTrig.at(iBit);
944 temp_algPrescaledOr =
true;
947 m_uGtAlgBlk.setAlgoDecisionInterm(iBit,
false);
952 temp_algPrescaledOr =
true;
955 else if (!alreadyReported) {
956 alreadyReported =
true;
957 edm::LogWarning(
"L1TGlobal") <<
"\nWarning: algoBit >= prescaleFactorsAlgoTrig.size() in bx " << iBxInEvent
963 m_algPrescaledOr = temp_algPrescaledOr;
967 m_algPrescaledOr = m_algInitialOr;
973 m_uGtAlgBlk.copyIntermToFinal();
975 if (!algorithmTriggersUnmasked) {
976 bool temp_algFinalOr =
false;
977 bool alreadyReported =
false;
978 for (
unsigned int iBit = 0; iBit < numberPhysTriggers; ++iBit) {
979 bool bitValue = m_uGtAlgBlk.getAlgoDecisionInterm(iBit);
983 bool isMasked =
false;
984 if (iBit < triggerMaskAlgoTrig.size())
985 isMasked = (triggerMaskAlgoTrig.at(iBit) == 0);
986 else if (!alreadyReported) {
987 alreadyReported =
true;
988 edm::LogWarning(
"L1TGlobal") <<
"\nWarning: algoBit >= triggerMaskAlgoTrig.size() in bx " << iBxInEvent
992 bool passMask = (bitValue && !isMasked);
995 temp_algFinalOr =
true;
997 m_uGtAlgBlk.setAlgoDecisionFinal(iBit,
false);
1000 if (triggerMaskVetoAlgoTrig.at(iBit) == 1)
1001 m_algFinalOrVeto =
true;
1005 m_algIntermOr = temp_algFinalOr;
1008 m_algIntermOr = m_algPrescaledOr;
1013 m_algFinalOr = (m_algIntermOr & !m_algFinalOrVeto);
1018 std::unique_ptr<GlobalAlgBlkBxCollection>& uGtAlgRecord,
1023 LogDebug(
"L1TGlobal") <<
"\n**** GlobalBoard fill DAQ Records for bx= " << iBxInEvent << std::endl;
1027 m_uGtAlgBlk.setbxInEventNr((iBxInEvent & 0xF));
1028 m_uGtAlgBlk.setPreScColumn(prescaleSet);
1029 m_uGtAlgBlk.setL1MenuUUID(menuUUID);
1030 m_uGtAlgBlk.setL1FirmwareUUID(firmwareUUID);
1032 m_uGtAlgBlk.setFinalORVeto(m_algFinalOrVeto);
1033 m_uGtAlgBlk.setFinalORPreVeto(m_algIntermOr);
1034 m_uGtAlgBlk.setFinalOR(m_algFinalOr);
1036 uGtAlgRecord->push_back(iBxInEvent, m_uGtAlgBlk);
1045 m_uGtAlgBlk.reset();
1047 m_gtlDecisionWord.reset();
1048 m_gtlAlgorithmOR.reset();
1053 m_candL1Mu->clear();
1054 m_candL1Mu->setBXRange(m_bxFirst_, m_bxLast_);
1059 m_candL1EG->clear();
1060 m_candL1Tau->clear();
1061 m_candL1Jet->clear();
1062 m_candL1EtSum->clear();
1064 m_candL1EG->setBXRange(m_bxFirst_, m_bxLast_);
1065 m_candL1Tau->setBXRange(m_bxFirst_, m_bxLast_);
1066 m_candL1Jet->setBXRange(m_bxFirst_, m_bxLast_);
1067 m_candL1EtSum->setBXRange(m_bxFirst_, m_bxLast_);
1071 m_candL1External->clear();
1072 m_candL1External->setBXRange(m_bxFirst_, m_bxLast_);
1077 LogTrace(
"L1TGlobal") <<
"\nl1t::L1GlobalTrigger: uGMT data received for BxInEvent = " << iBxInEvent << std::endl;
1079 int nrL1Mu = m_candL1Mu->size(iBxInEvent);
1080 LogTrace(
"L1TGlobal") <<
"Number of GMT muons = " << nrL1Mu <<
"\n" << std::endl;
1082 LogTrace(
"L1TGlobal") << std::endl;