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;
182 for(std::vector<l1t::EGamma>::const_iterator eg = egData->begin(
i); eg != egData->end(
i); ++eg) {
184 (*m_candL1EG).push_back(
i,&(*eg));
185 LogDebug(
"L1TGlobal") <<
"EG Pt " << eg->hwPt() <<
" Eta " << eg->hwEta() <<
" Phi " << eg->hwPhi() <<
" Qual " << eg->hwQual() <<
" Iso " << eg->hwIso() << std::endl;
201 <<
"\nWarning: BXVector<l1t::Tau> with input tag "
203 <<
"\nrequested in configuration, but not found in the event.\n"
208 for(
int i = tauData->getFirstBX();
i <= tauData->getLastBX(); ++
i) {
211 if( i < m_bxFirst_ || i > m_bxLast_ )
continue;
214 for(std::vector<l1t::Tau>::const_iterator
tau = tauData->begin(
i);
tau != tauData->end(
i); ++
tau) {
216 (*m_candL1Tau).push_back(
i,&(*
tau));
217 LogDebug(
"L1TGlobal") <<
"tau Pt " <<
tau->hwPt() <<
" Eta " <<
tau->hwEta() <<
" Phi " <<
tau->hwPhi() <<
" Qual " <<
tau->hwQual() <<
" Iso " <<
tau->hwIso() << std::endl;
233 <<
"\nWarning: BXVector<l1t::Jet> with input tag "
235 <<
"\nrequested in configuration, but not found in the event.\n"
240 for(
int i = jetData->getFirstBX();
i <= jetData->getLastBX(); ++
i) {
243 if( i < m_bxFirst_ || i > m_bxLast_ )
continue;
246 for(std::vector<l1t::Jet>::const_iterator
jet = jetData->begin(
i);
jet != jetData->end(
i); ++
jet) {
248 (*m_candL1Jet).push_back(
i,&(*
jet));
249 LogDebug(
"L1TGlobal") <<
"Jet Pt " <<
jet->hwPt() <<
" Eta " <<
jet->hwEta() <<
" Phi " <<
jet->hwPhi() <<
" Qual " <<
jet->hwQual() <<
" Iso " <<
jet->hwIso() << std::endl;
265 <<
"\nWarning: BXVector<l1t::EtSum> with input tag "
267 <<
"\nrequested in configuration, but not found in the event.\n"
272 for(
int i = etSumData->getFirstBX();
i <= etSumData->getLastBX(); ++
i) {
275 if( i < m_bxFirst_ || i > m_bxLast_ )
continue;
278 for(std::vector<l1t::EtSum>::const_iterator etsum = etSumData->begin(
i); etsum != etSumData->end(
i); ++etsum) {
280 (*m_candL1EtSum).push_back(
i,&(*etsum));
321 <<
"\n**** GlobalBoard receiving muon data = "
336 <<
"\nWarning: BXVector<l1t::Muon> with input tag "
338 <<
"\nrequested in configuration, but not found in the event.\n"
343 for(
int i = muonData->getFirstBX();
i <= muonData->getLastBX(); ++
i) {
346 if( i < m_bxFirst_ || i > m_bxLast_ )
continue;
349 for(std::vector<l1t::Muon>::const_iterator
mu = muonData->begin(
i);
mu != muonData->end(
i); ++
mu) {
351 (*m_candL1Mu).push_back(
i,&(*
mu));
352 LogDebug(
"L1TGlobal") <<
"Muon Pt " <<
mu->hwPt() <<
" Eta " <<
mu->hwEta() <<
" Phi " <<
mu->hwPhi() <<
" Qual " <<
mu->hwQual() <<
" Iso " <<
mu->hwIso() << std::endl;
370 <<
"\n**** GlobalBoard receiving external data = "
385 <<
"\nWarning: BXVector<GlobalExtBlk> with input tag "
387 <<
"\nrequested in configuration, but not found in the event.\n"
392 for(
int i = extData->getFirstBX();
i <= extData->getLastBX(); ++
i) {
395 if( i < m_bxFirst_ || i > m_bxLast_ )
continue;
398 for(std::vector<GlobalExtBlk>::const_iterator ext = extData->begin(
i); ext != extData->end(
i); ++ext) {
400 (*m_candL1External).push_back(
i,&(*ext));
414 const bool produceL1GtObjectMapRecord,
415 const int iBxInEvent,
416 std::auto_ptr<GlobalObjectMapRecord>& gtObjectMapRecord,
417 const unsigned int numberPhysTriggers,
421 const int nrL1Jet ) {
423 const std::vector<ConditionMap>& conditionMap = m_l1GtMenu->
gtConditionMap();
427 LogDebug(
"L1TGlobal") <<
" L1 Menu Scales -- Set Name: " << scaleSetName << std::endl;
431 m_algInitialOr=
false;
432 m_algPrescaledOr=
false;
435 m_algFinalOrVeto=
false;
438 const std::vector<std::vector<MuonTemplate> >& corrMuon =
442 const std::vector<std::vector<CaloTemplate> >& corrCalo =
445 const std::vector<std::vector<EnergySumTemplate> >& corrEnergySum =
448 LogDebug(
"L1TGlobal") <<
"Size corrMuon " << corrMuon.size()
449 <<
"\nSize corrCalo " << corrCalo.size()
450 <<
"\nSize corrSums " << corrEnergySum.size() << std::endl;
458 if (m_conditionResultMaps.size() != conditionMap.size()) {
459 m_conditionResultMaps.clear();
460 m_conditionResultMaps.resize(conditionMap.size());
465 for (std::vector<ConditionMap>::const_iterator
466 itCondOnChip = conditionMap.begin(); itCondOnChip != conditionMap.end(); itCondOnChip++) {
471 m_conditionResultMaps[iChip];
475 for (
CItCond itCond = itCondOnChip->begin(); itCond != itCondOnChip->end(); itCond++) {
478 switch ((itCond->second)->condCategory()) {
482 const int ifMuEtaNumberBits = 0;
485 nrL1Mu, ifMuEtaNumberBits);
492 cMapResults[itCond->first] = muCondition;
494 if (m_verbosity && m_isDebugEnabled) {
495 std::ostringstream myCout;
496 muCondition->
print(myCout);
498 LogTrace(
"L1TGlobal") << myCout.str() << std::endl;
507 const int ifCaloEtaNumberBits = 0;
510 itCond->second,
this,
514 ifCaloEtaNumberBits);
521 cMapResults[itCond->first] = caloCondition;
523 if (m_verbosity && m_isDebugEnabled) {
524 std::ostringstream myCout;
525 caloCondition->
print(myCout);
527 LogTrace(
"L1TGlobal") << myCout.str() << std::endl;
536 itCond->second,
this);
541 cMapResults[itCond->first] = eSumCondition;
543 if (m_verbosity && m_isDebugEnabled) {
544 std::ostringstream myCout;
545 eSumCondition->
print(myCout);
547 LogTrace(
"L1TGlobal") << myCout.str() << std::endl;
557 itCond->second,
this);
562 cMapResults[itCond->first] = extCondition;
564 if (m_verbosity && m_isDebugEnabled) {
565 std::ostringstream myCout;
566 extCondition->
print(myCout);
568 LogTrace(
"L1TGlobal") << myCout.str() << std::endl;
585 const int cond0Ind = corrTemplate->
cond0Index();
586 const int cond1Ind = corrTemplate->
cond1Index();
592 int cond0NrL1Objects = 0;
593 int cond1NrL1Objects = 0;
594 LogDebug(
"L1TGlobal") <<
" cond0NrL1Objects" << cond0NrL1Objects <<
" cond1NrL1Objects " << cond1NrL1Objects << std::endl;
597 switch (cond0Categ) {
599 cond0Condition = &((corrMuon[iChip])[cond0Ind]);
603 cond0Condition = &((corrCalo[iChip])[cond0Ind]);
607 cond0Condition = &((corrEnergySum[iChip])[cond0Ind]);
616 switch (cond1Categ) {
618 cond1Condition = &((corrMuon[iChip])[cond1Ind]);
622 cond1Condition = &((corrCalo[iChip])[cond1Ind]);
626 cond1Condition = &((corrEnergySum[iChip])[cond1Ind]);
636 new CorrCondition(itCond->second, cond0Condition, cond1Condition,
this);
642 cMapResults[itCond->first] = correlationCond;
644 if (m_verbosity && m_isDebugEnabled) {
645 std::ostringstream myCout;
646 correlationCond->
print(myCout);
648 LogTrace(
"L1TGlobal") << myCout.str() << std::endl;
676 std::vector<GlobalObjectMap> objMapVec;
677 if (produceL1GtObjectMapRecord && (iBxInEvent == 0)) objMapVec.reserve(numberPhysTriggers);
679 for (
CItAlgo itAlgo = algorithmMap.begin(); itAlgo != algorithmMap.end(); itAlgo++) {
681 gtAlg.
evaluateAlgorithm((itAlgo->second).algoChipNumber(), m_conditionResultMaps);
683 int algBitNumber = (itAlgo->second).algoBitNumber();
686 LogDebug(
"L1TGlobal") <<
" ===> for iBxInEvent = " << iBxInEvent <<
":\t algBitName = " << itAlgo->first <<
",\t algBitNumber = " << algBitNumber <<
",\t algResult = " << algResult << std::endl;
690 m_uGtAlgBlk.setAlgoDecisionInitial(algBitNumber,algResult);
691 m_algInitialOr =
true;
694 if (m_verbosity && m_isDebugEnabled) {
695 std::ostringstream myCout;
696 ( itAlgo->second ).
print(myCout);
699 LogTrace(
"L1TGlobal") << myCout.str() << std::endl;
704 if (produceL1GtObjectMapRecord && (iBxInEvent == 0)) {
706 std::vector<ObjectTypeInCond> otypes;
712 for (
auto imap = conditionMap.begin(); imap != conditionMap.end(); imap++) {
714 auto match = imap->find(iop->tokenName);
716 if (
match != imap->end()){
720 otype =
match->second->objectType();
722 for (
auto itype = otype.begin(); itype != otype.end() ; itype++){
728 edm::LogWarning(
"L1TGlobal") <<
"\n Failed to find match for operand token " << iop->tokenName <<
"\n";
730 otypes.push_back(otype);
745 if (m_verbosity && m_isDebugEnabled) {
746 std::ostringstream myCout1;
747 objMap.
print(myCout1);
749 LogTrace(
"L1TGlobal") << myCout1.str() << std::endl;
752 objMapVec.push_back(objMap);
760 if (produceL1GtObjectMapRecord && (iBxInEvent == 0)) {
761 gtObjectMapRecord->swapGtObjectMap(objMapVec);
767 for (std::vector<AlgorithmEvaluation::ConditionEvaluationMap>::iterator
768 itCondOnChip = m_conditionResultMaps.begin();
769 itCondOnChip != m_conditionResultMaps.end(); itCondOnChip++) {
772 itCond = itCondOnChip->begin();
773 itCond != itCondOnChip->end(); itCond++) {
775 delete itCond->second;
785 const int iBxInEvent,
786 const int totalBxInEvent,
787 const unsigned int numberPhysTriggers,
788 const std::vector<int>& prescaleFactorsAlgoTrig,
789 const std::vector<unsigned int>& triggerMaskAlgoTrig,
790 const std::vector<unsigned int>& triggerMaskVetoAlgoTrig,
791 const bool algorithmTriggersUnprescaled,
792 const bool algorithmTriggersUnmasked ){
797 <<
"\n**** GlobalBoard apply Final Decision Logic "
806 m_prescaleCounterAlgoTrig.reserve(numberPhysTriggers*totalBxInEvent);
808 for(
int iBxInEvent = 0; iBxInEvent <= totalBxInEvent; ++iBxInEvent ){
809 m_prescaleCounterAlgoTrig.push_back(prescaleFactorsAlgoTrig);
815 if( m_firstEvLumiSegment ){
817 m_prescaleCounterAlgoTrig.clear();
818 for(
int iBxInEvent = 0; iBxInEvent <= totalBxInEvent; ++iBxInEvent ){
819 m_prescaleCounterAlgoTrig.push_back(prescaleFactorsAlgoTrig);
822 m_firstEvLumiSegment =
false;
827 m_uGtAlgBlk.copyInitialToInterm();
833 if( !algorithmTriggersUnmasked ){
853 m_algIntermOr = m_algInitialOr;
858 m_algIntermOr = m_algInitialOr;
865 m_uGtAlgBlk.copyIntermToFinal();
870 if( !algorithmTriggersUnprescaled ){
873 int inBxInEvent = totalBxInEvent/2 + iBxInEvent;
875 bool temp_algPrescaledOr =
false;
876 for(
unsigned int iBit = 0; iBit < numberPhysTriggers; ++iBit ){
878 bool bitValue = m_uGtAlgBlk.getAlgoDecisionInitial( iBit );
880 if( prescaleFactorsAlgoTrig.at(iBit) != 1 ){
882 (m_prescaleCounterAlgoTrig.at(inBxInEvent).at(iBit))--;
883 if( m_prescaleCounterAlgoTrig.at(inBxInEvent).at(iBit) == 0 ){
886 m_prescaleCounterAlgoTrig.at(inBxInEvent).at(iBit) = prescaleFactorsAlgoTrig.at(iBit);
887 temp_algPrescaledOr =
true;
890 if ( triggerMaskVetoAlgoTrig.at(iBit) == 1 ) m_algFinalOrVeto =
true;
895 m_uGtAlgBlk.setAlgoDecisionFinal(iBit,
false);
901 temp_algPrescaledOr =
true;
904 if ( triggerMaskVetoAlgoTrig.at(iBit) == 1 ) m_algFinalOrVeto =
true;
910 m_algPrescaledOr = temp_algPrescaledOr;
915 m_algPrescaledOr = m_algIntermOr;
922 m_algFinalOr = (m_algPrescaledOr & !m_algFinalOrVeto);
929 std::auto_ptr<GlobalAlgBlkBxCollection>& uGtAlgRecord,
938 <<
"\n**** GlobalBoard fill DAQ Records for bx= " << iBxInEvent
944 m_uGtAlgBlk.setbxInEventNr((iBxInEvent & 0xF));
945 m_uGtAlgBlk.setPreScColumn(prescaleSet);
946 m_uGtAlgBlk.setL1MenuUUID(menuUUID);
947 m_uGtAlgBlk.setL1FirmwareUUID(firmwareUUID);
949 m_uGtAlgBlk.setFinalORVeto(m_algFinalOrVeto);
950 m_uGtAlgBlk.setFinalORPreVeto(m_algPrescaledOr);
951 m_uGtAlgBlk.setFinalOR(m_algFinalOr);
954 uGtAlgRecord->push_back(iBxInEvent, m_uGtAlgBlk);
968 m_gtlDecisionWord.reset();
969 m_gtlAlgorithmOR.reset();
979 m_candL1Mu->setBXRange( m_bxFirst_, m_bxLast_ );
987 m_candL1Tau->clear();
988 m_candL1Jet->clear();
989 m_candL1EtSum->clear();
991 m_candL1EG->setBXRange( m_bxFirst_, m_bxLast_ );
992 m_candL1Tau->setBXRange( m_bxFirst_, m_bxLast_ );
993 m_candL1Jet->setBXRange( m_bxFirst_, m_bxLast_ );
994 m_candL1EtSum->setBXRange( m_bxFirst_, m_bxLast_ );
1000 m_candL1External->clear();
1001 m_candL1External->setBXRange( m_bxFirst_, m_bxLast_ );
1010 <<
"\nl1t::L1GlobalTrigger: uGMT data received for BxInEvent = "
1011 << iBxInEvent << std::endl;
1013 int nrL1Mu = m_candL1Mu->size(iBxInEvent);
1015 <<
"Number of GMT muons = " << nrL1Mu <<
"\n"
1018 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 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< unsigned int > &triggerMaskVetoAlgoTrig, const bool algorithmTriggersUnprescaled, const bool algorithmTriggersUnmasked)
run the uGT FDL (Apply Prescales and Veto)
void setAlgoName(const std::string &algoNameValue)
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)