CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/L1Trigger/DTTrackFinder/src/L1MuDTTrackAssembler.cc

Go to the documentation of this file.
00001 //-------------------------------------------------
00002 //
00003 //   Class: L1MuDTTrackAssembler
00004 //
00005 //   Description: Track Assembler
00006 //
00007 //
00008 //   $Date: 2008/02/18 17:38:04 $
00009 //   $Revision: 1.3 $
00010 //
00011 //   Author :
00012 //   N. Neumeister            CERN EP
00013 //
00014 //--------------------------------------------------
00015 
00016 //-----------------------
00017 // This Class's Header --
00018 //-----------------------
00019 
00020 #include "L1Trigger/DTTrackFinder/src/L1MuDTTrackAssembler.h"
00021 
00022 //---------------
00023 // C++ Headers --
00024 //---------------
00025 
00026 #include <iostream>
00027 #include <string>
00028 
00029 //-------------------------------
00030 // Collaborating Class Headers --
00031 //-------------------------------
00032 
00033 #include "L1Trigger/DTTrackFinder/src/L1MuDTTFConfig.h"
00034 #include "L1Trigger/DTTrackFinder/src/L1MuDTSectorProcessor.h"
00035 #include "L1Trigger/DTTrackFinder/src/L1MuDTExtrapolationUnit.h"
00036 
00037 using namespace std;
00038 
00039 // --------------------------------
00040 //       class L1MuDTTrackAssembler
00041 //---------------------------------
00042 
00043 //----------------
00044 // Constructors --
00045 //----------------
00046 
00047 L1MuDTTrackAssembler::L1MuDTTrackAssembler(const L1MuDTSectorProcessor& sp) : 
00048          m_sp(sp) {
00049 
00050 
00051 }
00052 
00053 
00054 //--------------
00055 // Destructor --
00056 //--------------
00057 
00058 L1MuDTTrackAssembler::~L1MuDTTrackAssembler() {
00059   
00060 }
00061 
00062 
00063 //--------------
00064 // Operations --
00065 //--------------
00066 
00067 //
00068 // run Track Assembler
00069 //
00070 void L1MuDTTrackAssembler::run() {
00071 
00072   // get the 18 bitmap tables from the Quality Sorter Unit
00073   
00074   bitset<12> b_adr12_8 = m_sp.EU()->getQSTable(EX12, 0);
00075   bitset<12> b_adr12_9 = m_sp.EU()->getQSTable(EX12, 1);
00076   bitset<12> b_adr13_8 = m_sp.EU()->getQSTable(EX13, 0); 
00077   bitset<12> b_adr13_9 = m_sp.EU()->getQSTable(EX13, 1);
00078   bitset<12> b_adr14_8 = m_sp.EU()->getQSTable(EX14, 0);
00079   bitset<12> b_adr14_9 = m_sp.EU()->getQSTable(EX14, 1);
00080   bitset<12> b_adr23_8 = m_sp.EU()->getQSTable(EX23, 0);
00081   bitset<12> b_adr23_9 = m_sp.EU()->getQSTable(EX23, 1);
00082   bitset<12> b_adr23_0 = m_sp.EU()->getQSTable(EX23, 2);
00083   bitset<12> b_adr23_1 = m_sp.EU()->getQSTable(EX23, 3);
00084   bitset<12> b_adr24_8 = m_sp.EU()->getQSTable(EX24, 0);
00085   bitset<12> b_adr24_9 = m_sp.EU()->getQSTable(EX24, 1);
00086   bitset<12> b_adr24_0 = m_sp.EU()->getQSTable(EX24, 2);
00087   bitset<12> b_adr24_1 = m_sp.EU()->getQSTable(EX24, 3);
00088   bitset<12> b_adr34_8 = m_sp.EU()->getQSTable(EX34, 0);
00089   bitset<12> b_adr34_9 = m_sp.EU()->getQSTable(EX34, 1);
00090   bitset<12> b_adr34_0 = m_sp.EU()->getQSTable(EX34, 2);
00091   bitset<12> b_adr34_1 = m_sp.EU()->getQSTable(EX34, 3);
00092 
00093     
00094   // Last segment node building 
00095  
00096   bitset<12> n_1234_888 = ( b_adr14_8 & b_adr24_8 & b_adr34_8 );
00097   bitset<12> n_1234_889 = ( b_adr14_8 & b_adr24_8 & b_adr34_9 );
00098   bitset<12> n_1234_880 = ( b_adr14_8 & b_adr24_8 & b_adr34_0 );
00099   bitset<12> n_1234_881 = ( b_adr14_8 & b_adr24_8 & b_adr34_1 );
00100   bitset<12> n_1234_898 = ( b_adr14_8 & b_adr24_9 & b_adr34_8 );
00101   bitset<12> n_1234_899 = ( b_adr14_8 & b_adr24_9 & b_adr34_9 );
00102   bitset<12> n_1234_890 = ( b_adr14_8 & b_adr24_9 & b_adr34_0 );
00103   bitset<12> n_1234_891 = ( b_adr14_8 & b_adr24_9 & b_adr34_1 );
00104   bitset<12> n_1234_800 = ( b_adr14_8 & b_adr24_0 & b_adr34_0 );
00105   bitset<12> n_1234_801 = ( b_adr14_8 & b_adr24_0 & b_adr34_1 );
00106   bitset<12> n_1234_810 = ( b_adr14_8 & b_adr24_1 & b_adr34_0 );
00107   bitset<12> n_1234_811 = ( b_adr14_8 & b_adr24_1 & b_adr34_1 );
00108 
00109   bitset<12> n_1234_988 = ( b_adr14_9 & b_adr24_8 & b_adr34_8 );
00110   bitset<12> n_1234_989 = ( b_adr14_9 & b_adr24_8 & b_adr34_9 );
00111   bitset<12> n_1234_980 = ( b_adr14_9 & b_adr24_8 & b_adr34_0 );
00112   bitset<12> n_1234_981 = ( b_adr14_9 & b_adr24_8 & b_adr34_1 );
00113   bitset<12> n_1234_998 = ( b_adr14_9 & b_adr24_9 & b_adr34_8 );
00114   bitset<12> n_1234_999 = ( b_adr14_9 & b_adr24_9 & b_adr34_9 );
00115   bitset<12> n_1234_990 = ( b_adr14_9 & b_adr24_9 & b_adr34_0 );
00116   bitset<12> n_1234_991 = ( b_adr14_9 & b_adr24_9 & b_adr34_1 );
00117   bitset<12> n_1234_900 = ( b_adr14_9 & b_adr24_0 & b_adr34_0 );
00118   bitset<12> n_1234_901 = ( b_adr14_9 & b_adr24_0 & b_adr34_1 );
00119   bitset<12> n_1234_910 = ( b_adr14_9 & b_adr24_1 & b_adr34_0 );
00120   bitset<12> n_1234_911 = ( b_adr14_9 & b_adr24_1 & b_adr34_1 );
00121 
00122   bitset<12> n_123_88 = ( b_adr13_8 & b_adr23_8 );
00123   bitset<12> n_123_89 = ( b_adr13_8 & b_adr23_9 );
00124   bitset<12> n_123_80 = ( b_adr13_8 & b_adr23_0 );
00125   bitset<12> n_123_81 = ( b_adr13_8 & b_adr23_1 );
00126 
00127   bitset<12> n_123_98 = ( b_adr13_9 & b_adr23_8 );
00128   bitset<12> n_123_99 = ( b_adr13_9 & b_adr23_9 );
00129   bitset<12> n_123_90 = ( b_adr13_9 & b_adr23_0 );
00130   bitset<12> n_123_91 = ( b_adr13_9 & b_adr23_1 );
00131 
00132   bitset<12> n_124_88 = ( b_adr14_8 & b_adr24_8 );
00133   bitset<12> n_124_89 = ( b_adr14_8 & b_adr24_9 );
00134   bitset<12> n_124_80 = ( b_adr14_8 & b_adr24_0 );
00135   bitset<12> n_124_81 = ( b_adr14_8 & b_adr24_1 );
00136 
00137   bitset<12> n_124_98 = ( b_adr14_9 & b_adr24_8 );
00138   bitset<12> n_124_99 = ( b_adr14_9 & b_adr24_9 );
00139   bitset<12> n_124_90 = ( b_adr14_9 & b_adr24_0 );
00140   bitset<12> n_124_91 = ( b_adr14_9 & b_adr24_1 );
00141 
00142   bitset<12> n_134_88 = ( b_adr14_8 & b_adr34_8 );
00143   bitset<12> n_134_89 = ( b_adr14_8 & b_adr34_9 );
00144   bitset<12> n_134_80 = ( b_adr14_8 & b_adr34_0 );
00145   bitset<12> n_134_81 = ( b_adr14_8 & b_adr34_1 );
00146 
00147   bitset<12> n_134_98 = ( b_adr14_9 & b_adr34_8 );
00148   bitset<12> n_134_99 = ( b_adr14_9 & b_adr34_9 );
00149   bitset<12> n_134_90 = ( b_adr14_9 & b_adr34_0 );
00150   bitset<12> n_134_91 = ( b_adr14_9 & b_adr34_1 );
00151 
00152   bitset<12> n_234_88 = ( b_adr24_8 & b_adr34_8 );
00153   bitset<12> n_234_89 = ( b_adr24_8 & b_adr34_9 );
00154   bitset<12> n_234_80 = ( b_adr24_8 & b_adr34_0 );
00155   bitset<12> n_234_81 = ( b_adr24_8 & b_adr34_1 );
00156 
00157   bitset<12> n_234_98 = ( b_adr24_9 & b_adr34_8 );
00158   bitset<12> n_234_99 = ( b_adr24_9 & b_adr34_9 );
00159   bitset<12> n_234_90 = ( b_adr24_9 & b_adr34_0 );
00160   bitset<12> n_234_91 = ( b_adr24_9 & b_adr34_1 );
00161 
00162   bitset<12> n_12_8 = b_adr12_8;
00163   bitset<12> n_12_9 = b_adr12_9;
00164 
00165   bitset<12> n_13_8 = b_adr13_8;
00166   bitset<12> n_13_9 = b_adr13_9;
00167 
00168   bitset<12> n_14_8 = b_adr14_8;
00169   bitset<12> n_14_9 = b_adr14_9;
00170 
00171   bitset<12> n_23_8 = b_adr23_8;
00172   bitset<12> n_23_9 = b_adr23_9;
00173 
00174   bitset<12> n_24_8 = b_adr24_8;
00175   bitset<12> n_24_9 = b_adr24_9;
00176 
00177   bitset<12> n_34_8 = b_adr34_8;
00178   bitset<12> n_34_9 = b_adr34_9;
00179 
00180   // Last address encoders
00181 
00182   m_theLastAddress[67] = addressEncoder12(n_1234_888);
00183   m_theLastAddress[66] = addressEncoder12(n_1234_889);
00184   m_theLastAddress[65] = addressEncoder12(n_1234_880);
00185   m_theLastAddress[64] = addressEncoder12(n_1234_881);
00186 
00187   m_theLastAddress[63] = addressEncoder12(n_1234_898);
00188   m_theLastAddress[62] = addressEncoder12(n_1234_899);
00189   m_theLastAddress[61] = addressEncoder12(n_1234_890);
00190   m_theLastAddress[60] = addressEncoder12(n_1234_891); 
00191 
00192   m_theLastAddress[59] = addressEncoder12(n_1234_800);
00193   m_theLastAddress[58] = addressEncoder12(n_1234_801);
00194   m_theLastAddress[57] = addressEncoder12(n_1234_810);
00195   m_theLastAddress[56] = addressEncoder12(n_1234_811);
00196 
00197   m_theLastAddress[55] = addressEncoder12(n_1234_988);
00198   m_theLastAddress[54] = addressEncoder12(n_1234_989);
00199   m_theLastAddress[53] = addressEncoder12(n_1234_980);
00200   m_theLastAddress[52] = addressEncoder12(n_1234_981);
00201 
00202   m_theLastAddress[51] = addressEncoder12(n_1234_998);
00203   m_theLastAddress[50] = addressEncoder12(n_1234_999);
00204   m_theLastAddress[49] = addressEncoder12(n_1234_990);
00205   m_theLastAddress[48] = addressEncoder12(n_1234_991);
00206 
00207   m_theLastAddress[47] = addressEncoder12(n_1234_900);
00208   m_theLastAddress[46] = addressEncoder12(n_1234_901);
00209   m_theLastAddress[45] = addressEncoder12(n_1234_910);
00210   m_theLastAddress[44] = addressEncoder12(n_1234_911);
00211 
00212   m_theLastAddress[43] = addressEncoder12(n_123_88);  
00213   m_theLastAddress[42] = addressEncoder12(n_123_89);
00214   m_theLastAddress[41] = addressEncoder12(n_123_80);
00215   m_theLastAddress[40] = addressEncoder12(n_123_81);
00216 
00217   m_theLastAddress[39] = addressEncoder12(n_123_98);
00218   m_theLastAddress[38] = addressEncoder12(n_123_99);
00219   m_theLastAddress[37] = addressEncoder12(n_123_90);
00220   m_theLastAddress[36] = addressEncoder12(n_123_91);
00221 
00222   m_theLastAddress[35] = addressEncoder12(n_124_88);
00223   m_theLastAddress[34] = addressEncoder12(n_124_89);
00224   m_theLastAddress[33] = addressEncoder12(n_124_80);
00225   m_theLastAddress[32] = addressEncoder12(n_124_81);
00226 
00227   m_theLastAddress[31] = addressEncoder12(n_124_98);
00228   m_theLastAddress[30] = addressEncoder12(n_124_99);
00229   m_theLastAddress[29] = addressEncoder12(n_124_90);
00230   m_theLastAddress[28] = addressEncoder12(n_124_91);
00231 
00232   m_theLastAddress[27] = addressEncoder12(n_134_88);
00233   m_theLastAddress[26] = addressEncoder12(n_134_89);
00234   m_theLastAddress[25] = addressEncoder12(n_134_80);
00235   m_theLastAddress[24] = addressEncoder12(n_134_81);
00236 
00237   m_theLastAddress[23] = addressEncoder12(n_134_98);
00238   m_theLastAddress[22] = addressEncoder12(n_134_99);
00239   m_theLastAddress[21] = addressEncoder12(n_134_90);
00240   m_theLastAddress[20] = addressEncoder12(n_134_91);
00241 
00242   m_theLastAddress[19] = addressEncoder12(n_234_88);
00243   m_theLastAddress[18] = addressEncoder12(n_234_89);
00244   m_theLastAddress[17] = addressEncoder12(n_234_80);
00245   m_theLastAddress[16] = addressEncoder12(n_234_81);
00246 
00247   m_theLastAddress[15] = addressEncoder12(n_234_98);
00248   m_theLastAddress[14] = addressEncoder12(n_234_99);
00249   m_theLastAddress[13] = addressEncoder12(n_234_90);
00250   m_theLastAddress[12] = addressEncoder12(n_234_91);
00251 
00252   m_theLastAddress[11] = addressEncoder12(n_12_8);
00253   m_theLastAddress[10] = addressEncoder12(n_12_9);
00254 
00255   m_theLastAddress[9]  = addressEncoder12(n_13_8);
00256   m_theLastAddress[8]  = addressEncoder12(n_13_9);
00257 
00258   m_theLastAddress[7]  = addressEncoder12(n_14_8);
00259   m_theLastAddress[6]  = addressEncoder12(n_14_9);
00260 
00261   m_theLastAddress[5]  = addressEncoder12(n_23_8);
00262   m_theLastAddress[4]  = addressEncoder12(n_23_9);
00263 
00264   m_theLastAddress[3]  = addressEncoder12(n_24_8);
00265   m_theLastAddress[2]  = addressEncoder12(n_24_9);
00266 
00267   m_theLastAddress[1]  = addressEncoder12(n_34_8);
00268   m_theLastAddress[0]  = addressEncoder12(n_34_9);
00269 
00270   m_theLastAddressI[11] = addressEncoder12s(n_12_8);
00271   m_theLastAddressI[10] = addressEncoder12s(n_12_9);
00272   m_theLastAddressI[9]  = addressEncoder12s(n_13_8);
00273   m_theLastAddressI[8]  = addressEncoder12s(n_13_9);
00274   m_theLastAddressI[7]  = addressEncoder12s(n_14_8);
00275   m_theLastAddressI[6]  = addressEncoder12s(n_14_9);
00276   m_theLastAddressI[5]  = addressEncoder12s(n_23_8);
00277   m_theLastAddressI[4]  = addressEncoder12s(n_23_9);
00278   m_theLastAddressI[3]  = addressEncoder12s(n_24_8);
00279   m_theLastAddressI[2]  = addressEncoder12s(n_24_9);
00280   m_theLastAddressI[1]  = addressEncoder12s(n_34_8);
00281   m_theLastAddressI[0]  = addressEncoder12s(n_34_9);
00282 
00283   // Main equations (68)
00284   
00285   m_thePriorityTable1[67] = ( b_adr12_8[0] & b_adr13_8[0] & b_adr23_8[0] & n_1234_888.any() );
00286   m_thePriorityTable1[66] = ( b_adr12_8[0] & b_adr13_8[1] & b_adr23_8[1] & n_1234_889.any() );
00287   m_thePriorityTable1[65] = ( b_adr12_8[0] & b_adr13_8[2] & b_adr23_8[2] & n_1234_880.any() );
00288   m_thePriorityTable1[64] = ( b_adr12_8[0] & b_adr13_8[3] & b_adr23_8[3] & n_1234_881.any() );
00289   m_thePriorityTable1[63] = ( b_adr12_8[1] & b_adr13_8[0] & b_adr23_9[0] & n_1234_898.any() );
00290   m_thePriorityTable1[62] = ( b_adr12_8[1] & b_adr13_8[1] & b_adr23_9[1] & n_1234_899.any() );
00291   m_thePriorityTable1[61] = ( b_adr12_8[1] & b_adr13_8[2] & b_adr23_9[2] & n_1234_890.any() );
00292   m_thePriorityTable1[60] = ( b_adr12_8[1] & b_adr13_8[3] & b_adr23_9[3] & n_1234_891.any() );
00293   m_thePriorityTable1[59] = ( b_adr12_8[2] & b_adr13_8[2] & b_adr23_0[2] & n_1234_800.any() );
00294   m_thePriorityTable1[58] = ( b_adr12_8[2] & b_adr13_8[3] & b_adr23_0[3] & n_1234_801.any() );
00295   m_thePriorityTable1[57] = ( b_adr12_8[3] & b_adr13_8[2] & b_adr23_1[2] & n_1234_810.any() );
00296   m_thePriorityTable1[56] = ( b_adr12_8[3] & b_adr13_8[3] & b_adr23_1[3] & n_1234_811.any() );
00297             
00298   m_thePriorityTable1[55] = ( b_adr12_9[0] & b_adr13_9[0] & b_adr23_8[0] & n_1234_988.any() );
00299   m_thePriorityTable1[54] = ( b_adr12_9[0] & b_adr13_9[1] & b_adr23_8[1] & n_1234_989.any() );
00300   m_thePriorityTable1[53] = ( b_adr12_9[0] & b_adr13_9[2] & b_adr23_8[2] & n_1234_980.any() );
00301   m_thePriorityTable1[52] = ( b_adr12_9[0] & b_adr13_9[3] & b_adr23_8[3] & n_1234_981.any() );
00302   m_thePriorityTable1[51] = ( b_adr12_9[1] & b_adr13_9[0] & b_adr23_9[0] & n_1234_998.any() );
00303   m_thePriorityTable1[50] = ( b_adr12_9[1] & b_adr13_9[1] & b_adr23_9[1] & n_1234_999.any() );
00304   m_thePriorityTable1[49] = ( b_adr12_9[1] & b_adr13_9[2] & b_adr23_9[2] & n_1234_990.any() );
00305   m_thePriorityTable1[48] = ( b_adr12_9[1] & b_adr13_9[3] & b_adr23_9[3] & n_1234_991.any() );
00306   m_thePriorityTable1[47] = ( b_adr12_9[2] & b_adr13_9[2] & b_adr23_0[2] & n_1234_900.any() );
00307   m_thePriorityTable1[46] = ( b_adr12_9[2] & b_adr13_9[3] & b_adr23_0[3] & n_1234_901.any() );
00308   m_thePriorityTable1[45] = ( b_adr12_9[3] & b_adr13_9[2] & b_adr23_1[2] & n_1234_910.any() );
00309   m_thePriorityTable1[44] = ( b_adr12_9[3] & b_adr13_9[3] & b_adr23_1[3] & n_1234_911.any() );
00310             
00311   m_thePriorityTable1[43] = ( b_adr12_8[0] & n_123_88.any() );
00312   m_thePriorityTable1[42] = ( b_adr12_8[1] & n_123_89.any() );
00313   m_thePriorityTable1[41] = ( b_adr12_8[2] & n_123_80.any() );
00314   m_thePriorityTable1[40] = ( b_adr12_8[3] & n_123_81.any() );
00315 
00316   m_thePriorityTable1[39] = ( b_adr12_9[0] & n_123_98.any() );
00317   m_thePriorityTable1[38] = ( b_adr12_9[1] & n_123_99.any() );
00318   m_thePriorityTable1[37] = ( b_adr12_9[2] & n_123_90.any() );
00319   m_thePriorityTable1[36] = ( b_adr12_9[3] & n_123_91.any() );
00320 
00321   m_thePriorityTable1[35] = ( b_adr12_8[0] & n_124_88.any() );
00322   m_thePriorityTable1[34] = ( b_adr12_8[1] & n_124_89.any() );
00323   m_thePriorityTable1[33] = ( b_adr12_8[2] & n_124_80.any() );
00324   m_thePriorityTable1[32] = ( b_adr12_8[3] & n_124_81.any() );
00325 
00326   m_thePriorityTable1[31] = ( b_adr12_9[0] & n_124_98.any() );
00327   m_thePriorityTable1[30] = ( b_adr12_9[1] & n_124_99.any() );
00328   m_thePriorityTable1[29] = ( b_adr12_9[2] & n_124_90.any() );
00329   m_thePriorityTable1[28] = ( b_adr12_9[3] & n_124_91.any() );
00330 
00331   m_thePriorityTable1[27] = ( b_adr13_8[0] & n_134_88.any() );
00332   m_thePriorityTable1[26] = ( b_adr13_8[1] & n_134_89.any() );
00333   m_thePriorityTable1[25] = ( b_adr13_8[2] & n_134_80.any() );
00334   m_thePriorityTable1[24] = ( b_adr13_8[3] & n_134_81.any() );
00335 
00336   m_thePriorityTable1[23] = ( b_adr13_9[0] & n_134_98.any() );
00337   m_thePriorityTable1[22] = ( b_adr13_9[1] & n_134_99.any() );
00338   m_thePriorityTable1[21] = ( b_adr13_9[2] & n_134_90.any() );
00339   m_thePriorityTable1[20] = ( b_adr13_9[3] & n_134_91.any() );
00340 
00341   m_thePriorityTable1[19] = ( b_adr23_8[0] & n_234_88.any() );
00342   m_thePriorityTable1[18] = ( b_adr23_8[1] & n_234_89.any() );
00343   m_thePriorityTable1[17] = ( b_adr23_8[2] & n_234_80.any() );
00344   m_thePriorityTable1[16] = ( b_adr23_8[3] & n_234_81.any() );
00345 
00346   m_thePriorityTable1[15] = ( b_adr23_9[0] & n_234_98.any() );
00347   m_thePriorityTable1[14] = ( b_adr23_9[1] & n_234_99.any() );
00348   m_thePriorityTable1[13] = ( b_adr23_9[2] & n_234_90.any() );
00349   m_thePriorityTable1[12] = ( b_adr23_9[3] & n_234_91.any() );
00350       
00351   m_thePriorityTable1[11] = n_12_8.any();
00352   m_thePriorityTable1[10] = n_12_9.any();
00353         
00354   m_thePriorityTable1[9]  = n_13_8.any();
00355   m_thePriorityTable1[8]  = n_13_9.any();
00356 
00357   m_thePriorityTable1[7]  = n_14_8.any();
00358   m_thePriorityTable1[6]  = n_14_9.any();
00359 
00360   m_thePriorityTable1[5]  = n_23_8.any();
00361   m_thePriorityTable1[4]  = n_23_9.any();
00362 
00363   m_thePriorityTable1[3]  = n_24_8.any();
00364   m_thePriorityTable1[2]  = n_24_9.any();
00365 
00366   m_thePriorityTable1[1]  = n_34_8.any();
00367   m_thePriorityTable1[0]  = n_34_9.any();
00368 
00369 
00370   if ( !m_thePriorityTable1.any() ) return;
00371   
00372   
00373   // first Priority Encoder Sub-Unit
00374   unsigned int global1 = 0;
00375   unsigned int group1 = 0;
00376   unsigned int p1 = 0;
00377   runEncoderSubUnit1(global1, group1, p1);
00378 
00379   // Address Assignment for the highest priority track
00380   runAddressAssignment1(global1, group1);
00381 
00382   // Cancellation and second Track Finder Unit
00383   for ( int i = 0; i < 56; i++ ) {
00384     m_thePriorityTable2[i] = m_thePriorityTable1[i];
00385   }
00386   m_thePriorityTable2 &= getCancelationTable(p1);
00387   
00388   if ( !m_thePriorityTable2.any() ) return;
00389   
00390   // second Priority Encoder Sub-Unit
00391   unsigned int global2 = 0;
00392   unsigned int group2 = 0;
00393   unsigned int p2 = 0;
00394   runEncoderSubUnit2(global2, group2, p2);
00395 
00396   // Address Assignment for the second priority track
00397   runAddressAssignment2(global2, group2);
00398 
00399   // Fake Pair Cancellation Unit
00400 
00401   unsigned int s1_2 = m_theAddresses[1].station(1);
00402   unsigned int s2_2 = m_theAddresses[1].station(2);
00403   unsigned int s3_2 = m_theAddresses[1].station(3);
00404   unsigned int s4_2 = m_theAddresses[1].station(4);
00405   
00406   if ( s2_2 == m_theAddresses[0].station(2) ) {
00407     s2_2 = 15; m_theBitMaps[1].reset(1); m_theAddresses[1].setStation(2,15);
00408     if ( m_theTCs[1] == T1234 ) m_theTCs[1] = T134;
00409     if ( m_theTCs[1] == T123  ) m_theTCs[1] = T13;
00410     if ( m_theTCs[1] == T124  ) m_theTCs[1] = T14;
00411     if ( m_theTCs[1] == T234  ) m_theTCs[1] = T34;
00412   }
00413   if ( s3_2 == m_theAddresses[0].station(3) ) {
00414     s3_2 = 15; m_theBitMaps[1].reset(2); m_theAddresses[1].setStation(3,15);
00415     if ( m_theTCs[1] == T1234 ) m_theTCs[1] = T124;
00416     if ( m_theTCs[1] == T123  ) m_theTCs[1] = T12;
00417     if ( m_theTCs[1] == T134  ) m_theTCs[1] = T14;
00418     if ( m_theTCs[1] == T234  ) m_theTCs[1] = T24;
00419   }
00420   if ( s4_2 == m_theAddresses[0].station(4) ) {
00421     s4_2 = 15; m_theBitMaps[1].reset(3); m_theAddresses[1].setStation(4,15);
00422     if ( m_theTCs[1] == T1234 ) m_theTCs[1] = T123;
00423     if ( m_theTCs[1] == T124  ) m_theTCs[1] = T12;
00424     if ( m_theTCs[1] == T134  ) m_theTCs[1] = T13;
00425     if ( m_theTCs[1] == T234  ) m_theTCs[1] = T23;
00426   }
00427   
00428   if ( ( s2_2 == 15 && s3_2 == 15 && s4_2 == 15 ) ||
00429        ( s1_2 == 15 && s3_2 == 15 && s4_2 == 15 ) ||
00430        ( s1_2 == 15 && s2_2 == 15 && s4_2 == 15 ) ||
00431        ( s1_2 == 15 && s2_2 == 15 && s3_2 == 15 ) ) {
00432        
00433     if ( L1MuDTTFConfig::Debug(5) ) cout << "L1MuDTTrackAssembler: second track has been cancelled" << endl;
00434     if ( L1MuDTTFConfig::Debug(5) ) print();
00435     
00436     m_theTCs[1] = UNDEF;
00437     m_theAddresses[1].reset();
00438     m_theBitMaps[1].reset();
00439     
00440   }
00441   
00442 /*
00443   if ( m_theBitMaps[1].to_ulong() != tc2bitmap(m_theTCs[1]) ) {
00444     if ( L1MuDTTFConfig::Debug(5) ) cout << "L1MuDTTrackAssembler: second track has been cancelled" << endl;
00445     if ( L1MuDTTFConfig::Debug(5) ) print();
00446    
00447     m_theTCs[1] = UNDEF;
00448     m_theAddresses[1].reset();
00449     m_theBitMaps[1].reset();
00450   }
00451 */
00452 
00453 }
00454 
00455 
00456 //
00457 // reset Track Assembler
00458 //
00459 void L1MuDTTrackAssembler::reset() {
00460 
00461   for ( int i = 0; i < 68; i++ ) m_theLastAddress[i] = 15;
00462   for ( int j = 0; j < 12; j++ ) m_theLastAddressI[j] = 15;  
00463   m_thePriorityTable1.reset();
00464   m_thePriorityTable2.reset();
00465   m_theTCs[0] = UNDEF;
00466   m_theTCs[1] = UNDEF;
00467   m_theBitMaps[0].reset();
00468   m_theBitMaps[1].reset();  
00469   m_theAddresses[0].reset();
00470   m_theAddresses[1].reset();
00471 
00472 }
00473 
00474 
00475 //
00476 // print result of Track Assembler
00477 //
00478 void L1MuDTTrackAssembler::print() const {
00479 
00480   cout << "Track Assembler : " << endl;
00481   cout << " Priority Table 1 : " << m_thePriorityTable1 << endl;
00482   cout << " Priority Table 2 : " << "            " << m_thePriorityTable2 << endl;  
00483 
00484   // print result
00485   cout << "Track 1: " << m_theTCs[0] << " " << m_theBitMaps[0] << '\t' << m_theAddresses[0] << endl;
00486   cout << "Track 2: " << m_theTCs[1] << " " << m_theBitMaps[1] << '\t' << m_theAddresses[1] << endl;
00487 
00488 }
00489 
00490 
00491 //
00492 // run the first Priority Encoder Sub-Unit
00493 //
00494 void L1MuDTTrackAssembler::runEncoderSubUnit1(unsigned& global, unsigned& group, unsigned& priority) {
00495 
00496   // Global Grouping 
00497 
00498   bitset<22> exi;
00499 
00500   exi[21] = m_thePriorityTable1[67] || m_thePriorityTable1[66] ||
00501             m_thePriorityTable1[65] || m_thePriorityTable1[64] ||  
00502             m_thePriorityTable1[63] || m_thePriorityTable1[62] ||
00503             m_thePriorityTable1[61] || m_thePriorityTable1[60] ||  
00504             m_thePriorityTable1[59] || m_thePriorityTable1[58] || 
00505             m_thePriorityTable1[57] || m_thePriorityTable1[56];
00506   exi[20] = m_thePriorityTable1[55] || m_thePriorityTable1[54] || 
00507             m_thePriorityTable1[53] || m_thePriorityTable1[52] ||
00508             m_thePriorityTable1[51] || m_thePriorityTable1[50] ||
00509             m_thePriorityTable1[49] || m_thePriorityTable1[48] ||
00510             m_thePriorityTable1[47] || m_thePriorityTable1[46] || 
00511             m_thePriorityTable1[45] || m_thePriorityTable1[44];
00512   exi[19] = m_thePriorityTable1[43] || m_thePriorityTable1[42] ||
00513             m_thePriorityTable1[41] || m_thePriorityTable1[40];
00514   exi[18] = m_thePriorityTable1[39] || m_thePriorityTable1[38] ||
00515             m_thePriorityTable1[37] || m_thePriorityTable1[36];
00516   exi[17] = m_thePriorityTable1[35] || m_thePriorityTable1[34] ||
00517             m_thePriorityTable1[33] || m_thePriorityTable1[32];
00518   exi[16] = m_thePriorityTable1[31] || m_thePriorityTable1[30] ||
00519             m_thePriorityTable1[29] || m_thePriorityTable1[28];
00520   exi[15] = m_thePriorityTable1[27] || m_thePriorityTable1[26] ||
00521             m_thePriorityTable1[25] || m_thePriorityTable1[24];
00522   exi[14] = m_thePriorityTable1[23] || m_thePriorityTable1[22] ||
00523             m_thePriorityTable1[21] || m_thePriorityTable1[20];
00524   exi[13] = m_thePriorityTable1[19] || m_thePriorityTable1[18] ||
00525             m_thePriorityTable1[17] || m_thePriorityTable1[16];
00526   exi[12] = m_thePriorityTable1[15] || m_thePriorityTable1[14] ||
00527             m_thePriorityTable1[13] || m_thePriorityTable1[12];
00528   exi[11] = m_thePriorityTable1[11];
00529   exi[10] = m_thePriorityTable1[10];
00530   exi[9]  = m_thePriorityTable1[9];
00531   exi[8]  = m_thePriorityTable1[8];
00532   exi[7]  = m_thePriorityTable1[7];
00533   exi[6]  = m_thePriorityTable1[6];
00534   exi[5]  = m_thePriorityTable1[5];
00535   exi[4]  = m_thePriorityTable1[4];
00536   exi[3]  = m_thePriorityTable1[3];
00537   exi[2]  = m_thePriorityTable1[2];
00538   exi[1]  = m_thePriorityTable1[1];
00539   exi[0]  = m_thePriorityTable1[0];
00540 
00541   // Global Priority Encoder
00542   
00543   global = priorityEncoder22(exi);
00544   if ( global == 31 ) {
00545     group = 15;
00546     priority = 0;
00547     return;
00548   }
00549 
00550   // Group priority encoders
00551   
00552   bitset<12> x;
00553   x = subBitset68(m_thePriorityTable1,56,12);
00554   unsigned int prio1234a = priorityEncoder12(x);
00555   x = subBitset68(m_thePriorityTable1,44,12);
00556   unsigned int prio1234b = priorityEncoder12(x);
00557 
00558   bitset<4> y;
00559   y = subBitset68(m_thePriorityTable1,40,4);
00560   unsigned int prio123a = priorityEncoder4(y);
00561   y = subBitset68(m_thePriorityTable1,36,4);
00562   unsigned int prio123b = priorityEncoder4(y);
00563   y = subBitset68(m_thePriorityTable1,32,4);
00564   unsigned int prio124a = priorityEncoder4(y);
00565   y = subBitset68(m_thePriorityTable1,28,4);
00566   unsigned int prio124b = priorityEncoder4(y);
00567   y = subBitset68(m_thePriorityTable1,24,4);
00568   unsigned int prio134a = priorityEncoder4(y);
00569   y = subBitset68(m_thePriorityTable1,20,4);
00570   unsigned int prio134b = priorityEncoder4(y);
00571   y = subBitset68(m_thePriorityTable1,16,4);
00572   unsigned int prio234a = priorityEncoder4(y);
00573   y = subBitset68(m_thePriorityTable1,12,4);
00574   unsigned int prio234b = priorityEncoder4(y);
00575   
00576   switch ( global ) {
00577     case 21 : { group = prio1234a; priority = 56 + group; break; }
00578     case 20 : { group = prio1234b; priority = 44 + group; break; }
00579     case 19 : { group = prio123a;  priority = 40 + group; break; }
00580     case 18 : { group = prio123b;  priority = 36 + group; break; }
00581     case 17 : { group = prio124a;  priority = 32 + group; break; }
00582     case 16 : { group = prio124b;  priority = 28 + group; break; }
00583     case 15 : { group = prio134a;  priority = 24 + group; break; }
00584     case 14 : { group = prio134b;  priority = 20 + group; break; }
00585     case 13 : { group = prio234a;  priority = 16 + group; break; }
00586     case 12 : { group = prio234b;  priority = 12 + group; break; }     
00587     default : { group = 15; priority = global; break; }
00588   }
00589    
00590 }
00591 
00592 
00593 //
00594 // run the second Priority Encoder Sub-Unit
00595 //
00596 void L1MuDTTrackAssembler::runEncoderSubUnit2(unsigned& global, unsigned& group, unsigned& priority) {
00597     
00598   // Global Grouping 
00599 
00600   bitset<21> exi;
00601 
00602   exi[20] = m_thePriorityTable2[55] || m_thePriorityTable2[54] || 
00603             m_thePriorityTable2[53] || m_thePriorityTable2[52] ||
00604             m_thePriorityTable2[51] || m_thePriorityTable2[50] ||
00605             m_thePriorityTable2[49] || m_thePriorityTable2[48] ||
00606             m_thePriorityTable2[47] || m_thePriorityTable2[46] || 
00607             m_thePriorityTable2[45] || m_thePriorityTable2[44];
00608   exi[19] = m_thePriorityTable2[43] || m_thePriorityTable2[42] ||
00609             m_thePriorityTable2[41] || m_thePriorityTable2[40];
00610   exi[18] = m_thePriorityTable2[39] || m_thePriorityTable2[38] ||
00611             m_thePriorityTable2[37] || m_thePriorityTable2[36];
00612   exi[17] = m_thePriorityTable2[35] || m_thePriorityTable2[34] ||
00613             m_thePriorityTable2[33] || m_thePriorityTable2[32];
00614   exi[16] = m_thePriorityTable2[31] || m_thePriorityTable2[30] ||
00615             m_thePriorityTable2[29] || m_thePriorityTable2[28];
00616   exi[15] = m_thePriorityTable2[27] || m_thePriorityTable2[26] ||
00617             m_thePriorityTable2[25] || m_thePriorityTable2[24];
00618   exi[14] = m_thePriorityTable2[23] || m_thePriorityTable2[22] ||
00619             m_thePriorityTable2[21] || m_thePriorityTable2[20];
00620   exi[13] = m_thePriorityTable2[19] || m_thePriorityTable2[18] ||
00621             m_thePriorityTable2[17] || m_thePriorityTable2[16];
00622   exi[12] = m_thePriorityTable2[15] || m_thePriorityTable2[14] ||
00623             m_thePriorityTable2[13] || m_thePriorityTable2[12];
00624   exi[11] = m_thePriorityTable2[11];
00625   exi[10] = m_thePriorityTable2[10];
00626   exi[9]  = m_thePriorityTable2[9];
00627   exi[8]  = m_thePriorityTable2[8];
00628   exi[7]  = m_thePriorityTable2[7];
00629   exi[6]  = m_thePriorityTable2[6];
00630   exi[5]  = m_thePriorityTable2[5];
00631   exi[4]  = m_thePriorityTable2[4];
00632   exi[3]  = m_thePriorityTable2[3];
00633   exi[2]  = m_thePriorityTable2[2];
00634   exi[1]  = m_thePriorityTable2[1];
00635   exi[0]  = m_thePriorityTable2[0];
00636 
00637   // Global Priority Encoder
00638   
00639   global = priorityEncoder21(exi);
00640   if ( global == 31 ) {
00641     group = 15;
00642     priority = 0;
00643     return;
00644   }
00645 
00646   // Group priority encoders
00647   
00648   bitset<12> x;
00649   x = subBitset56(m_thePriorityTable2,44,12);
00650   unsigned int prio1234b = priorityEncoder12(x);
00651   
00652   bitset<4> y;
00653   y = subBitset56(m_thePriorityTable2,40,4);
00654   unsigned int prio123a = priorityEncoder4(y);
00655   y = subBitset56(m_thePriorityTable2,36,4);
00656   unsigned int prio123b = priorityEncoder4(y);
00657   y = subBitset56(m_thePriorityTable2,32,4);
00658   unsigned int prio124a = priorityEncoder4(y);
00659   y = subBitset56(m_thePriorityTable2,28,4);
00660   unsigned int prio124b = priorityEncoder4(y);
00661   y = subBitset56(m_thePriorityTable2,24,4);
00662   unsigned int prio134a = priorityEncoder4(y);
00663   y = subBitset56(m_thePriorityTable2,20,4);
00664   unsigned int prio134b = priorityEncoder4(y);
00665   y = subBitset56(m_thePriorityTable2,16,4);
00666   unsigned int prio234a = priorityEncoder4(y);
00667   y = subBitset56(m_thePriorityTable2,12,4);
00668   unsigned int prio234b = priorityEncoder4(y); 
00669   
00670   switch ( global ) {
00671     case 20 : { group = prio1234b; priority = 44 + group; break; }
00672     case 19 : { group = prio123a;  priority = 40 + group; break; }
00673     case 18 : { group = prio123b;  priority = 36 + group; break; }
00674     case 17 : { group = prio124a;  priority = 32 + group; break; }
00675     case 16 : { group = prio124b;  priority = 28 + group; break; }
00676     case 15 : { group = prio134a;  priority = 24 + group; break; }
00677     case 14 : { group = prio134b;  priority = 20 + group; break; }
00678     case 13 : { group = prio234a;  priority = 16 + group; break; }
00679     case 12 : { group = prio234b;  priority = 12 + group; break; }     
00680     default : { group = 15; priority = global; break; }
00681   }
00682    
00683 }
00684 
00685 
00686 //
00687 // run the first Address Assignment Sub-Unit
00688 //
00689 void L1MuDTTrackAssembler::runAddressAssignment1(int global, int group) {
00690 
00691   TrackClass tc(UNDEF);
00692   
00693   switch ( global ) {
00694     case 21 : { tc = T1234;
00695       switch ( group ) { 
00696         case 11 : m_theAddresses[0].setStations( 0, 0, 0, m_theLastAddress[67]); break;
00697         case 10 : m_theAddresses[0].setStations( 0, 0, 1, m_theLastAddress[66]); break;
00698         case  9 : m_theAddresses[0].setStations( 0, 0, 2, m_theLastAddress[65]); break;
00699         case  8 : m_theAddresses[0].setStations( 0, 0, 3, m_theLastAddress[64]); break;
00700         case  7 : m_theAddresses[0].setStations( 0, 1, 0, m_theLastAddress[63]); break;
00701         case  6 : m_theAddresses[0].setStations( 0, 1, 1, m_theLastAddress[62]); break;
00702         case  5 : m_theAddresses[0].setStations( 0, 1, 2, m_theLastAddress[61]); break;
00703         case  4 : m_theAddresses[0].setStations( 0, 1, 3, m_theLastAddress[60]); break;
00704         case  3 : m_theAddresses[0].setStations( 0, 2, 2, m_theLastAddress[59]); break;
00705         case  2 : m_theAddresses[0].setStations( 0, 2, 3, m_theLastAddress[58]); break;
00706         case  1 : m_theAddresses[0].setStations( 0, 3, 2, m_theLastAddress[57]); break;
00707         case  0 : m_theAddresses[0].setStations( 0, 3, 3, m_theLastAddress[56]); break;
00708       }  
00709       break;   
00710     }
00711     case 20 : { tc = T1234;
00712       switch ( group ) {
00713         case 11 : m_theAddresses[0].setStations( 1, 0, 0, m_theLastAddress[55]); break;
00714         case 10 : m_theAddresses[0].setStations( 1, 0, 1, m_theLastAddress[54]); break;
00715         case  9 : m_theAddresses[0].setStations( 1, 0, 2, m_theLastAddress[53]); break;
00716         case  8 : m_theAddresses[0].setStations( 1, 0, 3, m_theLastAddress[52]); break;
00717         case  7 : m_theAddresses[0].setStations( 1, 1, 0, m_theLastAddress[51]); break;
00718         case  6 : m_theAddresses[0].setStations( 1, 1, 1, m_theLastAddress[50]); break;
00719         case  5 : m_theAddresses[0].setStations( 1, 1, 2, m_theLastAddress[49]); break;
00720         case  4 : m_theAddresses[0].setStations( 1, 1, 3, m_theLastAddress[48]); break;
00721         case  3 : m_theAddresses[0].setStations( 1, 2, 2, m_theLastAddress[47]); break;
00722         case  2 : m_theAddresses[0].setStations( 1, 2, 3, m_theLastAddress[46]); break;
00723         case  1 : m_theAddresses[0].setStations( 1, 3, 2, m_theLastAddress[45]); break;
00724         case  0 : m_theAddresses[0].setStations( 1, 3, 3, m_theLastAddress[44]); break;
00725       }
00726       break;
00727     }
00728     case 19 : { tc = T123;
00729       switch ( group ) {
00730         case  3 : m_theAddresses[0].setStations( 0, 0, m_theLastAddress[43],15); break;
00731         case  2 : m_theAddresses[0].setStations( 0, 1, m_theLastAddress[42],15); break;
00732         case  1 : m_theAddresses[0].setStations( 0, 2, m_theLastAddress[41],15); break;
00733         case  0 : m_theAddresses[0].setStations( 0, 3, m_theLastAddress[40],15); break;
00734       }
00735       break;        
00736     }
00737     case 18 : { tc = T123;
00738       switch ( group ) {
00739         case  3 : m_theAddresses[0].setStations( 1, 0, m_theLastAddress[39],15); break;
00740         case  2 : m_theAddresses[0].setStations( 1, 1, m_theLastAddress[38],15); break;
00741         case  1 : m_theAddresses[0].setStations( 1, 2, m_theLastAddress[37],15); break;
00742         case  0 : m_theAddresses[0].setStations( 1, 3, m_theLastAddress[36],15); break;
00743       }
00744       break;  
00745     }
00746     case 17 : { tc = T124; 
00747       switch ( group ) {
00748         case  3 : m_theAddresses[0].setStations( 0, 0,15, m_theLastAddress[35]); break;
00749         case  2 : m_theAddresses[0].setStations( 0, 1,15, m_theLastAddress[34]); break;
00750         case  1 : m_theAddresses[0].setStations( 0, 2,15, m_theLastAddress[33]); break;
00751         case  0 : m_theAddresses[0].setStations( 0, 3,15, m_theLastAddress[32]); break;
00752       }
00753       break;  
00754     }
00755     case 16 : { tc = T124;
00756       switch ( group ) {
00757         case  3 : m_theAddresses[0].setStations( 1, 0,15, m_theLastAddress[31]); break;
00758         case  2 : m_theAddresses[0].setStations( 1, 1,15, m_theLastAddress[30]); break;
00759         case  1 : m_theAddresses[0].setStations( 1, 2,15, m_theLastAddress[29]); break;
00760         case  0 : m_theAddresses[0].setStations( 1, 3,15, m_theLastAddress[28]); break;
00761       }
00762       break;  
00763     }
00764     case 15 : { tc = T134; 
00765       switch ( group ) {
00766         case  3 : m_theAddresses[0].setStations( 0,15, 0, m_theLastAddress[27]); break;
00767         case  2 : m_theAddresses[0].setStations( 0,15, 1, m_theLastAddress[26]); break;
00768         case  1 : m_theAddresses[0].setStations( 0,15, 2, m_theLastAddress[25]); break;
00769         case  0 : m_theAddresses[0].setStations( 0,15, 3, m_theLastAddress[24]); break;
00770       }
00771       break;  
00772     }
00773     case 14 : { tc = T134;
00774       switch ( group ) {
00775         case  3 : m_theAddresses[0].setStations( 1,15, 0, m_theLastAddress[23]); break;
00776         case  2 : m_theAddresses[0].setStations( 1,15, 1, m_theLastAddress[22]); break;
00777         case  1 : m_theAddresses[0].setStations( 1,15, 2, m_theLastAddress[21]); break;
00778         case  0 : m_theAddresses[0].setStations( 1,15, 3, m_theLastAddress[20]); break;
00779       }
00780       break;  
00781     }
00782     case 13 : { tc = T234; 
00783       switch ( group ) {
00784         case  3 : m_theAddresses[0].setStations(15, 0, 0, m_theLastAddress[19]); break;
00785         case  2 : m_theAddresses[0].setStations(15, 0, 1, m_theLastAddress[18]); break;
00786         case  1 : m_theAddresses[0].setStations(15, 0, 2, m_theLastAddress[17]); break;
00787         case  0 : m_theAddresses[0].setStations(15, 0, 3, m_theLastAddress[16]); break;
00788       }
00789       break;  
00790     }
00791     case 12 : { tc = T234;
00792       switch ( group ) {
00793         case  3 : m_theAddresses[0].setStations(15, 1, 0, m_theLastAddress[15]); break;
00794         case  2 : m_theAddresses[0].setStations(15, 1, 1, m_theLastAddress[14]); break;
00795         case  1 : m_theAddresses[0].setStations(15, 1, 2, m_theLastAddress[13]); break;
00796         case  0 : m_theAddresses[0].setStations(15, 1, 3, m_theLastAddress[12]); break;
00797       }
00798       break;  
00799     }
00800     case 11 : { tc = T12; m_theAddresses[0].setStations( 0, m_theLastAddress[11],15,15); break; }
00801     case 10 : { tc = T12; m_theAddresses[0].setStations( 1, m_theLastAddress[10],15,15); break; }
00802     case 9  : { tc = T13; m_theAddresses[0].setStations( 0,15, m_theLastAddress[9],15); break; }
00803     case 8  : { tc = T13; m_theAddresses[0].setStations( 1,15, m_theLastAddress[8],15); break; }
00804     case 7  : { tc = T14; m_theAddresses[0].setStations( 0,15,15, m_theLastAddress[7]); break; }
00805     case 6  : { tc = T14; m_theAddresses[0].setStations( 1,15,15, m_theLastAddress[6]); break; } 
00806     case 5  : { tc = T23; m_theAddresses[0].setStations(15, 0, m_theLastAddress[5],15); break; }
00807     case 4  : { tc = T23; m_theAddresses[0].setStations(15, 1, m_theLastAddress[4],15); break; }
00808     case 3  : { tc = T24; m_theAddresses[0].setStations(15, 0,15, m_theLastAddress[3]); break; }
00809     case 2  : { tc = T24; m_theAddresses[0].setStations(15, 1,15, m_theLastAddress[2]); break; }
00810     case 1  : { tc = T34; m_theAddresses[0].setStations(15,15, 0, m_theLastAddress[1]); break; }
00811     case 0  : { tc = T34; m_theAddresses[0].setStations(15,15, 1, m_theLastAddress[0]); break; }
00812   }
00813 
00814   // set Track Class and covert to bitmap
00815   m_theTCs[0] = tc;
00816   m_theBitMaps[0] = tc2bitmap(tc);
00817   
00818 }
00819 
00820 
00821 //
00822 // run the second Address Assignment Sub-Unit
00823 //
00824 void L1MuDTTrackAssembler::runAddressAssignment2(int global, int group) {
00825 
00826   TrackClass tc(UNDEF);
00827   
00828   switch ( global ) {
00829     case 20 : { tc = T1234;
00830       switch ( group ) {
00831         case 11 : m_theAddresses[1].setStations( 1, 0, 0, m_theLastAddress[55]); break;
00832         case 10 : m_theAddresses[1].setStations( 1, 0, 1, m_theLastAddress[54]); break;
00833         case  9 : m_theAddresses[1].setStations( 1, 0, 2, m_theLastAddress[53]); break;
00834         case  8 : m_theAddresses[1].setStations( 1, 0, 3, m_theLastAddress[52]); break;
00835         case  7 : m_theAddresses[1].setStations( 1, 1, 0, m_theLastAddress[51]); break;
00836         case  6 : m_theAddresses[1].setStations( 1, 1, 1, m_theLastAddress[50]); break;
00837         case  5 : m_theAddresses[1].setStations( 1, 1, 2, m_theLastAddress[49]); break;
00838         case  4 : m_theAddresses[1].setStations( 1, 1, 3, m_theLastAddress[48]); break;
00839         case  3 : m_theAddresses[1].setStations( 1, 2, 2, m_theLastAddress[47]); break;
00840         case  2 : m_theAddresses[1].setStations( 1, 2, 3, m_theLastAddress[46]); break;
00841         case  1 : m_theAddresses[1].setStations( 1, 3, 2, m_theLastAddress[45]); break;
00842         case  0 : m_theAddresses[1].setStations( 1, 3, 3, m_theLastAddress[44]); break;
00843       }  
00844       break;
00845     }
00846     case 19 : { tc = T123;
00847       switch ( group ) {
00848         case  3 : m_theAddresses[1].setStations( 0, 0, m_theLastAddress[43],15); break;
00849         case  2 : m_theAddresses[1].setStations( 0, 1, m_theLastAddress[42],15); break;
00850         case  1 : m_theAddresses[1].setStations( 0, 2, m_theLastAddress[41],15); break;
00851         case  0 : m_theAddresses[1].setStations( 0, 3, m_theLastAddress[40],15); break;
00852       }
00853       break;        
00854     }
00855     case 18 : { tc = T123;
00856       switch ( group ) {
00857         case  3 : m_theAddresses[1].setStations( 1, 0, m_theLastAddress[39],15); break;
00858         case  2 : m_theAddresses[1].setStations( 1, 1, m_theLastAddress[38],15); break;
00859         case  1 : m_theAddresses[1].setStations( 1, 2, m_theLastAddress[37],15); break;
00860         case  0 : m_theAddresses[1].setStations( 1, 3, m_theLastAddress[36],15); break;
00861       }
00862       break;  
00863     }
00864     case 17 : { tc = T124; 
00865       switch ( group ) {
00866         case  3 : m_theAddresses[1].setStations( 0, 0,15, m_theLastAddress[35]); break;
00867         case  2 : m_theAddresses[1].setStations( 0, 1,15, m_theLastAddress[34]); break;
00868         case  1 : m_theAddresses[1].setStations( 0, 2,15, m_theLastAddress[33]); break;
00869         case  0 : m_theAddresses[1].setStations( 0, 3,15, m_theLastAddress[32]); break;
00870       }
00871       break;  
00872     }
00873     case 16 : { tc = T124;
00874       switch ( group ) {
00875         case  3 : m_theAddresses[1].setStations( 1, 0,15, m_theLastAddress[31]); break;
00876         case  2 : m_theAddresses[1].setStations( 1, 1,15, m_theLastAddress[30]); break;
00877         case  1 : m_theAddresses[1].setStations( 1, 2,15, m_theLastAddress[29]); break;
00878         case  0 : m_theAddresses[1].setStations( 1, 3,15, m_theLastAddress[28]); break;
00879       }
00880       break;  
00881     }
00882     case 15 : { tc = T134; 
00883       switch ( group ) {
00884         case  3 : m_theAddresses[1].setStations( 0,15, 0, m_theLastAddress[27]); break;
00885         case  2 : m_theAddresses[1].setStations( 0,15, 1, m_theLastAddress[26]); break;
00886         case  1 : m_theAddresses[1].setStations( 0,15, 2, m_theLastAddress[25]); break;
00887         case  0 : m_theAddresses[1].setStations( 0,15, 3, m_theLastAddress[24]); break;
00888       }
00889       break;  
00890     }
00891     case 14 : { tc = T134;
00892       switch ( group ) {
00893         case  3 : m_theAddresses[1].setStations( 1,15, 0, m_theLastAddress[23]); break;
00894         case  2 : m_theAddresses[1].setStations( 1,15, 1, m_theLastAddress[22]); break;
00895         case  1 : m_theAddresses[1].setStations( 1,15, 2, m_theLastAddress[21]); break;
00896         case  0 : m_theAddresses[1].setStations( 1,15, 3, m_theLastAddress[20]); break;
00897       }
00898       break;  
00899     }
00900     case 13 : { tc = T234; 
00901       switch ( group ) {
00902         case  3 : m_theAddresses[1].setStations(15, 0, 0, m_theLastAddress[19]); break;
00903         case  2 : m_theAddresses[1].setStations(15, 0, 1, m_theLastAddress[18]); break;
00904         case  1 : m_theAddresses[1].setStations(15, 0, 2, m_theLastAddress[17]); break;
00905         case  0 : m_theAddresses[1].setStations(15, 0, 3, m_theLastAddress[16]); break;
00906       }
00907       break;  
00908     }
00909     case 12 : { tc = T234;
00910       switch ( group ) {
00911         case  3 : m_theAddresses[1].setStations(15, 1, 0, m_theLastAddress[15]); break;
00912         case  2 : m_theAddresses[1].setStations(15, 1, 1, m_theLastAddress[14]); break;
00913         case  1 : m_theAddresses[1].setStations(15, 1, 2, m_theLastAddress[13]); break;
00914         case  0 : m_theAddresses[1].setStations(15, 1, 3, m_theLastAddress[12]); break;
00915       }
00916       break;  
00917     }
00918     case 11 : { tc = T12; m_theAddresses[1].setStations( 0, m_theLastAddressI[11],15,15); break; }
00919     case 10 : { tc = T12; m_theAddresses[1].setStations( 1, m_theLastAddressI[10],15,15); break; }
00920     case 9  : { tc = T13; m_theAddresses[1].setStations( 0,15, m_theLastAddressI[9],15); break; }
00921     case 8  : { tc = T13; m_theAddresses[1].setStations( 1,15, m_theLastAddressI[8],15); break; }
00922     case 7  : { tc = T14; m_theAddresses[1].setStations( 0,15,15, m_theLastAddressI[7]); break; }
00923     case 6  : { tc = T14; m_theAddresses[1].setStations( 1,15,15, m_theLastAddressI[6]); break; } 
00924     case 5  : { tc = T23; m_theAddresses[1].setStations(15, 0, m_theLastAddressI[5],15); break; }
00925     case 4  : { tc = T23; m_theAddresses[1].setStations(15, 1, m_theLastAddressI[4],15); break; }
00926     case 3  : { tc = T24; m_theAddresses[1].setStations(15, 0,15, m_theLastAddressI[3]); break; }
00927     case 2  : { tc = T24; m_theAddresses[1].setStations(15, 1,15, m_theLastAddressI[2]); break; }
00928     case 1  : { tc = T34; m_theAddresses[1].setStations(15,15, 0, m_theLastAddressI[1]); break; }
00929     case 0  : { tc = T34; m_theAddresses[1].setStations(15,15, 1, m_theLastAddressI[0]); break; }
00930   }
00931 
00932   // set Track Class and covert to bitmap
00933   m_theTCs[1] = tc;
00934   m_theBitMaps[1] = tc2bitmap(tc);
00935   
00936 }
00937 
00938 
00939 //
00940 // 12 bit priority encoder
00941 //
00942 unsigned int L1MuDTTrackAssembler::priorityEncoder12(const bitset<12>& input)  {
00943 
00944   unsigned int result = 15;
00945 
00946   for ( int i = 0; i < 12; i++ ) {
00947     if ( input.test(i) ) result = i;
00948   }
00949 
00950   return result;
00951 
00952 }
00953 
00954 
00955 //
00956 // 4 bit priority encoder
00957 //
00958 unsigned int L1MuDTTrackAssembler::priorityEncoder4(const bitset<4>& input)  {
00959 
00960   unsigned int result = 3;
00961 
00962   for ( int i = 0; i < 4; i++ ) {
00963     if ( input.test(i) ) result = i;
00964   }
00965 
00966   return result;
00967 
00968 }
00969 
00970 
00971 //
00972 // 22 bit priority encoder
00973 //
00974 unsigned int L1MuDTTrackAssembler::priorityEncoder22(const bitset<22>& input)  {
00975 
00976   unsigned int result = 31;
00977 
00978   for ( int i = 0; i < 22; i++ ) {
00979     if ( input.test(i) ) result = i;
00980   }
00981 
00982   return result;
00983 
00984 }
00985 
00986 
00987 //
00988 // 21 bit priority encoder
00989 //
00990 unsigned int L1MuDTTrackAssembler::priorityEncoder21(const bitset<21>& input)  {
00991 
00992   unsigned int result = 31;
00993 
00994   for ( int i = 0; i < 21; i++ ) {
00995     if ( input.test(i) ) result = i;
00996   }
00997 
00998   return result;
00999 
01000 }
01001 
01002 
01003 //
01004 // 12 bit address encoder
01005 //
01006 unsigned int L1MuDTTrackAssembler::addressEncoder12(const bitset<12>& input)  {
01007 
01008   // inverse order priority encoder
01009   
01010   unsigned int result = 15;
01011    
01012   for ( int i = 0; i < 12; i++ ) {
01013     if ( input.test(i) )  { 
01014       result = i;
01015       break;
01016     }  
01017   }
01018 
01019   return result;
01020 
01021 }
01022 
01023 
01024 //
01025 // special 12 bit address encoder
01026 //
01027 unsigned int L1MuDTTrackAssembler::addressEncoder12s(const bitset<12>& input)  {
01028 
01029   // inverse order priority encoder which prefers second addresses
01030    
01031   unsigned int result = 15;
01032 
01033   for ( int i = 0; i < 11; i += 2 ) {
01034     if ( input.test(i) || input.test(i+1) ) {
01035       if ( input.test(i) )   result = i;
01036       if ( input.test(i+1) ) result = i+1;
01037       break;
01038     }  
01039   }
01040 
01041   return result;
01042 
01043 }
01044 
01045 //
01046 // get sub-bitmap of a 68-bit word
01047 //
01048 unsigned long L1MuDTTrackAssembler::subBitset68(const bitset<68>& input, int pos, int length) {
01049     
01050   bitset<68> s(input);
01051 
01052   for ( int i = pos+length; i < 68; i++ ) s.reset(i);
01053 
01054   s >>= pos;
01055 
01056   return s.to_ulong();
01057 
01058 }
01059 
01060 
01061 //
01062 // get sub-bitmap of a 56-bit word
01063 //
01064 unsigned long L1MuDTTrackAssembler::subBitset56(const bitset<56>& input, int pos, int length) {
01065     
01066   bitset<56> s(input);
01067   
01068   for ( int i = pos+length; i < 56; i++ ) s.reset(i);
01069 
01070   s >>= pos;
01071 
01072   return s.to_ulong();
01073 
01074 }
01075 
01076 
01077 //
01078 // Cancel Out Table
01079 //
01080 bitset<56> L1MuDTTrackAssembler::getCancelationTable(unsigned int p) {
01081 
01082   // Cancellation Table
01083   // Each 0 in this Table means a sub-track of the
01084   // previous found Track               
01085   
01086   switch ( p ) {
01087     case 67 : { bitset<56> b(string("00000111111100000111000001110000011100000111010101010101")); return b; break; }
01088     case 66 : { bitset<56> b(string("00001011111100000111000001110000101100001011010101010110")); return b; break; }
01089     case 65 : { bitset<56> b(string("00001101010100000111000001110000110100001101010101010111")); return b; break; }
01090     case 64 : { bitset<56> b(string("00001110101000000111000001110000111000001110010101010111")); return b; break; }
01091     case 63 : { bitset<56> b(string("01110000111100001011000010110000011101110000010101101001")); return b; break; }
01092     case 62 : { bitset<56> b(string("10110000111100001011000010110000101110110000010101101010")); return b; break; }
01093     case 61 : { bitset<56> b(string("11010000111100001011000010110000110111010000010101101011")); return b; break; }
01094     case 60 : { bitset<56> b(string("11100000111100001011000010110000111011100000010101101011")); return b; break; }
01095     case 59 : { bitset<56> b(string("11011101000100001101000011010000110111011101010101111111")); return b; break; }
01096     case 58 : { bitset<56> b(string("11101110001000001101000011010000111011101110010101111111")); return b; break; }
01097     case 57 : { bitset<56> b(string("11011101010000001110000011100000110111011101010101111111")); return b; break; }
01098     case 56 : { bitset<56> b(string("11101110100000001110000011100000111011101110010101111111")); return b; break; }
01099 
01100     case 55 : { bitset<56> b(string("00000000000001110000011100000111000000000111101010010101")); return b; break; }
01101     case 54 : { bitset<56> b(string("00000000000001110000011100001011000000001011101010010110")); return b; break; }
01102     case 53 : { bitset<56> b(string("00000000000001110000011100001101000000001101101010010111")); return b; break; }
01103     case 52 : { bitset<56> b(string("00000000000001110000011100001110000000001110101010010111")); return b; break; }
01104     case 51 : { bitset<56> b(string("00000000000010110000101100000111000001110000101010101001")); return b; break; }
01105     case 50 : { bitset<56> b(string("00000000000010110000101100001011000010110000101010101010")); return b; break; }
01106     case 49 : { bitset<56> b(string("00000000000010110000101100001101000011010000101010101011")); return b; break; }
01107     case 48 : { bitset<56> b(string("00000000000010110000101100001110000011100000101010101011")); return b; break; }
01108     case 47 : { bitset<56> b(string("00000000000011010000110100001101000011011101101010111111")); return b; break; }
01109     case 46 : { bitset<56> b(string("00000000000011010000110100001110000011101110101010111111")); return b; break; }
01110     case 45 : { bitset<56> b(string("00000000000011100000111000001101000011011101101010111111")); return b; break; }
01111     case 44 : { bitset<56> b(string("00000000000011100000111000001110000011101110101010111111")); return b; break; }
01112 
01113     case 43 : { bitset<56> b(string("00000000000000000111000001110000111100001111010101010111")); return b; break; }
01114     case 42 : { bitset<56> b(string("00000000000000001011000010110000111111110000010101101011")); return b; break; }
01115     case 41 : { bitset<56> b(string("00000000000000001101000011010000111111111111010101111111")); return b; break; }
01116     case 40 : { bitset<56> b(string("00000000000000001110000011100000111111111111010101111111")); return b; break; }
01117 
01118     case 39 : { bitset<56> b(string("00000000000000000000011100001111000000001111101010010111")); return b; break; }
01119     case 38 : { bitset<56> b(string("00000000000000000000101100001111000011110000101010101011")); return b; break; }
01120     case 37 : { bitset<56> b(string("00000000000000000000110100001111000011111111101010111111")); return b; break; }
01121     case 36 : { bitset<56> b(string("00000000000000000000111000001111000011111111101010111111")); return b; break; }
01122 
01123     case 35 : { bitset<56> b(string("00000000000000000000000001110000111100001111010101010111")); return b; break; }
01124     case 34 : { bitset<56> b(string("00000000000000000000000010110000111111110000010101101011")); return b; break; }
01125     case 33 : { bitset<56> b(string("00000000000000000000000011010000111111111111010101111111")); return b; break; }
01126     case 32 : { bitset<56> b(string("00000000000000000000000011100000111111111111010101111111")); return b; break; }
01127 
01128     case 31 : { bitset<56> b(string("00000000000000000000011100001111000000001111101010010111")); return b; break; }
01129     case 30 : { bitset<56> b(string("00000000000000000000101100001111000011110000101010101011")); return b; break; } 
01130     case 29 : { bitset<56> b(string("00000000000000000000110100001111000011111111101010111111")); return b; break; }
01131     case 28 : { bitset<56> b(string("00000000000000000000111000001111000011111111101010111111")); return b; break; }
01132 
01133     case 27 : { bitset<56> b(string("00000000000000000000000000000000011101110111010101111101")); return b; break; }
01134     case 26 : { bitset<56> b(string("00000000000000000000000000000000101110111011010101111110")); return b; break; }
01135     case 25 : { bitset<56> b(string("00000000000000000000000000000000110111011101010101111111")); return b; break; }
01136     case 24 : { bitset<56> b(string("00000000000000000000000000000000111011101110010101111111")); return b; break; }
01137 
01138     case 23 : { bitset<56> b(string("00000000000000000000000000000000000001110111101010111101")); return b; break; }
01139     case 22 : { bitset<56> b(string("00000000000000000000000000000000000010111011101010111110")); return b; break; }
01140     case 21 : { bitset<56> b(string("00000000000000000000000000000000000011011101101010111111")); return b; break; }
01141     case 20 : { bitset<56> b(string("00000000000000000000000000000000000011101110101010111111")); return b; break; }
01142 
01143     case 19 : { bitset<56> b(string("00000000000000000000000000000000000000000111111111010101")); return b; break; }
01144     case 18 : { bitset<56> b(string("00000000000000000000000000000000000000001011111111010110")); return b; break; }
01145     case 17 : { bitset<56> b(string("00000000000000000000000000000000000000001101111111010111")); return b; break; }
01146     case 16 : { bitset<56> b(string("00000000000000000000000000000000000000001110111111010111")); return b; break; }
01147 
01148     case 15 : { bitset<56> b(string("00000000000000000000000000000000000000000000111111101001")); return b; break; }
01149     case 14 : { bitset<56> b(string("00000000000000000000000000000000000000000000111111101010")); return b; break; }
01150     case 13 : { bitset<56> b(string("00000000000000000000000000000000000000000000111111101011")); return b; break; }
01151     case 12 : { bitset<56> b(string("00000000000000000000000000000000000000000000111111101011")); return b; break; }
01152 
01153     case 11 : { bitset<56> b(string("00000000000000000000000000000000000000000000010101111111")); return b; break; }
01154     case 10 : { bitset<56> b(string("00000000000000000000000000000000000000000000001010111111")); return b; break; }
01155 
01156     case  9 : { bitset<56> b(string("00000000000000000000000000000000000000000000000101111111")); return b; break; }
01157     case  8 : { bitset<56> b(string("00000000000000000000000000000000000000000000000010111111")); return b; break; }
01158 
01159     case  7 : { bitset<56> b(string("00000000000000000000000000000000000000000000000001111111")); return b; break; }
01160     case  6 : { bitset<56> b(string("00000000000000000000000000000000000000000000000000111111")); return b; break; }
01161   
01162     case  5 : { bitset<56> b(string("00000000000000000000000000000000000000000000000000010111")); return b; break; }
01163     case  4 : { bitset<56> b(string("00000000000000000000000000000000000000000000000000001011")); return b; break; }
01164 
01165     case  3 : { bitset<56> b(string("00000000000000000000000000000000000000000000000000000111")); return b; break; }
01166     case  2 : { bitset<56> b(string("00000000000000000000000000000000000000000000000000000011")); return b; break; }
01167 
01168     case  1 : { bitset<56> b(string("00000000000000000000000000000000000000000000000000000001")); return b; break; }
01169     case  0 : { bitset<56> b(string("00000000000000000000000000000000000000000000000000000000")); return b; break; }
01170     default : { bitset<56> b; return b; break; }
01171   
01172   }
01173 
01174 }