Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:52

0001 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctEmLeafCard.h"
0002 #include <vector>
0003 
0004 using std::endl;
0005 using std::ostream;
0006 using std::vector;
0007 
0008 const unsigned L1GctEmLeafCard::N_SORTERS = 4;
0009 
0010 L1GctEmLeafCard::L1GctEmLeafCard(int id) : m_id(id), m_sorters(4) {
0011   // sorters 0 and 1 are in FPGA U1 and deal with RCT crates 4-8 (13-17)
0012   m_sorters.at(0) = new L1GctElectronSorter(5, true);
0013   m_sorters.at(1) = new L1GctElectronSorter(5, false);
0014 
0015   // sorters 2 and 3 are in FPGA U2 and deal with RCT crates 0-3 (9-12)
0016   m_sorters.at(2) = new L1GctElectronSorter(4, true);
0017   m_sorters.at(3) = new L1GctElectronSorter(4, false);
0018 }
0019 
0020 L1GctEmLeafCard::~L1GctEmLeafCard() {
0021   delete m_sorters.at(0);
0022   delete m_sorters.at(1);
0023   delete m_sorters.at(2);
0024   delete m_sorters.at(3);
0025 }
0026 
0027 /// clear buffers
0028 void L1GctEmLeafCard::reset() {
0029   L1GctProcessor::reset();
0030   for (unsigned i = 0; i < N_SORTERS; i++) {
0031     m_sorters.at(i)->reset();
0032   }
0033 }
0034 
0035 /// partially clear buffers
0036 void L1GctEmLeafCard::setBxRange(const int firstBx, const int numberOfBx) {
0037   L1GctProcessor::setBxRange(firstBx, numberOfBx);
0038   for (unsigned i = 0; i < N_SORTERS; i++) {
0039     m_sorters.at(i)->setBxRange(firstBx, numberOfBx);
0040   }
0041 }
0042 
0043 /// partially clear buffers
0044 void L1GctEmLeafCard::setNextBx(const int bx) {
0045   L1GctProcessor::setNextBx(bx);
0046   for (unsigned i = 0; i < N_SORTERS; i++) {
0047     m_sorters.at(i)->setNextBx(bx);
0048   }
0049 }
0050 
0051 /// fetch input data
0052 void L1GctEmLeafCard::fetchInput() {
0053   for (unsigned i = 0; i < N_SORTERS; i++) {
0054     m_sorters.at(i)->fetchInput();
0055   }
0056 }
0057 
0058 /// process the event
0059 void L1GctEmLeafCard::process() {
0060   for (unsigned i = 0; i < N_SORTERS; i++) {
0061     m_sorters.at(i)->process();
0062   }
0063 }
0064 
0065 /// get the output candidates
0066 vector<L1GctEmCand> L1GctEmLeafCard::getOutputIsoEmCands(int fpga) {
0067   if (fpga < 2) {
0068     return m_sorters.at(2 * fpga)->getOutputCands();
0069   } else {
0070     return vector<L1GctEmCand>(0);
0071   }
0072 }
0073 
0074 /// get the output candidates
0075 vector<L1GctEmCand> L1GctEmLeafCard::getOutputNonIsoEmCands(int fpga) {
0076   if (fpga < 2) {
0077     return m_sorters.at(2 * fpga + 1)->getOutputCands();
0078   } else {
0079     return vector<L1GctEmCand>(0);
0080   }
0081 }
0082 
0083 ostream& operator<<(ostream& s, const L1GctEmLeafCard& card) {
0084   s << "===L1GctEmLeafCard===" << endl;
0085   s << "ID = " << card.m_id << endl;
0086   s << "No of Electron Sorters = " << card.m_sorters.size() << endl;
0087   for (unsigned i = 0; i < card.m_sorters.size(); i++) {
0088     s << std::endl;
0089     s << "===ElectronSorter===" << std::endl;
0090     s << "ElectronSorter no: " << i << endl << (*card.m_sorters.at(i));
0091   }
0092   s << endl;
0093   return s;
0094 }