CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/L1Trigger/TextToDigi/src/SourceCardRouting.cc

Go to the documentation of this file.
00001 /*
00002   SourceCardRouting library
00003   Copyright Andrew Rose 2007
00004 */
00005 
00006 // Prototype class definition
00007 #include "SourceCardRouting.h"                  //hh"
00008 
00009 // File streams
00010 #include <iomanip>
00011 #include <iostream>
00012 #include <sstream>
00013 using namespace std;
00014 
00017   SourceCardRouting::SourceCardRouting(){
00018         //std::cout<<"Constructor"<<std::endl;
00019         }
00020 
00021   SourceCardRouting::~SourceCardRouting(){
00022         //std::cout<<"Destructor"<<std::endl;
00023         }
00026 //SFP arrays are SFP[cycle<2][sfp number<4]
00027 //electron arrays are eIsoRank[candidate number<4]
00028 //muon arrays are MIPbits[rec card number<7][region<2]
00029 
00030 void SourceCardRouting::EMUtoSFP(       unsigned short (&eIsoRank)[4],
00031                         unsigned short (&eIsoCardId)[4],
00032                         unsigned short (&eIsoRegionId)[4],
00033                         unsigned short (&eNonIsoRank)[4],
00034                         unsigned short (&eNonIsoCardId)[4],
00035                         unsigned short (&eNonIsoRegionId)[4],
00036                         unsigned short (&MIPbits)[7][2],
00037                         unsigned short (&Qbits)[7][2],
00038                         unsigned short (&SFP)[2][4] ) const{
00039 
00040 SFP[0][0]=0;
00041 SFP[1][0]=0x8000;
00042 
00043 for (int i=0;i<7;i++){
00044         for (int j=0;j<2;j++){
00045                 SFP[0][0] = SFP[0][0]|((MIPbits[i][j]&0x01)<<((2*i)+j) );
00046                 SFP[1][0] = SFP[1][0]|((Qbits[i][j]&0x01)<<((2*i)+j) );
00047         }
00048 }
00049 
00050         SFP[0][1] = (eIsoRank[0]&0x3f)|((eIsoRegionId[0]&0x01)<<6)|((eIsoCardId[0]&0x07)<<7)|((eIsoRank[1]&0x7)<<10);
00051         SFP[1][1] = 0x8000|(eIsoRank[2]&0x3f)|((eIsoRegionId[2]&0x01)<<6)|((eIsoCardId[2]&0x07)<<7)|((eIsoRank[3]&0x7)<<10);
00052         SFP[0][2] = (eNonIsoRank[0]&0x3f)|((eNonIsoRegionId[0]&0x01)<<6)|((eNonIsoCardId[0]&0x07)<<7)|((eIsoRank[1]&0x38)<<7)|((eIsoRegionId[1]&0x01)<<13);
00053         SFP[1][2] = 0x8000|(eNonIsoRank[2]&0x3f)|((eNonIsoRegionId[2]&0x01)<<6)|((eNonIsoCardId[2]&0x07)<<7)|((eIsoRank[3]&0x38)<<7)|((eIsoRegionId[3]&0x01)<<13);
00054         SFP[0][3] = (eNonIsoRank[1]&0x3f)|((eNonIsoRegionId[1]&0x01)<<6)|((eNonIsoCardId[1]&0x07)<<7)|((eIsoCardId[1]&0x07)<<10);
00055         SFP[1][3] = 0x8000|(eNonIsoRank[3]&0x3f)|((eNonIsoRegionId[3]&0x01)<<6)|((eNonIsoCardId[3]&0x07)<<7)|((eIsoCardId[3]&0x07)<<10);
00056 }
00057 
00059 //SFP arrays are SFP[cycle<2][sfp number<4]
00060 //electron arrays are eIsoRank[candidate number<4]
00061 //muon arrays are MIPbits[rec card number<7][region<2]
00062 
00063 void SourceCardRouting::SFPtoEMU(       unsigned short (&eIsoRank)[4],
00064                         unsigned short (&eIsoCardId)[4],
00065                         unsigned short (&eIsoRegionId)[4],
00066                         unsigned short (&eNonIsoRank)[4],
00067                         unsigned short (&eNonIsoCardId)[4],
00068                         unsigned short (&eNonIsoRegionId)[4],
00069                         unsigned short (&MIPbits)[7][2],
00070                         unsigned short (&Qbits)[7][2],
00071                         unsigned short (&SFP)[2][4] ) const{
00072 
00073 
00074           for (int i=0; i<7;i++){
00075                 for (int j=0; j<2;j++){
00076                         MIPbits[i][j] = (SFP[0][0]>>((2*i)+j) )&0x1;
00077                         Qbits[i][j] = (SFP[1][0]>>((2*i)+j) )&0x1;
00078                 }
00079           }
00080 
00081         eIsoRank[0] = SFP[0][1]&0x3f;
00082         eIsoRank[1] = ((SFP[0][1]>>10)&0x7)|((SFP[0][2]>>7)&0x38);
00083         eIsoRank[2] = SFP[1][1]&0x3f;
00084         eIsoRank[3] = ((SFP[1][1]>>10)&0x7)|((SFP[1][2]>>7)&0x38);
00085 
00086         eNonIsoRank[0] = SFP[0][2]&0x3f;
00087         eNonIsoRank[1] = SFP[0][3]&0x3f;
00088         eNonIsoRank[2] = SFP[1][2]&0x3f;
00089         eNonIsoRank[3] = SFP[1][3]&0x3f;
00090 
00091         eIsoRegionId[0] = (SFP[0][1]>>6)&0x1;
00092         eIsoRegionId[1] = (SFP[0][2]>>13)&0x1;
00093         eIsoRegionId[2] = (SFP[1][1]>>6)&0x1;
00094         eIsoRegionId[3] = (SFP[1][2]>>13)&0x1;
00095 
00096         eNonIsoRegionId[0] = (SFP[0][2]>>6)&0x1;
00097         eNonIsoRegionId[1] = (SFP[0][3]>>6)&0x1;
00098         eNonIsoRegionId[2] = (SFP[1][2]>>6)&0x1;
00099         eNonIsoRegionId[3] = (SFP[1][3]>>6)&0x1;
00100 
00101         eIsoCardId[0] = (SFP[0][1]>>7)&0x7;
00102         eIsoCardId[1] = (SFP[0][3]>>10)&0x7;
00103         eIsoCardId[2] = (SFP[1][1]>>7)&0x7;
00104         eIsoCardId[3] = (SFP[1][3]>>10)&0x7;
00105 
00106         eNonIsoCardId[0] = (SFP[0][2]>>7)&0x7;
00107         eNonIsoCardId[1] = (SFP[0][3]>>7)&0x7;
00108         eNonIsoCardId[2] = (SFP[1][2]>>7)&0x7;
00109         eNonIsoCardId[3] = (SFP[1][3]>>7)&0x7;
00110 
00111 }
00112 
00114 //RC arrays are RC[receiver card number<7][region<2]
00115 //HF arrays are HF[eta<4][HF region<2]
00116 //SFP arrays are SFP[cycle<2][sfp number<4]
00117  
00118 void SourceCardRouting::RC56HFtoSFP(    unsigned short (&RC)[7][2],
00119                         unsigned short (&RCof)[7][2],
00120                         unsigned short (&RCtau)[7][2],
00121                         unsigned short (&HF)[4][2],
00122                         unsigned short (&HFQ)[4][2],
00123                         unsigned short (&SFP)[2][4]) const{
00124 
00125         SFP[0][0] = (RC[5][0]&0x3ff)|((RCof[5][0]&0x1)<<10)|((RCtau[5][0]&0x1)<<11)|((HFQ[0][0]&0x1)<<12)|((HFQ[1][0]&0x01)<<13)|((HF[0][0]&0x01)<<14);
00126         SFP[1][0] = 0x8000|(RC[5][1]&0x3ff)|((RCof[5][1]&0x1)<<10)|((RCtau[5][1]&0x1)<<11)|((HFQ[2][0]&0x1)<<12)|((HFQ[3][0]&0x01)<<13)|((HF[2][0]&0x01)<<14);
00127         SFP[0][1] = (RC[6][0]&0x3ff)|((RCof[6][0]&0x1)<<10)|((RCtau[6][0]&0x1)<<11)|((HFQ[0][1]&0x1)<<12)|((HFQ[1][1]&0x01)<<13)|((HF[0][1]&0x01)<<14);
00128         SFP[1][1] = 0x8000|(RC[6][1]&0x3ff)|((RCof[6][1]&0x1)<<10)|((RCtau[6][1]&0x1)<<11)|((HFQ[2][1]&0x1)<<12)|((HFQ[3][1]&0x01)<<13)|((HF[2][1]&0x01)<<14);
00129         SFP[0][2] = ((HF[0][0]>>1)&0x7f)|((HF[1][0]&0xff)<<7);
00130         SFP[1][2] = 0x8000|((HF[2][0]>>1)&0x7f)|((HF[3][0]&0xff)<<7);
00131         SFP[0][3] = ((HF[0][1]>>1)&0x7f)|((HF[1][1]&0xff)<<7);
00132         SFP[1][3] = 0x8000|((HF[2][1]>>1)&0x7f)|((HF[3][1]&0xff)<<7);
00133 
00134 
00135 }
00136 
00138 //RC arrays are RC[receiver card number<7][region<2]
00139 //HF arrays are HF[eta<4][HF region<2]
00140 //SFP arrays are SFP[cycle<2][sfp number<4]
00141  
00142     void SourceCardRouting::SFPtoRC56HF(        unsigned short (&RC)[7][2],
00143                         unsigned short (&RCof)[7][2],
00144                         unsigned short (&RCtau)[7][2],
00145                         unsigned short (&HF)[4][2],
00146                         unsigned short (&HFQ)[4][2],
00147                         unsigned short (&SFP)[2][4]) const{
00148 
00149         RC[5][0]=SFP[0][0]&0x3ff;
00150         RC[5][1]=SFP[1][0]&0x3ff;
00151         RC[6][0]=SFP[0][1]&0x3ff;
00152         RC[6][1]=SFP[1][1]&0x3ff;
00153 
00154         RCof[5][0]=(SFP[0][0]>>10)&0x1;
00155         RCof[5][1]=(SFP[1][0]>>10)&0x1;
00156         RCof[6][0]=(SFP[0][1]>>10)&0x1;
00157         RCof[6][1]=(SFP[1][1]>>10)&0x1;
00158 
00159         RCtau[5][0]=(SFP[0][0]>>11)&0x1;
00160         RCtau[5][1]=(SFP[1][0]>>11)&0x1;
00161         RCtau[6][0]=(SFP[0][1]>>11)&0x1;
00162         RCtau[6][1]=(SFP[1][1]>>11)&0x1;
00163 
00164         HFQ[0][0]=(SFP[0][0]>>12)&0x1;
00165         HFQ[1][0]=(SFP[0][0]>>13)&0x1;
00166         HFQ[2][0]=(SFP[1][0]>>12)&0x1;
00167         HFQ[3][0]=(SFP[1][0]>>13)&0x1;
00168 
00169         HFQ[0][1]=(SFP[0][1]>>12)&0x1;
00170         HFQ[1][1]=(SFP[0][1]>>13)&0x1;
00171         HFQ[2][1]=(SFP[1][1]>>12)&0x1;
00172         HFQ[3][1]=(SFP[1][1]>>13)&0x1;
00173 
00174         HF[0][0]=((SFP[0][2]&0x7f)<<1)|((SFP[0][0]>>14)&0x01);
00175         HF[1][0]=(SFP[0][2]>>7)&0xff;
00176         HF[2][0]=((SFP[1][2]&0x7f)<<1)|((SFP[1][0]>>14)&0x01);
00177         HF[3][0]=(SFP[1][2]>>7)&0xff;
00178 
00179         HF[0][1]=((SFP[0][3]&0x7f)<<1)|((SFP[0][1]>>14)&0x01);
00180         HF[1][1]=(SFP[0][3]>>7)&0xff;
00181         HF[2][1]=((SFP[1][3]&0x7f)<<1)|((SFP[1][1]>>14)&0x01);
00182         HF[3][1]=(SFP[1][3]>>7)&0xff;
00183 
00184 }
00185 
00187 //RC arrays are RC[receiver card number<7][region<2]
00188 //SFP arrays are SFP[cycle<2][sfp number<4]
00189  
00190     void SourceCardRouting::RC012toSFP( unsigned short (&RC)[7][2],
00191                         unsigned short (&RCof)[7][2],
00192                         unsigned short (&RCtau)[7][2],
00193                         unsigned short (&SFP)[2][4]) const{
00194 
00195         SFP[0][0] = (RC[0][0]&0x3ff)|((RCof[0][0]&0x1)<<10)|((RCtau[0][0]&0x1)<<11)|((RC[2][0]&0x7)<<12);
00196         SFP[1][0] = 0x8000|(RC[0][1]&0x3ff)|((RCof[0][1]&0x1)<<10)|((RCtau[0][1]&0x1)<<11)|((RC[2][1]&0x7)<<12);
00197 
00198         SFP[0][1] = (RC[1][0]&0x3ff)|((RCof[1][0]&0x1)<<10)|((RCtau[1][0]&0x1)<<11)|((RC[2][0]&0x38)<<9);
00199         SFP[1][1] = 0x8000|(RC[1][1]&0x3ff)|((RCof[1][1]&0x1)<<10)|((RCtau[1][1]&0x1)<<11)|((RC[2][1]&0x38)<<9);
00200 
00201         SFP[0][2] = (RC[0][0]&0x3ff)|((RCof[0][0]&0x1)<<10)|((RCtau[0][0]&0x1)<<11);
00202         SFP[1][2] = 0x8000|(RC[0][1]&0x3ff)|((RCof[0][1]&0x1)<<10)|((RCtau[0][1]&0x1)<<11);
00203 
00204         SFP[0][3] = (RC[1][0]&0x3ff)|((RCof[1][0]&0x1)<<10)|((RCtau[1][0]&0x1)<<11);
00205         SFP[1][3] = 0x8000|(RC[1][1]&0x3ff)|((RCof[1][1]&0x1)<<10)|((RCtau[1][1]&0x1)<<11);
00206 
00207 }
00208 
00210 //RC arrays are RC[receiver card number<7][region<2]
00211 //SFP arrays are SFP[cycle<2][sfp number<4]
00212  
00213     void SourceCardRouting::SFPtoRC012( unsigned short (&RC)[7][2],
00214                         unsigned short (&RCof)[7][2],
00215                         unsigned short (&RCtau)[7][2],
00216                         unsigned short (&SFP)[2][4]) const{
00217 
00218         RC[0][0]=SFP[0][0]&0x3ff;
00219         RC[0][1]=SFP[1][0]&0x3ff;
00220         RC[1][0]=SFP[0][1]&0x3ff;
00221         RC[1][1]=SFP[1][1]&0x3ff;
00222         RC[2][0]=(RC[2][0]&0x3c0)|((SFP[0][0]&0x7000)>>12)|((SFP[0][1]&0x7000)>>9);
00223         RC[2][1]=(RC[2][1]&0x3c0)|((SFP[1][0]&0x7000)>>12)|((SFP[1][1]&0x7000)>>9);
00224 
00225         RCof[0][0]=(SFP[0][0]>>10)&0x1;
00226         RCof[0][1]=(SFP[1][0]>>10)&0x1;
00227         RCof[1][0]=(SFP[0][1]>>10)&0x1;
00228         RCof[1][1]=(SFP[1][1]>>10)&0x1;
00229 
00230         RCtau[0][0]=(SFP[0][0]>>11)&0x1;
00231         RCtau[0][1]=(SFP[1][0]>>11)&0x1;
00232         RCtau[1][0]=(SFP[0][1]>>11)&0x1;
00233         RCtau[1][1]=(SFP[1][1]>>11)&0x1;
00234 
00235 
00236 }
00237 
00239 //RC arrays are RC[receiver card number<7][region<2]
00240 //SFP arrays are SFP[cycle<2][sfp number<4]
00241  
00242     void SourceCardRouting::RC234toSFP( unsigned short (&RC)[7][2],
00243                         unsigned short (&RCof)[7][2],
00244                         unsigned short (&RCtau)[7][2],
00245                         unsigned short (&sisterRC)[7][2],
00246                         unsigned short (&sisterRCof)[7][2],
00247                         unsigned short (&sisterRCtau)[7][2],
00248                         unsigned short (&SFP)[2][4]) const{
00249 
00250         SFP[0][0] = (RC[3][0]&0x3ff)|((RCof[3][0]&0x1)<<10)|((RCtau[3][0]&0x1)<<11)|((RC[2][0]&0x1c0)<<6);
00251         SFP[1][0] = 0x8000|(RC[3][1]&0x3ff)|((RCof[3][1]&0x1)<<10)|((RCtau[3][1]&0x1)<<11)|((RC[2][1]&0x1c0)<<6);
00252 
00253         SFP[0][1] = (RC[4][0]&0x3ff)|((RCof[4][0]&0x1)<<10)|((RCtau[4][0]&0x1)<<11)|((RC[2][0]&0x200)<<3)|((RCof[2][0]&0x1)<<13)|((RCtau[2][0]&0x1)<<14);
00254         SFP[1][1] = 0x8000|(RC[4][1]&0x3ff)|((RCof[4][1]&0x1)<<10)|((RCtau[4][1]&0x1)<<11)|((RC[2][1]&0x200)<<3)|((RCof[2][1]&0x1)<<13)|((RCtau[2][1]&0x1)<<14);
00255 
00256         SFP[0][2] = (sisterRC[3][0]&0x3ff)|((sisterRCof[3][0]&0x1)<<10)|((sisterRCtau[3][0]&0x1)<<11)|((sisterRC[2][0]&0x1c0)<<6);
00257         SFP[1][2] = 0x8000|(sisterRC[3][1]&0x3ff)|((sisterRCof[3][1]&0x1)<<10)|((sisterRCtau[3][1]&0x1)<<11)|((sisterRC[2][1]&0x1c0)<<6);
00258 
00259         SFP[0][3] = (sisterRC[4][0]&0x3ff)|((sisterRCof[4][0]&0x1)<<10)|((sisterRCtau[4][0]&0x1)<<11)|((sisterRC[2][0]&0x200)<<3)|((sisterRCof[2][0]&0x1)<<13)|((sisterRCtau[2][0]&0x1)<<14);
00260         SFP[1][3] = 0x8000|(sisterRC[4][1]&0x3ff)|((sisterRCof[4][1]&0x1)<<10)|((sisterRCtau[4][1]&0x1)<<11)|((sisterRC[2][1]&0x200)<<3)|((sisterRCof[2][1]&0x1)<<13)|((sisterRCtau[2][1]&0x1)<<14);
00261 
00262 }
00263 
00265 //RC arrays are RC[receiver card number<7][region<2]
00266 //SFP arrays are SFP[cycle<2][sfp number<4]
00267  
00268      void SourceCardRouting::SFPtoRC234(        unsigned short (&RC)[7][2],
00269                         unsigned short (&RCof)[7][2],
00270                         unsigned short (&RCtau)[7][2],
00271                         unsigned short (&sisterRC)[7][2],
00272                         unsigned short (&sisterRCof)[7][2],
00273                         unsigned short (&sisterRCtau)[7][2],
00274                         unsigned short (&SFP)[2][4]) const{
00275 
00276         RC[2][0]=(RC[2][0]&0x3f)|((SFP[0][0]&0x7000)>>6)|((SFP[0][1]&0x1000)>>3);
00277         RC[3][0]=SFP[0][0]&0x3ff;
00278         RC[4][0]=SFP[0][1]&0x3ff;
00279         RC[2][1]=(RC[2][1]&0x3f)|((SFP[1][0]&0x7000)>>6)|((SFP[1][1]&0x1000)>>3);
00280         RC[3][1]=SFP[1][0]&0x3ff;
00281         RC[4][1]=SFP[1][1]&0x3ff;
00282 
00283         RCof[2][0]=(SFP[0][1]>>13)&0x1;
00284         RCof[3][0]=(SFP[0][0]>>10)&0x1;
00285         RCof[4][0]=(SFP[0][1]>>10)&0x1;
00286         RCof[2][1]=(SFP[1][1]>>13)&0x1;
00287         RCof[3][1]=(SFP[1][0]>>10)&0x1;
00288         RCof[4][1]=(SFP[1][1]>>10)&0x1;
00289 
00290         RCtau[2][0]=(SFP[0][1]>>14)&0x1;
00291         RCtau[3][0]=(SFP[0][0]>>11)&0x1;
00292         RCtau[4][0]=(SFP[0][1]>>11)&0x1;
00293         RCtau[2][1]=(SFP[1][1]>>14)&0x1;
00294         RCtau[3][1]=(SFP[1][0]>>11)&0x1;
00295         RCtau[4][1]=(SFP[1][1]>>11)&0x1;
00296 
00297         sisterRC[2][0]=(sisterRC[2][0]&~0x3C0)|((SFP[0][2]&0x7000)>>6)|((SFP[0][3]&0x1000)>>3);
00298         sisterRC[3][0]=SFP[0][2]&0x3ff;
00299         sisterRC[4][0]=SFP[0][3]&0x3ff;
00300         sisterRC[2][1]=(sisterRC[2][1]&~0x3C0)|((SFP[1][2]&0x7000)>>6)|((SFP[1][3]&0x1000)>>3);
00301         sisterRC[3][1]=SFP[1][2]&0x3ff;
00302         sisterRC[4][1]=SFP[1][3]&0x3ff;
00303 
00304         sisterRCof[2][0]=(SFP[0][3]>>13)&0x1;
00305         sisterRCof[3][0]=(SFP[0][2]>>10)&0x1;
00306         sisterRCof[4][0]=(SFP[0][3]>>10)&0x1;
00307         sisterRCof[2][1]=(SFP[1][3]>>13)&0x1;
00308         sisterRCof[3][1]=(SFP[1][2]>>10)&0x1;
00309         sisterRCof[4][1]=(SFP[1][3]>>10)&0x1;
00310 
00311         sisterRCtau[2][0]=(SFP[0][3]>>14)&0x1;
00312         sisterRCtau[3][0]=(SFP[0][2]>>11)&0x1;
00313         sisterRCtau[4][0]=(SFP[0][3]>>11)&0x1;
00314         sisterRCtau[2][1]=(SFP[1][3]>>14)&0x1;
00315         sisterRCtau[3][1]=(SFP[1][2]>>11)&0x1;
00316         sisterRCtau[4][1]=(SFP[1][3]>>11)&0x1;
00317 
00318 }
00319 
00320 
00323 //VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
00324 //SFP arrays are SFP[cycle<2][sfp number<4]
00325 
00326     void SourceCardRouting::SFPtoVHDCI( int RoutingMode,
00327                         unsigned short (&SFP)[2][4],
00328                         unsigned long (&VHDCI)[2][2] ) const{
00329 
00330 unsigned short sfp_reverse[2][4]={{0}};
00331 
00332 for (int i=0; i<2;i++){
00333         for(int j=0; j<4;j++){
00334                 for (int k=0; k<16;k++){
00335                         sfp_reverse[i][j]=sfp_reverse[i][j]|(((SFP[i][j]>>k)&0x01)<<(15-k));
00336                 }
00337                 //std::cout <<hex<< SFP[i][j]<<'\t'<<sfp_reverse[i][j]<<std::endl;
00338         }
00339 }
00340 
00341         switch (RoutingMode){
00342                 case 0:
00343                         VHDCI[0][0]=(SFP[0][1]&0x3ff)|((SFP[0][1]&0x1c00)<<1)|((SFP[0][2]&0x3c00)<<4)|((SFP[0][3]&0x1c00)<<8)|((SFP[0][0]&0xff)<<22);
00344                         VHDCI[0][1]=(SFP[1][1]&0x3ff)|((SFP[1][1]&0x1c00)<<1)|((SFP[1][2]&0x3c00)<<4)|((SFP[1][3]&0x1c00)<<8)|((SFP[1][0]&0xff)<<22);
00345                         VHDCI[1][0]=(SFP[0][2]&0x3ff)|((SFP[0][3]&0x3ff)<<11)|((SFP[0][0]&0x3f00)<<14);
00346                         VHDCI[1][1]=(SFP[1][2]&0x3ff)|((SFP[1][3]&0x3ff)<<11)|((SFP[1][0]&0x3f00)<<14);
00347                 break;
00348                 case 1:
00349                         VHDCI[0][0]=(SFP[0][0]&0xfff)|((SFP[0][1]&0x7)<<12)|((SFP[0][2]&0x80)<<10)|((SFP[0][0]&0x4000)<<4)|((sfp_reverse[0][1]&0xc)<<17)|((sfp_reverse[0][0]&0xc)<<19)|((sfp_reverse[0][1]&0x1ff0)<<19);
00350                         VHDCI[0][1]=(SFP[1][0]&0xfff)|((SFP[1][1]&0x7)<<12)|((SFP[1][2]&0x80)<<10)|((SFP[1][0]&0x4000)<<4)|((sfp_reverse[1][1]&0xc)<<17)|((sfp_reverse[1][0]&0xc)<<19)|((sfp_reverse[1][1]&0x1ff0)<<19);
00351 
00352                         VHDCI[1][0]=(SFP[0][1]&0x4000)|((SFP[0][3]&0x80)<<24);
00353                         VHDCI[1][1]=(SFP[1][1]&0x4000)|((SFP[1][3]&0x80)<<24);
00354 
00355                         for (int i=0; i<7;i++){
00356                                 VHDCI[1][0]=VHDCI[1][0]|(((SFP[0][2]>>i)&0x1)<<(2*i))|(((SFP[0][2]>>(i+8))&0x1)<<((2*i)+1))|(((sfp_reverse[0][3]>>(i+1))&0x1)<<((2*i)+17))|(((sfp_reverse[0][3]>>(i+9))&0x1)<<((2*i)+18));
00357                                 VHDCI[1][1]=VHDCI[1][1]|(((SFP[1][2]>>i)&0x1)<<(2*i))|(((SFP[1][2]>>(i+8))&0x1)<<((2*i)+1))|(((sfp_reverse[1][3]>>(i+1))&0x1)<<((2*i)+17))|(((sfp_reverse[1][3]>>(i+9))&0x1)<<((2*i)+18));              
00358                         }
00359                 break;
00360                 case 2:
00361                         VHDCI[0][0]=(SFP[0][0]&0xfff)|((SFP[0][1]&0x7)<<12)|((sfp_reverse[0][1]&0xe)<<16)|((sfp_reverse[0][0]&0xe)<<19)|((sfp_reverse[0][1]&0x1ff0)<<19);
00362                         VHDCI[0][1]=(SFP[1][0]&0xfff)|((SFP[1][1]&0x7)<<12)|((sfp_reverse[1][1]&0xe)<<16)|((sfp_reverse[1][0]&0xe)<<19)|((sfp_reverse[1][1]&0x1ff0)<<19);
00363                         VHDCI[1][0]=0;
00364                         VHDCI[1][1]=0;
00365                 break;
00366                 case 3:
00367                         VHDCI[0][0]=((SFP[0][0]>>12)&0x7)|((SFP[0][1]>>9)&0x38)|((SFP[0][0]&0x1ff)<<6)|((sfp_reverse[0][1]&0xfff0)<<13)|((sfp_reverse[0][0]&0x70)<<25);
00368                         VHDCI[0][1]=((SFP[1][0]>>12)&0x7)|((SFP[1][1]>>9)&0x38)|((SFP[1][0]&0x1ff)<<6)|((sfp_reverse[1][1]&0xfff0)<<13)|((sfp_reverse[1][0]&0x70)<<25);
00369 
00370                         VHDCI[1][0]=((SFP[0][2]>>12)&0x7)|((SFP[0][3]>>9)&0x38)|((SFP[0][2]&0x1ff)<<6)|((sfp_reverse[0][3]&0xfff0)<<13)|((sfp_reverse[0][2]&0x70)<<25);
00371                         VHDCI[1][1]=((SFP[1][2]>>12)&0x7)|((SFP[1][3]>>9)&0x38)|((SFP[1][2]&0x1ff)<<6)|((sfp_reverse[1][3]&0xfff0)<<13)|((sfp_reverse[1][2]&0x70)<<25);
00372                 break;
00373                 default:
00374                         VHDCI[0][0]=0;
00375                         VHDCI[0][1]=0;
00376                         VHDCI[1][0]=0;
00377                         VHDCI[1][1]=0;
00378                 }
00379 
00380 }
00381 
00383 //VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
00384 //SFP arrays are SFP[cycle<2][sfp number<4]
00385     void SourceCardRouting::VHDCItoSFP( int RoutingMode,
00386                         unsigned short (&SFP)[2][4],
00387                         unsigned long (&VHDCI)[2][2]    ) const{
00388 
00389 unsigned short VHDCI_reverse[2][4]={{0}};
00390 
00391 for (int i=0; i<2;i++){
00392         for(int j=0; j<2;j++){
00393                 for (int k=0; k<32;k++){
00394                         VHDCI_reverse[i][j]=VHDCI_reverse[i][j]|(((VHDCI[i][j]>>k)&0x01)<<(31-k));
00395                 }
00396         }
00397 }
00398 
00399         switch (RoutingMode){
00400                 case 0:
00401                         SFP[0][0]=((VHDCI[0][0]>>22)&0xff)|((VHDCI[1][0]>>14)&0x3f00);
00402                         SFP[1][0]=0x8000|((VHDCI[0][1]>>22)&0xff)|((VHDCI[1][1]>>14)&0x3f00);
00403                         SFP[0][1]=(VHDCI[0][0]&0x3ff)|((VHDCI[0][0]>>1)&0x1c00);
00404                         SFP[1][1]=0x8000|(VHDCI[0][1]&0x3ff)|((VHDCI[0][1]>>1)&0x1c00);
00405                         SFP[0][2]=(VHDCI[1][0]&0x3ff)|((VHDCI[0][0]>>4)&0x3c00);
00406                         SFP[1][2]=0x8000|(VHDCI[1][1]&0x3ff)|((VHDCI[0][1]>>4)&0x3c00);
00407                         SFP[0][3]=((VHDCI[1][0]>>11)&0x3ff)|((VHDCI[0][0]>>8)&0x1c00);
00408                         SFP[1][3]=0x8000|((VHDCI[1][1]>>11)&0x3ff)|((VHDCI[0][1]>>8)&0x1c00);
00409                 break;
00410                 case 1:
00411                         SFP[0][0]=(VHDCI[0][0]&0xfff)|((VHDCI_reverse[0][0]&0x600)<<3)|((VHDCI_reverse[0][0]&0x2000)<<1);
00412                         SFP[1][0]=0x8000|(VHDCI[0][1]&0xfff)|((VHDCI_reverse[0][1]&0x600)<<3)|((VHDCI_reverse[0][1]&0x2000)<<1);
00413                         SFP[0][1]=((VHDCI[0][0]&0x7000)>>12)|((VHDCI_reverse[0][0]&0x1ff)<<3)|((VHDCI_reverse[0][0]&0x1800)<<1)|(VHDCI[1][0]&0x4000);
00414                         SFP[1][1]=0x8000|((VHDCI[0][1]&0x7000)>>12)|((VHDCI_reverse[0][1]&0x1ff)<<3)|((VHDCI_reverse[0][1]&0x1800)<<1)|(VHDCI[1][1]&0x4000);
00415 
00416                         SFP[0][2]=((VHDCI[0][0]&0x20000)>>10);
00417                         SFP[1][2]=0x8000|((VHDCI[0][1]&0x20000)>>10);
00418                         SFP[0][3]=((VHDCI[1][0]&0x20000)>>3);
00419                         SFP[1][3]=0x8000|((VHDCI[1][1]&0x20000)>>3);
00420                         for (int i=0; i<7;i++){
00421                                 SFP[0][2]=SFP[0][2]|(((VHDCI[1][0]>>(2*i))&0x1)<<i)|(((VHDCI[1][0]>>((2*i)+1))&0x1)<<(i+8));
00422                                 SFP[1][2]=SFP[1][2]|(((VHDCI[1][1]>>(2*i))&0x1)<<i)|(((VHDCI[1][1]>>((2*i)+1))&0x1)<<(i+8));
00423                                 SFP[0][3]=SFP[0][3]|(((VHDCI_reverse[1][0]>>((2*i)+1))&0x1)<<i)|(((VHDCI_reverse[1][0]>>(2*i))&0x1)<<(i+7));
00424                                 SFP[1][3]=SFP[1][3]|(((VHDCI_reverse[1][1]>>((2*i)+1))&0x1)<<i)|(((VHDCI_reverse[1][1]>>(2*i))&0x1)<<(i+7));
00425                         }
00426                 break;
00427                 case 2:
00428                         SFP[0][0]=(VHDCI[0][0]&0xfff)|((VHDCI_reverse[0][0]&0xe00)<<3);
00429                         SFP[1][0]=0x8000|(VHDCI[0][1]&0xfff)|((VHDCI_reverse[0][1]&0xe00)<<3);
00430                         SFP[0][1]=((VHDCI[0][0]&0x7000)>>12)|((VHDCI_reverse[0][0]&0x1ff)<<3)|(VHDCI_reverse[0][0]&0x7000);
00431                         SFP[1][1]=0x8000|((VHDCI[0][1]&0x7000)>>12)|((VHDCI_reverse[0][1]&0x1ff)<<3)|(VHDCI_reverse[0][1]&0x7000);
00432                         SFP[0][2]=(VHDCI[0][0]&0xfff);
00433                         SFP[1][2]=0x8000|(VHDCI[0][1]&0xfff);
00434                         SFP[0][3]=((VHDCI[0][0]&0x7000)>>12)|((VHDCI_reverse[0][0]&0x1ff)<<3);
00435                         SFP[1][3]=0x8000|((VHDCI[0][1]&0x7000)>>12)|((VHDCI_reverse[0][1]&0x1ff)<<3);
00436                 break;
00437                 case 3:
00438                         SFP[0][0]=((VHDCI[0][0]&0x7fc0)>>6)|((VHDCI_reverse[0][0]&0x7)<<9)|((VHDCI[0][0]&0x7)<<12);
00439                         SFP[1][0]=0x8000|((VHDCI[0][1]&0x7fc0)>>6)|((VHDCI_reverse[0][1]&0x7)<<9)|((VHDCI[0][1]&0x7)<<12);
00440                         SFP[0][1]=((VHDCI_reverse[0][0]&0x7ff8)>>3)|((VHDCI[0][0]&0x38)<<9);
00441                         SFP[1][1]=0x8000|((VHDCI_reverse[0][1]&0x7ff8)>>3)|((VHDCI[0][1]&0x38)<<9);
00442                         SFP[0][2]=((VHDCI[1][0]&0x7fc0)>>6)|((VHDCI_reverse[1][0]&0x7)<<9)|((VHDCI[1][0]&0x7)<<12);
00443                         SFP[1][2]=0x8000|((VHDCI[1][1]&0x7fc0)>>6)|((VHDCI_reverse[1][1]&0x7)<<9)|((VHDCI[1][1]&0x7)<<12);
00444                         SFP[0][3]=((VHDCI_reverse[1][0]&0x7ff8)>>3)|((VHDCI[1][0]&0x38)<<9);
00445                         SFP[1][3]=0x8000|((VHDCI_reverse[1][1]&0x7ff8)>>3)|((VHDCI[1][1]&0x38)<<9);
00446                 break;
00447                 default:
00448                         SFP[0][0]=0;
00449                         SFP[1][0]=0x8000;
00450                         SFP[0][1]=0;
00451                         SFP[1][1]=0x8000;
00452                         SFP[0][2]=0;
00453                         SFP[1][2]=0x8000;
00454                         SFP[0][3]=0;
00455                         SFP[1][3]=0x8000;
00456                 }
00457 }
00458   
00461 //VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
00462 //electron arrays are eIsoRank[candidate number<4]
00463 //muon arrays are MIPbits[rec card number<7][region<2]
00464 
00465     void SourceCardRouting::EMUtoVHDCI( unsigned short (&eIsoRank)[4],
00466                         unsigned short (&eIsoCardId)[4],
00467                         unsigned short (&eIsoRegionId)[4],
00468                         unsigned short (&eNonIsoRank)[4],
00469                         unsigned short (&eNonIsoCardId)[4],
00470                         unsigned short (&eNonIsoRegionId)[4],
00471                         unsigned short (&MIPbits)[7][2],
00472                         unsigned short (&Qbits)[7][2],
00473                         unsigned long (&VHDCI)[2][2] ) const{
00474 
00475         unsigned short SFP[2][4]={{0}};
00476         EMUtoSFP(eIsoRank,eIsoCardId,eIsoRegionId,eNonIsoRank,eNonIsoCardId,eNonIsoRegionId,MIPbits,Qbits,SFP);
00477         SFPtoVHDCI(0,SFP,VHDCI);
00478 
00479 }
00480 
00482 //VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
00483 //electron arrays are eIsoRank[candidate number<4]
00484 //muon arrays are MIPbits[rec card number<7][region<2]
00485 
00486     void SourceCardRouting::VHDCItoEMU( unsigned short (&eIsoRank)[4],
00487                         unsigned short (&eIsoCardId)[4],
00488                         unsigned short (&eIsoRegionId)[4],
00489                         unsigned short (&eNonIsoRank)[4],
00490                         unsigned short (&eNonIsoCardId)[4],
00491                         unsigned short (&eNonIsoRegionId)[4],
00492                         unsigned short (&MIPbits)[7][2],
00493                         unsigned short (&Qbits)[7][2],
00494                         unsigned long (&VHDCI)[2][2] ) const{
00495 
00496         unsigned short SFP[2][4]={{0}};
00497         VHDCItoSFP(0,SFP,VHDCI);
00498         SFPtoEMU(eIsoRank,eIsoCardId,eIsoRegionId,eNonIsoRank,eNonIsoCardId,eNonIsoRegionId,MIPbits,Qbits,SFP);
00499 
00500 }
00501 
00502 
00503 
00504 
00505 
00507 //RC arrays are RC[receiver card number<7][region<2]
00508 //HF arrays are HF[eta<4][HF region<2]
00509 //VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
00510  
00511     void SourceCardRouting::RC56HFtoVHDCI(      unsigned short (&RC)[7][2],
00512                         unsigned short (&RCof)[7][2],
00513                         unsigned short (&RCtau)[7][2],
00514                         unsigned short (&HF)[4][2],
00515                         unsigned short (&HFQ)[4][2],
00516                         unsigned long (&VHDCI)[2][2] ) const{
00517 
00518         unsigned short SFP[2][4]={{0}};
00519         RC56HFtoSFP(RC,RCof,RCtau,HF,HFQ,SFP);
00520         SFPtoVHDCI(1,SFP,VHDCI);
00521 
00522 }
00523 
00525 //RC arrays are RC[receiver card number<7][region<2]
00526 //HF arrays are HF[eta<4][HF region<2]
00527 //VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
00528  
00529     void SourceCardRouting::VHDCItoRC56HF(      unsigned short (&RC)[7][2],
00530                         unsigned short (&RCof)[7][2],
00531                         unsigned short (&RCtau)[7][2],
00532                         unsigned short (&HF)[4][2],
00533                         unsigned short (&HFQ)[4][2],
00534                         unsigned long (&VHDCI)[2][2] ) const{
00535 
00536         unsigned short SFP[2][4]={{0}};
00537         VHDCItoSFP(1,SFP,VHDCI);
00538         SFPtoRC56HF(RC,RCof,RCtau,HF,HFQ,SFP);
00539 
00540 }
00541 
00543 //RC arrays are RC[receiver card number<7][region<2]
00544 //VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
00545  
00546     void SourceCardRouting::RC012toVHDCI(       unsigned short (&RC)[7][2],
00547                         unsigned short (&RCof)[7][2],
00548                         unsigned short (&RCtau)[7][2],
00549                         unsigned long (&VHDCI)[2][2] ) const{
00550 
00551         unsigned short SFP[2][4]={{0}};
00552         RC012toSFP(RC,RCof,RCtau,SFP);
00553         SFPtoVHDCI(2,SFP,VHDCI);
00554 }
00555 
00557 //RC arrays are RC[receiver card number<7][region<2]
00558 //VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
00559  
00560     void SourceCardRouting::VHDCItoRC012(       unsigned short (&RC)[7][2],
00561                         unsigned short (&RCof)[7][2],
00562                         unsigned short (&RCtau)[7][2],
00563                         unsigned long (&VHDCI)[2][2] ) const{
00564 
00565         unsigned short SFP[2][4]={{0}};
00566         VHDCItoSFP(2,SFP,VHDCI);
00567         SFPtoRC012(RC,RCof,RCtau,SFP);
00568 
00569 }
00570 
00572 //RC arrays are RC[receiver card number<7][region<2]
00573 //VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
00574  
00575     void SourceCardRouting::RC234toVHDCI(       unsigned short (&RC)[7][2],
00576                         unsigned short (&RCof)[7][2],
00577                         unsigned short (&RCtau)[7][2],
00578                         unsigned short (&sisterRC)[7][2],
00579                         unsigned short (&sisterRCof)[7][2],
00580                         unsigned short (&sisterRCtau)[7][2],
00581                         unsigned long (&VHDCI)[2][2] ) const{
00582 
00583         unsigned short SFP[2][4]={{0}};
00584         RC234toSFP(RC,RCof,RCtau,sisterRC,sisterRCof,sisterRCtau,SFP);
00585         SFPtoVHDCI(3,SFP,VHDCI);
00586 
00587 }
00588 
00590 //RC arrays are RC[receiver card number<7][region<2]
00591 //VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
00592  
00593      void SourceCardRouting::VHDCItoRC234(      unsigned short (&RC)[7][2],
00594                         unsigned short (&RCof)[7][2],
00595                         unsigned short (&RCtau)[7][2],
00596                         unsigned short (&sisterRC)[7][2],
00597                         unsigned short (&sisterRCof)[7][2],
00598                         unsigned short (&sisterRCtau)[7][2],
00599                         unsigned long (&VHDCI)[2][2] ) const{
00600 
00601         unsigned short SFP[2][4]={{0}};
00602         VHDCItoSFP(3,SFP,VHDCI);
00603         SFPtoRC234(RC,RCof,RCtau,sisterRC,sisterRCof,sisterRCtau,SFP);
00604 
00605 }
00606 
00609 //electron arrays are eIsoRank[candidate number<4]
00610 //muon arrays are MIPbits[rec card number<7][region<2]
00611 
00612     void SourceCardRouting::EMUtoSTRING(        unsigned short &logicalCardID,
00613                         unsigned short &eventNumber,
00614                         unsigned short (&eIsoRank)[4],
00615                         unsigned short (&eIsoCardId)[4],
00616                         unsigned short (&eIsoRegionId)[4],
00617                         unsigned short (&eNonIsoRank)[4],
00618                         unsigned short (&eNonIsoCardId)[4],
00619                         unsigned short (&eNonIsoRegionId)[4],
00620                         unsigned short (&MIPbits)[7][2],
00621                         unsigned short (&Qbits)[7][2],
00622                         std::string &dataString ) const{
00623 
00624                 unsigned long VHDCI[2][2]={{0}};
00625                 EMUtoVHDCI(eIsoRank,eIsoCardId,eIsoRegionId,eNonIsoRank,eNonIsoCardId,eNonIsoRegionId,MIPbits,Qbits,VHDCI);
00626                 VHDCItoSTRING (logicalCardID, eventNumber, dataString, VHDCI);
00627 
00628 }
00629 
00631 //RC arrays are RC[receiver card number<7][region<2]
00632 //HF arrays are HF[eta<4][HF region<2]
00633 
00634  
00635     void SourceCardRouting::RC56HFtoSTRING(     unsigned short &logicalCardID,
00636                         unsigned short &eventNumber,
00637                         unsigned short (&RC)[7][2],
00638                         unsigned short (&RCof)[7][2],
00639                         unsigned short (&RCtau)[7][2],
00640                         unsigned short (&HF)[4][2],
00641                         unsigned short (&HFQ)[4][2],
00642                         std::string &dataString ) const{
00643 
00644                 unsigned long VHDCI[2][2]={{0}};
00645                 RC56HFtoVHDCI(RC,RCof,RCtau,HF,HFQ,VHDCI);
00646                 VHDCItoSTRING (logicalCardID, eventNumber, dataString, VHDCI);
00647 
00648 }
00649 
00651 //RC arrays are RC[receiver card number<7][region<2]
00652 
00653  
00654     void SourceCardRouting::RC012toSTRING(      unsigned short &logicalCardID,
00655                         unsigned short &eventNumber,
00656                         unsigned short (&RC)[7][2],
00657                         unsigned short (&RCof)[7][2],
00658                         unsigned short (&RCtau)[7][2],
00659                         std::string &dataString ) const{
00660 
00661                 unsigned long VHDCI[2][2]={{0}};
00662                 RC012toVHDCI(RC,RCof,RCtau,VHDCI);
00663                 VHDCItoSTRING (logicalCardID, eventNumber, dataString, VHDCI);
00664 
00665 }
00666 
00668 //RC arrays are RC[receiver card number<7][region<2]
00669 
00670  
00671     void SourceCardRouting::RC234toSTRING(      unsigned short &logicalCardID,
00672                         unsigned short &eventNumber,
00673                         unsigned short (&RC)[7][2],
00674                         unsigned short (&RCof)[7][2],
00675                         unsigned short (&RCtau)[7][2],
00676                         unsigned short (&sisterRC)[7][2],
00677                         unsigned short (&sisterRCof)[7][2],
00678                         unsigned short (&sisterRCtau)[7][2],
00679                         std::string &dataString ) const{
00680 
00681                 unsigned long VHDCI[2][2]={{0}};
00682                 RC234toVHDCI(RC,RCof,RCtau,sisterRC,sisterRCof,sisterRCtau,VHDCI);
00683                 VHDCItoSTRING (logicalCardID, eventNumber, dataString, VHDCI);
00684 
00685 }
00686 
00687 
00690 //SFP arrays are SFP[cycle<2][sfp number<4]
00691     void SourceCardRouting::SFPtoSTRING(        unsigned short &logicalCardID,
00692                         unsigned short &eventNumber,
00693                         int RoutingMode,
00694                         unsigned short (&SFP)[2][4],
00695                         std::string &dataString ) const{
00696 
00697                 unsigned long VHDCI[2][2]={{0}};
00698                 SFPtoVHDCI(RoutingMode,SFP,VHDCI);
00699                 VHDCItoSTRING (logicalCardID, eventNumber, dataString, VHDCI);
00700 
00701 }
00702 
00703 
00706 //VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
00707     void SourceCardRouting::STRINGtoVHDCI(      unsigned short &logicalCardID,
00708                         unsigned short &eventNumber,
00709                         std::string &dataString,
00710                         unsigned long (&VHDCI)[2][2]    ) const{
00711 
00712                 stringstream temp;
00713                 
00714                 if (dataString!=""){
00715                         temp << dataString << std::endl;
00716                         temp >> dec >> eventNumber;
00717                         temp >> dec >> logicalCardID;
00718                         temp >> hex >> VHDCI[0][0];
00719                         temp >> hex >> VHDCI[0][1];
00720                         temp >> hex >> VHDCI[1][0];
00721                         temp >> hex >> VHDCI[1][1];
00722                 }else{
00723                         eventNumber=65535;
00724                         logicalCardID=65535;
00725                         VHDCI[0][0]=0;
00726                         VHDCI[0][1]=0;
00727                         VHDCI[1][0]=0;
00728                         VHDCI[1][1]=0;
00729                 }
00730 
00731 }
00732 
00734 //VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
00735     void SourceCardRouting::VHDCItoSTRING(      unsigned short &logicalCardID,
00736                         unsigned short &eventNumber,
00737                         std::string &dataString,
00738                         unsigned long (&VHDCI)[2][2]    ) const{
00739 
00740                 stringstream temp;
00741 
00742                 temp << dec << eventNumber << '\t';
00743                 temp << dec << logicalCardID << '\t';
00744                 temp << hex << setw(8) << setfill('0') << VHDCI[0][0] << '\t';
00745                 temp << hex << setw(8) << setfill('0') << VHDCI[0][1] << '\t';
00746                 temp << hex << setw(8) << setfill('0') << VHDCI[1][0] << '\t';
00747                 temp << hex << setw(8) << setfill('0') << VHDCI[1][1] << std::endl;
00748                 dataString = temp.str();
00749 }
00750   
00753 
00754     void SourceCardRouting::LogicalCardIDtoRoutingMode( unsigned short &logicalCardID,
00755                                      int &RoutingMode,
00756                                      int &RCTCrateNumber        ) const{
00757                 
00758                 RCTCrateNumber = (logicalCardID>>3);
00759                 if ( (logicalCardID&0x4) != 0)RCTCrateNumber+=9;
00760                 RoutingMode = (logicalCardID&0x3); 
00761 
00762 }
00763 
00765 
00766    void SourceCardRouting::RoutingModetoLogicalCardID( unsigned short &logicalCardID,
00767                                      int &RoutingMode,
00768                                      int &RCTCrateNumber        ) const{
00769 
00770                 logicalCardID = ((RCTCrateNumber%9)<<3)|(RCTCrateNumber>8?0x4:0x0)|(RoutingMode&0x3);
00771 
00772 }
00773 
00774 
00775 
00776 
00777 
00778 
00779 
00780 
00781 
00782 
00783 
00784 
00785 
00786 
00787 
00788 
00789 
00790 
00791 
00792 
00793 
00794 
00795 
00796 
00797 
00798 
00799 
00800 
00801 
00803 //These were going to be implimented but made things a lot more complicated than necessary
00804 
00805 /*
00807 //RC arrays are RC[receiver card number<7][region<2]
00808 //HF arrays are HF[eta<4][HF region<2]
00809 //SFP arrays are SFP[cycle<2][sfp number<4]
00810     void SourceCardRouting::RCtoSFP(    int &RoutingMode,
00811                         unsigned short (&RC)[7][2],
00812                         unsigned short (&RCof)[7][2],
00813                         unsigned short (&RCtau)[7][2],
00814                         unsigned short (&sisterRC)[7][2],
00815                         unsigned short (&sisterRCof)[7][2],
00816                         unsigned short (&sisterRCtau)[7][2],
00817                         unsigned short (&HF)[4][2],
00818                         unsigned short (&HFQ)[4][2],
00819                         unsigned short (&SFP)[2][4] ){
00820 
00821         switch(RoutingMode){
00822                 case 1:
00823                         RC56HFtoSFP(RC,RCof,RCtau,HF,HFQ,SFP);
00824                         break;
00825                 case 2:
00826                         RC012toSFP(RC,RCof,RCtau,SFP);          
00827                         break;
00828                 case 3:
00829                         RC234toSFP(RC,RCof,RCtau,sisterRC,sisterRCof,sisterRCtau,SFP);
00830                         break;
00831                 default:
00832                         break;
00833         }
00834 }
00835 
00836 
00838 //RC arrays are RC[receiver card number<7][region<2]
00839 //HF arrays are HF[eta<4][HF region<2]
00840 //SFP arrays are SFP[cycle<2][sfp number<4]
00841     void SourceCardRouting::SFPtoRC(    int &RoutingMode,
00842                         unsigned short (&RC)[7][2],
00843                         unsigned short (&RCof)[7][2],
00844                         unsigned short (&RCtau)[7][2],
00845                         unsigned short (&sisterRC)[7][2],
00846                         unsigned short (&sisterRCof)[7][2],
00847                         unsigned short (&sisterRCtau)[7][2],
00848                         unsigned short (&HF)[4][2],
00849                         unsigned short (&HFQ)[4][2],
00850                         unsigned short (&SFP)[2][4] ){
00851 
00852         switch(RoutingMode){
00853                 case 1:
00854                         SFPtoRC56HF(RC,RCof,RCtau,HF,HFQ,SFP);
00855                         break;
00856                 case 2:
00857                         SFPtoRC012(RC,RCof,RCtau,SFP);          
00858                         break;
00859                 case 3:
00860                         SFPtoRC234(RC,RCof,RCtau,sisterRC,sisterRCof,sisterRCtau,SFP);
00861                         break;
00862                 default:
00863                         break;
00864         }
00865 }
00866 */
00867 
00868 /*
00870 //RC arrays are RC[receiver card number<7][region<2]
00871 //HF arrays are HF[eta<4][HF region<2]
00872 //VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
00873     void SourceCardRouting::RCtoVHDCI(  int &RoutingMode,
00874                         unsigned short (&RC)[7][2],
00875                         unsigned short (&RCof)[7][2],
00876                         unsigned short (&RCtau)[7][2],
00877                         unsigned short (&sisterRC)[7][2],
00878                         unsigned short (&sisterRCof)[7][2],
00879                         unsigned short (&sisterRCtau)[7][2],
00880                         unsigned short (&HF)[4][2],
00881                         unsigned short (&HFQ)[4][2],
00882                         unsigned long (&VHDCI)[2][2]    ){
00883 
00884         switch(RoutingMode){
00885                 case 1:
00886                         RC56HFtoVHDCI(RC,RCof,RCtau,HF,HFQ,VHDCI);
00887                         break;
00888                 case 2:
00889                         RC012toVHDCI(RC,RCof,RCtau,VHDCI);              
00890                         break;
00891                 case 3:
00892                         RC234toVHDCI(RC,RCof,RCtau,sisterRC,sisterRCof,sisterRCtau,VHDCI);
00893                         break;
00894                 default:
00895                         break;
00896         }
00897 }
00898 
00900 //RC arrays are RC[receiver card number<7][region<2]
00901 //HF arrays are HF[eta<4][HF region<2]
00902 //VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
00903     void SourceCardRouting::VHDCItoRC(  int &RoutingMode,
00904                         unsigned short (&RC)[7][2],
00905                         unsigned short (&RCof)[7][2],
00906                         unsigned short (&RCtau)[7][2],
00907                         unsigned short (&sisterRC)[7][2],
00908                         unsigned short (&sisterRCof)[7][2],
00909                         unsigned short (&sisterRCtau)[7][2],
00910                         unsigned short (&HF)[4][2],
00911                         unsigned short (&HFQ)[4][2],
00912                         unsigned long (&VHDCI)[2][2]    ){
00913 
00914         switch(RoutingMode){
00915                 case 1:
00916                         VHDCItoRC56HF(RC,RCof,RCtau,HF,HFQ,VHDCI);
00917                         break;
00918                 case 2:
00919                         VHDCItoRC012(RC,RCof,RCtau,VHDCI);              
00920                         break;
00921                 case 3:
00922                         VHDCItoRC234(RC,RCof,RCtau,sisterRC,sisterRCof,sisterRCtau,VHDCI);
00923                         break;
00924                 default:
00925                         break;
00926         }
00927 }
00928 */
00929