File indexing completed on 2024-04-06 12:19:52
0001 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctElectronSorter.h"
0002 #include <algorithm>
0003
0004 L1GctElectronSorter::L1GctElectronSorter(int nInputs, bool iso)
0005 : L1GctProcessor(), m_id(nInputs), m_isolation(iso), m_inputCands(nInputs * 4), m_outputCands(4) {}
0006
0007 L1GctElectronSorter::~L1GctElectronSorter() {}
0008
0009
0010 void L1GctElectronSorter::resetProcessor() {
0011 m_inputCands.clear();
0012 m_inputCands.resize(m_id * 4);
0013
0014 m_outputCands.clear();
0015 m_outputCands.resize(4);
0016 }
0017
0018
0019
0020
0021 void L1GctElectronSorter::setupObjects() {
0022
0023
0024 L1CaloEmCand temp;
0025 temp.setBx(bxAbs());
0026 m_inputCands.assign(m_id * 4, temp);
0027 }
0028
0029
0030 void L1GctElectronSorter::fetchInput() {
0031
0032 }
0033
0034
0035 void L1GctElectronSorter::process() {
0036
0037 std::vector<prioritisedEmCand> data(m_inputCands.size());
0038
0039
0040 for (unsigned i = 0; i < m_inputCands.size(); i++) {
0041 prioritisedEmCand c(m_inputCands.at(i), i);
0042 data.at(i) = c;
0043 }
0044
0045
0046 sort(data.begin(), data.end(), rankByGt);
0047
0048
0049 for (int i = 0; i < 4; i++) {
0050 m_outputCands.at(i) = data.at(i).emCand;
0051 }
0052 }
0053
0054 void L1GctElectronSorter::setInputEmCand(const L1CaloEmCand& cand) {
0055
0056
0057
0058
0059
0060
0061 unsigned crate = cand.rctCrate();
0062 unsigned input = ((m_id == 4) ? (crate % 9) : (crate % 9 - 4));
0063 unsigned i = input * 4 + (3 - cand.index());
0064 if (m_inputCands.at(i).rank() == 0) {
0065 m_inputCands.at(i) = cand;
0066 }
0067 }
0068
0069 std::ostream& operator<<(std::ostream& s, const L1GctElectronSorter& ems) {
0070 s << "===L1GctElectronSorter===" << std::endl;
0071 s << "Algo type = " << ems.m_isolation << std::endl;
0072 s << "No of Electron Input Candidates = " << ems.m_inputCands.size() << std::endl;
0073 s << "No of Electron Output Candidates = " << ems.m_outputCands.size() << std::endl;
0074 return s;
0075 }