Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-02 03:45:47

0001 //-------------------------------------------------
0002 //
0003 //   Class: L1MuDTAddressArray
0004 //
0005 //   Description: Array of relative Addresses
0006 //
0007 //
0008 //
0009 //   Author :
0010 //   N. Neumeister            CERN EP
0011 //
0012 //--------------------------------------------------
0013 
0014 //-----------------------
0015 // This Class's Header --
0016 //-----------------------
0017 
0018 #include "L1Trigger/DTTrackFinder/interface/L1MuDTAddressArray.h"
0019 
0020 //---------------
0021 // C++ Headers --
0022 //---------------
0023 
0024 #include <iostream>
0025 #include <iomanip>
0026 #include <vector>
0027 #include <cassert>
0028 
0029 //-------------------------------
0030 // Collaborating Class Headers --
0031 //-------------------------------
0032 
0033 using namespace std;
0034 
0035 // --------------------------------
0036 //       class L1MuDTAddressArray
0037 //---------------------------------
0038 
0039 //----------------
0040 // Constructors --
0041 //----------------
0042 
0043 L1MuDTAddressArray::L1MuDTAddressArray() { reset(); }
0044 
0045 L1MuDTAddressArray::L1MuDTAddressArray(const L1MuDTAddressArray& addarray) {
0046   for (int stat = 1; stat <= 4; stat++) {
0047     m_station[stat - 1] = addarray.m_station[stat - 1];
0048   }
0049 }
0050 
0051 //--------------
0052 // Destructor --
0053 //--------------
0054 
0055 L1MuDTAddressArray::~L1MuDTAddressArray() {}
0056 
0057 //--------------
0058 // Operations --
0059 //--------------
0060 
0061 //
0062 // assignment operator
0063 //
0064 L1MuDTAddressArray& L1MuDTAddressArray::operator=(const L1MuDTAddressArray& addarray) {
0065   if (this != &addarray) {
0066     for (int stat = 1; stat <= 4; stat++) {
0067       m_station[stat - 1] = addarray.m_station[stat - 1];
0068     }
0069   }
0070   return *this;
0071 }
0072 
0073 //
0074 //
0075 //
0076 bool L1MuDTAddressArray::operator==(const L1MuDTAddressArray& addarray) const {
0077   for (int stat = 1; stat <= 4; stat++) {
0078     if (m_station[stat - 1] != addarray.m_station[stat - 1])
0079       return false;
0080   }
0081 
0082   return true;
0083 }
0084 
0085 //
0086 //
0087 //
0088 bool L1MuDTAddressArray::operator!=(const L1MuDTAddressArray& addarray) const {
0089   for (int stat = 1; stat <= 4; stat++) {
0090     if (m_station[stat - 1] != addarray.m_station[stat - 1])
0091       return true;
0092   }
0093 
0094   return false;
0095 }
0096 
0097 //
0098 // reset AddressArray
0099 //
0100 void L1MuDTAddressArray::reset() {
0101   for (int stat = 1; stat <= 4; stat++) {
0102     m_station[stat - 1] = 15;
0103   }
0104 }
0105 
0106 //
0107 // set Address of a given station
0108 //
0109 void L1MuDTAddressArray::setStation(int stat, int adr) {
0110   //  assert( stat >  0 && stat <= 4 );
0111   //  assert( adr  >= 0 && adr  <= 15       );
0112   m_station[stat - 1] = adr;
0113 }
0114 
0115 //
0116 // set Addresses of all four stations
0117 //
0118 void L1MuDTAddressArray::setStations(int adr1, int adr2, int adr3, int adr4) {
0119   setStation(1, adr1);
0120   setStation(2, adr2);
0121   setStation(3, adr3);
0122   setStation(4, adr4);
0123 }
0124 
0125 //
0126 // get track address code (for eta track finder)
0127 //
0128 int L1MuDTAddressArray::trackAddressCode() const {
0129   int code = -1;
0130 
0131   int s1 = m_station[0];
0132   s1 = (s1 == 15) ? 0 : ((s1 / 2) % 2) + 1;
0133   int s2 = m_station[1];
0134   s2 = (s2 == 15) ? 0 : ((s2 / 2) % 2) + 1;
0135   int s3 = m_station[2];
0136   s3 = (s3 == 15) ? 0 : ((s3 / 2) % 2) + 1;
0137   int s4 = m_station[3];
0138   s4 = (s4 == 15) ? 0 : ((s4 / 2) % 2) + 1;
0139 
0140   //  0 ... empty track segment
0141   //  1 ... same wheel
0142   //  2 ... next wheel
0143 
0144   if (s1 == 0 && s2 == 0 && s3 == 0 && s4 == 0)
0145     code = 0;
0146   if (s1 == 0 && s2 == 0 && s3 == 2 && s4 == 1)
0147     code = 0;
0148   if (s1 == 0 && s2 == 0 && s3 == 2 && s4 == 2)
0149     code = 0;
0150   if (s1 == 0 && s2 == 2 && s3 == 0 && s4 == 1)
0151     code = 0;
0152   if (s1 == 0 && s2 == 2 && s3 == 0 && s4 == 2)
0153     code = 0;
0154   if (s1 == 0 && s2 == 2 && s3 == 1 && s4 == 0)
0155     code = 0;
0156   if (s1 == 0 && s2 == 2 && s3 == 2 && s4 == 0)
0157     code = 0;
0158   if (s1 == 0 && s2 == 1 && s3 == 2 && s4 == 1)
0159     code = 0;
0160   if (s1 == 0 && s2 == 2 && s3 == 1 && s4 == 1)
0161     code = 0;
0162   if (s1 == 0 && s2 == 2 && s3 == 1 && s4 == 2)
0163     code = 0;
0164   if (s1 == 0 && s2 == 2 && s3 == 2 && s4 == 1)
0165     code = 0;
0166   if (s1 == 0 && s2 == 2 && s3 == 2 && s4 == 2)
0167     code = 0;
0168   if (s1 == 1 && s2 == 0 && s3 == 2 && s4 == 1)
0169     code = 0;
0170   if (s1 == 1 && s2 == 2 && s3 == 0 && s4 == 1)
0171     code = 0;
0172   if (s1 == 1 && s2 == 2 && s3 == 1 && s4 == 0)
0173     code = 0;
0174   if (s1 == 1 && s2 == 1 && s3 == 2 && s4 == 1)
0175     code = 0;
0176   if (s1 == 1 && s2 == 2 && s3 == 1 && s4 == 1)
0177     code = 0;
0178   if (s1 == 1 && s2 == 2 && s3 == 1 && s4 == 2)
0179     code = 0;
0180   if (s1 == 1 && s2 == 2 && s3 == 2 && s4 == 1)
0181     code = 0;
0182   if (s1 == 0 && s2 == 0 && s3 == 1 && s4 == 1)
0183     code = 1;
0184   if (s1 == 0 && s2 == 0 && s3 == 1 && s4 == 2)
0185     code = 2;
0186   if (s1 == 0 && s2 == 1 && s3 == 0 && s4 == 1)
0187     code = 3;
0188   if (s1 == 0 && s2 == 1 && s3 == 0 && s4 == 2)
0189     code = 4;
0190   if (s1 == 0 && s2 == 1 && s3 == 1 && s4 == 0)
0191     code = 5;
0192   if (s1 == 0 && s2 == 1 && s3 == 1 && s4 == 1)
0193     code = 6;
0194   if (s1 == 0 && s2 == 1 && s3 == 1 && s4 == 2)
0195     code = 7;
0196   if (s1 == 0 && s2 == 1 && s3 == 2 && s4 == 0)
0197     code = 8;
0198   if (s1 == 0 && s2 == 1 && s3 == 2 && s4 == 2)
0199     code = 8;
0200   if (s1 == 1 && s2 == 0 && s3 == 0 && s4 == 1)
0201     code = 9;
0202   if (s1 == 1 && s2 == 0 && s3 == 0 && s4 == 2)
0203     code = 10;
0204   if (s1 == 1 && s2 == 0 && s3 == 1 && s4 == 0)
0205     code = 11;
0206   if (s1 == 1 && s2 == 0 && s3 == 1 && s4 == 1)
0207     code = 12;
0208   if (s1 == 1 && s2 == 0 && s3 == 1 && s4 == 2)
0209     code = 13;
0210   if (s1 == 1 && s2 == 0 && s3 == 2 && s4 == 0)
0211     code = 14;
0212   if (s1 == 1 && s2 == 0 && s3 == 2 && s4 == 2)
0213     code = 14;
0214   if (s1 == 1 && s2 == 1 && s3 == 0 && s4 == 0)
0215     code = 15;
0216   if (s1 == 1 && s2 == 1 && s3 == 0 && s4 == 1)
0217     code = 16;
0218   if (s1 == 1 && s2 == 1 && s3 == 0 && s4 == 2)
0219     code = 17;
0220   if (s1 == 1 && s2 == 1 && s3 == 1 && s4 == 0)
0221     code = 18;
0222   if (s1 == 1 && s2 == 1 && s3 == 1 && s4 == 1)
0223     code = 19;
0224   if (s1 == 1 && s2 == 1 && s3 == 1 && s4 == 2)
0225     code = 20;
0226   if (s1 == 1 && s2 == 1 && s3 == 2 && s4 == 0)
0227     code = 21;
0228   if (s1 == 1 && s2 == 1 && s3 == 2 && s4 == 2)
0229     code = 21;
0230   if (s1 == 1 && s2 == 2 && s3 == 0 && s4 == 0)
0231     code = 22;
0232   if (s1 == 1 && s2 == 2 && s3 == 0 && s4 == 2)
0233     code = 22;
0234   if (s1 == 1 && s2 == 2 && s3 == 2 && s4 == 0)
0235     code = 22;
0236   if (s1 == 1 && s2 == 2 && s3 == 2 && s4 == 2)
0237     code = 22;
0238 
0239   return code;
0240 }
0241 
0242 //
0243 // get converted Addresses
0244 //
0245 L1MuDTAddressArray L1MuDTAddressArray::converted() const {
0246   unsigned short int adr1 = L1MuDTAddressArray::convert(m_station[0]);
0247   unsigned short int adr2 = L1MuDTAddressArray::convert(m_station[1]);
0248   unsigned short int adr3 = L1MuDTAddressArray::convert(m_station[2]);
0249   unsigned short int adr4 = L1MuDTAddressArray::convert(m_station[3]);
0250 
0251   L1MuDTAddressArray newaddressarray;
0252   newaddressarray.setStations(adr1, adr2, adr3, adr4);
0253 
0254   return newaddressarray;
0255 }
0256 
0257 //
0258 //
0259 //
0260 ostream& operator<<(ostream& s, const L1MuDTAddressArray& adrarr) {
0261   s.setf(ios::right, ios::adjustfield);
0262   for (int stat = 1; stat <= 4; stat++) {
0263     s << "stat " << stat << ": " << setw(2) << adrarr.station(stat) << "  ";
0264   }
0265 
0266   return s;
0267 }
0268 
0269 //
0270 // convert address to corresponding VHDL address
0271 //
0272 unsigned short int L1MuDTAddressArray::convert(unsigned short int adr) {
0273   unsigned short int newaddress = 15;
0274 
0275   switch (adr) {
0276     case 0: {
0277       newaddress = 8;
0278       break;
0279     }
0280     case 1: {
0281       newaddress = 9;
0282       break;
0283     }
0284     case 2: {
0285       newaddress = 0;
0286       break;
0287     }
0288     case 3: {
0289       newaddress = 1;
0290       break;
0291     }
0292     case 4: {
0293       newaddress = 10;
0294       break;
0295     }
0296     case 5: {
0297       newaddress = 11;
0298       break;
0299     }
0300     case 6: {
0301       newaddress = 2;
0302       break;
0303     }
0304     case 7: {
0305       newaddress = 3;
0306       break;
0307     }
0308     case 8: {
0309       newaddress = 12;
0310       break;
0311     }
0312     case 9: {
0313       newaddress = 13;
0314       break;
0315     }
0316     case 10: {
0317       newaddress = 4;
0318       break;
0319     }
0320     case 11: {
0321       newaddress = 5;
0322       break;
0323     }
0324     case 15: {
0325       newaddress = 15;
0326       break;
0327     }
0328     default: {
0329       newaddress = 15;
0330       break;
0331     }
0332   }
0333 
0334   return newaddress;
0335 }
0336 
0337 //
0338 // is it a same wheel address?
0339 //
0340 bool L1MuDTAddressArray::sameWheel(unsigned short int adr) {
0341   //  if ( adr > 15 ) cerr << "L1MuDTAddressArray : Error wrong address " << adr << endl;
0342   return ((adr / 2) % 2 == 0);
0343 }
0344 
0345 //
0346 // is it a next wheel address?
0347 //
0348 bool L1MuDTAddressArray::nextWheel(unsigned short int adr) {
0349   //  if ( adr > 15 ) cerr << "L1MuDTAddressArray : Error wrong address " << adr << endl;
0350   return ((adr / 2) % 2 == 1);
0351 }