22 #include <ext/hash_map>
75 m_firstEvLumiSegment(
true),
113 delete m_candL1EtSum;
114 delete m_candL1External;
133 void l1t::GtBoard::init(
const int numberPhysTriggers,
const int nrL1Mu,
const int nrL1EG,
const int nrL1Tau,
const int nrL1Jet,
134 int bxFirst,
int bxLast) {
139 m_candL1Mu->setBXRange( m_bxFirst_, m_bxLast_ );
140 m_candL1EG->setBXRange( m_bxFirst_, m_bxLast_ );
141 m_candL1Tau->setBXRange( m_bxFirst_, m_bxLast_ );
142 m_candL1Jet->setBXRange( m_bxFirst_, m_bxLast_ );
143 m_candL1EtSum->setBXRange( m_bxFirst_, m_bxLast_ );
144 m_candL1External->setBXRange( m_bxFirst_, m_bxLast_ );
149 LogDebug(
"l1t|Global") <<
"\t Initializing Board with bxFirst = " << m_bxFirst_ <<
", bxLast = " << m_bxLast_ << std::endl;
172 const bool receiveEG,
const int nrL1EG,
173 const bool receiveTau,
const int nrL1Tau,
174 const bool receiveJet,
const int nrL1Jet,
175 const bool receiveEtSums) {
179 <<
"\n**** Board receiving Calo Data "
195 <<
"\nWarning: BXVector<l1t::EGamma> with input tag "
197 <<
"\nrequested in configuration, but not found in the event.\n"
202 for(
int i = egData->getFirstBX();
i <= egData->getLastBX(); ++
i) {
205 if( i < m_bxFirst_ || i > m_bxLast_ )
continue;
208 for(std::vector<l1t::EGamma>::const_iterator eg = egData->begin(
i); eg != egData->end(
i); ++eg) {
210 (*m_candL1EG).push_back(
i,&(*eg));
211 LogDebug(
"l1t|Global") <<
"EG Pt " << eg->hwPt() <<
" Eta " << eg->hwEta() <<
" Phi " << eg->hwPhi() <<
" Qual " << eg->hwQual() <<
" Iso " << eg->hwIso() << std::endl;
227 <<
"\nWarning: BXVector<l1t::Tau> with input tag "
229 <<
"\nrequested in configuration, but not found in the event.\n"
234 for(
int i = tauData->getFirstBX();
i <= tauData->getLastBX(); ++
i) {
237 if( i < m_bxFirst_ || i > m_bxLast_ )
continue;
240 for(std::vector<l1t::Tau>::const_iterator
tau = tauData->begin(
i);
tau != tauData->end(
i); ++
tau) {
242 (*m_candL1Tau).push_back(
i,&(*
tau));
243 LogDebug(
"l1t|Global") <<
"tau Pt " <<
tau->hwPt() <<
" Eta " <<
tau->hwEta() <<
" Phi " <<
tau->hwPhi() <<
" Qual " <<
tau->hwQual() <<
" Iso " <<
tau->hwIso() << std::endl;
259 <<
"\nWarning: BXVector<l1t::Jet> with input tag "
261 <<
"\nrequested in configuration, but not found in the event.\n"
266 for(
int i = jetData->getFirstBX();
i <= jetData->getLastBX(); ++
i) {
269 if( i < m_bxFirst_ || i > m_bxLast_ )
continue;
272 for(std::vector<l1t::Jet>::const_iterator
jet = jetData->begin(
i);
jet != jetData->end(
i); ++
jet) {
274 (*m_candL1Jet).push_back(
i,&(*
jet));
275 LogDebug(
"l1t|Global") <<
"Jet Pt " <<
jet->hwPt() <<
" Eta " <<
jet->hwEta() <<
" Phi " <<
jet->hwPhi() <<
" Qual " <<
jet->hwQual() <<
" Iso " <<
jet->hwIso() << std::endl;
291 <<
"\nWarning: BXVector<l1t::EtSum> with input tag "
293 <<
"\nrequested in configuration, but not found in the event.\n"
298 for(
int i = etSumData->getFirstBX();
i <= etSumData->getLastBX(); ++
i) {
301 if( i < m_bxFirst_ || i > m_bxLast_ )
continue;
304 for(std::vector<l1t::EtSum>::const_iterator etsum = etSumData->begin(
i); etsum != etSumData->end(
i); ++etsum) {
306 (*m_candL1EtSum).push_back(
i,&(*etsum));
347 <<
"\n**** GtBoard receiving muon data = "
362 <<
"\nWarning: BXVector<l1t::Muon> with input tag "
364 <<
"\nrequested in configuration, but not found in the event.\n"
369 for(
int i = muonData->getFirstBX();
i <= muonData->getLastBX(); ++
i) {
372 if( i < m_bxFirst_ || i > m_bxLast_ )
continue;
375 for(std::vector<l1t::Muon>::const_iterator
mu = muonData->begin(
i);
mu != muonData->end(
i); ++
mu) {
377 (*m_candL1Mu).push_back(
i,&(*
mu));
378 LogDebug(
"l1t|Global") <<
"Muon Pt " <<
mu->hwPt() <<
" Eta " <<
mu->hwEta() <<
" Phi " <<
mu->hwPhi() <<
" Qual " <<
mu->hwQual() <<
" Iso " <<
mu->hwIso() << std::endl;
386 if (m_verbosity && m_isDebugEnabled) {
400 <<
"\n**** GtBoard receiving external data = "
415 <<
"\nWarning: BXVector<GlobalExtBlk> with input tag "
417 <<
"\nrequested in configuration, but not found in the event.\n"
422 for(
int i = extData->getFirstBX();
i <= extData->getLastBX(); ++
i) {
425 if( i < m_bxFirst_ || i > m_bxLast_ )
continue;
428 for(std::vector<GlobalExtBlk>::const_iterator ext = extData->begin(
i); ext != extData->end(
i); ++ext) {
430 (*m_candL1External).push_back(
i,&(*ext));
444 const bool produceL1GtObjectMapRecord,
445 const int iBxInEvent,
446 std::auto_ptr<L1GlobalTriggerObjectMapRecord>& gtObjectMapRecord,
447 const unsigned int numberPhysTriggers,
452 const int nrL1JetCounts) {
454 const std::vector<ConditionMap>& conditionMap = m_l1GtMenu->
gtConditionMap();
458 LogDebug(
"L1TGlobal") <<
" L1 Menu Scales -- Set Name: " << scaleSetName << std::endl;
463 m_algInitialOr=
false;
464 m_algPrescaledOr=
false;
465 m_algFinalOrPreVeto=
false;
467 m_algFinalOrVeto=
false;
470 const std::vector<std::vector<MuonTemplate> >& corrMuon =
474 const std::vector<std::vector<CaloTemplate> >& corrCalo =
477 const std::vector<std::vector<EnergySumTemplate> >& corrEnergySum =
480 LogDebug(
"L1TGlobal") <<
"Size corrMuon " << corrMuon.size()
481 <<
"\nSize corrCalo " << corrCalo.size()
482 <<
"\nSize corrSums " << corrEnergySum.size() << std::endl;
487 bool convertScale =
false;
542 convertScale =
false;
551 if (m_conditionResultMaps.size() != conditionMap.size()) {
552 m_conditionResultMaps.clear();
553 m_conditionResultMaps.resize(conditionMap.size());
558 for (std::vector<ConditionMap>::const_iterator
559 itCondOnChip = conditionMap.begin(); itCondOnChip != conditionMap.end(); itCondOnChip++) {
568 m_conditionResultMaps[iChip];
572 for (
CItCond itCond = itCondOnChip->begin(); itCond != itCondOnChip->end(); itCond++) {
575 switch ((itCond->second)->condCategory()) {
579 const int ifMuEtaNumberBits = 0;
582 nrL1Mu, ifMuEtaNumberBits);
593 cMapResults[itCond->first] = muCondition;
595 if (m_verbosity && m_isDebugEnabled) {
596 std::ostringstream myCout;
597 muCondition->
print(myCout);
599 LogTrace(
"l1t|Global") << myCout.str() << std::endl;
608 const int ifCaloEtaNumberBits = 0;
611 itCond->second,
this,
615 ifCaloEtaNumberBits);
627 cMapResults[itCond->first] = caloCondition;
629 if (m_verbosity && m_isDebugEnabled) {
630 std::ostringstream myCout;
631 caloCondition->
print(myCout);
633 LogTrace(
"l1t|Global") << myCout.str() << std::endl;
642 itCond->second,
this);
647 cMapResults[itCond->first] = eSumCondition;
649 if (m_verbosity && m_isDebugEnabled) {
650 std::ostringstream myCout;
651 eSumCondition->
print(myCout);
653 LogTrace(
"l1t|Global") << myCout.str() << std::endl;
663 itCond->second,
this);
668 cMapResults[itCond->first] = extCondition;
670 if (m_verbosity && m_isDebugEnabled) {
671 std::ostringstream myCout;
672 extCondition->
print(myCout);
674 LogTrace(
"l1t|Global") << myCout.str() << std::endl;
691 const int cond0Ind = corrTemplate->
cond0Index();
692 const int cond1Ind = corrTemplate->
cond1Index();
698 int cond0NrL1Objects = 0;
699 int cond1NrL1Objects = 0;
700 LogDebug(
"l1t|Global") <<
" cond0NrL1Objects" << cond0NrL1Objects <<
" cond1NrL1Objects " << cond1NrL1Objects << std::endl;
706 switch (cond0Categ) {
708 cond0Condition = &((corrMuon[iChip])[cond0Ind]);
714 cond0Condition = &((corrCalo[iChip])[cond0Ind]);
718 cond0Condition = &((corrEnergySum[iChip])[cond0Ind]);
728 switch (cond1Categ) {
730 cond1Condition = &((corrMuon[iChip])[cond1Ind]);
736 cond1Condition = &((corrCalo[iChip])[cond1Ind]);
740 cond1Condition = &((corrEnergySum[iChip])[cond1Ind]);
751 new CorrCondition(itCond->second, cond0Condition, cond1Condition,
this);
756 cMapResults[itCond->first] = correlationCond;
758 if (m_verbosity && m_isDebugEnabled) {
759 std::ostringstream myCout;
760 correlationCond->
print(myCout);
762 LogTrace(
"l1t|Global") << myCout.str() << std::endl;
790 std::vector<L1GlobalTriggerObjectMap> objMapVec;
791 if (produceL1GtObjectMapRecord && (iBxInEvent == 0)) objMapVec.reserve(numberPhysTriggers);
793 for (
CItAlgo itAlgo = algorithmMap.begin(); itAlgo != algorithmMap.end(); itAlgo++) {
795 gtAlg.
evaluateAlgorithm((itAlgo->second).algoChipNumber(), m_conditionResultMaps);
797 int algBitNumber = (itAlgo->second).algoBitNumber();
800 LogDebug(
"l1t|Global") <<
" ===> for iBxInEvent = " << iBxInEvent <<
":\t algBitName = " << itAlgo->first <<
",\t algBitNumber = " << algBitNumber <<
",\t algResult = " << algResult << std::endl;
804 m_uGtAlgBlk.setAlgoDecisionInitial(algBitNumber,algResult);
805 m_algInitialOr =
true;
808 if (m_verbosity && m_isDebugEnabled) {
809 std::ostringstream myCout;
810 ( itAlgo->second ).
print(myCout);
813 LogTrace(
"l1t|Global") << myCout.str() << std::endl;
818 if (produceL1GtObjectMapRecord && (iBxInEvent == 0)) {
820 std::vector<ObjectTypeInCond> otypes;
826 for (
auto imap = conditionMap.begin(); imap != conditionMap.end(); imap++) {
828 auto match = imap->find(iop->tokenName);
830 if (
match != imap->end()){
833 otype =
match->second->objectType();
834 for (
auto itype = otype.begin(); itype != otype.end() ; itype++){
840 edm::LogWarning(
"l1t|Global") <<
"\n Failed to find match for operand token " << iop->tokenName <<
"\n";
842 otypes.push_back(otype);
857 if (m_verbosity && m_isDebugEnabled) {
858 std::ostringstream myCout1;
859 objMap.
print(myCout1);
861 LogTrace(
"l1t|Global") << myCout1.str() << std::endl;
864 objMapVec.push_back(objMap);
872 if (produceL1GtObjectMapRecord && (iBxInEvent == 0)) {
873 gtObjectMapRecord->swapGtObjectMap(objMapVec);
879 for (std::vector<AlgorithmEvaluation::ConditionEvaluationMap>::iterator
880 itCondOnChip = m_conditionResultMaps.begin();
881 itCondOnChip != m_conditionResultMaps.end(); itCondOnChip++) {
884 itCond = itCondOnChip->begin();
885 itCond != itCondOnChip->end(); itCond++) {
887 delete itCond->second;
897 const int iBxInEvent,
898 const int totalBxInEvent,
899 const unsigned int numberPhysTriggers,
900 const std::vector<int>& prescaleFactorsAlgoTrig,
901 const std::vector<unsigned int>& triggerMaskAlgoTrig,
902 const std::vector<unsigned int>& triggerMaskVetoAlgoTrig,
903 const bool algorithmTriggersUnprescaled,
904 const bool algorithmTriggersUnmasked ){
909 <<
"\n**** GtBoard apply Final Decision Logic "
918 m_prescaleCounterAlgoTrig.reserve(numberPhysTriggers*totalBxInEvent);
920 for(
int iBxInEvent = 0; iBxInEvent <= totalBxInEvent; ++iBxInEvent ){
921 m_prescaleCounterAlgoTrig.push_back(prescaleFactorsAlgoTrig);
927 if( m_firstEvLumiSegment ){
929 m_prescaleCounterAlgoTrig.clear();
930 for(
int iBxInEvent = 0; iBxInEvent <= totalBxInEvent; ++iBxInEvent ){
931 m_prescaleCounterAlgoTrig.push_back(prescaleFactorsAlgoTrig);
934 m_firstEvLumiSegment =
false;
939 m_uGtAlgBlk.copyInitialToPrescaled();
945 if( !algorithmTriggersUnprescaled ){
948 int inBxInEvent = totalBxInEvent/2 + iBxInEvent;
950 bool temp_algPrescaledOr =
false;
951 for(
unsigned int iBit = 0; iBit < numberPhysTriggers; ++iBit ){
953 bool bitValue = m_uGtAlgBlk.getAlgoDecisionInitial( iBit );
955 if( prescaleFactorsAlgoTrig.at(iBit) != 1 ){
957 (m_prescaleCounterAlgoTrig.at(inBxInEvent).at(iBit))--;
958 if( m_prescaleCounterAlgoTrig.at(inBxInEvent).at(iBit) == 0 ){
961 m_prescaleCounterAlgoTrig.at(inBxInEvent).at(iBit) = prescaleFactorsAlgoTrig.at(iBit);
962 temp_algPrescaledOr =
true;
967 m_uGtAlgBlk.setAlgoDecisionPreScaled(iBit,
false);
973 temp_algPrescaledOr =
true;
978 m_algPrescaledOr = temp_algPrescaledOr;
983 m_algPrescaledOr = m_algInitialOr;
990 m_uGtAlgBlk.copyPrescaledToFinal();
992 if( !algorithmTriggersUnmasked ){
994 bool temp_algFinalOr =
false;
995 for(
unsigned int iBit = 0; iBit < numberPhysTriggers; ++iBit ){
997 bool bitValue = m_uGtAlgBlk.getAlgoDecisionPreScaled( iBit );
1000 bool isMasked = ( triggerMaskAlgoTrig.at(iBit) == 0 );
1002 bool passMask = ( bitValue && !isMasked );
1004 if( passMask ) temp_algFinalOr =
true;
1005 else m_uGtAlgBlk.setAlgoDecisionFinal(iBit,
false);
1008 if ( triggerMaskVetoAlgoTrig.at(iBit) == 1 ) m_algFinalOrVeto =
true;
1013 m_algFinalOrPreVeto = temp_algFinalOr;
1018 m_algFinalOrPreVeto = m_algPrescaledOr;
1023 m_algFinalOr = (m_algFinalOrPreVeto & !m_algFinalOrVeto);
1031 std::auto_ptr<GlobalAlgBlkBxCollection>& uGtAlgRecord,
1039 <<
"\n**** GtBoard fill DAQ Records for bx= " << iBxInEvent
1045 m_uGtAlgBlk.setOrbitNr((
unsigned int)(orbNr & 0xFFFFFFFF));
1046 m_uGtAlgBlk.setbxNr((bxNr & 0xFFFF));
1047 m_uGtAlgBlk.setbxInEventNr((iBxInEvent & 0xF));
1048 m_uGtAlgBlk.setPreScColumn(0);
1050 m_uGtAlgBlk.setFinalORVeto(m_algFinalOrVeto);
1051 m_uGtAlgBlk.setFinalORPreVeto(m_algFinalOrPreVeto);
1052 m_uGtAlgBlk.setFinalOR(m_algFinalOr);
1055 uGtAlgRecord->push_back(iBxInEvent, m_uGtAlgBlk);
1061 std::auto_ptr<GlobalExtBlkBxCollection>& uGtExtRecord,
1069 <<
"\n**** Board fill DAQ Records for bx= " << iBxInEvent
1076 uGtExtRecord->push_back(iBxInEvent, m_uGtExtBlk);
1088 m_uGtAlgBlk.reset();
1089 m_uGtExtBlk.reset();
1091 m_gtlDecisionWord.reset();
1092 m_gtlAlgorithmOR.reset();
1101 m_candL1Mu->clear();
1102 m_candL1Mu->setBXRange( m_bxFirst_, m_bxLast_ );
1109 m_candL1EG->clear();
1110 m_candL1Tau->clear();
1111 m_candL1Jet->clear();
1112 m_candL1EtSum->clear();
1114 m_candL1EG->setBXRange( m_bxFirst_, m_bxLast_ );
1115 m_candL1Tau->setBXRange( m_bxFirst_, m_bxLast_ );
1116 m_candL1Jet->setBXRange( m_bxFirst_, m_bxLast_ );
1117 m_candL1EtSum->setBXRange( m_bxFirst_, m_bxLast_ );
1123 m_candL1External->clear();
1124 m_candL1External->setBXRange( m_bxFirst_, m_bxLast_ );
1133 <<
"\nl1t::L1GlobalTrigger: GMT data received for BxInEvent = "
1134 << iBxInEvent << std::endl;
1136 int nrL1Mu = m_candL1Mu->size(iBxInEvent);
1138 <<
"Number of GMT muons = " << nrL1Mu <<
"\n"
1148 LogTrace(
"l1t|Global") << std::endl;
void print(std::ostream &myCout) const
print condition
virtual std::string getScalesName() const
bool gtAlgoResult() const
get / set the result of the algorithm
std::bitset< L1GlobalTriggerReadoutSetup::NumberPhysTriggers > m_gtlAlgorithmOR
void printGmtData(const int iBxInEvent) const
print received Muon dataWord
void evaluateConditionStoreResult(const int bxEval)
call evaluateCondition and save last result
void reset()
reset the content of a GlobalExtBlk
void swapCombinationVector(std::vector< CombinationsInCond > &combinationVectorValue)
void print(std::ostream &myCout) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< L1GtLogicParser::OperandToken > & operandTokenVector()
void setAlgoName(const std::string &algoNameValue)
void receiveExternalData(edm::Event &, const edm::EDGetTokenT< BXVector< GlobalExtBlk > > &, const bool receiveExt)
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
void swapOperandTokenVector(std::vector< L1GtLogicParser::OperandToken > &operandTokenVectorValue)
ConditionEvaluationMap::iterator ItEvalMap
unsigned int m_boardEventCount
ConditionMap::const_iterator CItCond
iterators through map containing the conditions
GtConditionCategory
condition categories
std::bitset< L1GlobalTriggerReadoutSetup::NumberPhysTriggers > m_gtlDecisionWord
unsigned long long m_l1MuTriggerScalesCacheID
const l1t::GtConditionCategory cond1Category() const
AlgorithmMap::const_iterator CItAlgo
iterators through map containing the algorithms
void reset()
reset the content of a GlobalAlgBlk
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
void print(std::ostream &myCout) const
print the full object map
const int cond0Index() const
get / set the index of the two sub-conditions in the cor* vector from menu
std::vector< CombinationsInCond > & gtAlgoCombinationVector()
void print(std::ostream &myCout) const
print condition
const int cond1Index() const
std::map< std::string, L1GtAlgorithm > AlgorithmMap
map containing the algorithms
std::vector< L1GtObject > ObjectTypeInCond
void evaluateAlgorithm(const int chipNumber, const std::vector< ConditionEvaluationMap > &)
evaluate an algorithm
void receiveMuonObjectData(edm::Event &, const edm::EDGetTokenT< BXVector< l1t::Muon > > &, const bool receiveMu, const int nrL1Mu)
void setAlgoGtlResult(bool algoGtlResultValue)
unsigned long long m_l1GtMenuCacheID
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)
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 setAlgoBitNumber(int algoBitNumberValue)
void fillExtRecord(int iBxInEvent, std::auto_ptr< GlobalExtBlkBxCollection > &uGtExtRecord, cms_uint64_t orbNr, int bxNr)
void swapObjectTypeVector(std::vector< ObjectTypeInCond > &objectTypeVectorValue)
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
void fillAlgRecord(int iBxInEvent, std::auto_ptr< GlobalAlgBlkBxCollection > &uGtAlgRecord, cms_uint64_t orbNr, int bxNr)
Fill the Daq Records.
unsigned long long cms_uint64_t
void runGTL(edm::Event &iEvent, const edm::EventSetup &evSetup, const TriggerMenu *m_l1GtMenu, const bool produceL1GtObjectMapRecord, const int iBxInEvent, std::auto_ptr< L1GlobalTriggerObjectMapRecord > >ObjectMapRecord, const unsigned int numberPhysTriggers, const int nrL1Mu, const int nrL1EG, const int nrL1Tau, const int nrL1Jet, const int nrL1JetCounts)
run the uGT GTL (Conditions and Algorithms)
unsigned long long m_l1CaloGeometryCacheID