CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/L1Trigger/DTTrackFinder/src/L1MuDTEUX.cc

Go to the documentation of this file.
00001 //-------------------------------------------------
00002 //
00003 //   Class: L1MuDTEUX
00004 //
00005 //   Description: Extrapolator
00006 //
00007 //
00008 //   $Date: 2008/11/28 10:30:51 $
00009 //   $Revision: 1.10 $
00010 //
00011 //   Author :
00012 //   N. Neumeister            CERN EP
00013 //
00014 //--------------------------------------------------
00015 
00016 //-----------------------
00017 // This Class's Header --
00018 //-----------------------
00019 
00020 #include "L1Trigger/DTTrackFinder/src/L1MuDTEUX.h"
00021 
00022 //---------------
00023 // C++ Headers --
00024 //---------------
00025 
00026 #include <iostream>
00027 
00028 //-------------------------------
00029 // Collaborating Class Headers --
00030 //-------------------------------
00031 
00032 #include "L1Trigger/DTTrackFinder/src/L1MuDTTFConfig.h"
00033 #include "CondFormats/L1TObjects/interface/L1MuDTExtParam.h"
00034 #include "L1Trigger/DTTrackFinder/src/L1MuDTSectorProcessor.h"
00035 #include "L1Trigger/DTTrackFinder/src/L1MuDTSEU.h"
00036 #include "L1Trigger/DTTrackFinder/src/L1MuDTTrackSegPhi.h"
00037 #include "CondFormats/L1TObjects/interface/L1MuDTExtLut.h"
00038 #include "CondFormats/DataRecord/interface/L1MuDTExtLutRcd.h"
00039 #include "CondFormats/L1TObjects/interface/L1MuDTTFParameters.h"
00040 #include "CondFormats/DataRecord/interface/L1MuDTTFParametersRcd.h"
00041 
00042 using namespace std;
00043 
00044 // --------------------------------
00045 //       class L1MuDTEUX
00046 //---------------------------------
00047 
00048 //----------------
00049 // Constructors --
00050 //----------------
00051 
00052 L1MuDTEUX::L1MuDTEUX(const L1MuDTSectorProcessor& sp, const L1MuDTSEU& seu, int id) : 
00053     m_sp(sp), m_seu(seu), m_id(id), 
00054     m_result(false), m_quality(0), m_address(15),
00055     m_start(0), m_target(0) {
00056 
00057   setPrecision();
00058 
00059 }
00060 
00061 
00062 //--------------
00063 // Destructor --
00064 //--------------
00065 
00066 L1MuDTEUX::~L1MuDTEUX() {}
00067 
00068 
00069 //--------------
00070 // Operations --
00071 //--------------
00072 
00073 //
00074 // Equal operator
00075 //
00076 bool L1MuDTEUX::operator==(const L1MuDTEUX& eux) const {
00077 
00078   if ( m_id      != eux.id() )      return false;
00079   if ( m_result  != eux.result() )  return false;
00080   if ( m_quality != eux.quality() ) return false;
00081   if ( m_address != eux.address() ) return false;
00082   return true;
00083 
00084 }
00085 
00086 
00087 //
00088 // run EUX
00089 //
00090 void L1MuDTEUX::run(const edm::EventSetup& c) {
00091 
00092   c.get< L1MuDTExtLutRcd >().get( theExtLUTs );
00093   c.get< L1MuDTTFParametersRcd >().get( pars );
00094 
00095   if ( L1MuDTTFConfig::Debug(4) ) cout << "Run EUX "  << m_id << endl;
00096   if ( L1MuDTTFConfig::Debug(4) ) cout << "start :  " << *m_start  << endl;
00097   if ( L1MuDTTFConfig::Debug(4) ) cout << "target : " << *m_target << endl;
00098 
00099   if ( m_start == 0 || m_target == 0 ) { 
00100     if ( L1MuDTTFConfig::Debug(4) ) cout << "Error: EUX has no data loaded" << endl;
00101     return;
00102   }
00103 
00104   // start sector
00105   int sector_st = m_start->sector();
00106 
00107   // target sector
00108   int sector_ta = m_target->sector();
00109 
00110   // get index of look-up table
00111   int lut_idx = m_seu.ext();
00112   if ( abs(m_target->wheel()) == 3 ) {
00113 
00114     switch ( m_seu.ext() ) {
00115       case EX13 : { lut_idx = EX15; break; }
00116       case EX23 : { lut_idx = EX25; break; }
00117       default   : { lut_idx = m_seu.ext(); break; }
00118     }
00119 
00120   }
00121 
00122   if ( L1MuDTTFConfig::Debug(5) ) cout << "EUX : using look-up table : "
00123                                        << static_cast<Extrapolation>(lut_idx)
00124                                        << endl;
00125 
00126   // Extrapolation TS quality filter
00127   int qcut = 0;
00128   if ( m_seu.ext() == EX12 ) qcut = pars->get_soc_qcut_st1(m_sp.id().wheel(), m_sp.id().sector());
00129   if ( m_seu.ext() == EX13 ) qcut = pars->get_soc_qcut_st1(m_sp.id().wheel(), m_sp.id().sector());
00130   if ( m_seu.ext() == EX14 ) qcut = pars->get_soc_qcut_st1(m_sp.id().wheel(), m_sp.id().sector());
00131   if ( m_seu.ext() == EX21 ) qcut = pars->get_soc_qcut_st2(m_sp.id().wheel(), m_sp.id().sector());
00132   if ( m_seu.ext() == EX23 ) qcut = pars->get_soc_qcut_st2(m_sp.id().wheel(), m_sp.id().sector());
00133   if ( m_seu.ext() == EX24 ) qcut = pars->get_soc_qcut_st2(m_sp.id().wheel(), m_sp.id().sector());
00134   if ( m_seu.ext() == EX34 ) qcut = pars->get_soc_qcut_st4(m_sp.id().wheel(), m_sp.id().sector());
00135 
00136   if ( m_start->quality() < qcut ) return;
00137   
00138   // calculate bit shift
00139   int sh_phi  = 12 - nbit_phi;
00140   int sh_phib = 10 - nbit_phib;
00141 
00142   int phi_target = m_target->phi() >> sh_phi;
00143   int phi_start  = m_start->phi()  >> sh_phi;
00144   int phib_start = (m_start->phib() >> sh_phib) << sh_phib;
00145   if ( phib_start < 0 ) phib_start += (1 << sh_phib) -1;
00146 
00147   // compute difference in phi
00148   int diff = phi_target - phi_start;
00149 
00150   // get low and high values from look-up table 
00151   // and add offset (30 degrees ) for extrapolation to adjacent sector 
00152   int offset = -2144 >> sh_phi;
00153   offset  *= sec_mod(sector_ta - sector_st);
00154   int low  = theExtLUTs->getLow(lut_idx,phib_start );
00155   int high = theExtLUTs->getHigh(lut_idx,phib_start );
00156   if ( low  < 0 ) low  += (1 << sh_phi) - 1;
00157   if ( high < 0 ) high += (1 << sh_phi) - 1;
00158   low  = (low  >> sh_phi) + offset;
00159   high = (high >> sh_phi) + offset;
00160 
00161   int phi_offset = phi_target - offset;
00162   if ( ( lut_idx == EX34 ) || ( lut_idx == EX21 ) )
00163     phi_offset = phi_start + offset;
00164   if ( phi_offset >= (1 << (nbit_phi-1)) -1 ) return;
00165   if ( phi_offset < -(1 << (nbit_phi-1)) +1 ) return;
00166 
00167   // is phi-difference within the extrapolation window?
00168   bool openlut = pars->get_soc_openlut_extr(m_sp.id().wheel(), m_sp.id().sector());
00169   if (( diff >= low && diff <= high ) || L1MuDTTFConfig::getopenLUTs() || openlut ) {
00170     m_result = true;
00171     int qual_st = m_start->quality();
00172     int qual_ta = m_target->quality();
00173     if ( m_seu.ext() == EX34 || m_seu.ext() == EX21 ) {
00174       m_quality = ( qual_st == 7 ) ? 0 : qual_st + 1;
00175     } 
00176     else {  
00177       m_quality = ( qual_ta == 7 ) ? 0 : qual_ta + 1;
00178     }
00179     m_address = m_id;
00180   }
00181 
00182   if ( L1MuDTTFConfig::Debug(5) ) cout << "diff : "   << low  << " "
00183                                        << diff << " " << high << " : "
00184                                        << m_result << " " << endl;
00185 
00186 }
00187 
00188 
00189 //
00190 // load data into EUX
00191 //
00192 void L1MuDTEUX::load(const L1MuDTTrackSegPhi* start_ts, 
00193                      const L1MuDTTrackSegPhi* target_ts) {
00194 
00195   m_start  = start_ts;
00196   m_target = target_ts;
00197 
00198   // in case of EX34 and EX21 exchange start and target
00199   if ( ( m_seu.ext() == EX34 ) || ( m_seu.ext() == EX21 ) ) {
00200     m_start  = target_ts;
00201     m_target = start_ts;
00202   }
00203 
00204 }
00205 
00206 
00207 //
00208 // reset this EUX
00209 //
00210 
00211 void L1MuDTEUX::reset() {
00212   
00213   m_result  = false;
00214   m_quality = 0;
00215   m_address = 15;
00216 
00217   m_start  = 0;
00218   m_target = 0;
00219 
00220 }
00221 
00222 
00223 //
00224 // return pointer to start and target track segment
00225 //
00226 pair<const L1MuDTTrackSegPhi* ,const L1MuDTTrackSegPhi*> L1MuDTEUX::ts() const {
00227 
00228   return pair<const L1MuDTTrackSegPhi*, const L1MuDTTrackSegPhi*>(m_start,m_target);
00229 
00230 }
00231 
00232 
00233 //
00234 // symmetric modulo function for sectors
00235 // output values in the range -6 to +5
00236 //
00237 int L1MuDTEUX::sec_mod(int sector) const {
00238 
00239   int new_sector = sector%12;
00240   if ( new_sector >= 6 )
00241     new_sector = new_sector - 12;
00242   if ( new_sector < -6 )
00243     new_sector = new_sector + 12;
00244    
00245   return new_sector;
00246 
00247 }
00248 
00249 
00250 //
00251 // set precision for phi and phib 
00252 // default is 12 bits for phi and 10 bits for phib
00253 //
00254 void L1MuDTEUX::setPrecision() {
00255 
00256   nbit_phi  = L1MuDTTFConfig::getNbitsExtPhi();
00257   nbit_phib = L1MuDTTFConfig::getNbitsExtPhib();
00258 
00259   theExtFilter = L1MuDTTFConfig::getExtTSFilter();
00260 
00261 }
00262 
00263 
00264 // static data members
00265 
00266 int L1MuDTEUX::theExtFilter = 1;
00267 unsigned short int L1MuDTEUX::nbit_phi  = 12;
00268 unsigned short int L1MuDTEUX::nbit_phib = 10;