CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/L1Trigger/DTTriggerServerPhi/src/DTTSCand.cc

Go to the documentation of this file.
00001 //-------------------------------------------------
00002 //
00003 //   Class: DTTSCand.cpp
00004 //
00005 //   Description: A Trigger Server Candidate
00006 //
00007 //
00008 //   Author List:
00009 //   C. Grandi
00010 //   Modifications: 
00011 //   S. Marcellini, D. Bonacorsi
00012 //   04/01/2007 : C. Battilana local config update
00013 //
00014 //--------------------------------------------------
00015 
00016 //-----------------------
00017 // This Class's Header --
00018 //-----------------------
00019 #include "L1Trigger/DTTriggerServerPhi/interface/DTTSCand.h"
00020 
00021 //-------------------------------
00022 // Collaborating Class Headers --
00023 //-------------------------------
00024 #include "L1TriggerConfig/DTTPGConfig/interface/DTConfigTSPhi.h"
00025 
00026 //---------------
00027 // C++ Headers --
00028 //---------------
00029 #include <iostream>
00030 
00031 //----------------
00032 
00033 // Constructors --
00034 //----------------
00035 
00036 DTTSCand::DTTSCand(DTTSS* tss, const DTTracoTrigData* tctrig, 
00037                            int ifs, int pos) 
00038   : _tss(tss), _tctrig(tctrig), _tcPos(pos), _isCarry(0) {
00039 
00040    _dataword.one();              // reset dataword to 0x1ff
00041 
00042    // SM sector collector Set bit 14 instead of 8, for 1st/2nd track to allow extra space 
00043    //      if(ifs==1)_dataword.unset(8); // set bit 8 (0=first, 1=second tracks)
00044       if(ifs==1)_dataword.unset(14); // set bit 14 (0=first, 1=second tracks)
00045 
00046 }
00047 
00048 DTTSCand::DTTSCand(const DTTSCand& tscand) 
00049   : _tss(tscand._tss), _tctrig(tscand._tctrig), _tcPos(tscand._tcPos), 
00050   _isCarry(tscand._isCarry) {
00051 
00052  
00053 }
00054 
00055 
00056 DTTSCand::DTTSCand() {}
00057 
00058 //--------------
00059 // Destructor --
00060 //--------------
00061 DTTSCand::~DTTSCand(){
00062 }
00063 
00064 
00065 //--------------
00066 // Operations --
00067 //--------------
00068 
00069 DTTSCand& 
00070 DTTSCand::operator=(const DTTSCand& tscand) {
00071   if(this != &tscand){
00072     _tss = tscand._tss;
00073     _tctrig = tscand._tctrig;
00074     _tcPos = tscand._tcPos;
00075     _isCarry = tscand._isCarry;
00076   }
00077   return *this;
00078 }
00079 
00080 void
00081 DTTSCand::clear()  { 
00082   _tctrig=0; 
00083   _dataword.one();
00084 
00085   _isCarry=0;
00086 
00087 }
00088 
00089 void
00090 DTTSCand::setBitsTss() {
00091   // first/second track already set. Set other 3 bits
00092   int itk=_dataword.element(14); // first tracks 0, second tracks 1
00093  
00094    clearBits();
00095       if(_tctrig->pvK()>32|| _tctrig->pvK()<0){ // Check K within 5 bits range
00096      std::cout << "DTTSCand::setBitsTss() pvK outside valid range: " << _tctrig->pvK();
00097      std::cout << " deltaPsiR set to 31" << std::endl;
00098    }
00099    else { 
00100      // assign preview in dataword (common to any other assignment)
00101         _dataword.assign(0,5,_tctrig->pvK());
00102      //  _dataword.assign(0,5,0);
00103      
00104      int posH=-1;
00105      int posI=-1;
00106      int posC=-1;
00107      switch(config()->TssMasking(itk)) {
00108      case 123: // H/L, In/Out, Corr/NotC
00109        posH = 7;
00110        posI = 6;
00111        posC = 5;
00112        break;
00113      case 132: // H/L, Corr/NotC, In/Out
00114        posH = 7;
00115        posI = 5;
00116        posC = 6;
00117        break;
00118      case 213: // In/Out, H/L, Corr/NotC 
00119        posH = 6;
00120        posI = 7;
00121        posC = 5;
00122        break;
00123      case 231: // In/Out, Corr/NotC, H/L 
00124        posH = 5;
00125        posI = 7;
00126        posC = 6;
00127        break;
00128      case 312: // Corr/NotC, H/L, In/Out
00129        posH = 6;
00130        posI = 5;
00131        posC = 7;
00132        break;
00133      case 321: // Corr/NotC, In/Out, H/L
00134        posH = 5;
00135        posI = 6;
00136        posC = 7;
00137        break;
00138      default:
00139        std::cout << "DTTSCand::DTTSCand(): masking not correct: ";
00140        std::cout << config()->TssMasking(itk);
00141        std::cout << " All bits set to 1" << std::endl;
00142      }
00143      // Masking:
00144      bool enaH = config()->TssHtrigEna(itk);
00145      bool enaI = config()->TssInOutEna(itk);
00146      bool enaC = config()->TssCorrEna(itk) ;
00147      if(isCarry()) {
00148        // Special setting for carry
00149        enaH = config()->TssHtrigEnaCarry();
00150        enaI = config()->TssInOutEnaCarry();
00151        enaC = config()->TssCorrEnaCarry() ;
00152      }
00153      // Bits set to 0 give higher priority:
00154      if(isHtrig()&&enaH&&posH>0)_dataword.unset(posH);
00155      if(isInner()&&enaI&&posI>0)_dataword.unset(posI);
00156      if(isCorr() &&enaC&&posC>0)_dataword.unset(posC);
00157    }
00158           
00159 }
00160 
00161 
00162 void
00163 DTTSCand::setBitsBkmod() {
00164   // first/second track already set. Set other 4 bits (1 for null, 3 for a2, a1, a0)
00165   clearBitsBkmod();
00166   //  std::cout << " clearbits in TSM bk mode " << _dataword.print() << std::endl;
00167 
00168   int a2  = 6;
00169   int a1  = 5;
00170   int a0  = 4;
00171   //
00172   // std::cout << " _tctrig->qdec(): " << _tctrig->qdec() << std::endl;
00173   if( _tctrig->qdec()==6 ) { _dataword.unset(a2); _dataword.unset(a1); _dataword.unset(a0); }  // 1-000
00174   if( _tctrig->qdec()==5 ) { _dataword.unset(a2); _dataword.unset(a1); }                         // 1-001
00175   if( _tctrig->qdec()==4 ) { _dataword.unset(a2); _dataword.unset(a0); }                         // 1-010
00176   if( _tctrig->qdec()==3 ) { _dataword.unset(a1); }                                                // 1-101
00177   if( _tctrig->qdec()==2 ) { _dataword.unset(a1); _dataword.unset(a0); }                         // 1-100
00178 
00179   if( _tctrig->qdec()==0 ) { _dataword.unset(a0); }                                                // 1-110
00180 
00181   //    std::cout << " set Bits TSM back up " << _dataword.print() << std::endl;    
00182 }
00183 
00184 
00185 void
00186 DTTSCand::setBitsTsm() {
00187   // first/second track already set. Set other 3 bits
00188    int itk=_dataword.element(14); // first tracks 0, second tracks 1
00189 
00190   clearBits();
00191 
00192   if(_tctrig->pvK()>31|| _tctrig->pvK()<0){ // Check K within 5 bits range
00193     std::cout << "DTTSCand::setBitsTsm pvK outside valid range: " << _tctrig->pvK();
00194     std::cout << " deltaPsiR set to 31" << std::endl;
00195   }
00196   else {
00197     // SM double TSM
00198     // assign preview in dataword (common to any other assignment)
00199      _dataword.assign(0,5,_tctrig->pvK());
00200      //  _dataword.assign(0,5,0);
00201     // 
00202     
00203     int posH=-1;
00204     int posI=-1;
00205     int posC=-1;
00206     switch(config()->TsmMasking(itk)) {
00207     case 123: // H/L, In/Out, Corr/NotC
00208       posH = 7;
00209       posI = 6;
00210       posC = 5;
00211       break;
00212     case 132: // H/L, Corr/NotC, In/Out
00213       posH = 7;
00214       posI = 5;
00215       posC = 6;
00216       break;
00217     case 213: // In/Out, H/L, Corr/NotC 
00218       posH = 6;
00219       posI = 7;
00220       posC = 5;
00221       break;
00222     case 231: // In/Out, Corr/NotC, H/L 
00223       posH = 5;
00224       posI = 7;
00225       posC = 6;
00226       break;
00227     case 312: // Corr/NotC, H/L, In/Out
00228       posH = 6;
00229       posI = 5;
00230       posC = 7;
00231       break;
00232     case 321: // Corr/NotC, In/Out, H/L
00233       posH = 5;
00234       posI = 6;
00235       posC = 7;
00236       break;
00237     default:
00238       std::cout << "DTTSCand::DTTSCand(): masking not correct: ";
00239       std::cout << config()->TssMasking(itk);
00240       std::cout << " All bits set to 1" << std::endl;
00241       
00242     // Masking:
00243       bool enaH = config()->TsmHtrigEna(itk);
00244       bool enaI = config()->TsmInOutEna(itk);
00245       bool enaC = config()->TsmCorrEna(itk) ;
00246       if(isCarry()) {
00247         // Special setting for carry
00248         enaH = config()->TsmHtrigEnaCarry();
00249         enaI = config()->TsmInOutEnaCarry();
00250         enaC = config()->TsmCorrEnaCarry() ;
00251       }
00252       // Bits set to 0 give higher priority:
00253       if(isHtrig()&&enaH&&posH>0)_dataword.unset(posH);
00254       if(isInner()&&enaI&&posI>0)_dataword.unset(posI);
00255       if(isCorr() &&enaC&&posC>0)_dataword.unset(posC);
00256             
00257     }
00258   }
00259 
00260 
00261 }
00262 void 
00263 DTTSCand::print() const {
00264   std::cout << " First=" << isFirst();
00265   std::cout << " HTRIG=" << isHtrig();
00266   std::cout << " Inner=" << isInner();
00267   std::cout << " Corr="  << isCorr();
00268   std::cout << " Kpv="   << tracoTr()->pvK();
00269   std::cout << " dataword=";
00270   _dataword.print();
00271   std::cout << std::endl;
00272 }
00273