CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MicroGMTCancelOutUnit.cc
Go to the documentation of this file.
1 #include "../interface/MicroGMTCancelOutUnit.h"
3 
4 namespace l1t {
6  m_boPosMatchQualLUT(iConfig, "BOPos", cancel_t::omtf_bmtf_pos),
7  m_boNegMatchQualLUT(iConfig, "BONeg", cancel_t::omtf_bmtf_neg),
8  m_foPosMatchQualLUT(iConfig, "FOPos", cancel_t::omtf_emtf_pos),
9  m_foNegMatchQualLUT(iConfig, "FONeg", cancel_t::omtf_emtf_neg),
10  m_brlSingleMatchQualLUT(iConfig, "BrlSingle", cancel_t::bmtf_bmtf),
11  m_ovlPosSingleMatchQualLUT(iConfig, "OvlPosSingle", cancel_t::omtf_omtf_pos),
12  m_ovlNegSingleMatchQualLUT(iConfig, "OvlNegSingle", cancel_t::omtf_omtf_neg),
13  m_fwdPosSingleMatchQualLUT(iConfig, "FwdPosSingle", cancel_t::emtf_emtf_pos),
14  m_fwdNegSingleMatchQualLUT(iConfig, "FwdNegSingle", cancel_t::emtf_emtf_neg)
15  {
25 }
26 
28 {
29 
30 }
31 
32 void
34 {
35  std::vector<std::shared_ptr<GMTInternalMuon>> coll1;
36  coll1.reserve(3);
37  std::vector<std::shared_ptr<GMTInternalMuon>> coll2;
38  coll2.reserve(3);
39  int maxWedges = 6;
40  if (trackFinder == bmtf) {
41  maxWedges = 12;
42  }
43  for (int currentWedge = 0; currentWedge < maxWedges; ++currentWedge) {
44  for (auto mu : wedges.at(currentWedge)) {
45  coll1.push_back(mu);
46  }
47  // handle wrap around: max "wedge" has to be compared to first "wedge"
48  int neighbourWedge = (currentWedge + 1) % maxWedges;
49  for (auto mu : wedges.at(neighbourWedge)) {
50  coll2.push_back(mu);
51  }
52  if (mode == cancelmode::coordinate) {
53  getCoordinateCancelBits(coll1, coll2);
54  } else {
55  getTrackAddrCancelBits(coll1, coll2);
56  }
57 
58  coll1.clear();
59  coll2.clear();
60  }
61 }
62 
63 void
65 {
66  // overlap sector collection
67  std::vector<std::shared_ptr<GMTInternalMuon>> coll1;
68  coll1.reserve(3);
69  // barrel wedge collection with 4 wedges
70  std::vector<std::shared_ptr<GMTInternalMuon>> coll2;
71  coll2.reserve(12);
72 
73  for (int currentSector = 0; currentSector < 6; ++currentSector) {
74  for (auto omtfMuon : omtfSectors.at(currentSector)) {
75  coll1.push_back(omtfMuon);
76  }
77  // BMTF | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 0 |
78  // OMTF | 0 | 1 | 2 | 3 | 4 | 5 |
79  // cancel OMTF sector x with corresponding BMTF wedge + the two on either side;
80  // e.g. OMTF 0 with BMTF 0, 1, 2, 3, OMTF 2 with BMTF 4, 5, 6, 7 etc.
81  for (int i = 0; i < 4; ++i) {
82  int currentWedge = (currentSector * 2 + i) % 12;
83  for (auto bmtfMuon : bmtfWedges.at(currentWedge)) {
84  coll2.push_back(bmtfMuon);
85  }
86  }
87  if (mode == cancelmode::coordinate) {
88  getCoordinateCancelBits(coll1, coll2);
89  } else {
90  getTrackAddrCancelBits(coll1, coll2);
91  }
92  coll1.clear();
93  coll2.clear();
94  }
95 }
96 
97 void
99 {
100  // overlap sector collection
101  std::vector<std::shared_ptr<GMTInternalMuon>> coll1;
102  coll1.reserve(3);
103  // endcap sector collection with 3 sectors
104  std::vector<std::shared_ptr<GMTInternalMuon>> coll2;
105  coll2.reserve(9);
106 
107  for (int curOmtfSector = 0; curOmtfSector < 6; ++curOmtfSector) {
108  for (auto omtfMuon : omtfSectors.at(curOmtfSector)) {
109  coll1.push_back(omtfMuon);
110  }
111  // OMTF | 0 | 1 | 2 | 3 | 4 | 5 |
112  // EMTF | 0 | 1 | 2 | 3 | 4 | 5 |
113  // cancel OMTF sector x with corresponding EMTF sector + the ones on either side;
114  // e.g. OMTF 1 with EMTF 0, 1, 2; OMTF 0 with EMTF 5, 0, 1 etc.
115  for (int i = 0; i < 3; ++i) {
116  // handling the wrap around: adding 5 because 0 has to be compared to 5
117  int curEmtfSector = ((curOmtfSector + 5) + i) % 6;
118  for (auto emtfMuon : emtfSectors.at(curEmtfSector)) {
119  coll2.push_back(emtfMuon);
120  }
121  }
122  if (mode == cancelmode::coordinate) {
123  getCoordinateCancelBits(coll1, coll2);
124  } else {
125  getTrackAddrCancelBits(coll1, coll2);
126  }
127  coll1.clear();
128  coll2.clear();
129  }
130 }
131 
132 void
133 MicroGMTCancelOutUnit::getCoordinateCancelBits(std::vector<std::shared_ptr<GMTInternalMuon>>& coll1, std::vector<std::shared_ptr<GMTInternalMuon>>& coll2)
134 {
135  if (coll1.size() == 0 || coll2.size() == 0) {
136  return;
137  }
138  MicroGMTMatchQualLUT* matchLUT = m_lutDict.at((*coll1.begin())->trackFinderType()+(*coll2.begin())->trackFinderType()*10);
139 
140  for (auto mu_w1 = coll1.begin(); mu_w1 != coll1.end(); ++mu_w1) {
141  for (auto mu_w2 = coll2.begin(); mu_w2 != coll2.end(); ++mu_w2) {
142  // The LUT for cancellation takes reduced width phi and eta, we need the LSBs
143  int dPhiMask = (1 << matchLUT->getDeltaPhiWidth()) - 1;
144  int dEtaMask = (1 << matchLUT->getDeltaEtaWidth()) - 1;
145 
146  // temporary fix to take processor offset into account...
147  int dPhi = (*mu_w1)->hwGlobalPhi() - (*mu_w2)->hwGlobalPhi();
148  if (dPhi > 338) dPhi -= 576; // shifts dPhi to [-pi, pi) in integer scale
149  dPhi = std::abs(dPhi);
150  int dEta = std::abs((*mu_w1)->hwEta() - (*mu_w2)->hwEta());
151  // check first if the delta is within the LSBs that the LUT takes, otherwise the distance
152  // is greater than what we want to cancel -> 15(int) is max => 15*0.01 = 0.15 (rad)
153  if (dEta < 15 && dPhi < 15) {
154  int match = matchLUT->lookup(dEta & dEtaMask, dPhi & dPhiMask);
155  if((*mu_w1)->hwPt() < (*mu_w2)->hwPt() && match == 1) {
156  (*mu_w2)->setHwCancelBit(1);
157  } else if (match == 1) {
158  (*mu_w1)->setHwCancelBit(1);
159  }
160  }
161  }
162  }
163 }
164 
165 void
166 MicroGMTCancelOutUnit::getTrackAddrCancelBits(std::vector<std::shared_ptr<GMTInternalMuon>>& coll1, std::vector<std::shared_ptr<GMTInternalMuon>>& coll2)
167 {
168  // not entirely clear how to do.. just a hook for now
169 }
170 
171 } // namespace l1t
int i
Definition: DBlmapReader.cc:9
void setCancelOutBitsOverlapEndcap(GMTInternalWedges &, GMTInternalWedges &, cancelmode)
Cancel-out between overlap and endcap track finders.
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...
MicroGMTCancelOutUnit(const edm::ParameterSet &)
MicroGMTMatchQualLUT m_brlSingleMatchQualLUT
MicroGMTMatchQualLUT m_boPosMatchQualLUT
MicroGMTMatchQualLUT m_foNegMatchQualLUT
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...
MicroGMTMatchQualLUT m_fwdPosSingleMatchQualLUT
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
MicroGMTMatchQualLUT m_ovlPosSingleMatchQualLUT
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const int mu
Definition: Constants.h:22
std::map< int, MicroGMTMatchQualLUT * > m_lutDict
MicroGMTMatchQualLUT m_boNegMatchQualLUT
int lookup(int dEta, int dPhi) const
void setCancelOutBits(GMTInternalWedges &, tftype, cancelmode)
Cancel out between sectors/wedges in one track finder.
MicroGMTMatchQualLUT m_fwdNegSingleMatchQualLUT
MicroGMTMatchQualLUT m_ovlNegSingleMatchQualLUT
MicroGMTMatchQualLUT m_foPosMatchQualLUT
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.
Definition: Utils.h:10