CMS 3D CMS Logo

L1MuDTEUX.cc

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

Generated on Tue Jun 9 17:40:01 2009 for CMSSW by  doxygen 1.5.4