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 (
auto mu : wedges.at(currentWedge)) {
53 int neighbourWedge = (currentWedge + 1) % maxWedges;
54 for (
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 (
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 (
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 (
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 (
auto emtfMuon : emtfSectors.at(curEmtfSector)) {
124 coll2.push_back(emtfMuon);
140 if (coll1.size() == 0 || coll2.size() == 0) {
143 tftype coll2TfType = (*coll2.begin())->trackFinderType();
144 if (coll2TfType !=
tftype::bmtf && (*coll1.begin())->trackFinderType() % 2 != coll2TfType % 2) {
145 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;
151 for (
auto mu_w1 = coll1.begin(); mu_w1 != coll1.end(); ++mu_w1) {
152 for (
auto mu_w2 = coll2.begin(); mu_w2 != coll2.end(); ++mu_w2) {
157 int dPhi = (*mu_w1)->hwGlobalPhi() - (*mu_w2)->hwGlobalPhi();
159 if (dPhi > 338) dPhi -= 576;
161 int dEta =
std::abs((*mu_w1)->hwEta() - (*mu_w2)->hwEta());
165 if (dEta < 16 && dPhi < 8) {
166 int match = matchLUT->
lookup(dEta & dEtaMask, dPhi & dPhiMask);
168 if((*mu_w1)->hwQual() > (*mu_w2)->hwQual()) {
169 (*mu_w2)->setHwCancelBit(1);
171 (*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.";
void setCancelOutBitsOverlapEndcap(GMTInternalWedges &, GMTInternalWedges &, cancelmode)
Cancel-out between overlap and endcap track finders.
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...
double fOPosMatchQualLUTMaxDR() const
double fwdPosSingleMatchQualLUTMaxDR() const
std::string fONegMatchQualLUTPath() const
std::shared_ptr< MicroGMTMatchQualLUT > m_ovlNegSingleMatchQualLUT
double fwdNegSingleMatchQualLUTMaxDR() const
std::string fwdPosSingleMatchQualLUTPath() const
double ovlPosSingleMatchQualLUTMaxDR() const
int getDeltaPhiWidth() const
double fONegMatchQualLUTMaxDR() const
std::string ovlPosSingleMatchQualLUTPath() 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
double bOPosMatchQualLUTMaxDR() const
double dPhi(double phi1, double phi2)
std::shared_ptr< MicroGMTMatchQualLUT > m_fwdNegSingleMatchQualLUT
std::string bONegMatchQualLUTPath() const
std::string fOPosMatchQualLUTPath() const
Abs< T >::type abs(const T &t)
std::shared_ptr< MicroGMTMatchQualLUT > m_fwdPosSingleMatchQualLUT
std::shared_ptr< MicroGMTMatchQualLUT > m_boPosMatchQualLUT
double ovlNegSingleMatchQualLUTMaxDR() const
int lookup(int dEta, int dPhi) const
void setCancelOutBits(GMTInternalWedges &, tftype, cancelmode)
Cancel out between sectors/wedges in one track finder.
std::shared_ptr< MicroGMTMatchQualLUT > m_boNegMatchQualLUT
int getDeltaEtaWidth() const
double bONegMatchQualLUTMaxDR() const
unsigned fwVersion() const
std::shared_ptr< MicroGMTMatchQualLUT > m_ovlPosSingleMatchQualLUT
std::shared_ptr< MicroGMTMatchQualLUT > m_foNegMatchQualLUT
std::string bOPosMatchQualLUTPath() 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 fwdNegSingleMatchQualLUTPath() const
std::string ovlNegSingleMatchQualLUTPath() const
std::map< int, std::shared_ptr< MicroGMTMatchQualLUT > > m_lutDict