File indexing completed on 2022-02-16 06:15:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #include "L1Trigger/DTTrackFinder/interface/L1MuDTTrackFinder.h"
0020
0021
0022
0023
0024
0025 #include <iostream>
0026
0027
0028
0029
0030
0031 #include <DataFormats/Common/interface/Handle.h>
0032 #include <FWCore/Framework/interface/Event.h>
0033 #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhContainer.h"
0034 #include "DataFormats/L1DTTrackFinder/interface/L1MuDTTrackCand.h"
0035 #include "L1Trigger/DTTrackFinder/interface/L1MuDTTFConfig.h"
0036 #include "L1Trigger/DTTrackFinder/interface/L1MuDTSecProcId.h"
0037 #include "L1Trigger/DTTrackFinder/src/L1MuDTSecProcMap.h"
0038 #include "L1Trigger/DTTrackFinder/src/L1MuDTSectorProcessor.h"
0039 #include "L1Trigger/DTTrackFinder/src/L1MuDTEtaProcessor.h"
0040 #include "L1Trigger/DTTrackFinder/src/L1MuDTWedgeSorter.h"
0041 #include "L1Trigger/DTTrackFinder/src/L1MuDTMuonSorter.h"
0042 #include "L1Trigger/DTTrackFinder/interface/L1MuDTTrack.h"
0043
0044 using namespace std;
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054 L1MuDTTrackFinder::L1MuDTTrackFinder(const edm::ParameterSet& ps, edm::ConsumesCollector&& iC) {
0055
0056 if (not m_config) {
0057 auto temp = std::make_shared<L1MuDTTFConfig>(ps);
0058 std::shared_ptr<L1MuDTTFConfig> empty;
0059 std::atomic_compare_exchange_strong(&m_config, &empty, temp);
0060 }
0061
0062 if (m_config->Debug(1))
0063 cout << endl;
0064 if (m_config->Debug(1))
0065 cout << "**** entering L1MuDTTrackFinder ****" << endl;
0066 if (m_config->Debug(1))
0067 cout << endl;
0068
0069 m_spmap = new L1MuDTSecProcMap();
0070 m_epvec.reserve(12);
0071 m_wsvec.reserve(12);
0072 m_ms = nullptr;
0073
0074 _cache.reserve(4 * 17);
0075 _cache0.reserve(144 * 17);
0076
0077 m_DTDigiToken = iC.consumes<L1MuDTChambPhContainer>(m_config->getDTDigiInputTag());
0078 }
0079
0080
0081
0082
0083
0084 L1MuDTTrackFinder::~L1MuDTTrackFinder() {
0085 delete m_spmap;
0086
0087 vector<L1MuDTEtaProcessor*>::iterator it_ep = m_epvec.begin();
0088 while (it_ep != m_epvec.end()) {
0089 delete (*it_ep);
0090 it_ep++;
0091 }
0092 m_epvec.clear();
0093
0094 vector<L1MuDTWedgeSorter*>::iterator it_ws = m_wsvec.begin();
0095 while (it_ws != m_wsvec.end()) {
0096 delete (*it_ws);
0097 it_ws++;
0098 }
0099 m_wsvec.clear();
0100
0101 delete m_ms;
0102 }
0103
0104
0105
0106
0107
0108
0109
0110
0111 void L1MuDTTrackFinder::setup(edm::ConsumesCollector&& iC) {
0112
0113
0114 if (m_config->Debug(1))
0115 cout << endl;
0116 if (m_config->Debug(1))
0117 cout << "**** L1MuDTTrackFinder building ****" << endl;
0118 if (m_config->Debug(1))
0119 cout << endl;
0120
0121
0122 for (int wh = -3; wh <= 3; wh++) {
0123 if (wh == 0)
0124 continue;
0125 for (int sc = 0; sc < 12; sc++) {
0126 L1MuDTSecProcId tmpspid(wh, sc);
0127 L1MuDTSectorProcessor* sp = new L1MuDTSectorProcessor(*this, tmpspid, std::move(iC));
0128 if (m_config->Debug(2))
0129 cout << "creating " << tmpspid << endl;
0130 m_spmap->insert(tmpspid, sp);
0131 }
0132 }
0133
0134
0135 for (int sc = 0; sc < 12; sc++) {
0136 L1MuDTEtaProcessor* ep = new L1MuDTEtaProcessor(*this, sc, std::move(iC));
0137 if (m_config->Debug(2))
0138 cout << "creating Eta Processor " << sc << endl;
0139 m_epvec.push_back(ep);
0140 L1MuDTWedgeSorter* ws = new L1MuDTWedgeSorter(*this, sc);
0141 if (m_config->Debug(2))
0142 cout << "creating Wedge Sorter " << sc << endl;
0143 m_wsvec.push_back(ws);
0144 }
0145
0146
0147 if (m_config->Debug(2))
0148 cout << "creating DT Muon Sorter " << endl;
0149 m_ms = new L1MuDTMuonSorter(*this);
0150 }
0151
0152
0153
0154
0155 void L1MuDTTrackFinder::run(const edm::Event& e, const edm::EventSetup& c) {
0156
0157
0158 edm::Handle<L1MuDTChambPhContainer> dttrig;
0159 e.getByToken(m_DTDigiToken, dttrig);
0160 if (dttrig->getContainer()->empty())
0161 return;
0162
0163 if (m_config->Debug(2))
0164 cout << endl;
0165 if (m_config->Debug(2))
0166 cout << "**** L1MuDTTrackFinder processing ****" << endl;
0167 if (m_config->Debug(2))
0168 cout << endl;
0169
0170 int bx_min = m_config->getBxMin();
0171 int bx_max = m_config->getBxMax();
0172
0173 for (int bx = bx_min; bx <= bx_max; bx++) {
0174 if (dttrig->bxEmpty(bx))
0175 continue;
0176
0177 if (m_config->Debug(2))
0178 cout << "L1MuDTTrackFinder processing bunch-crossing : " << bx << endl;
0179
0180
0181 reset();
0182
0183
0184 L1MuDTSecProcMap::SPmap_iter it_sp = m_spmap->begin();
0185 while (it_sp != m_spmap->end()) {
0186 if (m_config->Debug(2))
0187 cout << "running " << (*it_sp).second->id() << endl;
0188 if ((*it_sp).second)
0189 (*it_sp).second->run(bx, e, c);
0190 if (m_config->Debug(2) && (*it_sp).second)
0191 (*it_sp).second->print();
0192 it_sp++;
0193 }
0194
0195
0196 vector<L1MuDTEtaProcessor*>::iterator it_ep = m_epvec.begin();
0197 while (it_ep != m_epvec.end()) {
0198 if (m_config->Debug(2))
0199 cout << "running Eta Processor " << (*it_ep)->id() << endl;
0200 if (*it_ep)
0201 (*it_ep)->run(bx, e, c);
0202 if (m_config->Debug(2) && *it_ep)
0203 (*it_ep)->print();
0204 it_ep++;
0205 }
0206
0207
0208 it_sp = m_spmap->begin();
0209 while (it_sp != m_spmap->end()) {
0210 if (m_config->Debug(2))
0211 cout << "reading " << (*it_sp).second->id() << endl;
0212 for (int number = 0; number < 2; number++) {
0213 const L1MuDTTrack* cand = (*it_sp).second->tracK(number);
0214 if (cand && !cand->empty())
0215 _cache0.push_back(L1MuDTTrackCand(cand->getDataWord(),
0216 cand->bx(),
0217 cand->spid().wheel(),
0218 cand->spid().sector(),
0219 number,
0220 cand->address(1),
0221 cand->address(2),
0222 cand->address(3),
0223 cand->address(4),
0224 cand->tc()));
0225 }
0226 it_sp++;
0227 }
0228
0229
0230 vector<L1MuDTWedgeSorter*>::iterator it_ws = m_wsvec.begin();
0231 while (it_ws != m_wsvec.end()) {
0232 if (m_config->Debug(2))
0233 cout << "running Wedge Sorter " << (*it_ws)->id() << endl;
0234 if (*it_ws)
0235 (*it_ws)->run();
0236 if (m_config->Debug(2) && *it_ws)
0237 (*it_ws)->print();
0238 it_ws++;
0239 }
0240
0241
0242 if (m_config->Debug(2))
0243 cout << "running DT Muon Sorter" << endl;
0244 if (m_ms)
0245 m_ms->run();
0246 if (m_config->Debug(2) && m_ms)
0247 m_ms->print();
0248
0249
0250 if (m_ms->numberOfTracks() > 0) {
0251 const vector<const L1MuDTTrack*>& mttf_cont = m_ms->tracks();
0252 vector<const L1MuDTTrack*>::const_iterator iter;
0253 for (iter = mttf_cont.begin(); iter != mttf_cont.end(); iter++) {
0254 if (*iter)
0255 _cache.push_back(L1MuRegionalCand((*iter)->getDataWord(), (*iter)->bx()));
0256 }
0257 }
0258 }
0259 }
0260
0261
0262
0263
0264 void L1MuDTTrackFinder::reset() {
0265 L1MuDTSecProcMap::SPmap_iter it_sp = m_spmap->begin();
0266 while (it_sp != m_spmap->end()) {
0267 if ((*it_sp).second)
0268 (*it_sp).second->reset();
0269 it_sp++;
0270 }
0271
0272 vector<L1MuDTEtaProcessor*>::iterator it_ep = m_epvec.begin();
0273 while (it_ep != m_epvec.end()) {
0274 if (*it_ep)
0275 (*it_ep)->reset();
0276 it_ep++;
0277 }
0278
0279 vector<L1MuDTWedgeSorter*>::iterator it_ws = m_wsvec.begin();
0280 while (it_ws != m_wsvec.end()) {
0281 if (*it_ws)
0282 (*it_ws)->reset();
0283 it_ws++;
0284 }
0285
0286 if (m_ms)
0287 m_ms->reset();
0288 }
0289
0290
0291
0292
0293 const L1MuDTSectorProcessor* L1MuDTTrackFinder::sp(const L1MuDTSecProcId& id) const { return m_spmap->sp(id); }
0294
0295
0296
0297
0298 int L1MuDTTrackFinder::numberOfTracks() { return _cache.size(); }
0299
0300 L1MuDTTrackFinder::TFtracks_const_iter L1MuDTTrackFinder::begin() { return _cache.begin(); }
0301
0302 L1MuDTTrackFinder::TFtracks_const_iter L1MuDTTrackFinder::end() { return _cache.end(); }
0303
0304 void L1MuDTTrackFinder::clear() {
0305 _cache.clear();
0306 _cache0.clear();
0307 }
0308
0309
0310
0311
0312 int L1MuDTTrackFinder::numberOfTracks(int bx) {
0313 int number = 0;
0314 for (TFtracks_const_iter it = _cache.begin(); it != _cache.end(); it++) {
0315 if ((*it).bx() == bx)
0316 number++;
0317 }
0318
0319 return number;
0320 }
0321
0322
0323
0324 std::shared_ptr<L1MuDTTFConfig> L1MuDTTrackFinder::m_config;