![]() |
![]() |
00001 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctJetSorter.h" 00002 00003 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctJetCand.h" 00004 00005 L1GctJetSorter::L1GctJetSorter() : 00006 m_inputJets() {} 00007 L1GctJetSorter::L1GctJetSorter(L1GctJetSorter::JetVector& inputJets) : 00008 m_inputJets(inputJets) {} 00009 00010 L1GctJetSorter::~L1GctJetSorter() {} 00011 00012 void L1GctJetSorter::setJets(L1GctJetSorter::JetVector& inputJets) { m_inputJets = inputJets; } 00013 00014 L1GctJetSorter::JetVector L1GctJetSorter::getSortedJets() const { 00015 unsigned nJets = m_inputJets.size(); 00016 std::vector<unsigned> position(nJets, 0); 00017 // Replicate the firmware jet sorting algorithm. 00018 // If two jets in the input array have equal rank, 00019 // the one that occurs first in the array has higher priority. 00020 for (unsigned j1=0; j1<nJets; j1++) { 00021 for (unsigned j2=j1+1; j2<nJets; j2++) { 00022 if (m_inputJets.at(j1).rank() < m_inputJets.at(j2).rank()) { 00023 position.at(j1) = position.at(j1) + 1; 00024 } else { 00025 position.at(j2) = position.at(j2) + 1; 00026 } 00027 } 00028 } 00029 00030 JetVector result(m_inputJets.size()); 00031 for (unsigned j1=0; j1<nJets; j1++) { 00032 result.at(position.at(j1)) = m_inputJets.at(j1); 00033 } 00034 00035 return result; 00036 } 00037 00038 L1GctJetSorter::JetVector L1GctJetSorter::getInputJets() const { return m_inputJets; }