From f14758a004d2367b56c91b64fd09cbed1b3e55e8 Mon Sep 17 00:00:00 2001 From: Marino Missiroli Date: Fri, 27 Dec 2024 14:59:26 +0100 Subject: [PATCH] add BX info to GlobalObjectMap (L1uGT emulation) --- .../L1TGlobal/interface/GlobalObjectMap.h | 34 +- .../L1TGlobal/interface/GlobalObjectMapFwd.h | 20 +- .../interface/GlobalObjectMapRecord.h | 12 +- DataFormats/L1TGlobal/src/GlobalObjectMap.cc | 62 ++- .../L1TGlobal/src/GlobalObjectMapRecord.cc | 8 +- DataFormats/L1TGlobal/src/classes_def.xml | 24 +- .../test/TestGlobalObjectMapRecordFormat.sh | 16 +- .../test/TestReadGlobalObjectMapRecord.cc | 23 +- .../test/TestWriteGlobalObjectMapRecord.cc | 17 +- ...ate_GlobalObjectMapRecord_test_file_cfg.py | 12 +- .../test_readGlobalObjectMapRecord_cfg.py | 22 +- HLTrigger/HLTfilters/plugins/HLTL1TSeed.cc | 391 +++++++----------- HLTrigger/HLTfilters/plugins/HLTL1TSeed.h | 6 +- .../L1TGlobal/interface/AlgorithmEvaluation.h | 7 +- .../L1TGlobal/interface/ConditionEvaluation.h | 6 +- L1Trigger/L1TGlobal/plugins/GtRecordDump.cc | 20 +- .../L1TGlobal/src/AlgorithmEvaluation.cc | 6 +- L1Trigger/L1TGlobal/src/CaloCondition.cc | 24 +- .../L1TGlobal/src/ConditionEvaluation.cc | 24 +- L1Trigger/L1TGlobal/src/CorrCondition.cc | 62 ++- .../L1TGlobal/src/CorrThreeBodyCondition.cc | 90 ++-- .../src/CorrWithOverlapRemovalCondition.cc | 106 +++-- L1Trigger/L1TGlobal/src/EnergySumCondition.cc | 11 +- .../L1TGlobal/src/EnergySumZdcCondition.cc | 11 +- L1Trigger/L1TGlobal/src/ExternalCondition.cc | 18 +- L1Trigger/L1TGlobal/src/MuCondition.cc | 8 +- .../L1TGlobal/src/MuonShowerCondition.cc | 6 +- 27 files changed, 467 insertions(+), 579 deletions(-) diff --git a/DataFormats/L1TGlobal/interface/GlobalObjectMap.h b/DataFormats/L1TGlobal/interface/GlobalObjectMap.h index 50a597b1187ff..beba289646640 100644 --- a/DataFormats/L1TGlobal/interface/GlobalObjectMap.h +++ b/DataFormats/L1TGlobal/interface/GlobalObjectMap.h @@ -1,5 +1,5 @@ -#ifndef L1GlobalTrigger_L1TGtObjectMap_h -#define L1GlobalTrigger_L1TGtObjectMap_h +#ifndef DataFormats_L1TGlobal_GlobalObjectMap_h +#define DataFormats_L1TGlobal_GlobalObjectMap_h /** * \class GlobalObjectMap @@ -15,28 +15,17 @@ * */ -// system include files #include #include - #include -// user include files #include "DataFormats/L1TGlobal/interface/GlobalObjectMapFwd.h" - #include "DataFormats/L1TGlobal/interface/GlobalLogicParser.h" -// forward declarations - -// class declaration class GlobalObjectMap { public: - /// constructor(s) GlobalObjectMap() {} - /// destructor - //~GlobalObjectMap(){} - public: /// get / set name for algorithm in the object map inline const std::string& algoName() const { return m_algoName; } @@ -56,13 +45,13 @@ class GlobalObjectMap { /// get / set the vector of combinations for the algorithm /// return a constant reference to the vector of combinations for the algorithm - inline const std::vector& combinationVector() const { return m_combinationVector; } + inline const std::vector& combinationVector() const { return m_combinationWithBxVector; } - void setCombinationVector(const std::vector& combinationVectorValue) { - m_combinationVector = combinationVectorValue; + void setCombinationVector(const std::vector& combinationVectorValue) { + m_combinationWithBxVector = combinationVectorValue; } - void swapCombinationVector(std::vector& combinationVectorValue) { - m_combinationVector.swap(combinationVectorValue); + void swapCombinationVector(std::vector& combinationVectorValue) { + m_combinationWithBxVector.swap(combinationVectorValue); } /// get / set the vector of operand tokens @@ -79,6 +68,7 @@ class GlobalObjectMap { /// get / set the vector of object types /// return a constant reference to the vector of operand tokens inline const std::vector& objectTypeVector() const { return m_objectTypeVector; } + void setObjectTypeVector(const std::vector& objectTypeVectorValue) { m_objectTypeVector = objectTypeVectorValue; } @@ -88,10 +78,10 @@ class GlobalObjectMap { public: /// return all the combinations passing the requirements imposed in condition condNameVal - const CombinationsInCond* getCombinationsInCond(const std::string& condNameVal) const; + const CombinationsWithBxInCond* getCombinationsInCond(const std::string& condNameVal) const; /// return all the combinations passing the requirements imposed in condition condNumberVal - const CombinationsInCond* getCombinationsInCond(const int condNumberVal) const; + const CombinationsWithBxInCond* getCombinationsInCond(const int condNumberVal) const; /// return the result for the condition condNameVal const bool getConditionResult(const std::string& condNameVal) const; @@ -118,10 +108,10 @@ class GlobalObjectMap { std::vector m_operandTokenVector; // vector of combinations for all conditions in an algorithm - std::vector m_combinationVector; + std::vector m_combinationWithBxVector; // vector of object type vectors for all conditions in an algorithm std::vector m_objectTypeVector; }; -#endif /* L1GlobalTrigger_L1TGtObjectMap_h */ +#endif diff --git a/DataFormats/L1TGlobal/interface/GlobalObjectMapFwd.h b/DataFormats/L1TGlobal/interface/GlobalObjectMapFwd.h index 39713cbc6ea8b..ff5b390fa6155 100644 --- a/DataFormats/L1TGlobal/interface/GlobalObjectMapFwd.h +++ b/DataFormats/L1TGlobal/interface/GlobalObjectMapFwd.h @@ -1,8 +1,8 @@ -#ifndef L1GlobalTrigger_L1TGtObjectMapFwd_h -#define L1GlobalTrigger_L1TGtObjectMapFwd_h +#ifndef DataFormats_L1TGlobal_L1TGtObjectMapFwd_h +#define DataFormats_L1TGlobal_L1TGtObjectMapFwd_h /** - * \class GlobalObjectMap + * \class GlobalObjectMapFwd * * * Description: group typedefs used by GlobalObjectMap. @@ -16,6 +16,7 @@ */ // system include files +#include #include // user include files @@ -24,14 +25,15 @@ // forward declarations /// typedefs +typedef int16_t L1TObjBxIndexType; +typedef int L1TObjIndexType; -/// list of object indices corresponding to a condition evaluated to true -typedef std::vector SingleCombInCond; +/// list of object indices:bx pairs corresponding to a condition evaluated to true +typedef std::vector> SingleCombWithBxInCond; -/// all the object combinations evaluated to true in the condition -typedef std::vector CombinationsInCond; +/// all the object combinations evaluated to true in the condition (object indices + BX indices) +typedef std::vector CombinationsWithBxInCond; typedef std::vector L1TObjectTypeInCond; -//typedef std::vector ObjectTypeInCond; -#endif /* L1GlobalTrigger_L1TGtObjectMapFwd_h */ +#endif diff --git a/DataFormats/L1TGlobal/interface/GlobalObjectMapRecord.h b/DataFormats/L1TGlobal/interface/GlobalObjectMapRecord.h index 88a2f4179cceb..88ad2c8eabdf4 100644 --- a/DataFormats/L1TGlobal/interface/GlobalObjectMapRecord.h +++ b/DataFormats/L1TGlobal/interface/GlobalObjectMapRecord.h @@ -1,5 +1,5 @@ -#ifndef L1GlobalTrigger_L1TGtObjectMapRecord_h -#define L1GlobalTrigger_L1TGtObjectMapRecord_h +#ifndef DataFormats_L1TGlobal_GlobalObjectMapRecord_h +#define DataFormats_L1TGlobal_GlobalObjectMapRecord_h /** * \class GlobalObjectMapRecord @@ -45,11 +45,13 @@ class GlobalObjectMapRecord { /// return all the combinations passing the requirements imposed in condition condNameVal /// from algorithm with name algoNameVal - const CombinationsInCond* getCombinationsInCond(const std::string& algoNameVal, const std::string& condNameVal) const; + const CombinationsWithBxInCond* getCombinationsInCond(const std::string& algoNameVal, + const std::string& condNameVal) const; /// return all the combinations passing the requirements imposed in condition condNameVal /// from algorithm with bit number algoBitNumberVal - const CombinationsInCond* getCombinationsInCond(const int algoBitNumberVal, const std::string& condNameVal) const; + const CombinationsWithBxInCond* getCombinationsInCond(const int algoBitNumberVal, + const std::string& condNameVal) const; /// return the result for the condition condNameVal /// from algorithm with name algoNameVal @@ -73,4 +75,4 @@ class GlobalObjectMapRecord { inline void swap(GlobalObjectMapRecord& lh, GlobalObjectMapRecord& rh) { lh.swap(rh); } -#endif /* L1GlobalTrigger_L1TGtObjectMapRecord_h */ +#endif diff --git a/DataFormats/L1TGlobal/src/GlobalObjectMap.cc b/DataFormats/L1TGlobal/src/GlobalObjectMap.cc index 237e4a5c45459..934c53a7e97a5 100644 --- a/DataFormats/L1TGlobal/src/GlobalObjectMap.cc +++ b/DataFormats/L1TGlobal/src/GlobalObjectMap.cc @@ -12,57 +12,47 @@ * */ -// this class header #include "DataFormats/L1TGlobal/interface/GlobalObjectMap.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" -// system include files #include #include #include - #include -// user include files -#include "FWCore/MessageLogger/interface/MessageLogger.h" - -// forward declarations - -// methods - -// return all the combinations passing the requirements imposed in condition condNameVal -const CombinationsInCond* GlobalObjectMap::getCombinationsInCond(const std::string& condNameVal) const { +/// return all the combinations passing the requirements imposed in condition condNameVal +const CombinationsWithBxInCond* GlobalObjectMap::getCombinationsInCond(const std::string& condNameVal) const { for (size_t i = 0; i < m_operandTokenVector.size(); ++i) { if ((m_operandTokenVector[i]).tokenName == condNameVal) { - return &(m_combinationVector.at((m_operandTokenVector[i]).tokenNumber)); + return &(m_combinationWithBxVector.at((m_operandTokenVector[i]).tokenNumber)); } } // return a null address - should not arrive here edm::LogError("GlobalObjectMap") << "\n\n ERROR: The requested condition with tokenName = " << condNameVal << "\n does not exists in the operand token vector." - << "\n Returning zero pointer for getCombinationsInCond\n\n" - << std::endl; + << "\n Returning zero pointer for getCombinationsInCond\n\n"; return nullptr; } /// return all the combinations passing the requirements imposed in condition condNumberVal -const CombinationsInCond* GlobalObjectMap::getCombinationsInCond(const int condNumberVal) const { +const CombinationsWithBxInCond* GlobalObjectMap::getCombinationsInCond(const int condNumberVal) const { for (size_t i = 0; i < m_operandTokenVector.size(); ++i) { if ((m_operandTokenVector[i]).tokenNumber == condNumberVal) { - return &(m_combinationVector.at((m_operandTokenVector[i]).tokenNumber)); + return &(m_combinationWithBxVector.at((m_operandTokenVector[i]).tokenNumber)); } } // return a null address - should not arrive here edm::LogError("GlobalObjectMap") << "\n\n ERROR: The requested condition with tokenNumber = " << condNumberVal << "\n does not exists in the operand token vector." - << "\n Returning zero pointer for getCombinationsInCond\n\n" - << std::endl; + << "\n Returning zero pointer for getCombinationsInCond\n\n"; return nullptr; } -// return the result for the condition condNameVal + +/// return the result for the condition condNameVal const bool GlobalObjectMap::getConditionResult(const std::string& condNameVal) const { for (size_t i = 0; i < m_operandTokenVector.size(); ++i) { if ((m_operandTokenVector[i]).tokenName == condNameVal) { @@ -73,8 +63,8 @@ const bool GlobalObjectMap::getConditionResult(const std::string& condNameVal) c // return false - should not arrive here edm::LogError("GlobalObjectMap") << "\n\n ERROR: The requested condition with name = " << condNameVal << "\n does not exists in the operand token vector." - << "\n Returning false for getConditionResult\n\n" - << std::endl; + << "\n Returning false for getConditionResult\n\n"; + return false; } @@ -92,7 +82,7 @@ void GlobalObjectMap::reset() { m_operandTokenVector.clear(); // vector of combinations for all conditions in an algorithm - m_combinationVector.clear(); + m_combinationWithBxVector.clear(); } void GlobalObjectMap::print(std::ostream& myCout) const { @@ -117,35 +107,29 @@ void GlobalObjectMap::print(std::ostream& myCout) const { } } - myCout << " CombinationVector size: " << m_combinationVector.size() << std::endl; + myCout << " CombinationWithBxVector size: " << m_combinationWithBxVector.size() << std::endl; myCout << " conditions: " << std::endl; - std::vector::const_iterator itVVV; - int iCond = 0; - for (itVVV = m_combinationVector.begin(); itVVV != m_combinationVector.end(); itVVV++) { - std::string condName = (m_operandTokenVector[iCond]).tokenName; - bool condResult = (m_operandTokenVector[iCond]).tokenResult; - + for (size_t i1 = 0; i1 < m_combinationWithBxVector.size(); ++i1) { + auto const& condName = m_operandTokenVector[i1].tokenName; + auto const condResult = m_operandTokenVector[i1].tokenResult; myCout << " Condition " << condName << " evaluated to " << condResult << std::endl; - myCout << " List of combinations passing all requirements for this condition:" << std::endl; - myCout << " "; - if ((*itVVV).empty()) { + if (m_combinationWithBxVector[i1].empty()) { myCout << "(none)"; } else { - CombinationsInCond::const_iterator itVV; - for (itVV = (*itVVV).begin(); itVV != (*itVVV).end(); itVV++) { + for (size_t i2 = 0; i2 < m_combinationWithBxVector[i1].size(); ++i2) { myCout << "( "; - - std::copy((*itVV).begin(), (*itVV).end(), std::ostream_iterator(myCout, " ")); - + for (size_t i3 = 0; i3 < m_combinationWithBxVector[i1][i2].size(); ++i3) { + myCout << m_combinationWithBxVector[i1][i2][i3].first << ":"; + myCout << m_combinationWithBxVector[i1][i2][i3].second << " "; + } myCout << "); "; } } - iCond++; myCout << "\n\n"; } } diff --git a/DataFormats/L1TGlobal/src/GlobalObjectMapRecord.cc b/DataFormats/L1TGlobal/src/GlobalObjectMapRecord.cc index 5944c034f6aa1..9c08772014d89 100644 --- a/DataFormats/L1TGlobal/src/GlobalObjectMapRecord.cc +++ b/DataFormats/L1TGlobal/src/GlobalObjectMapRecord.cc @@ -64,8 +64,8 @@ const GlobalObjectMap* GlobalObjectMapRecord::getObjectMap(const int algoBitNumb // return all the combinations passing the requirements imposed in condition condNameVal // from algorithm algoNameVal -const CombinationsInCond* GlobalObjectMapRecord::getCombinationsInCond(const std::string& algoNameVal, - const std::string& condNameVal) const { +const CombinationsWithBxInCond* GlobalObjectMapRecord::getCombinationsInCond(const std::string& algoNameVal, + const std::string& condNameVal) const { for (std::vector::const_iterator itObj = m_gtObjectMap.begin(); itObj != m_gtObjectMap.end(); ++itObj) { if (itObj->algoName() == algoNameVal) { @@ -85,8 +85,8 @@ const CombinationsInCond* GlobalObjectMapRecord::getCombinationsInCond(const std // return all the combinations passing the requirements imposed in condition condNameVal // from algorithm with bit number algoBitNumberVal -const CombinationsInCond* GlobalObjectMapRecord::getCombinationsInCond(const int algoBitNumberVal, - const std::string& condNameVal) const { +const CombinationsWithBxInCond* GlobalObjectMapRecord::getCombinationsInCond(const int algoBitNumberVal, + const std::string& condNameVal) const { for (std::vector::const_iterator itObj = m_gtObjectMap.begin(); itObj != m_gtObjectMap.end(); ++itObj) { if (itObj->algoBitNumber() == algoBitNumberVal) { diff --git a/DataFormats/L1TGlobal/src/classes_def.xml b/DataFormats/L1TGlobal/src/classes_def.xml index b1df5c7316978..64f19b967783c 100644 --- a/DataFormats/L1TGlobal/src/classes_def.xml +++ b/DataFormats/L1TGlobal/src/classes_def.xml @@ -31,12 +31,34 @@ - + + + + + + diff --git a/DataFormats/L1TGlobal/test/TestGlobalObjectMapRecordFormat.sh b/DataFormats/L1TGlobal/test/TestGlobalObjectMapRecordFormat.sh index f0fe5b61af7ff..54171ff5b25f0 100755 --- a/DataFormats/L1TGlobal/test/TestGlobalObjectMapRecordFormat.sh +++ b/DataFormats/L1TGlobal/test/TestGlobalObjectMapRecordFormat.sh @@ -4,11 +4,9 @@ function die { echo $1: status $2 ; exit $2; } LOCAL_TEST_DIR=${SCRAM_TEST_PATH} -cmsRun ${LOCAL_TEST_DIR}/create_GlobalObjectMapRecord_test_file_cfg.py || die 'Failure using create_GlobalObjectMapRecord_test_file_cfg.py' $? - -file=testGlobalObjectMapRecord.root - -cmsRun ${LOCAL_TEST_DIR}/test_readGlobalObjectMapRecord_cfg.py "$file" || die "Failure using test_readGlobalObjectMapRecord_cfg.py $file" $? +tmpfile=testGlobalObjectMapRecord.root +cmsRun ${LOCAL_TEST_DIR}/create_GlobalObjectMapRecord_test_file_cfg.py --outputFileName "${tmpfile}" || die 'Failure using create_GlobalObjectMapRecord_test_file_cfg.py' $? +cmsRun ${LOCAL_TEST_DIR}/test_readGlobalObjectMapRecord_cfg.py --inputFileName "${tmpfile}" --globalObjectMapClassVersion 11 || die "Failure using test_readGlobalObjectMapRecord_cfg.py ${tmpfile}" $? # The old files read below were generated as follows. # @@ -28,7 +26,13 @@ oldFiles="testGlobalObjectMapRecord_CMSSW_13_0_0_split_99.root testGlobalObjectM oldFiles+=" testGlobalObjectMapRecord_CMSSW_13_1_0_pre3_split_99.root testGlobalObjectMapRecord_CMSSW_13_1_0_pre3_split_0.root" for file in $oldFiles; do inputfile=$(edmFileInPath DataFormats/L1TGlobal/data/$file) || die "Failure edmFileInPath DataFormats/L1TGlobal/data/$file" $? - cmsRun ${LOCAL_TEST_DIR}/test_readGlobalObjectMapRecord_cfg.py "$inputfile" || die "Failed to read old file $file" $? + cmsRun ${LOCAL_TEST_DIR}/test_readGlobalObjectMapRecord_cfg.py --inputFileName "$inputfile" --globalObjectMapClassVersion 10 || die "Failed to read old file $file" $? done +#oldFiles="testGlobalObjectMapRecord_CMSSW_15_0_0_pre2_split_99.root testGlobalObjectMapRecord_CMSSW_15_0_0_pre2_split_0.root" +#for file in $oldFiles; do +# inputfile=$(edmFileInPath DataFormats/L1TGlobal/data/$file) || die "Failure edmFileInPath DataFormats/L1TGlobal/data/$file" $? +# cmsRun ${LOCAL_TEST_DIR}/test_readGlobalObjectMapRecord_cfg.py --inputFileName "$inputfile" --globalObjectMapClassVersion 11 || die "Failed to read old file $file" $? +#done + exit 0 diff --git a/DataFormats/L1TGlobal/test/TestReadGlobalObjectMapRecord.cc b/DataFormats/L1TGlobal/test/TestReadGlobalObjectMapRecord.cc index 940bf98db1de8..e42c5c66f0945 100644 --- a/DataFormats/L1TGlobal/test/TestReadGlobalObjectMapRecord.cc +++ b/DataFormats/L1TGlobal/test/TestReadGlobalObjectMapRecord.cc @@ -58,8 +58,10 @@ namespace edmtest { int expectedFirstElement_; int expectedElementDelta_; int expectedFinalValue_; + uint expectedBxIndexModulus_; edm::EDGetTokenT globalObjectMapRecordToken_; + uint globalObjectMapClassVersion_; }; TestReadGlobalObjectMapRecord::TestReadGlobalObjectMapRecord(edm::ParameterSet const& iPSet) @@ -75,8 +77,9 @@ namespace edmtest { expectedFirstElement_(iPSet.getParameter("expectedFirstElement")), expectedElementDelta_(iPSet.getParameter("expectedElementDelta")), expectedFinalValue_(iPSet.getParameter("expectedFinalValue")), - - globalObjectMapRecordToken_(consumes(iPSet.getParameter("globalObjectMapRecordTag"))) { + expectedBxIndexModulus_(iPSet.getParameter("expectedBxIndexModulus")), + globalObjectMapRecordToken_(consumes(iPSet.getParameter("globalObjectMapRecordTag"))), + globalObjectMapClassVersion_(iPSet.getParameter("globalObjectMapClassVersion")) { if (expectedAlgoNames_.size() != expectedAlgoBitNumbers_.size() || expectedAlgoNames_.size() != expectedAlgoGtlResults_.size() || expectedAlgoNames_.size() != expectedTokenNames0_.size() || @@ -134,12 +137,20 @@ namespace edmtest { throwWithMessage("tokenResult3 does not have expected value"); } + uint bxCounter = 0; int expectedValue = expectedFirstElement_; for (auto const& combinationsInCond : globalObjectMap.combinationVector()) { for (auto const& singleCombInCond : combinationsInCond) { for (auto const& value : singleCombInCond) { - if (value != expectedValue) { - throwWithMessage("element in inner combination vector does have expected value"); + L1TObjBxIndexType const expectedBxValue = + globalObjectMapClassVersion_ > 10 ? bxCounter % expectedBxIndexModulus_ : 0; + if (value.first != expectedBxValue) { + throwWithMessage("BX in combinationVector does not have expected value"); + } + ++bxCounter; + + if (value.second != expectedValue) { + throwWithMessage("index in combinationVector does not have expected value"); } expectedValue += expectedElementDelta_; } @@ -149,7 +160,7 @@ namespace edmtest { for (auto const& l1tObjectTypeInCond : globalObjectMap.objectTypeVector()) { for (auto const& globalObject : l1tObjectTypeInCond) { if (static_cast(globalObject) != (expectedValue % 28)) { - throwWithMessage("globalObject does have expected value"); + throwWithMessage("globalObject does not have expected value"); } expectedValue += expectedElementDelta_; } @@ -181,7 +192,9 @@ namespace edmtest { desc.add("expectedFirstElement"); desc.add("expectedElementDelta"); desc.add("expectedFinalValue"); + desc.add("expectedBxIndexModulus"); desc.add("globalObjectMapRecordTag"); + desc.add("globalObjectMapClassVersion"); descriptions.addDefault(desc); } } // namespace edmtest diff --git a/DataFormats/L1TGlobal/test/TestWriteGlobalObjectMapRecord.cc b/DataFormats/L1TGlobal/test/TestWriteGlobalObjectMapRecord.cc index 4d7150d4554a8..a3765c81e699a 100644 --- a/DataFormats/L1TGlobal/test/TestWriteGlobalObjectMapRecord.cc +++ b/DataFormats/L1TGlobal/test/TestWriteGlobalObjectMapRecord.cc @@ -56,6 +56,7 @@ namespace edmtest { unsigned int nElements3_; int firstElement_; int elementDelta_; + uint bxIndexModulus_; edm::EDPutTokenT globalObjectMapRecordPutToken_; }; @@ -76,6 +77,7 @@ namespace edmtest { nElements3_(iPSet.getParameter("nElements3")), firstElement_(iPSet.getParameter("firstElement")), elementDelta_(iPSet.getParameter("elementDelta")), + bxIndexModulus_(iPSet.getParameter("bxIndexModulus")), globalObjectMapRecordPutToken_(produces()) { if (algoNames_.size() != nGlobalObjectMaps_ || algoBitNumbers_.size() != nGlobalObjectMaps_ || algoResults_.size() != nGlobalObjectMaps_ || tokenNames0_.size() != nGlobalObjectMaps_ || @@ -121,14 +123,20 @@ namespace edmtest { // The only purpose is to later check that when // we read we get values that match what we wrote. int value = firstElement_; - std::vector combinationsInCondVector; + uint bxCounter = 0; + std::vector combinationsInCondVector; + combinationsInCondVector.reserve(nElements1_); for (unsigned int i = 0; i < nElements1_; ++i) { - CombinationsInCond combinationsInCond; + CombinationsWithBxInCond combinationsInCond; + combinationsInCond.reserve(nElements2_); for (unsigned int j = 0; j < nElements2_; ++j) { - SingleCombInCond singleCombInCond; + SingleCombWithBxInCond singleCombInCond; + singleCombInCond.reserve(nElements3_); for (unsigned int k = 0; k < nElements3_; ++k) { - singleCombInCond.push_back(value); + L1TObjBxIndexType const bxIdx = bxCounter % bxIndexModulus_; + singleCombInCond.emplace_back(bxIdx, value); value += elementDelta_; + ++bxCounter; } combinationsInCond.push_back(std::move(singleCombInCond)); } @@ -172,6 +180,7 @@ namespace edmtest { desc.add("nElements3"); desc.add("firstElement"); desc.add("elementDelta"); + desc.add("bxIndexModulus"); descriptions.addDefault(desc); } diff --git a/DataFormats/L1TGlobal/test/create_GlobalObjectMapRecord_test_file_cfg.py b/DataFormats/L1TGlobal/test/create_GlobalObjectMapRecord_test_file_cfg.py index a1db6ff649fd1..aff4fd6308f25 100644 --- a/DataFormats/L1TGlobal/test/create_GlobalObjectMapRecord_test_file_cfg.py +++ b/DataFormats/L1TGlobal/test/create_GlobalObjectMapRecord_test_file_cfg.py @@ -1,4 +1,11 @@ import FWCore.ParameterSet.Config as cms +import argparse +import sys + +parser = argparse.ArgumentParser(prog=sys.argv[0], description='Test GlobalObjectMapRecord') + +parser.add_argument('--outputFileName', type=str, help='Output file name (default: testGlobalObjectMapRecord.root)', default='testGlobalObjectMapRecord.root') +args = parser.parse_args() process = cms.Process("PROD") @@ -24,11 +31,12 @@ nElements2 = cms.uint32(4), nElements3 = cms.uint32(5), firstElement = cms.int32(11), - elementDelta = cms.int32(3) + elementDelta = cms.int32(3), + bxIndexModulus = cms.uint32(3), ) process.out = cms.OutputModule("PoolOutputModule", - fileName = cms.untracked.string('testGlobalObjectMapRecord.root') + fileName = cms.untracked.string(f'{args.outputFileName}') ) process.path = cms.Path(process.globalObjectMapRecordProducer) diff --git a/DataFormats/L1TGlobal/test/test_readGlobalObjectMapRecord_cfg.py b/DataFormats/L1TGlobal/test/test_readGlobalObjectMapRecord_cfg.py index f3ffc9ea5e249..a71a047e6cd18 100644 --- a/DataFormats/L1TGlobal/test/test_readGlobalObjectMapRecord_cfg.py +++ b/DataFormats/L1TGlobal/test/test_readGlobalObjectMapRecord_cfg.py @@ -1,12 +1,20 @@ import FWCore.ParameterSet.Config as cms +import argparse import sys -process = cms.Process("READ") +parser = argparse.ArgumentParser(prog=sys.argv[0], description='Test GlobalObjectMapRecord') -process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring("file:"+sys.argv[1])) +parser.add_argument('--globalObjectMapClassVersion', type=int, help='Class version of GlobalObjectMap (default: 10)', default=10) +parser.add_argument('--inputFileName', type=str, help='Input file name (default: testGlobalObjectMapRecord.root)', default='testGlobalObjectMapRecord.root') +parser.add_argument('--outputFileName', type=str, help='Output file name (default: testGlobalObjectMapRecord2.root)', default='testGlobalObjectMapRecord2.root') +args = parser.parse_args() + +process = cms.Process('READ') + +process.source = cms.Source('PoolSource', fileNames = cms.untracked.vstring(f'file:{args.inputFileName}')) process.maxEvents.input = 1 -process.testReadGlobalObjectMapRecord = cms.EDAnalyzer("TestReadGlobalObjectMapRecord", +process.testReadGlobalObjectMapRecord = cms.EDAnalyzer('TestReadGlobalObjectMapRecord', expectedAlgoNames = cms.vstring('muonAlgo', 'electronAlgo'), expectedAlgoBitNumbers = cms.vint32(11, 21), expectedAlgoGtlResults = cms.vint32(1, 0), @@ -18,13 +26,15 @@ expectedTokenResults3 = cms.vint32(0, 1), expectedFirstElement = cms.int32(11), expectedElementDelta = cms.int32(3), + expectedBxIndexModulus = cms.uint32(3), # 3 (delta) * (3*4*5 + 3*4) + 11 = 227 expectedFinalValue = cms.int32(227), - globalObjectMapRecordTag = cms.InputTag("globalObjectMapRecordProducer", "", "PROD"), + globalObjectMapRecordTag = cms.InputTag('globalObjectMapRecordProducer', '', 'PROD'), + globalObjectMapClassVersion = cms.uint32(args.globalObjectMapClassVersion), ) -process.out = cms.OutputModule("PoolOutputModule", - fileName = cms.untracked.string('testGlobalObjectMapRecord2.root'), +process.out = cms.OutputModule('PoolOutputModule', + fileName = cms.untracked.string(f'{args.outputFileName}'), fastCloning = cms.untracked.bool(False) ) diff --git a/HLTrigger/HLTfilters/plugins/HLTL1TSeed.cc b/HLTrigger/HLTfilters/plugins/HLTL1TSeed.cc index 3c5a1930ed059..a86ddef8099ce 100644 --- a/HLTrigger/HLTfilters/plugins/HLTL1TSeed.cc +++ b/HLTrigger/HLTfilters/plugins/HLTL1TSeed.cc @@ -5,6 +5,7 @@ #include #include #include +#include #include "DataFormats/Common/interface/Handle.h" #include "DataFormats/Common/interface/Ref.h" @@ -72,7 +73,7 @@ HLTL1TSeed::HLTL1TSeed(const edm::ParameterSet& parSet) // dummy values for tokenNumber and tokenResult m_l1AlgoSeeds.reserve((m_l1AlgoLogicParser.operandTokenVector()).size()); m_l1AlgoSeeds = m_l1AlgoLogicParser.expressionSeedsOperandList(); - size_t l1AlgoSeedsSize = m_l1AlgoSeeds.size(); + size_t const l1AlgoSeedsSize = m_l1AlgoSeeds.size(); m_l1AlgoSeedsRpn.reserve(l1AlgoSeedsSize); m_l1AlgoSeedsObjType.reserve(l1AlgoSeedsSize); @@ -82,13 +83,6 @@ HLTL1TSeed::HLTL1TSeed(const edm::ParameterSet& parSet) } } -// destructor -HLTL1TSeed::~HLTL1TSeed() { - // empty now -} - -// member functions - void HLTL1TSeed::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; makeHLTFilterDescription(desc); @@ -486,38 +480,37 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi // and only available from ObjectMaps created in (2). // define index lists for all particle types - - std::list listMuon; - std::list listMuonShower; - - std::list listEG; - - std::list listJet; - std::list listTau; - - std::list listETM; - std::list listETT; - std::list listHTT; - std::list listHTM; - std::list listETMHF; - std::list listHTMHF; - - std::list listJetCounts; - - std::list listCentrality; - std::list listMinBiasHFP0; - std::list listMinBiasHFM0; - std::list listMinBiasHFP1; - std::list listMinBiasHFM1; - std::list listTotalEtEm; - std::list listMissingEtHF; - std::list listTowerCount; - std::list listAsymEt; - std::list listAsymHt; - std::list listAsymEtHF; - std::list listAsymHtHF; - std::list listZDCP; - std::list listZDCM; + using idxListType = std::list>; + + idxListType listMuon; + idxListType listMuonShower; + + idxListType listEG; + + idxListType listJet; + idxListType listTau; + + idxListType listETM; + idxListType listETT; + idxListType listHTT; + idxListType listHTM; + idxListType listETMHF; + idxListType listHTMHF; + + idxListType listCentrality; + idxListType listMinBiasHFP0; + idxListType listMinBiasHFM0; + idxListType listMinBiasHFP1; + idxListType listMinBiasHFM1; + idxListType listTotalEtEm; + idxListType listMissingEtHF; + idxListType listTowerCount; + idxListType listAsymEt; + idxListType listAsymHt; + idxListType listAsymEtHF; + idxListType listAsymHtHF; + idxListType listZDCP; + idxListType listZDCM; // get handle to unpacked GT edm::Handle uGtAlgoBlocks; @@ -694,7 +687,7 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi const std::vector& opTokenVecObjMap = objMap->operandTokenVector(); const std::vector& condObjTypeVec = objMap->objectTypeVector(); - const std::vector& condCombinations = objMap->combinationVector(); + const std::vector& condCombinations = objMap->combinationVector(); LogTrace("HLTL1TSeed") << "\n\talgoName =" << objMap->algoName() << "\talgoBitNumber = " << algoSeedBitNumber << "\talgoGtlResult = " << algoSeedResult << endl @@ -722,16 +715,15 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi // operands are conditions of L1 algo // for (size_t condNumber = 0; condNumber < opTokenVecObjMap.size(); condNumber++) { - std::vector condObjType = condObjTypeVec[condNumber]; + std::vector const& condObjType = condObjTypeVec[condNumber]; - for (auto& jOb : condObjType) { + for (auto const& jOb : condObjType) { LogTrace("HLTL1TSeed") << setw(15) << "\tcondObjType = " << jOb << endl; } - const std::string condName = opTokenVecObjMap[condNumber].tokenName; - bool condResult = opTokenVecObjMap[condNumber].tokenResult; + bool const condResult = opTokenVecObjMap[condNumber].tokenResult; - // only procede for conditions that passed + // only proceed for conditions that passed // if (!condResult) { continue; @@ -739,16 +731,16 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi // loop over combinations for a given condition // - const CombinationsInCond* condComb = objMap->getCombinationsInCond(condNumber); + auto const& condComb = *(objMap->getCombinationsInCond(condNumber)); - LogTrace("HLTL1TSeed") << setw(15) << "\tcondCombinations = " << condComb->size() << endl; + LogTrace("HLTL1TSeed") << setw(15) << "\tcondCombinations = " << condComb.size(); - for (auto const& itComb : (*condComb)) { + for (size_t i1 = 0; i1 < condComb.size(); ++i1) { LogTrace("HLTL1TSeed") << setw(15) << "\tnew combination" << endl; // loop over objects in a combination for a given condition // - for (auto itObject = itComb.begin(); itObject != itComb.end(); itObject++) { + for (size_t i2 = 0; i2 < condComb[i1].size(); ++i2) { // in case of object-less triggers (e.g. L1_ZeroBias) condObjType vector is empty, so don't seed! // if (condObjType.empty()) { @@ -759,90 +751,94 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi continue; } - // the index of the object type is the same as the index of the object - size_t iType = std::distance(itComb.begin(), itObject); + // BX of the L1T object + auto const objBx = condComb[i1][i2].first; - // get object type and push indices on the list - // - const l1t::GlobalObject objTypeVal = condObjType.at(iType); + // index of the L1T object in the relevant BXVector + auto const objIdx = condComb[i1][i2].second; + + // type of the L1T object + // (the index of the object type is the same as the index of the object) + l1t::GlobalObject const objTypeVal = condObjType[i2]; - LogTrace("HLTL1TSeed") << "\tAdd object of type " << objTypeVal << " and index " << (*itObject) - << " to the seed list." << std::endl; + LogTrace("HLTL1TSeed") << "\tAdd object of type " << objTypeVal << " and index " << objIdx + << " (BX = " << objBx << ") to the seed list."; // THESE OBJECT CASES ARE CURRENTLY MISSING: //gtMinBias, //gtExternal, //ObjNull + // fill list(s) of BX:index values switch (objTypeVal) { case l1t::gtMu: { - listMuon.push_back(*itObject); + listMuon.emplace_back(objBx, objIdx); } break; case l1t::gtMuShower: { - listMuonShower.push_back(*itObject); + listMuonShower.emplace_back(objBx, objIdx); } break; case l1t::gtEG: { - listEG.push_back(*itObject); + listEG.emplace_back(objBx, objIdx); } break; case l1t::gtJet: { - listJet.push_back(*itObject); + listJet.emplace_back(objBx, objIdx); } break; case l1t::gtTau: { - listTau.push_back(*itObject); + listTau.emplace_back(objBx, objIdx); } break; case l1t::gtETM: { - listETM.push_back(*itObject); + listETM.emplace_back(objBx, objIdx); } break; case l1t::gtETT: { - listETT.push_back(*itObject); + listETT.emplace_back(objBx, objIdx); } break; case l1t::gtHTT: { - listHTT.push_back(*itObject); + listHTT.emplace_back(objBx, objIdx); } break; case l1t::gtHTM: { - listHTM.push_back(*itObject); + listHTM.emplace_back(objBx, objIdx); } break; case l1t::gtETMHF: { - listETMHF.push_back(*itObject); + listETMHF.emplace_back(objBx, objIdx); } break; case l1t::gtHTMHF: { - listHTMHF.push_back(*itObject); + listHTMHF.emplace_back(objBx, objIdx); } break; case l1t::gtTowerCount: { - listTowerCount.push_back(*itObject); + listTowerCount.emplace_back(objBx, objIdx); } break; case l1t::gtMinBiasHFP0: { - listMinBiasHFP0.push_back(*itObject); + listMinBiasHFP0.emplace_back(objBx, objIdx); } break; case l1t::gtMinBiasHFM0: { - listMinBiasHFM0.push_back(*itObject); + listMinBiasHFM0.emplace_back(objBx, objIdx); } break; case l1t::gtMinBiasHFP1: { - listMinBiasHFP1.push_back(*itObject); + listMinBiasHFP1.emplace_back(objBx, objIdx); } break; case l1t::gtMinBiasHFM1: { - listMinBiasHFM1.push_back(*itObject); + listMinBiasHFM1.emplace_back(objBx, objIdx); } break; case l1t::gtETTem: { - listTotalEtEm.push_back(*itObject); + listTotalEtEm.emplace_back(objBx, objIdx); } break; case l1t::gtAsymmetryEt: { - listAsymEt.push_back(*itObject); + listAsymEt.emplace_back(objBx, objIdx); } break; case l1t::gtAsymmetryHt: { - listAsymHt.push_back(*itObject); + listAsymHt.emplace_back(objBx, objIdx); } break; case l1t::gtAsymmetryEtHF: { - listAsymEtHF.push_back(*itObject); + listAsymEtHF.emplace_back(objBx, objIdx); } break; case l1t::gtAsymmetryHtHF: { - listAsymHtHF.push_back(*itObject); + listAsymHtHF.emplace_back(objBx, objIdx); } break; case l1t::gtZDCP: { - listZDCP.push_back(*itObject); + listZDCP.emplace_back(objBx, objIdx); } break; case l1t::gtZDCM: { - listZDCM.push_back(*itObject); + listZDCM.emplace_back(objBx, objIdx); } break; case l1t::gtCentrality0: case l1t::gtCentrality1: @@ -852,20 +848,14 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi case l1t::gtCentrality5: case l1t::gtCentrality6: case l1t::gtCentrality7: { - listCentrality.push_back(*itObject); + listCentrality.emplace_back(objBx, objIdx); } break; - //case JetCounts: { - // listJetCounts.push_back(*itObject); - //} - - break; default: { // should not arrive here - LogTrace("HLTL1TSeed") << "\n HLTL1TSeed::hltFilter " - << "\n Unknown object of type " << objTypeVal << " and index " << (*itObject) - << " in the seed list." << std::endl; + << "\n Unknown object of type " << objTypeVal << " and index " << objIdx + << " (BX = " << objBx << ") in the seed list."; } break; } // end switch objTypeVal @@ -913,9 +903,6 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi listHTMHF.sort(); listHTMHF.unique(); - listJetCounts.sort(); - listJetCounts.unique(); - listCentrality.sort(); listCentrality.unique(); @@ -971,17 +958,17 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi << "\nrequested in configuration, but not found in the event." << "\nNo muons added to filterproduct." << endl; } else { - for (std::list::const_iterator itObj = listMuon.begin(); itObj != listMuon.end(); ++itObj) { + for (auto const& [bxIdx, objIdx] : listMuon) { // skip invalid indices - if (*itObj < 0 or unsigned(*itObj) >= muons->size(0)) { + if (objIdx < 0 or unsigned(objIdx) >= muons->size(bxIdx)) { edm::LogWarning("HLTL1TSeed") << "Invalid index from the L1ObjectMap (L1uGT emulator), will be ignored (l1t::MuonBxCollection):" - << " index=" << *itObj << " (size of unpacked L1T objects in BX0 = " << muons->size(0) << ")"; + << " index=" << objIdx << " (" << muons->size(bxIdx) << " unpacked L1T objects in BX " << bxIdx << ")"; continue; } // Transform to index for Bx = 0 to begin of BxVector - unsigned int index = muons->begin(0) - muons->begin() + *itObj; + unsigned int index = muons->begin(bxIdx) - muons->begin() + objIdx; l1t::MuonRef myref(muons, index); filterproduct.addObject(trigger::TriggerL1Mu, myref); @@ -999,17 +986,18 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi << "\nrequested in configuration, but not found in the event." << "\nNo muon showers added to filterproduct." << endl; } else { - for (std::list::const_iterator itObj = listMuonShower.begin(); itObj != listMuonShower.end(); ++itObj) { + for (auto const& [bxIdx, objIdx] : listMuonShower) { // skip invalid indices - if (*itObj < 0 or unsigned(*itObj) >= muonShowers->size(0)) { + if (objIdx < 0 or unsigned(objIdx) >= muonShowers->size(bxIdx)) { edm::LogWarning("HLTL1TSeed") << "Invalid index from the L1ObjectMap (L1uGT emulator), will be ignored (l1t::MuonShowerBxCollection):" - << " index=" << *itObj << " (size of unpacked L1T objects in BX0 = " << muonShowers->size(0) << ")"; + << " index=" << objIdx << " (" << muonShowers->size(bxIdx) << " unpacked L1T objects in BX " << bxIdx + << ")"; continue; } // Transform to index for Bx = 0 to begin of BxVector - unsigned int index = muonShowers->begin(0) - muonShowers->begin() + *itObj; + unsigned int index = muonShowers->begin(bxIdx) - muonShowers->begin() + objIdx; l1t::MuonShowerRef myref(muonShowers, index); filterproduct.addObject(trigger::TriggerL1MuShower, myref); @@ -1026,17 +1014,17 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi << "\nrequested in configuration, but not found in the event." << "\nNo egammas added to filterproduct." << endl; } else { - for (std::list::const_iterator itObj = listEG.begin(); itObj != listEG.end(); ++itObj) { + for (auto const& [bxIdx, objIdx] : listEG) { // skip invalid indices - if (*itObj < 0 or unsigned(*itObj) >= egammas->size(0)) { + if (objIdx < 0 or unsigned(objIdx) >= egammas->size(bxIdx)) { edm::LogWarning("HLTL1TSeed") << "Invalid index from the L1ObjectMap (L1uGT emulator), will be ignored (l1t::EGammaBxCollection):" - << " index=" << *itObj << " (size of unpacked L1T objects in BX0 = " << egammas->size(0) << ")"; + << " index=" << objIdx << " (" << egammas->size(bxIdx) << " unpacked L1T objects in BX " << bxIdx << ")"; continue; } // Transform to begin of BxVector - unsigned int index = egammas->begin(0) - egammas->begin() + *itObj; + unsigned int index = egammas->begin(bxIdx) - egammas->begin() + objIdx; l1t::EGammaRef myref(egammas, index); filterproduct.addObject(trigger::TriggerL1EG, myref); @@ -1054,17 +1042,17 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi << "\nrequested in configuration, but not found in the event." << "\nNo jets added to filterproduct." << endl; } else { - for (std::list::const_iterator itObj = listJet.begin(); itObj != listJet.end(); ++itObj) { + for (auto const& [bxIdx, objIdx] : listJet) { // skip invalid indices - if (*itObj < 0 or unsigned(*itObj) >= jets->size(0)) { + if (objIdx < 0 or unsigned(objIdx) >= jets->size(bxIdx)) { edm::LogWarning("HLTL1TSeed") << "Invalid index from the L1ObjectMap (L1uGT emulator), will be ignored (l1t::JetBxCollection):" - << " index=" << *itObj << " (size of unpacked L1T objects in BX0 = " << jets->size(0) << ")"; + << " index=" << objIdx << " (" << jets->size(bxIdx) << " unpacked L1T objects in BX " << bxIdx << ")"; continue; } // Transform to begin of BxVector - unsigned int index = jets->begin(0) - jets->begin() + *itObj; + unsigned int index = jets->begin(bxIdx) - jets->begin() + objIdx; l1t::JetRef myref(jets, index); filterproduct.addObject(trigger::TriggerL1Jet, myref); @@ -1082,17 +1070,17 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi << "\nrequested in configuration, but not found in the event." << "\nNo taus added to filterproduct." << endl; } else { - for (std::list::const_iterator itObj = listTau.begin(); itObj != listTau.end(); ++itObj) { + for (auto const& [bxIdx, objIdx] : listTau) { // skip invalid indices - if (*itObj < 0 or unsigned(*itObj) >= taus->size(0)) { + if (objIdx < 0 or unsigned(objIdx) >= taus->size(bxIdx)) { edm::LogWarning("HLTL1TSeed") << "Invalid index from the L1ObjectMap (L1uGT emulator), will be ignored (l1t::TauBxCollection):" - << " index=" << *itObj << " (size of unpacked L1T objects in BX0 = " << taus->size(0) << ")"; + << " index=" << objIdx << " (" << taus->size(bxIdx) << " unpacked L1T objects in BX " << bxIdx << ")"; continue; } // Transform to begin of BxVector - unsigned int index = taus->begin(0) - taus->begin() + *itObj; + unsigned int index = taus->begin(bxIdx) - taus->begin() + objIdx; l1t::TauRef myref(taus, index); filterproduct.addObject(trigger::TriggerL1Tau, myref); @@ -1101,150 +1089,57 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi } // ETT, HTT, ETM, HTM - edm::Handle etsums; - iEvent.getByToken(m_l1EtSumToken, etsums); - if (!etsums.isValid()) { + auto fillEtSums = [&](edm::Handle const& etSums, + idxListType const& theList, + l1t::EtSum::EtSumType const l1tId, + trigger::TriggerObjectType const trigObjId) { + for (auto const& [bxIdx, objIdx] : theList) { + for (auto iter = etSums->begin(bxIdx); iter != etSums->end(bxIdx); ++iter) { + l1t::EtSumRef myref(etSums, etSums->key(iter)); + if (myref->getType() == l1tId) { + filterproduct.addObject(trigObjId, myref); + } + } + } + }; + + auto const etsums = iEvent.getHandle(m_l1EtSumToken); + if (not etsums.isValid()) { edm::LogWarning("HLTL1TSeed") << "\nWarning: L1EtSumBxCollection with input tag " << m_l1EtSumTag << "\nrequested in configuration, but not found in the event." << "\nNo etsums added to filterproduct." << endl; } else { - l1t::EtSumBxCollection::const_iterator iter; - - for (iter = etsums->begin(0); iter != etsums->end(0); ++iter) { - l1t::EtSumRef myref(etsums, etsums->key(iter)); - - switch (iter->getType()) { - case l1t::EtSum::kTotalEt: - if (!listETT.empty()) - filterproduct.addObject(trigger::TriggerL1ETT, myref); - break; - case l1t::EtSum::kTotalHt: - if (!listHTT.empty()) - filterproduct.addObject(trigger::TriggerL1HTT, myref); - break; - case l1t::EtSum::kMissingEt: - if (!listETM.empty()) - filterproduct.addObject(trigger::TriggerL1ETM, myref); - break; - case l1t::EtSum::kMissingHt: - if (!listHTM.empty()) - filterproduct.addObject(trigger::TriggerL1HTM, myref); - break; - case l1t::EtSum::kMissingEtHF: - if (!listETMHF.empty()) - filterproduct.addObject(trigger::TriggerL1ETMHF, myref); - break; - case l1t::EtSum::kMissingHtHF: - if (!listHTMHF.empty()) - filterproduct.addObject(trigger::TriggerL1HTMHF, myref); - break; - case l1t::EtSum::kCentrality: - if (!listCentrality.empty()) - filterproduct.addObject(trigger::TriggerL1Centrality, myref); - break; - case l1t::EtSum::kMinBiasHFP0: - if (!listMinBiasHFP0.empty()) - filterproduct.addObject(trigger::TriggerL1MinBiasHFP0, myref); - break; - case l1t::EtSum::kMinBiasHFM0: - if (!listMinBiasHFM0.empty()) - filterproduct.addObject(trigger::TriggerL1MinBiasHFM0, myref); - break; - case l1t::EtSum::kMinBiasHFP1: - if (!listMinBiasHFP1.empty()) - filterproduct.addObject(trigger::TriggerL1MinBiasHFP1, myref); - break; - case l1t::EtSum::kMinBiasHFM1: - if (!listMinBiasHFM1.empty()) - filterproduct.addObject(trigger::TriggerL1MinBiasHFM1, myref); - break; - case l1t::EtSum::kTotalEtEm: - if (!listTotalEtEm.empty()) - filterproduct.addObject(trigger::TriggerL1TotalEtEm, myref); - break; - case l1t::EtSum::kTowerCount: - if (!listTowerCount.empty()) - filterproduct.addObject(trigger::TriggerL1TowerCount, myref); - break; - case l1t::EtSum::kAsymEt: - if (!listAsymEt.empty()) - filterproduct.addObject(trigger::TriggerL1AsymEt, myref); - break; - case l1t::EtSum::kAsymHt: - if (!listAsymHt.empty()) - filterproduct.addObject(trigger::TriggerL1AsymHt, myref); - break; - case l1t::EtSum::kAsymEtHF: - if (!listAsymEtHF.empty()) - filterproduct.addObject(trigger::TriggerL1AsymEtHF, myref); - break; - case l1t::EtSum::kAsymHtHF: - if (!listAsymHtHF.empty()) - filterproduct.addObject(trigger::TriggerL1AsymHtHF, myref); - break; - default: - LogTrace("HLTL1TSeed") << " L1EtSum seed of currently unsuported HLT TriggerType. l1t::EtSum type: " - << iter->getType() << "\n"; - - } // end switch - - } // end for - - } // end else + fillEtSums(etsums, listETT, l1t::EtSum::kTotalEt, trigger::TriggerL1ETT); + fillEtSums(etsums, listHTT, l1t::EtSum::kTotalHt, trigger::TriggerL1HTT); + fillEtSums(etsums, listETM, l1t::EtSum::kMissingEt, trigger::TriggerL1ETM); + fillEtSums(etsums, listHTM, l1t::EtSum::kMissingHt, trigger::TriggerL1HTM); + fillEtSums(etsums, listETMHF, l1t::EtSum::kMissingEtHF, trigger::TriggerL1ETMHF); + fillEtSums(etsums, listHTMHF, l1t::EtSum::kMissingHtHF, trigger::TriggerL1HTMHF); + fillEtSums(etsums, listCentrality, l1t::EtSum::kCentrality, trigger::TriggerL1Centrality); + fillEtSums(etsums, listMinBiasHFP0, l1t::EtSum::kMinBiasHFP0, trigger::TriggerL1MinBiasHFP0); + fillEtSums(etsums, listMinBiasHFM0, l1t::EtSum::kMinBiasHFM0, trigger::TriggerL1MinBiasHFM0); + fillEtSums(etsums, listMinBiasHFP1, l1t::EtSum::kMinBiasHFP1, trigger::TriggerL1MinBiasHFP1); + fillEtSums(etsums, listMinBiasHFM1, l1t::EtSum::kMinBiasHFM1, trigger::TriggerL1MinBiasHFM1); + fillEtSums(etsums, listTotalEtEm, l1t::EtSum::kTotalEtEm, trigger::TriggerL1TotalEtEm); + fillEtSums(etsums, listTowerCount, l1t::EtSum::kTowerCount, trigger::TriggerL1TowerCount); + fillEtSums(etsums, listAsymEt, l1t::EtSum::kAsymEt, trigger::TriggerL1AsymEt); + fillEtSums(etsums, listAsymHt, l1t::EtSum::kAsymHt, trigger::TriggerL1AsymHt); + fillEtSums(etsums, listAsymEtHF, l1t::EtSum::kAsymEtHF, trigger::TriggerL1AsymEtHF); + fillEtSums(etsums, listAsymHtHF, l1t::EtSum::kAsymHtHF, trigger::TriggerL1AsymHtHF); + } // ZDCP, ZDCM - edm::Handle etsumzdcs; - iEvent.getByToken(m_l1EtSumZdcToken, etsumzdcs); - if (!etsumzdcs.isValid()) { - //!! FIXME: replace LogDebug with edm::LogWarning once unpacker of ZDC inputs to L1-uGT becomes available - //!! https://github.com/cms-sw/cmssw/pull/42634#issuecomment-1698132805 - //!! https://github.com/cms-sw/cmssw/blob/bece38936ef0ba111f4b5f4502e819595560afa6/EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTSetup.cc#L76 - LogDebug("HLTL1TSeed") << "\nWarning: L1EtSumBxCollection with input tag " << m_l1EtSumZdcTag - << "\nrequested in configuration, but not found in the event." - << "\nNo etsums (ZDC) added to filterproduct."; + auto const etsumzdcs = iEvent.getHandle(m_l1EtSumZdcToken); + if (not etsumzdcs.isValid()) { + edm::LogWarning("HLTL1TSeed") << "\nWarning: L1EtSumBxCollection with input tag " << m_l1EtSumZdcTag + << "\nrequested in configuration, but not found in the event." + << "\nNo etsums (ZDC) added to filterproduct."; } else { - l1t::EtSumBxCollection::const_iterator iter; - - for (iter = etsumzdcs->begin(0); iter != etsumzdcs->end(0); ++iter) { - l1t::EtSumRef myref(etsumzdcs, etsumzdcs->key(iter)); - - switch (iter->getType()) { - case l1t::EtSum::kZDCP: - if (!listZDCP.empty()) - filterproduct.addObject(trigger::TriggerL1ZDCP, myref); - break; - case l1t::EtSum::kZDCM: - if (!listZDCM.empty()) - filterproduct.addObject(trigger::TriggerL1ZDCM, myref); - break; - default: - LogTrace("HLTL1TSeed") - << " L1EtSum (ZDC) seed of currently unsuported HLT TriggerType. l1t::EtSum type: " - << iter->getType() << "\n"; - - } // end switch - - } // end for - - } // end else - - // TODO FIXME uncomment if block when JetCounts implemented - - // // jet counts - // if (!listJetCounts.empty()) { - // edm::Handle l1JetCounts; - // iEvent.getByToken(m_l1CollectionsToken.label(), l1JetCounts); - // - // for (std::list::const_iterator itObj = listJetCounts.begin(); - // itObj != listJetCounts.end(); ++itObj) { - // - // filterproduct.addObject(trigger::TriggerL1JetCounts,l1extra::L1JetCountsRefProd(l1JetCounts)); - // // FIXME: RefProd! - // - // } - // - // } + fillEtSums(etsumzdcs, listZDCP, l1t::EtSum::kZDCP, trigger::TriggerL1ZDCP); + fillEtSums(etsumzdcs, listZDCM, l1t::EtSum::kZDCM, trigger::TriggerL1ZDCM); + } + // return filter decision LogTrace("HLTL1TSeed") << "\nHLTL1Seed:seedsL1TriggerObjectMaps returning " << seedsResult << endl << endl; return seedsResult; diff --git a/HLTrigger/HLTfilters/plugins/HLTL1TSeed.h b/HLTrigger/HLTfilters/plugins/HLTL1TSeed.h index e4a3788566c87..775130a9df19c 100644 --- a/HLTrigger/HLTfilters/plugins/HLTL1TSeed.h +++ b/HLTrigger/HLTfilters/plugins/HLTL1TSeed.h @@ -1,5 +1,5 @@ -#ifndef HLTfilters_HLTL1TSeed_h -#define HLTfilters_HLTL1TSeed_h +#ifndef HLTrigger_HLTfilters_HLTL1TSeed_h +#define HLTrigger_HLTfilters_HLTL1TSeed_h /** * \class HLTL1TSeed @@ -49,7 +49,7 @@ class HLTL1TSeed : public HLTStreamFilter { explicit HLTL1TSeed(const edm::ParameterSet&); /// destructor - ~HLTL1TSeed() override; + ~HLTL1TSeed() override = default; /// parameter description static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); diff --git a/L1Trigger/L1TGlobal/interface/AlgorithmEvaluation.h b/L1Trigger/L1TGlobal/interface/AlgorithmEvaluation.h index 464b7bc37bbee..345948273f7a6 100644 --- a/L1Trigger/L1TGlobal/interface/AlgorithmEvaluation.h +++ b/L1Trigger/L1TGlobal/interface/AlgorithmEvaluation.h @@ -68,9 +68,8 @@ namespace l1t { /// evaluate an algorithm void evaluateAlgorithm(const int chipNumber, const std::vector&); - /// get all the object combinations evaluated to true in the conditions - /// from the algorithm - inline std::vector& gtAlgoCombinationVector() { return m_algoCombinationVector; } + /// get all the object combinations evaluated to true in the conditions from the algorithm + inline std::vector& gtAlgoCombinationVector() { return m_algoCombinationVector; } inline std::vector& operandTokenVector() { return m_operandTokenVector; } @@ -86,7 +85,7 @@ namespace l1t { std::vector m_operandTokenVector; - std::vector m_algoCombinationVector; + std::vector m_algoCombinationVector; }; } // namespace l1t diff --git a/L1Trigger/L1TGlobal/interface/ConditionEvaluation.h b/L1Trigger/L1TGlobal/interface/ConditionEvaluation.h index 022f525bf3569..c65a688cbcc01 100644 --- a/L1Trigger/L1TGlobal/interface/ConditionEvaluation.h +++ b/L1Trigger/L1TGlobal/interface/ConditionEvaluation.h @@ -78,7 +78,7 @@ namespace l1t { } /// get all the object combinations evaluated to true in the condition - inline CombinationsInCond const& getCombinationsInCond() const { return m_combinationsInCond; } + inline CombinationsWithBxInCond const& getCombinationsInCond() const { return m_combinationsInCond; } /// print condition virtual void print(std::ostream& myCout) const; @@ -87,7 +87,7 @@ namespace l1t { protected: /// get all the object combinations (to fill it...) - inline CombinationsInCond& combinationsInCond() const { return m_combinationsInCond; } + inline CombinationsWithBxInCond& combinationsInCond() const { return m_combinationsInCond; } /// check if a value is greater than a threshold or /// greater-or-equal depending on the value of the condGEqValue flag @@ -166,7 +166,7 @@ namespace l1t { bool m_condLastResult; /// store all the object combinations evaluated to true in the condition - mutable CombinationsInCond m_combinationsInCond; + mutable CombinationsWithBxInCond m_combinationsInCond; /// verbosity level int m_verbosity; diff --git a/L1Trigger/L1TGlobal/plugins/GtRecordDump.cc b/L1Trigger/L1TGlobal/plugins/GtRecordDump.cc index ec899523716db..e5e16c75a163e 100644 --- a/L1Trigger/L1TGlobal/plugins/GtRecordDump.cc +++ b/L1Trigger/L1TGlobal/plugins/GtRecordDump.cc @@ -287,28 +287,24 @@ namespace l1t { // Combination const std::vector& opTokenVecObjMap = oMap.operandTokenVector(); const std::vector& condObjTypeVec = oMap.objectTypeVector(); - // const std::vector& condCombinations = oMapcombinationVector(); for (size_t iCond = 0; iCond < opTokenVecObjMap.size(); iCond++) { - std::cout << " " << iCond << ") Condition Token: " << opTokenVecObjMap.at(iCond).tokenName + std::cout << " " << iCond << ") Condition Token: " << opTokenVecObjMap[iCond].tokenName << " Types: "; - std::vector condObjType = condObjTypeVec[iCond]; + auto const& condObjType = condObjTypeVec[iCond]; for (size_t iCondType = 0; iCondType < condObjType.size(); iCondType++) { std::cout << condObjType.at(iCondType) << " "; } std::cout << std::endl; - const CombinationsInCond* condComb = oMap.getCombinationsInCond(iCond); + const CombinationsWithBxInCond* condComb = oMap.getCombinationsInCond(iCond); std::cout << " Combinations in Condition [" << condComb->size() << "] : "; - for (std::vector::const_iterator itComb = (*condComb).begin(); - itComb != (*condComb).end(); - itComb++) { + for (auto const& itComb : *condComb) { // loop over objects in a combination for a given condition // unsigned int iType = 0; std::cout << "("; - for (SingleCombInCond::const_iterator itObject = (*itComb).begin(); itObject != (*itComb).end(); - itObject++) { + for (auto const& [bxIdx, objIdx] : itComb) { // loop over types for the object in a combination. This object might have more then one type (i.e. mu-eg) // @@ -318,12 +314,12 @@ namespace l1t { // //const l1t::GlobalObject objTypeVal = condObjType.at(iType); - std::cout << (*itObject); - //std::cout <second)->getCombinationsInCond(); + auto const& combInCondition = (itCond->second)->getCombinationsInCond(); m_algoCombinationVector.push_back(combInCondition); } else { @@ -161,9 +161,9 @@ void l1t::AlgorithmEvaluation::evaluateAlgorithm(const int chipNumber, void l1t::AlgorithmEvaluation::print(std::ostream& myCout) const { myCout << std::endl; - myCout << " Algorithm result: " << m_algoResult << std::endl; + myCout << " Algorithm result: " << m_algoResult << std::endl; - myCout << " CombinationVector size: " << m_algoCombinationVector.size() << std::endl; + myCout << " CombinationVector size: " << m_algoCombinationVector.size() << std::endl; int operandTokenVectorSize = m_operandTokenVector.size(); diff --git a/L1Trigger/L1TGlobal/src/CaloCondition.cc b/L1Trigger/L1TGlobal/src/CaloCondition.cc index 0eebe30412f13..b4512d5602e0f 100644 --- a/L1Trigger/L1TGlobal/src/CaloCondition.cc +++ b/L1Trigger/L1TGlobal/src/CaloCondition.cc @@ -155,7 +155,7 @@ const bool l1t::CaloCondition::evaluateCondition(const int bxEval) const { } // Look at objects in bx = bx + relativeBx - int useBx = bxEval + m_gtCaloTemplate->condRelativeBx(); + L1TObjBxIndexType const useBx = bxEval + m_gtCaloTemplate->condRelativeBx(); // Fail condition if attempting to get Bx outside of range if ((useBx < candVec->getFirstBX()) || (useBx > candVec->getLastBX())) { @@ -185,7 +185,7 @@ const bool l1t::CaloCondition::evaluateCondition(const int bxEval) const { // store the indices of the calorimeter objects // from the combination evaluated in the condition - SingleCombInCond objectsInComb; + SingleCombWithBxInCond objectsInComb; objectsInComb.reserve(nObjInCond); // clear the m_combinationsInCond vector @@ -203,7 +203,7 @@ const bool l1t::CaloCondition::evaluateCondition(const int bxEval) const { totalLoops++; bool passCondition = checkObjectParameter(0, *(candVec->at(useBx, i)), index[i]); if (passCondition) { - objectsInComb.push_back(i); + objectsInComb.emplace_back(useBx, i); condResult = true; passLoops++; combinationsInCond().push_back(objectsInComb); @@ -268,8 +268,8 @@ const bool l1t::CaloCondition::evaluateCondition(const int bxEval) const { } // end wsc check objectsInComb.clear(); - objectsInComb.push_back(i); - objectsInComb.push_back(j); + objectsInComb.emplace_back(useBx, i); + objectsInComb.emplace_back(useBx, j); condResult = true; passLoops++; combinationsInCond().push_back(objectsInComb); @@ -315,9 +315,9 @@ const bool l1t::CaloCondition::evaluateCondition(const int bxEval) const { condResult = true; passLoops++; objectsInComb.clear(); - objectsInComb.push_back(i); - objectsInComb.push_back(j); - objectsInComb.push_back(k); + objectsInComb.emplace_back(useBx, i); + objectsInComb.emplace_back(useBx, j); + objectsInComb.emplace_back(useBx, k); combinationsInCond().push_back(objectsInComb); } } // end loop on k @@ -394,10 +394,10 @@ const bool l1t::CaloCondition::evaluateCondition(const int bxEval) const { (passCondition0m && passCondition1k && passCondition2j && passCondition3i)); if (pass) { objectsInComb.clear(); - objectsInComb.push_back(i); - objectsInComb.push_back(j); - objectsInComb.push_back(k); - objectsInComb.push_back(m); + objectsInComb.emplace_back(useBx, i); + objectsInComb.emplace_back(useBx, j); + objectsInComb.emplace_back(useBx, k); + objectsInComb.emplace_back(useBx, m); condResult = true; passLoops++; combinationsInCond().push_back(objectsInComb); diff --git a/L1Trigger/L1TGlobal/src/ConditionEvaluation.cc b/L1Trigger/L1TGlobal/src/ConditionEvaluation.cc index 807dcca60c111..ff873e4cf8cf4 100644 --- a/L1Trigger/L1TGlobal/src/ConditionEvaluation.cc +++ b/L1Trigger/L1TGlobal/src/ConditionEvaluation.cc @@ -12,21 +12,9 @@ * */ -// this class header #include "L1Trigger/L1TGlobal/interface/ConditionEvaluation.h" -// system include files -#include -#include -#include - -// user include files - -// base class - -// - -// methods +#include /// print condition void l1t::ConditionEvaluation::print(std::ostream& myCout) const { @@ -34,14 +22,12 @@ void l1t::ConditionEvaluation::print(std::ostream& myCout) const { myCout << " Maximum number of objects in condition: " << m_condMaxNumberObjects << std::endl; myCout << " Condition result: " << m_condLastResult << std::endl; - CombinationsInCond::const_iterator itVV; std::ostringstream myCout1; - - for (itVV = (m_combinationsInCond).begin(); itVV != (m_combinationsInCond).end(); itVV++) { + for (size_t i1 = 0; i1 < m_combinationsInCond.size(); ++i1) { myCout1 << "( "; - - std::copy((*itVV).begin(), (*itVV).end(), std::ostream_iterator(myCout1, " ")); - + for (size_t i2 = 0; i2 < m_combinationsInCond[i1].size(); ++i2) { + myCout1 << m_combinationsInCond[i1][i2].first << ":" << m_combinationsInCond[i1][i2].second << " "; + } myCout1 << "); "; } diff --git a/L1Trigger/L1TGlobal/src/CorrCondition.cc b/L1Trigger/L1TGlobal/src/CorrCondition.cc index 082bed42d2017..06f2d34b08521 100644 --- a/L1Trigger/L1TGlobal/src/CorrCondition.cc +++ b/L1Trigger/L1TGlobal/src/CorrCondition.cc @@ -126,11 +126,8 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { const EnergySumTemplate* corrEnergySum = nullptr; // FIXME copying is slow... - CombinationsInCond cond0Comb; - CombinationsInCond cond1Comb; - - int cond0bx(0); - int cond1bx(0); + CombinationsWithBxInCond cond0Comb{}; + CombinationsWithBxInCond cond1Comb{}; switch (cond0Categ) { case CondMuon: { @@ -142,7 +139,7 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { reqObjResult = muCondition.condLastResult(); cond0Comb = (muCondition.getCombinationsInCond()); - cond0bx = bxEval + (corrMuon->condRelativeBx()); + cndObjTypeVec[0] = (corrMuon->objectType())[0]; if (m_verbosity) { @@ -162,7 +159,7 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { reqObjResult = caloCondition.condLastResult(); cond0Comb = (caloCondition.getCombinationsInCond()); - cond0bx = bxEval + (corrCalo->condRelativeBx()); + cndObjTypeVec[0] = (corrCalo->objectType())[0]; if (m_verbosity) { @@ -180,7 +177,7 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { reqObjResult = eSumCondition.condLastResult(); cond0Comb = (eSumCondition.getCombinationsInCond()); - cond0bx = bxEval + (corrEnergySum->condRelativeBx()); + cndObjTypeVec[0] = (corrEnergySum->objectType())[0]; if (m_verbosity) { @@ -214,7 +211,6 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { reqObjResult = muCondition.condLastResult(); cond1Comb = (muCondition.getCombinationsInCond()); - cond1bx = bxEval + (corrMuon->condRelativeBx()); cndObjTypeVec[1] = (corrMuon->objectType())[0]; @@ -234,7 +230,7 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { reqObjResult = caloCondition.condLastResult(); cond1Comb = (caloCondition.getCombinationsInCond()); - cond1bx = bxEval + (corrCalo->condRelativeBx()); + cndObjTypeVec[1] = (corrCalo->objectType())[0]; if (m_verbosity) { @@ -254,7 +250,7 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { reqObjResult = eSumCondition.condLastResult(); cond1Comb = (eSumCondition.getCombinationsInCond()); - cond1bx = bxEval + (corrEnergySum->condRelativeBx()); + cndObjTypeVec[1] = (corrEnergySum->objectType())[0]; if (m_verbosity) { @@ -285,7 +281,7 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { // vector to store the indices of the calorimeter objects // from the combination evaluated in the condition - SingleCombInCond objectsInComb; + SingleCombWithBxInCond objectsInComb; objectsInComb.reserve(nObjInCond); // clear the m_combinationsInCond vector @@ -385,26 +381,24 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { std::string lutObj0 = "NULL"; std::string lutObj1 = "NULL"; - LogTrace("L1TGlobal") << " Sub-condition 0: std::vector size: " << (cond0Comb.size()) << std::endl; - LogTrace("L1TGlobal") << " Sub-condition 1: std::vector size: " << (cond1Comb.size()) << std::endl; + LogTrace("L1TGlobal") << " Sub-condition 0: std::vector size: " << cond0Comb.size(); + LogTrace("L1TGlobal") << " Sub-condition 1: std::vector size: " << cond1Comb.size(); // loop over all combinations which produced individually "true" as Type1s // // BLW: Optimization issue: potentially making the same comparison twice // if both legs are the same object type. - for (std::vector::const_iterator it0Comb = cond0Comb.begin(); it0Comb != cond0Comb.end(); - it0Comb++) { - // Type1s: there is 1 object only, no need for a loop, index 0 should be OK in (*it0Comb)[0] + for (auto const& it0Comb : cond0Comb) { + // Type1s: there is 1 object only, no need for a loop, index 0 should be OK in it0Comb[0] // ... but add protection to not crash - int obj0Index = -1; - - if (!(*it0Comb).empty()) { - obj0Index = (*it0Comb)[0]; - } else { - LogTrace("L1TGlobal") << "\n SingleCombInCond (*it0Comb).size() " << ((*it0Comb).size()) << std::endl; + if (it0Comb.empty()) { + LogTrace("L1TGlobal") << "\n SingleCombWithBxInCond it0Comb.size() " << it0Comb.size(); return false; } + auto const cond0bx = it0Comb[0].first; + auto const obj0Index = it0Comb[0].second; + // Collect the information on the first leg of the correlation switch (cond0Categ) { case CondMuon: { @@ -684,20 +678,18 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { } //end switch on first leg type // Now loop over the second leg to get its information - for (std::vector::const_iterator it1Comb = cond1Comb.begin(); it1Comb != cond1Comb.end(); - it1Comb++) { - LogDebug("L1TGlobal") << "Looking at second Condition" << std::endl; - // Type1s: there is 1 object only, no need for a loop (*it1Comb)[0] + for (auto const& it1Comb : cond1Comb) { + LogDebug("L1TGlobal") << "Looking at second Condition"; + // Type1s: there is 1 object only, no need for a loop it1Comb[0] // ... but add protection to not crash - int obj1Index = -1; - - if (!(*it1Comb).empty()) { - obj1Index = (*it1Comb)[0]; - } else { - LogTrace("L1TGlobal") << "\n SingleCombInCond (*it1Comb).size() " << ((*it1Comb).size()) << std::endl; + if (it1Comb.empty()) { + LogTrace("L1TGlobal") << "\n SingleCombWithBxInCond it1Comb.size() " << it1Comb.size(); return false; } + auto const cond1bx = it1Comb[0].first; + auto const obj1Index = it1Comb[0].second; + //If we are dealing with the same object type avoid the two legs // either being the same object if (cndObjTypeVec[0] == cndObjTypeVec[1] && obj0Index == obj1Index && cond0bx == cond1bx) { @@ -995,8 +987,8 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { // clear the indices in the combination objectsInComb.clear(); - objectsInComb.push_back(obj0Index); - objectsInComb.push_back(obj1Index); + objectsInComb.emplace_back(cond0bx, obj0Index); + objectsInComb.emplace_back(cond1bx, obj1Index); // if we get here all checks were successful for this combination // set the general result for evaluateCondition to "true" diff --git a/L1Trigger/L1TGlobal/src/CorrThreeBodyCondition.cc b/L1Trigger/L1TGlobal/src/CorrThreeBodyCondition.cc index 99fa3843edd84..fc18c148c241e 100644 --- a/L1Trigger/L1TGlobal/src/CorrThreeBodyCondition.cc +++ b/L1Trigger/L1TGlobal/src/CorrThreeBodyCondition.cc @@ -106,13 +106,9 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons const MuonTemplate* corrMuon = nullptr; - CombinationsInCond cond0Comb; - CombinationsInCond cond1Comb; - CombinationsInCond cond2Comb; - - int cond0bx(0); - int cond1bx(0); - int cond2bx(0); + CombinationsWithBxInCond cond0Comb{}; + CombinationsWithBxInCond cond1Comb{}; + CombinationsWithBxInCond cond2Comb{}; // FIRST OBJECT bool reqObjResult = false; @@ -126,7 +122,7 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons reqObjResult = muCondition.condLastResult(); cond0Comb = (muCondition.getCombinationsInCond()); - cond0bx = bxEval + (corrMuon->condRelativeBx()); + cndObjTypeVec[0] = (corrMuon->objectType())[0]; if (m_verbosity) { @@ -157,7 +153,7 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons reqObjResult = muCondition.condLastResult(); cond1Comb = (muCondition.getCombinationsInCond()); - cond1bx = bxEval + (corrMuon->condRelativeBx()); + cndObjTypeVec[1] = (corrMuon->objectType())[0]; if (m_verbosity) { @@ -190,7 +186,7 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons reqObjResult = muCondition.condLastResult(); cond2Comb = (muCondition.getCombinationsInCond()); - cond2bx = bxEval + (corrMuon->condRelativeBx()); + cndObjTypeVec[2] = (corrMuon->objectType())[0]; if (m_verbosity) { @@ -221,7 +217,7 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons *(m_gtCorrelationThreeBodyTemplate->correlationThreeBodyParameter()); // Vector to store the indices of the objects involved in the condition evaluation - SingleCombInCond objectsInComb; + SingleCombWithBxInCond objectsInComb; objectsInComb.reserve(nObjInCond); // Clear the m_combinationsInCond vector: @@ -291,28 +287,28 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons unsigned int preShift = 0; // *** Looking for a set of three objects - for (std::vector::const_iterator it0Comb = cond0Comb.begin(); it0Comb != cond0Comb.end(); - it0Comb++) { + for (auto const& it0Comb : cond0Comb) { // Type1s: there is 1 object only, no need for a loop, index 0 should be OK in (*it0Comb)[0] // ... but add protection to not crash LogDebug("L1TGlobal") << "Looking at first subcondition" << std::endl; - int obj0Index = -1; - if (!(*it0Comb).empty()) { - obj0Index = (*it0Comb)[0]; - } else { - LogTrace("L1TGlobal") << "\n SingleCombInCond (*it0Comb).size() " << ((*it0Comb).size()) << std::endl; + if (it0Comb.empty()) { + LogTrace("L1TGlobal") << "\n SingleCombWithBxInCond it0Comb.size() " << it0Comb.size(); return false; } + auto const cond0bx = it0Comb[0].first; + auto const obj0Index = it0Comb[0].second; + // FIRST OBJECT: Collect the information on the first leg of the correlation if (cond0Categ == CondMuon) { lutObj0 = "MU"; candMuVec = m_uGtB->getCandL1Mu(); - phiIndex0 = (candMuVec->at(cond0bx, obj0Index))->hwPhiAtVtx(); - etaIndex0 = (candMuVec->at(cond0bx, obj0Index))->hwEtaAtVtx(); - etIndex0 = (candMuVec->at(cond0bx, obj0Index))->hwPt(); - chrg0 = (candMuVec->at(cond0bx, obj0Index))->hwCharge(); + auto const* mu0 = candMuVec->at(cond0bx, obj0Index); + phiIndex0 = mu0->hwPhiAtVtx(); + etaIndex0 = mu0->hwEtaAtVtx(); + etIndex0 = mu0->hwPt(); + chrg0 = mu0->hwCharge(); etaBin0 = etaIndex0; if (etaBin0 < 0) @@ -340,18 +336,17 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons } // SECOND OBJECT: Now loop over the second leg to get its information - for (std::vector::const_iterator it1Comb = cond1Comb.begin(); it1Comb != cond1Comb.end(); - it1Comb++) { + for (auto const& it1Comb : cond1Comb) { LogDebug("L1TGlobal") << "Looking at second subcondition" << std::endl; - int obj1Index = -1; - if (!(*it1Comb).empty()) { - obj1Index = (*it1Comb)[0]; - } else { - LogTrace("L1TGlobal") << "\n SingleCombInCond (*it1Comb).size() " << ((*it1Comb).size()) << std::endl; + if (it1Comb.empty()) { + LogTrace("L1TGlobal") << "\n SingleCombWithBxInCond it1Comb.size() " << it1Comb.size(); return false; } + auto const cond1bx = it1Comb[0].first; + auto const obj1Index = it1Comb[0].second; + // If we are dealing with the same object type avoid the two legs either being the same object if (cndObjTypeVec[0] == cndObjTypeVec[1] && obj0Index == obj1Index && cond0bx == cond1bx) { LogDebug("L1TGlobal") << "Corr Condition looking at same leg...skip" << std::endl; @@ -361,10 +356,11 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons if (cond1Categ == CondMuon) { lutObj1 = "MU"; candMuVec = m_uGtB->getCandL1Mu(); - phiIndex1 = (candMuVec->at(cond1bx, obj1Index))->hwPhiAtVtx(); - etaIndex1 = (candMuVec->at(cond1bx, obj1Index))->hwEtaAtVtx(); - etIndex1 = (candMuVec->at(cond1bx, obj1Index))->hwPt(); - chrg1 = (candMuVec->at(cond1bx, obj1Index))->hwCharge(); + auto const* mu1 = candMuVec->at(cond1bx, obj1Index); + phiIndex1 = mu1->hwPhiAtVtx(); + etaIndex1 = mu1->hwEtaAtVtx(); + etIndex1 = mu1->hwPt(); + chrg1 = mu1->hwCharge(); etaBin1 = etaIndex1; if (etaBin1 < 0) @@ -392,18 +388,17 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons } // THIRD OBJECT: Finally loop over the third leg to get its information - for (std::vector::const_iterator it2Comb = cond2Comb.begin(); it2Comb != cond2Comb.end(); - it2Comb++) { + for (auto const& it2Comb : cond2Comb) { LogDebug("L1TGlobal") << "Looking at the third object for the three-body condition" << std::endl; - int obj2Index = -1; - if (!(*it2Comb).empty()) { - obj2Index = (*it2Comb)[0]; - } else { - LogTrace("L1TGlobal") << "\n SingleCombInCond (*it2Comb).size() " << ((*it2Comb).size()) << std::endl; + if (it2Comb.empty()) { + LogTrace("L1TGlobal") << "\n SingleCombWithBxInCond it2Comb.size() " << it2Comb.size(); return false; } + auto const cond2bx = it2Comb[0].first; + auto const obj2Index = it2Comb[0].second; + // If we are dealing with the same object type avoid the two legs // either being the same object if ((cndObjTypeVec[0] == cndObjTypeVec[2] && obj0Index == obj2Index && cond0bx == cond2bx) || @@ -415,10 +410,11 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons if (cond2Categ == CondMuon) { lutObj2 = "MU"; candMuVec = m_uGtB->getCandL1Mu(); - phiIndex2 = (candMuVec->at(cond2bx, obj2Index))->hwPhiAtVtx(); - etaIndex2 = (candMuVec->at(cond2bx, obj2Index))->hwEtaAtVtx(); - etIndex2 = (candMuVec->at(cond2bx, obj2Index))->hwPt(); - chrg2 = (candMuVec->at(cond2bx, obj2Index))->hwCharge(); + auto const* mu2 = candMuVec->at(cond2bx, obj2Index); + phiIndex2 = mu2->hwPhiAtVtx(); + etaIndex2 = mu2->hwEtaAtVtx(); + etIndex2 = mu2->hwPt(); + chrg2 = mu2->hwCharge(); etaBin2 = etaIndex2; if (etaBin2 < 0) @@ -487,9 +483,9 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons // Clear the vector containing indices of the objects of the combination involved in the condition evaluation objectsInComb.clear(); - objectsInComb.push_back(obj0Index); - objectsInComb.push_back(obj1Index); - objectsInComb.push_back(obj2Index); + objectsInComb.emplace_back(cond0bx, obj0Index); + objectsInComb.emplace_back(cond1bx, obj1Index); + objectsInComb.emplace_back(cond2bx, obj2Index); // Delta eta and phi calculations needed to evaluate the three-body invariant mass double deltaPhiPhy_01 = fabs(phi1Phy - phi0Phy); diff --git a/L1Trigger/L1TGlobal/src/CorrWithOverlapRemovalCondition.cc b/L1Trigger/L1TGlobal/src/CorrWithOverlapRemovalCondition.cc index 5c26f8a51cdfe..7fd7283505e70 100644 --- a/L1Trigger/L1TGlobal/src/CorrWithOverlapRemovalCondition.cc +++ b/L1Trigger/L1TGlobal/src/CorrWithOverlapRemovalCondition.cc @@ -175,13 +175,9 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE const EnergySumTemplate* corrEnergySum = nullptr; // FIXME copying is slow... - CombinationsInCond cond0Comb; - CombinationsInCond cond1Comb; - CombinationsInCond cond2Comb; - - int cond0bx(0); - int cond1bx(0); - int cond2bx(0); + CombinationsWithBxInCond cond0Comb{}; + CombinationsWithBxInCond cond1Comb{}; + CombinationsWithBxInCond cond2Comb{}; switch (cond0Categ) { case CondMuon: { @@ -193,7 +189,6 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE reqObjResult = muCondition.condLastResult(); cond0Comb = (muCondition.getCombinationsInCond()); - cond0bx = bxEval + (corrMuon->condRelativeBx()); cndObjTypeVec[0] = (corrMuon->objectType())[0]; @@ -213,8 +208,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE caloCondition.evaluateConditionStoreResult(bxEval); reqObjResult = caloCondition.condLastResult(); - cond0Comb = (caloCondition.getCombinationsInCond()); - cond0bx = bxEval + (corrCalo->condRelativeBx()); + cond0Comb = caloCondition.getCombinationsInCond(); cndObjTypeVec[0] = (corrCalo->objectType())[0]; @@ -232,8 +226,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE eSumCondition.evaluateConditionStoreResult(bxEval); reqObjResult = eSumCondition.condLastResult(); - cond0Comb = (eSumCondition.getCombinationsInCond()); - cond0bx = bxEval + (corrEnergySum->condRelativeBx()); + cond0Comb = eSumCondition.getCombinationsInCond(); cndObjTypeVec[0] = (corrEnergySum->objectType())[0]; @@ -267,8 +260,8 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE muCondition.evaluateConditionStoreResult(bxEval); reqObjResult = muCondition.condLastResult(); - cond1Comb = (muCondition.getCombinationsInCond()); - cond1bx = bxEval + (corrMuon->condRelativeBx()); + cond1Comb = muCondition.getCombinationsInCond(); + cndObjTypeVec[1] = (corrMuon->objectType())[0]; if (m_verbosity) { @@ -286,8 +279,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE caloCondition.evaluateConditionStoreResult(bxEval); reqObjResult = caloCondition.condLastResult(); - cond1Comb = (caloCondition.getCombinationsInCond()); - cond1bx = bxEval + (corrCalo->condRelativeBx()); + cond1Comb = caloCondition.getCombinationsInCond(); cndObjTypeVec[1] = (corrCalo->objectType())[0]; @@ -307,8 +299,8 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE eSumCondition.evaluateConditionStoreResult(bxEval); reqObjResult = eSumCondition.condLastResult(); - cond1Comb = (eSumCondition.getCombinationsInCond()); - cond1bx = bxEval + (corrEnergySum->condRelativeBx()); + cond1Comb = eSumCondition.getCombinationsInCond(); + cndObjTypeVec[1] = (corrEnergySum->objectType())[0]; if (m_verbosity) { @@ -344,8 +336,8 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE muCondition.evaluateConditionStoreResult(bxEval); reqObjResult = muCondition.condLastResult(); - cond2Comb = (muCondition.getCombinationsInCond()); - cond2bx = bxEval + (corrMuon->condRelativeBx()); + cond2Comb = muCondition.getCombinationsInCond(); + cndObjTypeVec[2] = (corrMuon->objectType())[0]; if (m_verbosity) { @@ -363,8 +355,8 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE caloCondition.evaluateConditionStoreResult(bxEval); reqObjResult = caloCondition.condLastResult(); - cond2Comb = (caloCondition.getCombinationsInCond()); - cond2bx = bxEval + (corrCalo->condRelativeBx()); + cond2Comb = caloCondition.getCombinationsInCond(); + cndObjTypeVec[2] = (corrCalo->objectType())[0]; if (m_verbosity) { @@ -383,8 +375,8 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE eSumCondition.evaluateConditionStoreResult(bxEval); reqObjResult = eSumCondition.condLastResult(); - cond2Comb = (eSumCondition.getCombinationsInCond()); - cond2bx = bxEval + (corrEnergySum->condRelativeBx()); + cond2Comb = eSumCondition.getCombinationsInCond(); + cndObjTypeVec[2] = (corrEnergySum->objectType())[0]; if (m_verbosity) { @@ -420,7 +412,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE // vector to store the indices of the calorimeter objects // from the combination evaluated in the condition - SingleCombInCond objectsInComb; + SingleCombWithBxInCond objectsInComb; objectsInComb.reserve(nObjInCond); // clear the m_combinationsInCond vector @@ -500,28 +492,27 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE // BLW: Optimization issue: potentially making the same comparison twice // if both legs are the same object type. // /////////////////////////////////////////////////////////////////////////////////////////// - for (std::vector::const_iterator it0Comb = cond0Comb.begin(); it0Comb != cond0Comb.end(); - it0Comb++) { - // Type1s: there is 1 object only, no need for a loop, index 0 should be OK in (*it0Comb)[0] + for (auto const& it0Comb : cond0Comb) { + // Type1s: there is 1 object only, no need for a loop, index 0 should be OK in it0Comb[0] // ... but add protection to not crash - int obj0Index = -1; - - if (!(*it0Comb).empty()) { - obj0Index = (*it0Comb)[0]; - } else { - LogTrace("L1TGlobal") << "\n SingleCombInCond (*it0Comb).size() " << ((*it0Comb).size()) << std::endl; + if (it0Comb.empty()) { + LogTrace("L1TGlobal") << "\n SingleCombWithBxCond it0Comb.size() " << it0Comb.size(); return false; } + auto const cond0bx = it0Comb[0].first; + auto const obj0Index = it0Comb[0].second; + // Collect the information on the first leg of the correlation switch (cond0Categ) { case CondMuon: { lutObj0 = "MU"; candMuVec = m_uGtB->getCandL1Mu(); - phiIndex0 = (candMuVec->at(cond0bx, obj0Index))->hwPhi(); //(*candMuVec)[obj0Index]->phiIndex(); - etaIndex0 = (candMuVec->at(cond0bx, obj0Index))->hwEta(); - etIndex0 = (candMuVec->at(cond0bx, obj0Index))->hwPt(); - chrg0 = (candMuVec->at(cond0bx, obj0Index))->hwCharge(); + auto const* mu0 = candMuVec->at(cond0bx, obj0Index); + phiIndex0 = mu0->hwPhi(); //mu0->phiIndex(); + etaIndex0 = mu0->hwEta(); + etIndex0 = mu0->hwPt(); + chrg0 = mu0->hwCharge(); int etaBin0 = etaIndex0; if (etaBin0 < 0) etaBin0 = m_gtScales->getMUScales().etaBins.size() + etaBin0; //twos complement @@ -792,20 +783,18 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE // /////////////////////////////////////////////////////////////////////////////////////////// // Now loop over the second leg to get its information // /////////////////////////////////////////////////////////////////////////////////////////// - for (std::vector::const_iterator it1Comb = cond1Comb.begin(); it1Comb != cond1Comb.end(); - it1Comb++) { + for (auto const& it1Comb : cond1Comb) { LogDebug("L1TGlobal") << "Looking at second Condition" << std::endl; - // Type1s: there is 1 object only, no need for a loop (*it1Comb)[0] + // Type1s: there is 1 object only, no need for a loop it1Comb[0] // ... but add protection to not crash - int obj1Index = -1; - - if (!(*it1Comb).empty()) { - obj1Index = (*it1Comb)[0]; - } else { - LogTrace("L1TGlobal") << "\n SingleCombInCond (*it1Comb).size() " << ((*it1Comb).size()) << std::endl; + if (it1Comb.empty()) { + LogTrace("L1TGlobal") << "\n SingleCombWithBxCond it1Comb.size() " << it1Comb.size(); return false; } + auto const cond1bx = it1Comb[0].first; + auto const obj1Index = it1Comb[0].second; + //If we are dealing with the same object type avoid the two legs // either being the same object if (cndObjTypeVec[0] == cndObjTypeVec[1] && obj0Index == obj1Index && cond0bx == cond1bx) { @@ -1422,19 +1411,17 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE // /////////////////////////////////////////////////////////////////////////////////////////// // loop over overlap-removal leg combination which produced individually "true" as Type1s // /////////////////////////////////////////////////////////////////////////////////////////// - for (std::vector::const_iterator it2Comb = cond2Comb.begin(); it2Comb != cond2Comb.end(); - it2Comb++) { - // Type1s: there is 1 object only, no need for a loop, index 0 should be OK in (*it2Comb)[0] + for (auto const& it2Comb : cond2Comb) { + // Type1s: there is 1 object only, no need for a loop, index 0 should be OK in it2Comb[0] // ... but add protection to not crash - int obj2Index = -1; - - if (!(*it2Comb).empty()) { - obj2Index = (*it2Comb)[0]; - } else { - LogTrace("L1TGlobal") << "\n SingleCombInCond (*it2Comb).size() " << ((*it2Comb).size()) << std::endl; + if (it2Comb.empty()) { + LogTrace("L1TGlobal") << "\n SingleCombWithBxCond it2Comb.size() " << it2Comb.size(); return false; } + auto const cond2bx = it2Comb[0].first; + auto const obj2Index = it2Comb[0].second; + // Collect the information on the overlap-removal leg switch (cond2Categ) { case CondMuon: { @@ -1898,10 +1885,9 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE // clear the indices in the combination objectsInComb.clear(); - - objectsInComb.push_back(obj0Index); - objectsInComb.push_back(obj1Index); - objectsInComb.push_back(obj2Index); + objectsInComb.emplace_back(cond0bx, obj0Index); + objectsInComb.emplace_back(cond1bx, obj1Index); + objectsInComb.emplace_back(cond2bx, obj2Index); (combinationsInCond()).push_back(objectsInComb); diff --git a/L1Trigger/L1TGlobal/src/EnergySumCondition.cc b/L1Trigger/L1TGlobal/src/EnergySumCondition.cc index 8ab5561ed1296..37f10aba7f0bb 100644 --- a/L1Trigger/L1TGlobal/src/EnergySumCondition.cc +++ b/L1Trigger/L1TGlobal/src/EnergySumCondition.cc @@ -95,7 +95,7 @@ const bool l1t::EnergySumCondition::evaluateCondition(const int bxEval) const { // store the indices of the calorimeter objects // from the combination evaluated in the condition - SingleCombInCond objectsInComb; + SingleCombWithBxInCond objectsInComb; // clear the m_combinationsInCond vector (combinationsInCond()).clear(); @@ -106,7 +106,7 @@ const bool l1t::EnergySumCondition::evaluateCondition(const int bxEval) const { const BXVector* candVec = m_uGtB->getCandL1EtSum(); // Look at objects in bx = bx + relativeBx - int useBx = bxEval + m_gtEnergySumTemplate->condRelativeBx(); + L1TObjBxIndexType const useBx = bxEval + m_gtEnergySumTemplate->condRelativeBx(); // Fail condition if attempting to get Bx outside of range if ((useBx < candVec->getFirstBX()) || (useBx > candVec->getLastBX())) { @@ -247,9 +247,10 @@ const bool l1t::EnergySumCondition::evaluateCondition(const int bxEval) const { // get energy, phi (ETM and HTM) and overflow for the trigger object unsigned int candEt = 0; unsigned int candPhi = 0; + bool candOverflow = false; for (int iEtSum = 0; iEtSum < numberObjects; ++iEtSum) { - l1t::EtSum cand = *(candVec->at(useBx, iEtSum)); + auto const& cand = *(candVec->at(useBx, iEtSum)); if (cand.getType() != type) continue; candEt = cand.hwPt(); @@ -302,9 +303,7 @@ const bool l1t::EnergySumCondition::evaluateCondition(const int bxEval) const { } // index is always zero, as they are global quantities (there is only one object) - int indexObj = 0; - - objectsInComb.push_back(indexObj); + objectsInComb.emplace_back(useBx, 0); (combinationsInCond()).push_back(objectsInComb); // if we get here all checks were successfull for this combination diff --git a/L1Trigger/L1TGlobal/src/EnergySumZdcCondition.cc b/L1Trigger/L1TGlobal/src/EnergySumZdcCondition.cc index 52a6bdcc9e392..07b3ad5152af1 100644 --- a/L1Trigger/L1TGlobal/src/EnergySumZdcCondition.cc +++ b/L1Trigger/L1TGlobal/src/EnergySumZdcCondition.cc @@ -96,7 +96,7 @@ const bool l1t::EnergySumZdcCondition::evaluateCondition(const int bxEval) const // store the indices of the calorimeter objects // from the combination evaluated in the condition - SingleCombInCond objectsInComb; + SingleCombWithBxInCond objectsInComb; // clear the m_combinationsInCond vector (combinationsInCond()).clear(); @@ -107,7 +107,7 @@ const bool l1t::EnergySumZdcCondition::evaluateCondition(const int bxEval) const const BXVector* candVecZdc = m_uGtB->getCandL1EtSumZdc(); // Look at objects in bx = bx + relativeBx - int useBx = bxEval + m_gtEnergySumZdcTemplate->condRelativeBx(); + L1TObjBxIndexType const useBx = bxEval + m_gtEnergySumZdcTemplate->condRelativeBx(); // Fail condition if attempting to get Bx outside of range if ((useBx < candVecZdc->getFirstBX()) || (useBx > candVecZdc->getLastBX())) { @@ -116,7 +116,6 @@ const bool l1t::EnergySumZdcCondition::evaluateCondition(const int bxEval) const // If no candidates, no use looking any further int numberObjectsZdc = candVecZdc->size(useBx); - if (numberObjectsZdc < 1) { return false; } @@ -150,7 +149,7 @@ const bool l1t::EnergySumZdcCondition::evaluateCondition(const int bxEval) const bool myres = false; for (int iEtSum = 0; iEtSum < numberObjectsZdc; ++iEtSum) { - l1t::EtSum candZdc = *(candVecZdc->at(useBx, iEtSum)); + auto const& candZdc = *(candVecZdc->at(useBx, iEtSum)); if (candZdc.getType() != type) continue; @@ -182,9 +181,7 @@ const bool l1t::EnergySumZdcCondition::evaluateCondition(const int bxEval) const return false; // index is always zero, as they are global quantities (there is only one object) - int indexObj = 0; - - objectsInComb.push_back(indexObj); + objectsInComb.emplace_back(useBx, 0); (combinationsInCond()).push_back(objectsInComb); // if we get here all checks were successful for this combination diff --git a/L1Trigger/L1TGlobal/src/ExternalCondition.cc b/L1Trigger/L1TGlobal/src/ExternalCondition.cc index d8cbfba71937d..0695e8c066d9f 100644 --- a/L1Trigger/L1TGlobal/src/ExternalCondition.cc +++ b/L1Trigger/L1TGlobal/src/ExternalCondition.cc @@ -100,7 +100,7 @@ const bool l1t::ExternalCondition::evaluateCondition(const int bxEval) const { // store the indices of the calorimeter objects // from the combination evaluated in the condition - SingleCombInCond objectsInComb; + SingleCombWithBxInCond objectsInComb; // clear the m_combinationsInCond vector (combinationsInCond()).clear(); @@ -111,34 +111,32 @@ const bool l1t::ExternalCondition::evaluateCondition(const int bxEval) const { const BXVector* candVec = m_uGtB->getCandL1External(); // Look at objects in bx = bx + relativeBx - int useBx = bxEval + m_gtExternalTemplate->condRelativeBx(); - unsigned int exCondCh = m_gtExternalTemplate->extChannel(); + L1TObjBxIndexType const useBx = bxEval + m_gtExternalTemplate->condRelativeBx(); // Fail condition if attempting to get Bx outside of range if ((useBx < candVec->getFirstBX()) || (useBx > candVec->getLastBX())) { return false; } - int numberObjects = candVec->size(useBx); + auto const numberObjects = candVec->size(useBx); if (numberObjects < 1) { return false; } //get external block (should only be one for the bx) - GlobalExtBlk ext = *(candVec->at(useBx, 0)); + unsigned int const candIndex{0u}; + GlobalExtBlk const& ext = *(candVec->at(useBx, candIndex)); //ext.print(std::cout); // check external bit + unsigned int exCondCh = m_gtExternalTemplate->extChannel(); if (!ext.getExternalDecision(exCondCh)) { LogDebug("L1TGlobal") << "\t\t External Condition was not set" << std::endl; return false; } - // index is always zero, as they are global quantities (there is only one object) - int indexObj = 0; - - //Do we need this? - objectsInComb.push_back(indexObj); + // Do we need this? + objectsInComb.emplace_back(useBx, candIndex); (combinationsInCond()).push_back(objectsInComb); // if we get here all checks were successfull for this combination diff --git a/L1Trigger/L1TGlobal/src/MuCondition.cc b/L1Trigger/L1TGlobal/src/MuCondition.cc index 279043bb20b68..541d1eff96f2f 100644 --- a/L1Trigger/L1TGlobal/src/MuCondition.cc +++ b/L1Trigger/L1TGlobal/src/MuCondition.cc @@ -111,7 +111,7 @@ const bool l1t::MuCondition::evaluateCondition(const int bxEval) const { const BXVector* candVec = m_gtGTL->getCandL1Mu(); //BLW Change for BXVector // Look at objects in bx = bx + relativeBx - int useBx = bxEval + m_gtMuonTemplate->condRelativeBx(); + L1TObjBxIndexType const useBx = bxEval + m_gtMuonTemplate->condRelativeBx(); // Fail condition if attempting to get Bx outside of range if ((useBx < candVec->getFirstBX()) || (useBx > candVec->getLastBX())) { @@ -148,7 +148,7 @@ const bool l1t::MuCondition::evaluateCondition(const int bxEval) const { // store the indices of the muon objects // from the combination evaluated in the condition - SingleCombInCond objectsInComb; + SingleCombWithBxInCond objectsInComb; objectsInComb.reserve(nObjInCond); // clear the m_combinationsInCond vector @@ -176,7 +176,7 @@ const bool l1t::MuCondition::evaluateCondition(const int bxEval) const { else LogDebug("L1TGlobal") << "===> MuCondition::evaluateCondition, FAIL!! This muon failed the condition." << std::endl; - objectsInComb.push_back(index[i]); + objectsInComb.emplace_back(useBx, index[i]); } // if permutation does not match particle conditions @@ -304,7 +304,7 @@ const bool l1t::MuCondition::evaluateCondition(const int bxEval) const { // set the general result for evaluateCondition to "true" condResult = true; - (combinationsInCond()).push_back(objectsInComb); + combinationsInCond().push_back(objectsInComb); } while (std::next_permutation(index.begin(), index.end())); diff --git a/L1Trigger/L1TGlobal/src/MuonShowerCondition.cc b/L1Trigger/L1TGlobal/src/MuonShowerCondition.cc index 26ae269e344d2..32656fb56a277 100644 --- a/L1Trigger/L1TGlobal/src/MuonShowerCondition.cc +++ b/L1Trigger/L1TGlobal/src/MuonShowerCondition.cc @@ -102,7 +102,7 @@ const bool l1t::MuonShowerCondition::evaluateCondition(const int bxEval) const { const BXVector>* candVec = m_gtGTL->getCandL1MuShower(); // Look at objects in BX = BX + relativeBX - int useBx = bxEval + m_gtMuonShowerTemplate->condRelativeBx(); + L1TObjBxIndexType const useBx = bxEval + m_gtMuonShowerTemplate->condRelativeBx(); LogDebug("MuonShowerCondition") << "Considering BX " << useBx << std::endl; // Fail condition if attempting to get BX outside of range @@ -111,7 +111,7 @@ const bool l1t::MuonShowerCondition::evaluateCondition(const int bxEval) const { } // Store the indices of the shower objects from the combination evaluated in the condition - SingleCombInCond objectsInComb; + SingleCombWithBxInCond objectsInComb; objectsInComb.reserve(nObjInCond); // Clear the m_combinationsInCond vector @@ -144,7 +144,7 @@ const bool l1t::MuonShowerCondition::evaluateCondition(const int bxEval) const { if (passCondition) { LogDebug("MuonShowerCondition") << "===> MuShowerCondition::evaluateCondition, PASS! This muon shower passed the condition." << std::endl; - objectsInComb.push_back(indexObj); + objectsInComb.emplace_back(useBx, indexObj); } else LogDebug("MuonShowerCondition") << "===> MuShowerCondition::evaluateCondition, FAIL! This muon shower failed the condition." << std::endl;