Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:50

0001 //-------------------------------------------------
0002 //
0003 //   Class: DTTSCand.cpp
0004 //
0005 //   Description: A Trigger Server Candidate
0006 //
0007 //
0008 //   Author List:
0009 //   C. Grandi
0010 //   Modifications:
0011 //   S. Marcellini, D. Bonacorsi
0012 //   04/01/2007 : C. Battilana local config update
0013 //
0014 //--------------------------------------------------
0015 
0016 //-----------------------
0017 // This Class's Header --
0018 //-----------------------
0019 #include "L1Trigger/DTTriggerServerPhi/interface/DTTSCand.h"
0020 
0021 //-------------------------------
0022 // Collaborating Class Headers --
0023 //-------------------------------
0024 #include "L1TriggerConfig/DTTPGConfig/interface/DTConfigTSPhi.h"
0025 
0026 //---------------
0027 // C++ Headers --
0028 //---------------
0029 #include <iostream>
0030 
0031 //----------------
0032 
0033 // Constructors --
0034 //----------------
0035 
0036 DTTSCand::DTTSCand(DTTSS *tss, const DTTracoTrigData *tctrig, int ifs, int pos)
0037     : _tss(tss), _tctrig(tctrig), _tcPos(pos), _isCarry(0) {
0038   _dataword.one();  // reset dataword to 0x1ff
0039 
0040   // SM sector collector Set bit 14 instead of 8, for 1st/2nd track to allow
0041   // extra space
0042   //      if(ifs==1)_dataword.unset(8); // set bit 8 (0=first, 1=second tracks)
0043   if (ifs == 1)
0044     _dataword.unset(14);  // set bit 14 (0=first, 1=second tracks)
0045 }
0046 
0047 DTTSCand::DTTSCand(const DTTSCand &tscand)
0048     : _tss(tscand._tss), _tctrig(tscand._tctrig), _tcPos(tscand._tcPos), _isCarry(tscand._isCarry) {}
0049 
0050 DTTSCand::DTTSCand() {}
0051 
0052 //--------------
0053 // Destructor --
0054 //--------------
0055 DTTSCand::~DTTSCand() {}
0056 
0057 //--------------
0058 // Operations --
0059 //--------------
0060 
0061 DTTSCand &DTTSCand::operator=(const DTTSCand &tscand) {
0062   if (this != &tscand) {
0063     _tss = tscand._tss;
0064     _tctrig = tscand._tctrig;
0065     _tcPos = tscand._tcPos;
0066     _isCarry = tscand._isCarry;
0067   }
0068   return *this;
0069 }
0070 
0071 void DTTSCand::clear() {
0072   _tctrig = nullptr;
0073   _dataword.one();
0074 
0075   _isCarry = 0;
0076 }
0077 
0078 void DTTSCand::setBitsTss() {
0079   // first/second track already set. Set other 3 bits
0080   int itk = _dataword.element(14);  // first tracks 0, second tracks 1
0081 
0082   clearBits();
0083   if (_tctrig->pvK() > 32 || _tctrig->pvK() < 0) {  // Check K within 5 bits range
0084     std::cout << "DTTSCand::setBitsTss() pvK outside valid range: " << _tctrig->pvK();
0085     std::cout << " deltaPsiR set to 31" << std::endl;
0086   } else {
0087     // assign preview in dataword (common to any other assignment)
0088     _dataword.assign(0, 5, _tctrig->pvK());
0089     //  _dataword.assign(0,5,0);
0090 
0091     int posH = -1;
0092     int posI = -1;
0093     int posC = -1;
0094     switch (config()->TssMasking(itk)) {
0095       case 123:  // H/L, In/Out, Corr/NotC
0096         posH = 7;
0097         posI = 6;
0098         posC = 5;
0099         break;
0100       case 132:  // H/L, Corr/NotC, In/Out
0101         posH = 7;
0102         posI = 5;
0103         posC = 6;
0104         break;
0105       case 213:  // In/Out, H/L, Corr/NotC
0106         posH = 6;
0107         posI = 7;
0108         posC = 5;
0109         break;
0110       case 231:  // In/Out, Corr/NotC, H/L
0111         posH = 5;
0112         posI = 7;
0113         posC = 6;
0114         break;
0115       case 312:  // Corr/NotC, H/L, In/Out
0116         posH = 6;
0117         posI = 5;
0118         posC = 7;
0119         break;
0120       case 321:  // Corr/NotC, In/Out, H/L
0121         posH = 5;
0122         posI = 6;
0123         posC = 7;
0124         break;
0125       default:
0126         std::cout << "DTTSCand::DTTSCand(): masking not correct: ";
0127         std::cout << config()->TssMasking(itk);
0128         std::cout << " All bits set to 1" << std::endl;
0129     }
0130     // Masking:
0131     bool enaH = config()->TssHtrigEna(itk);
0132     bool enaI = config()->TssInOutEna(itk);
0133     bool enaC = config()->TssCorrEna(itk);
0134     if (isCarry()) {
0135       // Special setting for carry
0136       enaH = config()->TssHtrigEnaCarry();
0137       enaI = config()->TssInOutEnaCarry();
0138       enaC = config()->TssCorrEnaCarry();
0139     }
0140     // Bits set to 0 give higher priority:
0141     if (isHtrig() && enaH && posH > 0)
0142       _dataword.unset(posH);
0143     if (isInner() && enaI && posI > 0)
0144       _dataword.unset(posI);
0145     if (isCorr() && enaC && posC > 0)
0146       _dataword.unset(posC);
0147   }
0148 }
0149 
0150 void DTTSCand::setBitsBkmod() {
0151   // first/second track already set. Set other 4 bits (1 for null, 3 for a2, a1,
0152   // a0)
0153   clearBitsBkmod();
0154   //  std::cout << " clearbits in TSM bk mode " << _dataword.print() <<
0155   //  std::endl;
0156 
0157   int a2 = 6;
0158   int a1 = 5;
0159   int a0 = 4;
0160   //
0161   // std::cout << " _tctrig->qdec(): " << _tctrig->qdec() << std::endl;
0162   if (_tctrig->qdec() == 6) {
0163     _dataword.unset(a2);
0164     _dataword.unset(a1);
0165     _dataword.unset(a0);
0166   }  // 1-000
0167   if (_tctrig->qdec() == 5) {
0168     _dataword.unset(a2);
0169     _dataword.unset(a1);
0170   }  // 1-001
0171   if (_tctrig->qdec() == 4) {
0172     _dataword.unset(a2);
0173     _dataword.unset(a0);
0174   }  // 1-010
0175   if (_tctrig->qdec() == 3) {
0176     _dataword.unset(a1);
0177   }  // 1-101
0178   if (_tctrig->qdec() == 2) {
0179     _dataword.unset(a1);
0180     _dataword.unset(a0);
0181   }  // 1-100
0182 
0183   if (_tctrig->qdec() == 0) {
0184     _dataword.unset(a0);
0185   }  // 1-110
0186 
0187   //    std::cout << " set Bits TSM back up " << _dataword.print() << std::endl;
0188 }
0189 
0190 void DTTSCand::setBitsTsm() {
0191   // first/second track already set. Set other 3 bits
0192   int itk = _dataword.element(14);  // first tracks 0, second tracks 1
0193 
0194   clearBits();
0195 
0196   if (_tctrig->pvK() > 31 || _tctrig->pvK() < 0) {  // Check K within 5 bits range
0197     std::cout << "DTTSCand::setBitsTsm pvK outside valid range: " << _tctrig->pvK();
0198     std::cout << " deltaPsiR set to 31" << std::endl;
0199   } else {
0200     // SM double TSM
0201     // assign preview in dataword (common to any other assignment)
0202     _dataword.assign(0, 5, _tctrig->pvK());
0203     //  _dataword.assign(0,5,0);
0204     //
0205 
0206     int posH = -1;
0207     int posI = -1;
0208     int posC = -1;
0209     switch (config()->TsmMasking(itk)) {
0210       case 123:  // H/L, In/Out, Corr/NotC
0211         posH = 7;
0212         posI = 6;
0213         posC = 5;
0214         break;
0215       case 132:  // H/L, Corr/NotC, In/Out
0216         posH = 7;
0217         posI = 5;
0218         posC = 6;
0219         break;
0220       case 213:  // In/Out, H/L, Corr/NotC
0221         posH = 6;
0222         posI = 7;
0223         posC = 5;
0224         break;
0225       case 231:  // In/Out, Corr/NotC, H/L
0226         posH = 5;
0227         posI = 7;
0228         posC = 6;
0229         break;
0230       case 312:  // Corr/NotC, H/L, In/Out
0231         posH = 6;
0232         posI = 5;
0233         posC = 7;
0234         break;
0235       case 321:  // Corr/NotC, In/Out, H/L
0236         posH = 5;
0237         posI = 6;
0238         posC = 7;
0239         break;
0240       default:
0241         std::cout << "DTTSCand::DTTSCand(): masking not correct: ";
0242         std::cout << config()->TssMasking(itk);
0243         std::cout << " All bits set to 1" << std::endl;
0244 
0245         // Masking:
0246         bool enaH = config()->TsmHtrigEna(itk);
0247         bool enaI = config()->TsmInOutEna(itk);
0248         bool enaC = config()->TsmCorrEna(itk);
0249         if (isCarry()) {
0250           // Special setting for carry
0251           enaH = config()->TsmHtrigEnaCarry();
0252           enaI = config()->TsmInOutEnaCarry();
0253           enaC = config()->TsmCorrEnaCarry();
0254         }
0255         // Bits set to 0 give higher priority:
0256         if (isHtrig() && enaH && posH > 0)
0257           _dataword.unset(posH);
0258         if (isInner() && enaI && posI > 0)
0259           _dataword.unset(posI);
0260         if (isCorr() && enaC && posC > 0)
0261           _dataword.unset(posC);
0262     }
0263   }
0264 }
0265 void DTTSCand::print() const {
0266   std::cout << " First=" << isFirst();
0267   std::cout << " HTRIG=" << isHtrig();
0268   std::cout << " Inner=" << isInner();
0269   std::cout << " Corr=" << isCorr();
0270   std::cout << " Kpv=" << tracoTr()->pvK();
0271   std::cout << " dataword=";
0272   _dataword.print();
0273   std::cout << std::endl;
0274 }