Go to the documentation of this file.00001 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctElectronFinalSort.h"
00002
00003 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctEmLeafCard.h"
00004
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006
00007 #include <algorithm>
00008
00009 L1GctElectronFinalSort::L1GctElectronFinalSort(bool iso, L1GctEmLeafCard* posEtaCard,
00010 L1GctEmLeafCard* negEtaCard):
00011 L1GctProcessor(),
00012 m_emCandsType(iso),
00013 m_thePosEtaLeafCard(0), m_theNegEtaLeafCard(0),
00014 m_inputCands(16),
00015 m_outputCands(4),
00016 m_setupOk(true)
00017 {
00018 if(posEtaCard!=0){
00019 m_thePosEtaLeafCard = posEtaCard;
00020 }else{
00021 m_setupOk = false;
00022 if (m_verbose) {
00023 edm::LogWarning("L1GctSetupError")
00024 <<"L1GctElectronFinalSort::Constructor() : 1st EmLeafCard passed is zero";
00025 }
00026 }
00027 if(negEtaCard!=0){
00028 m_theNegEtaLeafCard = negEtaCard;
00029 }else{
00030 m_setupOk = false;
00031 if (m_verbose) {
00032 edm::LogWarning("L1GctSetupError")
00033 <<"L1GctElectronFinalSort::Constructor() : 2nd EmLeafCard passed is zero";
00034 }
00035 }
00036 if (!m_setupOk && m_verbose) {
00037 edm::LogError("L1GctSetupError") << "L1GctElectronFinalSort has been incorrectly constructed";
00038 }
00039 }
00040
00041 L1GctElectronFinalSort::~L1GctElectronFinalSort(){
00042 m_inputCands.clear();
00043 m_outputCands.contents.clear();
00044 }
00045
00046 void L1GctElectronFinalSort::resetProcessor() {
00047 m_inputCands.clear();
00048 m_inputCands.resize(16);
00049 }
00050
00051 void L1GctElectronFinalSort::resetPipelines() {
00052 m_outputCands.reset(numOfBx());
00053 }
00054
00055 void L1GctElectronFinalSort::fetchInput() {
00056 if (m_setupOk) {
00057 for (int k=0; k<4; k++) {
00058 if (m_emCandsType) {
00059 setInputEmCand( k , m_thePosEtaLeafCard->getIsoElectronSorterU1()->getOutputCands().at(k));
00060 setInputEmCand( k+4 , m_thePosEtaLeafCard->getIsoElectronSorterU2()->getOutputCands().at(k));
00061 setInputEmCand( k+8 , m_theNegEtaLeafCard->getIsoElectronSorterU1()->getOutputCands().at(k));
00062 setInputEmCand( k+12, m_theNegEtaLeafCard->getIsoElectronSorterU2()->getOutputCands().at(k));
00063 }
00064 else {
00065 setInputEmCand( k , m_thePosEtaLeafCard->getNonIsoElectronSorterU1()->getOutputCands().at(k));
00066 setInputEmCand( k+4 , m_thePosEtaLeafCard->getNonIsoElectronSorterU2()->getOutputCands().at(k));
00067 setInputEmCand( k+8 , m_theNegEtaLeafCard->getNonIsoElectronSorterU1()->getOutputCands().at(k));
00068 setInputEmCand( k+12, m_theNegEtaLeafCard->getNonIsoElectronSorterU2()->getOutputCands().at(k));
00069 }
00070 }
00071 }
00072 }
00073
00074 void L1GctElectronFinalSort::process(){
00075
00076 if (m_setupOk) {
00077 std::vector<prioritisedEmCand> data(m_inputCands.size());
00078
00079
00080 for (unsigned i=0; i<m_inputCands.size(); i++) {
00081 prioritisedEmCand c(m_inputCands.at(i), i);
00082 data.at(i) = c;
00083 }
00084
00085
00086 sort(data.begin(),data.end(),rank_gt());
00087
00088
00089 std::vector<L1GctEmCand> temp(4);
00090 for(int i = 0; i<4; i++){
00091 temp.at(i) = data.at(i).emCand;
00092 }
00093 m_outputCands.store(temp, bxRel());
00094 }
00095 }
00096
00097 void L1GctElectronFinalSort::setInputEmCand(unsigned i, const L1GctEmCand& cand){
00098 if ((i<m_inputCands.size())
00099 && (cand.bx()==bxAbs())) {
00100 m_inputCands.at(i) = cand;
00101 }
00102 }
00103
00104 std::ostream& operator<<(std::ostream& s, const L1GctElectronFinalSort& cand) {
00105 s << "===ElectronFinalSort===" << std::endl;
00106 s << "Card type = " << ( cand.m_emCandsType ? "isolated" : "non-isolated" ) <<std::endl;
00107 s << "Pointers to the Electron Leaf cards are: "<<std::endl;
00108 s << " Pos. eta: " << cand.m_thePosEtaLeafCard;
00109 s << " Neg. eta: " << cand.m_theNegEtaLeafCard;
00110 s << std::endl;
00111 s << "No of Electron Input Candidates " << cand.m_inputCands.size() << std::endl;
00112 s << "No of Electron Output Candidates " << cand.m_outputCands.contents.size() << std::endl;
00113
00114 return s;
00115 }
00116
00117