CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/L1Trigger/DTTrackFinder/src/L1MuDTSectorProcessor.cc

Go to the documentation of this file.
00001 //-------------------------------------------------
00002 //
00003 //   Class: L1MuDTSectorProcessor
00004 //
00005 //   Description: Sector Processor
00006 //
00007 //
00008 //   $Date: 2010/06/28 14:35:29 $
00009 //   $Revision: 1.7 $
00010 //
00011 //   Author :
00012 //   N. Neumeister            CERN EP
00013 //   J. Troconiz              UAM Madrid
00014 //
00015 //--------------------------------------------------
00016 
00017 //-----------------------
00018 // This Class's Header --
00019 //-----------------------
00020 
00021 #include "L1Trigger/DTTrackFinder/src/L1MuDTSectorProcessor.h"
00022 
00023 //---------------
00024 // C++ Headers --
00025 //---------------
00026 
00027 #include <iostream>
00028 #include <cmath>
00029 
00030 //-------------------------------
00031 // Collaborating Class Headers --
00032 //-------------------------------
00033 
00034 #include <FWCore/Framework/interface/Event.h>
00035 #include "L1Trigger/DTTrackFinder/src/L1MuDTTFConfig.h"
00036 #include "L1Trigger/DTTrackFinder/src/L1MuDTSecProcId.h"
00037 #include "L1Trigger/DTTrackFinder/src/L1MuDTSectorReceiver.h"
00038 #include "L1Trigger/DTTrackFinder/src/L1MuDTDataBuffer.h"
00039 #include "L1Trigger/DTTrackFinder/src/L1MuDTExtrapolationUnit.h"
00040 #include "L1Trigger/DTTrackFinder/src/L1MuDTTrackAssembler.h"
00041 #include "L1Trigger/DTTrackFinder/src/L1MuDTAssignmentUnit.h"
00042 #include "L1Trigger/DTTrackFinder/interface/L1MuDTTrackFinder.h"
00043 #include "L1Trigger/DTTrackFinder/interface/L1MuDTTrack.h"
00044 
00045 using namespace std;
00046 
00047 // --------------------------------
00048 //       class L1MuDTSectorProcessor
00049 //---------------------------------
00050 
00051 //----------------
00052 // Constructors --
00053 //----------------
00054 
00055 L1MuDTSectorProcessor::L1MuDTSectorProcessor(const L1MuDTTrackFinder& tf,
00056                                              const L1MuDTSecProcId& id) :
00057       m_tf(tf), m_spid(id), 
00058       m_SectorReceiver(new L1MuDTSectorReceiver(*this)),
00059       m_DataBuffer(new L1MuDTDataBuffer(*this)),
00060       m_EU(new L1MuDTExtrapolationUnit(*this)),
00061       m_TA(new L1MuDTTrackAssembler(*this)), 
00062       m_AUs(), m_TrackCands(), m_TracKCands() {
00063 
00064   // 2 assignment units
00065   m_AUs.reserve(2);
00066   m_AUs.push_back(new L1MuDTAssignmentUnit(*this,0));
00067   m_AUs.push_back(new L1MuDTAssignmentUnit(*this,1));
00068 
00069   // now the 2 track candidates
00070   m_TrackCands.reserve(2);
00071   m_TrackCands.push_back(new L1MuDTTrack(m_spid) );
00072   m_TrackCands.push_back(new L1MuDTTrack(m_spid) );
00073 
00074   m_TracKCands.reserve(2);
00075   m_TracKCands.push_back(new L1MuDTTrack(m_spid) );
00076   m_TracKCands.push_back(new L1MuDTTrack(m_spid) );
00077   
00078 }
00079 
00080 
00081 //--------------
00082 // Destructor --
00083 //--------------
00084 
00085 L1MuDTSectorProcessor::~L1MuDTSectorProcessor() {
00086 
00087   delete m_SectorReceiver;
00088   delete m_DataBuffer;
00089   delete m_EU;
00090   delete m_TA;
00091   delete m_AUs[0];
00092   delete m_AUs[1];
00093   delete m_TrackCands[0];
00094   delete m_TrackCands[1];
00095   delete m_TracKCands[0];
00096   delete m_TracKCands[1];
00097 
00098 }
00099 
00100 //--------------
00101 // Operations --
00102 //--------------
00103 
00104 //
00105 // run Sector Processor
00106 //
00107 void L1MuDTSectorProcessor::run(int bx, const edm::Event& e, const edm::EventSetup& c) {
00108 
00109   // receive data and store them into the data buffer
00110   if ( m_SectorReceiver ) m_SectorReceiver->run(bx, e, c);
00111 
00112   // check content of data buffer
00113   if ( m_DataBuffer ) {
00114     if ( L1MuDTTFConfig::Debug(4) && m_DataBuffer->numberTSphi() > 0 ) {
00115       cout << "Phi track segments received by " << m_spid << " : " << endl;
00116       m_DataBuffer->printTSphi();
00117     }
00118   }
00119 
00120   // perform all extrapolations
00121   int n_ext = 0;        // number of successful extrapolations
00122   if ( m_EU && m_DataBuffer && m_DataBuffer->numberTSphi() > 1 ) {
00123     m_EU->run(c);
00124     n_ext = m_EU->numberOfExt();
00125     if ( L1MuDTTFConfig::Debug(3) && n_ext > 0  ) {
00126       cout << "Number of successful extrapolations : " << n_ext << endl;
00127       m_EU->print();
00128     }
00129   }
00130 
00131   // hardware debug (output from Extrapolator and Quality Sorter)
00132   // m_EU->print(1);
00133 
00134   // perform track assembling
00135   if ( m_TA &&  n_ext > 0 ) {
00136     m_TA->run();
00137     if ( L1MuDTTFConfig::Debug(3) ) m_TA->print();
00138   }
00139 
00140   // assign pt, eta, phi and quality
00141   if ( m_AUs[0] && !m_TA->isEmpty(0) ) m_AUs[0]->run(c);
00142   if ( m_AUs[1] && !m_TA->isEmpty(1) ) m_AUs[1]->run(c);
00143 
00144   if ( m_spid.wheel() == -1 ) {
00145     if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(2)>3 && m_TrackCands[0]->address(2)<6 ) m_TrackCands[0]->reset();
00146     if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(3)>3 && m_TrackCands[0]->address(3)<6 ) m_TrackCands[0]->reset();
00147     if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(4)>3 && m_TrackCands[0]->address(4)<6 ) m_TrackCands[0]->reset();
00148 
00149     if ( m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(2)>3 && m_TracKCands[0]->address(2)<6 ) m_TracKCands[0]->reset();
00150     if ( m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(3)>3 && m_TracKCands[0]->address(3)<6 ) m_TracKCands[0]->reset();
00151     if ( m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(4)>3 && m_TracKCands[0]->address(4)<6 ) m_TracKCands[0]->reset();
00152 
00153     if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(2)>3 && m_TrackCands[1]->address(2)<6 ) m_TrackCands[1]->reset();
00154     if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(3)>3 && m_TrackCands[1]->address(3)<6 ) m_TrackCands[1]->reset();
00155     if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(4)>3 && m_TrackCands[1]->address(4)<6 ) m_TrackCands[1]->reset();
00156 
00157     if ( m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(2)>3 && m_TracKCands[1]->address(2)<6 ) m_TracKCands[1]->reset();
00158     if ( m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(3)>3 && m_TracKCands[1]->address(3)<6 ) m_TracKCands[1]->reset();
00159     if ( m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(4)>3 && m_TracKCands[1]->address(4)<6 ) m_TracKCands[1]->reset();
00160 
00161     if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(2)>7 && m_TrackCands[0]->address(2)<10 ) m_TrackCands[0]->reset();
00162     if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(3)>7 && m_TrackCands[0]->address(3)<10 ) m_TrackCands[0]->reset();
00163     if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(4)>7 && m_TrackCands[0]->address(4)<10 ) m_TrackCands[0]->reset();
00164 
00165     if ( m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(2)>7 && m_TracKCands[0]->address(2)<10 ) m_TracKCands[0]->reset();
00166     if ( m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(3)>7 && m_TracKCands[0]->address(3)<10 ) m_TracKCands[0]->reset();
00167     if ( m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(4)>7 && m_TracKCands[0]->address(4)<10 ) m_TracKCands[0]->reset();
00168 
00169     if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(2)>7 && m_TrackCands[1]->address(2)<10 ) m_TrackCands[1]->reset();
00170     if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(3)>7 && m_TrackCands[1]->address(3)<10 ) m_TrackCands[1]->reset();
00171     if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(4)>7 && m_TrackCands[1]->address(4)<10 ) m_TrackCands[1]->reset();
00172 
00173     if ( m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(2)>7 && m_TracKCands[1]->address(2)<10 ) m_TracKCands[1]->reset();
00174     if ( m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(3)>7 && m_TracKCands[1]->address(3)<10 ) m_TracKCands[1]->reset();
00175     if ( m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(4)>7 && m_TracKCands[1]->address(4)<10 ) m_TracKCands[1]->reset();
00176   }
00177 
00178 } 
00179 
00180 
00181 //
00182 // reset Sector Processor
00183 //
00184 void L1MuDTSectorProcessor::reset() {
00185 
00186   if ( m_SectorReceiver ) m_SectorReceiver->reset();
00187   if ( m_DataBuffer ) m_DataBuffer->reset();
00188   if ( m_EU ) m_EU->reset();
00189   if ( m_TA ) m_TA->reset();
00190   if ( m_AUs[0] ) m_AUs[0]->reset();
00191   if ( m_AUs[1] ) m_AUs[1]->reset();
00192   if ( m_TrackCands[0] ) m_TrackCands[0]->reset();
00193   if ( m_TrackCands[1] ) m_TrackCands[1]->reset();
00194   if ( m_TracKCands[0] ) m_TracKCands[0]->reset();
00195   if ( m_TracKCands[1] ) m_TracKCands[1]->reset();
00196 
00197 } 
00198 
00199 
00200 //
00201 // print candidates found in Sector Processor
00202 //
00203 void L1MuDTSectorProcessor::print() const {
00204 
00205   if ( anyTrack() ) {
00206     cout << "Muon candidates found in " << m_spid << " : " << endl;
00207     vector<L1MuDTTrack*>::const_iterator iter = m_TrackCands.begin();
00208     while ( iter != m_TrackCands.end() ) {
00209       if ( *iter) (*iter)->print();
00210       iter++;
00211     }
00212   }
00213 
00214 }
00215 
00216 
00217 //
00218 // return pointer to nextWheel neighbour
00219 //
00220 const L1MuDTSectorProcessor* L1MuDTSectorProcessor::neighbour() const {
00221 
00222   int sector = m_spid.sector();
00223   int wheel  = m_spid.wheel();
00224 
00225   // the neighbour is in the same wedge with the following definition:
00226   // current SP  -3  -2  -1  +1  +2  +3
00227   // neighbour   -2  -1  +1   0  +1  +2
00228 
00229   if ( wheel == 1) return 0;
00230   wheel = (wheel == -1) ? 1 : (wheel/abs(wheel)) * (abs(wheel)-1);
00231 
00232   const L1MuDTSecProcId id(wheel,sector);
00233 
00234   return m_tf.sp(id);
00235 
00236 }
00237 
00238 
00239 //
00240 // are there any muon candidates?
00241 //
00242 bool L1MuDTSectorProcessor::anyTrack() const {
00243 
00244   if ( m_TrackCands[0] && !m_TrackCands[0]->empty() ) return true;
00245   if ( m_TrackCands[1] && !m_TrackCands[1]->empty() ) return true;
00246   
00247   return false;
00248 
00249 }