22 #include <ext/hash_map>
66 m_firstEvLumiSegment(
true),
99 delete m_candL1External;
118 void l1t::GlobalBoard::init(
const int numberPhysTriggers,
const int nrL1Mu,
const int nrL1EG,
const int nrL1Tau,
const int nrL1Jet,
119 int bxFirst,
int bxLast) {
124 m_candL1Mu->setBXRange( m_bxFirst_, m_bxLast_ );
125 m_candL1EG->setBXRange( m_bxFirst_, m_bxLast_ );
126 m_candL1Tau->setBXRange( m_bxFirst_, m_bxLast_ );
127 m_candL1Jet->setBXRange( m_bxFirst_, m_bxLast_ );
128 m_candL1EtSum->setBXRange( m_bxFirst_, m_bxLast_ );
129 m_candL1External->setBXRange( m_bxFirst_, m_bxLast_ );
133 LogDebug(
"L1TGlobal") <<
"\t Initializing Board with bxFirst = " << m_bxFirst_ <<
", bxLast = " << m_bxLast_ << std::endl;
146 const bool receiveEG,
const int nrL1EG,
147 const bool receiveTau,
const int nrL1Tau,
148 const bool receiveJet,
const int nrL1Jet,
149 const bool receiveEtSums) {
153 <<
"\n**** Board receiving Calo Data "
169 <<
"\nWarning: BXVector<l1t::EGamma> with input tag "
171 <<
"\nrequested in configuration, but not found in the event.\n"
176 for(
int i = egData->getFirstBX();
i <= egData->getLastBX(); ++
i) {
179 if( i < m_bxFirst_ || i > m_bxLast_ )
continue;
183 for(std::vector<l1t::EGamma>::const_iterator eg = egData->begin(
i); eg != egData->end(
i); ++eg) {
186 (*m_candL1EG).push_back(
i,&(*eg));
188 edm::LogWarning(
"L1TGlobal") <<
" Too many EG ("<<nObj<<
") for uGT Configuration maxEG =" <<nrL1EG << std::endl;
190 LogDebug(
"L1TGlobal") <<
"EG Pt " << eg->hwPt() <<
" Eta " << eg->hwEta() <<
" Phi " << eg->hwPhi() <<
" Qual " << eg->hwQual() <<
" Iso " << eg->hwIso() << std::endl;
208 <<
"\nWarning: BXVector<l1t::Tau> with input tag "
210 <<
"\nrequested in configuration, but not found in the event.\n"
215 for(
int i = tauData->getFirstBX();
i <= tauData->getLastBX(); ++
i) {
218 if( i < m_bxFirst_ || i > m_bxLast_ )
continue;
222 for(std::vector<l1t::Tau>::const_iterator
tau = tauData->begin(
i);
tau != tauData->end(
i); ++
tau) {
225 (*m_candL1Tau).push_back(
i,&(*
tau));
227 LogTrace(
"L1TGlobal") <<
" Too many Tau ("<<nObj<<
") for uGT Configuration maxTau =" <<nrL1Tau << std::endl;
230 LogDebug(
"L1TGlobal") <<
"tau Pt " <<
tau->hwPt() <<
" Eta " <<
tau->hwEta() <<
" Phi " <<
tau->hwPhi() <<
" Qual " <<
tau->hwQual() <<
" Iso " <<
tau->hwIso() << std::endl;
248 <<
"\nWarning: BXVector<l1t::Jet> with input tag "
250 <<
"\nrequested in configuration, but not found in the event.\n"
255 for(
int i = jetData->getFirstBX();
i <= jetData->getLastBX(); ++
i) {
258 if( i < m_bxFirst_ || i > m_bxLast_ )
continue;
262 for(std::vector<l1t::Jet>::const_iterator
jet = jetData->begin(
i);
jet != jetData->end(
i); ++
jet) {
265 (*m_candL1Jet).push_back(
i,&(*
jet));
267 edm::LogWarning(
"L1TGlobal") <<
" Too many Jets ("<<nObj<<
") for uGT Configuration maxJet =" <<nrL1Jet << std::endl;
270 LogDebug(
"L1TGlobal") <<
"Jet Pt " <<
jet->hwPt() <<
" Eta " <<
jet->hwEta() <<
" Phi " <<
jet->hwPhi() <<
" Qual " <<
jet->hwQual() <<
" Iso " <<
jet->hwIso() << std::endl;
287 <<
"\nWarning: BXVector<l1t::EtSum> with input tag "
289 <<
"\nrequested in configuration, but not found in the event.\n"
294 for(
int i = etSumData->getFirstBX();
i <= etSumData->getLastBX(); ++
i) {
297 if( i < m_bxFirst_ || i > m_bxLast_ )
continue;
300 for(std::vector<l1t::EtSum>::const_iterator etsum = etSumData->begin(
i); etsum != etSumData->end(
i); ++etsum) {
302 (*m_candL1EtSum).push_back(
i,&(*etsum));
360 <<
"\n**** GlobalBoard receiving muon data = "
375 <<
"\nWarning: BXVector<l1t::Muon> with input tag "
377 <<
"\nrequested in configuration, but not found in the event.\n"
382 for(
int i = muonData->getFirstBX();
i <= muonData->getLastBX(); ++
i) {
385 if( i < m_bxFirst_ || i > m_bxLast_ )
continue;
389 for(std::vector<l1t::Muon>::const_iterator
mu = muonData->begin(
i);
mu != muonData->end(
i); ++
mu) {
392 (*m_candL1Mu).push_back(
i,&(*
mu));
394 edm::LogWarning(
"L1TGlobal") <<
" Too many Muons ("<<nObj<<
") for uGT Configuration maxMu =" <<nrL1Mu << std::endl;
397 LogDebug(
"L1TGlobal") <<
"Muon Pt " <<
mu->hwPt() <<
" Eta " <<
mu->hwEta() <<
" Phi " <<
mu->hwPhi() <<
" Qual " <<
mu->hwQual() <<
" Iso " <<
mu->hwIso() << std::endl;
416 <<
"\n**** GlobalBoard receiving external data = "
431 <<
"\nWarning: BXVector<GlobalExtBlk> with input tag "
433 <<
"\nrequested in configuration, but not found in the event.\n"
438 for(
int i = extData->getFirstBX();
i <= extData->getLastBX(); ++
i) {
441 if( i < m_bxFirst_ || i > m_bxLast_ )
continue;
444 for(std::vector<GlobalExtBlk>::const_iterator ext = extData->begin(
i); ext != extData->end(
i); ++ext) {
446 (*m_candL1External).push_back(
i,&(*ext));
460 const bool produceL1GtObjectMapRecord,
461 const int iBxInEvent,
462 std::auto_ptr<GlobalObjectMapRecord>& gtObjectMapRecord,
463 const unsigned int numberPhysTriggers,
467 const int nrL1Jet ) {
469 const std::vector<ConditionMap>& conditionMap = m_l1GtMenu->
gtConditionMap();
473 LogDebug(
"L1TGlobal") <<
" L1 Menu Scales -- Set Name: " << scaleSetName << std::endl;
477 m_algInitialOr=
false;
478 m_algPrescaledOr=
false;
481 m_algFinalOrVeto=
false;
484 const std::vector<std::vector<MuonTemplate> >& corrMuon =
488 const std::vector<std::vector<CaloTemplate> >& corrCalo =
491 const std::vector<std::vector<EnergySumTemplate> >& corrEnergySum =
494 LogDebug(
"L1TGlobal") <<
"Size corrMuon " << corrMuon.size()
495 <<
"\nSize corrCalo " << corrCalo.size()
496 <<
"\nSize corrSums " << corrEnergySum.size() << std::endl;
504 if (m_conditionResultMaps.size() != conditionMap.size()) {
505 m_conditionResultMaps.clear();
506 m_conditionResultMaps.resize(conditionMap.size());
511 for (std::vector<ConditionMap>::const_iterator
512 itCondOnChip = conditionMap.begin(); itCondOnChip != conditionMap.end(); itCondOnChip++) {
517 m_conditionResultMaps[iChip];
521 for (
CItCond itCond = itCondOnChip->begin(); itCond != itCondOnChip->end(); itCond++) {
524 switch ((itCond->second)->condCategory()) {
528 const int ifMuEtaNumberBits = 0;
531 nrL1Mu, ifMuEtaNumberBits);
538 cMapResults[itCond->first] = muCondition;
540 if (m_verbosity && m_isDebugEnabled) {
541 std::ostringstream myCout;
542 muCondition->
print(myCout);
544 LogTrace(
"L1TGlobal") << myCout.str() << std::endl;
553 const int ifCaloEtaNumberBits = 0;
556 itCond->second,
this,
560 ifCaloEtaNumberBits);
567 cMapResults[itCond->first] = caloCondition;
569 if (m_verbosity && m_isDebugEnabled) {
570 std::ostringstream myCout;
571 caloCondition->
print(myCout);
573 LogTrace(
"L1TGlobal") << myCout.str() << std::endl;
582 itCond->second,
this);
587 cMapResults[itCond->first] = eSumCondition;
589 if (m_verbosity && m_isDebugEnabled) {
590 std::ostringstream myCout;
591 eSumCondition->
print(myCout);
593 LogTrace(
"L1TGlobal") << myCout.str() << std::endl;
603 itCond->second,
this);
608 cMapResults[itCond->first] = extCondition;
610 if (m_verbosity && m_isDebugEnabled) {
611 std::ostringstream myCout;
612 extCondition->
print(myCout);
614 LogTrace(
"L1TGlobal") << myCout.str() << std::endl;
631 const int cond0Ind = corrTemplate->
cond0Index();
632 const int cond1Ind = corrTemplate->
cond1Index();
638 int cond0NrL1Objects = 0;
639 int cond1NrL1Objects = 0;
640 LogDebug(
"L1TGlobal") <<
" cond0NrL1Objects" << cond0NrL1Objects <<
" cond1NrL1Objects " << cond1NrL1Objects << std::endl;
643 switch (cond0Categ) {
645 cond0Condition = &((corrMuon[iChip])[cond0Ind]);
649 cond0Condition = &((corrCalo[iChip])[cond0Ind]);
653 cond0Condition = &((corrEnergySum[iChip])[cond0Ind]);
662 switch (cond1Categ) {
664 cond1Condition = &((corrMuon[iChip])[cond1Ind]);
668 cond1Condition = &((corrCalo[iChip])[cond1Ind]);
672 cond1Condition = &((corrEnergySum[iChip])[cond1Ind]);
682 new CorrCondition(itCond->second, cond0Condition, cond1Condition,
this);
688 cMapResults[itCond->first] = correlationCond;
690 if (m_verbosity && m_isDebugEnabled) {
691 std::ostringstream myCout;
692 correlationCond->
print(myCout);
694 LogTrace(
"L1TGlobal") << myCout.str() << std::endl;
722 std::vector<GlobalObjectMap> objMapVec;
723 if (produceL1GtObjectMapRecord && (iBxInEvent == 0)) objMapVec.reserve(numberPhysTriggers);
725 for (
CItAlgo itAlgo = algorithmMap.begin(); itAlgo != algorithmMap.end(); itAlgo++) {
727 gtAlg.
evaluateAlgorithm((itAlgo->second).algoChipNumber(), m_conditionResultMaps);
729 int algBitNumber = (itAlgo->second).algoBitNumber();
732 LogDebug(
"L1TGlobal") <<
" ===> for iBxInEvent = " << iBxInEvent <<
":\t algBitName = " << itAlgo->first <<
",\t algBitNumber = " << algBitNumber <<
",\t algResult = " << algResult << std::endl;
736 m_uGtAlgBlk.setAlgoDecisionInitial(algBitNumber,algResult);
737 m_algInitialOr =
true;
740 if (m_verbosity && m_isDebugEnabled) {
741 std::ostringstream myCout;
742 ( itAlgo->second ).
print(myCout);
745 LogTrace(
"L1TGlobal") << myCout.str() << std::endl;
750 if (produceL1GtObjectMapRecord && (iBxInEvent == 0)) {
752 std::vector<ObjectTypeInCond> otypes;
758 for (
auto imap = conditionMap.begin(); imap != conditionMap.end(); imap++) {
760 auto match = imap->find(iop->tokenName);
762 if (
match != imap->end()){
766 otype =
match->second->objectType();
768 for (
auto itype = otype.begin(); itype != otype.end() ; itype++){
774 edm::LogWarning(
"L1TGlobal") <<
"\n Failed to find match for operand token " << iop->tokenName <<
"\n";
776 otypes.push_back(otype);
791 if (m_verbosity && m_isDebugEnabled) {
792 std::ostringstream myCout1;
793 objMap.
print(myCout1);
795 LogTrace(
"L1TGlobal") << myCout1.str() << std::endl;
798 objMapVec.push_back(objMap);
806 if (produceL1GtObjectMapRecord && (iBxInEvent == 0)) {
807 gtObjectMapRecord->swapGtObjectMap(objMapVec);
813 for (std::vector<AlgorithmEvaluation::ConditionEvaluationMap>::iterator
814 itCondOnChip = m_conditionResultMaps.begin();
815 itCondOnChip != m_conditionResultMaps.end(); itCondOnChip++) {
818 itCond = itCondOnChip->begin();
819 itCond != itCondOnChip->end(); itCond++) {
821 delete itCond->second;
831 const int iBxInEvent,
832 const int totalBxInEvent,
833 const unsigned int numberPhysTriggers,
834 const std::vector<int>& prescaleFactorsAlgoTrig,
835 const std::vector<unsigned int>& triggerMaskAlgoTrig,
836 const std::vector<int>& triggerMaskVetoAlgoTrig,
837 const bool algorithmTriggersUnprescaled,
838 const bool algorithmTriggersUnmasked ){
843 <<
"\n**** GlobalBoard apply Final Decision Logic "
852 m_prescaleCounterAlgoTrig.reserve(numberPhysTriggers*totalBxInEvent);
854 for(
int iBxInEvent = 0; iBxInEvent <= totalBxInEvent; ++iBxInEvent ){
855 m_prescaleCounterAlgoTrig.push_back(prescaleFactorsAlgoTrig);
861 if( m_firstEvLumiSegment ){
863 m_prescaleCounterAlgoTrig.clear();
864 for(
int iBxInEvent = 0; iBxInEvent <= totalBxInEvent; ++iBxInEvent ){
865 m_prescaleCounterAlgoTrig.push_back(prescaleFactorsAlgoTrig);
868 m_firstEvLumiSegment =
false;
873 m_uGtAlgBlk.copyInitialToInterm();
879 if( !algorithmTriggersUnprescaled ){
882 int inBxInEvent = totalBxInEvent/2 + iBxInEvent;
884 bool temp_algPrescaledOr =
false;
885 for(
unsigned int iBit = 0; iBit < numberPhysTriggers; ++iBit ){
887 bool bitValue = m_uGtAlgBlk.getAlgoDecisionInitial( iBit );
890 if( iBit < prescaleFactorsAlgoTrig.size() ){
891 if( prescaleFactorsAlgoTrig.at(iBit) != 1 ){
893 (m_prescaleCounterAlgoTrig.at(inBxInEvent).at(iBit))--;
894 if( m_prescaleCounterAlgoTrig.at(inBxInEvent).at(iBit) == 0 ){
897 m_prescaleCounterAlgoTrig.at(inBxInEvent).at(iBit) = prescaleFactorsAlgoTrig.at(iBit);
898 temp_algPrescaledOr =
true;
903 m_uGtAlgBlk.setAlgoDecisionInterm(iBit,
false);
909 temp_algPrescaledOr =
true;
914 <<
"\nWarning: algoBit >= prescaleFactorsAlgoTrig.size() "
920 m_algPrescaledOr = temp_algPrescaledOr;
925 m_algPrescaledOr = m_algInitialOr;
932 m_uGtAlgBlk.copyIntermToFinal();
934 if( !algorithmTriggersUnmasked ){
936 bool temp_algFinalOr =
false;
937 for(
unsigned int iBit = 0; iBit < numberPhysTriggers; ++iBit ){
939 bool bitValue = m_uGtAlgBlk.getAlgoDecisionInterm( iBit );
943 bool isMasked =
false;
944 if( iBit < triggerMaskAlgoTrig.size() ) isMasked = ( triggerMaskAlgoTrig.at(iBit) == 0 );
947 <<
"\nWarning: algoBit >= triggerMaskAlgoTrig.size() "
951 bool passMask = ( bitValue && !isMasked );
953 if( passMask ) temp_algFinalOr =
true;
954 else m_uGtAlgBlk.setAlgoDecisionFinal(iBit,
false);
957 if ( triggerMaskVetoAlgoTrig.at(iBit) == 1 ) m_algFinalOrVeto =
true;
962 m_algIntermOr = temp_algFinalOr;
967 m_algIntermOr = m_algPrescaledOr;
972 m_algFinalOr = (m_algIntermOr & !m_algFinalOrVeto);
980 std::auto_ptr<GlobalAlgBlkBxCollection>& uGtAlgRecord,
989 <<
"\n**** GlobalBoard fill DAQ Records for bx= " << iBxInEvent
995 m_uGtAlgBlk.setbxInEventNr((iBxInEvent & 0xF));
996 m_uGtAlgBlk.setPreScColumn(prescaleSet);
997 m_uGtAlgBlk.setL1MenuUUID(menuUUID);
998 m_uGtAlgBlk.setL1FirmwareUUID(firmwareUUID);
1000 m_uGtAlgBlk.setFinalORVeto(m_algFinalOrVeto);
1001 m_uGtAlgBlk.setFinalORPreVeto(m_algIntermOr);
1002 m_uGtAlgBlk.setFinalOR(m_algFinalOr);
1005 uGtAlgRecord->push_back(iBxInEvent, m_uGtAlgBlk);
1017 m_uGtAlgBlk.reset();
1019 m_gtlDecisionWord.reset();
1020 m_gtlAlgorithmOR.reset();
1029 m_candL1Mu->clear();
1030 m_candL1Mu->setBXRange( m_bxFirst_, m_bxLast_ );
1037 m_candL1EG->clear();
1038 m_candL1Tau->clear();
1039 m_candL1Jet->clear();
1040 m_candL1EtSum->clear();
1042 m_candL1EG->setBXRange( m_bxFirst_, m_bxLast_ );
1043 m_candL1Tau->setBXRange( m_bxFirst_, m_bxLast_ );
1044 m_candL1Jet->setBXRange( m_bxFirst_, m_bxLast_ );
1045 m_candL1EtSum->setBXRange( m_bxFirst_, m_bxLast_ );
1051 m_candL1External->clear();
1052 m_candL1External->setBXRange( m_bxFirst_, m_bxLast_ );
1061 <<
"\nl1t::L1GlobalTrigger: uGMT data received for BxInEvent = "
1062 << iBxInEvent << std::endl;
1064 int nrL1Mu = m_candL1Mu->size(iBxInEvent);
1066 <<
"Number of GMT muons = " << nrL1Mu <<
"\n"
1069 LogTrace(
"L1TGlobal") << std::endl;
void receiveMuonObjectData(edm::Event &, const edm::EDGetTokenT< BXVector< l1t::Muon > > &, const bool receiveMu, const int nrL1Mu)
void print(std::ostream &myCout) const
print condition
void setAlgoBitNumber(int algoBitNumberValue)
void init(const int numberPhysTriggers, const int nrL1Mu, const int nrL1EG, const int nrL1Tau, const int nrL1Jet, int bxFirst, int bxLast)
initialize the class (mainly reserve)
bool gtAlgoResult() const
get / set the result of the algorithm
void evaluateConditionStoreResult(const int bxEval)
call evaluateCondition and save last result
void swapOperandTokenVector(std::vector< GlobalLogicParser::OperandToken > &operandTokenVectorValue)
void print(std::ostream &myCout) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void fillAlgRecord(int iBxInEvent, std::auto_ptr< GlobalAlgBlkBxCollection > &uGtAlgRecord, int prescaleSet, int menuUUID, int firmwareUUID)
Fill the Daq Records.
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
void print(std::ostream &myCout) const
print condition
void setVerbosity(const int verbosity)
void print(std::ostream &myCout) const
print condition
const l1t::GtConditionCategory cond0Category() const
get / set the category of the two sub-conditions
__gnu_cxx::hash_map< std::string, ConditionEvaluation * > ConditionEvaluationMap
copy constructor
void print(std::ostream &myCout) const
print condition
unsigned long long m_l1MuTriggerScalesCacheID
void swapCombinationVector(std::vector< CombinationsInCond > &combinationVectorValue)
ConditionEvaluationMap::iterator ItEvalMap
unsigned long long m_l1GtMenuCacheID
void receiveCaloObjectData(edm::Event &, const edm::EDGetTokenT< BXVector< l1t::EGamma >> &, const edm::EDGetTokenT< BXVector< l1t::Tau >> &, const edm::EDGetTokenT< BXVector< l1t::Jet >> &, const edm::EDGetTokenT< BXVector< l1t::EtSum >> &, const bool receiveEG, const int nrL1EG, const bool receiveTau, const int nrL1Tau, const bool receiveJet, const int nrL1Jet, const bool receiveEtSums)
receive data from Global Muon Trigger
std::bitset< GlobalAlgBlk::maxPhysicsTriggers > m_gtlDecisionWord
ConditionMap::const_iterator CItCond
iterators through map containing the conditions
GtConditionCategory
condition categories
void printGmtData(const int iBxInEvent) const
print received Muon dataWord
void print(std::ostream &myCout) const
print the full object map
unsigned int m_boardEventCount
const l1t::GtConditionCategory cond1Category() const
AlgorithmMap::const_iterator CItAlgo
iterators through map containing the algorithms
void reset()
reset the content of a GlobalAlgBlk
void receiveExternalData(edm::Event &, const edm::EDGetTokenT< BXVector< GlobalExtBlk > > &, const bool receiveExt)
const int cond0Index() const
get / set the index of the two sub-conditions in the cor* vector from menu
unsigned long long m_l1CaloGeometryCacheID
void setAlgoGtlResult(bool algoGtlResultValue)
std::vector< CombinationsInCond > & gtAlgoCombinationVector()
void print(std::ostream &myCout) const
print condition
const int cond1Index() const
void setScales(const GlobalScales *)
std::vector< L1GtObject > ObjectTypeInCond
void evaluateAlgorithm(const int chipNumber, const std::vector< ConditionEvaluationMap > &)
evaluate an algorithm
void swapObjectTypeVector(std::vector< ObjectTypeInCond > &objectTypeVectorValue)
void setAlgoName(const std::string &algoNameValue)
void runFDL(edm::Event &iEvent, const int iBxInEvent, const int totalBxInEvent, const unsigned int numberPhysTriggers, const std::vector< int > &prescaleFactorsAlgoTrig, const std::vector< unsigned int > &triggerMaskAlgoTrig, const std::vector< int > &triggerMaskVetoAlgoTrig, const bool algorithmTriggersUnprescaled, const bool algorithmTriggersUnmasked)
run the uGT FDL (Apply Prescales and Veto)
std::vector< GlobalLogicParser::OperandToken > & operandTokenVector()
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
std::bitset< GlobalAlgBlk::maxPhysicsTriggers > m_gtlAlgorithmOR
std::map< std::string, GlobalAlgorithm > AlgorithmMap
map containing the algorithms
virtual std::string getScalesName() const
void runGTL(edm::Event &iEvent, const edm::EventSetup &evSetup, const TriggerMenu *m_l1GtMenu, const bool produceL1GtObjectMapRecord, const int iBxInEvent, std::auto_ptr< GlobalObjectMapRecord > >ObjectMapRecord, const unsigned int numberPhysTriggers, const int nrL1Mu, const int nrL1EG, const int nrL1Tau, const int nrL1Jet)
run the uGT GTL (Conditions and Algorithms)