Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:21:57

0001 //-------------------------------------------------
0002 //
0003 //   Class: DTBtiChip
0004 //
0005 //   Description: Implementation of DTBtiChip
0006 //                trigger algorithm
0007 //                (Equations' implementation)
0008 //
0009 //
0010 //   Author List:
0011 //   C. Grandi
0012 //   Modifications:
0013 //   22/X/02 S. Vanini: redundant patterns added
0014 //   9/XII/02 SV : equation in manual form
0015 //   13/I/2003 SV equations in manual order
0016 //   22/VI/04 SV: last trigger code update
0017 //--------------------------------------------------
0018 
0019 //#include "Utilities/Configuration/interface/Architecture.h"
0020 
0021 //-----------------------
0022 // This Class's Header --
0023 //-----------------------
0024 #include "L1Trigger/DTBti/interface/DTBtiChip.h"
0025 
0026 //-------------------------------
0027 // Collaborating Class Headers --
0028 //-------------------------------
0029 #include "L1Trigger/DTBti/interface/DTBtiHit.h"
0030 
0031 //---------------
0032 // C++ Headers --
0033 //---------------
0034 #include <iostream>
0035 
0036 using namespace std;
0037 
0038 void DTBtiChip::computeSums() {
0039   //
0040   // compute all sums and diffs
0041   // nothing more than a table...
0042   // numbering convention here is the same as the fortran version:
0043   //   sum number in the range [1,25]
0044   //   cell numbers in the range [1,9]
0045   //     --> sum(int,int,int) decreases the indices by 1
0046   // sum (sum_number, first_cell, second_cell)
0047   //
0048 
0049   if (config()->debug() > 3) {
0050     cout << "DTBtiChip::computeSums called" << endl;
0051   }
0052 
0053   sum(1, 2, 1);
0054   sum(2, 3, 1);
0055   sum(3, 4, 1);
0056   sum(4, 6, 1);
0057   sum(5, 8, 1);
0058   sum(6, 3, 2);
0059   sum(7, 4, 2);
0060   sum(8, 5, 2);
0061   sum(9, 4, 3);
0062   sum(10, 5, 3);
0063   sum(11, 6, 3);
0064   sum(12, 8, 3);
0065   sum(13, 5, 4);
0066   sum(14, 6, 4);
0067   sum(15, 7, 4);
0068   sum(16, 9, 4);
0069   sum(17, 6, 5);
0070   sum(18, 7, 5);
0071   sum(19, 8, 5);
0072   sum(20, 7, 6);
0073   sum(21, 8, 6);
0074   sum(22, 9, 6);
0075   sum(23, 8, 7);
0076   sum(24, 9, 7);
0077   sum(25, 9, 8);
0078 }
0079 
0080 void DTBtiChip::sum(const int s, const int a, const int b) {
0081   //
0082   // fill the sums and difs arrays
0083   // a and b are the cell numbers (in the range [1,9])
0084   // s is the sum number (in the range [1,25])
0085   //
0086 
0087   if (_thisStepUsedHit[a - 1] != nullptr && _thisStepUsedHit[b - 1] != nullptr) {
0088     _sums[s - 1] = (float)(_thisStepUsedHit[a - 1]->jtrig() + _thisStepUsedHit[b - 1]->jtrig());
0089     _difs[s - 1] = (float)(_thisStepUsedHit[a - 1]->jtrig() - _thisStepUsedHit[b - 1]->jtrig());
0090   } else {
0091     _sums[s - 1] = 1000;
0092     _difs[s - 1] = 1000;
0093   }
0094 }
0095 
0096 void DTBtiChip::reSumSet() {
0097   reSumAr[2][2 + 2] = 0;
0098   reSumAr[2][1 + 2] = 0;
0099   reSumAr[2][0 + 2] = 0;
0100   reSumAr[2][-1 + 2] = -1;
0101   reSumAr[2][-2 + 2] = -1;
0102 
0103   reSumAr[1][2 + 2] = 1;
0104   reSumAr[1][1 + 2] = 1;
0105   reSumAr[1][0 + 2] = 0;
0106   reSumAr[1][-1 + 2] = 0;
0107   reSumAr[1][-2 + 2] = 0;
0108 
0109   reSumAr[0][2 + 2] = 1;
0110   reSumAr[0][1 + 2] = 0;
0111   reSumAr[0][0 + 2] = 0;
0112   reSumAr[0][-1 + 2] = 0;
0113   reSumAr[0][-2 + 2] = -1;
0114 
0115   reSumAr23[2][2 + 2] = 1;
0116   reSumAr23[2][1 + 2] = 1;
0117   reSumAr23[2][0 + 2] = 1;
0118   reSumAr23[2][-1 + 2] = 0;
0119   reSumAr23[2][-2 + 2] = 0;
0120 
0121   reSumAr23[1][2 + 2] = 1;
0122   reSumAr23[1][1 + 2] = 1;
0123   reSumAr23[1][0 + 2] = 0;
0124   reSumAr23[1][-1 + 2] = 0;
0125   reSumAr23[1][-2 + 2] = 0;
0126 
0127   reSumAr23[0][2 + 2] = 1;
0128   reSumAr23[0][1 + 2] = 0;
0129   reSumAr23[0][0 + 2] = 0;
0130   reSumAr23[0][-1 + 2] = 0;
0131   reSumAr23[0][-2 + 2] = -1;
0132 }
0133 
0134 void DTBtiChip::computeEqs() {
0135   //
0136   // Compute all K and X equations of DTBtiChip algorithm
0137   // NB now Keq=Kman
0138 
0139   float K0 = config()->ST();
0140   //cout <<"K0="<<K0<<endl;
0141 
0142   //enabled patterns....
0143   int PTMS[32];
0144   for (int i = 0; i < 32; i++) {
0145     PTMS[i] = config()->PTMSflag(i);
0146   }
0147 
0148   int i;
0149   // redundant patterns added by Sara Vanini
0150   i = 0;  //  1324A  --> 1L3L2R4L
0151   if (PTMS[i]) {
0152     _Keq[i][0] = _difs[1] + 2. * K0;                 //eq. AB
0153     _Keq[i][1] = -_sums[5] + 2. * K0;                //eq. BC
0154     _Keq[i][2] = _sums[6];                           //eq. CD
0155     _Keq[i][3] = -(_sums[0] / 2.) + 2. * K0 + 0.01;  //eq. AC
0156     _Keq[i][4] = (_difs[8] / 2.) + K0 + 0.01;        //eq. BD
0157     //_Keq[i][5] =  (_difs[2]/3.) + 4.*K0/3. + 0.51;                 //eq. AD
0158     _Keq[i][5] = ST43 + reSum(RE43, int(fmod(double(_difs[2]), 3.))) + int((double(_difs[2]) / 3.));  //eq. AD
0159 
0160     //patt 0 always uses Xbc, because Xad could be negative...
0161     //when wire B is missing,  TshiftB=0
0162     //when hit B is gone out of shift register, Tshift=K0+1
0163     float _difs_p0 = _difs[5];
0164 
0165     float TshiftB = 0;
0166     float TshiftC = 0;
0167     if (_thisStepUsedHit[3 - 1] == nullptr) {
0168       if (_hits[3 - 1].empty())
0169         TshiftB = 0;
0170       if (!_hits[3 - 1].empty() && (*(_hits[3 - 1].begin()))->clockTime() <= -K0)
0171         TshiftB = K0 + 1;
0172     } else
0173       TshiftB = _thisStepUsedHit[3 - 1]->jtrig();
0174 
0175     if (_thisStepUsedHit[2 - 1] == nullptr) {
0176       if (_hits[2 - 1].empty())
0177         TshiftC = 0;
0178       if (!_hits[2 - 1].empty() && (*(_hits[2 - 1].begin()))->clockTime() <= -K0)
0179         TshiftC = K0 + 1;
0180     } else
0181       TshiftC = _thisStepUsedHit[2 - 1]->jtrig();
0182 
0183     _difs_p0 = (float)(TshiftB - TshiftC);
0184 
0185     // Zotto's
0186     _XeqAB_patt0 = (_sums[1] - K0) / 4.;  //eq. AB
0187     _Xeq[i][0] = (_difs_p0 + K0) / 4.;    //eq. BC
0188     _XeqCD_patt0 = (_difs[6] + K0) / 4.;  //eq. CD
0189     _XeqAC_patt0 = -(_difs[0]) / 4.;      //eq. AC
0190     _XeqBD_patt0 = (_sums[8]) / 4.;       //eq. BD
0191     _Xeq[i][1] = (_sums[2] - K0) / 4.;    //eq. AD
0192 
0193     /*
0194 // my eq
0195   _XeqAB_patt0 = (_sums[1] - K0) / 4.;                       //eq. AB
0196   _Xeq[i][0]   = (_difs[5] + K0) / 4.;                       //eq. BC
0197   _XeqCD_patt0 = (_difs[6] + K0) / 4.;                        //eq. CD
0198   _XeqAC_patt0 = -(_difs[0])   / 4.;                         //eq. AC
0199   _XeqBD_patt0 =  (_sums[8])   / 4.;                         //eq. BD
0200   _Xeq[i][1] = (_sums[2] - K0) / 4.;                         //eq. AD
0201 */
0202   }
0203 
0204   i = 1;  //  1324B  --> 1L3L2R4R
0205   if (PTMS[i]) {
0206     _Keq[i][0] = _difs[1] + 2. * K0;
0207     _Keq[i][1] = -(_sums[5]) + 2. * K0;
0208     _Keq[i][2] = -_difs[6] + 2. * K0;
0209     _Keq[i][3] = -(_sums[0] / 2.) + 2. * K0 + 0.01;
0210     _Keq[i][4] = -(_sums[8] / 2.) + 2. * K0 + 0.01;
0211     //_Keq[i][5] = -(_sums[2]/3.)     + 2.*K0 + 0.51;
0212     _Keq[i][5] = ST2 + reSum23(0, int(fmod(double(-_sums[2]), 3.))) + int((double(-_sums[2]) / 3.));
0213 
0214     _Xeq[i][0] = (_difs[5] + K0) / 4.;
0215     _Xeq[i][1] = (-_difs[2] + K0) / 4.;
0216   }
0217 
0218   i = 2;  //  1324C  --> 1R3L2R4L
0219   if (PTMS[i]) {
0220     _Keq[i][0] = _sums[1];
0221     _Keq[i][1] = -_sums[5] + 2. * K0;
0222     _Keq[i][2] = _sums[6];
0223     _Keq[i][3] = -(_difs[0] / 2.) + K0 + 0.01;
0224     _Keq[i][4] = (_difs[8] / 2.) + K0 + 0.01;
0225     //_Keq[i][5] =  (_sums[2]/3.)    + 2.*K0/3. + 0.51;
0226     _Keq[i][5] = ST23 + reSum23(RE23, int(fmod(double(_sums[2]), 3.))) + int((double(_sums[2]) / 3.));  //eq. AD
0227                                                                                                         /*  
0228 cout << "ST23 =" << ST23 << endl;
0229 cout << "RE23 =" << RE23 << endl;
0230 cout << "fmod(double(_sums[2]),3.) =" << fmod(double(_sums[2]),3.) << endl;
0231 cout << "reSum23 = "<< reSum23( RE23 , fmod(double(_sums[2]),3.) ) << endl;
0232 cout << "double(_sums[2])/3.="<<double(_sums[2])/3.<< endl;
0233 cout << "int('') = " << int( (double(_sums[2])/3.) ) << endl;
0234 */
0235     _Xeq[i][0] = (_difs[5] + K0) / 4.;
0236     _Xeq[i][1] = (_difs[2] + K0) / 4.;
0237   }
0238 
0239   i = 3;  //  1324D  --> 1R3L2R4R
0240   if (PTMS[i]) {
0241     _Keq[i][0] = _sums[1];
0242     _Keq[i][1] = -_sums[5] + 2. * K0;
0243     _Keq[i][2] = -_difs[6] + 2. * K0;
0244     _Keq[i][3] = -(_difs[0] / 2.) + K0 + 0.01;
0245     _Keq[i][4] = -(_sums[8] / 2.) + 2. * K0 + 0.01;
0246     //_Keq[i][5] = -(_difs[2]/3.) + 4.*K0/3.;
0247     _Keq[i][5] = ST43 + reSum(RE43, int(fmod(double(-_difs[2]), 3.))) + int((double(-_difs[2]) / 3.));  //eq. AD
0248 
0249     _Xeq[i][0] = (_difs[5] + K0) / 4.;
0250     _Xeq[i][1] = (-_sums[2] + 3. * K0) / 4.;
0251   }
0252 
0253   i = 4;  //  i = DTBtiChipEQMAP->index("1364A");  --> 1L3L6L4R
0254   if (PTMS[i]) {
0255     _Keq[i][0] = _difs[1] + 2. * K0;
0256     _Keq[i][1] = _difs[10] + 2. * K0;
0257     _Keq[i][2] = -(_sums[13]) + 2. * K0;
0258     _Keq[i][3] = (_difs[3] / 2.) + 2. * K0 + 0.01;
0259     _Keq[i][4] = -(_sums[8] / 2.) + 2. * K0 + 0.01;
0260     //_Keq[i][5] = -(_sums[2]/3.)   + 2.*K0 + 0.51;
0261     _Keq[i][5] = ST2 + reSum23(0, int(fmod(double(-_sums[2]), 3.))) + int((double(-_sums[2]) / 3.));
0262 
0263     _Xeq[i][0] = (_sums[10] + K0) / 4.;
0264     _Xeq[i][1] = (-_difs[2] + K0) / 4.;
0265   }
0266 
0267   i = 5;  //  i = DTBtiChipEQMAP->index("1364B");  --> 1R3L6L4R
0268   if (PTMS[i]) {
0269     _Keq[i][0] = _sums[1];
0270     _Keq[i][1] = _difs[10] + 2. * K0;
0271     _Keq[i][2] = -_sums[13] + 2. * K0;
0272     _Keq[i][3] = (_sums[3] / 2.) + K0 + 0.01;
0273     _Keq[i][4] = -(_sums[8] / 2.) + 2. * K0 + 0.01;
0274     //_Keq[i][5] = -(_difs[2]/3.)  + 4.*K0/3.;
0275     _Keq[i][5] = ST43 + reSum(RE43, int(fmod(double(-_difs[2]), 3.))) + int((double(-_difs[2]) / 3.));  //eq. AD
0276 
0277     _Xeq[i][0] = (_sums[10] + K0) / 4.;
0278     _Xeq[i][1] = (-_sums[2] + 3. * K0) / 4.;
0279   }
0280 
0281   i = 6;  //  i = DTBtiChipEQMAP->index("1364C");  --> 1R3R6L4R
0282   if (PTMS[i]) {
0283     _Keq[i][0] = -_difs[1] + 2. * K0;
0284     _Keq[i][1] = _sums[10];
0285     _Keq[i][2] = -_sums[13] + 2. * K0;
0286     _Keq[i][3] = (_sums[3] / 2.) + K0 + 0.01;
0287     _Keq[i][4] = -(_difs[8] / 2.) + K0 + 0.01;
0288     //_Keq[i][5] = -(_difs[2]/3.)  + 4.*K0/3.;
0289     _Keq[i][5] = ST43 + reSum(RE43, int(fmod(double(-_difs[2]), 3.))) + int((double(-_difs[2]) / 3.));  //eq. AD
0290 
0291     _Xeq[i][0] = (_difs[10] + 3. * K0) / 4.;
0292     _Xeq[i][1] = (-_sums[2] + 3. * K0) / 4.;
0293   }
0294 
0295   i = 7;  //  i = DTBtiChipEQMAP->index("1368A");  --> 1R3R6L8L
0296   if (PTMS[i]) {
0297     _Keq[i][0] = -_difs[1] + 2. * K0;
0298     _Keq[i][1] = (_sums[10]);
0299     _Keq[i][2] = _difs[20] + 2. * K0;
0300     _Keq[i][3] = (_sums[3] / 2.) + K0 + 0.01;
0301     _Keq[i][4] = (_sums[11] / 2.) + K0 + 0.01;
0302     //_Keq[i][5] =  (_sums[4]/3.)   + 4.*K0/3. + 0.51;
0303     _Keq[i][5] = ST43 + reSum(RE43, int(fmod(double(_sums[4]), 3.))) + int((double(_sums[4]) / 3.));  //eq. AD
0304 
0305     _Xeq[i][0] = (_difs[10] + 3. * K0) / 4.;
0306     _Xeq[i][1] = (_difs[4] + 3. * K0) / 4.;
0307   }
0308 
0309   i = 8;  //  i = DTBtiChipEQMAP->index("1368B");  --> 1R3R6R8L
0310   if (PTMS[i]) {
0311     _Keq[i][0] = -_difs[1] + 2. * K0;
0312     _Keq[i][1] = -_difs[10] + 2. * K0;
0313     _Keq[i][2] = (_sums[20]);
0314     _Keq[i][3] = -(_difs[3] / 2.) + 2. * K0 + 0.01;
0315     _Keq[i][4] = (_sums[11] / 2.) + K0 + 0.01;
0316     //_Keq[i][5] =  (_sums[4]/3.)     + 4.*K0/3.;
0317     _Keq[i][5] = ST43 + reSum(RE43, int(fmod(double(_sums[4]), 3.))) + int((double(_sums[4]) / 3.));  //eq. AD
0318 
0319     _Xeq[i][0] = (-_sums[10] + 5. * K0) / 4.;
0320     _Xeq[i][1] = (_difs[4] + 3. * K0) / 4.;
0321   }
0322 
0323   i = 9;  //  i = DTBtiChipEQMAP->index("1368C");  --> 1R3L6L8L
0324   if (PTMS[i]) {
0325     _Keq[i][0] = (_sums[1]);
0326     _Keq[i][1] = _difs[10] + 2. * K0;
0327     _Keq[i][2] = _difs[20] + 2. * K0;
0328     _Keq[i][3] = (_sums[3] / 2.) + K0 + 0.01;
0329     _Keq[i][4] = (_difs[11] / 2.) + 2. * K0 + 0.01;
0330     //_Keq[i][5] =  (_sums[4]/3.)    + 4.*K0/3.;
0331     _Keq[i][5] = ST43 + reSum(RE43, int(fmod(double(_sums[4]), 3.))) + int((double(_sums[4]) / 3.));  //eq. AD
0332 
0333     _Xeq[i][0] = (_sums[10] + K0) / 4.;
0334     _Xeq[i][1] = (_difs[4] + 3. * K0) / 4.;
0335   }
0336 
0337   i = 10;  //  i = DTBtiChipEQMAP->index("5324A");  --> 5L3L2R4L
0338   if (PTMS[i]) {
0339     _Keq[i][0] = -_difs[9];
0340     _Keq[i][1] = -_sums[5] + 2. * K0;
0341     _Keq[i][2] = _sums[6];
0342     _Keq[i][3] = -(_sums[7] / 2.) + K0 + 0.01;
0343     _Keq[i][4] = (_difs[8] / 2.) + K0 + 0.01;
0344     //_Keq[i][5] = -(_difs[12]/3.) + 2.*K0/3.;
0345     _Keq[i][5] = ST23 + reSum23(RE23, int(fmod(double(-_difs[12]), 3.))) + int((double(-_difs[12]) / 3.));  //eq. AD
0346 
0347     _Xeq[i][0] = (_difs[5] + K0) / 4.;
0348     _Xeq[i][1] = (_sums[12] + K0) / 4.;
0349   }
0350 
0351   i = 11;  //  i = DTBtiChipEQMAP->index("5324B");  --> 5L3R2R4L
0352   if (PTMS[i]) {
0353     _Keq[i][0] = -_sums[9] + 2. * K0;
0354     _Keq[i][1] = _difs[5];
0355     _Keq[i][2] = _sums[6];
0356     _Keq[i][3] = -(_sums[7] / 2.) + K0 + 0.01;
0357     _Keq[i][4] = (_sums[8] / 2. + 0.01);
0358     //_Keq[i][5] = -(_difs[12]/3.) + 2.*K0/3.;
0359     _Keq[i][5] = ST23 + reSum23(RE23, int(fmod(double(-_difs[12]), 3.))) + int((double(-_difs[12]) / 3.));  //eq. AD
0360 
0361     _Xeq[i][0] = (-_sums[5] + 3. * K0) / 4.;
0362     _Xeq[i][1] = (_sums[12] + K0) / 4.;
0363   }
0364 
0365   i = 12;  //  i = DTBtiChipEQMAP->index("5324C");  --> 5R3R2R4L
0366   if (PTMS[i]) {
0367     _Keq[i][0] = _difs[9];
0368     _Keq[i][1] = _difs[5];
0369     _Keq[i][2] = (_sums[6]);
0370     _Keq[i][3] = (_difs[7] / 2.) + 0.01;
0371     _Keq[i][4] = (_sums[8] / 2.) + 0.01;
0372     _Keq[i][5] = (_sums[12] / 3.) + 0.51;
0373 
0374     _Xeq[i][0] = (-_sums[5] + 3. * K0) / 4.;
0375     _Xeq[i][1] = (-_difs[12] + 3. * K0) / 4.;
0376   }
0377 
0378   i = 13;  //  i = DTBtiChipEQMAP->index("5364A");  --> 5L3R6L4L
0379   if (PTMS[i]) {
0380     _Keq[i][0] = -_sums[9] + 2. * K0;
0381     _Keq[i][1] = _sums[10];
0382     _Keq[i][2] = -_difs[13];
0383     _Keq[i][3] = (_difs[16] / 2.) + K0 + 0.01;
0384     _Keq[i][4] = (_sums[8] / 2. + 0.01);
0385     //_Keq[i][5] = -(_difs[12]/3.)  +  2.*K0/3.;
0386     _Keq[i][5] = ST23 + reSum23(RE23, int(fmod(double(-_difs[12]), 3.))) + int((double(-_difs[12]) / 3.));  //eq. AD
0387 
0388     _Xeq[i][0] = (_difs[10] + 3. * K0) / 4.;
0389     _Xeq[i][1] = (_sums[12] + K0) / 4.;
0390   }
0391 
0392   i = 14;  //  i = DTBtiChipEQMAP->index("5364B");  --> 5L3R6L4R
0393   if (PTMS[i]) {
0394     _Keq[i][0] = -_sums[9] + 2. * K0;
0395     _Keq[i][1] = _sums[10];
0396     _Keq[i][2] = -_sums[13] + 2. * K0;
0397     _Keq[i][3] = (_difs[16] / 2.) + K0 + 0.01;
0398     _Keq[i][4] = -(_difs[8] / 2.) + K0 + 0.01;
0399     //_Keq[i][5] = -(_sums[12]/3.)  + 4.*K0/3.;
0400     _Keq[i][5] = ST43 + reSum(RE43, int(fmod(double(-_sums[12]), 3.))) + int((double(-_sums[12]) / 3.));
0401 
0402     _Xeq[i][0] = (_difs[10] + 3. * K0) / 4.;
0403     _Xeq[i][1] = (_difs[12] + 3. * K0) / 4.;
0404   }
0405 
0406   i = 15;  //  i = DTBtiChipEQMAP->index("5364C");  --> 5R3R6L4L
0407   if (PTMS[i]) {
0408     _Keq[i][0] = _difs[9];
0409     _Keq[i][1] = (_sums[10]);
0410     _Keq[i][2] = -_difs[13];
0411     _Keq[i][3] = (_sums[16] / 2. + 0.01);
0412     _Keq[i][4] = (_sums[8] / 2. + 0.01);
0413     _Keq[i][5] = (_sums[12] / 3.) + 0.51;
0414 
0415     _Xeq[i][0] = (_difs[10] + 3. * K0) / 4.;
0416     _Xeq[i][1] = (-_difs[12] + 3. * K0) / 4.;
0417   }
0418 
0419   i = 16;  //  i = DTBtiChipEQMAP->index("5364D");  --> 5R3R6L4R
0420   if (PTMS[i]) {
0421     _Keq[i][0] = _difs[9];
0422     _Keq[i][1] = _sums[10];
0423     _Keq[i][2] = -_sums[13] + 2. * K0;
0424     _Keq[i][3] = (_sums[16] / 2. + 0.01);
0425     _Keq[i][4] = -(_difs[8] / 2.) + K0 + 0.01;
0426     //_Keq[i][5] =  (_difs[12]/3.) + 2.*K0/3.;
0427     _Keq[i][5] = ST23 + reSum23(RE23, int(fmod(double(_difs[12]), 3.))) + int((double(_difs[12]) / 3.));  //eq. AD
0428 
0429     _Xeq[i][0] = (_difs[10] + 3. * K0) / 4.;
0430     _Xeq[i][1] = (-_sums[12] + 5. * K0) / 4.;
0431   }
0432 
0433   i = 17;  //  i = DTBtiChipEQMAP->index("5368A");  --> 5L3R6L8L
0434   if (PTMS[i]) {
0435     _Keq[i][0] = -_sums[9] + 2. * K0;
0436     _Keq[i][1] = _sums[10];
0437     _Keq[i][2] = _difs[20] + 2. * K0;
0438     _Keq[i][3] = (_difs[16] / 2.) + K0 + 0.01;
0439     _Keq[i][4] = (_sums[11] / 2.) + K0 + 0.01;
0440     //_Keq[i][5] =  (_difs[18]/3.)  + 4.*K0/3.;
0441     _Keq[i][5] = ST43 + reSum(RE43, int(fmod(double(_difs[18]), 3.))) + int((double(_difs[18]) / 3.));  //eq. AD
0442 
0443     _Xeq[i][0] = (_difs[10] + 3. * K0) / 4.;
0444     _Xeq[i][1] = (_sums[18] + 3. * K0) / 4.;
0445   }
0446 
0447   i = 18;  //  i = DTBtiChipEQMAP->index("5368B");  --> 5L3R6R8L
0448   if (PTMS[i]) {
0449     _Keq[i][0] = -_sums[9] + 2. * K0;
0450     _Keq[i][1] = -_difs[10] + 2. * K0;
0451     _Keq[i][2] = _sums[20];
0452     _Keq[i][3] = -(_sums[16] / 2.) + 2. * K0 + 0.01;
0453     _Keq[i][4] = (_sums[11] / 2.) + K0 + 0.01;
0454     //_Keq[i][5] =  (_difs[18]/3.)  + 4.*K0/3.;
0455     _Keq[i][5] = ST43 + reSum(RE43, int(fmod(double(_difs[18]), 3.))) + int((double(_difs[18]) / 3.));  //eq. AD
0456 
0457     _Xeq[i][0] = (-_sums[10] + 5. * K0) / 4.;
0458     _Xeq[i][1] = (_sums[18] + 3. * K0) / 4.;
0459   }
0460 
0461   i = 19;  //  i = DTBtiChipEQMAP->index("5368C");  --> 5L3R6R8R
0462   if (PTMS[i]) {
0463     _Keq[i][0] = -(_sums[9]) + 2. * K0;
0464     _Keq[i][1] = -_difs[10] + 2. * K0;
0465     _Keq[i][2] = -_difs[20] + 2. * K0;
0466     _Keq[i][3] = -(_sums[16] / 2.) + 2. * K0 + 0.01;
0467     _Keq[i][4] = -(_difs[11] / 2.) + 2. * K0 + 0.01;
0468     //_Keq[i][5] = -(_sums[18]/3.)  + 2.*K0 + 0.51;
0469     _Keq[i][5] = ST2 + reSum23(0, int(fmod(double(-_sums[18]), 3.))) + int((double(-_sums[18]) / 3.));
0470 
0471     _Xeq[i][0] = (-_sums[10] + 5. * K0) / 4.;
0472     _Xeq[i][1] = (-_difs[18] + 5. * K0) / 4.;
0473   }
0474 
0475   i = 20;  //  i = DTBtiChipEQMAP->index("5764A");  --> 5R7L6L4R
0476   if (PTMS[i]) {
0477     _Keq[i][0] = _sums[17];
0478     _Keq[i][1] = -_difs[19];
0479     _Keq[i][2] = -_sums[13] + 2. * K0;
0480     _Keq[i][3] = (_sums[16] / 2. + 0.01);
0481     _Keq[i][4] = -(_sums[14] / 2.) + K0 + 0.01;
0482     //_Keq[i][5] =  (_difs[12]/3.)  + 2.*K0/3.;
0483     _Keq[i][5] = ST23 + reSum23(RE23, int(fmod(double(_difs[12]), 3.))) + int((double(_difs[12]) / 3.));  //eq. AD
0484 
0485     _Xeq[i][0] = (_sums[19] + 3. * K0) / 4.;
0486     _Xeq[i][1] = (-_sums[12] + 5. * K0) / 4.;
0487   }
0488 
0489   i = 21;  //  i = DTBtiChipEQMAP->index("5764B");  --> 5R7L6R4R
0490   if (PTMS[i]) {
0491     _Keq[i][0] = _sums[17];
0492     _Keq[i][1] = -_sums[19] + 2. * K0;
0493     _Keq[i][2] = _difs[13];
0494     _Keq[i][3] = -(_difs[16] / 2.) + K0 + 0.01;
0495     _Keq[i][4] = -(_sums[14] / 2.) + K0 + 0.01;
0496     //_Keq[i][5] =  (_difs[12]/3.) + 2.*K0/3.;
0497     _Keq[i][5] = ST23 + reSum23(RE23, int(fmod(double(_difs[12]), 3.))) + int((double(_difs[12]) / 3.));  //eq. AD
0498 
0499     _Xeq[i][0] = (_difs[19] + 5. * K0) / 4.;
0500     _Xeq[i][1] = (-_sums[12] + 5. * K0) / 4.;
0501   }
0502 
0503   i = 22;  //  i = DTBtiChipEQMAP->index("5764C");  --> 5R7L6L4L
0504   if (PTMS[i]) {
0505     _Keq[i][0] = (_sums[17]);
0506     _Keq[i][1] = -_difs[19];
0507     _Keq[i][2] = -_difs[13];
0508     _Keq[i][3] = (_sums[16] / 2. + 0.01);
0509     _Keq[i][4] = -(_difs[14] / 2.) + 0.01;
0510     _Keq[i][5] = (_sums[12] / 3.) + 0.51;
0511 
0512     _Xeq[i][0] = (_sums[19] + 3. * K0) / 4.;
0513     _Xeq[i][1] = (-_difs[12] + 3. * K0) / 4.;
0514   }
0515 
0516   i = 23;  //  i = DTBtiChipEQMAP->index("9764A");  --> 9L7L6L4R
0517   if (PTMS[i]) {
0518     _Keq[i][0] = -_difs[23];
0519     _Keq[i][1] = -_difs[19];
0520     _Keq[i][2] = -(_sums[13]) + 2. * K0;
0521     _Keq[i][3] = -(_difs[21] / 2.) + 0.01;
0522     _Keq[i][4] = -(_sums[14] / 2.) + K0 + 0.01;
0523     //_Keq[i][5] = -(_sums[15]/3.)  + 2.*K0/3.;
0524     _Keq[i][5] = ST23 + reSum23(RE23, int(fmod(double(-_sums[15]), 3.))) + int((double(-_sums[15]) / 3.));  //eq. AD
0525 
0526     _Xeq[i][0] = (_sums[19] + 3. * K0) / 4.;
0527     _Xeq[i][1] = (_difs[15] + 5. * K0) / 4.;
0528   }
0529 
0530   i = 24;  //  i = DTBtiChipEQMAP->index("9764B");  --> 9L7L6R4R
0531   if (PTMS[i]) {
0532     _Keq[i][0] = -_difs[23];
0533     _Keq[i][1] = -(_sums[19]) + 2. * K0;
0534     _Keq[i][2] = _difs[13];
0535     _Keq[i][3] = -(_sums[21] / 2.) + K0 + 0.01;
0536     _Keq[i][4] = -(_sums[14] / 2.) + K0 + 0.01;
0537     //_Keq[i][5] = -(_sums[15]/3.)    + 2.*K0/3.;
0538     _Keq[i][5] = ST23 + reSum23(RE23, int(fmod(double(-_sums[15]), 3.))) + int((double(-_sums[15]) / 3.));  //eq. AD
0539 
0540     _Xeq[i][0] = (_difs[19] + 5. * K0) / 4.;
0541     _Xeq[i][1] = (_difs[15] + 5. * K0) / 4.;
0542   }
0543 
0544   i = 25;  //  i = DTBtiChipEQMAP->index("9764C");  --> 9L7R6R4R
0545   if (PTMS[i]) {
0546     _Keq[i][0] = -(_sums[23]) + 2. * K0;
0547     _Keq[i][1] = _difs[19];
0548     _Keq[i][2] = _difs[13];
0549     _Keq[i][3] = -(_sums[21] / 2.) + K0 + 0.01;
0550     _Keq[i][4] = (_difs[14] / 2.) + 0.01;
0551     //_Keq[i][5] = -(_sums[15]/3.)    + 2.*K0/3.;
0552     _Keq[i][5] = ST23 + reSum23(RE23, int(fmod(double(-_sums[15]), 3.))) + int((double(-_sums[15]) / 3.));  //eq. AD
0553 
0554     _Xeq[i][0] = (-_sums[19] + 7. * K0) / 4.;
0555     _Xeq[i][1] = (_difs[15] + 5. * K0) / 4.;
0556   }
0557 
0558   i = 26;  //  int i = DTBtiChipEQMAP->index("5768A") --> 5L7L6R8L
0559   if (PTMS[i]) {
0560     _Keq[i][0] = _difs[17] + 2. * K0;
0561     _Keq[i][1] = -_sums[19] + 2. * K0;
0562     _Keq[i][2] = _sums[20];
0563     _Keq[i][3] = -(_sums[16] / 2.) + 2. * K0 + 0.01;
0564     _Keq[i][4] = (_difs[22] / 2.) + K0 + 0.01;
0565     //_Keq[i][5] =  (_difs[18]/3.)  + 4.*K0/3.;
0566     _Keq[i][5] = ST43 + reSum(RE43, int(fmod(double(_difs[18]), 3.))) + int((double(_difs[18]) / 3.));  //eq. AD
0567 
0568     _Xeq[i][0] = (_difs[19] + 5. * K0) / 4.;
0569     _Xeq[i][1] = (_sums[18] + 3. * K0) / 4.;
0570   }
0571 
0572   i = 27;  //  i = DTBtiChipEQMAP->index("5768B");  --> 5L7L6R8R
0573   if (PTMS[i]) {
0574     _Keq[i][0] = _difs[17] + 2. * K0;
0575     _Keq[i][1] = -(_sums[19]) + 2. * K0;
0576     _Keq[i][2] = -_difs[20] + 2. * K0;
0577     _Keq[i][3] = -(_sums[16] / 2.) + 2. * K0 + 0.01;
0578     _Keq[i][4] = -(_sums[22] / 2.) + 2. * K0 + 0.01;
0579     //_Keq[i][5] = -(_sums[18]/3.)  + 2.*K0 + 0.51;
0580     _Keq[i][5] = ST2 + reSum23(0, int(fmod(double(-_sums[18]), 3.))) + int((double(-_sums[18]) / 3.));
0581 
0582     _Xeq[i][0] = (_difs[19] + 5. * K0) / 4.;
0583     _Xeq[i][1] = (-_difs[18] + 5. * K0) / 4.;
0584   }
0585 
0586   i = 28;  //  i = DTBtiChipEQMAP->index("5768C");  --> 5R7L6R8L
0587   if (PTMS[i]) {
0588     _Keq[i][0] = _sums[17];
0589     _Keq[i][1] = -_sums[19] + 2. * K0;
0590     _Keq[i][2] = _sums[20];
0591     _Keq[i][3] = -(_difs[16] / 2.) + K0 + 0.01;
0592     _Keq[i][4] = (_difs[22] / 2.) + K0 + 0.01;
0593     //_Keq[i][5] =  (_sums[18]/3.)  + 2.*K0/3.;
0594     _Keq[i][5] = ST23 + reSum23(RE23, int(fmod(double(_sums[18]), 3.))) + int((double(_sums[18]) / 3.));  //eq. AD
0595 
0596     _Xeq[i][0] = (_difs[19] + 5. * K0) / 4.;
0597     _Xeq[i][1] = (_difs[18] + 5. * K0) / 4.;
0598   }
0599 
0600   i = 29;  //  i = DTBtiChipEQMAP->index("5768D");  --> 5R7L6R8R
0601   if (PTMS[i]) {
0602     _Keq[i][0] = _sums[17];
0603     _Keq[i][1] = -_sums[19] + 2. * K0;
0604     _Keq[i][2] = -_difs[20] + 2. * K0;
0605     _Keq[i][3] = -(_difs[16] / 2.) + K0 + 0.01;
0606     _Keq[i][4] = -(_sums[22] / 2.) + 2. * K0 + 0.01;
0607     //_Keq[i][5] = -(_difs[18]/3.)  + 4.*K0/3. ;
0608     _Keq[i][5] = ST43 + reSum(RE43, int(fmod(double(-_difs[18]), 3.))) + int((double(-_difs[18]) / 3.));  //eq. AD
0609 
0610     _Xeq[i][0] = (_difs[19] + 5. * K0) / 4.;
0611     _Xeq[i][1] = (-_sums[18] + 7. * K0) / 4.;
0612   }
0613 
0614   i = 30;  //  9768A  --> 9L7L6R8L
0615   if (PTMS[i]) {
0616     _Keq[i][0] = -_difs[23];
0617     _Keq[i][1] = -_sums[19] + 2. * K0;
0618     _Keq[i][2] = _sums[20];
0619     _Keq[i][3] = -(_sums[21] / 2.) + K0 + 0.01;
0620     _Keq[i][4] = (_difs[22] / 2.) + K0 + 0.01;
0621     //_Keq[i][5] = -(_difs[24]/3.)  + 2.*K0/3. ;
0622     _Keq[i][5] = ST23 + reSum23(RE23, int(fmod(double(-_difs[24]), 3.))) + int((double(-_difs[24]) / 3.));  //eq. AD
0623 
0624     _Xeq[i][0] = (_difs[19] + 5. * K0) / 4.;
0625     _Xeq[i][1] = (_sums[24] + 5. * K0) / 4.;
0626   }
0627 
0628   i = 31;  //  9768B  --> 9L7R6R8L
0629   if (PTMS[i]) {
0630     _Keq[i][0] = -_sums[23] + 2. * K0;
0631     _Keq[i][1] = _difs[19];
0632     _Keq[i][2] = _sums[20];
0633     _Keq[i][3] = -(_sums[21] / 2.) + K0 + 0.01;
0634     _Keq[i][4] = (_sums[22] / 2.) + 0.01;
0635     //_Keq[i][5] = -(_difs[24]/3.)  + 2.*K0/3.;
0636     _Keq[i][5] = ST23 + reSum23(RE23, int(fmod(double(-_difs[24]), 3.))) + int((double(-_difs[24]) / 3.));  //eq. AD
0637 
0638     _Xeq[i][0] = (-_sums[19] + 7. * K0) / 4.;
0639     _Xeq[i][1] = (_sums[24] + 5. * K0) / 4.;
0640   }
0641 
0642   // debugging
0643   if (config()->debug() > 3) {
0644     cout << endl << " Step: " << currentStep() << endl;
0645     for (i = 0; i < 32; i++) {
0646       if (PTMS[i]) {
0647         cout << "K Equation " << i << " --> ";
0648         int j = 0;
0649         for (j = 0; j < 6; j++) {
0650           cout << _Keq[i][j] << " ";
0651         }
0652         cout << endl;
0653         cout << "X Equation " << i << " --> ";
0654         for (j = 0; j < 2; j++) {
0655           cout << _Xeq[i][j] << " ";
0656         }
0657         if (i == 0) {
0658           cout << _XeqAB_patt0 << " " << _XeqCD_patt0 << " ";
0659           cout << _XeqAC_patt0 << " " << _XeqBD_patt0 << " ";
0660         }
0661         cout << endl;
0662       }
0663     }
0664   }
0665   // end debugging
0666 }