File indexing completed on 2024-04-06 12:19:42
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #include "L1Trigger/DTTrackFinder/src/L1MuDTSectorReceiver.h"
0020
0021
0022
0023
0024
0025 #include <iostream>
0026 #include <cmath>
0027
0028
0029
0030
0031
0032 #include "L1Trigger/DTTrackFinder/interface/L1MuDTTFConfig.h"
0033 #include "L1Trigger/DTTrackFinder/src/L1MuDTSectorProcessor.h"
0034 #include "L1Trigger/DTTrackFinder/src/L1MuDTDataBuffer.h"
0035 #include "L1Trigger/DTTrackFinder/interface/L1MuDTTrackSegLoc.h"
0036 #include "L1Trigger/DTTrackFinder/interface/L1MuDTTrackSegPhi.h"
0037 #include "L1Trigger/DTTrackFinder/interface/L1MuDTTrackFinder.h"
0038 #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhDigi.h"
0039 #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhContainer.h"
0040 #include "DataFormats/L1CSCTrackFinder/interface/TrackStub.h"
0041 #include "DataFormats/L1CSCTrackFinder/interface/CSCTriggerContainer.h"
0042 #include "CondFormats/L1TObjects/interface/L1MuDTTFParameters.h"
0043 #include "CondFormats/DataRecord/interface/L1MuDTTFParametersRcd.h"
0044 #include "CondFormats/L1TObjects/interface/L1MuDTTFMasks.h"
0045 #include "CondFormats/DataRecord/interface/L1MuDTTFMasksRcd.h"
0046
0047 using namespace std;
0048
0049
0050
0051
0052
0053
0054
0055
0056 L1MuDTSectorReceiver::L1MuDTSectorReceiver(L1MuDTSectorProcessor& sp, edm::ConsumesCollector iC)
0057 : m_sp(sp),
0058 m_DTDigiToken(iC.consumes<L1MuDTChambPhContainer>(m_sp.tf().config()->getDTDigiInputTag())),
0059 m_CSCTrSToken(iC.mayConsume<CSCTriggerContainer<csctf::TrackStub> >(m_sp.tf().config()->getCSCTrSInputTag())),
0060 m_parsToken(iC.esConsumes()),
0061 m_msksToken(iC.esConsumes()) {}
0062
0063
0064
0065
0066 L1MuDTSectorReceiver::~L1MuDTSectorReceiver() {
0067
0068 }
0069
0070
0071
0072
0073
0074
0075
0076
0077 void L1MuDTSectorReceiver::run(int bx, const edm::Event& e, const edm::EventSetup& c) {
0078 pars = c.getHandle(m_parsToken);
0079 msks = c.getHandle(m_msksToken);
0080
0081
0082 receiveDTBXData(bx, e, c);
0083
0084
0085 if (m_sp.tf().config()->overlap() && m_sp.ovl()) {
0086 receiveCSCData(bx, e, c);
0087 }
0088 }
0089
0090
0091
0092
0093 void L1MuDTSectorReceiver::reset() {}
0094
0095
0096
0097
0098 void L1MuDTSectorReceiver::receiveDTBXData(int bx, const edm::Event& e, const edm::EventSetup& c) {
0099 edm::Handle<L1MuDTChambPhContainer> dttrig;
0100 e.getByToken(m_DTDigiToken, dttrig);
0101
0102 L1MuDTChambPhDigi const* ts = nullptr;
0103
0104
0105 int bx_offset = 0;
0106 bx = bx + bx_offset;
0107
0108
0109 int address = 0;
0110 for (int station = 1; station <= 4; station++) {
0111 int max_address = (station == 1) ? 2 : 12;
0112 for (int reladr = 0; reladr < max_address; reladr++) {
0113 address++;
0114 if (m_sp.ovl() && (reladr / 2) % 2 != 0)
0115 continue;
0116 int wheel = address2wheel(reladr);
0117 int sector = address2sector(reladr);
0118 if (reladr % 2 == 0)
0119 ts = dttrig->chPhiSegm1(wheel, station, sector, bx);
0120 if (reladr % 2 == 1)
0121 ts = dttrig->chPhiSegm2(wheel, station, sector, bx);
0122 if (ts) {
0123 int phi = ts->phi();
0124 int phib = ts->phiB();
0125 int qual = ts->code();
0126 bool tag = (reladr % 2 == 1) ? true : false;
0127
0128 int lwheel = m_sp.id().wheel();
0129 lwheel = abs(lwheel) / lwheel * (abs(wheel) + 1);
0130
0131 if (station == 1) {
0132 if (msks->get_inrec_chdis_st1(lwheel, sector))
0133 continue;
0134 if (qual < pars->get_inrec_qual_st1(lwheel, sector))
0135 continue;
0136 } else if (station == 2) {
0137 if (msks->get_inrec_chdis_st2(lwheel, sector))
0138 continue;
0139 if (qual < pars->get_inrec_qual_st2(lwheel, sector))
0140 continue;
0141 } else if (station == 3) {
0142 if (msks->get_inrec_chdis_st3(lwheel, sector))
0143 continue;
0144 if (qual < pars->get_inrec_qual_st3(lwheel, sector))
0145 continue;
0146 } else if (station == 4) {
0147 if (msks->get_inrec_chdis_st4(lwheel, sector))
0148 continue;
0149 if (qual < pars->get_inrec_qual_st4(lwheel, sector))
0150 continue;
0151 }
0152
0153 if (reladr / 2 == 1 && qual < pars->get_soc_stdis_n(m_sp.id().wheel(), m_sp.id().sector()))
0154 continue;
0155 if (reladr / 2 == 2 && qual < pars->get_soc_stdis_wl(m_sp.id().wheel(), m_sp.id().sector()))
0156 continue;
0157 if (reladr / 2 == 3 && qual < pars->get_soc_stdis_zl(m_sp.id().wheel(), m_sp.id().sector()))
0158 continue;
0159 if (reladr / 2 == 4 && qual < pars->get_soc_stdis_wr(m_sp.id().wheel(), m_sp.id().sector()))
0160 continue;
0161 if (reladr / 2 == 5 && qual < pars->get_soc_stdis_zr(m_sp.id().wheel(), m_sp.id().sector()))
0162 continue;
0163
0164
0165
0166
0167 bool skipTS = false;
0168
0169 bool nbx_del = pars->get_soc_nbx_del(m_sp.id().wheel(), m_sp.id().sector());
0170 if (m_sp.tf().config()->getTSOutOfTimeFilter() || nbx_del) {
0171 int sh_phi = 12 - m_sp.tf().config()->getNbitsExtPhi();
0172 int tolerance = m_sp.tf().config()->getTSOutOfTimeWindow();
0173
0174 L1MuDTChambPhDigi const* tsPreviousBX_1 = dttrig->chPhiSegm1(wheel, station, sector, bx - 1);
0175 if (tsPreviousBX_1) {
0176 int phiBX = tsPreviousBX_1->phi();
0177 int qualBX = tsPreviousBX_1->code();
0178 if (abs((phi >> sh_phi) - (phiBX >> sh_phi)) <= tolerance && qualBX > qual)
0179 skipTS = true;
0180 }
0181
0182 L1MuDTChambPhDigi const* tsPreviousBX_2 = dttrig->chPhiSegm2(wheel, station, sector, bx - 1);
0183 if (tsPreviousBX_2) {
0184 int phiBX = tsPreviousBX_2->phi();
0185 int qualBX = tsPreviousBX_2->code();
0186 if (abs((phi >> sh_phi) - (phiBX >> sh_phi)) <= tolerance && qualBX > qual)
0187 skipTS = true;
0188 }
0189
0190 L1MuDTChambPhDigi const* tsNextBX_1 = dttrig->chPhiSegm1(wheel, station, sector, bx + 1);
0191 if (tsNextBX_1) {
0192 int phiBX = tsNextBX_1->phi();
0193 int qualBX = tsNextBX_1->code();
0194 if (abs((phi >> sh_phi) - (phiBX >> sh_phi)) <= tolerance && qualBX > qual)
0195 skipTS = true;
0196 }
0197
0198 L1MuDTChambPhDigi const* tsNextBX_2 = dttrig->chPhiSegm2(wheel, station, sector, bx + 1);
0199 if (tsNextBX_2) {
0200 int phiBX = tsNextBX_2->phi();
0201 int qualBX = tsNextBX_2->code();
0202 if (abs((phi >> sh_phi) - (phiBX >> sh_phi)) <= tolerance && qualBX > qual)
0203 skipTS = true;
0204 }
0205 }
0206
0207 if (!skipTS) {
0208 L1MuDTTrackSegPhi tmpts(
0209 wheel, sector, station, phi, phib, static_cast<L1MuDTTrackSegPhi::TSQuality>(qual), tag, bx - bx_offset);
0210 m_sp.data()->addTSphi(address - 1, tmpts);
0211 }
0212 }
0213 }
0214 }
0215 }
0216
0217
0218
0219
0220 void L1MuDTSectorReceiver::receiveCSCData(int bx, const edm::Event& e, const edm::EventSetup& c) {
0221 if ((m_sp.tf().config()->getCSCTrSInputTag()).label() == "none")
0222 return;
0223
0224 if (bx < -6 || bx > 6)
0225 return;
0226
0227 edm::Handle<CSCTriggerContainer<csctf::TrackStub> > csctrig;
0228 e.getByToken(m_CSCTrSToken, csctrig);
0229
0230 const int bxCSC = 6;
0231
0232 vector<csctf::TrackStub> csc_list;
0233 vector<csctf::TrackStub>::const_iterator csc_iter;
0234
0235 int station = 1;
0236 int wheel = m_sp.id().wheel();
0237 int side = (wheel == 3) ? 1 : 2;
0238 int sector = m_sp.id().sector();
0239 int csc_sector = (sector == 0) ? 6 : (sector + 1) / 2;
0240 int subsector = (sector % 2 == 0) ? 2 : 1;
0241
0242 csc_list = csctrig->get(side, station, csc_sector, subsector, bxCSC + bx);
0243 int ncsc = 0;
0244 for (csc_iter = csc_list.begin(); csc_iter != csc_list.end(); csc_iter++) {
0245 bool etaFlag = (csc_iter->etaPacked() > 17);
0246 int qualCSC = csc_iter->getQuality();
0247
0248
0249 unsigned int qual = 7;
0250 if (qualCSC == 2)
0251 qual = 0;
0252 if (qualCSC == 6)
0253 qual = 1;
0254 if (qualCSC == 7)
0255 qual = 2;
0256 if (qualCSC == 8)
0257 qual = 2;
0258 if (qualCSC == 9)
0259 qual = 3;
0260 if (qualCSC == 10)
0261 qual = 3;
0262 if (qualCSC == 11)
0263 qual = 4;
0264 if (qualCSC == 12)
0265 qual = 5;
0266 if (qualCSC == 13)
0267 qual = 5;
0268 if (qualCSC == 14)
0269 qual = 6;
0270 if (qualCSC == 15)
0271 qual = 6;
0272 if (qual == 7)
0273 continue;
0274
0275
0276 int phi = csc_iter->phiPacked();
0277 if (phi > 2047)
0278 phi -= 4096;
0279 if (phi < -2048 || phi > 2047)
0280 continue;
0281
0282 if (msks->get_inrec_chdis_csc(m_sp.id().wheel(), m_sp.id().sector()))
0283 continue;
0284 if (qual < pars->get_soc_qual_csc(m_sp.id().wheel(), m_sp.id().sector()))
0285 continue;
0286 if (pars->get_soc_csc_etacanc(m_sp.id().wheel(), m_sp.id().sector()) && etaFlag)
0287 continue;
0288 if (m_sp.tf().config()->getEtaCanc() && etaFlag)
0289 continue;
0290
0291 if (ncsc < 2) {
0292 int address = 16 + ncsc;
0293 bool tag = (ncsc == 1) ? true : false;
0294 L1MuDTTrackSegPhi tmpts(
0295 wheel, sector, station + 2, phi, 0, static_cast<L1MuDTTrackSegPhi::TSQuality>(qual), tag, bx, etaFlag);
0296 m_sp.data()->addTSphi(address, tmpts);
0297 ncsc++;
0298 }
0299
0300 }
0301 }
0302
0303
0304
0305
0306 int L1MuDTSectorReceiver::address2sector(int adr) const {
0307 int sector = m_sp.id().sector();
0308
0309 if (adr >= 4 && adr <= 7)
0310 sector = (sector + 13) % 12;
0311 if (adr >= 8 && adr <= 11)
0312 sector = (sector + 11) % 12;
0313
0314 return sector;
0315 }
0316
0317
0318
0319
0320 int L1MuDTSectorReceiver::address2wheel(int adr) const {
0321 int wheel = m_sp.id().locwheel();
0322
0323
0324 if ((adr / 2) % 2 == 1)
0325 wheel = m_sp.id().wheel();
0326
0327 return wheel;
0328 }