1 #include "../interface/MicroGMTCancelOutUnit.h" 40 std::vector<std::shared_ptr<GMTInternalMuon>> coll1;
42 std::vector<std::shared_ptr<GMTInternalMuon>> coll2;
45 if (trackFinder ==
bmtf) {
48 for (
int currentWedge = 0; currentWedge < maxWedges; ++currentWedge) {
49 for (
const auto &
mu : wedges.at(currentWedge)) {
53 int neighbourWedge = (currentWedge + 1) % maxWedges;
54 for (
const auto &
mu : wedges.at(neighbourWedge)) {
72 std::vector<std::shared_ptr<GMTInternalMuon>> coll1;
75 std::vector<std::shared_ptr<GMTInternalMuon>> coll2;
78 for (
int currentSector = 0; currentSector < 6; ++currentSector) {
79 for (
const auto &omtfMuon : omtfSectors.at(currentSector)) {
80 coll1.push_back(omtfMuon);
86 for (
int i = 0;
i < 4; ++
i) {
87 int currentWedge = (currentSector * 2 +
i) % 12;
88 for (
const auto &bmtfMuon : bmtfWedges.at(currentWedge)) {
89 coll2.push_back(bmtfMuon);
106 std::vector<std::shared_ptr<GMTInternalMuon>> coll1;
109 std::vector<std::shared_ptr<GMTInternalMuon>> coll2;
112 for (
int curOmtfSector = 0; curOmtfSector < 6; ++curOmtfSector) {
113 for (
const auto &omtfMuon : omtfSectors.at(curOmtfSector)) {
114 coll1.push_back(omtfMuon);
120 for (
int i = 0;
i < 3; ++
i) {
122 int curEmtfSector = ((curOmtfSector + 5) +
i) % 6;
123 for (
const auto &emtfMuon : emtfSectors.at(curEmtfSector)) {
124 coll2.push_back(emtfMuon);
140 if (coll1.empty() || coll2.empty()) {
143 tftype coll1TfType = (*coll1.begin())->trackFinderType();
144 tftype coll2TfType = (*coll2.begin())->trackFinderType();
145 if (coll2TfType !=
tftype::bmtf && coll1TfType % 2 != coll2TfType % 2) {
146 edm::LogError(
"Detector side mismatch") <<
"Overlap-Endcap cancel out between positive and negative detector side attempted. Check eta assignment. OMTF candidate: TF type: " << coll1TfType <<
", hwEta: " << (*coll1.begin())->hwEta() <<
". EMTF candidate: TF type: " << coll2TfType <<
", hwEta: " << (*coll2.begin())->hwEta() <<
". TF type even: pos. side; odd: neg. side." << std::endl;
152 for (
auto mu_w1 = coll1.begin(); mu_w1 != coll1.end(); ++mu_w1) {
153 int etaFine1 = (*mu_w1)->hwHF();
158 for (
auto mu_w2 = coll2.begin(); mu_w2 != coll2.end(); ++mu_w2) {
159 int etaFine2 = (*mu_w2)->hwHF();
165 int etaFine = (
int)(etaFine1 > 0 && etaFine2 > 0);
171 int dPhi = (*mu_w1)->hwGlobalPhi() - (*mu_w2)->hwGlobalPhi();
173 if (dPhi > 338) dPhi -= 576;
175 int dEta =
std::abs((*mu_w1)->hwEta() - (*mu_w2)->hwEta());
179 if (dEta <= dEtaMask && dPhi <= dPhiMask) {
180 int match = matchLUT->
lookup(etaFine, dEta & dEtaMask, dPhi & dPhiMask);
182 if((*mu_w1)->hwQual() > (*mu_w2)->hwQual()) {
183 (*mu_w2)->setHwCancelBit(1);
185 (*mu_w1)->setHwCancelBit(1);
196 if (coll1.empty() || coll2.empty()) {
201 for (
auto mu_w1 = coll1.begin(); mu_w1 != coll1.end(); ++mu_w1) {
202 std::map<int, int> trkAddr_w1 = (*mu_w1)->origin().trackAddress();
203 int wheelNum_w1 = trkAddr_w1[l1t::RegionalMuonCand::bmtfAddress::kWheelNum];
204 int wheelSide_w1 = trkAddr_w1[l1t::RegionalMuonCand::bmtfAddress::kWheelSide];
205 std::vector<int> stations_w1;
206 stations_w1.push_back(trkAddr_w1[l1t::RegionalMuonCand::bmtfAddress::kStat1]);
207 stations_w1.push_back(trkAddr_w1[l1t::RegionalMuonCand::bmtfAddress::kStat2]);
208 stations_w1.push_back(trkAddr_w1[l1t::RegionalMuonCand::bmtfAddress::kStat3]);
209 stations_w1.push_back(trkAddr_w1[l1t::RegionalMuonCand::bmtfAddress::kStat4]);
212 for (
auto mu_w2 = coll2.begin(); mu_w2 != coll2.end(); ++mu_w2) {
213 std::map<int, int> trkAddr_w2 = (*mu_w2)->origin().trackAddress();
214 int wheelNum_w2 = trkAddr_w2[l1t::RegionalMuonCand::bmtfAddress::kWheelNum];
215 int wheelSide_w2 = trkAddr_w2[l1t::RegionalMuonCand::bmtfAddress::kWheelSide];
216 std::vector<int> stations_w2;
217 stations_w2.push_back(trkAddr_w2[l1t::RegionalMuonCand::bmtfAddress::kStat1]);
218 stations_w2.push_back(trkAddr_w2[l1t::RegionalMuonCand::bmtfAddress::kStat2]);
219 stations_w2.push_back(trkAddr_w2[l1t::RegionalMuonCand::bmtfAddress::kStat3]);
220 stations_w2.push_back(trkAddr_w2[l1t::RegionalMuonCand::bmtfAddress::kStat4]);
223 int nMatchedStations = 0;
225 for (
int i = 1;
i < 4; ++
i) {
226 if (wheelSide_w1 == wheelSide_w2) {
227 if (wheelNum_w1 == wheelNum_w2) {
228 if ((stations_w1[
i] == 0x0 && stations_w2[
i] == 0
x2) ||
229 (stations_w1[
i] == 0
x1 && stations_w2[
i] == 0x3) ||
230 (stations_w1[
i] == 0x4 && stations_w2[
i] == 0x0) ||
231 (stations_w1[
i] == 0x5 && stations_w2[
i] == 0
x1) ||
232 (stations_w1[
i] == 0x8 && stations_w2[
i] == 0xA) ||
233 (stations_w1[
i] == 0x9 && stations_w2[
i] == 0xB) ||
234 (stations_w1[
i] == 0xC && stations_w2[
i] == 0x8) ||
235 (stations_w1[
i] == 0xD && stations_w2[
i] == 0x9))
239 }
else if (wheelNum_w1 == wheelNum_w2 - 1) {
240 if ((stations_w1[
i] == 0x0 && stations_w2[
i] == 0xA) ||
241 (stations_w1[
i] == 0
x1 && stations_w2[
i] == 0xB) ||
242 (stations_w1[
i] == 0x4 && stations_w2[
i] == 0x8) ||
243 (stations_w1[
i] == 0x5 && stations_w2[
i] == 0x9))
247 }
else if (wheelNum_w1 == wheelNum_w2 + 1) {
248 if ((stations_w1[
i] == 0x8 && stations_w2[
i] == 0
x2) ||
249 (stations_w1[
i] == 0x9 && stations_w2[
i] == 0x3) ||
250 (stations_w1[
i] == 0xC && stations_w2[
i] == 0x0) ||
251 (stations_w1[
i] == 0xD && stations_w2[
i] == 0
x1))
257 if (wheelNum_w1 == 0 && wheelNum_w2 == 0) {
258 if ((stations_w1[
i] == 0x8 && stations_w2[
i] == 0xA) ||
259 (stations_w1[
i] == 0x9 && stations_w2[
i] == 0xB) ||
260 (stations_w1[
i] == 0xC && stations_w2[
i] == 0x8) ||
261 (stations_w1[
i] == 0xD && stations_w2[
i] == 0x9))
269 if (nMatchedStations > 0) {
270 if ((*mu_w1)->origin().hwQual() >= (*mu_w2)->origin().hwQual()) {
271 (*mu_w2)->setHwCancelBit(1);
273 (*mu_w1)->setHwCancelBit(1);
281 for (
auto mu_s1 = coll1.begin(); mu_s1 != coll1.end(); ++mu_s1) {
282 std::map<int, int> trkAddr_s1 = (*mu_s1)->origin().trackAddress();
283 int me1_ch_s1 = trkAddr_s1[l1t::RegionalMuonCand::emtfAddress::kME1Ch];
284 int me2_ch_s1 = trkAddr_s1[l1t::RegionalMuonCand::emtfAddress::kME2Ch];
285 int me3_ch_s1 = trkAddr_s1[l1t::RegionalMuonCand::emtfAddress::kME3Ch];
286 int me4_ch_s1 = trkAddr_s1[l1t::RegionalMuonCand::emtfAddress::kME4Ch];
287 if (me1_ch_s1 + me2_ch_s1 + me3_ch_s1 + me4_ch_s1 == 0) {
290 int me1_seg_s1 = trkAddr_s1[l1t::RegionalMuonCand::emtfAddress::kME1Seg];
291 int me2_seg_s1 = trkAddr_s1[l1t::RegionalMuonCand::emtfAddress::kME2Seg];
292 int me3_seg_s1 = trkAddr_s1[l1t::RegionalMuonCand::emtfAddress::kME3Seg];
293 int me4_seg_s1 = trkAddr_s1[l1t::RegionalMuonCand::emtfAddress::kME4Seg];
294 for (
auto mu_s2 = coll2.begin(); mu_s2 != coll2.end(); ++mu_s2) {
295 std::map<int, int> trkAddr_s2 = (*mu_s2)->origin().trackAddress();
296 int me1_ch_s2 = trkAddr_s2[l1t::RegionalMuonCand::emtfAddress::kME1Ch];
297 int me2_ch_s2 = trkAddr_s2[l1t::RegionalMuonCand::emtfAddress::kME2Ch];
298 int me3_ch_s2 = trkAddr_s2[l1t::RegionalMuonCand::emtfAddress::kME3Ch];
299 int me4_ch_s2 = trkAddr_s2[l1t::RegionalMuonCand::emtfAddress::kME4Ch];
300 if (me1_ch_s2 + me2_ch_s2 + me3_ch_s2 + me4_ch_s2 == 0) {
303 int me1_seg_s2 = trkAddr_s2[l1t::RegionalMuonCand::emtfAddress::kME1Seg];
304 int me2_seg_s2 = trkAddr_s2[l1t::RegionalMuonCand::emtfAddress::kME2Seg];
305 int me3_seg_s2 = trkAddr_s2[l1t::RegionalMuonCand::emtfAddress::kME3Seg];
306 int me4_seg_s2 = trkAddr_s2[l1t::RegionalMuonCand::emtfAddress::kME4Seg];
308 int nMatchedStations = 0;
309 if (me1_ch_s2 != 0 && me1_ch_s1 == me1_ch_s2+3 && me1_seg_s1 == me1_seg_s2) {
312 if (me2_ch_s2 != 0 && me2_ch_s1 == me2_ch_s2+2 && me2_seg_s1 == me2_seg_s2) {
315 if (me3_ch_s2 != 0 && me3_ch_s1 == me3_ch_s2+2 && me3_seg_s1 == me3_seg_s2) {
318 if (me4_ch_s2 != 0 && me4_ch_s1 == me4_ch_s2+2 && me4_seg_s1 == me4_seg_s2) {
323 if (nMatchedStations > 0) {
324 if ((*mu_s1)->origin().hwQual() >= (*mu_s2)->origin().hwQual()) {
325 (*mu_s2)->setHwCancelBit(1);
327 (*mu_s1)->setHwCancelBit(1);
333 edm::LogError(
"Cancel out not implemented") <<
"Address based cancel out is currently only implemented for the barrel track finder.";
l1t::LUT * bOPosMatchQualLUT()
void setCancelOutBitsOverlapEndcap(GMTInternalWedges &, GMTInternalWedges &, cancelmode)
Cancel-out between overlap and endcap track finders.
l1t::LUT * fOPosMatchQualLUT()
l1t::LUT * ovlNegSingleMatchQualLUT()
void initialise(L1TMuonGlobalParamsHelper *)
Initialisation from ES record.
void setCancelOutBitsOverlapBarrel(GMTInternalWedges &, GMTInternalWedges &, cancelmode)
Cancel-out between overlap and barrel track finders.
void getTrackAddrCancelBits(std::vector< std::shared_ptr< GMTInternalMuon >> &, std::vector< std::shared_ptr< GMTInternalMuon >> &)
Compares all muons from coll1 with all muons from coll2 and sets the cancel-bits based on track addre...
std::shared_ptr< MicroGMTMatchQualLUT > m_ovlNegSingleMatchQualLUT
int getDeltaPhiWidth() const
void getCoordinateCancelBits(std::vector< std::shared_ptr< GMTInternalMuon >> &, std::vector< std::shared_ptr< GMTInternalMuon >> &)
Compares all muons from coll1 with all muons from coll2 and sets the cancel-bits based on eta/phi coo...
std::shared_ptr< MicroGMTMatchQualLUT > m_foPosMatchQualLUT
std::shared_ptr< MicroGMTMatchQualLUT > m_fwdNegSingleMatchQualLUT
l1t::LUT * fONegMatchQualLUT()
l1t::LUT * ovlPosSingleMatchQualLUT()
Abs< T >::type abs(const T &t)
std::shared_ptr< MicroGMTMatchQualLUT > m_fwdPosSingleMatchQualLUT
std::shared_ptr< MicroGMTMatchQualLUT > m_boPosMatchQualLUT
virtual int lookup(int etaFine, int dEta, int dPhi) const =0
void setCancelOutBits(GMTInternalWedges &, tftype, cancelmode)
Cancel out between sectors/wedges in one track finder.
std::shared_ptr< MicroGMTMatchQualLUT > m_boNegMatchQualLUT
int getDeltaEtaWidth() const
l1t::LUT * fwdNegSingleMatchQualLUT()
l1t::LUT * bONegMatchQualLUT()
unsigned fwVersion() const
std::shared_ptr< MicroGMTMatchQualLUT > m_ovlPosSingleMatchQualLUT
std::shared_ptr< MicroGMTMatchQualLUT > m_foNegMatchQualLUT
static ReturnType create(const std::string &filename, const double maxDR, const double fEta, const double fEtaCoarse, const double fPhi, cancel_t cancelType, const int fwVersion)
std::map< int, std::vector< std::shared_ptr< GMTInternalMuon > > > GMTInternalWedges
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
virtual ~MicroGMTCancelOutUnit()
l1t::LUT * fwdPosSingleMatchQualLUT()
std::map< int, std::shared_ptr< MicroGMTMatchQualLUT > > m_lutDict