Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-28 23:48:42

0001 //-------------------------------------------------
0002 //
0003 //   Class: L1MuBMSectorProcessor
0004 //
0005 //   Description: Sector Processor
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 "L1MuBMSectorProcessor.h"
0020 
0021 //---------------
0022 // C++ Headers --
0023 //---------------
0024 
0025 #include <iostream>
0026 #include <cmath>
0027 
0028 //-------------------------------
0029 // Collaborating Class Headers --
0030 //-------------------------------
0031 
0032 #include <FWCore/Framework/interface/Event.h>
0033 #include "L1Trigger/L1TMuonBarrel/src/L1MuBMTFConfig.h"
0034 #include "L1Trigger/L1TMuonBarrel/src/L1MuBMSectorReceiver.h"
0035 #include "L1Trigger/L1TMuonBarrel/src/L1MuBMDataBuffer.h"
0036 #include "L1Trigger/L1TMuonBarrel/src/L1MuBMExtrapolationUnit.h"
0037 #include "L1Trigger/L1TMuonBarrel/src/L1MuBMTrackAssembler.h"
0038 #include "L1Trigger/L1TMuonBarrel/src/L1MuBMAssignmentUnit.h"
0039 #include "L1Trigger/L1TMuonBarrel/interface/L1MuBMTrackFinder.h"
0040 
0041 #include "DataFormats/L1TMuon/interface/BMTF/L1MuBMSecProcId.h"
0042 #include "DataFormats/L1TMuon/interface/L1MuBMTrack.h"
0043 
0044 using namespace std;
0045 
0046 // --------------------------------
0047 //       class L1MuBMSectorProcessor
0048 //---------------------------------
0049 
0050 //----------------
0051 // Constructors --
0052 //----------------
0053 
0054 L1MuBMSectorProcessor::L1MuBMSectorProcessor(const L1MuBMTrackFinder& tf,
0055                                              const L1MuBMSecProcId& id,
0056                                              edm::ConsumesCollector&& iC)
0057     :
0058 
0059       m_tf(tf),
0060       m_spid(id),
0061       m_SectorReceiver(new L1MuBMSectorReceiver(*this, std::move(iC))),
0062       m_DataBuffer(new L1MuBMDataBuffer(*this)),
0063       m_EU(new L1MuBMExtrapolationUnit(*this, iC)),
0064       m_TA(new L1MuBMTrackAssembler(*this)),
0065       m_bmtfParamsToken(iC.esConsumes()),
0066       m_AUs(),
0067       m_TrackCands(),
0068       m_TracKCands() {
0069   // 2 assignment units
0070   m_AUs.reserve(2);
0071   m_AUs.push_back(new L1MuBMAssignmentUnit(*this, 0));
0072   m_AUs.push_back(new L1MuBMAssignmentUnit(*this, 1));
0073 
0074   // now the 2 track candidates
0075   m_TrackCands.reserve(2);
0076   m_TrackCands.push_back(new L1MuBMTrack(m_spid));
0077   m_TrackCands.push_back(new L1MuBMTrack(m_spid));
0078 
0079   m_TracKCands.reserve(2);
0080   m_TracKCands.push_back(new L1MuBMTrack(m_spid));
0081   m_TracKCands.push_back(new L1MuBMTrack(m_spid));
0082 }
0083 
0084 //--------------
0085 // Destructor --
0086 //--------------
0087 
0088 L1MuBMSectorProcessor::~L1MuBMSectorProcessor() {
0089   delete m_SectorReceiver;
0090   delete m_DataBuffer;
0091   delete m_EU;
0092   delete m_TA;
0093   delete m_AUs[0];
0094   delete m_AUs[1];
0095   delete m_TrackCands[0];
0096   delete m_TrackCands[1];
0097   delete m_TracKCands[0];
0098   delete m_TracKCands[1];
0099 }
0100 
0101 //--------------
0102 // Operations --
0103 //--------------
0104 
0105 //
0106 // run Sector Processor
0107 //
0108 void L1MuBMSectorProcessor::run(int bx, const edm::Event& e, const edm::EventSetup& c) {
0109   // receive data and store them into the data buffer
0110   if (m_SectorReceiver)
0111     m_SectorReceiver->run(bx, e, c);
0112 
0113   // check content of data buffer
0114   if (m_DataBuffer) {
0115     if (L1MuBMTFConfig::Debug(4) && m_DataBuffer->numberTSphi() > 0) {
0116       cout << "Phi track segments received by " << m_spid << " : " << endl;
0117       m_DataBuffer->printTSphi();
0118     }
0119   }
0120 
0121   // perform all extrapolations
0122   int n_ext = 0;  // number of successful extrapolations
0123   if (m_EU && m_DataBuffer && m_DataBuffer->numberTSphi() > 1) {
0124     m_EU->run(c);
0125     n_ext = m_EU->numberOfExt();
0126     if (L1MuBMTFConfig::Debug(3) && n_ext > 0) {
0127       //    if ( print_flag && n_ext > 0  ) {
0128       cout << "Number of successful extrapolations : " << n_ext << endl;
0129       m_EU->print();
0130     }
0131   }
0132 
0133   // hardware debug (output from Extrapolator and Quality Sorter)
0134   // m_EU->print(1);
0135 
0136   // perform track assembling
0137   if (m_TA && n_ext > 0) {
0138     m_TA->run();
0139     if (L1MuBMTFConfig::Debug(3))
0140       m_TA->print();
0141   }
0142 
0143   L1TMuonBarrelParams const& bmtfParams = c.getData(m_bmtfParamsToken);
0144 
0145   // assign pt, eta, phi and quality
0146   if (m_AUs[0] && !m_TA->isEmpty(0))
0147     m_AUs[0]->run(bmtfParams);
0148   if (m_AUs[1] && !m_TA->isEmpty(1))
0149     m_AUs[1]->run(bmtfParams);
0150 
0151   if (m_spid.wheel() == -1) {
0152     if (m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(2) > 3 &&
0153         m_TrackCands[0]->address(2) < 6)
0154       m_TrackCands[0]->reset();
0155     if (m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(3) > 3 &&
0156         m_TrackCands[0]->address(3) < 6)
0157       m_TrackCands[0]->reset();
0158     if (m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(4) > 3 &&
0159         m_TrackCands[0]->address(4) < 6)
0160       m_TrackCands[0]->reset();
0161 
0162     if (m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(2) > 3 &&
0163         m_TracKCands[0]->address(2) < 6)
0164       m_TracKCands[0]->reset();
0165     if (m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(3) > 3 &&
0166         m_TracKCands[0]->address(3) < 6)
0167       m_TracKCands[0]->reset();
0168     if (m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(4) > 3 &&
0169         m_TracKCands[0]->address(4) < 6)
0170       m_TracKCands[0]->reset();
0171 
0172     if (m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(2) > 3 &&
0173         m_TrackCands[1]->address(2) < 6)
0174       m_TrackCands[1]->reset();
0175     if (m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(3) > 3 &&
0176         m_TrackCands[1]->address(3) < 6)
0177       m_TrackCands[1]->reset();
0178     if (m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(4) > 3 &&
0179         m_TrackCands[1]->address(4) < 6)
0180       m_TrackCands[1]->reset();
0181 
0182     if (m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(2) > 3 &&
0183         m_TracKCands[1]->address(2) < 6)
0184       m_TracKCands[1]->reset();
0185     if (m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(3) > 3 &&
0186         m_TracKCands[1]->address(3) < 6)
0187       m_TracKCands[1]->reset();
0188     if (m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(4) > 3 &&
0189         m_TracKCands[1]->address(4) < 6)
0190       m_TracKCands[1]->reset();
0191 
0192     if (m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(2) > 7 &&
0193         m_TrackCands[0]->address(2) < 10)
0194       m_TrackCands[0]->reset();
0195     if (m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(3) > 7 &&
0196         m_TrackCands[0]->address(3) < 10)
0197       m_TrackCands[0]->reset();
0198     if (m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(4) > 7 &&
0199         m_TrackCands[0]->address(4) < 10)
0200       m_TrackCands[0]->reset();
0201 
0202     if (m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(2) > 7 &&
0203         m_TracKCands[0]->address(2) < 10)
0204       m_TracKCands[0]->reset();
0205     if (m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(3) > 7 &&
0206         m_TracKCands[0]->address(3) < 10)
0207       m_TracKCands[0]->reset();
0208     if (m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(4) > 7 &&
0209         m_TracKCands[0]->address(4) < 10)
0210       m_TracKCands[0]->reset();
0211 
0212     if (m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(2) > 7 &&
0213         m_TrackCands[1]->address(2) < 10)
0214       m_TrackCands[1]->reset();
0215     if (m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(3) > 7 &&
0216         m_TrackCands[1]->address(3) < 10)
0217       m_TrackCands[1]->reset();
0218     if (m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(4) > 7 &&
0219         m_TrackCands[1]->address(4) < 10)
0220       m_TrackCands[1]->reset();
0221 
0222     if (m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(2) > 7 &&
0223         m_TracKCands[1]->address(2) < 10)
0224       m_TracKCands[1]->reset();
0225     if (m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(3) > 7 &&
0226         m_TracKCands[1]->address(3) < 10)
0227       m_TracKCands[1]->reset();
0228     if (m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(4) > 7 &&
0229         m_TracKCands[1]->address(4) < 10)
0230       m_TracKCands[1]->reset();
0231   }
0232 }
0233 
0234 //
0235 // reset Sector Processor
0236 //
0237 void L1MuBMSectorProcessor::reset() {
0238   if (m_SectorReceiver)
0239     m_SectorReceiver->reset();
0240   if (m_DataBuffer)
0241     m_DataBuffer->reset();
0242   if (m_EU)
0243     m_EU->reset();
0244   if (m_TA)
0245     m_TA->reset();
0246   if (m_AUs[0])
0247     m_AUs[0]->reset();
0248   if (m_AUs[1])
0249     m_AUs[1]->reset();
0250   if (m_TrackCands[0])
0251     m_TrackCands[0]->reset();
0252   if (m_TrackCands[1])
0253     m_TrackCands[1]->reset();
0254   if (m_TracKCands[0])
0255     m_TracKCands[0]->reset();
0256   if (m_TracKCands[1])
0257     m_TracKCands[1]->reset();
0258 }
0259 
0260 //
0261 // print candidates found in Sector Processor
0262 //
0263 void L1MuBMSectorProcessor::print() const {
0264   if (anyTrack()) {
0265     cout << "Muon candidates found in " << m_spid << " : " << endl;
0266     vector<L1MuBMTrack*>::const_iterator iter = m_TrackCands.begin();
0267     while (iter != m_TrackCands.end()) {
0268       if (*iter)
0269         (*iter)->print();
0270       iter++;
0271     }
0272   }
0273 }
0274 
0275 //
0276 // return pointer to nextWheel neighbour
0277 //
0278 const L1MuBMSectorProcessor* L1MuBMSectorProcessor::neighbour() const {
0279   int sector = m_spid.sector();
0280   int wheel = m_spid.wheel();
0281 
0282   // the neighbour is in the same wedge with the following definition:
0283   // current SP  -3  -2  -1  +1  +2  +3
0284   // neighbour   -2  -1  +1   0  +1  +2
0285 
0286   if (wheel == 1)
0287     return nullptr;
0288   wheel = (wheel == -1) ? 1 : (wheel / abs(wheel)) * (abs(wheel) - 1);
0289 
0290   const L1MuBMSecProcId id(wheel, sector);
0291 
0292   return m_tf.sp(id);
0293 }
0294 
0295 //
0296 // are there any muon candidates?
0297 //
0298 bool L1MuBMSectorProcessor::anyTrack() const {
0299   if (m_TrackCands[0] && !m_TrackCands[0]->empty())
0300     return true;
0301   if (m_TrackCands[1] && !m_TrackCands[1]->empty())
0302     return true;
0303 
0304   return false;
0305 }