1 #include "../interface/MicroGMTCancelOutUnit.h"
42 std::vector<std::shared_ptr<GMTInternalMuon>> coll1;
44 std::vector<std::shared_ptr<GMTInternalMuon>> coll2;
47 if (trackFinder ==
bmtf) {
50 for (
int currentWedge = 0; currentWedge < maxWedges; ++currentWedge) {
51 for (
auto mu : wedges.at(currentWedge)) {
55 int neighbourWedge = (currentWedge + 1) % maxWedges;
56 for (
auto mu : wedges.at(neighbourWedge)) {
74 std::vector<std::shared_ptr<GMTInternalMuon>> coll1;
77 std::vector<std::shared_ptr<GMTInternalMuon>> coll2;
80 for (
int currentSector = 0; currentSector < 6; ++currentSector) {
81 for (
auto omtfMuon : omtfSectors.at(currentSector)) {
82 coll1.push_back(omtfMuon);
88 for (
int i = 0;
i < 4; ++
i) {
89 int currentWedge = (currentSector * 2 +
i) % 12;
90 for (
auto bmtfMuon : bmtfWedges.at(currentWedge)) {
91 coll2.push_back(bmtfMuon);
108 std::vector<std::shared_ptr<GMTInternalMuon>> coll1;
111 std::vector<std::shared_ptr<GMTInternalMuon>> coll2;
114 for (
int curOmtfSector = 0; curOmtfSector < 6; ++curOmtfSector) {
115 for (
auto omtfMuon : omtfSectors.at(curOmtfSector)) {
116 coll1.push_back(omtfMuon);
122 for (
int i = 0;
i < 3; ++
i) {
124 int curEmtfSector = ((curOmtfSector + 5) +
i) % 6;
125 for (
auto emtfMuon : emtfSectors.at(curEmtfSector)) {
126 coll2.push_back(emtfMuon);
142 if (coll1.size() == 0 || coll2.size() == 0) {
145 tftype coll2TfType = (*coll2.begin())->trackFinderType();
146 if (coll2TfType !=
tftype::bmtf && (*coll1.begin())->trackFinderType() % 2 != coll2TfType % 2) {
147 edm::LogError(
"Detector side mismatch") <<
"Overlap-Endcap cancel out between positive and negative detector side attempted. Check eta assignment. OMTF candidate: TF type: " << (*coll1.begin())->trackFinderType() <<
", hwEta: " << (*coll1.begin())->hwEta() <<
". EMTF candidate: TF type: " << coll2TfType <<
", hwEta: " << (*coll2.begin())->hwEta() <<
". TF type even: pos. side; odd: neg. side." << std::endl;
153 for (
auto mu_w1 = coll1.begin(); mu_w1 != coll1.end(); ++mu_w1) {
154 for (
auto mu_w2 = coll2.begin(); mu_w2 != coll2.end(); ++mu_w2) {
160 int dPhi = (*mu_w1)->hwGlobalPhi() - (*mu_w2)->hwGlobalPhi();
161 if (dPhi > 338) dPhi -= 576;
163 int dEta =
std::abs((*mu_w1)->hwEta() - (*mu_w2)->hwEta());
167 if (dEta < 16 && dPhi < 8) {
168 int match = matchLUT->
lookup(dEta & dEtaMask, dPhi & dPhiMask);
169 if((*mu_w1)->hwPt() < (*mu_w2)->hwPt() && match == 1) {
170 (*mu_w2)->setHwCancelBit(1);
171 }
else if (match == 1) {
172 (*mu_w1)->setHwCancelBit(1);
182 if (coll1.size() == 0 || coll2.size() == 0) {
187 for (
auto mu_w1 = coll1.begin(); mu_w1 != coll1.end(); ++mu_w1) {
188 std::map<int, int> trkAddr_w1 = (*mu_w1)->origin().trackAddress();
189 int wheelNum_w1 = trkAddr_w1[l1t::RegionalMuonCand::bmtfAddress::kWheelNum];
190 int wheelSide_w1 = trkAddr_w1[l1t::RegionalMuonCand::bmtfAddress::kWheelSide];
191 std::vector<int> stations_w1;
192 stations_w1.push_back(trkAddr_w1[l1t::RegionalMuonCand::bmtfAddress::kStat1]);
193 stations_w1.push_back(trkAddr_w1[l1t::RegionalMuonCand::bmtfAddress::kStat2]);
194 stations_w1.push_back(trkAddr_w1[l1t::RegionalMuonCand::bmtfAddress::kStat3]);
195 stations_w1.push_back(trkAddr_w1[l1t::RegionalMuonCand::bmtfAddress::kStat4]);
198 for (
auto mu_w2 = coll2.begin(); mu_w2 != coll2.end(); ++mu_w2) {
199 std::map<int, int> trkAddr_w2 = (*mu_w2)->origin().trackAddress();
200 int wheelNum_w2 = trkAddr_w2[l1t::RegionalMuonCand::bmtfAddress::kWheelNum];
201 int wheelSide_w2 = trkAddr_w2[l1t::RegionalMuonCand::bmtfAddress::kWheelSide];
202 std::vector<int> stations_w2;
203 stations_w2.push_back(trkAddr_w2[l1t::RegionalMuonCand::bmtfAddress::kStat1]);
204 stations_w2.push_back(trkAddr_w2[l1t::RegionalMuonCand::bmtfAddress::kStat2]);
205 stations_w2.push_back(trkAddr_w2[l1t::RegionalMuonCand::bmtfAddress::kStat3]);
206 stations_w2.push_back(trkAddr_w2[l1t::RegionalMuonCand::bmtfAddress::kStat4]);
209 int nMatchedStations = 0;
211 for (
int i = 1;
i < 4; ++
i) {
212 if (wheelSide_w1 == wheelSide_w2) {
213 if (wheelNum_w1 == wheelNum_w2) {
214 if ((stations_w1[
i] == 0x0 && stations_w2[
i] == 0x2) ||
215 (stations_w1[
i] == 0x1 && stations_w2[
i] == 0x3) ||
216 (stations_w1[
i] == 0x4 && stations_w2[
i] == 0x0) ||
217 (stations_w1[
i] == 0x5 && stations_w2[
i] == 0x1) ||
218 (stations_w1[
i] == 0x8 && stations_w2[
i] == 0xA) ||
219 (stations_w1[
i] == 0x9 && stations_w2[
i] == 0xB) ||
220 (stations_w1[
i] == 0xC && stations_w2[
i] == 0x8) ||
221 (stations_w1[
i] == 0xD && stations_w2[
i] == 0x9))
225 }
else if (wheelNum_w1 == wheelNum_w2 - 1) {
226 if ((stations_w1[
i] == 0x0 && stations_w2[
i] == 0xA) ||
227 (stations_w1[
i] == 0x1 && stations_w2[
i] == 0xB) ||
228 (stations_w1[
i] == 0x4 && stations_w2[
i] == 0x8) ||
229 (stations_w1[
i] == 0x5 && stations_w2[
i] == 0x9))
233 }
else if (wheelNum_w1 == wheelNum_w2 + 1) {
234 if ((stations_w1[
i] == 0x8 && stations_w2[
i] == 0x2) ||
235 (stations_w1[
i] == 0x9 && stations_w2[
i] == 0x3) ||
236 (stations_w1[
i] == 0xC && stations_w2[
i] == 0x0) ||
237 (stations_w1[
i] == 0xD && stations_w2[
i] == 0x1))
243 if (wheelNum_w1 == 0 && wheelNum_w2 == 0) {
244 if ((stations_w1[
i] == 0x8 && stations_w2[
i] == 0xA) ||
245 (stations_w1[
i] == 0x9 && stations_w2[
i] == 0xB) ||
246 (stations_w1[
i] == 0xC && stations_w2[
i] == 0x8) ||
247 (stations_w1[
i] == 0xD && stations_w2[
i] == 0x9))
255 if (nMatchedStations > 0) {
256 if ((*mu_w1)->origin().hwQual() > (*mu_w2)->origin().hwQual()) {
257 (*mu_w2)->setHwCancelBit(1);
259 (*mu_w1)->setHwCancelBit(1);
265 edm::LogError(
"Cancel out not implemented") <<
"Address based cancel out is currently only implemented for the barrel track finder.";
std::string fOPosMatchQualLUTPath() const
double fOPosMatchQualLUTMaxDR() const
void setCancelOutBitsOverlapEndcap(GMTInternalWedges &, GMTInternalWedges &, cancelmode)
Cancel-out between overlap and endcap track finders.
std::string fwdPosSingleMatchQualLUTPath() const
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
double ovlPosSingleMatchQualLUTMaxDR() const
void initialise(L1TMuonGlobalParams *)
Initialisation from ES record.
int getDeltaPhiWidth() const
std::string fONegMatchQualLUTPath() const
std::string ovlPosSingleMatchQualLUTPath() const
double bOPosMatchQualLUTMaxDR() const
double ovlNegSingleMatchQualLUTMaxDR() 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...
static ReturnType create(const std::string &filename, const double maxDR, cancel_t cancelType, const int fwVersion)
std::shared_ptr< MicroGMTMatchQualLUT > m_foPosMatchQualLUT
unsigned fwVersion() const
double dPhi(double phi1, double phi2)
std::shared_ptr< MicroGMTMatchQualLUT > m_fwdNegSingleMatchQualLUT
Abs< T >::type abs(const T &t)
double fwdPosSingleMatchQualLUTMaxDR() const
std::shared_ptr< MicroGMTMatchQualLUT > m_fwdPosSingleMatchQualLUT
std::shared_ptr< MicroGMTMatchQualLUT > m_boPosMatchQualLUT
std::string fwdNegSingleMatchQualLUTPath() const
int lookup(int dEta, int dPhi) const
void setCancelOutBits(GMTInternalWedges &, tftype, cancelmode)
Cancel out between sectors/wedges in one track finder.
std::string ovlNegSingleMatchQualLUTPath() const
std::shared_ptr< MicroGMTMatchQualLUT > m_boNegMatchQualLUT
int getDeltaEtaWidth() const
std::string bONegMatchQualLUTPath() const
std::shared_ptr< MicroGMTMatchQualLUT > m_ovlPosSingleMatchQualLUT
double fwdNegSingleMatchQualLUTMaxDR() const
std::shared_ptr< MicroGMTMatchQualLUT > m_foNegMatchQualLUT
double bONegMatchQualLUTMaxDR() const
double fONegMatchQualLUTMaxDR() const
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()
std::string bOPosMatchQualLUTPath() const
std::map< int, std::shared_ptr< MicroGMTMatchQualLUT > > m_lutDict