File indexing completed on 2023-03-17 11:13:28
0001
0002
0003
0004
0005
0006
0007
0008 #include "L1Trigger/RPCTrigger/interface/RPCTBGhostBuster.h"
0009
0010 #include <algorithm>
0011
0012 using namespace std;
0013
0014
0015 L1RpcTBMuonsVec RPCTBGhostBuster::run(L1RpcTBMuonsVec2 &pacMuonsVec2) const {
0016 L1RpcTBMuonsVec2 gbPhiMuonsVec2;
0017 for (unsigned int iTow = 0; iTow < pacMuonsVec2.size(); iTow++) {
0018 gbPhiMuonsVec2.push_back(gBPhi(pacMuonsVec2[iTow]));
0019 }
0020
0021 return gBEta(gbPhiMuonsVec2);
0022 }
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051 L1RpcTBMuonsVec RPCTBGhostBuster::gBPhi(L1RpcTBMuonsVec &pacMuonsVec) const {
0052 if (pacMuonsVec.empty())
0053 return L1RpcTBMuonsVec();
0054
0055 pacMuonsVec.push_back(RPCTBMuon());
0056
0057 for (unsigned int iMu = 0; iMu < RPCConst::m_SEGMENTS_IN_SECTOR_CNT; iMu++) {
0058 if (pacMuonsVec[iMu].getCode() == 0)
0059 ;
0060 else if (pacMuonsVec[iMu].getCode() < pacMuonsVec[iMu + 1].getCode())
0061 pacMuonsVec[iMu].kill();
0062 else if (pacMuonsVec[iMu].getCode() == pacMuonsVec[iMu + 1].getCode()) {
0063 if (pacMuonsVec[iMu].wasKilled())
0064 pacMuonsVec[iMu + 1].kill();
0065 else
0066 pacMuonsVec[iMu].kill();
0067 } else
0068 pacMuonsVec[iMu + 1].kill();
0069 }
0070
0071 pacMuonsVec.pop_back();
0072
0073
0074 if (pacMuonsVec[0].isLive())
0075 pacMuonsVec[0].setGBDataKilledFirst();
0076 else if (pacMuonsVec[0].wasKilled())
0077 for (unsigned int iMu = 0; iMu < RPCConst::m_SEGMENTS_IN_SECTOR_CNT; iMu++) {
0078 if (pacMuonsVec[iMu].isLive()) {
0079 pacMuonsVec[iMu].setGBDataKilledFirst();
0080 break;
0081 }
0082 }
0083
0084 if (pacMuonsVec[RPCConst::m_SEGMENTS_IN_SECTOR_CNT - 1].isLive())
0085 pacMuonsVec[RPCConst::m_SEGMENTS_IN_SECTOR_CNT - 1].setGBDataKilledLast();
0086 else if (pacMuonsVec[RPCConst::m_SEGMENTS_IN_SECTOR_CNT - 1].wasKilled())
0087 for (int iMu = RPCConst::m_SEGMENTS_IN_SECTOR_CNT - 1; iMu >= 0; iMu--) {
0088 if (pacMuonsVec[iMu].isLive()) {
0089 pacMuonsVec[iMu].setGBDataKilledLast();
0090 break;
0091 }
0092 }
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104 L1RpcTBMuonsVec outputMuons;
0105 for (unsigned int iMu = 0; iMu < RPCConst::m_SEGMENTS_IN_SECTOR_CNT; iMu++) {
0106 if (pacMuonsVec[iMu].isLive()) {
0107 pacMuonsVec[iMu].setPhiAddr(iMu);
0108 outputMuons.push_back(pacMuonsVec[iMu]);
0109 }
0110 }
0111 sort(outputMuons.begin(), outputMuons.end(), RPCTBMuon::TMuonMore());
0112
0113
0114 while (outputMuons.size() < RPCConst::m_GBPHI_OUT_MUONS_CNT)
0115 outputMuons.push_back(RPCTBMuon());
0116 while (outputMuons.size() > RPCConst::m_GBPHI_OUT_MUONS_CNT)
0117 outputMuons.pop_back();
0118
0119 return outputMuons;
0120 }
0121
0122
0123
0124 L1RpcTBMuonsVec RPCTBGhostBuster::gBEta(L1RpcTBMuonsVec2 &gbPhiMuonsVec2) const {
0125
0126 for (unsigned int iMuVec = 0; iMuVec < gbPhiMuonsVec2.size() - 1; iMuVec++) {
0127 for (unsigned int iMu = 0; iMu < gbPhiMuonsVec2[iMuVec].size(); iMu++) {
0128 if (gbPhiMuonsVec2[iMuVec][iMu].getCode() == 0)
0129 break;
0130
0131 for (unsigned int iMuNext = 0; iMuNext < gbPhiMuonsVec2[iMuVec + 1].size(); iMuNext++) {
0132 if (abs(gbPhiMuonsVec2[iMuVec][iMu].getPhiAddr() - gbPhiMuonsVec2[iMuVec + 1][iMuNext].getPhiAddr()) <= 1) {
0133
0134 if (gbPhiMuonsVec2[iMuVec][iMu].getCode() < gbPhiMuonsVec2[iMuVec + 1][iMuNext].getCode()) {
0135 gbPhiMuonsVec2[iMuVec][iMu].kill();
0136 } else {
0137 gbPhiMuonsVec2[iMuVec + 1][iMuNext].kill();
0138 }
0139 }
0140 }
0141 }
0142 }
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154 L1RpcTBMuonsVec outputMuons;
0155 for (unsigned int iMuVec = 0; iMuVec < gbPhiMuonsVec2.size(); iMuVec++)
0156 for (unsigned int iMu = 0; iMu < gbPhiMuonsVec2[iMuVec].size(); iMu++)
0157 if (gbPhiMuonsVec2[iMuVec][iMu].isLive()) {
0158 gbPhiMuonsVec2[iMuVec][iMu].setEtaAddr(iMuVec);
0159 outputMuons.push_back(gbPhiMuonsVec2[iMuVec][iMu]);
0160 }
0161 sort(outputMuons.begin(), outputMuons.end(), RPCTBMuon::TMuonMore());
0162
0163
0164 while (outputMuons.size() < RPCConst::m_GBETA_OUT_MUONS_CNT)
0165 outputMuons.push_back(RPCTBMuon());
0166 while (outputMuons.size() > RPCConst::m_GBETA_OUT_MUONS_CNT)
0167 outputMuons.pop_back();
0168
0169 return outputMuons;
0170 }