Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-16 03:23:56

0001 //-------------------------------------------------
0002 //
0003 //   Class: L1MuDTSectorProcessor
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 "L1Trigger/DTTrackFinder/src/L1MuDTSectorProcessor.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/DTTrackFinder/interface/L1MuDTTFConfig.h"
0034 #include "L1Trigger/DTTrackFinder/interface/L1MuDTSecProcId.h"
0035 #include "L1Trigger/DTTrackFinder/src/L1MuDTSectorReceiver.h"
0036 #include "L1Trigger/DTTrackFinder/src/L1MuDTDataBuffer.h"
0037 #include "L1Trigger/DTTrackFinder/src/L1MuDTExtrapolationUnit.h"
0038 #include "L1Trigger/DTTrackFinder/src/L1MuDTTrackAssembler.h"
0039 #include "L1Trigger/DTTrackFinder/src/L1MuDTAssignmentUnit.h"
0040 #include "L1Trigger/DTTrackFinder/interface/L1MuDTTrackFinder.h"
0041 
0042 using namespace std;
0043 
0044 // --------------------------------
0045 //       class L1MuDTSectorProcessor
0046 //---------------------------------
0047 
0048 //----------------
0049 // Constructors --
0050 //----------------
0051 
0052 L1MuDTSectorProcessor::L1MuDTSectorProcessor(const L1MuDTTrackFinder& tf,
0053                                              const L1MuDTSecProcId& id,
0054                                              edm::ConsumesCollector iC)
0055     : m_tf(tf),
0056       m_spid(id),
0057       m_SectorReceiver(*this, iC),
0058       m_DataBuffer(*this),
0059       m_EU(*this, iC),
0060       m_TA(*this),
0061       m_AUs{{{*this, 0, iC}, {*this, 1, iC}}},
0062       m_TrackCands{{{m_spid}, {m_spid}}},
0063       m_TracKCands{{{m_spid}, {m_spid}}} {}
0064 
0065 //--------------
0066 // Destructor --
0067 //--------------
0068 
0069 L1MuDTSectorProcessor::~L1MuDTSectorProcessor() {}
0070 
0071 //--------------
0072 // Operations --
0073 //--------------
0074 
0075 //
0076 // run Sector Processor
0077 //
0078 void L1MuDTSectorProcessor::run(int bx, const edm::Event& e, const edm::EventSetup& c) {
0079   // receive data and store them into the data buffer
0080   m_SectorReceiver.run(bx, e, c);
0081 
0082   // check content of data buffer
0083   if (m_tf.config()->Debug(4) && m_DataBuffer.numberTSphi() > 0) {
0084     cout << "Phi track segments received by " << m_spid << " : " << endl;
0085     m_DataBuffer.printTSphi();
0086   }
0087 
0088   // perform all extrapolations
0089   int n_ext = 0;  // number of successful extrapolations
0090   if (m_DataBuffer.numberTSphi() > 1) {
0091     m_EU.run(c);
0092     n_ext = m_EU.numberOfExt();
0093     if (m_tf.config()->Debug(3) && n_ext > 0) {
0094       cout << "Number of successful extrapolations : " << n_ext << endl;
0095       m_EU.print();
0096     }
0097   }
0098 
0099   // hardware debug (output from Extrapolator and Quality Sorter)
0100   // m_EU->print(1);
0101 
0102   // perform track assembling
0103   if (n_ext > 0) {
0104     m_TA.run();
0105     if (m_tf.config()->Debug(3))
0106       m_TA.print();
0107   }
0108 
0109   // assign pt, eta, phi and quality
0110   if (!m_TA.isEmpty(0))
0111     m_AUs[0].run(c);
0112   if (!m_TA.isEmpty(1))
0113     m_AUs[1].run(c);
0114 
0115   if (m_spid.wheel() == -1) {
0116     if (!m_TrackCands[0].empty() && m_TrackCands[0].address(2) > 3 && m_TrackCands[0].address(2) < 6)
0117       m_TrackCands[0].reset();
0118     if (!m_TrackCands[0].empty() && m_TrackCands[0].address(3) > 3 && m_TrackCands[0].address(3) < 6)
0119       m_TrackCands[0].reset();
0120     if (!m_TrackCands[0].empty() && m_TrackCands[0].address(4) > 3 && m_TrackCands[0].address(4) < 6)
0121       m_TrackCands[0].reset();
0122 
0123     if (!m_TracKCands[0].empty() && m_TracKCands[0].address(2) > 3 && m_TracKCands[0].address(2) < 6)
0124       m_TracKCands[0].reset();
0125     if (!m_TracKCands[0].empty() && m_TracKCands[0].address(3) > 3 && m_TracKCands[0].address(3) < 6)
0126       m_TracKCands[0].reset();
0127     if (!m_TracKCands[0].empty() && m_TracKCands[0].address(4) > 3 && m_TracKCands[0].address(4) < 6)
0128       m_TracKCands[0].reset();
0129 
0130     if (!m_TrackCands[1].empty() && m_TrackCands[1].address(2) > 3 && m_TrackCands[1].address(2) < 6)
0131       m_TrackCands[1].reset();
0132     if (!m_TrackCands[1].empty() && m_TrackCands[1].address(3) > 3 && m_TrackCands[1].address(3) < 6)
0133       m_TrackCands[1].reset();
0134     if (!m_TrackCands[1].empty() && m_TrackCands[1].address(4) > 3 && m_TrackCands[1].address(4) < 6)
0135       m_TrackCands[1].reset();
0136 
0137     if (!m_TracKCands[1].empty() && m_TracKCands[1].address(2) > 3 && m_TracKCands[1].address(2) < 6)
0138       m_TracKCands[1].reset();
0139     if (!m_TracKCands[1].empty() && m_TracKCands[1].address(3) > 3 && m_TracKCands[1].address(3) < 6)
0140       m_TracKCands[1].reset();
0141     if (!m_TracKCands[1].empty() && m_TracKCands[1].address(4) > 3 && m_TracKCands[1].address(4) < 6)
0142       m_TracKCands[1].reset();
0143 
0144     if (!m_TrackCands[0].empty() && m_TrackCands[0].address(2) > 7 && m_TrackCands[0].address(2) < 10)
0145       m_TrackCands[0].reset();
0146     if (!m_TrackCands[0].empty() && m_TrackCands[0].address(3) > 7 && m_TrackCands[0].address(3) < 10)
0147       m_TrackCands[0].reset();
0148     if (!m_TrackCands[0].empty() && m_TrackCands[0].address(4) > 7 && m_TrackCands[0].address(4) < 10)
0149       m_TrackCands[0].reset();
0150 
0151     if (!m_TracKCands[0].empty() && m_TracKCands[0].address(2) > 7 && m_TracKCands[0].address(2) < 10)
0152       m_TracKCands[0].reset();
0153     if (!m_TracKCands[0].empty() && m_TracKCands[0].address(3) > 7 && m_TracKCands[0].address(3) < 10)
0154       m_TracKCands[0].reset();
0155     if (!m_TracKCands[0].empty() && m_TracKCands[0].address(4) > 7 && m_TracKCands[0].address(4) < 10)
0156       m_TracKCands[0].reset();
0157 
0158     if (!m_TrackCands[1].empty() && m_TrackCands[1].address(2) > 7 && m_TrackCands[1].address(2) < 10)
0159       m_TrackCands[1].reset();
0160     if (!m_TrackCands[1].empty() && m_TrackCands[1].address(3) > 7 && m_TrackCands[1].address(3) < 10)
0161       m_TrackCands[1].reset();
0162     if (!m_TrackCands[1].empty() && m_TrackCands[1].address(4) > 7 && m_TrackCands[1].address(4) < 10)
0163       m_TrackCands[1].reset();
0164 
0165     if (!m_TracKCands[1].empty() && m_TracKCands[1].address(2) > 7 && m_TracKCands[1].address(2) < 10)
0166       m_TracKCands[1].reset();
0167     if (!m_TracKCands[1].empty() && m_TracKCands[1].address(3) > 7 && m_TracKCands[1].address(3) < 10)
0168       m_TracKCands[1].reset();
0169     if (!m_TracKCands[1].empty() && m_TracKCands[1].address(4) > 7 && m_TracKCands[1].address(4) < 10)
0170       m_TracKCands[1].reset();
0171   }
0172 }
0173 
0174 //
0175 // reset Sector Processor
0176 //
0177 void L1MuDTSectorProcessor::reset() {
0178   m_SectorReceiver.reset();
0179   m_DataBuffer.reset();
0180   m_EU.reset();
0181   m_TA.reset();
0182   m_AUs[0].reset();
0183   m_AUs[1].reset();
0184   m_TrackCands[0].reset();
0185   m_TrackCands[1].reset();
0186   m_TracKCands[0].reset();
0187   m_TracKCands[1].reset();
0188 }
0189 
0190 //
0191 // print candidates found in Sector Processor
0192 //
0193 void L1MuDTSectorProcessor::print() const {
0194   if (anyTrack()) {
0195     cout << "Muon candidates found in " << m_spid << " : " << endl;
0196     auto iter = m_TrackCands.cbegin();
0197     while (iter != m_TrackCands.end()) {
0198       iter->print();
0199       iter++;
0200     }
0201   }
0202 }
0203 
0204 //
0205 // return pointer to nextWheel neighbour
0206 //
0207 const L1MuDTSectorProcessor* L1MuDTSectorProcessor::neighbour() const {
0208   int sector = m_spid.sector();
0209   int wheel = m_spid.wheel();
0210 
0211   // the neighbour is in the same wedge with the following definition:
0212   // current SP  -3  -2  -1  +1  +2  +3
0213   // neighbour   -2  -1  +1   0  +1  +2
0214 
0215   if (wheel == 1)
0216     return nullptr;
0217   wheel = (wheel == -1) ? 1 : (wheel / abs(wheel)) * (abs(wheel) - 1);
0218 
0219   const L1MuDTSecProcId id(wheel, sector);
0220 
0221   return m_tf.sp(id);
0222 }
0223 
0224 //
0225 // are there any muon candidates?
0226 //
0227 bool L1MuDTSectorProcessor::anyTrack() const {
0228   if (!m_TrackCands[0].empty())
0229     return true;
0230   if (!m_TrackCands[1].empty())
0231     return true;
0232 
0233   return false;
0234 }