From 052da05e039bc8c38343324de6a95a90e1095fae 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 | 74 ++- .../L1TGlobal/interface/GlobalObjectMapFwd.h | 28 +- DataFormats/L1TGlobal/src/GlobalObjectMap.cc | 85 ++- DataFormats/L1TGlobal/src/classes_def.xml | 3 +- .../test/TestGlobalObjectMapRecordFormat.sh | 16 +- .../test/TestReadGlobalObjectMapRecord.cc | 38 +- .../test/TestWriteGlobalObjectMapRecord.cc | 23 +- ...ate_GlobalObjectMapRecord_test_file_cfg.py | 12 +- .../test_readGlobalObjectMapRecord_cfg.py | 22 +- HLTrigger/HLTfilters/plugins/HLTL1TSeed.cc | 565 ++++++++---------- HLTrigger/HLTfilters/plugins/HLTL1TSeed.h | 6 +- .../L1TGlobal/interface/AlgorithmEvaluation.h | 7 +- .../L1TGlobal/interface/ConditionEvaluation.h | 6 +- .../L1TGlobal/src/AlgorithmEvaluation.cc | 11 +- L1Trigger/L1TGlobal/src/CaloCondition.cc | 24 +- .../L1TGlobal/src/ConditionEvaluation.cc | 33 +- L1Trigger/L1TGlobal/src/CorrCondition.cc | 200 +++---- .../L1TGlobal/src/CorrThreeBodyCondition.cc | 192 +++--- .../src/CorrWithOverlapRemovalCondition.cc | 325 +++++----- L1Trigger/L1TGlobal/src/EnergySumCondition.cc | 17 +- .../L1TGlobal/src/EnergySumZdcCondition.cc | 22 +- L1Trigger/L1TGlobal/src/ExternalCondition.cc | 24 +- L1Trigger/L1TGlobal/src/GlobalBoard.cc | 3 +- L1Trigger/L1TGlobal/src/MuCondition.cc | 15 +- .../L1TGlobal/src/MuonShowerCondition.cc | 44 +- 25 files changed, 865 insertions(+), 930 deletions(-) diff --git a/DataFormats/L1TGlobal/interface/GlobalObjectMap.h b/DataFormats/L1TGlobal/interface/GlobalObjectMap.h index 50a597b1187ff..f2b069a4b0aec 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,47 @@ 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& combinationBxVector() const { return m_combinationBxVector; } inline const std::vector& combinationVector() const { return m_combinationVector; } - void setCombinationVector(const std::vector& combinationVectorValue) { - m_combinationVector = combinationVectorValue; + void clearCombinationVectors() { + m_combinationBxVector.clear(); + m_combinationVector.clear(); } - void swapCombinationVector(std::vector& combinationVectorValue) { - m_combinationVector.swap(combinationVectorValue); + + void reserveCombinationVectors(size_t const size) { + m_combinationBxVector.reserve(size); + m_combinationVector.reserve(size); + } + + void appendToCombinationVectors(CombinationsWithBxInCond const& c0) { + CombinationsBxInCond a1; + a1.reserve(c0.size()); + CombinationsInCond b1; + b1.reserve(c0.size()); + for (auto const& c1 : c0) { + SingleCombBxInCond a2; + a2.reserve(c1.size()); + SingleCombInCond b2; + b2.reserve(c1.size()); + for (auto const& c2 : c1) { + a2.emplace_back(c2.first); + b2.emplace_back(c2.second); + } + a1.emplace_back(a2); + b1.emplace_back(b2); + } + + m_combinationBxVector.emplace_back(a1); + m_combinationVector.emplace_back(b1); + } + + void setCombinationVectors(std::vector const& combinationWithBxInCondVector) { + clearCombinationVectors(); + reserveCombinationVectors(combinationWithBxInCondVector.size()); + for (auto const& foo : combinationWithBxInCondVector) { + appendToCombinationVectors(foo); + } } /// get / set the vector of operand tokens @@ -79,6 +102,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; } @@ -87,15 +111,24 @@ class GlobalObjectMap { } public: - /// return all the combinations passing the requirements imposed in condition condNameVal + /// return the bx values of all the combinations passing the requirements imposed in condition condNameVal + const CombinationsBxInCond* getCombinationsBxInCond(const std::string& condNameVal) const; + + /// return the bx values of all the combinations passing the requirements imposed in condition condNumberVal + const CombinationsBxInCond* getCombinationsBxInCond(const int condNumberVal) const; + + /// return the indices of all the combinations passing the requirements imposed in condition condNameVal const CombinationsInCond* getCombinationsInCond(const std::string& condNameVal) const; - /// return all the combinations passing the requirements imposed in condition condNumberVal + /// return the indices of all the combinations passing the requirements imposed in condition condNumberVal const CombinationsInCond* getCombinationsInCond(const int condNumberVal) const; /// return the result for the condition condNameVal const bool getConditionResult(const std::string& condNameVal) const; + /// check whether or not m_combinationBxVector is empty + bool hasBxInfo() const { return (not m_combinationBxVector.empty()); } + public: /// reset the object map void reset(); @@ -118,10 +151,11 @@ class GlobalObjectMap { std::vector m_operandTokenVector; // vector of combinations for all conditions in an algorithm + std::vector m_combinationBxVector; std::vector m_combinationVector; // 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..861c325c041d9 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,27 @@ // forward declarations /// typedefs +typedef int16_t L1TObjBxIndexType; +typedef int L1TObjIndexType; + +/// list of object BX values corresponding to a condition evaluated to true +typedef std::vector SingleCombBxInCond; /// list of object indices corresponding to a condition evaluated to true -typedef std::vector SingleCombInCond; +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 +/// all the object combinations evaluated to true in the condition (object BX indices) +typedef std::vector CombinationsBxInCond; + +/// all the object combinations evaluated to true in the condition (object indices) 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/src/GlobalObjectMap.cc b/DataFormats/L1TGlobal/src/GlobalObjectMap.cc index 237e4a5c45459..5ba45fd49a59c 100644 --- a/DataFormats/L1TGlobal/src/GlobalObjectMap.cc +++ b/DataFormats/L1TGlobal/src/GlobalObjectMap.cc @@ -12,24 +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" +/// return the bx values of all the combinations passing the requirements imposed in condition condNameVal +const CombinationsBxInCond* GlobalObjectMap::getCombinationsBxInCond(const std::string& condNameVal) const { + for (size_t i = 0; i < m_operandTokenVector.size(); ++i) { + if ((m_operandTokenVector[i]).tokenName == condNameVal) { + return &(m_combinationBxVector.at((m_operandTokenVector[i]).tokenNumber)); + } + } -// forward declarations + // 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 getCombinationsBxInCond\n\n"; -// methods + return nullptr; +} -// return all the combinations passing the requirements imposed in condition condNameVal +/// return the bx values of all the combinations passing the requirements imposed in condition condNumberVal +const CombinationsBxInCond* GlobalObjectMap::getCombinationsBxInCond(const int condNumberVal) const { + for (size_t i = 0; i < m_operandTokenVector.size(); ++i) { + if ((m_operandTokenVector[i]).tokenNumber == condNumberVal) { + return &(m_combinationBxVector.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 getCombinationsBxInCond\n\n"; + + return nullptr; +} + +/// return the indices of all the combinations passing the requirements imposed in condition condNameVal const CombinationsInCond* GlobalObjectMap::getCombinationsInCond(const std::string& condNameVal) const { for (size_t i = 0; i < m_operandTokenVector.size(); ++i) { if ((m_operandTokenVector[i]).tokenName == condNameVal) { @@ -40,13 +63,12 @@ const CombinationsInCond* GlobalObjectMap::getCombinationsInCond(const std::stri // 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 +/// return the indices of all the combinations passing the requirements imposed in condition condNumberVal const CombinationsInCond* GlobalObjectMap::getCombinationsInCond(const int condNumberVal) const { for (size_t i = 0; i < m_operandTokenVector.size(); ++i) { if ((m_operandTokenVector[i]).tokenNumber == condNumberVal) { @@ -57,12 +79,12 @@ const CombinationsInCond* GlobalObjectMap::getCombinationsInCond(const int condN // 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 +95,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; } @@ -91,8 +113,8 @@ void GlobalObjectMap::reset() { // vector of operand tokens for an algorithm m_operandTokenVector.clear(); - // vector of combinations for all conditions in an algorithm - m_combinationVector.clear(); + // vectors of bx/index combinations for all conditions in an algorithm + clearCombinationVectors(); } void GlobalObjectMap::print(std::ostream& myCout) const { @@ -117,35 +139,32 @@ void GlobalObjectMap::print(std::ostream& myCout) const { } } + myCout << " CombinationBxVector size: " << m_combinationBxVector.size() << std::endl; myCout << " CombinationVector size: " << m_combinationVector.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_combinationVector.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_combinationVector[i1].empty()) { myCout << "(none)"; } else { - CombinationsInCond::const_iterator itVV; - for (itVV = (*itVVV).begin(); itVV != (*itVVV).end(); itVV++) { + for (size_t i2 = 0; i2 < m_combinationVector[i1].size(); ++i2) { myCout << "( "; - - std::copy((*itVV).begin(), (*itVV).end(), std::ostream_iterator(myCout, " ")); - + for (size_t i3 = 0; i3 < m_combinationVector[i1][i2].size(); ++i3) { + if (hasBxInfo()) { + myCout << m_combinationBxVector[i1][i2][i3] << ":"; + } + myCout << m_combinationVector[i1][i2][i3] << " "; + } myCout << "); "; } } - iCond++; myCout << "\n\n"; } } diff --git a/DataFormats/L1TGlobal/src/classes_def.xml b/DataFormats/L1TGlobal/src/classes_def.xml index b1df5c7316978..6726d46e7ea00 100644 --- a/DataFormats/L1TGlobal/src/classes_def.xml +++ b/DataFormats/L1TGlobal/src/classes_def.xml @@ -31,7 +31,8 @@ - + + 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..bb7fb68c0423a 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() || @@ -91,6 +94,12 @@ namespace edmtest { "expectedTokenNames3_, expectedTokenNumbers3_, and expectedTokenResults3_ " "should have the same size."; } + + if (globalObjectMapClassVersion_ < 10) { + throw cms::Exception("TestFailure") + << "TestWriteGlobalObjectMapRecord, invalid value for globalObjectMapClassVersion: " + << globalObjectMapClassVersion_; + } } void TestReadGlobalObjectMapRecord::analyze(edm::StreamID, edm::Event const& iEvent, edm::EventSetup const&) const { @@ -139,17 +148,36 @@ namespace edmtest { for (auto const& singleCombInCond : combinationsInCond) { for (auto const& value : singleCombInCond) { if (value != expectedValue) { - throwWithMessage("element in inner combination vector does have expected value"); + throwWithMessage("element in inner combination vector does not have expected value"); } expectedValue += expectedElementDelta_; } } } + if (globalObjectMapClassVersion_ == 10) { + if (globalObjectMap.hasBxInfo()) { + throwWithMessage("GlobalObjectMap objects with classClassVersion=10 cannot have BX information"); + } + } else { + uint bxCounter = 0; + for (auto const& combinationsBxInCond : globalObjectMap.combinationBxVector()) { + for (auto const& singleCombBxInCond : combinationsBxInCond) { + for (auto const& value : singleCombBxInCond) { + L1TObjBxIndexType const expectedValue = bxCounter % expectedBxIndexModulus_; + if (value != expectedValue) { + throwWithMessage("element in inner combination-bx vector does not have expected value"); + } + ++bxCounter; + } + } + } + } + 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 +209,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..1166df41c12bd 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,20 +123,26 @@ 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 combinationsWithBxInCondVector; + combinationsWithBxInCondVector.reserve(nElements1_); for (unsigned int i = 0; i < nElements1_; ++i) { - CombinationsInCond combinationsInCond; + CombinationsWithBxInCond combinationsWithBxInCond; + combinationsWithBxInCond.reserve(nElements2_); for (unsigned int j = 0; j < nElements2_; ++j) { - SingleCombInCond singleCombInCond; + SingleCombWithBxInCond singleCombWithBxInCond; + singleCombWithBxInCond.reserve(nElements3_); for (unsigned int k = 0; k < nElements3_; ++k) { - singleCombInCond.push_back(value); + L1TObjBxIndexType const bxIdx = bxCounter % bxIndexModulus_; + singleCombWithBxInCond.emplace_back(bxIdx, value); value += elementDelta_; + ++bxCounter; } - combinationsInCond.push_back(std::move(singleCombInCond)); + combinationsWithBxInCond.push_back(std::move(singleCombWithBxInCond)); } - combinationsInCondVector.push_back(combinationsInCond); + combinationsWithBxInCondVector.push_back(combinationsWithBxInCond); } - globalObjectMap.swapCombinationVector(combinationsInCondVector); + globalObjectMap.setCombinationVectors(combinationsWithBxInCondVector); std::vector objectTypeVector; for (unsigned int i = 0; i < nElements1_; ++i) { @@ -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..4e14ac578b7cd 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" @@ -26,8 +27,6 @@ #include "HLTL1TSeed.h" -using namespace std; - // constructors HLTL1TSeed::HLTL1TSeed(const edm::ParameterSet& parSet) : HLTStreamFilter(parSet), @@ -62,7 +61,7 @@ HLTL1TSeed::HLTL1TSeed(const edm::ParameterSet& parSet) m_l1GlobalDecision(false), m_isDebugEnabled(edm::isDebugEnabled()) { if (m_l1SeedsLogicalExpression.empty()) { - throw cms::Exception("FailModule") << "\nTrying to seed with an empty L1SeedsLogicalExpression.\n" << std::endl; + throw cms::Exception("FailModule") << "\nTrying to seed with an empty L1SeedsLogicalExpression.\n"; } else if (m_l1SeedsLogicalExpression != "L1GlobalDecision") { // check also the logical expression - add/remove spaces if needed @@ -72,7 +71,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 +81,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); @@ -154,16 +146,15 @@ bool HLTL1TSeed::hltFilter(edm::Event& iEvent, // detailed print of filter content void HLTL1TSeed::dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWithRefs& filterproduct) const { LogTrace("HLTL1TSeed") << "\nHLTL1TSeed::hltFilter " - << "\n Dump TriggerFilterObjectWithRefs\n" - << endl; + << "\n Dump TriggerFilterObjectWithRefs\n"; - vector seedsL1Mu; + std::vector seedsL1Mu; filterproduct.getObjects(trigger::TriggerL1Mu, seedsL1Mu); const size_t sizeSeedsL1Mu = seedsL1Mu.size(); - LogTrace("HLTL1TSeed") << "\n HLTL1TSeed: seed logical expression = " << m_l1SeedsLogicalExpression << endl; + LogTrace("HLTL1TSeed") << "\n HLTL1TSeed: seed logical expression = " << m_l1SeedsLogicalExpression; - LogTrace("HLTL1TSeed") << "\n L1Mu seeds: " << sizeSeedsL1Mu << endl << endl; + LogTrace("HLTL1TSeed") << "\n L1Mu seeds: " << sizeSeedsL1Mu; for (size_t i = 0; i != sizeSeedsL1Mu; i++) { l1t::MuonRef obj = l1t::MuonRef(seedsL1Mu[i]); @@ -178,13 +169,13 @@ void HLTL1TSeed::dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWit << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx(); } - vector seedsL1MuShower; + std::vector seedsL1MuShower; filterproduct.getObjects(trigger::TriggerL1MuShower, seedsL1MuShower); const size_t sizeSeedsL1MuShower = seedsL1MuShower.size(); - LogTrace("HLTL1TSeed") << "\n HLTL1TSeed: seed logical expression = " << m_l1SeedsLogicalExpression << endl; + LogTrace("HLTL1TSeed") << "\n HLTL1TSeed: seed logical expression = " << m_l1SeedsLogicalExpression; - LogTrace("HLTL1TSeed") << "\n L1MuShower seeds: " << sizeSeedsL1MuShower << endl << endl; + LogTrace("HLTL1TSeed") << "\n L1MuShower seeds: " << sizeSeedsL1MuShower; for (size_t i = 0; i != sizeSeedsL1MuShower; i++) { l1t::MuonShowerRef obj = l1t::MuonShowerRef(seedsL1MuShower[i]); @@ -196,11 +187,11 @@ void HLTL1TSeed::dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWit << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx(); } - vector seedsL1EG; + std::vector seedsL1EG; filterproduct.getObjects(trigger::TriggerL1EG, seedsL1EG); const size_t sizeSeedsL1EG = seedsL1EG.size(); - LogTrace("HLTL1TSeed") << "\n L1EG seeds: " << sizeSeedsL1EG << endl << endl; + LogTrace("HLTL1TSeed") << "\n L1EG seeds: " << sizeSeedsL1EG; for (size_t i = 0; i != sizeSeedsL1EG; i++) { l1t::EGammaRef obj = l1t::EGammaRef(seedsL1EG[i]); @@ -212,11 +203,11 @@ void HLTL1TSeed::dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWit << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx(); } - vector seedsL1Jet; + std::vector seedsL1Jet; filterproduct.getObjects(trigger::TriggerL1Jet, seedsL1Jet); const size_t sizeSeedsL1Jet = seedsL1Jet.size(); - LogTrace("HLTL1TSeed") << "\n L1Jet seeds: " << sizeSeedsL1Jet << endl << endl; + LogTrace("HLTL1TSeed") << "\n L1Jet seeds: " << sizeSeedsL1Jet; for (size_t i = 0; i != sizeSeedsL1Jet; i++) { l1t::JetRef obj = l1t::JetRef(seedsL1Jet[i]); @@ -228,11 +219,11 @@ void HLTL1TSeed::dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWit << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx(); } - vector seedsL1Tau; + std::vector seedsL1Tau; filterproduct.getObjects(trigger::TriggerL1Tau, seedsL1Tau); const size_t sizeSeedsL1Tau = seedsL1Tau.size(); - LogTrace("HLTL1TSeed") << "\n L1Tau seeds: " << sizeSeedsL1Tau << endl << endl; + LogTrace("HLTL1TSeed") << "\n L1Tau seeds: " << sizeSeedsL1Tau; for (size_t i = 0; i != sizeSeedsL1Tau; i++) { l1t::TauRef obj = l1t::TauRef(seedsL1Tau[i]); @@ -244,10 +235,10 @@ void HLTL1TSeed::dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWit << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx(); } - vector seedsL1EtSumETT; + std::vector seedsL1EtSumETT; filterproduct.getObjects(trigger::TriggerL1ETT, seedsL1EtSumETT); const size_t sizeSeedsL1EtSumETT = seedsL1EtSumETT.size(); - LogTrace("HLTL1TSeed") << "\n L1EtSum ETT seeds: " << sizeSeedsL1EtSumETT << endl << endl; + LogTrace("HLTL1TSeed") << "\n L1EtSum ETT seeds: " << sizeSeedsL1EtSumETT; for (size_t i = 0; i != sizeSeedsL1EtSumETT; i++) { l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumETT[i]); @@ -259,10 +250,10 @@ void HLTL1TSeed::dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWit << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx(); } - vector seedsL1EtSumHTT; + std::vector seedsL1EtSumHTT; filterproduct.getObjects(trigger::TriggerL1HTT, seedsL1EtSumHTT); const size_t sizeSeedsL1EtSumHTT = seedsL1EtSumHTT.size(); - LogTrace("HLTL1TSeed") << "\n L1EtSum HTT seeds: " << sizeSeedsL1EtSumHTT << endl << endl; + LogTrace("HLTL1TSeed") << "\n L1EtSum HTT seeds: " << sizeSeedsL1EtSumHTT; for (size_t i = 0; i != sizeSeedsL1EtSumHTT; i++) { l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumHTT[i]); @@ -274,10 +265,10 @@ void HLTL1TSeed::dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWit << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx(); } - vector seedsL1EtSumETM; + std::vector seedsL1EtSumETM; filterproduct.getObjects(trigger::TriggerL1ETM, seedsL1EtSumETM); const size_t sizeSeedsL1EtSumETM = seedsL1EtSumETM.size(); - LogTrace("HLTL1TSeed") << "\n L1EtSum ETM seeds: " << sizeSeedsL1EtSumETM << endl << endl; + LogTrace("HLTL1TSeed") << "\n L1EtSum ETM seeds: " << sizeSeedsL1EtSumETM; for (size_t i = 0; i != sizeSeedsL1EtSumETM; i++) { l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumETM[i]); @@ -289,10 +280,10 @@ void HLTL1TSeed::dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWit << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx(); } - vector seedsL1EtSumETMHF; + std::vector seedsL1EtSumETMHF; filterproduct.getObjects(trigger::TriggerL1ETMHF, seedsL1EtSumETMHF); const size_t sizeSeedsL1EtSumETMHF = seedsL1EtSumETMHF.size(); - LogTrace("HLTL1TSeed") << "\n L1EtSum ETMHF seeds: " << sizeSeedsL1EtSumETMHF << endl << endl; + LogTrace("HLTL1TSeed") << "\n L1EtSum ETMHF seeds: " << sizeSeedsL1EtSumETMHF; for (size_t i = 0; i != sizeSeedsL1EtSumETMHF; i++) { l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumETMHF[i]); @@ -304,10 +295,10 @@ void HLTL1TSeed::dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWit << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx(); } - vector seedsL1EtSumHTMHF; + std::vector seedsL1EtSumHTMHF; filterproduct.getObjects(trigger::TriggerL1HTMHF, seedsL1EtSumHTMHF); const size_t sizeSeedsL1EtSumHTMHF = seedsL1EtSumHTMHF.size(); - LogTrace("HLTL1TSeed") << "\n L1EtSum HTMHF seeds: " << sizeSeedsL1EtSumHTMHF << endl << endl; + LogTrace("HLTL1TSeed") << "\n L1EtSum HTMHF seeds: " << sizeSeedsL1EtSumHTMHF; for (size_t i = 0; i != sizeSeedsL1EtSumHTMHF; i++) { l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumHTMHF[i]); @@ -319,10 +310,10 @@ void HLTL1TSeed::dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWit << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx(); } - vector seedsL1EtSumHTM; + std::vector seedsL1EtSumHTM; filterproduct.getObjects(trigger::TriggerL1HTM, seedsL1EtSumHTM); const size_t sizeSeedsL1EtSumHTM = seedsL1EtSumHTM.size(); - LogTrace("HLTL1TSeed") << "\n L1EtSum HTM seeds: " << sizeSeedsL1EtSumHTM << endl << endl; + LogTrace("HLTL1TSeed") << "\n L1EtSum HTM seeds: " << sizeSeedsL1EtSumHTM; for (size_t i = 0; i != sizeSeedsL1EtSumHTM; i++) { l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumHTM[i]); @@ -334,10 +325,10 @@ void HLTL1TSeed::dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWit << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx(); } - vector seedsL1EtSumCentrality; + std::vector seedsL1EtSumCentrality; filterproduct.getObjects(trigger::TriggerL1Centrality, seedsL1EtSumCentrality); const size_t sizeSeedsL1EtSumCentrality = seedsL1EtSumCentrality.size(); - LogTrace("HLTL1TSeed") << "\n L1EtSum Centrality seeds: " << sizeSeedsL1EtSumCentrality << endl << endl; + LogTrace("HLTL1TSeed") << "\n L1EtSum Centrality seeds: " << sizeSeedsL1EtSumCentrality; for (size_t i = 0; i != sizeSeedsL1EtSumCentrality; i++) { l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumCentrality[i]); @@ -346,10 +337,10 @@ void HLTL1TSeed::dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWit << " (hwPt = " << obj->hwPt() << ")"; } - vector seedsL1EtSumMinBiasHFP0; + std::vector seedsL1EtSumMinBiasHFP0; filterproduct.getObjects(trigger::TriggerL1MinBiasHFP0, seedsL1EtSumMinBiasHFP0); const size_t sizeSeedsL1EtSumMinBiasHFP0 = seedsL1EtSumMinBiasHFP0.size(); - LogTrace("HLTL1TSeed") << "\n L1EtSum MinBiasHFP0 seeds: " << sizeSeedsL1EtSumMinBiasHFP0 << endl << endl; + LogTrace("HLTL1TSeed") << "\n L1EtSum MinBiasHFP0 seeds: " << sizeSeedsL1EtSumMinBiasHFP0; for (size_t i = 0; i != sizeSeedsL1EtSumMinBiasHFP0; i++) { l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumMinBiasHFP0[i]); @@ -357,10 +348,10 @@ void HLTL1TSeed::dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWit LogTrace("HLTL1TSeed") << "\tL1EtSum MinBiasHFP0: hwPt = " << obj->hwPt(); } - vector seedsL1EtSumMinBiasHFM0; + std::vector seedsL1EtSumMinBiasHFM0; filterproduct.getObjects(trigger::TriggerL1MinBiasHFM0, seedsL1EtSumMinBiasHFM0); const size_t sizeSeedsL1EtSumMinBiasHFM0 = seedsL1EtSumMinBiasHFM0.size(); - LogTrace("HLTL1TSeed") << "\n L1EtSum MinBiasHFM0 seeds: " << sizeSeedsL1EtSumMinBiasHFM0 << endl << endl; + LogTrace("HLTL1TSeed") << "\n L1EtSum MinBiasHFM0 seeds: " << sizeSeedsL1EtSumMinBiasHFM0; for (size_t i = 0; i != sizeSeedsL1EtSumMinBiasHFM0; i++) { l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumMinBiasHFM0[i]); @@ -368,10 +359,10 @@ void HLTL1TSeed::dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWit LogTrace("HLTL1TSeed") << "\tL1EtSum MinBiasHFM0: hwPt = " << obj->hwPt(); } - vector seedsL1EtSumMinBiasHFP1; + std::vector seedsL1EtSumMinBiasHFP1; filterproduct.getObjects(trigger::TriggerL1MinBiasHFP1, seedsL1EtSumMinBiasHFP1); const size_t sizeSeedsL1EtSumMinBiasHFP1 = seedsL1EtSumMinBiasHFP1.size(); - LogTrace("HLTL1TSeed") << "\n L1EtSum MinBiasHFP1 seeds: " << sizeSeedsL1EtSumMinBiasHFP1 << endl << endl; + LogTrace("HLTL1TSeed") << "\n L1EtSum MinBiasHFP1 seeds: " << sizeSeedsL1EtSumMinBiasHFP1; for (size_t i = 0; i != sizeSeedsL1EtSumMinBiasHFP1; i++) { l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumMinBiasHFP1[i]); @@ -379,10 +370,10 @@ void HLTL1TSeed::dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWit LogTrace("HLTL1TSeed") << "\tL1EtSum MinBiasHFP1: hwPt = " << obj->hwPt(); } - vector seedsL1EtSumMinBiasHFM1; + std::vector seedsL1EtSumMinBiasHFM1; filterproduct.getObjects(trigger::TriggerL1MinBiasHFM1, seedsL1EtSumMinBiasHFM1); const size_t sizeSeedsL1EtSumMinBiasHFM1 = seedsL1EtSumMinBiasHFM1.size(); - LogTrace("HLTL1TSeed") << "\n L1EtSum MinBiasHFM1 seeds: " << sizeSeedsL1EtSumMinBiasHFM1 << endl << endl; + LogTrace("HLTL1TSeed") << "\n L1EtSum MinBiasHFM1 seeds: " << sizeSeedsL1EtSumMinBiasHFM1; for (size_t i = 0; i != sizeSeedsL1EtSumMinBiasHFM1; i++) { l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumMinBiasHFM1[i]); @@ -390,10 +381,10 @@ void HLTL1TSeed::dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWit LogTrace("HLTL1TSeed") << "\tL1EtSum MinBiasHFM1: hwPt = " << obj->hwPt(); } - vector seedsL1EtSumTowerCount; + std::vector seedsL1EtSumTowerCount; filterproduct.getObjects(trigger::TriggerL1TowerCount, seedsL1EtSumTowerCount); const size_t sizeSeedsL1EtSumTowerCount = seedsL1EtSumTowerCount.size(); - LogTrace("HLTL1TSeed") << "\n L1EtSum TowerCount seeds: " << sizeSeedsL1EtSumTowerCount << endl << endl; + LogTrace("HLTL1TSeed") << "\n L1EtSum TowerCount seeds: " << sizeSeedsL1EtSumTowerCount; for (size_t i = 0; i != sizeSeedsL1EtSumTowerCount; i++) { l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumTowerCount[i]); @@ -401,10 +392,10 @@ void HLTL1TSeed::dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWit LogTrace("HLTL1TSeed") << "\tL1EtSum TowerCount: hwPt = " << obj->hwPt(); } - vector seedsL1EtSumAsymEt; + std::vector seedsL1EtSumAsymEt; filterproduct.getObjects(trigger::TriggerL1AsymEt, seedsL1EtSumAsymEt); const size_t sizeSeedsL1EtSumAsymEt = seedsL1EtSumAsymEt.size(); - LogTrace("HLTL1TSeed") << "\n L1EtSum AsymEt seeds: " << sizeSeedsL1EtSumAsymEt << endl << endl; + LogTrace("HLTL1TSeed") << "\n L1EtSum AsymEt seeds: " << sizeSeedsL1EtSumAsymEt; for (size_t i = 0; i != sizeSeedsL1EtSumAsymEt; i++) { l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumAsymEt[i]); @@ -412,10 +403,10 @@ void HLTL1TSeed::dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWit LogTrace("HLTL1TSeed") << "\tL1EtSum AsymEt: hwPt = " << obj->hwPt(); } - vector seedsL1EtSumAsymHt; + std::vector seedsL1EtSumAsymHt; filterproduct.getObjects(trigger::TriggerL1AsymHt, seedsL1EtSumAsymHt); const size_t sizeSeedsL1EtSumAsymHt = seedsL1EtSumAsymHt.size(); - LogTrace("HLTL1TSeed") << "\n L1EtSum AsymHt seeds: " << sizeSeedsL1EtSumAsymHt << endl << endl; + LogTrace("HLTL1TSeed") << "\n L1EtSum AsymHt seeds: " << sizeSeedsL1EtSumAsymHt; for (size_t i = 0; i != sizeSeedsL1EtSumAsymHt; i++) { l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumAsymHt[i]); @@ -423,10 +414,10 @@ void HLTL1TSeed::dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWit LogTrace("HLTL1TSeed") << "\tL1EtSum AsymHt: hwPt = " << obj->hwPt(); } - vector seedsL1EtSumAsymEtHF; + std::vector seedsL1EtSumAsymEtHF; filterproduct.getObjects(trigger::TriggerL1AsymEtHF, seedsL1EtSumAsymEtHF); const size_t sizeSeedsL1EtSumAsymEtHF = seedsL1EtSumAsymEtHF.size(); - LogTrace("HLTL1TSeed") << "\n L1EtSum AsymEtHF seeds: " << sizeSeedsL1EtSumAsymEtHF << endl << endl; + LogTrace("HLTL1TSeed") << "\n L1EtSum AsymEtHF seeds: " << sizeSeedsL1EtSumAsymEtHF; for (size_t i = 0; i != sizeSeedsL1EtSumAsymEtHF; i++) { l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumAsymEtHF[i]); @@ -434,10 +425,10 @@ void HLTL1TSeed::dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWit LogTrace("HLTL1TSeed") << "\tL1EtSum AsymEtHF: hwPt = " << obj->hwPt(); } - vector seedsL1EtSumAsymHtHF; + std::vector seedsL1EtSumAsymHtHF; filterproduct.getObjects(trigger::TriggerL1AsymHtHF, seedsL1EtSumAsymHtHF); const size_t sizeSeedsL1EtSumAsymHtHF = seedsL1EtSumAsymHtHF.size(); - LogTrace("HLTL1TSeed") << "\n L1EtSum AsymHtHF seeds: " << sizeSeedsL1EtSumAsymHtHF << endl << endl; + LogTrace("HLTL1TSeed") << "\n L1EtSum AsymHtHF seeds: " << sizeSeedsL1EtSumAsymHtHF; for (size_t i = 0; i != sizeSeedsL1EtSumAsymHtHF; i++) { l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumAsymHtHF[i]); @@ -445,10 +436,10 @@ void HLTL1TSeed::dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWit LogTrace("HLTL1TSeed") << "\tL1EtSum AsymHtHF: hwPt = " << obj->hwPt(); } - vector seedsL1EtSumZDCP; + std::vector seedsL1EtSumZDCP; filterproduct.getObjects(trigger::TriggerL1ZDCP, seedsL1EtSumZDCP); const size_t sizeSeedsL1EtSumZDCP = seedsL1EtSumZDCP.size(); - LogTrace("HLTL1TSeed") << "\n L1EtSum ZDCP seeds: " << sizeSeedsL1EtSumZDCP << endl << endl; + LogTrace("HLTL1TSeed") << "\n L1EtSum ZDCP seeds: " << sizeSeedsL1EtSumZDCP; for (size_t i = 0; i != sizeSeedsL1EtSumZDCP; i++) { l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumZDCP[i]); @@ -460,10 +451,10 @@ void HLTL1TSeed::dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWit << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx(); } - vector seedsL1EtSumZDCM; + std::vector seedsL1EtSumZDCM; filterproduct.getObjects(trigger::TriggerL1ZDCM, seedsL1EtSumZDCM); const size_t sizeSeedsL1EtSumZDCM = seedsL1EtSumZDCM.size(); - LogTrace("HLTL1TSeed") << "\n L1EtSum ZDCM seeds: " << sizeSeedsL1EtSumZDCM << endl << endl; + LogTrace("HLTL1TSeed") << "\n L1EtSum ZDCM seeds: " << sizeSeedsL1EtSumZDCM; for (size_t i = 0; i != sizeSeedsL1EtSumZDCM; i++) { l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumZDCM[i]); @@ -475,7 +466,7 @@ void HLTL1TSeed::dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWit << "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx(); } - LogTrace("HLTL1TSeed") << " \n\n" << endl; + LogTrace("HLTL1TSeed") << " \n\n"; } // seeding is done via L1 trigger object maps, considering the objects which fired in L1 @@ -486,38 +477,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; @@ -525,7 +515,7 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi if (!uGtAlgoBlocks.isValid()) { edm::LogWarning("HLTL1TSeed") << " Warning: GlobalAlgBlkBxCollection with input tag " << m_l1GlobalTag - << " requested in configuration, but not found in the event." << std::endl; + << " requested in configuration, but not found in the event."; return false; } @@ -550,7 +540,7 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi if (!gtObjectMapRecord.isValid()) { edm::LogWarning("HLTL1TSeed") << " Warning: GlobalObjectMapRecord with input tag " << m_l1GtObjectMapTag - << " requested in configuration, but not found in the event." << std::endl; + << " requested in configuration, but not found in the event."; return false; } @@ -563,12 +553,11 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi "-------------------------------"; LogTrace("HLTL1TSeed") - << "\n\tAlgorithms in L1TriggerObjectMapRecord and GT results ( emulated | initial | prescaled | final ) " - << endl; + << "\n\tAlgorithms in L1TriggerObjectMapRecord and GT results ( emulated | initial | prescaled | final ) "; LogTrace("HLTL1TSeed") << "\n\tmap" << "\tAlgoBit" << std::setw(40) << "algoName" - << "\t (emul|ini|pre|fin)" << endl; + << "\t (emul|ini|pre|fin)"; LogTrace("HLTL1TSeed") << "----------------------------------------------------------------------------------------" "-----------------------------"; @@ -588,15 +577,14 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi << "\n\tbit = " << std::setw(3) << bit << std::setw(40) << objMaps[imap].algoName() << "\t emulated decision = " << emulDecision << "\t unpacked initial decision = " << initDecision - << "\nThis should not happen. Include the L1TGtEmulCompare module in the sequence." - << endl; + << "\nThis should not happen. Include the L1TGtEmulCompare module in the sequence."; } LogTrace("HLTL1TSeed") << "\t" << std::setw(3) << imap << "\tbit = " << std::setw(3) << bit << std::setw(40) << objMaps[imap].algoName() << "\t ( " << emulDecision << " | " << initDecision << " | " << presDecision << " | " << finlDecision << " ) "; } - LogTrace("HLTL1TSeed") << endl; + LogTrace("HLTL1TSeed") << "\n"; } // Filter decision in case of "L1GlobalDecision" logical expression. @@ -628,8 +616,7 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi throw cms::Exception("FailModule") << "\nAlgorithm " << algoName << ", requested as seed by a HLT path, cannot be matched to a L1 algo name in any GlobalObjectMap\n" - << "Please check if algorithm " << algoName << " is present in the L1 menu\n" - << std::endl; + << "Please check if algorithm " << algoName << " is present in the L1 menu\n"; } else { //(algOpTokenVector[i]).tokenResult = objMap->algoGtlResult(); @@ -646,8 +633,7 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi if (m_isDebugEnabled) { LogTrace("HLTL1TSeed") << "\nHLTL1TSeed: l1SeedsLogicalExpression (names) = '" << m_l1SeedsLogicalExpression << "'" - << "\n Result for logical expression after update of algOpTokens: " << seedsResult << "\n" - << std::endl; + << "\n Result for logical expression after update of algOpTokens: " << seedsResult << "\n"; } /// Loop over the list of required algorithms for seeding @@ -658,7 +644,7 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi ++itSeed) { std::string algoSeedName = (*itSeed).tokenName; - LogTrace("HLTL1TSeed") << "\n ---------------- algo seed name = " << algoSeedName << endl; + LogTrace("HLTL1TSeed") << "\n ---------------- algo seed name = " << algoSeedName; const GlobalObjectMap* objMap = gtObjectMapRecord->getObjectMap(algoSeedName); @@ -668,8 +654,7 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi throw cms::Exception("FailModule") << "\nAlgorithm " << algoSeedName << ", requested as seed by a HLT path, cannot be matched to a L1 algo name in any GlobalObjectMap\n" - << "Please check if algorithm " << algoSeedName << " is present in the L1 menu\n" - << std::endl; + << "Please check if algorithm " << algoSeedName << " is present in the L1 menu\n"; } int algoSeedBitNumber = objMap->algoBitNumber(); @@ -679,7 +664,7 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi bool algoSeedResultMaskAndPresc = uGtAlgoBlocks->at(0, 0).getAlgoDecisionFinal(algoSeedBitNumber); LogTrace("HLTL1TSeed") << "\n\tAlgo seed " << algoSeedName << " result emulated | final = " << algoSeedResult - << " | " << algoSeedResultMaskAndPresc << endl; + << " | " << algoSeedResultMaskAndPresc; /// Unpacked GT result of algorithm is false after masks and prescales - no seeds /// //////////////////////////////////////////////////////////////////////////////// @@ -697,14 +682,13 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi const std::vector& condCombinations = objMap->combinationVector(); LogTrace("HLTL1TSeed") << "\n\talgoName =" << objMap->algoName() << "\talgoBitNumber = " << algoSeedBitNumber - << "\talgoGtlResult = " << algoSeedResult << endl - << endl; + << "\talgoGtlResult = " << algoSeedResult; if (opTokenVecObjMap.size() != condObjTypeVec.size()) { edm::LogWarning("HLTL1TSeed") << "\nWarning: GlobalObjectMapRecord with input tag " << m_l1GtObjectMapTag << "\nhas object map for bit number " << algoSeedBitNumber - << " which contains different size vectors of operand tokens and of condition object types!" << std::endl; + << " which contains different size vectors of operand tokens and of condition object types!"; assert(opTokenVecObjMap.size() == condObjTypeVec.size()); } @@ -713,8 +697,7 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi edm::LogWarning("HLTL1TSeed") << "\nWarning: GlobalObjectMapRecord with input tag " << m_l1GtObjectMapTag << "\nhas object map for bit number " << algoSeedBitNumber - << " which contains different size vectors of operand tokens and of condition object combinations!" - << std::endl; + << " which contains different size vectors of operand tokens and of condition object combinations!"; assert(opTokenVecObjMap.size() == condCombinations.size()); } @@ -722,14 +705,14 @@ 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) { - LogTrace("HLTL1TSeed") << setw(15) << "\tcondObjType = " << jOb << endl; + for (auto const& jOb : condObjType) { + LogTrace("HLTL1TSeed") << setw(15) << "\tcondObjType = " << jOb; } - const std::string condName = opTokenVecObjMap[condNumber].tokenName; - bool condResult = opTokenVecObjMap[condNumber].tokenResult; + std::string const& condName = opTokenVecObjMap[condNumber].tokenName; + bool const condResult = opTokenVecObjMap[condNumber].tokenResult; // only procede for conditions that passed // @@ -739,110 +722,120 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi // loop over combinations for a given condition // - const CombinationsInCond* condComb = objMap->getCombinationsInCond(condNumber); + auto const& condCombBx = *(objMap->getCombinationsBxInCond(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)) { - LogTrace("HLTL1TSeed") << setw(15) << "\tnew combination" << endl; + for (size_t i1 = 0; i1 < condComb.size(); ++i1) { + LogTrace("HLTL1TSeed") << setw(15) << "\tnew combination"; // 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()) { LogTrace("HLTL1TSeed") << "\talgoName = " << objMap->algoName() - << " is object-less L1 algorithm, so do not attempt to store any objects to the list of seeds.\n" - << std::endl; + << " is object-less L1 algorithm, so do not attempt to store any objects to the list of seeds.\n"; 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 + // Note. + // - Up to its version 10 (included), the GlobalObjectMap class + // did not include the BX values of the relevant L1T objects. + // - This means that, if the GlobalObjectMap is read from old data (class version <= 10), + // 'hasBxInfo() == false' and any 'condCombBx' will be empty. + // In that case, HLTL1TSeed assumes that the BX value is 0 (see next line). + L1TObjBxIndexType const objBx = objMap->hasBxInfo() ? condCombBx[i1][i2] : 0; - // 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]; - LogTrace("HLTL1TSeed") << "\tAdd object of type " << objTypeVal << " and index " << (*itObject) - << " to the seed list." << std::endl; + // 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 " << 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 +845,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 + << " in the seed list."; } break; } // end switch objTypeVal @@ -913,9 +900,6 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi listHTMHF.sort(); listHTMHF.unique(); - listJetCounts.sort(); - listJetCounts.unique(); - listCentrality.sort(); listCentrality.unique(); @@ -969,19 +953,19 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi if (!muons.isValid()) { edm::LogWarning("HLTL1TSeed") << "\nWarning: L1MuonBxCollection with input tag " << m_l1MuonTag << "\nrequested in configuration, but not found in the event." - << "\nNo muons added to filterproduct." << endl; + << "\nNo muons added to filterproduct."; } 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); @@ -997,19 +981,20 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi if (!muonShowers.isValid()) { edm::LogWarning("HLTL1TSeed") << "\nWarning: L1MuonShowerBxCollection with input tag " << m_l1MuonShowerTag << "\nrequested in configuration, but not found in the event." - << "\nNo muon showers added to filterproduct." << endl; + << "\nNo muon showers added to filterproduct."; } 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); @@ -1024,19 +1009,19 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi if (!egammas.isValid()) { edm::LogWarning("HLTL1TSeed") << "\nWarning: L1EGammaBxCollection with input tag " << m_l1EGammaTag << "\nrequested in configuration, but not found in the event." - << "\nNo egammas added to filterproduct." << endl; + << "\nNo egammas added to filterproduct."; } 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); @@ -1052,19 +1037,19 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi if (!jets.isValid()) { edm::LogWarning("HLTL1TSeed") << "\nWarning: L1JetBxCollection with input tag " << m_l1JetTag << "\nrequested in configuration, but not found in the event." - << "\nNo jets added to filterproduct." << endl; + << "\nNo jets added to filterproduct."; } 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); @@ -1080,19 +1065,19 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi if (!taus.isValid()) { edm::LogWarning("HLTL1TSeed") << "\nWarning: L1TauBxCollection with input tag " << m_l1TauTag << "\nrequested in configuration, but not found in the event." - << "\nNo taus added to filterproduct." << endl; + << "\nNo taus added to filterproduct."; } 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,151 +1086,67 @@ 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) { + // skip invalid indices + if (objIdx < 0 or unsigned(objIdx) >= etSums->size(bxIdx)) { + edm::LogWarning("HLTL1TSeed") + << "Invalid index from the L1ObjectMap (L1uGT emulator), will be ignored (l1t::EtSumBxCollection):" + << " index=" << objIdx << " (" << etSums->size(bxIdx) << " unpacked L1T objects in BX " << bxIdx << ")"; + continue; + } + + // Transform to begin of BxVector + unsigned int index = etSums->begin(bxIdx) - etSums->begin() + objIdx; + + l1t::EtSumRef myref(etSums, index); + 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; + << "\nNo etsums added to filterproduct."; } 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); + } - LogTrace("HLTL1TSeed") << "\nHLTL1Seed:seedsL1TriggerObjectMaps returning " << seedsResult << endl << endl; + // return filter decision + LogTrace("HLTL1TSeed") << "\nHLTL1Seed:seedsL1TriggerObjectMaps returning " << seedsResult; 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/src/AlgorithmEvaluation.cc b/L1Trigger/L1TGlobal/src/AlgorithmEvaluation.cc index 1ce0458b7e7c2..1dbd11c554e3e 100644 --- a/L1Trigger/L1TGlobal/src/AlgorithmEvaluation.cc +++ b/L1Trigger/L1TGlobal/src/AlgorithmEvaluation.cc @@ -51,8 +51,7 @@ void l1t::AlgorithmEvaluation::evaluateAlgorithm(const int chipNumber, m_algoResult = false; // it should never be happen - throw cms::Exception("FailModule") << "\nEmpty RPN vector for the logical expression = " << m_logicalExpression - << std::endl; + throw cms::Exception("FailModule") << "\nEmpty RPN vector for the logical expression = " << m_logicalExpression; } // reserve memory @@ -80,7 +79,7 @@ void l1t::AlgorithmEvaluation::evaluateAlgorithm(const int chipNumber, if (nullptr == itCond->second) { // it should never be happen, only valid conditions are in the maps throw cms::Exception("FailModule") - << "\nCondition " << (it->operand) << " NULL pointer found in condition map" << std::endl; + << "\nCondition " << (it->operand) << " NULL pointer found in condition map"; } // @@ -98,14 +97,12 @@ void l1t::AlgorithmEvaluation::evaluateAlgorithm(const int chipNumber, m_operandTokenVector.push_back(opToken); opNumber++; - // - CombinationsInCond const& combInCondition = (itCond->second)->getCombinationsInCond(); + auto const& combInCondition = (itCond->second)->getCombinationsInCond(); m_algoCombinationVector.push_back(combInCondition); } else { // it should never be happen, all conditions are in the maps - throw cms::Exception("FailModule") - << "\nCondition " << (it->operand) << " not found in condition map" << std::endl; + throw cms::Exception("FailModule") << "\nCondition " << (it->operand) << " not found in condition map."; } } 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..3ac6b090e0f46 100644 --- a/L1Trigger/L1TGlobal/src/ConditionEvaluation.cc +++ b/L1Trigger/L1TGlobal/src/ConditionEvaluation.cc @@ -12,39 +12,24 @@ * */ -// 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 { - myCout << "\n ConditionEvaluation print...\n" << std::endl; - myCout << " Maximum number of objects in condition: " << m_condMaxNumberObjects << std::endl; - myCout << " Condition result: " << m_condLastResult << std::endl; + myCout << "\n ConditionEvaluation print...\n\n"; + myCout << " Maximum number of objects in condition: " << m_condMaxNumberObjects << "\n"; + myCout << " Condition result: " << m_condLastResult << "\n"; - 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 << "); "; } - myCout << "\n List of combinations passing all requirements for this condition: \n " << myCout1.str() << " \n" - << std::endl; + myCout << "\n List of combinations passing all requirements for this condition: \n " << myCout1.str() << " \n\n"; } diff --git a/L1Trigger/L1TGlobal/src/CorrCondition.cc b/L1Trigger/L1TGlobal/src/CorrCondition.cc index 082bed42d2017..fbf8ded1d5f2c 100644 --- a/L1Trigger/L1TGlobal/src/CorrCondition.cc +++ b/L1Trigger/L1TGlobal/src/CorrCondition.cc @@ -100,7 +100,7 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { //std::ostringstream myCout; //m_gtCorrelationTemplate->print(myCout); //LogDebug("L1TGlobal") - // << "Correlation Condition Evaluation \n" << myCout.str() << std::endl; + // << "Correlation Condition Evaluation \n" << myCout.str(); bool condResult = false; bool reqObjResult = false; @@ -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,14 +139,14 @@ 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) { std::ostringstream myCout; muCondition.print(myCout); - LogDebug("L1TGlobal") << myCout.str() << std::endl; + LogDebug("L1TGlobal") << myCout.str(); } } break; case CondCalo: { @@ -162,14 +159,14 @@ 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) { std::ostringstream myCout; caloCondition.print(myCout); - LogDebug("L1TGlobal") << myCout.str() << std::endl; + LogDebug("L1TGlobal") << myCout.str(); } } break; case CondEnergySum: { @@ -180,14 +177,14 @@ 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) { std::ostringstream myCout; eSumCondition.print(myCout); - LogDebug("L1TGlobal") << myCout.str() << std::endl; + LogDebug("L1TGlobal") << myCout.str(); } } break; default: { @@ -198,8 +195,7 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { // return if first subcondition is false if (!reqObjResult) { - LogDebug("L1TGlobal") << "\n First sub-condition false, second sub-condition not evaluated and not printed." - << std::endl; + LogDebug("L1TGlobal") << "\n First sub-condition false, second sub-condition not evaluated and not printed."; return false; } @@ -214,7 +210,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]; @@ -222,7 +217,7 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { std::ostringstream myCout; muCondition.print(myCout); - LogDebug("L1TGlobal") << myCout.str() << std::endl; + LogDebug("L1TGlobal") << myCout.str(); } } break; case CondCalo: { @@ -234,14 +229,14 @@ 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) { std::ostringstream myCout; caloCondition.print(myCout); - LogDebug("L1TGlobal") << myCout.str() << std::endl; + LogDebug("L1TGlobal") << myCout.str(); } } break; @@ -254,14 +249,14 @@ 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) { std::ostringstream myCout; eSumCondition.print(myCout); - LogDebug("L1TGlobal") << myCout.str() << std::endl; + LogDebug("L1TGlobal") << myCout.str(); } } break; default: { @@ -276,8 +271,7 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { } else { LogDebug("L1TGlobal") << "\n" << " Both sub-conditions true for object requirements." - << " Evaluate correlation requirements.\n" - << std::endl; + << " Evaluate correlation requirements.\n"; } // since we have two good legs get the correlation parameters @@ -285,7 +279,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 @@ -342,7 +336,7 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { //phiBound = par.phiBins.size()/2; phiBound = (int)((par.phiMax - par.phiMin) / par.phiStep) / 2; } - LogDebug("L1TGlobal") << "Phi Bound = " << phiBound << std::endl; + LogDebug("L1TGlobal") << "Phi Bound = " << phiBound; // BUILD THE 1/dR2 LUT BASED ON CONDITION int iRSq = 0; @@ -355,11 +349,11 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { double resolution = 1.0; unsigned int precInvRsq = 0x5; if (cond0Categ == CondMuon || cond1Categ == CondMuon) { - LogTrace("L1TGlobal") << " Building 1/dR2 for Muon " << std::endl; + LogTrace("L1TGlobal") << " Building 1/dR2 for Muon "; tempdiffeta = tempdiffeta / 2.0; resolution = 0.5; } else { - LogTrace("L1TGlobal") << " Building 1/dR2 for Calo " << std::endl; + LogTrace("L1TGlobal") << " Building 1/dR2 for Calo "; iRSqmax = 231; jRSqmax = 73; tempdiffphi = 0.04363323129985824; @@ -385,26 +379,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 SingleCombInCond 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: { @@ -439,7 +431,7 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { binEdges = m_gtScales->getMUScales().uptBins.at(uptBin0); upt0Phy = 0.5 * (binEdges.second + binEdges.first); } - LogDebug("L1TGlobal") << "Found all quantities for the muon 0" << std::endl; + LogDebug("L1TGlobal") << "Found all quantities for the muon 0"; } break; // Calorimeter Objects (EG, Jet, Tau) @@ -454,7 +446,7 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { etaBin0 = etaIndex0; if (etaBin0 < 0) etaBin0 = m_gtScales->getEGScales().etaBins.size() + etaBin0; - // LogDebug("L1TGlobal") << "EG0 phi" << phiIndex0 << " eta " << etaIndex0 << " etaBin0 = " << etaBin0 << " et " << etIndex0 << std::endl; + // LogDebug("L1TGlobal") << "EG0 phi" << phiIndex0 << " eta " << etaIndex0 << " etaBin0 = " << etaBin0 << " et " << etIndex0; etBin0 = etIndex0; int ssize = m_gtScales->getEGScales().etBins.size(); @@ -534,11 +526,11 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { lutName += "-MU"; long long tst = m_gtScales->getLUT_CalMuEta(lutName, etaBin0); LogDebug("L1TGlobal") << lutName << " EtaCal = " << etaIndex0 << " etaBin0 = " << etaBin0 - << " EtaMu = " << tst << std::endl; + << " EtaMu = " << tst; etaIndex0 = tst; tst = m_gtScales->getLUT_CalMuPhi(lutName, phiIndex0); - LogDebug("L1TGlobal") << lutName << " PhiCal = " << phiIndex0 << " PhiMu = " << tst << std::endl; + LogDebug("L1TGlobal") << lutName << " PhiCal = " << phiIndex0 << " PhiMu = " << tst; phiIndex0 = tst; } @@ -590,7 +582,7 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { default: edm::LogError("L1TGlobal") << "\n Error: " << "Unmatched object type from template to EtSumType, cndObjTypeVec[0] = " - << cndObjTypeVec[0] << std::endl; + << cndObjTypeVec[0]; type = l1t::EtSum::EtSumType::kTotalEt; break; } @@ -667,7 +659,7 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { std::string lutName = lutObj0; lutName += "-MU"; long long tst = m_gtScales->getLUT_CalMuPhi(lutName, phiIndex0); - LogDebug("L1TGlobal") << lutName << " PhiCal = " << phiIndex0 << " PhiMu = " << tst << std::endl; + LogDebug("L1TGlobal") << lutName << " PhiCal = " << phiIndex0 << " PhiMu = " << tst; phiIndex0 = tst; } @@ -678,30 +670,28 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { default: { // should not arrive here, there are no correlation conditions defined for this object - LogDebug("L1TGlobal") << "Error could not find the Cond Category for Leg 0" << std::endl; + LogDebug("L1TGlobal") << "Error could not find the Cond Category for Leg 0"; return false; } break; } //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 SingleCombInCond 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; + LogDebug("L1TGlobal") << "Corr Condition looking at same leg...skip"; continue; } @@ -717,7 +707,7 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { etaBin1 = etaIndex1; if (etaBin1 < 0) etaBin1 = m_gtScales->getMUScales().etaBins.size() + etaBin1; - // LogDebug("L1TGlobal") << "Muon phi" << phiIndex1 << " eta " << etaIndex1 << " etaBin1 = " << etaBin1 << " et " << etIndex1 << std::endl; + // LogDebug("L1TGlobal") << "Muon phi" << phiIndex1 << " eta " << etaIndex1 << " etaBin1 = " << etaBin1 << " et " << etIndex1; etBin1 = etIndex1; uptBin1 = uptIndex1; // Added for displaced muons @@ -739,7 +729,7 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { binEdges = m_gtScales->getMUScales().uptBins.at(uptBin1); upt1Phy = 0.5 * (binEdges.second + binEdges.first); } - LogDebug("L1TGlobal") << "Found all quantities for the muon 1" << std::endl; + LogDebug("L1TGlobal") << "Found all quantities for the muon 1"; } break; case CondCalo: { switch (cndObjTypeVec[1]) { @@ -830,17 +820,17 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { std::string lutName = lutObj1; lutName += "-MU"; long long tst = m_gtScales->getLUT_CalMuEta(lutName, etaBin1); - LogDebug("L1TGlobal") << lutName << " EtaCal = " << etaIndex1 << " EtaMu = " << tst << std::endl; + LogDebug("L1TGlobal") << lutName << " EtaCal = " << etaIndex1 << " EtaMu = " << tst; etaIndex1 = tst; tst = m_gtScales->getLUT_CalMuPhi(lutName, phiIndex1); - LogDebug("L1TGlobal") << lutName << " PhiCal = " << phiIndex1 << " PhiMu = " << tst << std::endl; + LogDebug("L1TGlobal") << lutName << " PhiCal = " << phiIndex1 << " PhiMu = " << tst; phiIndex1 = tst; } } break; case CondEnergySum: { - LogDebug("L1TGlobal") << "Looking at second Condition as Energy Sum: " << cndObjTypeVec[1] << std::endl; + LogDebug("L1TGlobal") << "Looking at second Condition as Energy Sum: " << cndObjTypeVec[1]; etSumCond = true; //Stupid mapping between enum types for energy sums. @@ -884,14 +874,14 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { default: edm::LogError("L1TGlobal") << "\n Error: " << "Unmatched object type from template to EtSumType, cndObjTypeVec[1] = " - << cndObjTypeVec[1] << std::endl; + << cndObjTypeVec[1]; type = l1t::EtSum::EtSumType::kTotalEt; break; } candEtSumVec = m_uGtB->getCandL1EtSum(); - LogDebug("L1TGlobal") << "obj " << lutObj1 << " Vector Size " << candEtSumVec->size(cond1bx) << std::endl; + LogDebug("L1TGlobal") << "obj " << lutObj1 << " Vector Size " << candEtSumVec->size(cond1bx); for (int iEtSum = 0; iEtSum < (int)candEtSumVec->size(cond1bx); iEtSum++) { if ((candEtSumVec->at(cond1bx, iEtSum))->getType() == type) { phiIndex1 = (candEtSumVec->at(cond1bx, iEtSum))->hwPhi(); @@ -963,7 +953,7 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { std::string lutName = lutObj1; lutName += "-MU"; long long tst = m_gtScales->getLUT_CalMuPhi(lutName, phiIndex1); - LogDebug("L1TGlobal") << lutName << " PhiCal = " << phiIndex1 << " PhiMu = " << tst << std::endl; + LogDebug("L1TGlobal") << lutName << " PhiCal = " << phiIndex1 << " PhiMu = " << tst; phiIndex1 = tst; } @@ -973,7 +963,7 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { } break; default: { // should not arrive here, there are no correlation conditions defined for this object - LogDebug("L1TGlobal") << "Error could not find the Cond Category for Leg 0" << std::endl; + LogDebug("L1TGlobal") << "Error could not find the Cond Category for Leg 0"; return false; } break; } //end switch on second leg @@ -995,8 +985,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" @@ -1034,7 +1024,7 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { << "Obj0 etaFW = " << etaIndex0 << " Obj1 etaFW = " << etaIndex1 << "\n" << " DeltaEtaFW = " << deltaEtaFW << "\n" << " LUT Name = " << lutName << " Prec = " << precDeltaEtaLUT - << " DeltaEtaLUT = " << deltaEtaLUT << std::endl; + << " DeltaEtaLUT = " << deltaEtaLUT; // If there is a delta eta, check it. if (corrPar.corrCutType & 0x1) { @@ -1047,19 +1037,19 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { << " Precision Shift = " << preShift << "\n" << " deltaEta (shift)= " << (deltaEtaLUT / pow(10, preShift + corrPar.precEtaCut)) << "\n" - << " deltaEtaPhy = " << deltaEtaPhy << std::endl; + << " deltaEtaPhy = " << deltaEtaPhy; //if(preShift>0) deltaEtaLUT /= pow(10,preShift); if (deltaEtaLUT >= (long long)(corrPar.minEtaCutValue * pow(10, preShift)) && deltaEtaLUT <= (long long)(corrPar.maxEtaCutValue * pow(10, preShift))) { LogDebug("L1TGlobal") << " Passed Delta Eta Cut [" << (long long)(corrPar.minEtaCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxEtaCutValue * pow(10, preShift)) << "]" << std::endl; + << (long long)(corrPar.maxEtaCutValue * pow(10, preShift)) << "]"; } else { LogDebug("L1TGlobal") << " Failed Delta Eta Cut [" << (long long)(corrPar.minEtaCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxEtaCutValue * pow(10, preShift)) << "]" << std::endl; + << (long long)(corrPar.maxEtaCutValue * pow(10, preShift)) << "]"; reqResult = false; } } @@ -1075,19 +1065,19 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { << " Precision Shift = " << preShift << "\n" << " deltaPhi (shift)= " << (deltaPhiLUT / pow(10, preShift + corrPar.precPhiCut)) << "\n" - << " deltaPhiPhy = " << deltaPhiPhy << std::endl; + << " deltaPhiPhy = " << deltaPhiPhy; //if(preShift>0) deltaPhiLUT /= pow(10,preShift); if (deltaPhiLUT >= (long long)(corrPar.minPhiCutValue * pow(10, preShift)) && deltaPhiLUT <= (long long)(corrPar.maxPhiCutValue * pow(10, preShift))) { LogDebug("L1TGlobal") << " Passed Delta Phi Cut [" << (long long)(corrPar.minPhiCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxPhiCutValue * pow(10, preShift)) << "]" << std::endl; + << (long long)(corrPar.maxPhiCutValue * pow(10, preShift)) << "]"; } else { LogDebug("L1TGlobal") << " Failed Delta Phi Cut [" << (long long)(corrPar.minPhiCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxPhiCutValue * pow(10, preShift)) << "]" << std::endl; + << (long long)(corrPar.maxPhiCutValue * pow(10, preShift)) << "]"; reqResult = false; } } @@ -1108,19 +1098,17 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { << " Precision Shift = " << preShift << "\n" << " deltaRSqLUT (shift)= " << (deltaRSq / pow(10, preShift + corrPar.precDRCut)) << "\n" - << " deltaRSqPhy = " << deltaRSqPhy << std::endl; + << " deltaRSqPhy = " << deltaRSqPhy; //if(preShift>0) deltaRSq /= pow(10,preShift); if (deltaRSq >= (long long)(corrPar.minDRCutValue * pow(10, preShift)) && deltaRSq <= (long long)(corrPar.maxDRCutValue * pow(10, preShift))) { LogDebug("L1TGlobal") << " Passed Delta R Cut [" << (long long)(corrPar.minDRCutValue * pow(10, preShift)) - << "," << (long long)(corrPar.maxDRCutValue * pow(10, preShift)) << "]" << deltaRSq - << std::endl; + << "," << (long long)(corrPar.maxDRCutValue * pow(10, preShift)) << "]" << deltaRSq; } else { LogDebug("L1TGlobal") << " Failed Delta R Cut [" << (int)(corrPar.minDRCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxDRCutValue * pow(10, preShift)) << "]" << deltaRSq - << std::endl; + << (long long)(corrPar.maxDRCutValue * pow(10, preShift)) << "]" << deltaRSq; reqResult = false; } } @@ -1149,13 +1137,13 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { unsigned int precSinLUT1 = m_gtScales->getPrec_Sin(lutName1); if (precCosLUT0 - precCosLUT1 != 0) - LogDebug("L1TGlobal") << "Warning: Cos LUTs for TwoBodyPt on different Precision" << std::endl; + LogDebug("L1TGlobal") << "Warning: Cos LUTs for TwoBodyPt on different Precision"; if (precSinLUT0 - precSinLUT1 != 0) - LogDebug("L1TGlobal") << "Warning: Sin LUTs for TwoBodyPt on different Precision" << std::endl; + LogDebug("L1TGlobal") << "Warning: Sin LUTs for TwoBodyPt on different Precision"; if (precSinLUT0 - precCosLUT1 != 0) - LogDebug("L1TGlobal") << "Warning: Sin and Cos LUTs for TwoBodyPt on different Precision" << std::endl; + LogDebug("L1TGlobal") << "Warning: Sin and Cos LUTs for TwoBodyPt on different Precision"; if (precSinLUT1 - precCosLUT0 != 0) - LogDebug("L1TGlobal") << "Warning: Sin and Cos LUTs for TwoBodyPt on different Precision" << std::endl; + LogDebug("L1TGlobal") << "Warning: Sin and Cos LUTs for TwoBodyPt on different Precision"; long long cosPhi1LUT = m_gtScales->getLUT_Cos(lutName0, phiIndex0); long long sinPhi1LUT = m_gtScales->getLUT_Sin(lutName0, phiIndex0); @@ -1196,23 +1184,23 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { unsigned int preShift = precPtLUTObj0 + precPtLUTObj1 + 2 * precCosLUT0; LogTrace("L1TGlobal") << "TBPT Result -- Phys: " << tbptSqPhy << "\tHW: " << tbptSqHW << "\tShifted\t" - << tbptSqHW / pow(10, preShift) << std::endl; + << tbptSqHW / pow(10, preShift); preShift = preShift - corrPar.precTBPTCut; - LogDebug("L1TGlobal") - << " Testing Two Body Pt Cut (" << lutObj0 << "," << lutObj1 << ") [" - << (long long)(corrPar.minTBPTCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxTBPTCutValue * pow(10, preShift)) << "] with precision = " << corrPar.precTBPTCut - << "\n" - << " etIndex0 = " << etIndex0 << " pt0LUT = " << ptObj0 << " PhyEt0 = " << et0Phy << "\n" - << " etIndex1 = " << etIndex1 << " pt1LUT = " << ptObj1 << " PhyEt1 = " << et1Phy << "\n" - << " Precision Shift = " << preShift << "\n" - << " Sin(phi1): LUT/Phys\t " << sinPhi1LUT << " / " << sinPhi1Phy << "\n" - << " Sin(phi2): LUT/Phys\t " << sinPhi2LUT << " / " << sinPhi2Phy << "\n" - << " Cos(phi1): LUT/Phys\t " << cosPhi1LUT << " / " << cosPhi1Phy << "\n" - << " Cos(phi2): LUT/Phys\t " << cosPhi2LUT << " / " << cosPhi2Phy - << "\n" + LogDebug("L1TGlobal") << " Testing Two Body Pt Cut (" << lutObj0 << "," << lutObj1 << ") [" + << (long long)(corrPar.minTBPTCutValue * pow(10, preShift)) << "," + << (long long)(corrPar.maxTBPTCutValue * pow(10, preShift)) + << "] with precision = " << corrPar.precTBPTCut << "\n" + << " etIndex0 = " << etIndex0 << " pt0LUT = " << ptObj0 + << " PhyEt0 = " << et0Phy << "\n" + << " etIndex1 = " << etIndex1 << " pt1LUT = " << ptObj1 + << " PhyEt1 = " << et1Phy << "\n" + << " Precision Shift = " << preShift << "\n" + << " Sin(phi1): LUT/Phys\t " << sinPhi1LUT << " / " << sinPhi1Phy << "\n" + << " Sin(phi2): LUT/Phys\t " << sinPhi2LUT << " / " << sinPhi2Phy << "\n" + << " Cos(phi1): LUT/Phys\t " << cosPhi1LUT << " / " << cosPhi1Phy << "\n" + << " Cos(phi2): LUT/Phys\t " << cosPhi2LUT << " / " << cosPhi2Phy << "\n" // << " deltaPhiLUT = " << deltaPhiLUT << "\n" // << " deltaEtaLUT = " << deltaEtaLUT << "\n" @@ -1220,21 +1208,21 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { // << " Precision Shift = " << preShift << "\n" // << " deltaRSqLUT (shift)= " << (deltaRSq/pow(10,preShift+corrPar.precDRCut)) << "\n" // << " deltaRSqPhy = " << deltaRSqPhy - << std::endl; + ; if (tbptSqHW > 0. && tbptSqHW >= (long long)(corrPar.minTBPTCutValue * pow(10, preShift))) { LogDebug("L1TGlobal") << " Passed Two Body pT Cut [" << (long long)(corrPar.minTBPTCutValue * pow(10, preShift)) << "]" << "\twith value: " << tbptSqHW << "\n" << "\tPhysics Cut[" << corrPar.minTBPTCutValue / pow(10, corrPar.precTBPTCut) - << "]\tPhysics Value: " << tbptSqPhy << std::endl; + << "]\tPhysics Value: " << tbptSqPhy; } else { LogDebug("L1TGlobal") << " Failed Two Body pT Cut [" << (long long)(corrPar.minTBPTCutValue * pow(10, preShift)) << "]" << "\t with value: " << tbptSqHW << "\n" << "\tPhysics Cut[" << corrPar.minTBPTCutValue / pow(10, corrPar.precTBPTCut) - << "]\tPhysics Value: " << tbptSqPhy << std::endl; + << "]\tPhysics Value: " << tbptSqPhy; reqResult = false; } } @@ -1263,7 +1251,7 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { coshDeltaEtaLUT = m_gtScales->getLUT_DeltaEta_Cosh(lutName, deltaEtaFW); unsigned int precCoshLUT = m_gtScales->getPrec_DeltaEta_Cosh(lutName); if (precCoshLUT - precCosLUT != 0) - LogDebug("L1TGlobal") << "Warning: Cos and Cosh LUTs on different Precision" << std::endl; + LogDebug("L1TGlobal") << "Warning: Cos and Cosh LUTs on different Precision"; } // if (corrPar.corrCutType & 0x10) coshDeltaEtaLUT=1*pow(10,precCosLUT); @@ -1312,7 +1300,7 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { << " deltaPhiPhy = " << deltaPhiPhy << " cos() = " << cosDeltaPhiPhy << "\n" << " deltaEtaPhy = " << deltaEtaPhy << " cosh()= " << coshDeltaEtaPhy << "\n" << " massSqPhy/2 = " << massSqPhy - << " sqrt(|massSq|) = " << sqrt(fabs(2. * massSqPhy)) << std::endl; + << " sqrt(|massSq|) = " << sqrt(fabs(2. * massSqPhy)); //if(preShift>0) massSq /= pow(10,preShift); if (corrPar.corrCutType & 0x80) { //deal with the Invariant Mass Over Delta R cut @@ -1344,13 +1332,13 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { << (long long)(corrPar.minMassCutValue * pow(10, preShift) * pow(10, precInvDRSqLUT)) << "," << (long long)(corrPar.maxMassCutValue * pow(10, preShift) * pow(10, precInvDRSqLUT)) - << "] massSqOverDeltaRSq " << massSqOverDeltaRSq << std::endl; + << "] massSqOverDeltaRSq " << massSqOverDeltaRSq; } else { LogDebug("L1TGlobal") << " Failed Invariant Mass OverDeltaR Cut [" << (long long)(corrPar.minMassCutValue * pow(10, preShift) * pow(10, precInvDRSqLUT)) << "," << (long long)(corrPar.maxMassCutValue * pow(10, preShift) * pow(10, precInvDRSqLUT)) - << "] massSqOverDeltaRSq " << massSqOverDeltaRSq << std::endl; + << "] massSqOverDeltaRSq " << massSqOverDeltaRSq; reqResult = false; } //Done with Invariant Mass Over Delta R vs Mass Cut choice @@ -1359,11 +1347,11 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { massSq <= (long long)(corrPar.maxMassCutValue * pow(10, preShift))) { LogDebug("L1TGlobal") << " Passed Invariant Mass Cut [" << (long long)(corrPar.minMassCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxMassCutValue * pow(10, preShift)) << "]" << std::endl; + << (long long)(corrPar.maxMassCutValue * pow(10, preShift)) << "]"; } else { LogDebug("L1TGlobal") << " Failed Invariant Mass Cut [" << (long long)(corrPar.minMassCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxMassCutValue * pow(10, preShift)) << "]" << std::endl; + << (long long)(corrPar.maxMassCutValue * pow(10, preShift)) << "]"; reqResult = false; } //Done with Invariant Mass Cut } //Done with choice of Invariant Mass Cut vs InvMass/dR @@ -1390,7 +1378,7 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const { } //end loop over first leg if (m_verbosity && condResult) { - LogDebug("L1TGlobal") << " pass(es) the correlation condition.\n" << std::endl; + LogDebug("L1TGlobal") << " pass(es) the correlation condition.\n"; } return condResult; diff --git a/L1Trigger/L1TGlobal/src/CorrThreeBodyCondition.cc b/L1Trigger/L1TGlobal/src/CorrThreeBodyCondition.cc index 99fa3843edd84..59a84dc4e53d2 100644 --- a/L1Trigger/L1TGlobal/src/CorrThreeBodyCondition.cc +++ b/L1Trigger/L1TGlobal/src/CorrThreeBodyCondition.cc @@ -90,7 +90,7 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons if (m_verbosity) { std::ostringstream myCout; m_gtCorrelationThreeBodyTemplate->print(myCout); - LogDebug("L1TGlobal") << "Three-body Correlation Condition Evaluation..." << std::endl; + LogDebug("L1TGlobal") << "Three-body Correlation Condition Evaluation..."; } bool condResult = false; @@ -106,19 +106,15 @@ 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; if (cond0Categ == CondMuon) { - LogDebug("L1TGlobal") << "\n --------------------- First muon checks ---------------------" << std::endl; + LogDebug("L1TGlobal") << "\n --------------------- First muon checks ---------------------"; corrMuon = static_cast(m_gtCond0); MuCondition muCondition(corrMuon, m_uGtB, 0, 0); @@ -126,30 +122,28 @@ 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) { std::ostringstream myCout; muCondition.print(myCout); - LogDebug("L1TGlobal") << myCout.str() << std::endl; + LogDebug("L1TGlobal") << myCout.str(); } } else { // Interested only in three-muon correlations - LogDebug("L1TGlobal") << "CondMuon not satisfied for Leg 0" << std::endl; + LogDebug("L1TGlobal") << "CondMuon not satisfied for Leg 0"; return false; } // return if first subcondition is false if (!reqObjResult) { - LogDebug("L1TGlobal") << "\n First subcondition false, second subcondition not evaluated and not printed." - << std::endl; + LogDebug("L1TGlobal") << "\n First subcondition false, second subcondition not evaluated and not printed."; return false; } // SECOND OBJECT if (cond1Categ == CondMuon) { - LogDebug("L1TGlobal") << "\n --------------------- Second muon checks ---------------------" << std::endl; + LogDebug("L1TGlobal") << "\n --------------------- Second muon checks ---------------------"; corrMuon = static_cast(m_gtCond1); MuCondition muCondition(corrMuon, m_uGtB, 0, 0); @@ -157,52 +151,45 @@ 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) { std::ostringstream myCout; muCondition.print(myCout); - LogDebug("L1TGlobal") << myCout.str() << std::endl; + LogDebug("L1TGlobal") << myCout.str(); } - } - - else { + } else { // Interested only in three-muon correlations - LogDebug("L1TGlobal") << "CondMuon not satisfied for Leg 1" << std::endl; + LogDebug("L1TGlobal") << "CondMuon not satisfied for Leg 1"; return false; } // return if second subcondition is false if (!reqObjResult) { - LogDebug("L1TGlobal") << "\n Second subcondition false, third subcondition not evaluated and not printed." - << std::endl; + LogDebug("L1TGlobal") << "\n Second subcondition false, third subcondition not evaluated and not printed."; return false; } // THIRD OBJECT if (cond2Categ == CondMuon) { - LogDebug("L1TGlobal") << "\n --------------------- Third muon checks ---------------------" << std::endl; + LogDebug("L1TGlobal") << "\n --------------------- Third muon checks ---------------------"; corrMuon = static_cast(m_gtCond2); MuCondition muCondition(corrMuon, m_uGtB, 0, 0); muCondition.evaluateConditionStoreResult(bxEval); reqObjResult = muCondition.condLastResult(); - cond2Comb = (muCondition.getCombinationsInCond()); - cond2bx = bxEval + (corrMuon->condRelativeBx()); + cond2Comb = muCondition.getCombinationsInCond(); cndObjTypeVec[2] = (corrMuon->objectType())[0]; if (m_verbosity) { std::ostringstream myCout; muCondition.print(myCout); - LogDebug("L1TGlobal") << myCout.str() << std::endl; + LogDebug("L1TGlobal") << myCout.str(); } - } - - else { + } else { // Interested only in three-muon correlations - LogDebug("L1TGlobal") << "CondMuon not satisfied for Leg 2" << std::endl; + LogDebug("L1TGlobal") << "CondMuon not satisfied for Leg 3"; return false; } @@ -212,8 +199,7 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons } else { LogDebug("L1TGlobal") << "\n" - << "Found three objects satisfying subconditions: evaluate three-body correlation requirements.\n" - << std::endl; + << "Found three objects satisfying subconditions: evaluate three-body correlation requirements.\n"; } // Since we have three good legs get the correlation parameters @@ -221,7 +207,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: @@ -274,16 +260,16 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons const GlobalScales::ScaleParameters& par = m_gtScales->getEGScales(); phiBound = (int)((par.phiMax - par.phiMin) / par.phiStep) / 2; } - LogDebug("L1TGlobal") << "Phi Bound = " << phiBound << std::endl; + LogDebug("L1TGlobal") << "Phi Bound = " << phiBound; // Keep track of objects for LUTS std::string lutObj0 = "NULL"; std::string lutObj1 = "NULL"; std::string lutObj2 = "NULL"; - LogTrace("L1TGlobal") << " Number of objects satisfying the subcondition 0: " << (cond0Comb.size()) << std::endl; - LogTrace("L1TGlobal") << " Number of objects satisfying the subcondition 1: " << (cond1Comb.size()) << std::endl; - LogTrace("L1TGlobal") << " Number of objects satisfying the subcondition 2: " << (cond2Comb.size()) << std::endl; + LogTrace("L1TGlobal") << " Number of objects satisfying the subcondition 0: " << (cond0Comb.size()); + LogTrace("L1TGlobal") << " Number of objects satisfying the subcondition 1: " << (cond1Comb.size()); + LogTrace("L1TGlobal") << " Number of objects satisfying the subcondition 2: " << (cond2Comb.size()); //////////////////////////////// // LOOP OVER ALL COMBINATIONS // @@ -291,28 +277,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; + LogDebug("L1TGlobal") << "Looking at first subcondition"; - if (!(*it0Comb).empty()) { - obj0Index = (*it0Comb)[0]; - } else { - LogTrace("L1TGlobal") << "\n SingleCombInCond (*it0Comb).size() " << ((*it0Comb).size()) << std::endl; + if (it0Comb.empty()) { + LogTrace("L1TGlobal") << "\n SingleCombInCond 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) @@ -332,39 +318,39 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons eta0Phy = 0.5 * (binEdges.second + binEdges.first); binEdges = m_gtScales->getMUScales().etBins.at(etBin0); et0Phy = 0.5 * (binEdges.second + binEdges.first); - LogDebug("L1TGlobal") << "Found all quantities for MU0" << std::endl; + LogDebug("L1TGlobal") << "Found all quantities for MU0"; } else { // Interested only in three-muon correlations - LogDebug("L1TGlobal") << "CondMuon not satisfied for Leg 0" << std::endl; + LogDebug("L1TGlobal") << "CondMuon not satisfied for Leg 0"; return false; } // SECOND OBJECT: 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 subcondition" << std::endl; - int obj1Index = -1; + for (auto const& it1Comb : cond1Comb) { + LogDebug("L1TGlobal") << "Looking at second subcondition"; - if (!(*it1Comb).empty()) { - obj1Index = (*it1Comb)[0]; - } else { - LogTrace("L1TGlobal") << "\n SingleCombInCond (*it1Comb).size() " << ((*it1Comb).size()) << std::endl; + if (it1Comb.empty()) { + LogTrace("L1TGlobal") << "\n SingleCombInCond 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; + LogDebug("L1TGlobal") << "Corr Condition looking at same leg...skip"; continue; } 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) @@ -384,41 +370,41 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons eta1Phy = 0.5 * (binEdges.second + binEdges.first); binEdges = m_gtScales->getMUScales().etBins.at(etBin1); et1Phy = 0.5 * (binEdges.second + binEdges.first); - LogDebug("L1TGlobal") << "Found all quantities for MU1" << std::endl; + LogDebug("L1TGlobal") << "Found all quantities for MU1"; } else { // Interested only in three-muon correlations - LogDebug("L1TGlobal") << "CondMuon not satisfied for Leg 1" << std::endl; + LogDebug("L1TGlobal") << "CondMuon not satisfied for Leg 1"; return false; } // THIRD OBJECT: Finally loop over the third leg to get its information - for (std::vector::const_iterator it2Comb = cond2Comb.begin(); it2Comb != cond2Comb.end(); - it2Comb++) { - LogDebug("L1TGlobal") << "Looking at the third object for the three-body condition" << std::endl; - int obj2Index = -1; + for (auto const& it2Comb : cond2Comb) { + LogDebug("L1TGlobal") << "Looking at the third object for the three-body condition"; - if (!(*it2Comb).empty()) { - obj2Index = (*it2Comb)[0]; - } else { - LogTrace("L1TGlobal") << "\n SingleCombInCond (*it2Comb).size() " << ((*it2Comb).size()) << std::endl; + if (it2Comb.empty()) { + LogTrace("L1TGlobal") << "\n SingleCombInCond 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) || (cndObjTypeVec[1] == cndObjTypeVec[2] && obj1Index == obj2Index && cond1bx == cond2bx)) { - LogDebug("L1TGlobal") << "Corr Condition looking at same leg...skip" << std::endl; + LogDebug("L1TGlobal") << "Corr Condition looking at same leg...skip"; continue; } 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) @@ -438,17 +424,15 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons eta2Phy = 0.5 * (binEdges.second + binEdges.first); binEdges = m_gtScales->getMUScales().etBins.at(etBin2); et2Phy = 0.5 * (binEdges.second + binEdges.first); - LogDebug("L1TGlobal") << "Found all quantities for MU2" << std::endl; - } - - else { + LogDebug("L1TGlobal") << "Found all quantities for MU2"; + } else { // Interested only in three-muon correlations - LogDebug("L1TGlobal") << "CondMuon not satisfied for Leg 2" << std::endl; + LogDebug("L1TGlobal") << "CondMuon not satisfied for Leg 2"; return false; }; if (m_verbosity) { - LogDebug("L1TGlobal") << "\n >>>>>> THREE-MUON EVENT!" << std::endl; + LogDebug("L1TGlobal") << "\n >>>>>> THREE-MUON EVENT !"; LogDebug("L1TGlobal") << ">>>>>> Object involved in the three-body correlation condition are [" << l1t::GlobalObjectEnumToString(cndObjTypeVec[0]) << ", " << l1t::GlobalObjectEnumToString(cndObjTypeVec[1]) << ", " @@ -487,9 +471,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); @@ -568,7 +552,7 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons << " LUT Name 02 = " << lutName_02 << " Prec 02 = " << precDeltaEtaLUT_02 << "\n" << " LUT Name 12 = " << lutName_12 << " Prec 12 = " << precDeltaEtaLUT_12 << "\n" << " DeltaEtaLUT_01 = " << deltaEtaLUT_01 << " DeltaEtaLUT_02 = " << deltaEtaLUT_02 - << " DeltaEtaLUT_12 = " << deltaEtaLUT_12 << std::endl; + << " DeltaEtaLUT_12 = " << deltaEtaLUT_12; if (corrPar.corrCutType & 0x9) { // Invariant mass calculation based for each pair on @@ -586,7 +570,7 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons coshDeltaEtaLUT_01 = m_gtScales->getLUT_DeltaEta_Cosh(lutName_01, deltaEtaFW_01); unsigned int precCoshLUT_01 = m_gtScales->getPrec_DeltaEta_Cosh(lutName_01); if (precCoshLUT_01 - precCosLUT_01 != 0) - LogDebug("L1TGlobal") << "Warning: Cos and Cosh LUTs on different precision" << std::endl; + LogDebug("L1TGlobal") << "Warning: Cos and Cosh LUTs on different precision"; double cosDeltaPhiPhy_02 = cos(deltaPhiPhy_02); double coshDeltaEtaPhy_02 = cosh(deltaEtaPhy_02); @@ -602,7 +586,7 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons coshDeltaEtaLUT_02 = m_gtScales->getLUT_DeltaEta_Cosh(lutName_02, deltaEtaFW_02); unsigned int precCoshLUT_02 = m_gtScales->getPrec_DeltaEta_Cosh(lutName_02); if (precCoshLUT_02 - precCosLUT_02 != 0) - LogDebug("L1TGlobal") << "Warning: Cos and Cosh LUTs on different precision" << std::endl; + LogDebug("L1TGlobal") << "Warning: Cos and Cosh LUTs on different precision"; } double cosDeltaPhiPhy_12 = cos(deltaPhiPhy_12); @@ -619,7 +603,7 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons coshDeltaEtaLUT_12 = m_gtScales->getLUT_DeltaEta_Cosh(lutName_12, deltaEtaFW_12); unsigned int precCoshLUT_12 = m_gtScales->getPrec_DeltaEta_Cosh(lutName_12); if (precCoshLUT_12 - precCosLUT_12 != 0) - LogDebug("L1TGlobal") << "Warning: Cos and Cosh LUTs on different precision" << std::endl; + LogDebug("L1TGlobal") << "Warning: Cos and Cosh LUTs on different precision"; } std::string lutName = lutObj0; @@ -656,7 +640,7 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons << " massSq (shift)= " << (massSq_01 / pow(10, preShift_01 + corrPar.precMassCut)) << "\n" << " massSqPhy/2 = " << massSqPhy_01 - << " sqrt(|massSq|) = " << sqrt(fabs(2. * massSqPhy_01)) << std::endl; + << " sqrt(|massSq|) = " << sqrt(fabs(2. * massSqPhy_01)); LogDebug("L1TGlobal") << "####################################\n"; LogDebug("L1TGlobal") << " Testing the dimuon invariant mass between the SECOND PAIR 0-2 (" << lutObj0 @@ -666,7 +650,7 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons << " massSq (shift)= " << (massSq_02 / pow(10, preShift_02 + corrPar.precMassCut)) << "\n" << " massSqPhy/2 = " << massSqPhy_02 - << " sqrt(|massSq|) = " << sqrt(fabs(2. * massSqPhy_02)) << std::endl; + << " sqrt(|massSq|) = " << sqrt(fabs(2. * massSqPhy_02)); LogDebug("L1TGlobal") << "####################################\n"; LogDebug("L1TGlobal") << " Testing the dimuon invariant mass between the THIRD PAIR 1-2 (" << lutObj1 @@ -676,38 +660,37 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons << " massSq (shift)= " << (massSq_12 / pow(10, preShift_12 + corrPar.precMassCut)) << "\n" << " massSqPhy/2 = " << massSqPhy_12 - << " sqrt(|massSq|) = " << sqrt(fabs(2. * massSqPhy_12)) << std::endl; + << " sqrt(|massSq|) = " << sqrt(fabs(2. * massSqPhy_12)); LogDebug("L1TGlobal") << "\n ########### THREE-BODY INVARIANT MASS #########################\n"; long long massSq = 0; if (preShift_01 == preShift_02 && preShift_01 == preShift_12 && preShift_02 == preShift_12) { LogDebug("L1TGlobal") << "Check the preshift value: " << preShift_01 << " = " << preShift_02 << " = " - << preShift_12 << std::endl; + << preShift_12; preShift = preShift_01; } else { LogDebug("L1TGlobal") - << "Preshift values considered for the sum of the dimuon invariant masses are different!" << std::endl; + << "Preshift values considered for the sum of the dimuon invariant masses are different!"; } if ((massSq_01 != massSq_02) && (massSq_01 != massSq_12) && (massSq_02 != massSq_12)) { massSq = massSq_01 + massSq_02 + massSq_12; - LogDebug("L1TGlobal") << "massSq = " << massSq << std::endl; + LogDebug("L1TGlobal") << "massSq = " << massSq; } else { - LogDebug("L1TGlobal") << "Same pair of muons considered, three-body invariant mass do not computed" - << std::endl; + LogDebug("L1TGlobal") << "Same pair of muons considered, three-body invariant mass do not computed"; } if (massSq >= 0 && massSq >= (long long)(corrPar.minMassCutValue * pow(10, preShift)) && massSq <= (long long)(corrPar.maxMassCutValue * pow(10, preShift))) { LogDebug("L1TGlobal") << " Passed Invariant Mass Cut [" << (long long)(corrPar.minMassCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxMassCutValue * pow(10, preShift)) << "]" << std::endl; + << (long long)(corrPar.maxMassCutValue * pow(10, preShift)) << "]"; reqResult = true; } else { LogDebug("L1TGlobal") << " Failed Invariant Mass Cut [" << (long long)(corrPar.minMassCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxMassCutValue * pow(10, preShift)) << "]" << std::endl; + << (long long)(corrPar.maxMassCutValue * pow(10, preShift)) << "]"; reqResult = false; } } @@ -722,8 +705,9 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons } //end loop over first leg if (m_verbosity && condResult) { - LogDebug("L1TGlobal") << " pass(es) the correlation condition.\n" << std::endl; + LogDebug("L1TGlobal") << " pass(es) the correlation condition.\n"; } + return condResult; } diff --git a/L1Trigger/L1TGlobal/src/CorrWithOverlapRemovalCondition.cc b/L1Trigger/L1TGlobal/src/CorrWithOverlapRemovalCondition.cc index 5c26f8a51cdfe..6f6bbc343d8c4 100644 --- a/L1Trigger/L1TGlobal/src/CorrWithOverlapRemovalCondition.cc +++ b/L1Trigger/L1TGlobal/src/CorrWithOverlapRemovalCondition.cc @@ -138,7 +138,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE //std::ostringstream myCout; //m_gtCorrelationWithOverlapRemovalTemplate->print(myCout); //LogDebug("L1TGlobal") - // << "CorrelationWithOverlapRemoval Condition Evaluation \n" << myCout.str() << std::endl; + // << "CorrelationWithOverlapRemoval Condition Evaluation \n" << myCout.str(); bool condResult = false; bool reqObjResult = false; @@ -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]; @@ -201,7 +196,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE std::ostringstream myCout; muCondition.print(myCout); - LogDebug("L1TGlobal") << myCout.str() << std::endl; + LogDebug("L1TGlobal") << myCout.str(); } } break; case CondCalo: { @@ -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]; @@ -222,7 +216,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE std::ostringstream myCout; caloCondition.print(myCout); - LogDebug("L1TGlobal") << myCout.str() << std::endl; + LogDebug("L1TGlobal") << myCout.str(); } } break; case CondEnergySum: { @@ -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]; @@ -241,7 +234,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE std::ostringstream myCout; eSumCondition.print(myCout); - LogDebug("L1TGlobal") << myCout.str() << std::endl; + LogDebug("L1TGlobal") << myCout.str(); } } break; default: { @@ -252,8 +245,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE // return if first subcondition is false if (!reqObjResult) { - LogDebug("L1TGlobal") << "\n First sub-condition false, second sub-condition not evaluated and not printed." - << std::endl; + LogDebug("L1TGlobal") << "\n First sub-condition false, second sub-condition not evaluated and not printed."; return false; } @@ -267,15 +259,15 @@ 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) { std::ostringstream myCout; muCondition.print(myCout); - LogDebug("L1TGlobal") << myCout.str() << std::endl; + LogDebug("L1TGlobal") << myCout.str(); } } break; case CondCalo: { @@ -286,8 +278,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]; @@ -295,7 +286,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE std::ostringstream myCout; caloCondition.print(myCout); - LogDebug("L1TGlobal") << myCout.str() << std::endl; + LogDebug("L1TGlobal") << myCout.str(); } } break; @@ -307,15 +298,15 @@ 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) { std::ostringstream myCout; eSumCondition.print(myCout); - LogDebug("L1TGlobal") << myCout.str() << std::endl; + LogDebug("L1TGlobal") << myCout.str(); } } break; default: { @@ -330,8 +321,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE } else { LogDebug("L1TGlobal") << "\n" << " Both sub-conditions true for object requirements." - << " Evaluate correlation requirements.\n" - << std::endl; + << " Evaluate correlation requirements.\n"; } // third object (used for overlap removal) @@ -344,15 +334,15 @@ 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) { std::ostringstream myCout; muCondition.print(myCout); - LogDebug("L1TGlobal") << myCout.str() << std::endl; + LogDebug("L1TGlobal") << myCout.str(); } } break; case CondCalo: { @@ -363,15 +353,15 @@ 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) { std::ostringstream myCout; caloCondition.print(myCout); - LogDebug("L1TGlobal") << myCout.str() << std::endl; + LogDebug("L1TGlobal") << myCout.str(); } } break; @@ -383,15 +373,15 @@ 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) { std::ostringstream myCout; eSumCondition.print(myCout); - LogDebug("L1TGlobal") << myCout.str() << std::endl; + LogDebug("L1TGlobal") << myCout.str(); } } break; default: { @@ -404,14 +394,12 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE if (!reqObjResult) { LogDebug("L1TGlobal") << "\n" << " Third sub-condtion false for object requirements." - << " Algorithm returning false.\n" - << std::endl; + << " Algorithm returning false.\n"; return false; } else { LogDebug("L1TGlobal") << "\n" << " All three sub-conditions true for object requirements." - << " Evaluate correlation requirements and overlap removal.\n" - << std::endl; + << " Evaluate correlation requirements and overlap removal.\n"; } // since we have two good legs and overlap-removal let, get the correlation parameters @@ -420,7 +408,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 @@ -483,16 +471,16 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE //phiBound = par.phiBins.size()/2; phiBound = (int)((par.phiMax - par.phiMin) / par.phiStep) / 2; } - LogDebug("L1TGlobal") << "Phi Bound = " << phiBound << std::endl; + LogDebug("L1TGlobal") << "Phi Bound = " << phiBound; // Keep track of objects for LUTS std::string lutObj0 = "NULL"; std::string lutObj1 = "NULL"; std::string lutObj2 = "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 2: std::vector size: " << (cond2Comb.size()) << std::endl; + LogTrace("L1TGlobal") << " Sub-condition 0: std::vector size: " << cond0Comb.size(); + LogTrace("L1TGlobal") << " Sub-condition 1: std::vector size: " << cond1Comb.size(); + LogTrace("L1TGlobal") << " Sub-condition 2: std::vector size: " << cond2Comb.size(); // /////////////////////////////////////////////////////////////////////////////////////////// // loop over all combinations which produced individually "true" as Type1s @@ -500,32 +488,31 @@ 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 SingleCombInCond 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 - // LogDebug("L1TGlobal") << "Muon phi" << phiIndex0 << " eta " << etaIndex0 << " etaBin0 = " << etaBin0 << " et " << etIndex0 << std::endl; + // LogDebug("L1TGlobal") << "Muon phi" << phiIndex0 << " eta " << etaIndex0 << " etaBin0 = " << etaBin0 << " et " << etIndex0; // etBin0 = etIndex0; @@ -543,7 +530,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE binEdges = m_gtScales->getMUScales().etBins.at(etBin0); et0Phy = 0.5 * (binEdges.second + binEdges.first); - LogDebug("L1TGlobal") << "Found all quantities for the muon 0" << std::endl; + LogDebug("L1TGlobal") << "Found all quantities for the muon 0"; } break; // Calorimeter Objects (EG, Jet, Tau) @@ -558,7 +545,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE etaBin0 = etaIndex0; if (etaBin0 < 0) etaBin0 = m_gtScales->getEGScales().etaBins.size() + etaBin0; - // LogDebug("L1TGlobal") << "EG0 phi" << phiIndex0 << " eta " << etaIndex0 << " etaBin0 = " << etaBin0 << " et " << etIndex0 << std::endl; + // LogDebug("L1TGlobal") << "EG0 phi" << phiIndex0 << " eta " << etaIndex0 << " etaBin0 = " << etaBin0 << " et " << etIndex0; etBin0 = etIndex0; int ssize = m_gtScales->getEGScales().etBins.size(); @@ -641,10 +628,10 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE lutName += "-MU"; long long tst = m_gtScales->getLUT_CalMuEta(lutName, etaBin0); LogDebug("L1TGlobal") << lutName << " EtaCal = " << etaIndex0 << " etaBin0 = " << etaBin0 - << " EtaMu = " << tst << std::endl; + << " EtaMu = " << tst; etaIndex0 = tst; tst = m_gtScales->getLUT_CalMuPhi(lutName, phiIndex0); - LogDebug("L1TGlobal") << lutName << " PhiCal = " << phiIndex0 << " PhiMu = " << tst << std::endl; + LogDebug("L1TGlobal") << lutName << " PhiCal = " << phiIndex0 << " PhiMu = " << tst; phiIndex0 = tst; } @@ -699,7 +686,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE default: edm::LogError("L1TGlobal") << "\n Error: " << "Unmatched object type from template to EtSumType, cndObjTypeVec[0] = " - << cndObjTypeVec[0] << std::endl; + << cndObjTypeVec[0]; type = l1t::EtSum::EtSumType::kTotalEt; break; } @@ -765,7 +752,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE std::string lutName = lutObj0; lutName += "-MU"; long long tst = m_gtScales->getLUT_CalMuPhi(lutName, phiIndex0); - LogDebug("L1TGlobal") << lutName << " PhiCal = " << phiIndex0 << " PhiMu = " << tst << std::endl; + LogDebug("L1TGlobal") << lutName << " PhiCal = " << phiIndex0 << " PhiMu = " << tst; phiIndex0 = tst; } @@ -782,34 +769,32 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE default: { // should not arrive here, there are no correlation conditions defined for this object - LogDebug("L1TGlobal") << "Error could not find the Cond Category for Leg 0" << std::endl; + LogDebug("L1TGlobal") << "Error could not find the Cond Category for Leg 0"; return false; } break; } //end switch on first leg type - LogDebug("L1TGlobal") << "lutObj0 = " << lutObj0 << std::endl; + LogDebug("L1TGlobal") << "lutObj0 = " << lutObj0; // /////////////////////////////////////////////////////////////////////////////////////////// // 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 SingleCombInCond 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; + LogDebug("L1TGlobal") << "Corr Condition looking at same leg...skip"; continue; } @@ -824,7 +809,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE etaBin1 = etaIndex1; if (etaBin1 < 0) etaBin1 = m_gtScales->getMUScales().etaBins.size() + etaBin1; - // LogDebug("L1TGlobal") << "Muon phi" << phiIndex1 << " eta " << etaIndex1 << " etaBin1 = " << etaBin1 << " et " << etIndex1 << std::endl; + // LogDebug("L1TGlobal") << "Muon phi" << phiIndex1 << " eta " << etaIndex1 << " etaBin1 = " << etaBin1 << " et " << etIndex1; etBin1 = etIndex1; int ssize = m_gtScales->getMUScales().etBins.size(); @@ -935,10 +920,10 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE std::string lutName = lutObj1; lutName += "-MU"; long long tst = m_gtScales->getLUT_CalMuEta(lutName, etaBin1); - LogDebug("L1TGlobal") << lutName << " EtaCal = " << etaIndex1 << " EtaMu = " << tst << std::endl; + LogDebug("L1TGlobal") << lutName << " EtaCal = " << etaIndex1 << " EtaMu = " << tst; etaIndex1 = tst; tst = m_gtScales->getLUT_CalMuPhi(lutName, phiIndex1); - LogDebug("L1TGlobal") << lutName << " PhiCal = " << phiIndex1 << " PhiMu = " << tst << std::endl; + LogDebug("L1TGlobal") << lutName << " PhiCal = " << phiIndex1 << " PhiMu = " << tst; phiIndex1 = tst; } @@ -951,7 +936,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE } // end case CondCalo break; case CondEnergySum: { - LogDebug("L1TGlobal") << "Looking at second Condition as Energy Sum: " << cndObjTypeVec[1] << std::endl; + LogDebug("L1TGlobal") << "Looking at second Condition as Energy Sum: " << cndObjTypeVec[1]; etSumCond = true; //Stupid mapping between enum types for energy sums. @@ -992,14 +977,14 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE default: edm::LogError("L1TGlobal") << "\n Error: " << "Unmatched object type from template to EtSumType, cndObjTypeVec[1] = " - << cndObjTypeVec[1] << std::endl; + << cndObjTypeVec[1]; type = l1t::EtSum::EtSumType::kTotalEt; break; } candEtSumVec = m_uGtB->getCandL1EtSum(); - LogDebug("L1TGlobal") << "obj " << lutObj1 << " Vector Size " << candEtSumVec->size(cond1bx) << std::endl; + LogDebug("L1TGlobal") << "obj " << lutObj1 << " Vector Size " << candEtSumVec->size(cond1bx); for (int iEtSum = 0; iEtSum < (int)candEtSumVec->size(cond1bx); iEtSum++) { if ((candEtSumVec->at(cond1bx, iEtSum))->getType() == type) { phiIndex1 = (candEtSumVec->at(cond1bx, iEtSum))->hwPhi(); @@ -1058,7 +1043,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE std::string lutName = lutObj1; lutName += "-MU"; long long tst = m_gtScales->getLUT_CalMuPhi(lutName, phiIndex1); - LogDebug("L1TGlobal") << lutName << " PhiCal = " << phiIndex1 << " PhiMu = " << tst << std::endl; + LogDebug("L1TGlobal") << lutName << " PhiCal = " << phiIndex1 << " PhiMu = " << tst; phiIndex1 = tst; } @@ -1074,7 +1059,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE break; default: { // should not arrive here, there are no correlation conditions defined for this object - LogDebug("L1TGlobal") << "Error could not find the Cond Category for Leg 0" << std::endl; + LogDebug("L1TGlobal") << "Error could not find the Cond Category for Leg 0"; return false; } break; } //end switch on second leg @@ -1129,7 +1114,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE << "Obj0 etaFW = " << etaIndex0 << " Obj1 etaFW = " << etaIndex1 << "\n" << " DeltaEtaFW = " << deltaEtaFW << "\n" << " LUT Name = " << lutName << " Prec = " << precDeltaEtaLUT - << " DeltaEtaLUT = " << deltaEtaLUT << std::endl; + << " DeltaEtaLUT = " << deltaEtaLUT; // If there is a delta eta, check it. if (corrPar.corrCutType & 0x1) { @@ -1142,19 +1127,19 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE << " Precision Shift = " << preShift << "\n" << " deltaEta (shift)= " << (deltaEtaLUT / pow(10, preShift + corrPar.precEtaCut)) << "\n" - << " deltaEtaPhy = " << deltaEtaPhy << std::endl; + << " deltaEtaPhy = " << deltaEtaPhy; //if(preShift>0) deltaEtaLUT /= pow(10,preShift); if (deltaEtaLUT >= (long long)(corrPar.minEtaCutValue * pow(10, preShift)) && deltaEtaLUT <= (long long)(corrPar.maxEtaCutValue * pow(10, preShift))) { LogDebug("L1TGlobal") << " Passed Delta Eta Cut [" << (long long)(corrPar.minEtaCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxEtaCutValue * pow(10, preShift)) << "]" << std::endl; + << (long long)(corrPar.maxEtaCutValue * pow(10, preShift)) << "]"; } else { LogDebug("L1TGlobal") << " Failed Delta Eta Cut [" << (long long)(corrPar.minEtaCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxEtaCutValue * pow(10, preShift)) << "]" << std::endl; + << (long long)(corrPar.maxEtaCutValue * pow(10, preShift)) << "]"; reqResult = false; } } @@ -1170,19 +1155,19 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE << " Precision Shift = " << preShift << "\n" << " deltaPhi (shift)= " << (deltaPhiLUT / pow(10, preShift + corrPar.precPhiCut)) << "\n" - << " deltaPhiPhy = " << deltaPhiPhy << std::endl; + << " deltaPhiPhy = " << deltaPhiPhy; //if(preShift>0) deltaPhiLUT /= pow(10,preShift); if (deltaPhiLUT >= (long long)(corrPar.minPhiCutValue * pow(10, preShift)) && deltaPhiLUT <= (long long)(corrPar.maxPhiCutValue * pow(10, preShift))) { LogDebug("L1TGlobal") << " Passed Delta Phi Cut [" << (long long)(corrPar.minPhiCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxPhiCutValue * pow(10, preShift)) << "]" << std::endl; + << (long long)(corrPar.maxPhiCutValue * pow(10, preShift)) << "]"; } else { LogDebug("L1TGlobal") << " Failed Delta Phi Cut [" << (long long)(corrPar.minPhiCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxPhiCutValue * pow(10, preShift)) << "]" << std::endl; + << (long long)(corrPar.maxPhiCutValue * pow(10, preShift)) << "]"; reqResult = false; } } @@ -1203,17 +1188,17 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE << " Precision Shift = " << preShift << "\n" << " deltaRSqLUT (shift)= " << (deltaRSq / pow(10, preShift + corrPar.precDRCut)) << "\n" - << " deltaRSqPhy = " << deltaRSqPhy << std::endl; + << " deltaRSqPhy = " << deltaRSqPhy; //if(preShift>0) deltaRSq /= pow(10,preShift); if (deltaRSq >= (long long)(corrPar.minDRCutValue * pow(10, preShift)) && deltaRSq <= (long long)(corrPar.maxDRCutValue * pow(10, preShift))) { LogDebug("L1TGlobal") << " Passed Delta R Cut [" << (long long)(corrPar.minDRCutValue * pow(10, preShift)) - << "," << (long long)(corrPar.maxDRCutValue * pow(10, preShift)) << "]" << std::endl; + << "," << (long long)(corrPar.maxDRCutValue * pow(10, preShift)) << "]"; } else { LogDebug("L1TGlobal") << " Failed Delta R Cut [" << (int)(corrPar.minDRCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxDRCutValue * pow(10, preShift)) << "]" << std::endl; + << (long long)(corrPar.maxDRCutValue * pow(10, preShift)) << "]"; reqResult = false; } } @@ -1242,13 +1227,13 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE unsigned int precSinLUT1 = m_gtScales->getPrec_Sin(lutName1); if (precCosLUT0 - precCosLUT1 != 0) - LogDebug("L1TGlobal") << "Warning: Cos LUTs for TwoBodyPt on different Precision" << std::endl; + LogDebug("L1TGlobal") << "Warning: Cos LUTs for TwoBodyPt on different Precision"; if (precSinLUT0 - precSinLUT1 != 0) - LogDebug("L1TGlobal") << "Warning: Sin LUTs for TwoBodyPt on different Precision" << std::endl; + LogDebug("L1TGlobal") << "Warning: Sin LUTs for TwoBodyPt on different Precision"; if (precSinLUT0 - precCosLUT1 != 0) - LogDebug("L1TGlobal") << "Warning: Sin and Cos LUTs for TwoBodyPt on different Precision" << std::endl; + LogDebug("L1TGlobal") << "Warning: Sin and Cos LUTs for TwoBodyPt on different Precision"; if (precSinLUT1 - precCosLUT0 != 0) - LogDebug("L1TGlobal") << "Warning: Sin and Cos LUTs for TwoBodyPt on different Precision" << std::endl; + LogDebug("L1TGlobal") << "Warning: Sin and Cos LUTs for TwoBodyPt on different Precision"; long long cosPhi1LUT = m_gtScales->getLUT_Cos(lutName0, phiIndex0); long long sinPhi1LUT = m_gtScales->getLUT_Sin(lutName0, phiIndex0); @@ -1289,23 +1274,23 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE unsigned int preShift = precPtLUTObj0 + precPtLUTObj1 + 2 * precCosLUT0; LogTrace("L1TGlobal") << "TBPT Result -- Phys: " << tbptSqPhy << "\tHW: " << tbptSqHW << "\tShifted\t" - << tbptSqHW / pow(10, preShift) << std::endl; + << tbptSqHW / pow(10, preShift); preShift = preShift - corrPar.precTBPTCut; - LogDebug("L1TGlobal") - << " Testing Two Body Pt Cut (" << lutObj0 << "," << lutObj1 << ") [" - << (long long)(corrPar.minTBPTCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxTBPTCutValue * pow(10, preShift)) << "] with precision = " << corrPar.precTBPTCut - << "\n" - << " etIndex0 = " << etIndex0 << " pt0LUT = " << ptObj0 << " PhyEt0 = " << et0Phy << "\n" - << " etIndex1 = " << etIndex1 << " pt1LUT = " << ptObj1 << " PhyEt1 = " << et1Phy << "\n" - << " Precision Shift = " << preShift << "\n" - << " Sin(phi1): LUT/Phys\t " << sinPhi1LUT << " / " << sinPhi1Phy << "\n" - << " Sin(phi2): LUT/Phys\t " << sinPhi2LUT << " / " << sinPhi2Phy << "\n" - << " Cos(phi1): LUT/Phys\t " << cosPhi1LUT << " / " << cosPhi1Phy << "\n" - << " Cos(phi2): LUT/Phys\t " << cosPhi2LUT << " / " << cosPhi2Phy - << "\n" + LogDebug("L1TGlobal") << " Testing Two Body Pt Cut (" << lutObj0 << "," << lutObj1 << ") [" + << (long long)(corrPar.minTBPTCutValue * pow(10, preShift)) << "," + << (long long)(corrPar.maxTBPTCutValue * pow(10, preShift)) + << "] with precision = " << corrPar.precTBPTCut << "\n" + << " etIndex0 = " << etIndex0 << " pt0LUT = " << ptObj0 + << " PhyEt0 = " << et0Phy << "\n" + << " etIndex1 = " << etIndex1 << " pt1LUT = " << ptObj1 + << " PhyEt1 = " << et1Phy << "\n" + << " Precision Shift = " << preShift << "\n" + << " Sin(phi1): LUT/Phys\t " << sinPhi1LUT << " / " << sinPhi1Phy << "\n" + << " Sin(phi2): LUT/Phys\t " << sinPhi2LUT << " / " << sinPhi2Phy << "\n" + << " Cos(phi1): LUT/Phys\t " << cosPhi1LUT << " / " << cosPhi1Phy << "\n" + << " Cos(phi2): LUT/Phys\t " << cosPhi2LUT << " / " << cosPhi2Phy << "\n" // << " deltaPhiLUT = " << deltaPhiLUT << "\n" // << " deltaEtaLUT = " << deltaEtaLUT << "\n" @@ -1313,21 +1298,21 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE // << " Precision Shift = " << preShift << "\n" // << " deltaRSqLUT (shift)= " << (deltaRSq/pow(10,preShift+corrPar.precDRCut)) << "\n" // << " deltaRSqPhy = " << deltaRSqPhy - << std::endl; + ; if (tbptSqHW > 0. && tbptSqHW >= (long long)(corrPar.minTBPTCutValue * pow(10, preShift))) { LogDebug("L1TGlobal") << " Passed Two Body pT Cut [" << (long long)(corrPar.minTBPTCutValue * pow(10, preShift)) << "]" << "\twith value: " << tbptSqHW << "\n" << "\tPhysics Cut[" << corrPar.minTBPTCutValue / pow(10, corrPar.precTBPTCut) - << "]\tPhysics Value: " << tbptSqPhy << std::endl; + << "]\tPhysics Value: " << tbptSqPhy; } else { LogDebug("L1TGlobal") << " Failed Two Body pT Cut [" << (long long)(corrPar.minTBPTCutValue * pow(10, preShift)) << "]" << "\t with value: " << tbptSqHW << "\n" << "\tPhysics Cut[" << corrPar.minTBPTCutValue / pow(10, corrPar.precTBPTCut) - << "]\tPhysics Value: " << tbptSqPhy << std::endl; + << "]\tPhysics Value: " << tbptSqPhy; reqResult = false; } } @@ -1353,7 +1338,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE coshDeltaEtaLUT = m_gtScales->getLUT_DeltaEta_Cosh(lutName, deltaEtaFW); unsigned int precCoshLUT = m_gtScales->getPrec_DeltaEta_Cosh(lutName); if (precCoshLUT - precCosLUT != 0) - LogDebug("L1TGlobal") << "Warning: Cos and Cosh LUTs on different Precision" << std::endl; + LogDebug("L1TGlobal") << "Warning: Cos and Cosh LUTs on different Precision"; } std::string lutName = lutObj0; @@ -1388,19 +1373,19 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE << " deltaPhiPhy = " << deltaPhiPhy << " cos() = " << cosDeltaPhiPhy << "\n" << " deltaEtaPhy = " << deltaEtaPhy << " cosh()= " << coshDeltaEtaPhy << "\n" << " massSqPhy/2 = " << massSqPhy - << " sqrt(|massSq|) = " << sqrt(fabs(2. * massSqPhy)) << std::endl; + << " sqrt(|massSq|) = " << sqrt(fabs(2. * massSqPhy)); //if(preShift>0) massSq /= pow(10,preShift); if (massSq >= 0 && massSq >= (long long)(corrPar.minMassCutValue * pow(10, preShift)) && massSq <= (long long)(corrPar.maxMassCutValue * pow(10, preShift))) { LogDebug("L1TGlobal") << " Passed Invariant Mass Cut [" << (long long)(corrPar.minMassCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxMassCutValue * pow(10, preShift)) << "]" << std::endl; + << (long long)(corrPar.maxMassCutValue * pow(10, preShift)) << "]"; } else { LogDebug("L1TGlobal") << " Failed Invariant Mass Cut [" << (long long)(corrPar.minMassCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxMassCutValue * pow(10, preShift)) << "]" << std::endl; + << (long long)(corrPar.maxMassCutValue * pow(10, preShift)) << "]"; reqResult = false; } } @@ -1422,19 +1407,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 SingleCombInCond 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: { @@ -1445,7 +1428,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE int etaBin2 = etaIndex2; if (etaBin2 < 0) etaBin2 = m_gtScales->getMUScales().etaBins.size() + etaBin2; //twos complement - //LogDebug("L1TGlobal") << "Muon phi" << phiIndex2 << " eta " << etaIndex2 << " etaBin2 = " << etaBin2 << " et " << etIndex2 << std::endl; + //LogDebug("L1TGlobal") << "Muon phi" << phiIndex2 << " eta " << etaIndex2 << " etaBin2 = " << etaBin2 << " et " << etIndex2; // Determine Floating Pt numbers for floating point caluclation std::pair binEdges = m_gtScales->getMUScales().phiBins.at(phiIndex2); @@ -1453,7 +1436,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE binEdges = m_gtScales->getMUScales().etaBins.at(etaBin2); eta2Phy = 0.5 * (binEdges.second + binEdges.first); - LogDebug("L1TGlobal") << "Found all quantities for the muon 0" << std::endl; + LogDebug("L1TGlobal") << "Found all quantities for the muon 0"; } break; // Calorimeter Objects (EG, Jet, Tau) @@ -1466,7 +1449,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE etaIndex2 = (candCaloVec->at(cond2bx, obj2Index))->hwEta(); if (etaBin2 < 0) etaBin2 = m_gtScales->getEGScales().etaBins.size() + etaBin2; - //LogDebug("L1TGlobal") << "EG0 phi" << phiIndex2 << " eta " << etaIndex2 << " etaBin2 = " << etaBin2 << " et " << etIndex2 << std::endl; + //LogDebug("L1TGlobal") << "EG0 phi" << phiIndex2 << " eta " << etaIndex2 << " etaBin2 = " << etaBin2 << " et " << etIndex2; // Determine Floating Pt numbers for floating point caluclation std::pair binEdges = m_gtScales->getEGScales().phiBins.at(phiIndex2); @@ -1513,11 +1496,11 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE lutName += "-MU"; long long tst = m_gtScales->getLUT_CalMuEta(lutName, etaBin2); LogDebug("L1TGlobal") << lutName << " EtaCal = " << etaIndex2 << " etaBin2 = " << etaBin2 - << " EtaMu = " << tst << std::endl; + << " EtaMu = " << tst; etaIndex2 = tst; tst = m_gtScales->getLUT_CalMuPhi(lutName, phiIndex2); - LogDebug("L1TGlobal") << lutName << " PhiCal = " << phiIndex2 << " PhiMu = " << tst << std::endl; + LogDebug("L1TGlobal") << lutName << " PhiCal = " << phiIndex2 << " PhiMu = " << tst; phiIndex2 = tst; } @@ -1565,8 +1548,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE default: edm::LogError("L1TGlobal") << "\n Error: " - << "Unmatched object type from template to EtSumType, cndObjTypeVec[2] = " << cndObjTypeVec[2] - << std::endl; + << "Unmatched object type from template to EtSumType, cndObjTypeVec[2] = " << cndObjTypeVec[2]; type = l1t::EtSum::EtSumType::kTotalEt; break; } @@ -1600,7 +1582,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE std::string lutName = lutObj2; lutName += "-MU"; long long tst = m_gtScales->getLUT_CalMuPhi(lutName, phiIndex2); - LogDebug("L1TGlobal") << lutName << " PhiCal = " << phiIndex2 << " PhiMu = " << tst << std::endl; + LogDebug("L1TGlobal") << lutName << " PhiCal = " << phiIndex2 << " PhiMu = " << tst; phiIndex2 = tst; } @@ -1611,7 +1593,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE break; default: { // should not arrive here, there are no correlation conditions defined for this object - LogDebug("L1TGlobal") << "Error could not find the Cond Category for Leg 3" << std::endl; + LogDebug("L1TGlobal") << "Error could not find the Cond Category for Leg 3"; return false; } break; } //end switch on overlap-removal leg type @@ -1653,7 +1635,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE << "Obj0 etaFW = " << etaIndex0 << " Obj2 etaFW = " << etaIndex2 << "\n" << " DeltaEtaFW = " << deltaEtaFW << "\n" << " LUT Name = " << lutName << " Prec = " << precDeltaEtaLUT - << " DeltaEtaLUT = " << deltaEtaLUT << std::endl; + << " DeltaEtaLUT = " << deltaEtaLUT; // If there is a OverlapRemovalDeltaEta cut, check it. if (corrPar.corrCutType & 0x10) { @@ -1666,23 +1648,21 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE << " Precision Shift = " << preShift << "\n" << " deltaEta (shift)= " << (deltaEtaLUT / pow(10, preShift + corrPar.precOverlapRemovalEtaCut)) << "\n" - << " deltaEtaPhy = " << deltaEtaPhy << std::endl; + << " deltaEtaPhy = " << deltaEtaPhy; //if(preShift>0) deltaEtaLUT /= pow(10,preShift); if (deltaEtaLUT >= (long long)(corrPar.minOverlapRemovalEtaCutValue * pow(10, preShift)) && deltaEtaLUT <= (long long)(corrPar.maxOverlapRemovalEtaCutValue * pow(10, preShift))) { LogDebug("L1TGlobal") << " Satified Leg1 Overlap Removal Delta Eta Cut [" << (long long)(corrPar.minOverlapRemovalEtaCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxOverlapRemovalEtaCutValue * pow(10, preShift)) << "]" - << std::endl; + << (long long)(corrPar.maxOverlapRemovalEtaCutValue * pow(10, preShift)) << "]"; // next leg3 object continue; } else { LogDebug("L1TGlobal") << " Failed Leg1 Overlap Removal Delta Eta Cut [" << (long long)(corrPar.minOverlapRemovalEtaCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxOverlapRemovalEtaCutValue * pow(10, preShift)) << "]" - << std::endl; + << (long long)(corrPar.maxOverlapRemovalEtaCutValue * pow(10, preShift)) << "]"; } } @@ -1697,23 +1677,21 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE << " Precision Shift = " << preShift << "\n" << " deltaPhi (shift)= " << (deltaPhiLUT / pow(10, preShift + corrPar.precOverlapRemovalPhiCut)) << "\n" - << " deltaPhiPhy = " << deltaPhiPhy << std::endl; + << " deltaPhiPhy = " << deltaPhiPhy; //if(preShift>0) deltaPhiLUT /= pow(10,preShift); if (deltaPhiLUT >= (long long)(corrPar.minOverlapRemovalPhiCutValue * pow(10, preShift)) && deltaPhiLUT <= (long long)(corrPar.maxOverlapRemovalPhiCutValue * pow(10, preShift))) { LogDebug("L1TGlobal") << " Satisfied Leg1 Overlap Removal Delta Phi Cut [" << (long long)(corrPar.minOverlapRemovalPhiCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxOverlapRemovalPhiCutValue * pow(10, preShift)) << "]" - << std::endl; + << (long long)(corrPar.maxOverlapRemovalPhiCutValue * pow(10, preShift)) << "]"; // next leg3 object continue; } else { LogDebug("L1TGlobal") << " Failed Leg1 Overlap Removal Delta Phi Cut [" << (long long)(corrPar.minOverlapRemovalPhiCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxOverlapRemovalPhiCutValue * pow(10, preShift)) << "]" - << std::endl; + << (long long)(corrPar.maxOverlapRemovalPhiCutValue * pow(10, preShift)) << "]"; } } @@ -1734,23 +1712,21 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE << " Precision Shift = " << preShift << "\n" << " deltaRSqLUT (shift)= " << (deltaRSq / pow(10, preShift + corrPar.precDRCut)) << "\n" - << " deltaRSqPhy = " << deltaRSqPhy << std::endl; + << " deltaRSqPhy = " << deltaRSqPhy; //if(preShift>0) deltaRSq /= pow(10,preShift); if (deltaRSq >= (long long)(corrPar.minOverlapRemovalDRCutValue * pow(10, preShift)) && deltaRSq <= (long long)(corrPar.maxOverlapRemovalDRCutValue * pow(10, preShift))) { LogDebug("L1TGlobal") << " Satified Leg1 Overlap Removal Delta R Cut [" << (long long)(corrPar.minOverlapRemovalDRCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxOverlapRemovalDRCutValue * pow(10, preShift)) << "]" - << std::endl; + << (long long)(corrPar.maxOverlapRemovalDRCutValue * pow(10, preShift)) << "]"; // next leg3 object continue; } else { LogDebug("L1TGlobal") << " Failed Leg1 Overlap Removal Delta R Cut [" << (int)(corrPar.minOverlapRemovalDRCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxOverlapRemovalDRCutValue * pow(10, preShift)) << "]" - << std::endl; + << (long long)(corrPar.maxOverlapRemovalDRCutValue * pow(10, preShift)) << "]"; } } @@ -1791,7 +1767,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE << "Obj1 etaFW = " << etaIndex1 << " Obj1 etaFW = " << etaIndex1 << "\n" << " DeltaEtaFW = " << deltaEtaFW << "\n" << " LUT Name = " << lutName << " Prec = " << precDeltaEtaLUT - << " DeltaEtaLUT = " << deltaEtaLUT << std::endl; + << " DeltaEtaLUT = " << deltaEtaLUT; // If there is a OverlapRemovalDeltaEta cut, check it. // ///////////////////////////////////////////////// @@ -1805,23 +1781,21 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE << " Precision Shift = " << preShift << "\n" << " deltaEta (shift)= " << (deltaEtaLUT / pow(10, preShift + corrPar.precOverlapRemovalEtaCut)) << "\n" - << " deltaEtaPhy = " << deltaEtaPhy << std::endl; + << " deltaEtaPhy = " << deltaEtaPhy; //if(preShift>0) deltaEtaLUT /= pow(10,preShift); if (deltaEtaLUT >= (long long)(corrPar.minOverlapRemovalEtaCutValue * pow(10, preShift)) && deltaEtaLUT <= (long long)(corrPar.maxOverlapRemovalEtaCutValue * pow(10, preShift))) { LogDebug("L1TGlobal") << " Satisfied Leg2 Overlap Removal Delta Eta Cut [" << (long long)(corrPar.minOverlapRemovalEtaCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxOverlapRemovalEtaCutValue * pow(10, preShift)) << "]" - << std::endl; + << (long long)(corrPar.maxOverlapRemovalEtaCutValue * pow(10, preShift)) << "]"; // next leg3 object continue; } else { LogDebug("L1TGlobal") << " Failed Leg2 Overlap Removal Delta Eta Cut [" << (long long)(corrPar.minOverlapRemovalEtaCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxOverlapRemovalEtaCutValue * pow(10, preShift)) << "]" - << std::endl; + << (long long)(corrPar.maxOverlapRemovalEtaCutValue * pow(10, preShift)) << "]"; } } // If there is a OverlapRemovalDeltaPhi cut, check it. @@ -1836,23 +1810,21 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE << " Precision Shift = " << preShift << "\n" << " deltaPhi (shift)= " << (deltaPhiLUT / pow(10, preShift + corrPar.precOverlapRemovalPhiCut)) << "\n" - << " deltaPhiPhy = " << deltaPhiPhy << std::endl; + << " deltaPhiPhy = " << deltaPhiPhy; //if(preShift>0) deltaPhiLUT /= pow(10,preShift); if (deltaPhiLUT >= (long long)(corrPar.minOverlapRemovalPhiCutValue * pow(10, preShift)) && deltaPhiLUT <= (long long)(corrPar.maxOverlapRemovalPhiCutValue * pow(10, preShift))) { LogDebug("L1TGlobal") << " Satisfied Leg2 Overlap Removal Delta Phi Cut [" << (long long)(corrPar.minOverlapRemovalPhiCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxOverlapRemovalPhiCutValue * pow(10, preShift)) << "]" - << std::endl; + << (long long)(corrPar.maxOverlapRemovalPhiCutValue * pow(10, preShift)) << "]"; // next leg3 object continue; } else { LogDebug("L1TGlobal") << " Failed Leg2 Overlap Removal Delta Phi Cut [" << (long long)(corrPar.minOverlapRemovalPhiCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxOverlapRemovalPhiCutValue * pow(10, preShift)) << "]" - << std::endl; + << (long long)(corrPar.maxOverlapRemovalPhiCutValue * pow(10, preShift)) << "]"; } } @@ -1874,23 +1846,21 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE << " Precision Shift = " << preShift << "\n" << " deltaRSqLUT (shift)= " << (deltaRSq / pow(10, preShift + corrPar.precDRCut)) << "\n" - << " deltaRSqPhy = " << deltaRSqPhy << std::endl; + << " deltaRSqPhy = " << deltaRSqPhy; //if(preShift>0) deltaRSq /= pow(10,preShift); if (deltaRSq >= (long long)(corrPar.minOverlapRemovalDRCutValue * pow(10, preShift)) && deltaRSq <= (long long)(corrPar.maxOverlapRemovalDRCutValue * pow(10, preShift))) { LogDebug("L1TGlobal") << " Satisfied Leg2 Overlap Removal Delta R Cut [" << (long long)(corrPar.minOverlapRemovalDRCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxOverlapRemovalDRCutValue * pow(10, preShift)) << "]" - << std::endl; + << (long long)(corrPar.maxOverlapRemovalDRCutValue * pow(10, preShift)) << "]"; // next leg3 object continue; } else { LogDebug("L1TGlobal") << " Failed Leg2 Overlap Removal Delta R Cut [" << (int)(corrPar.minOverlapRemovalDRCutValue * pow(10, preShift)) << "," - << (long long)(corrPar.maxOverlapRemovalDRCutValue * pow(10, preShift)) << "]" - << std::endl; + << (long long)(corrPar.maxOverlapRemovalDRCutValue * pow(10, preShift)) << "]"; } } @@ -1898,10 +1868,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); @@ -1912,7 +1881,7 @@ const bool l1t::CorrWithOverlapRemovalCondition::evaluateCondition(const int bxE } //end loop over first leg if (m_verbosity && condResult) { - LogDebug("L1TGlobal") << " pass(es) the correlation condition.\n" << std::endl; + LogDebug("L1TGlobal") << " pass(es) the correlation condition.\n"; } return condResult; diff --git a/L1Trigger/L1TGlobal/src/EnergySumCondition.cc b/L1Trigger/L1TGlobal/src/EnergySumCondition.cc index 8ab5561ed1296..e62737c4d6e4d 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())) { @@ -114,7 +114,7 @@ const bool l1t::EnergySumCondition::evaluateCondition(const int bxEval) const { } // If no candidates, no use looking any further. - int numberObjects = candVec->size(useBx); + auto const numberObjects = candVec->size(useBx); if (numberObjects < 1) { return false; } @@ -247,13 +247,15 @@ 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; + unsigned int candIndex = 0; bool candOverflow = false; - for (int iEtSum = 0; iEtSum < numberObjects; ++iEtSum) { - l1t::EtSum cand = *(candVec->at(useBx, iEtSum)); + for (size_t iEtSum = 0; iEtSum < numberObjects; ++iEtSum) { + l1t::EtSum const& cand = *(candVec->at(useBx, iEtSum)); if (cand.getType() != type) continue; candEt = cand.hwPt(); candPhi = cand.hwPhi(); + candIndex = iEtSum; } const EnergySumTemplate::ObjectParameter objPar = (*(m_gtEnergySumTemplate->objectParameter()))[iCondition]; @@ -301,10 +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, candIndex); (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..5b039a274dd5d 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())) { @@ -115,8 +115,7 @@ const bool l1t::EnergySumZdcCondition::evaluateCondition(const int bxEval) const } // If no candidates, no use looking any further - int numberObjectsZdc = candVecZdc->size(useBx); - + auto const numberObjectsZdc = candVecZdc->size(useBx); if (numberObjectsZdc < 1) { return false; } @@ -147,10 +146,11 @@ const bool l1t::EnergySumZdcCondition::evaluateCondition(const int bxEval) const l1t::EtSum candZdcMinus; unsigned int candZDCPEsum = 0; unsigned int candZDCMEsum = 0; + unsigned int candIndex = 0; bool myres = false; - for (int iEtSum = 0; iEtSum < numberObjectsZdc; ++iEtSum) { - l1t::EtSum candZdc = *(candVecZdc->at(useBx, iEtSum)); + for (size_t iEtSum = 0; iEtSum < numberObjectsZdc; ++iEtSum) { + l1t::EtSum const& candZdc = *(candVecZdc->at(useBx, iEtSum)); if (candZdc.getType() != type) continue; @@ -158,10 +158,12 @@ const bool l1t::EnergySumZdcCondition::evaluateCondition(const int bxEval) const if (candZdc.getType() == l1t::EtSum::EtSumType::kZDCP) { candZdcPlus = *(candVecZdc->at(useBx, iEtSum)); candZDCPEsum = candZdcPlus.hwPt(); + candIndex = iEtSum; myres = checkThreshold(objPar.etLowThreshold, objPar.etHighThreshold, candZDCPEsum, condGEqVal); } else if (candZdc.getType() == l1t::EtSum::EtSumType::kZDCM) { candZdcMinus = *(candVecZdc->at(useBx, iEtSum)); candZDCMEsum = candZdcMinus.hwPt(); + candIndex = iEtSum; myres = checkThreshold(objPar.etLowThreshold, objPar.etHighThreshold, candZDCMEsum, condGEqVal); } else { LogDebug("L1TGlobal") << "\t\t l1t::EtSum failed ZDC checkThreshold" << std::endl; @@ -174,17 +176,13 @@ const bool l1t::EnergySumZdcCondition::evaluateCondition(const int bxEval) const << "----------------------------------------------> ZDC EtSumType object from EnergySumZdcTemplate" << "\n objPar.etLowThreshold = " << objPar.etLowThreshold << "\n objPar.etHighThreshold = " << objPar.etHighThreshold << "\n candZDCPEsum = " << candZDCPEsum - << "\n candZDCMEsum = " << candZDCMEsum << "\n condGEqVal = " << condGEqVal << "\n myres = " << myres - << std::endl; + << "\n candZDCMEsum = " << candZDCMEsum << "\n condGEqVal = " << condGEqVal << "\n myres = " << myres; } if (not myres) 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, candIndex); (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..219ada828f64c 100644 --- a/L1Trigger/L1TGlobal/src/ExternalCondition.cc +++ b/L1Trigger/L1TGlobal/src/ExternalCondition.cc @@ -89,7 +89,7 @@ void l1t::ExternalCondition::setuGtB(const GlobalBoard* ptrGTB) { m_uGtB = ptrGT const bool l1t::ExternalCondition::evaluateCondition(const int bxEval) const { LogDebug("L1TGlobal") << "Evaluating External Condition " << m_gtExternalTemplate->condName() << " on Channel " << m_gtExternalTemplate->extChannel() << " relative Bx " - << m_gtExternalTemplate->condRelativeBx() << std::endl; + << m_gtExternalTemplate->condRelativeBx(); // number of trigger objects in the condition // in fact, there is only one object // int iCondition = 0; @@ -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,40 +111,38 @@ 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; + LogDebug("L1TGlobal") << "\t\t External Condition was not set"; 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 // set the general result for evaluateCondition to "true" condResult = true; - LogDebug("L1TGlobal") << "\t\t Congrats, External Condition was set!" << std::endl; + LogDebug("L1TGlobal") << "\t\t Congrats, External Condition was set!"; return condResult; } diff --git a/L1Trigger/L1TGlobal/src/GlobalBoard.cc b/L1Trigger/L1TGlobal/src/GlobalBoard.cc index b967fc83095f8..5d210677df5f3 100644 --- a/L1Trigger/L1TGlobal/src/GlobalBoard.cc +++ b/L1Trigger/L1TGlobal/src/GlobalBoard.cc @@ -1030,9 +1030,8 @@ void l1t::GlobalBoard::runGTL(const edm::Event&, objMap.setAlgoName(itAlgo->first); objMap.setAlgoBitNumber(algBitNumber); objMap.setAlgoGtlResult(algResult); + objMap.setCombinationVectors(gtAlg.gtAlgoCombinationVector()); objMap.swapOperandTokenVector(gtAlg.operandTokenVector()); - objMap.swapCombinationVector(gtAlg.gtAlgoCombinationVector()); - // gtAlg is empty now... objMap.swapObjectTypeVector(otypes); if (m_verbosity && m_isDebugEnabled) { diff --git a/L1Trigger/L1TGlobal/src/MuCondition.cc b/L1Trigger/L1TGlobal/src/MuCondition.cc index 279043bb20b68..3713a49ddc846 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 @@ -171,12 +171,11 @@ const bool l1t::MuCondition::evaluateCondition(const int bxEval) const { passCondition = checkObjectParameter(i, *(candVec->at(useBx, index[i])), index[i]); //BLW Change for BXVector tmpResult &= passCondition; if (passCondition) - LogDebug("L1TGlobal") << "===> MuCondition::evaluateCondition, CONGRATS!! This muon passed the condition." - << std::endl; + LogDebug("L1TGlobal") << "===> MuCondition::evaluateCondition, CONGRATS!! This muon passed the condition."; else - LogDebug("L1TGlobal") << "===> MuCondition::evaluateCondition, FAIL!! This muon failed the condition." - << std::endl; - objectsInComb.push_back(index[i]); + LogDebug("L1TGlobal") << "===> MuCondition::evaluateCondition, FAIL!! This muon failed the condition."; + + objectsInComb.emplace_back(useBx, index[i]); } // if permutation does not match particle conditions @@ -304,7 +303,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..ee461f52ce559 100644 --- a/L1Trigger/L1TGlobal/src/MuonShowerCondition.cc +++ b/L1Trigger/L1TGlobal/src/MuonShowerCondition.cc @@ -102,8 +102,8 @@ 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(); - LogDebug("MuonShowerCondition") << "Considering BX " << useBx << std::endl; + L1TObjBxIndexType const useBx = bxEval + m_gtMuonShowerTemplate->condRelativeBx(); + LogDebug("MuonShowerCondition") << "Considering BX " << useBx; // Fail condition if attempting to get BX outside of range if ((useBx < candVec->getFirstBX()) || (useBx > candVec->getLastBX())) { @@ -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 @@ -123,31 +123,21 @@ const bool l1t::MuonShowerCondition::evaluateCondition(const int bxEval) const { // If there is a muon shower trigger, the size of the candidates vector is always 4: // in fact, we have four muon shower objects created in the Global Board. */ - int numberObjects = candVec->size(useBx); + auto const numberObjects = candVec->size(useBx); if (numberObjects < 1) { return false; } - std::vector index(numberObjects); - for (int i = 0; i < numberObjects; ++i) { - index[i] = i; - } - - // index is always zero, as they are global quantities (there is only one object) - int indexObj = 0; - - bool passCondition = false; - - for (int i = 0; i < numberObjects; i++) { - passCondition = checkObjectParameter(0, *(candVec->at(useBx, index[i])), index[i]); //BLW Change for BXVector + for (size_t idx = 0; idx < numberObjects; ++idx) { + auto const passCondition = checkObjectParameter(0, *(candVec->at(useBx, idx)), idx); //BLW Change for BXVector condResult |= passCondition; if (passCondition) { LogDebug("MuonShowerCondition") - << "===> MuShowerCondition::evaluateCondition, PASS! This muon shower passed the condition." << std::endl; - objectsInComb.push_back(indexObj); + << "===> MuShowerCondition::evaluateCondition, PASS! This muon shower passed the condition."; + objectsInComb.emplace_back(useBx, idx); } else LogDebug("MuonShowerCondition") - << "===> MuShowerCondition::evaluateCondition, FAIL! This muon shower failed the condition." << std::endl; + << "===> MuShowerCondition::evaluateCondition, FAIL! This muon shower failed the condition."; } // if we get here all checks were successfull for this combination @@ -167,7 +157,7 @@ const bool l1t::MuonShowerCondition::evaluateCondition(const int bxEval) const { const bool l1t::MuonShowerCondition::checkObjectParameter(const int iCondition, const l1t::MuonShower& cand, - const unsigned int index) const { + const unsigned int) const { // number of objects in condition int nObjInCond = m_gtMuonShowerTemplate->nrObjects(); @@ -181,36 +171,36 @@ const bool l1t::MuonShowerCondition::checkObjectParameter(const int iCondition, << std::hex << "\n\t MuonShower0 = 0x " << objPar.MuonShower0 << "\n\t MuonShower1 = 0x " << objPar.MuonShower1 << "\n\t MuonShower2 = 0x " << objPar.MuonShower2 << "\n\t MuonShowerOutOfTime0 = 0x " << objPar.MuonShowerOutOfTime0 - << "\n\t MuonShowerOutOfTime1 = 0x " << objPar.MuonShowerOutOfTime1 << std::endl; + << "\n\t MuonShowerOutOfTime1 = 0x " << objPar.MuonShowerOutOfTime1; LogDebug("L1TGlobal") << "\n l1t::MuonShower (uGT emulator bits): " << "\n\t MuonShower0: isOneNominalInTime() = " << cand.isOneNominalInTime() << "\n\t MuonShower1: isOneTightInTime() = " << cand.isOneTightInTime() << "\n\t MuonShower2: isTwoLooseDiffSectorsInTime() = " << cand.isTwoLooseDiffSectorsInTime() << "\n\t MuonShowerOutOfTime0: musOutOfTime0() = " << cand.musOutOfTime0() - << "\n\t MuonShowerOutOfTime1: musOutOfTime1() = " << cand.musOutOfTime1() << std::endl; + << "\n\t MuonShowerOutOfTime1: musOutOfTime1() = " << cand.musOutOfTime1(); // Check oneNominalInTime if (cand.isOneNominalInTime() != objPar.MuonShower0) { - LogDebug("L1TGlobal") << "\t\t MuonShower failed MuonShower0 requirement" << std::endl; + LogDebug("L1TGlobal") << "\t\t MuonShower failed MuonShower0 requirement"; return false; } // Check oneTightInTime if (cand.isOneTightInTime() != objPar.MuonShower1) { - LogDebug("L1TGlobal") << "\t\t MuonShower failed MuonShower1 requirement" << std::endl; + LogDebug("L1TGlobal") << "\t\t MuonShower failed MuonShower1 requirement"; return false; } // Check twoLooseInTime if (cand.isTwoLooseDiffSectorsInTime() != objPar.MuonShower2) { - LogDebug("L1TGlobal") << "\t\t MuonShower failed MuonShower2 requirement" << std::endl; + LogDebug("L1TGlobal") << "\t\t MuonShower failed MuonShower2 requirement"; return false; } if (cand.musOutOfTime0() != objPar.MuonShowerOutOfTime0) { - LogDebug("L1TGlobal") << "\t\t MuonShower failed MuonShowerOutOfTime0 requirement" << std::endl; + LogDebug("L1TGlobal") << "\t\t MuonShower failed MuonShowerOutOfTime0 requirement"; return false; } if (cand.musOutOfTime1() != objPar.MuonShowerOutOfTime1) { - LogDebug("L1TGlobal") << "\t\t MuonShower failed MuonShowerOutOfTime1 requirement" << std::endl; + LogDebug("L1TGlobal") << "\t\t MuonShower failed MuonShowerOutOfTime1 requirement"; return false; }