Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-01-04 23:37:37

0001 //-------------------------------------------------
0002 //
0003 //   Class: L1MuDTTrackFinder
0004 //
0005 //   Description: L1 barrel Muon Trigger Track Finder
0006 //
0007 //
0008 //
0009 //   Author :
0010 //   N. Neumeister            CERN EP
0011 //   J. Troconiz              UAM Madrid
0012 //
0013 //--------------------------------------------------
0014 
0015 //-----------------------
0016 // This Class's Header --
0017 //-----------------------
0018 
0019 #include "L1Trigger/DTTrackFinder/interface/L1MuDTTrackFinder.h"
0020 
0021 //---------------
0022 // C++ Headers --
0023 //---------------
0024 
0025 #include <iostream>
0026 
0027 //-------------------------------
0028 // Collaborating Class Headers --
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 //       class L1MuDTTrackFinder
0048 //---------------------------------
0049 
0050 //----------------
0051 // Constructors --
0052 //----------------
0053 
0054 L1MuDTTrackFinder::L1MuDTTrackFinder(const edm::ParameterSet& ps, edm::ConsumesCollector&& iC) {
0055   // set configuration parameters
0056   m_config = std::make_unique<L1MuDTTFConfig>(ps);
0057 
0058   if (m_config->Debug(1))
0059     cout << endl;
0060   if (m_config->Debug(1))
0061     cout << "**** entering L1MuDTTrackFinder ****" << endl;
0062   if (m_config->Debug(1))
0063     cout << endl;
0064 
0065   m_spmap = std::make_unique<L1MuDTSecProcMap>();
0066   m_epvec.reserve(12);
0067   m_wsvec.reserve(12);
0068 
0069   _cache.reserve(4 * 17);
0070   _cache0.reserve(144 * 17);
0071 
0072   m_DTDigiToken = iC.consumes<L1MuDTChambPhContainer>(m_config->getDTDigiInputTag());
0073 }
0074 
0075 //--------------
0076 // Destructor --
0077 //--------------
0078 
0079 L1MuDTTrackFinder::~L1MuDTTrackFinder() = default;
0080 
0081 //--------------
0082 // Operations --
0083 //--------------
0084 
0085 //
0086 // setup MTTF configuration
0087 //
0088 void L1MuDTTrackFinder::setup(edm::ConsumesCollector&& iC) {
0089   // build the barrel Muon Trigger Track Finder
0090 
0091   if (m_config->Debug(1))
0092     cout << endl;
0093   if (m_config->Debug(1))
0094     cout << "**** L1MuDTTrackFinder building ****" << endl;
0095   if (m_config->Debug(1))
0096     cout << endl;
0097 
0098   // create new sector processors
0099   for (int wh = -3; wh <= 3; wh++) {
0100     if (wh == 0)
0101       continue;
0102     for (int sc = 0; sc < 12; sc++) {
0103       L1MuDTSecProcId tmpspid(wh, sc);
0104       auto sp = std::make_unique<L1MuDTSectorProcessor>(*this, tmpspid, iC);
0105       if (m_config->Debug(2))
0106         cout << "creating " << tmpspid << endl;
0107       m_spmap->insert(tmpspid, std::move(sp));
0108     }
0109   }
0110 
0111   // create new eta processors and wedge sorters
0112   for (int sc = 0; sc < 12; sc++) {
0113     auto ep = std::make_unique<L1MuDTEtaProcessor>(*this, sc, iC);
0114     if (m_config->Debug(2))
0115       cout << "creating Eta Processor " << sc << endl;
0116     m_epvec.push_back(std::move(ep));
0117     auto ws = std::make_unique<L1MuDTWedgeSorter>(*this, sc);
0118     if (m_config->Debug(2))
0119       cout << "creating Wedge Sorter " << sc << endl;
0120     m_wsvec.push_back(std::move(ws));
0121   }
0122 
0123   // create new muon sorter
0124   if (m_config->Debug(2))
0125     cout << "creating DT Muon Sorter " << endl;
0126   m_ms = std::make_unique<L1MuDTMuonSorter>(*this);
0127 }
0128 
0129 //
0130 // run MTTF
0131 //
0132 void L1MuDTTrackFinder::run(const edm::Event& e, const edm::EventSetup& c) {
0133   // run the barrel Muon Trigger Track Finder
0134 
0135   edm::Handle<L1MuDTChambPhContainer> dttrig;
0136   e.getByToken(m_DTDigiToken, dttrig);
0137   if (dttrig->getContainer()->empty())
0138     return;
0139 
0140   if (m_config->Debug(2))
0141     cout << endl;
0142   if (m_config->Debug(2))
0143     cout << "**** L1MuDTTrackFinder processing ****" << endl;
0144   if (m_config->Debug(2))
0145     cout << endl;
0146 
0147   int bx_min = m_config->getBxMin();
0148   int bx_max = m_config->getBxMax();
0149 
0150   for (int bx = bx_min; bx <= bx_max; bx++) {
0151     if (dttrig->bxEmpty(bx))
0152       continue;
0153 
0154     if (m_config->Debug(2))
0155       cout << "L1MuDTTrackFinder processing bunch-crossing : " << bx << endl;
0156 
0157     // reset MTTF
0158     reset();
0159 
0160     // run sector processors
0161     for (auto& sp : *m_spmap) {
0162       if (m_config->Debug(2))
0163         cout << "running " << sp.second->id() << endl;
0164       if (sp.second)
0165         sp.second->run(bx, e, c);
0166       if (m_config->Debug(2) && sp.second)
0167         sp.second->print();
0168     }
0169 
0170     // run eta processors
0171     for (auto& ep : m_epvec) {
0172       if (m_config->Debug(2))
0173         cout << "running Eta Processor " << ep->id() << endl;
0174       if (ep)
0175         ep->run(bx, e, c);
0176       if (m_config->Debug(2) && ep)
0177         ep->print();
0178     }
0179 
0180     // read sector processors
0181     for (auto& sp : *m_spmap) {
0182       if (m_config->Debug(2))
0183         cout << "reading " << sp.second->id() << endl;
0184       for (int number = 0; number < 2; number++) {
0185         const L1MuDTTrack* cand = sp.second->tracK(number);
0186         if (cand && !cand->empty())
0187           _cache0.push_back(L1MuDTTrackCand(cand->getDataWord(),
0188                                             cand->bx(),
0189                                             cand->spid().wheel(),
0190                                             cand->spid().sector(),
0191                                             number,
0192                                             cand->address(1),
0193                                             cand->address(2),
0194                                             cand->address(3),
0195                                             cand->address(4),
0196                                             cand->tc()));
0197       }
0198     }
0199 
0200     // run wedge sorters
0201     for (auto& ws : m_wsvec) {
0202       if (m_config->Debug(2))
0203         cout << "running Wedge Sorter " << ws->id() << endl;
0204       if (ws)
0205         ws->run();
0206       if (m_config->Debug(2) && ws)
0207         ws->print();
0208     }
0209 
0210     // run muon sorter
0211     if (m_config->Debug(2))
0212       cout << "running DT Muon Sorter" << endl;
0213     if (m_ms)
0214       m_ms->run();
0215     if (m_config->Debug(2) && m_ms)
0216       m_ms->print();
0217 
0218     // store found track candidates in container (cache)
0219     if (m_ms->numberOfTracks() > 0) {
0220       for (auto const& mttf : m_ms->tracks()) {
0221         if (mttf)
0222           _cache.push_back(L1MuRegionalCand(mttf->getDataWord(), mttf->bx()));
0223       }
0224     }
0225   }
0226 }
0227 
0228 //
0229 // reset MTTF
0230 //
0231 void L1MuDTTrackFinder::reset() {
0232   for (auto& sp : *m_spmap) {
0233     if (sp.second)
0234       sp.second->reset();
0235   }
0236 
0237   for (auto& ep : m_epvec) {
0238     if (ep)
0239       ep->reset();
0240   }
0241 
0242   for (auto& ws : m_wsvec) {
0243     if (ws)
0244       ws->reset();
0245   }
0246 
0247   if (m_ms)
0248     m_ms->reset();
0249 }
0250 
0251 //
0252 // return Sector Processor container
0253 //
0254 const L1MuDTSectorProcessor* L1MuDTTrackFinder::sp(const L1MuDTSecProcId& id) const { return m_spmap->sp(id); }
0255 
0256 //
0257 // return number of muon candidates found by the barrel MTTF
0258 //
0259 int L1MuDTTrackFinder::numberOfTracks() { return _cache.size(); }
0260 
0261 L1MuDTTrackFinder::TFtracks_const_iter L1MuDTTrackFinder::begin() { return _cache.begin(); }
0262 
0263 L1MuDTTrackFinder::TFtracks_const_iter L1MuDTTrackFinder::end() { return _cache.end(); }
0264 
0265 void L1MuDTTrackFinder::clear() {
0266   _cache.clear();
0267   _cache0.clear();
0268 }
0269 
0270 //
0271 // return number of muon candidates found by the barrel MTTF at a given bx
0272 //
0273 int L1MuDTTrackFinder::numberOfTracks(int bx) {
0274   int number = 0;
0275   for (auto const& elem : _cache) {
0276     if (elem.bx() == bx)
0277       number++;
0278   }
0279 
0280   return number;
0281 }