Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:21:41

0001 #include "L1Trigger/RPCTrigger/interface/RPCTCGhostBusterSorter.h"
0002 //#include <set>
0003 #include <algorithm>
0004 
0005 using namespace std;
0006 
0007 //---------------------------------------------------------------------------
0008 RPCTCGhostBusterSorter::RPCTCGhostBusterSorter(RPCTriggerConfiguration* triggerConfig) {
0009   m_TriggerConfig = triggerConfig;
0010 }
0011 //---------------------------------------------------------------------------
0012 L1RpcTBMuonsVec RPCTCGhostBusterSorter::run(L1RpcTBMuonsVec2& tbMuonsVec2) {
0013   for (unsigned int iTB = 0; iTB < tbMuonsVec2.size() - 1; iTB++) {
0014     for (unsigned int iMu = 0; iMu < tbMuonsVec2[iTB].size(); iMu++) {
0015       if (tbMuonsVec2[iTB][iMu].getPtCode() == 0)
0016         break;  //becouse muons are sorted
0017 
0018       //muon from this TB is on positive edge of TB (last m_tower of this tb):
0019       if (tbMuonsVec2[iTB][iMu].getEtaAddr() == (m_TriggerConfig->getTowsCntOnTB(iTB) - 1)) {
0020         for (unsigned int iMuN = 0; iMuN < tbMuonsVec2[iTB + 1].size(); iMuN++) {
0021           if (tbMuonsVec2[iTB + 1][iMuN].getPtCode() == 0)
0022             break;  //becouse muons are sorted
0023 
0024           //muon from next TB is on negative edge (first m_tower of this TB):
0025           if (tbMuonsVec2[iTB + 1][iMuN].getEtaAddr() == 0) {
0026             if (abs(tbMuonsVec2[iTB][iMu].getPhiAddr() - tbMuonsVec2[iTB + 1][iMuN].getPhiAddr()) <= 1) {
0027               if (tbMuonsVec2[iTB][iMu].getCode() < tbMuonsVec2[iTB + 1][iMuN].getCode()) {
0028                 tbMuonsVec2[iTB][iMu].kill();
0029               } else {
0030                 tbMuonsVec2[iTB + 1][iMuN].kill();
0031               }
0032             }
0033           }
0034         }
0035       }
0036     }
0037   }
0038 
0039   //---------sorting-----------------------------------------
0040   /*  multiset<RPCTBMuon, RPCTBMuon::TMuonMore> liveMuonsSet;
0041   for(unsigned int iTB = 0; iTB < tbMuonsVec2.size(); iTB++)
0042   for(unsigned int iMu = 0; iMu < tbMuonsVec2[iTB].size(); iMu++)
0043       if(tbMuonsVec2[iTB][iMu].isLive()) {
0044 
0045         int etaAddr = tbMuonsVec2[iTB][iMu].getEtaAddr() | (iTB<<2); //m_tower number natural
0046         etaAddr = m_TriggerConfig->towAddr2TowNum(etaAddr); //m_tower number: -16 : 16
0047         etaAddr = etaAddr + 16;                     // m_tower number continous 0 : 32
0048         tbMuonsVec2[iTB][iMu].setEtaAddr(etaAddr);
0049 
0050         liveMuonsSet.insert(tbMuonsVec2[iTB][iMu]);
0051       }
0052   L1RpcTBMuonsVec outputMuons(liveMuonsSet.begin(), liveMuonsSet.end()); */
0053 
0054   L1RpcTBMuonsVec outputMuons;
0055   for (unsigned int iTB = 0; iTB < tbMuonsVec2.size(); iTB++)
0056     for (unsigned int iMu = 0; iMu < tbMuonsVec2[iTB].size(); iMu++)
0057       if (tbMuonsVec2[iTB][iMu].isLive()) {
0058         int etaAddr = tbMuonsVec2[iTB][iMu].getEtaAddr() | (iTB << 2);  //m_tower number natural <0...35>
0059         etaAddr = m_TriggerConfig->towAddr2TowNum(etaAddr);             //m_tower number: -16 : 16
0060         //etaAddr = etaAddr + 16;                     // m_tower number continous 0 : 32
0061         etaAddr = m_TriggerConfig->towNum2TowNum2Comp(etaAddr);  // 10 oct 2006 - moved from FS
0062         tbMuonsVec2[iTB][iMu].setEtaAddr(etaAddr);
0063 
0064         outputMuons.push_back(tbMuonsVec2[iTB][iMu]);
0065       }
0066 
0067   sort(outputMuons.begin(), outputMuons.end(), RPCTBMuon::TMuonMore());
0068 
0069   //-------setting size to m_GBETA_OUT_MUONS_CNT----------------
0070   while (outputMuons.size() < RPCConst::m_TCGB_OUT_MUONS_CNT)
0071     outputMuons.push_back(RPCTBMuon());
0072   while (outputMuons.size() > RPCConst::m_TCGB_OUT_MUONS_CNT)
0073     outputMuons.pop_back();
0074 
0075   return outputMuons;
0076 }