CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/L1Trigger/DTBti/src/DTBtiChipEquations.cc

Go to the documentation of this file.
00001 //-------------------------------------------------
00002 //
00003 //   Class: DTBtiChip
00004 //
00005 //   Description: Implementation of DTBtiChip 
00006 //                trigger algorithm
00007 //                (Equations' implementation)
00008 //
00009 //
00010 //   Author List:
00011 //   C. Grandi
00012 //   Modifications: 
00013 //   22/X/02 S. Vanini: redundant patterns added 
00014 //   9/XII/02 SV : equation in manual form
00015 //   13/I/2003 SV equations in manual order  
00016 //   22/VI/04 SV: last trigger code update
00017 //--------------------------------------------------
00018 
00019 //#include "Utilities/Configuration/interface/Architecture.h"
00020 
00021 //-----------------------
00022 // This Class's Header --
00023 //-----------------------
00024 #include "L1Trigger/DTBti/interface/DTBtiChip.h"
00025 
00026 //-------------------------------
00027 // Collaborating Class Headers --
00028 //-------------------------------
00029 #include "L1Trigger/DTBti/interface/DTBtiHit.h"
00030 
00031 //---------------
00032 // C++ Headers --
00033 //---------------
00034 #include <iostream>
00035 
00036 using namespace std;
00037 
00038 void
00039 DTBtiChip::computeSums(){
00040   //
00041   // compute all sums and diffs
00042   // nothing more than a table...
00043   // numbering convention here is the same as the fortran version:
00044   //   sum number in the range [1,25]
00045   //   cell numbers in the range [1,9]
00046   //     --> sum(int,int,int) decreases the indices by 1
00047   // sum (sum_number, first_cell, second_cell)
00048   //
00049   
00050   if(config()->debug()>3){
00051     cout << "DTBtiChip::computeSums called" << endl; 
00052   }
00053 
00054   sum( 1,2,1);
00055   sum( 2,3,1);
00056   sum( 3,4,1);
00057   sum( 4,6,1);
00058   sum( 5,8,1);
00059   sum( 6,3,2);
00060   sum( 7,4,2);
00061   sum( 8,5,2);
00062   sum( 9,4,3);
00063   sum(10,5,3);
00064   sum(11,6,3);
00065   sum(12,8,3);
00066   sum(13,5,4);
00067   sum(14,6,4);
00068   sum(15,7,4);
00069   sum(16,9,4);
00070   sum(17,6,5);
00071   sum(18,7,5);
00072   sum(19,8,5);
00073   sum(20,7,6);
00074   sum(21,8,6);
00075   sum(22,9,6);
00076   sum(23,8,7);
00077   sum(24,9,7);
00078   sum(25,9,8);
00079 }
00080 
00081 void
00082 DTBtiChip::sum(const int s, const int a, const int b) {
00083   //
00084   // fill the sums and difs arrays
00085   // a and b are the cell numbers (in the range [1,9])
00086   // s is the sum number (in the range [1,25])
00087   //
00088 
00089   if( _thisStepUsedHit[a-1]!=0 && _thisStepUsedHit[b-1]!=0 ){
00090     _sums[s-1] = (float)(_thisStepUsedHit[a-1]->jtrig() +
00091                          _thisStepUsedHit[b-1]->jtrig()  );
00092     _difs[s-1] = (float)(_thisStepUsedHit[a-1]->jtrig() -
00093                          _thisStepUsedHit[b-1]->jtrig()  );
00094   } else {
00095     _sums[s-1] = 1000;
00096     _difs[s-1] = 1000;
00097   }
00098 
00099 }
00100 
00101 
00102 void
00103 DTBtiChip::reSumSet(){
00104 
00105   reSumAr[2][ 2 +2]=0;
00106   reSumAr[2][ 1 +2]=0;
00107   reSumAr[2][ 0 +2]=0;
00108   reSumAr[2][-1 +2]=-1;
00109   reSumAr[2][-2 +2]=-1;
00110 
00111   reSumAr[1][ 2 +2]=1;
00112   reSumAr[1][ 1 +2]=1;
00113   reSumAr[1][ 0 +2]=0;
00114   reSumAr[1][-1 +2]=0;
00115   reSumAr[1][-2 +2]=0;
00116 
00117   reSumAr[0][ 2 +2]=1;
00118   reSumAr[0][ 1 +2]=0;
00119   reSumAr[0][ 0 +2]=0;
00120   reSumAr[0][-1 +2]=0;
00121   reSumAr[0][-2 +2]=-1;
00122 
00123   reSumAr23[2][ 2 +2]=1;
00124   reSumAr23[2][ 1 +2]=1;
00125   reSumAr23[2][ 0 +2]=1;
00126   reSumAr23[2][-1 +2]=0;
00127   reSumAr23[2][-2 +2]=0;
00128 
00129   reSumAr23[1][ 2 +2]=1;
00130   reSumAr23[1][ 1 +2]=1;
00131   reSumAr23[1][ 0 +2]=0;
00132   reSumAr23[1][-1 +2]=0;
00133   reSumAr23[1][-2 +2]=0;
00134 
00135   reSumAr23[0][ 2 +2]=1;
00136   reSumAr23[0][ 1 +2]=0;
00137   reSumAr23[0][ 0 +2]=0;
00138   reSumAr23[0][-1 +2]=0;
00139   reSumAr23[0][-2 +2]=-1;
00140  }
00141 
00142 
00143 
00144 void 
00145 DTBtiChip::computeEqs(){
00146   //
00147   // Compute all K and X equations of DTBtiChip algorithm
00148   // NB now Keq=Kman
00149 
00150   float K0 = config()->ST();
00151   //cout <<"K0="<<K0<<endl;
00152 
00153   //enabled patterns....
00154   int PTMS[32];
00155   for(int i=0; i<32; i++){
00156     PTMS[i] = config()->PTMSflag(i);
00157   }
00158 
00159     int i;
00160   // redundant patterns added by Sara Vanini
00161   i=0;  //  1324A  --> 1L3L2R4L
00162   if(PTMS[i] ){
00163   _Keq[i][0] =  _difs[1]          + 2.*K0;                  //eq. AB
00164   _Keq[i][1] = -_sums[5]          + 2.*K0;                  //eq. BC
00165   _Keq[i][2] =  _sums[6];                                   //eq. CD
00166   _Keq[i][3] = -(_sums[0]/2.)  + 2.*K0 + 0.01;              //eq. AC
00167   _Keq[i][4] =  (_difs[8]/2.)  +    K0 + 0.01 ;             //eq. BD
00168   //_Keq[i][5] =  (_difs[2]/3.) + 4.*K0/3. + 0.51;                 //eq. AD
00169   _Keq[i][5] =  ST43 + 
00170                 reSum( RE43 , int(fmod(double(_difs[2]),3.)) ) + 
00171                 int( (double(_difs[2])/3.) );                        //eq. AD
00172 
00173   //patt 0 always uses Xbc, because Xad could be negative...
00174   //when wire B is missing,  TshiftB=0
00175   //when hit B is gone out of shift register, Tshift=K0+1
00176   float _difs_p0 = _difs[5]; 
00177 
00178   float TshiftB = 0;
00179   float TshiftC = 0;
00180   if(_thisStepUsedHit[3-1]==0){
00181     if(_hits[3-1].size()==0 )
00182       TshiftB = 0;
00183     if(_hits[3-1].size()>0 && (*(_hits[3-1].begin()))->clockTime()<=-K0 )
00184       TshiftB = K0+1; 
00185   }
00186   else
00187    TshiftB = _thisStepUsedHit[3-1]->jtrig();  
00188 
00189   if(_thisStepUsedHit[2-1]==0){
00190     if(_hits[2-1].size()==0 )
00191       TshiftC = 0;
00192     if(_hits[2-1].size()>0 && (*(_hits[2-1].begin()))->clockTime()<=-K0 )
00193       TshiftC = K0+1; 
00194   }
00195   else
00196     TshiftC = _thisStepUsedHit[2-1]->jtrig();  
00197 
00198   _difs_p0 = (float)(TshiftB - TshiftC);
00199 
00200 // Zotto's
00201   _XeqAB_patt0 = (_sums[1] - K0) / 4.;                       //eq. AB
00202   _Xeq[i][0]   = (_difs_p0 + K0) / 4.;                       //eq. BC
00203   _XeqCD_patt0 = (_difs[6] + K0) / 4.;                        //eq. CD
00204   _XeqAC_patt0 = -(_difs[0])   / 4.;                         //eq. AC
00205   _XeqBD_patt0 =  (_sums[8])   / 4.;                         //eq. BD
00206   _Xeq[i][1] = (_sums[2] - K0) / 4.;                         //eq. AD
00207   
00208 /*
00209 // my eq
00210   _XeqAB_patt0 = (_sums[1] - K0) / 4.;                       //eq. AB
00211   _Xeq[i][0]   = (_difs[5] + K0) / 4.;                       //eq. BC
00212   _XeqCD_patt0 = (_difs[6] + K0) / 4.;                        //eq. CD
00213   _XeqAC_patt0 = -(_difs[0])   / 4.;                         //eq. AC
00214   _XeqBD_patt0 =  (_sums[8])   / 4.;                         //eq. BD
00215   _Xeq[i][1] = (_sums[2] - K0) / 4.;                         //eq. AD
00216 */
00217    
00218   }
00219  
00220 
00221   i=1;  //  1324B  --> 1L3L2R4R
00222   if(PTMS[i] ){
00223   _Keq[i][0] =  _difs[1]        + 2.*K0;
00224   _Keq[i][1] = -(_sums[5])  + 2.*K0;
00225   _Keq[i][2] = -_difs[6]        + 2.*K0;
00226   _Keq[i][3] = -(_sums[0]/2.) + 2.*K0 + 0.01;
00227   _Keq[i][4] = -(_sums[8]/2.) + 2.*K0 + 0.01;
00228   //_Keq[i][5] = -(_sums[2]/3.)     + 2.*K0 + 0.51;
00229   _Keq[i][5] = ST2 +
00230                reSum23( 0 , int(fmod(double(-_sums[2]),3.)) ) +
00231                int( (double(-_sums[2])/3.) );   
00232 
00233   _Xeq[i][0] = ( _difs[5] + K0) / 4.;
00234   _Xeq[i][1] = (-_difs[2] + K0) / 4.;
00235   }
00236  
00237   i=2;  //  1324C  --> 1R3L2R4L
00238   if(PTMS[i] ){
00239   _Keq[i][0] =  _sums[1];
00240   _Keq[i][1] = -_sums[5]       + 2.*K0;
00241   _Keq[i][2] =  _sums[6];
00242   _Keq[i][3] = -(_difs[0]/2.) +   K0 + 0.01;
00243   _Keq[i][4] =  (_difs[8]/2.) +   K0 + 0.01;
00244   //_Keq[i][5] =  (_sums[2]/3.)    + 2.*K0/3. + 0.51;
00245   _Keq[i][5] =  ST23 + 
00246                 reSum23( RE23 , int(fmod(double(_sums[2]),3.)) ) + 
00247                 int( (double(_sums[2])/3.) );                        //eq. AD
00248 /*  
00249 cout << "ST23 =" << ST23 << endl;
00250 cout << "RE23 =" << RE23 << endl;
00251 cout << "fmod(double(_sums[2]),3.) =" << fmod(double(_sums[2]),3.) << endl;
00252 cout << "reSum23 = "<< reSum23( RE23 , fmod(double(_sums[2]),3.) ) << endl;
00253 cout << "double(_sums[2])/3.="<<double(_sums[2])/3.<< endl;
00254 cout << "int('') = " << int( (double(_sums[2])/3.) ) << endl;
00255 */
00256   _Xeq[i][0] = (_difs[5] + K0) / 4.;
00257   _Xeq[i][1] = (_difs[2] + K0) / 4.;
00258   }
00259  
00260   i=3;  //  1324D  --> 1R3L2R4R
00261   if(PTMS[i] ){
00262   _Keq[i][0] =  _sums[1];
00263   _Keq[i][1] = -_sums[5]      + 2.*K0;
00264   _Keq[i][2] = -_difs[6]      + 2.*K0;
00265   _Keq[i][3] = -(_difs[0]/2.) +    K0 + 0.01;
00266   _Keq[i][4] = -(_sums[8]/2.) + 2.*K0 + 0.01;
00267   //_Keq[i][5] = -(_difs[2]/3.) + 4.*K0/3.;
00268   _Keq[i][5] =  ST43 + 
00269                 reSum( RE43 , int(fmod(double(-_difs[2]),3.)) ) + 
00270                 int( (double(-_difs[2])/3.) );                        //eq. AD
00271 
00272 
00273   _Xeq[i][0] = ( _difs[5] +   K0) / 4.;
00274   _Xeq[i][1] = (-_sums[2] + 3.*K0) / 4.;
00275   }
00276  
00277 
00278   i=4;  //  i = DTBtiChipEQMAP->index("1364A");  --> 1L3L6L4R
00279   if(PTMS[i] ){
00280   _Keq[i][0] =  _difs[1]        + 2.*K0;
00281   _Keq[i][1] =  _difs[10]       + 2.*K0;
00282   _Keq[i][2] = -(_sums[13]) + 2.*K0;
00283   _Keq[i][3] =  (_difs[3]/2.)   + 2.*K0 + 0.01;
00284   _Keq[i][4] = -(_sums[8]/2.)   + 2.*K0 + 0.01;
00285   //_Keq[i][5] = -(_sums[2]/3.)   + 2.*K0 + 0.51;
00286   _Keq[i][5] = ST2 +
00287                reSum23( 0 , int(fmod(double(-_sums[2]),3.)) ) +
00288                int( (double(-_sums[2])/3.) );   
00289 
00290   _Xeq[i][0] = ( _sums[10] + K0) / 4.;
00291   _Xeq[i][1] = (-_difs[2]  + K0) / 4.;
00292   }
00293  
00294   i=5;  //  i = DTBtiChipEQMAP->index("1364B");  --> 1R3L6L4R
00295   if(PTMS[i] ){
00296   _Keq[i][0] =  _sums[1];
00297   _Keq[i][1] =  _difs[10]      + 2.*K0;
00298   _Keq[i][2] = -_sums[13]      + 2.*K0;
00299   _Keq[i][3] =  (_sums[3]/2.)  +   K0 + 0.01;
00300   _Keq[i][4] = -(_sums[8]/2.)  + 2.*K0 + 0.01;
00301   //_Keq[i][5] = -(_difs[2]/3.)  + 4.*K0/3.;
00302   _Keq[i][5] =  ST43 + 
00303                 reSum( RE43 , int(fmod(double(-_difs[2]),3.)) ) + 
00304                 int( (double(-_difs[2])/3.) );                        //eq. AD
00305 
00306   _Xeq[i][0] = ( _sums[10]+   K0) / 4.;
00307   _Xeq[i][1] = (-_sums[2] + 3.*K0) / 4.;
00308   }
00309 
00310   i=6;  //  i = DTBtiChipEQMAP->index("1364C");  --> 1R3R6L4R
00311   if(PTMS[i] ){
00312   _Keq[i][0] = -_difs[1]       + 2.*K0;
00313   _Keq[i][1] =  _sums[10];
00314   _Keq[i][2] = -_sums[13]      + 2.*K0;
00315   _Keq[i][3] =  (_sums[3]/2.)  +    K0 + 0.01;
00316   _Keq[i][4] = -(_difs[8]/2.)  +    K0 + 0.01;
00317   //_Keq[i][5] = -(_difs[2]/3.)  + 4.*K0/3.;
00318   _Keq[i][5] =  ST43 + 
00319                 reSum( RE43 , int(fmod(double(-_difs[2]),3.)) ) + 
00320                 int( (double(-_difs[2])/3.) );                        //eq. AD
00321 
00322   _Xeq[i][0] = ( _difs[10]+ 3.*K0) / 4.;
00323   _Xeq[i][1] = (-_sums[2] + 3.*K0) / 4.;
00324   }
00325  
00326   i=7;  //  i = DTBtiChipEQMAP->index("1368A");  --> 1R3R6L8L
00327   if(PTMS[i] ){
00328   _Keq[i][0] = -_difs[1]        + 2.*K0;
00329   _Keq[i][1] =  (_sums[10]);
00330   _Keq[i][2] =  _difs[20]       + 2.*K0;
00331   _Keq[i][3] =  (_sums[3]/2.)   +    K0 + 0.01;
00332   _Keq[i][4] =  (_sums[11]/2.)  +    K0 + 0.01;
00333   //_Keq[i][5] =  (_sums[4]/3.)   + 4.*K0/3. + 0.51;
00334   _Keq[i][5] =  ST43 + 
00335                 reSum( RE43 , int(fmod(double(_sums[4]),3.)) ) + 
00336                 int( (double(_sums[4])/3.) );                        //eq. AD
00337 
00338   _Xeq[i][0] =  (_difs[10]+ 3.*K0) / 4.;
00339   _Xeq[i][1] =  (_difs[4] + 3.*K0) / 4.;
00340   }
00341  
00342   i=8;  //  i = DTBtiChipEQMAP->index("1368B");  --> 1R3R6R8L
00343   if(PTMS[i] ){
00344   _Keq[i][0] = -_difs[1]          + 2.*K0;
00345   _Keq[i][1] = -_difs[10]         + 2.*K0;
00346   _Keq[i][2] =  (_sums[20]);
00347   _Keq[i][3] = -(_difs[3]/2.)     + 2.*K0 + 0.01;
00348   _Keq[i][4] =  (_sums[11]/2.)    +    K0 + 0.01;
00349   //_Keq[i][5] =  (_sums[4]/3.)     + 4.*K0/3.;
00350   _Keq[i][5] =  ST43 + 
00351                 reSum( RE43 , int(fmod(double(_sums[4]),3.)) ) + 
00352                 int( (double(_sums[4])/3.) );                        //eq. AD
00353 
00354 
00355   _Xeq[i][0] = (-_sums[10]+ 5.*K0) / 4.;
00356   _Xeq[i][1] = ( _difs[4] + 3.*K0) / 4.;
00357   }
00358 
00359   i=9;  //  i = DTBtiChipEQMAP->index("1368C");  --> 1R3L6L8L
00360   if(PTMS[i] ){
00361   _Keq[i][0] =  (_sums[1]);
00362   _Keq[i][1] =  _difs[10]        + 2.*K0;
00363   _Keq[i][2] =  _difs[20]        + 2.*K0;
00364   _Keq[i][3] =  (_sums[3]/2.)    +    K0 + 0.01;
00365   _Keq[i][4] =  (_difs[11]/2.)   + 2.*K0 + 0.01;
00366   //_Keq[i][5] =  (_sums[4]/3.)    + 4.*K0/3.;
00367   _Keq[i][5] =  ST43 + 
00368                 reSum( RE43 , int(fmod(double(_sums[4]),3.)) ) + 
00369                 int( (double(_sums[4])/3.) );                        //eq. AD
00370 
00371 
00372   _Xeq[i][0] =  (_sums[10]+  K0) / 4.;
00373   _Xeq[i][1] =  (_difs[4] + 3.*K0) / 4.;
00374   }
00375   
00376   i=10;  //  i = DTBtiChipEQMAP->index("5324A");  --> 5L3L2R4L
00377   if(PTMS[i] ){
00378   _Keq[i][0] = -_difs[9];
00379   _Keq[i][1] = -_sums[5]       + 2.*K0;
00380   _Keq[i][2] =  _sums[6];
00381   _Keq[i][3] = -(_sums[7]/2.)  +    K0 + 0.01;
00382   _Keq[i][4] =  (_difs[8]/2.)  +    K0 + 0.01;
00383   //_Keq[i][5] = -(_difs[12]/3.) + 2.*K0/3.;
00384   _Keq[i][5] =  ST23 + 
00385                 reSum23( RE23 , int(fmod(double(-_difs[12]),3.)) ) + 
00386                 int( (double(-_difs[12])/3.) );                        //eq. AD
00387 
00388   _Xeq[i][0] =  (_difs[5] + K0) / 4.;
00389   _Xeq[i][1] =  (_sums[12]+ K0) / 4.;
00390   }
00391 
00392   i=11;  //  i = DTBtiChipEQMAP->index("5324B");  --> 5L3R2R4L
00393   if(PTMS[i] ){
00394   _Keq[i][0] = -_sums[9]       + 2.*K0;
00395   _Keq[i][1] =  _difs[5];
00396   _Keq[i][2] =  _sums[6];
00397   _Keq[i][3] = -(_sums[7]/2.)  +    K0 + 0.01;
00398   _Keq[i][4] =  (_sums[8]/2.   + 0.01);
00399   //_Keq[i][5] = -(_difs[12]/3.) + 2.*K0/3.;
00400   _Keq[i][5] =  ST23 + 
00401                 reSum23( RE23 , int(fmod(double(-_difs[12]),3.)) ) + 
00402                 int( (double(-_difs[12])/3.) );                        //eq. AD
00403 
00404   _Xeq[i][0] = (-_sums[5] + 3.*K0) / 4.;
00405   _Xeq[i][1] = ( _sums[12]+   K0) / 4.;
00406   }
00407 
00408   i=12;  //  i = DTBtiChipEQMAP->index("5324C");  --> 5R3R2R4L
00409   if(PTMS[i] ){
00410   _Keq[i][0] =  _difs[9];
00411   _Keq[i][1] =  _difs[5];
00412   _Keq[i][2] =  (_sums[6]);
00413   _Keq[i][3] =  (_difs[7]/2.) + 0.01;
00414   _Keq[i][4] =  (_sums[8]/2.)  + 0.01;
00415   _Keq[i][5] =  (_sums[12]/3.) + 0.51;
00416 
00417   _Xeq[i][0] = (-_sums[5] + 3. * K0) / 4.;
00418   _Xeq[i][1] = (-_difs[12]+ 3. * K0) / 4.;
00419   }
00420 
00421   i=13;  //  i = DTBtiChipEQMAP->index("5364A");  --> 5L3R6L4L
00422   if(PTMS[i] ){
00423   _Keq[i][0] = -_sums[9]        + 2.*K0;
00424   _Keq[i][1] =  _sums[10];
00425   _Keq[i][2] = -_difs[13];
00426   _Keq[i][3] =  (_difs[16]/2.)  +    K0 + 0.01;
00427   _Keq[i][4] =  (_sums[8]/2.    + 0.01);
00428   //_Keq[i][5] = -(_difs[12]/3.)  +  2.*K0/3.;
00429   _Keq[i][5] =  ST23 + 
00430                 reSum23( RE23 , int(fmod(double(-_difs[12]),3.)) ) + 
00431                 int( (double(-_difs[12])/3.) );                        //eq. AD
00432 
00433   _Xeq[i][0] =  (_difs[10]+ 3.*K0) / 4.;
00434   _Xeq[i][1] =  (_sums[12]+   K0) / 4.;
00435   }
00436  
00437   i=14;  //  i = DTBtiChipEQMAP->index("5364B");  --> 5L3R6L4R
00438   if(PTMS[i] ){
00439   _Keq[i][0] = -_sums[9]        + 2.*K0;
00440   _Keq[i][1] =  _sums[10];
00441   _Keq[i][2] = -_sums[13]       + 2.*K0;
00442   _Keq[i][3] =  (_difs[16]/2.)  +    K0 + 0.01;
00443   _Keq[i][4] = -(_difs[8]/2.)   +    K0 + 0.01;
00444   //_Keq[i][5] = -(_sums[12]/3.)  + 4.*K0/3.;
00445   _Keq[i][5] =  ST43 + 
00446                 reSum( RE43 , int(fmod(double(-_sums[12]),3.)) ) + 
00447                 int( (double(-_sums[12])/3.) ); 
00448 
00449   _Xeq[i][0] =  (_difs[10]+ 3.*K0) / 4.;
00450   _Xeq[i][1] =  (_difs[12]+ 3.*K0) / 4.;
00451   }
00452  
00453   i=15;  //  i = DTBtiChipEQMAP->index("5364C");  --> 5R3R6L4L
00454   if(PTMS[i] ){
00455   _Keq[i][0] =  _difs[9];
00456   _Keq[i][1] =  (_sums[10]);
00457   _Keq[i][2] = -_difs[13];
00458   _Keq[i][3] =  (_sums[16]/2.  + 0.01);
00459   _Keq[i][4] =  (_sums[8]/2.   + 0.01);
00460   _Keq[i][5] =  (_sums[12]/3.) + 0.51;
00461 
00462   _Xeq[i][0] = ( _difs[10]+ 3.*K0) / 4.;
00463   _Xeq[i][1] = (-_difs[12]+ 3.*K0) / 4.;
00464   }
00465  
00466   i=16;  //  i = DTBtiChipEQMAP->index("5364D");  --> 5R3R6L4R
00467   if(PTMS[i] ){
00468   _Keq[i][0] =  _difs[9];
00469   _Keq[i][1] =  _sums[10];
00470   _Keq[i][2] = -_sums[13]      + 2.*K0;
00471   _Keq[i][3] =  (_sums[16]/2.  + 0.01);
00472   _Keq[i][4] = -(_difs[8]/2.)  +    K0 + 0.01;
00473   //_Keq[i][5] =  (_difs[12]/3.) + 2.*K0/3.;
00474   _Keq[i][5] =  ST23 + 
00475                 reSum23( RE23 , int(fmod(double(_difs[12]),3.)) ) + 
00476                 int( (double(_difs[12])/3.) );                        //eq. AD
00477 
00478   _Xeq[i][0] = ( _difs[10]+ 3.*K0) / 4.;
00479   _Xeq[i][1] = (-_sums[12]+ 5.*K0) / 4.;
00480   }
00481  
00482   i=17;  //  i = DTBtiChipEQMAP->index("5368A");  --> 5L3R6L8L
00483   if(PTMS[i] ){
00484   _Keq[i][0] = -_sums[9]        + 2.*K0;
00485   _Keq[i][1] =  _sums[10];
00486   _Keq[i][2] =  _difs[20]       + 2.*K0;
00487   _Keq[i][3] =  (_difs[16]/2.)  +    K0 + 0.01;
00488   _Keq[i][4] =  (_sums[11]/2.)  +    K0 + 0.01;
00489   //_Keq[i][5] =  (_difs[18]/3.)  + 4.*K0/3.;
00490   _Keq[i][5] =  ST43 + 
00491                 reSum( RE43 , int(fmod(double(_difs[18]),3.)) ) + 
00492                 int( (double(_difs[18])/3.) );                        //eq. AD
00493 
00494   _Xeq[i][0] =  (_difs[10]+ 3.*K0) / 4.;
00495   _Xeq[i][1] =  (_sums[18]+ 3.*K0) / 4.;
00496   }
00497  
00498   i=18;  //  i = DTBtiChipEQMAP->index("5368B");  --> 5L3R6R8L
00499   if(PTMS[i] ){
00500   _Keq[i][0] = -_sums[9]        + 2.*K0;
00501   _Keq[i][1] = -_difs[10]       + 2.*K0;
00502   _Keq[i][2] =  _sums[20];
00503   _Keq[i][3] = -(_sums[16]/2.)  + 2.*K0 + 0.01;
00504   _Keq[i][4] =  (_sums[11]/2.)  +    K0 + 0.01;
00505   //_Keq[i][5] =  (_difs[18]/3.)  + 4.*K0/3.;
00506   _Keq[i][5] =  ST43 + 
00507                 reSum( RE43 , int(fmod(double(_difs[18]),3.)) ) + 
00508                 int( (double(_difs[18])/3.) );                        //eq. AD
00509 
00510   _Xeq[i][0] = (-_sums[10]+ 5.*K0) / 4.;
00511   _Xeq[i][1] = ( _sums[18]+ 3.*K0) / 4.;
00512   }
00513  
00514   i=19;  //  i = DTBtiChipEQMAP->index("5368C");  --> 5L3R6R8R
00515   if(PTMS[i] ){
00516   _Keq[i][0] = -(_sums[9])  + 2.*K0;
00517   _Keq[i][1] = -_difs[10]       + 2.*K0;
00518   _Keq[i][2] = -_difs[20]       + 2.*K0;
00519   _Keq[i][3] = -(_sums[16]/2.)  + 2.*K0 + 0.01;
00520   _Keq[i][4] = -(_difs[11]/2.)  + 2.*K0 + 0.01;
00521   //_Keq[i][5] = -(_sums[18]/3.)  + 2.*K0 + 0.51;
00522   _Keq[i][5] = ST2 +
00523                reSum23( 0 , int(fmod(double(-_sums[18]),3.)) ) +
00524                int( (double(-_sums[18])/3.) );   
00525 
00526   _Xeq[i][0] = (-_sums[10]+ 5.*K0) / 4.;
00527   _Xeq[i][1] = (-_difs[18]+ 5.*K0) / 4.;
00528   }
00529  
00530   i=20;  //  i = DTBtiChipEQMAP->index("5764A");  --> 5R7L6L4R
00531   if(PTMS[i] ){
00532   _Keq[i][0] =  _sums[17];
00533   _Keq[i][1] = -_difs[19];
00534   _Keq[i][2] = -_sums[13]       + 2.*K0;
00535   _Keq[i][3] =  (_sums[16]/2.   + 0.01);
00536   _Keq[i][4] = -(_sums[14]/2.)  +    K0 + 0.01;
00537   //_Keq[i][5] =  (_difs[12]/3.)  + 2.*K0/3.;
00538   _Keq[i][5] =  ST23 + 
00539                 reSum23( RE23 , int(fmod(double(_difs[12]),3.)) ) + 
00540                 int( (double(_difs[12])/3.) );                        //eq. AD
00541 
00542   _Xeq[i][0] = ( _sums[19]+ 3.*K0) / 4.;
00543   _Xeq[i][1] = (-_sums[12]+ 5.*K0) / 4.;
00544   }
00545  
00546   i=21;  //  i = DTBtiChipEQMAP->index("5764B");  --> 5R7L6R4R
00547   if(PTMS[i] ){
00548   _Keq[i][0] =  _sums[17];
00549   _Keq[i][1] = -_sums[19]      + 2.*K0;
00550   _Keq[i][2] =  _difs[13];
00551   _Keq[i][3] = -(_difs[16]/2.) +    K0 + 0.01;
00552   _Keq[i][4] = -(_sums[14]/2.) +    K0 + 0.01;
00553   //_Keq[i][5] =  (_difs[12]/3.) + 2.*K0/3.;
00554   _Keq[i][5] =  ST23 + 
00555                 reSum23( RE23 , int(fmod(double(_difs[12]),3.)) ) + 
00556                 int( (double(_difs[12])/3.) );                        //eq. AD
00557 
00558   _Xeq[i][0] = ( _difs[19]+ 5.*K0) / 4.;
00559   _Xeq[i][1] = (-_sums[12]+ 5.*K0) / 4.;
00560   }
00561  
00562   i=22;  //  i = DTBtiChipEQMAP->index("5764C");  --> 5R7L6L4L
00563   if(PTMS[i] ){
00564   _Keq[i][0] =  (_sums[17]);
00565   _Keq[i][1] = -_difs[19];
00566   _Keq[i][2] = -_difs[13];
00567   _Keq[i][3] =  (_sums[16]/2.  + 0.01);
00568   _Keq[i][4] = -(_difs[14]/2.) + 0.01;
00569   _Keq[i][5] =  (_sums[12]/3.) + 0.51;
00570 
00571   _Xeq[i][0] = ( _sums[19]+ 3.*K0) / 4.;
00572   _Xeq[i][1] = (-_difs[12]+ 3.*K0) / 4.;
00573   }
00574  
00575   i=23;  //  i = DTBtiChipEQMAP->index("9764A");  --> 9L7L6L4R
00576   if(PTMS[i] ){
00577   _Keq[i][0] = -_difs[23];
00578   _Keq[i][1] = -_difs[19];
00579   _Keq[i][2] = -(_sums[13]) + 2.*K0;
00580   _Keq[i][3] = -(_difs[21]/2.) + 0.01;
00581   _Keq[i][4] = -(_sums[14]/2.)  +    K0 + 0.01;
00582   //_Keq[i][5] = -(_sums[15]/3.)  + 2.*K0/3.;
00583   _Keq[i][5] =  ST23 + 
00584                 reSum23( RE23 , int(fmod(double(-_sums[15]),3.)) ) + 
00585                 int( (double(-_sums[15])/3.) );                        //eq. AD
00586 
00587   _Xeq[i][0] =  (_sums[19]+ 3.*K0) / 4.;
00588   _Xeq[i][1] =  (_difs[15]+ 5.*K0) / 4.;
00589   }
00590  
00591   i=24;  //  i = DTBtiChipEQMAP->index("9764B");  --> 9L7L6R4R
00592   if(PTMS[i] ){
00593   _Keq[i][0] = -_difs[23];
00594   _Keq[i][1] = -(_sums[19])   + 2.*K0;
00595   _Keq[i][2] =  _difs[13];
00596   _Keq[i][3] = -(_sums[21]/2.)    +    K0 + 0.01;
00597   _Keq[i][4] = -(_sums[14]/2.)    +    K0 + 0.01;
00598   //_Keq[i][5] = -(_sums[15]/3.)    + 2.*K0/3.;
00599   _Keq[i][5] =  ST23 + 
00600                 reSum23( RE23 , int(fmod(double(-_sums[15]),3.)) ) + 
00601                 int( (double(-_sums[15])/3.) );                        //eq. AD
00602 
00603   _Xeq[i][0] =  (_difs[19]+ 5.*K0) / 4.;
00604   _Xeq[i][1] =  (_difs[15]+ 5.*K0) / 4.;
00605   }
00606  
00607   i=25;  //  i = DTBtiChipEQMAP->index("9764C");  --> 9L7R6R4R
00608   if(PTMS[i] ){
00609   _Keq[i][0] = -(_sums[23])   + 2.*K0;
00610   _Keq[i][1] =  _difs[19];
00611   _Keq[i][2] =  _difs[13];
00612   _Keq[i][3] = -(_sums[21]/2.)    +   K0 + 0.01;
00613   _Keq[i][4] =  (_difs[14]/2.) + 0.01;
00614   //_Keq[i][5] = -(_sums[15]/3.)    + 2.*K0/3.;
00615   _Keq[i][5] =  ST23 + 
00616                 reSum23( RE23 , int(fmod(double(-_sums[15]),3.)) ) + 
00617                 int( (double(-_sums[15])/3.) );                        //eq. AD
00618 
00619   _Xeq[i][0] = (-_sums[19]+ 7.*K0) / 4.;
00620   _Xeq[i][1] = ( _difs[15]+ 5.*K0) / 4.;
00621   }
00622 
00623   i=26;  //  int i = DTBtiChipEQMAP->index("5768A") --> 5L7L6R8L
00624   if(PTMS[i] ){
00625   _Keq[i][0] =  _difs[17]       + 2.*K0;
00626   _Keq[i][1] = -_sums[19]       + 2.*K0;
00627   _Keq[i][2] =  _sums[20];
00628   _Keq[i][3] = -(_sums[16]/2.)  + 2.*K0 + 0.01;
00629   _Keq[i][4] =  (_difs[22]/2.)  +    K0 + 0.01;
00630   //_Keq[i][5] =  (_difs[18]/3.)  + 4.*K0/3.;
00631   _Keq[i][5] =  ST43 + 
00632                 reSum( RE43 , int(fmod(double(_difs[18]),3.)) ) + 
00633                 int( (double(_difs[18])/3.) );                        //eq. AD
00634 
00635   _Xeq[i][0] =  (_difs[19] + 5.*K0) / 4.;
00636   _Xeq[i][1] =  (_sums[18] + 3.*K0) / 4.;
00637   }
00638  
00639   i=27;  //  i = DTBtiChipEQMAP->index("5768B");  --> 5L7L6R8R
00640   if(PTMS[i] ){
00641   _Keq[i][0] =  _difs[17]       + 2.*K0;
00642   _Keq[i][1] = -(_sums[19]) + 2.*K0;
00643   _Keq[i][2] = -_difs[20]       + 2.*K0;
00644   _Keq[i][3] = -(_sums[16]/2.)  + 2.*K0 + 0.01;
00645   _Keq[i][4] = -(_sums[22]/2.)  + 2.*K0 + 0.01;
00646   //_Keq[i][5] = -(_sums[18]/3.)  + 2.*K0 + 0.51;
00647   _Keq[i][5] = ST2 +
00648                reSum23( 0 , int(fmod(double(-_sums[18]),3.)) ) +
00649                int( (double(-_sums[18])/3.) );   
00650   
00651   _Xeq[i][0] = ( _difs[19] + 5.*K0) / 4.;
00652   _Xeq[i][1] = (-_difs[18] + 5.*K0) / 4.;
00653   }
00654  
00655   i=28;  //  i = DTBtiChipEQMAP->index("5768C");  --> 5R7L6R8L
00656   if(PTMS[i] ){
00657   _Keq[i][0] =  _sums[17];
00658   _Keq[i][1] = -_sums[19]       + 2.*K0;
00659   _Keq[i][2] =  _sums[20];
00660   _Keq[i][3] = -(_difs[16]/2.)  +   K0 + 0.01;
00661   _Keq[i][4] =  (_difs[22]/2.)  +   K0 + 0.01;
00662   //_Keq[i][5] =  (_sums[18]/3.)  + 2.*K0/3.;
00663   _Keq[i][5] =  ST23 + 
00664                 reSum23( RE23 , int(fmod(double(_sums[18]),3.)) ) + 
00665                 int( (double(_sums[18])/3.) );                        //eq. AD
00666 
00667   _Xeq[i][0] =  (_difs[19] + 5.*K0) / 4.;
00668   _Xeq[i][1] =  (_difs[18] + 5.*K0) / 4.;
00669   }
00670 
00671   i=29;  //  i = DTBtiChipEQMAP->index("5768D");  --> 5R7L6R8R
00672   if(PTMS[i] ){
00673   _Keq[i][0] =  _sums[17];
00674   _Keq[i][1] = -_sums[19]       + 2.*K0;
00675   _Keq[i][2] = -_difs[20]       + 2.*K0;
00676   _Keq[i][3] = -(_difs[16]/2.)  +    K0 + 0.01;
00677   _Keq[i][4] = -(_sums[22]/2.)  + 2.*K0 + 0.01;
00678   //_Keq[i][5] = -(_difs[18]/3.)  + 4.*K0/3. ;
00679   _Keq[i][5] =  ST43 + 
00680                 reSum( RE43 , int(fmod(double(-_difs[18]),3.)) ) + 
00681                 int( (double(-_difs[18])/3.) );                        //eq. AD
00682 
00683   _Xeq[i][0] = ( _difs[19] + 5.*K0) / 4.;
00684   _Xeq[i][1] = (-_sums[18] + 7.*K0) / 4.;
00685   }
00686 
00687   i=30;  //  9768A  --> 9L7L6R8L
00688   if(PTMS[i] ){
00689   _Keq[i][0] = -_difs[23];
00690   _Keq[i][1] = -_sums[19]       + 2.*K0;
00691   _Keq[i][2] =  _sums[20];
00692   _Keq[i][3] = -(_sums[21]/2.)  +    K0 + 0.01;
00693   _Keq[i][4] =  (_difs[22]/2.)  +    K0 + 0.01;
00694   //_Keq[i][5] = -(_difs[24]/3.)  + 2.*K0/3. ;
00695   _Keq[i][5] =  ST23 + 
00696                 reSum23( RE23 , int(fmod(double(-_difs[24]),3.)) ) + 
00697                 int( (double(-_difs[24])/3.) );                        //eq. AD
00698 
00699   _Xeq[i][0] = (_difs[19] + 5.*K0) / 4.;
00700   _Xeq[i][1] = (_sums[24] + 5.*K0) / 4.;
00701   }
00702  
00703   i=31;  //  9768B  --> 9L7R6R8L
00704   if(PTMS[i] ){
00705   _Keq[i][0] = -_sums[23]       + 2.*K0;
00706   _Keq[i][1] =  _difs[19];
00707   _Keq[i][2] =  _sums[20];
00708   _Keq[i][3] = -(_sums[21]/2.)  +   K0 + 0.01;
00709   _Keq[i][4] =  (_sums[22]/2.) + 0.01;
00710   //_Keq[i][5] = -(_difs[24]/3.)  + 2.*K0/3.;
00711   _Keq[i][5] =  ST23 + 
00712                 reSum23( RE23 , int(fmod(double(-_difs[24]),3.)) ) + 
00713                 int( (double(-_difs[24])/3.) );                        //eq. AD
00714 
00715   _Xeq[i][0] = (-_sums[19] + 7.*K0) / 4.;
00716   _Xeq[i][1] = ( _sums[24] + 5.*K0) / 4.;
00717   }
00718  
00719   // debugging
00720   if(config()->debug()>3){
00721     cout << endl << " Step: " << currentStep() << endl;
00722     for(i=0;i<32;i++){
00723       if(PTMS[i] ){
00724         cout << "K Equation " << i << " --> ";
00725         int j=0;
00726         for(j=0;j<6;j++){
00727           cout << _Keq[i][j] << " ";
00728         }
00729         cout << endl;
00730         cout << "X Equation " << i << " --> ";
00731         for(j=0;j<2;j++){
00732           cout << _Xeq[i][j] << " ";
00733         }
00734         if( i==0 ){
00735           cout << _XeqAB_patt0 << " " << _XeqCD_patt0 << " ";
00736           cout << _XeqAC_patt0 << " " << _XeqBD_patt0 << " ";
00737         }
00738         cout << endl;
00739       }
00740     }
00741   }
00742   // end debugging
00743   
00744 }