Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-08 08:15:45

0001 #include <cassert>
0002 #include <iostream>
0003 #include <cstdlib>
0004 #include <string>
0005 using namespace std;
0006 
0007 #include "CalibCalorimetry/EcalLaserAnalyzer/interface/ME.h"
0008 #include "CalibCalorimetry/EcalLaserAnalyzer/interface/MEEEGeom.h"
0009 
0010 //GHM ClassImp(MEEEGeom)
0011 
0012 const bool MEEEGeom::pnTheory = true;
0013 
0014 int MEEEGeom::quadrant(SuperCrysCoord iX, SuperCrysCoord iY) {
0015   bool near = iX >= 11;
0016   bool far = !near;
0017   bool top = iY >= 11;
0018   bool bot = !top;
0019 
0020   int iquad = 0;
0021   if (near && top)
0022     iquad = 1;
0023   if (far && top)
0024     iquad = 2;
0025   if (far && bot)
0026     iquad = 3;
0027   if (near && bot)
0028     iquad = 4;
0029 
0030   return iquad;
0031 }
0032 
0033 int MEEEGeom::sector(SuperCrysCoord iX, SuperCrysCoord iY) {
0034   //  Y (towards the surface)
0035   //  T
0036   //  |
0037   //  |
0038   //  |
0039   //  o---------| X  (towards center of LHC)
0040   //
0041   static const int idx_[] = {
0042       // 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
0043       0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 9,
0044       9, 9, 0, 0, 0, 0, 0, 0, 0,  // 20
0045       0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 9,
0046       9, 9, 9, 9, 9, 0, 0, 0, 0,  // 19
0047       0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 9,
0048       9, 9, 9, 9, 9, 8, 0, 0, 0,  // 18
0049       0, 0, 2, 2, 2, 1, 1, 1, 1, 1, 9,
0050       9, 9, 9, 9, 8, 8, 8, 0, 0,  // 17
0051       0, 2, 2, 2, 2, 1, 1, 1, 1, 1, 9,
0052       9, 9, 9, 9, 8, 8, 8, 8, 0,  // 16
0053       0, 2, 2, 2, 2, 2, 1, 1, 1, 1, 9,
0054       9, 9, 9, 8, 8, 8, 8, 8, 0,  // 15
0055       0, 2, 2, 2, 2, 2, 2, 1, 1, 1, 9,
0056       9, 9, 8, 8, 8, 8, 8, 8, 0,  // 14
0057       2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 9,
0058       9, 8, 8, 8, 8, 8, 8, 8, 8,  // 13
0059       3, 3, 2, 2, 2, 2, 2, 2, 2, 0, 0,
0060       8, 8, 8, 8, 8, 8, 8, 7, 7,  // 12
0061       3, 3, 3, 3, 3, 3, 3, 2, 0, 0, 0,
0062       0, 8, 7, 7, 7, 7, 7, 7, 7,  // 11
0063       3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0,
0064       0, 7, 7, 7, 7, 7, 7, 7, 7,  // 10
0065       3, 3, 3, 3, 3, 3, 3, 4, 4, 0, 0,
0066       6, 6, 7, 7, 7, 7, 7, 7, 7,  // 9
0067       3, 3, 3, 3, 3, 3, 4, 4, 4, 5, 5,
0068       6, 6, 6, 7, 7, 7, 7, 7, 7,  // 8
0069       0, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5,
0070       6, 6, 6, 6, 6, 7, 7, 7, 0,  // 7
0071       0, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5,
0072       5, 6, 6, 6, 6, 6, 6, 7, 0,  // 6
0073       0, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5,
0074       5, 6, 6, 6, 6, 6, 6, 6, 0,  // 5
0075       0, 0, 4, 4, 4, 4, 4, 4, 5, 5, 5,
0076       5, 6, 6, 6, 6, 6, 6, 0, 0,  // 4
0077       0, 0, 0, 4, 4, 4, 4, 5, 5, 5, 5,
0078       5, 5, 6, 6, 6, 6, 0, 0, 0,  // 3
0079       0, 0, 0, 0, 4, 4, 4, 5, 5, 5, 5,
0080       5, 5, 6, 6, 6, 0, 0, 0, 0,  // 2
0081       0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5,
0082       5, 5, 0, 0, 0, 0, 0, 0, 0  // 1
0083                                  // 1  2  3  4  5  6  7  8  9 10   11 12 13 14 15 16 17 18 19 20
0084   };
0085 
0086   int iym, ixm, il, ic, ii;
0087   iym = 20;
0088   ixm = 20;
0089   int iX_ = iX;
0090   int iY_ = iY;
0091   il = iym - iY_;
0092   ic = iX_ - 1;
0093   ii = il * ixm + ic;
0094 
0095   if (ii < 0 || ii > (int)(sizeof(idx_) / sizeof(int)) || idx_[ii] == 0) {
0096     return -1;
0097   };
0098   return idx_[ii];
0099 }
0100 
0101 int MEEEGeom::sm(SuperCrysCoord iX, SuperCrysCoord iY, int iz) {
0102   // this is *my* convention. To be consistent with the barrel
0103   // sm goes from 1 to 9 for iz+ and from 10 to 18 for iz-
0104   int ism_ = sector(iX, iY);
0105   if (ism_ < 0)
0106     return ism_;
0107   if (iz < 0)
0108     ism_ += 9;
0109   return ism_;
0110 }
0111 
0112 int MEEEGeom::lmmod(SuperCrysCoord iX, SuperCrysCoord iY) {
0113   //
0114   // laser monitoring modules for EE-F and EE+F
0115   // for EE-N and EE+N :  iX ---> 20-iX+1
0116   //
0117 
0118   static const int idx_[] = {// 1  2  3   4   5   6   7   8   9   A
0119                              //------------------------------
0120                              0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  0,  0,  0,  0,  2,  1,  1,  1,  1,  1,  0,  0,  0,
0121                              5,  2,  2,  2,  2,  2,  1,  0,  0,  5,  5,  5,  3,  3,  2,  2,  2,  0,  8,  5,  5,  5,  3,
0122                              3,  3,  3,  3,  0,  8,  8,  5,  6,  6,  4,  4,  4,  3,  0,  8,  8,  5,  6,  6,  7,  4,  4,
0123                              4,  8,  8,  8,  6,  6,  7,  7,  7,  4,  4,  9,  9,  8,  6,  6,  7,  7,  7,  7,  0,  9,  9,
0124                              9,  10, 10, 11, 11, 7,  0,  0,  12, 9,  9,  10, 10, 11, 11, 11, 0,  0,  12, 12, 13, 10, 10,
0125                              11, 11, 17, 17, 0,  12, 12, 13, 13, 13, 11, 17, 17, 17, 19, 0,  12, 13, 13, 14, 15, 17, 17,
0126                              17, 19, 0,  12, 14, 14, 14, 15, 16, 17, 19, 19, 0,  14, 14, 14, 14, 15, 16, 16, 19, 19, 0,
0127                              0,  14, 15, 15, 15, 16, 16, 19, 19, 0,  0,  0,  15, 15, 15, 16, 18, 18, 18, 0,  0,  0,  0,
0128                              16, 16, 16, 18, 18, 18, 0,  0,  0,  0,  0,  0,  0,  18, 18, 18};
0129 
0130   int iym, ixm, il, ic, ii;
0131   iym = 20;
0132   ixm = 10;
0133   int iX_ = iX;
0134   if (iX >= 11)
0135     iX_ = 20 - iX + 1;
0136   int iY_ = iY;
0137   il = iym - iY_;
0138   ic = iX_ - 1;
0139   ii = il * ixm + ic;
0140   if (ii < 0 || ii > (int)(sizeof(idx_) / sizeof(int)) || idx_[ii] == 0) {
0141     return -1;
0142   };
0143   return idx_[ii];
0144 }
0145 
0146 int MEEEGeom::sc_in_quad(SuperCrysCoord iX, SuperCrysCoord iY) {
0147   static const int idx_[] = {
0148       // 1  2  3  4  5  6  7  8  9  A
0149       //-----------------------------------
0150       77, 71, 63, 55, 46, 37, 28, 18, 0,  0,  // A
0151       78, 72, 64, 56, 47, 38, 29, 19, 9,  0,  // 9
0152       79, 73, 65, 57, 48, 39, 30, 20, 10, 1,  // 8
0153       0,  74, 66, 58, 49, 40, 31, 21, 11, 2,  // 7
0154       0,  75, 67, 59, 50, 41, 32, 22, 12, 3,  // 6
0155       0,  76, 68, 60, 51, 42, 33, 23, 13, 4,  // 5
0156       0,  0,  69, 61, 52, 43, 34, 24, 14, 5,  // 4
0157       0,  0,  70, 62, 53, 44, 35, 25, 15, 6,  // 3
0158       0,  0,  0,  0,  54, 45, 36, 26, 16, 7,  // 2
0159       0,  0,  0,  0,  0,  0,  0,  27, 17, 8,  // 1
0160                                               //-----------------------------------
0161   };
0162   int iym, ixm, il, ic, ii;
0163   iym = 10;
0164   ixm = 10;
0165   int iX_ = iX;
0166   if (iX >= 11)
0167     iX_ = 20 - iX + 1;
0168   int iY_ = iY;
0169   if (iY >= 11)
0170     iY_ = 20 - iY + 1;
0171   il = iym - iY_;
0172   ic = iX_ - 1;
0173   ii = il * ixm + ic;
0174   if (ii < 0 || ii > (int)(sizeof(idx_) / sizeof(int)) || idx_[ii] == 0) {
0175     return -1;
0176   };
0177   return idx_[ii];
0178 }
0179 
0180 int MEEEGeom::sc_type(SuperCrysCoord iX, SuperCrysCoord iY) {
0181   static const int idx_[] = {
0182       // there are seven types of super-crystals
0183       // 1  2  3  4  5  6  7  8  9 10
0184       //-----------------------------------
0185       0,  0,  0,  0,  0,  0,  0,  3, -1, -1,  // 10
0186       0,  0,  0,  0,  0,  0,  0,  0, 2,  -1,  //  9
0187       6,  0,  0,  0,  0,  0,  0,  0, 0,  1,   //  8
0188       -1, 0,  0,  0,  0,  0,  0,  0, 0,  0,   //  7
0189       -1, 0,  0,  0,  0,  0,  0,  0, 0,  0,   //  6
0190       -1, 6,  0,  0,  0,  0,  0,  0, 0,  0,   //  5
0191       -1, -1, 6,  0,  0,  0,  0,  0, 0,  0,   //  4
0192       -1, -1, 5,  4,  0,  0,  0,  0, 0,  0,   //  3
0193       -1, -1, -1, -1, 4,  0,  0,  0, 0,  0,   //  2
0194       -1, -1, -1, -1, -1, -1, -1, 4, 0,  0,   //  1
0195                                               //-----------------------------------
0196   };
0197   int iym, ixm, il, ic, ii;
0198   iym = 10;
0199   ixm = 10;
0200   int iX_ = iX;
0201   if (iX >= 11)
0202     iX_ = 20 - iX + 1;
0203   int iY_ = iY;
0204   if (iY >= 11)
0205     iY_ = 20 - iY + 1;
0206   il = iym - iY_;
0207   ic = iX_ - 1;
0208   ii = il * ixm + ic;
0209   if (ii < 0 || ii > (int)(sizeof(idx_) / sizeof(int)) || idx_[ii] == -1) {
0210     return -1;
0211   };
0212   return idx_[ii];
0213 }
0214 
0215 int MEEEGeom::sc(SuperCrysCoord iX, SuperCrysCoord iY) {
0216   int isc_in_quad = sc_in_quad(iX, iY);
0217   assert(isc_in_quad != 0);
0218   if (isc_in_quad < 0)
0219     return -1;
0220 
0221   int iquad = quadrant(iX, iY);
0222   return 79 * (iquad - 1) + isc_in_quad;
0223 }
0224 
0225 int MEEEGeom::dcc(SuperCrysCoord iX, SuperCrysCoord iY, int iz) {
0226   // end-cap minus:
0227   // S7  --> DCC-1 (N)
0228   // S8  --> DCC-2 (N)
0229   // S9  --> DCC-3 (N)
0230   // S1  --> DCC-4 (F)
0231   // S2  --> DCC-5 (F)
0232   // S3  --> DCC-6 (F)
0233   // S4  --> DCC-7 (F)
0234   // S5  --> DCC-8 (F and N)
0235   // S6  --> DCC-9 (N)
0236   // for the end-cap plus, add 45 to the DCC number
0237   int isect = sector(iX, iY);
0238   assert(isect != 0);
0239   assert(abs(iz) == 1);
0240   if (isect < 0)
0241     return -1;
0242 
0243   int idcc = 0;
0244 
0245   idcc = isect - 6;
0246   if (idcc <= 0)
0247     idcc += 9;
0248   if (iz == +1)
0249     idcc += 45;
0250 
0251   return idcc;
0252 }
0253 
0254 int MEEEGeom::lmr(SuperCrysCoord iX, SuperCrysCoord iY, int iz) {
0255   // laser monitoring regions
0256   // end-cap minus:
0257   // S7  --> LM-1
0258   // S8  --> LM-2
0259   // S9  --> LM-3
0260   // S1  --> LM-4
0261   // S2  --> LM-5
0262   // S3  --> LM-6
0263   // S4  --> LM-7
0264   // S5  --> LM-8 (F) and LM-9 (N)
0265   // S6  --> LM-10
0266   // for the end-cap plus,  add 72 to the LM number
0267   // for the end-cap minus, add 82 to the LM number
0268 
0269   int iquad = quadrant(iX, iY);
0270   int isect = sector(iX, iY);
0271   assert(isect != 0);
0272   assert(abs(iz) == 1);
0273   if (isect < 0)
0274     return -1;
0275 
0276   int ilmr = 0;
0277   ilmr = isect - 6;
0278   if (ilmr <= 0)
0279     ilmr += 9;
0280   if (ilmr == 9)
0281     ilmr++;
0282   if (ilmr == 8 && iquad == 4)
0283     ilmr++;
0284   if (iz == +1)
0285     ilmr += 72;
0286   else
0287     ilmr += 82;
0288 
0289   return ilmr;
0290 }
0291 
0292 int MEEEGeom::dee(SuperCrysCoord iX, SuperCrysCoord iY, int iz) {
0293   int iquad = quadrant(iX, iY);
0294   int idee = 0;
0295   bool far = (iquad == 2 || iquad == 3);
0296   bool near = !far;
0297   bool plus = (iz > 0);
0298   bool minus = !plus;
0299   if (far && plus)
0300     idee = 1;
0301   if (near && plus)
0302     idee = 2;
0303   if (near && minus)
0304     idee = 3;
0305   if (far && minus)
0306     idee = 4;
0307 
0308   return idee;
0309 }
0310 
0311 int MEEEGeom::crystal_in_sc(CrysCoord ix, CrysCoord iy) {
0312   // the seven types of super-crystals
0313   static const int idx_[7][25] = {
0314       {21, 16, 11, 6, 1, 22, 17, 12, 7, 2, 23, 18, 13, 8, 3, 24, 19, 14, 9, 4, 25, 20, 15, 10, 5},
0315       {
0316           -1, -1, -1, -1, -1, 22, 17, 12, 7, 2, 23, 18, 13, 8, 3, 24, 19, 14, 9, 4, 25, 20, 15, 10, 5,
0317       },
0318       {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 23, -1, -1, -1, -1, 24, 19, -1, -1, -1, 25, 20, 15, -1, -1},
0319       {21, 16, 11, 6, -1, 22, 17, 12, 7, -1, 23, 18, 13, 8, -1, 24, 19, 14, 9, -1, 25, 20, 15, 10, -1},
0320       {
0321           21, 16, 11, 6, 1, 22, 17, 12, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
0322       },
0323       {
0324           -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
0325       },
0326       {-1, -1, -1, 6, 1, -1, -1, -1, 7, 2, -1, -1, -1, 8, 3, -1, -1, -1, 9, 4, -1, -1, -1, 10, 5}};
0327 
0328   int iX, iY, jx, jy;
0329   int iX_ = (ix - 1) / 5 + 1;
0330   int iY_ = (iy - 1) / 5 + 1;
0331   int jx_ = ix - 5 * (iX_ - 1);
0332   int jy_ = iy - 5 * (iY_ - 1);
0333 
0334   int iquad = quadrant(iX_, iY_);
0335   if (iX_ >= 11) {
0336     iX_ = 20 - iX_ + 1;
0337     jx_ = 5 - jx_ + 1;
0338   }
0339   if (iY_ >= 11) {
0340     iY_ = 20 - iY_ + 1;
0341     jy_ = 5 - jy_ + 1;
0342   }
0343 
0344   // FIXME : this is stupid !!!
0345   if (iquad == 1 || iquad == 3) {
0346     iX = iX_;
0347     iY = iY_;
0348     jx = jx_;
0349     jy = jy_;
0350   } else {
0351     iX = iY_;
0352     iY = iX_;
0353     jx = jy_;
0354     jy = jx_;
0355   }
0356 
0357   int isc_type = sc_type(iX, iY);
0358   assert(isc_type >= 0 && isc_type < 7);
0359 
0360   int iym, ixm, il, ic, ii;
0361   iym = 5;
0362   ixm = 5;
0363   il = iym - jy;
0364   ic = jx - 1;
0365   ii = il * ixm + ic;
0366   if (ii < 0 || ii > (int)(sizeof(idx_) / sizeof(int)) || idx_[isc_type][ii] == -1) {
0367     return -1;
0368   };
0369   return idx_[isc_type][ii];
0370 }
0371 
0372 int MEEEGeom::crystal(CrysCoord ix, CrysCoord iy) {
0373   int iX = (ix - 1) / 5 + 1;
0374   int iY = (iy - 1) / 5 + 1;
0375   int isc = sc(iX, iY);
0376   assert(isc != 0);
0377   if (isc < 0)
0378     return -2;
0379 
0380   int icr_in_sc = crystal_in_sc(ix, iy);
0381   assert(icr_in_sc != 0);
0382   if (icr_in_sc < 0)
0383     return -1;
0384 
0385   return 25 * (isc - 1) + icr_in_sc;
0386 }
0387 
0388 TString MEEEGeom::smName(int ism) {
0389   assert(ism >= 1 && ism <= 18);
0390   TString out = "EE+";
0391   if (ism > 9) {
0392     out = "EE-";
0393     ism -= 9;
0394   }
0395   out += ism;
0396   return out;
0397 }
0398 
0399 int MEEEGeom::dccFromSm(int ism) {
0400   assert(ism >= 1 && ism <= 18);
0401   int dcc_[18] = {49, 50, 51, 52, 53, 54, 46, 47, 48, 4, 5, 6, 7, 8, 9, 1, 2, 3};
0402   return dcc_[ism - 1];
0403 }
0404 
0405 int MEEEGeom::smFromDcc(int idcc) {
0406   if (idcc > 600)
0407     idcc -= 600;  // also works with FEDids
0408   int ism(0);
0409   if (idcc >= 1 && idcc <= 9) {
0410     ism = 6 + idcc;
0411     if (ism > 9)
0412       ism -= 9;
0413     ism += 9;
0414   } else if (idcc >= 46 && idcc <= 54) {
0415     ism = idcc - 46 + 7;
0416     if (ism > 9)
0417       ism -= 9;
0418   } else
0419     abort();
0420   return ism;
0421 }
0422 
0423 TGraph* MEEEGeom::getGraphBoundary(int type, int num, int iz, int xside) {
0424   std::list<std::pair<float, float> > l;
0425   getBoundary(l, type, num, iz, xside);
0426   int n = l.size();
0427   if (n == 0)
0428     return nullptr;
0429 
0430   // GHM : changed to comply to CMSSW compilator options
0431   float ix[1000];
0432   float iy[1000];
0433   assert(n < 1000);
0434 
0435   int ii = 0;
0436   std::list<std::pair<float, float> >::const_iterator l_it;
0437   for (l_it = l.begin(); l_it != l.end(); ++l_it) {
0438     //      std::cout << "[" << l_it->first << "," << l_it->second << "]" << std::endl;
0439     ix[ii] = l_it->first;
0440     iy[ii] = l_it->second;
0441     ii++;
0442   }
0443   assert(ii == n);
0444   return new TGraph(n, ix, iy);
0445 }
0446 
0447 void MEEEGeom::getBoundary(std::list<std::pair<float, float> >& l, int type, int num, int iz, int xside) {
0448   // for each iy, get first and last ix for <whatever>
0449   std::multimap<int, std::pair<int, int> > map_;
0450 
0451   int iymin = 1;
0452   int iymax = 100;
0453   int ixmin = 1;
0454   int ixmax = 100;
0455   if (xside == 1) {
0456     ixmin = 1;
0457     ixmax = 50;
0458   }
0459   if (xside == 2) {
0460     ixmin = 51;
0461     ixmax = 100;
0462   }
0463 
0464   for (int iy = iymin; iy <= iymax; iy++) {
0465     bool in = false;
0466     int firstix(0);
0467     int lastix(0);
0468     for (int ix = ixmin; ix <= ixmax; ix++) {
0469       int icr = crystal(ix, iy);
0470       bool ok = icr > 0;
0471 
0472       int iX = (ix - 1) / 5 + 1;
0473       int iY = (iy - 1) / 5 + 1;
0474 
0475       int num_(0);
0476       switch (type) {
0477         case iDee:
0478           num_ = dee(iX, iY, iz);
0479           break;
0480         case iQuadrant:
0481           num_ = quadrant(iX, iY);
0482           break;
0483         case iSector:
0484           num_ = sector(iX, iY);
0485           break;
0486         case iLMRegion:
0487           num_ = lmr(iX, iY, iz);
0488           break;
0489         case iLMModule:
0490           num_ = lmmod(iX, iY);
0491           break;
0492         case iDCC:
0493           num_ = dcc(iX, iY, iz);
0494           break;
0495         case iSuperCrystal:
0496           num_ = sc(iX, iY);
0497           break;
0498         case iCrystal:
0499           num_ = crystal(ix, iy);
0500           break;
0501         default:
0502           abort();
0503       };
0504       ok &= num_ == num;
0505 
0506       if (!in && !ok)
0507         continue;
0508       if (in && ok) {
0509         lastix = ix;
0510         continue;
0511       }
0512       if (!in && ok) {
0513         in = true;
0514         firstix = ix;
0515       } else if (in && !ok) {
0516         in = false;
0517         map_.insert(std::pair<int, std::pair<int, int> >(iy, std::pair<int, int>(firstix, lastix)));
0518       }
0519     }
0520     if (in)
0521       map_.insert(std::pair<int, std::pair<int, int> >(iy, std::pair<int, int>(firstix, lastix)));
0522   }
0523 
0524   // clean the list
0525   l.clear();
0526 
0527   std::multimap<int, std::pair<int, int> >::const_iterator it;
0528   std::multimap<int, std::pair<int, int> >::const_iterator lastelement;
0529   std::list<std::pair<float, float> > rightl;
0530   for (int iy = 1; iy <= 100; iy++) {
0531     it = map_.find(iy);
0532     if (it == map_.end())
0533       continue;
0534     int n_ = map_.count(iy);
0535     //      std::cout << "n[" << iy << "]=" << n_ << std::endl;
0536     assert(n_ == 1);  // fixme !
0537 
0538     lastelement = map_.upper_bound(iy);
0539     for (; it != lastelement; ++it) {
0540       std::pair<float, float> p_ = it->second;
0541       l.push_back(std::pair<float, float>(p_.first - 0.5, iy - 0.5));
0542       l.push_back(std::pair<float, float>(p_.first - 0.5, iy + 0.5));
0543       rightl.push_back(std::pair<float, float>(p_.second + 0.5, iy - 0.5));
0544       rightl.push_back(std::pair<float, float>(p_.second + 0.5, iy + 0.5));
0545     }
0546   }
0547   l.unique();
0548   rightl.unique();
0549   rightl.reverse();
0550 
0551   std::list<std::pair<float, float> >::const_iterator rightl_it;
0552   for (rightl_it = rightl.begin(); rightl_it != rightl.end(); ++rightl_it) {
0553     l.push_back(std::pair<float, float>(rightl_it->first, rightl_it->second));
0554   }
0555   l.push_back(*l.begin());
0556 }
0557 
0558 int MEEEGeom::deeFromMem(int imem) {
0559   int imem_ = imem % 600;
0560   int dee_(0);
0561   if (imem_ == 50 || imem_ == 51)
0562     dee_ = 1;
0563   else if (imem_ == 47 || imem_ == 46)
0564     dee_ = 2;
0565   else if (imem_ == 1 || imem_ == 2)
0566     dee_ = 3;
0567   else if (imem_ == 5 || imem_ == 6)
0568     dee_ = 4;
0569   else
0570     abort();
0571   return dee_;
0572 }
0573 
0574 std::pair<int, int> MEEEGeom::pn(int dee, int ilmmod) {
0575   // table below
0576   // convention to be consistent with Marc's numbering
0577   // PNA = 100 + pn + 1
0578   // PNB = 200 + pn + 1
0579 
0580   // LMR=73 EE+7(646/0)
0581   // -- module 9     PNA=(647)106    PNB=(646)201
0582   // -- module 10    PNA=(647)103    PNB=(646)208
0583   // -- module 11    PNA=(647)103    PNB=(646)203
0584   // -- module 12    PNA=(647)101    PNB=(646)206
0585   // -- module 13    PNA=(647)104    PNB=(646)209
0586   // LMR=74 EE+8(647/0)
0587   // -- module 5     PNA=(647)105    PNB=(646)210
0588   // -- module 6     PNA=(647)110    PNB=(646)205
0589   // -- module 7     PNA=(647)107    PNB=(646)202
0590   // -- module 8     PNA=(647)105    PNB=(646)210
0591   // LMR=75 EE+9(648/0)
0592   // -- module 1     PNA=(647)110    PNB=(646)205
0593   // -- module 2     PNA=(647)107    PNB=(646)202
0594   // -- module 3     PNA=(647)105    PNB=(646)210
0595   // -- module 4     PNA=(647)105    PNB=(646)210
0596   // LMR=76 EE+1(649/0)
0597   // -- module 1     PNA=(650)102    PNB=(651)206
0598   // -- module 2     PNA=(650)102    PNB=(651)207
0599   // -- module 3     PNA=(650)103    PNB=(651)208
0600   // -- module 4     PNA=(650)104    PNB=(651)209
0601   // LMR=77 EE+2(650/0)
0602   // -- module 5     PNA=(650)103    PNB=(651)208
0603   // -- module 6     PNA=(650)102    PNB=(651)206
0604   // -- module 7     PNA=(650)102    PNB=(651)207
0605   // -- module 8     PNA=(650)104    PNB=(651)209
0606   // LMR=78 EE+3(651/0)
0607   // -- module 9     PNA=(650)106    PNB=(651)201
0608   // -- module 10    PNA=(650)107    PNB=(651)202
0609   // -- module 11    PNA=(650)108    PNB=(651)203
0610   // -- module 12    PNA=(650)109    PNB=(651)204
0611   // -- module 13    PNA=(650)110    PNB=(651)205
0612   // LMR=79 EE+4(652/0)
0613   // -- module 14    PNA=(650)108    PNB=(651)203
0614   // -- module 15    PNA=(650)106    PNB=(651)201
0615   // -- module 16    PNA=(650)107    PNB=(651)202
0616   // -- module 17    PNA=(650)110    PNB=(651)205
0617   // LMR=80 EE+5(653/0)
0618   // -- module 18    PNA=(650)105    PNB=(651)210
0619   // -- module 19    PNA=(650)109    PNB=(651)204
0620   // LMR=81 EE+5(653/1)
0621   // -- module 18    PNA=(647)101    PNB=(646)206
0622   // -- module 19    PNA=(647)101    PNB=(646)206
0623   // LMR=82 EE+6(654/0)
0624   // -- module 14    PNA=(647)108    PNB=(646)203
0625   // -- module 15    PNA=(647)106    PNB=(646)201
0626   // -- module 16    PNA=(647)103    PNB=(646)208
0627   // -- module 17    PNA=(647)104    PNB=(646)209
0628   // LMR=83 EE-7(601/0)
0629   // -- module 9     PNA=(601)108    PNB=(602)203
0630   // -- module 10    PNA=(601)105    PNB=(602)210
0631   // -- module 11    PNA=(601)106    PNB=(602)201
0632   // -- module 12    PNA=(601)110    PNB=(602)205
0633   // -- module 13    PNA=(601)110    PNB=(602)205
0634   // LMR=84 EE-8(602/0)
0635   // -- module 5     PNA=(601)103    PNB=(602)208
0636   // -- module 6     PNA=(601)101    PNB=(602)206
0637   // -- module 7     PNA=(601)101    PNB=(602)206
0638   // -- module 8     PNA=(601)103    PNB=(602)209
0639   // LMR=85 EE-9(603/0)
0640   // -- module 1     PNA=(601)101    PNB=(602)206
0641   // -- module 2     PNA=(601)101    PNB=(602)206
0642   // -- module 3     PNA=(601)103    PNB=(602)208
0643   // -- module 4     PNA=(601)103    PNB=(602)209
0644   // LMR=86 EE-1(604/0)
0645   // -- module 1     PNA=(605)105    PNB=(606)210
0646   // -- module 2     PNA=(605)102    PNB=(606)207
0647   // -- module 3     PNA=(605)102    PNB=(606)207
0648   // -- module 4     PNA=(605)110    PNB=(606)205
0649   // LMR=87 EE-2(605/0)
0650   // -- module 5     PNA=(605)105    PNB=(606)210
0651   // -- module 6     PNA=(605)105    PNB=(606)210
0652   // -- module 7     PNA=(605)102    PNB=(606)207
0653   // -- module 8     PNA=(605)110    PNB=(606)205
0654   // LMR=88 EE-3(606/0)
0655   // -- module 9     PNA=(605)101    PNB=(606)206
0656   // -- module 10    PNA=(605)108    PNB=(606)203
0657   // -- module 11    PNA=(605)103    PNB=(606)208
0658   // -- module 12    PNA=(605)106    PNB=(606)201
0659   // -- module 13    PNA=(605)109    PNB=(606)204
0660   // LMR=89 EE-4(607/0)
0661   // -- module 14    PNA=(605)103    PNB=(606)208
0662   // -- module 15    PNA=(605)101    PNB=(606)206
0663   // -- module 16    PNA=(605)108    PNB=(606)203
0664   // -- module 17    PNA=(605)109    PNB=(606)204
0665   // LMR=90 EE-5(608/0)
0666   // -- module 18    PNA=(605)106    PNB=(606)201
0667   // -- module 19    PNA=(605)106    PNB=(606)201
0668   // LMR=91 EE-5(608/1)
0669   // -- module 18    PNA=(601)107    PNB=(602)202
0670   // -- module 19    PNA=(601)110    PNB=(602)205
0671   // LMR=92 EE-6(609/0)
0672   // -- module 14    PNA=(601)106    PNB=(602)201
0673   // -- module 15    PNA=(601)108    PNB=(602)203
0674   // -- module 16    PNA=(601)105    PNB=(602)210
0675   // -- module 17    PNA=(601)105    PNB=(602)210
0676 
0677   if (ilmmod == 20)
0678     ilmmod = 18;
0679   if (ilmmod == 21)
0680     ilmmod = 19;
0681 
0682   std::pair<int, int> pns(0, 0);
0683 
0684   if (pnTheory) {
0685     switch (ilmmod) {
0686       case 1:
0687         pns.first = 0;
0688         pns.second = 5;
0689         break;
0690       case 2:
0691         pns.first = 1;
0692         pns.second = 6;
0693         break;
0694       case 3:
0695         pns.first = 2;
0696         pns.second = 7;
0697         break;
0698       case 4:
0699         pns.first = 3;
0700         pns.second = 8;
0701         break;
0702       case 5:
0703         pns.first = 2;
0704         pns.second = 7;
0705         break;
0706       case 6:
0707         pns.first = 0;
0708         pns.second = 5;
0709         break;
0710       case 7:
0711         pns.first = 1;
0712         pns.second = 6;
0713         break;
0714       case 8:
0715         pns.first = 3;
0716         pns.second = 8;
0717         break;
0718       case 9:
0719         pns.first = 5;
0720         pns.second = 0;
0721         break;
0722       case 10:
0723         pns.first = 6;
0724         pns.second = 1;
0725         break;
0726       case 11:
0727         pns.first = 7;
0728         pns.second = 2;
0729         break;
0730       case 12:
0731         pns.first = 8;
0732         pns.second = 3;
0733         break;
0734       case 13:
0735         pns.first = 9;
0736         pns.second = 4;
0737         break;
0738       case 14:
0739         pns.first = 7;
0740         pns.second = 2;
0741         break;
0742       case 15:
0743         pns.first = 5;
0744         pns.second = 0;
0745         break;
0746       case 16:
0747         pns.first = 6;
0748         pns.second = 1;
0749         break;
0750       case 17:
0751         pns.first = 9;
0752         pns.second = 4;
0753         break;
0754       case 18:
0755         pns.first = 4;
0756         pns.second = 9;
0757         break;
0758       case 19:
0759         pns.first = 8;
0760         pns.second = 3;
0761         break;
0762       default:
0763         abort();
0764     };
0765   } else {
0766     // theoretical ~ dee 1
0767     if (dee == 1) {
0768       switch (ilmmod) {
0769           //    case   1: pns.first=0; pns.second=5; break;
0770         case 1:
0771           pns.first = 1;
0772           pns.second = 5;
0773           break;  // missing PNA
0774         case 2:
0775           pns.first = 1;
0776           pns.second = 6;
0777           break;
0778         case 3:
0779           pns.first = 2;
0780           pns.second = 7;
0781           break;
0782         case 4:
0783           pns.first = 3;
0784           pns.second = 8;
0785           break;
0786         case 5:
0787           pns.first = 2;
0788           pns.second = 7;
0789           break;
0790           //    case   6: pns.first=0; pns.second=5; break;
0791         case 6:
0792           pns.first = 1;
0793           pns.second = 5;
0794           break;  // missing PNA
0795         case 7:
0796           pns.first = 1;
0797           pns.second = 6;
0798           break;
0799         case 8:
0800           pns.first = 3;
0801           pns.second = 8;
0802           break;
0803         case 9:
0804           pns.first = 5;
0805           pns.second = 0;
0806           break;
0807         case 10:
0808           pns.first = 6;
0809           pns.second = 1;
0810           break;
0811         case 11:
0812           pns.first = 7;
0813           pns.second = 2;
0814           break;
0815         case 12:
0816           pns.first = 8;
0817           pns.second = 3;
0818           break;
0819         case 13:
0820           pns.first = 9;
0821           pns.second = 4;
0822           break;
0823         case 14:
0824           pns.first = 7;
0825           pns.second = 2;
0826           break;
0827         case 15:
0828           pns.first = 5;
0829           pns.second = 0;
0830           break;
0831         case 16:
0832           pns.first = 6;
0833           pns.second = 1;
0834           break;
0835         case 17:
0836           pns.first = 9;
0837           pns.second = 4;
0838           break;
0839         case 18:
0840           pns.first = 4;
0841           pns.second = 9;
0842           break;
0843         case 19:
0844           pns.first = 8;
0845           pns.second = 3;
0846           break;
0847         default:
0848           abort();
0849       };
0850     } else if (dee == 2) {
0851       switch (ilmmod) {
0852         case 1:
0853           pns.first = 9;
0854           pns.second = 4;
0855           break;
0856         case 2:
0857           pns.first = 6;
0858           pns.second = 1;
0859           break;
0860           //    case   3: pns.first=2; pns.second=7; break;
0861         case 3:
0862           pns.first = 4;
0863           pns.second = 9;
0864           break;  // missing PNA & PNB
0865         case 4:
0866           pns.first = 4;
0867           pns.second = 9;
0868           break;
0869           //    case   5: pns.first=2; pns.second=7; break;
0870         case 5:
0871           pns.first = 4;
0872           pns.second = 9;
0873           break;  // missing PNA & PNB
0874         case 6:
0875           pns.first = 9;
0876           pns.second = 4;
0877           break;
0878         case 7:
0879           pns.first = 6;
0880           pns.second = 1;
0881           break;
0882         case 8:
0883           pns.first = 4;
0884           pns.second = 9;
0885           break;
0886         case 9:
0887           pns.first = 5;
0888           pns.second = 0;
0889           break;
0890         case 10:
0891           pns.first = 2;
0892           pns.second = 7;
0893           break;
0894           //    case  11: pns.first=7; pns2second=2; break;
0895         case 11:
0896           pns.first = 2;
0897           pns.second = 2;
0898           break;  // PNA - fibre cassee
0899         case 12:
0900           pns.first = 0;
0901           pns.second = 5;
0902           break;
0903         case 13:
0904           pns.first = 3;
0905           pns.second = 8;
0906           break;
0907         case 14:
0908           pns.first = 7;
0909           pns.second = 2;
0910           break;
0911         case 15:
0912           pns.first = 5;
0913           pns.second = 0;
0914           break;
0915         case 16:
0916           pns.first = 2;
0917           pns.second = 7;
0918           break;
0919         case 17:
0920           pns.first = 3;
0921           pns.second = 8;
0922           break;
0923           //    case  18: pns.first=4; pns.second=9; break;
0924         case 18:
0925           pns.first = 0;
0926           pns.second = 5;
0927           break;  // missing PNA & PNB
0928         case 19:
0929           pns.first = 0;
0930           pns.second = 5;
0931           break;
0932         default:
0933           abort();
0934       };
0935     } else if (dee == 3) {
0936       switch (ilmmod) {
0937         case 1:
0938           pns.first = 0;
0939           pns.second = 5;
0940           break;
0941           //    case   2: pns.first=0; pns.second=1; break;
0942         case 2:
0943           pns.first = 0;
0944           pns.second = 5;
0945           break;  // missing PNA & PNB
0946         case 3:
0947           pns.first = 2;
0948           pns.second = 7;
0949           break;
0950           //    case   4: pns.first=4; pns.second=9; break;
0951         case 4:
0952           pns.first = 2;
0953           pns.second = 8;
0954           break;  // missing PNA
0955         case 5:
0956           pns.first = 2;
0957           pns.second = 7;
0958           break;
0959         case 6:
0960           pns.first = 0;
0961           pns.second = 5;
0962           break;
0963           //    case   7: pns.first=6; pns.second=1; break;
0964         case 7:
0965           pns.first = 0;
0966           pns.second = 5;
0967           break;  // missing PNA & PNB
0968           //    case   8: pns.first=4; pns.second=9; break;
0969         case 8:
0970           pns.first = 2;
0971           pns.second = 8;
0972           break;  // missing PNA
0973         case 9:
0974           pns.first = 7;
0975           pns.second = 2;
0976           break;
0977         case 10:
0978           pns.first = 4;
0979           pns.second = 9;
0980           break;
0981         case 11:
0982           pns.first = 5;
0983           pns.second = 0;
0984           break;
0985         case 12:
0986           pns.first = 9;
0987           pns.second = 4;
0988           break;
0989           //    case  13: pns.first=3; pns.second=8; break;
0990         case 13:
0991           pns.first = 9;
0992           pns.second = 4;
0993           break;  // missing PNA & PNB
0994         case 14:
0995           pns.first = 5;
0996           pns.second = 0;
0997           break;
0998         case 15:
0999           pns.first = 7;
1000           pns.second = 2;
1001           break;
1002         case 16:
1003           pns.first = 4;
1004           pns.second = 9;
1005           break;
1006           //    case  17: pns.first=3; pns.second=8; break;
1007         case 17:
1008           pns.first = 4;
1009           pns.second = 9;
1010           break;  // missing PNA & PNB
1011         case 18:
1012           pns.first = 6;
1013           pns.second = 1;
1014           break;
1015         case 19:
1016           pns.first = 9;
1017           pns.second = 4;
1018           break;
1019         default:
1020           abort();
1021       };
1022     } else if (dee == 4) {
1023       switch (ilmmod) {
1024         case 1:
1025           pns.first = 4;
1026           pns.second = 9;
1027           break;
1028         case 2:
1029           pns.first = 1;
1030           pns.second = 6;
1031           break;
1032           //    case   3: pns.first=6; pns.second=1; break;
1033         case 3:
1034           pns.first = 1;
1035           pns.second = 6;
1036           break;  // missing PNA & PNB
1037         case 4:
1038           pns.first = 9;
1039           pns.second = 4;
1040           break;
1041           //    case   5: pns.first=4; pns.second=9; break;
1042         case 5:
1043           pns.first = 4;
1044           pns.second = 9;
1045           break;  // missing PNA & PNB
1046         case 6:
1047           pns.first = 4;
1048           pns.second = 9;
1049           break;
1050         case 7:
1051           pns.first = 1;
1052           pns.second = 6;
1053           break;
1054         case 8:
1055           pns.first = 9;
1056           pns.second = 4;
1057           break;
1058         case 9:
1059           pns.first = 0;
1060           pns.second = 5;
1061           break;
1062         case 10:
1063           pns.first = 7;
1064           pns.second = 2;
1065           break;
1066         case 11:
1067           pns.first = 2;
1068           pns.second = 7;
1069           break;
1070         case 12:
1071           pns.first = 5;
1072           pns.second = 0;
1073           break;
1074         case 13:
1075           pns.first = 8;
1076           pns.second = 3;
1077           break;
1078         case 14:
1079           pns.first = 2;
1080           pns.second = 7;
1081           break;
1082         case 15:
1083           pns.first = 0;
1084           pns.second = 5;
1085           break;
1086         case 16:
1087           pns.first = 7;
1088           pns.second = 2;
1089           break;
1090         case 17:
1091           pns.first = 8;
1092           pns.second = 3;
1093           break;
1094           //    case  18: pns.first=9; pns.second=4; break;
1095         case 18:
1096           pns.first = 5;
1097           pns.second = 0;
1098           break;  // missing PNA & PNB
1099         case 19:
1100           pns.first = 5;
1101           pns.second = 0;
1102           break;
1103         default:
1104           abort();
1105       };
1106     }
1107   }
1108   return pns;
1109 }
1110 
1111 int MEEEGeom::dee(int ilmr) {
1112   int dee_(0);
1113   int i_[7] = {73, 76, 81, 83, 86, 91, 93};
1114   int d_[6] = {2, 1, 2, 3, 4, 3};
1115   for (int ii = 0; ii < 6; ii++) {
1116     if (ilmr >= i_[ii] && ilmr < i_[ii + 1]) {
1117       dee_ = d_[ii];
1118       break;
1119     }
1120   }
1121   if (dee_ == 0) {
1122     std::cout << "ilmr=" << ilmr << std::endl;
1123   }
1124   assert(dee_ != 0);
1125   return dee_;
1126 }
1127 
1128 std::pair<int, int> MEEEGeom::memFromLmr(int ilmr) {
1129   std::pair<int, int> out_;
1130   int dee_ = dee(ilmr);
1131   if (dee_ == 1)  // EE+F
1132   {
1133     out_.first = 50;
1134     out_.second = 51;
1135   } else if (dee_ == 2)  // EE+N
1136   {
1137     out_.first = 47;  // JM: warning -- inverted !!
1138     out_.second = 46;
1139   } else if (dee_ == 3)  // EE-N
1140   {
1141     out_.first = 1;
1142     out_.second = 2;
1143   } else if (dee_ == 4) {
1144     out_.first = 5;
1145     out_.second = 6;
1146   }
1147   return out_;
1148 }
1149 
1150 bool MEEEGeom::near(int ilmr) {
1151   int idee = dee(ilmr);
1152   return (idee == 2 || idee == 3);
1153 }
1154 
1155 int MEEEGeom::side(SuperCrysCoord iX, SuperCrysCoord iY, int iz) {
1156   int side = 0;
1157   int ilmr = lmr(iX, iY, iz);
1158   if (ilmr == 81 || ilmr == 91)
1159     side = 1;
1160 
1161   return side;
1162 }
1163 std::vector<int> MEEEGeom::lmmodFromLmr(int ilmr) {
1164   std::vector<int> vec;
1165 
1166   std::pair<int, int> dccAndSide_ = ME::dccAndSide(ilmr);
1167   int idcc = dccAndSide_.first;
1168   int iside = dccAndSide_.second;
1169   bool near_ = near(ilmr);
1170   int ism = smFromDcc(idcc);
1171   if (ism > 9)
1172     ism -= 9;
1173   assert(iside == 0 || ism == 5);
1174   if (ism == 5 || (ism < 5 && !near_) || (ism > 5 && near_)) {
1175   } else {
1176     std::cout << "ism/near " << ism << "/" << near_ << std::endl;
1177   }
1178 
1179   if (ism == 1 || ism == 9) {
1180     vec.push_back(1);
1181     vec.push_back(2);
1182     vec.push_back(3);
1183     vec.push_back(4);
1184   } else if (ism == 2 || ism == 8) {
1185     vec.push_back(5);
1186     vec.push_back(6);
1187     vec.push_back(7);
1188     vec.push_back(8);
1189   } else if (ism == 3 || ism == 7) {
1190     vec.push_back(9);
1191     vec.push_back(10);
1192     vec.push_back(11);
1193     vec.push_back(12);
1194     vec.push_back(13);
1195   } else if (ism == 4 || ism == 6) {
1196     vec.push_back(14);
1197     vec.push_back(15);
1198     vec.push_back(16);
1199     vec.push_back(17);
1200   } else {
1201     assert(ism == 5);
1202     vec.push_back(18);
1203     vec.push_back(19);
1204   }
1205   return vec;
1206 }
1207 
1208 int MEEEGeom::apdRefTower(int ilmr, int ilmmod) {
1209   int ilmr10 = ilmr % 10;
1210   int tower = 0;
1211 
1212   if (ilmr10 == 3) {
1213     switch (ilmmod) {
1214       case 9:
1215         tower = 77;
1216         break;
1217       case 10:
1218         tower = 55;
1219         break;
1220       case 11:
1221         tower = 37;
1222         break;
1223       case 12:
1224         tower = 310;
1225         break;
1226       case 13:
1227         tower = 294;
1228         break;
1229       default:
1230         abort();
1231     }
1232   } else if (ilmr10 == 4) {
1233     switch (ilmmod) {
1234       case 5:
1235         tower = 52;
1236         break;
1237       case 6:
1238         tower = 41;
1239         break;
1240       case 7:
1241         tower = 18;
1242         break;
1243       case 8:
1244         tower = 65;
1245         break;
1246       default:
1247         abort();
1248     }
1249   } else if (ilmr10 == 5) {
1250     switch (ilmmod) {
1251       case 1:
1252         tower = 45;
1253         break;
1254       case 2:
1255         tower = 53;
1256         break;
1257       case 3:
1258         tower = 42;
1259         break;
1260       case 4:
1261         tower = 32;
1262         break;
1263       default:
1264         abort();
1265     }
1266   } else if (ilmr10 == 6) {
1267     switch (ilmmod) {
1268       case 1:
1269         tower = 124;
1270         break;
1271       case 2:
1272         tower = 132;
1273         break;
1274       case 3:
1275         tower = 121;
1276         break;
1277       case 4:
1278         tower = 111;
1279         break;
1280       default:
1281         abort();
1282     }
1283   } else if (ilmr10 == 7) {
1284     switch (ilmmod) {
1285       case 5:
1286         tower = 147;
1287         break;
1288       case 6:
1289         tower = 135;
1290         break;
1291       case 7:
1292         tower = 117;
1293         break;
1294       case 8:
1295         tower = 158;
1296         break;
1297       default:
1298         abort();
1299     }
1300 
1301   } else if (ilmr10 == 8) {
1302     switch (ilmmod) {
1303       case 9:
1304         tower = 156;
1305         break;
1306       case 10:
1307         tower = 214;
1308         break;
1309       case 11:
1310         tower = 197;
1311         break;
1312       case 12:
1313         tower = 237;
1314         break;
1315       case 13:
1316         tower = 224;
1317         break;
1318       default:
1319         abort();
1320     }
1321   } else if (ilmr10 == 9) {
1322     switch (ilmmod) {
1323       case 14:
1324         tower = 234;
1325         break;
1326       case 15:
1327         tower = 220;
1328         break;
1329       case 16:
1330         tower = 212;
1331         break;
1332       case 17:
1333         tower = 189;
1334         break;
1335       default:
1336         abort();
1337     }
1338   } else if (ilmr10 == 0) {
1339     switch (ilmmod) {
1340       case 18:
1341         tower = 185;
1342         break;
1343       case 19:
1344         tower = 172;
1345         break;
1346       default:
1347         abort();
1348     }
1349   } else if (ilmr10 == 1) {
1350     switch (ilmmod) {
1351       case 18:
1352         tower = 264;
1353         break;
1354       case 19:
1355         tower = 251;
1356         break;
1357       default:
1358         abort();
1359     }
1360   }
1361   return tower;
1362 }
1363 
1364 std::vector<int> MEEEGeom::apdRefChannels(int ilmmod) {
1365   std::vector<int> vec;
1366   switch (ilmmod) {
1367     case 1:
1368       vec.push_back(0);
1369       vec.push_back(1);
1370       break;
1371     case 2:
1372       vec.push_back(0);
1373       vec.push_back(1);
1374       break;
1375     case 3:
1376       vec.push_back(0);
1377       vec.push_back(1);
1378       break;
1379     case 4:
1380       vec.push_back(0);
1381       vec.push_back(1);
1382       break;
1383     case 5:
1384       vec.push_back(0);
1385       vec.push_back(1);
1386       break;
1387     case 6:
1388       vec.push_back(0);
1389       vec.push_back(1);
1390       break;
1391     case 7:
1392       vec.push_back(0);
1393       vec.push_back(1);
1394       break;
1395     case 8:
1396       vec.push_back(0);
1397       vec.push_back(1);
1398       break;
1399     case 9:
1400       vec.push_back(0);
1401       vec.push_back(1);
1402       break;
1403     case 10:
1404       vec.push_back(0);
1405       vec.push_back(1);
1406       break;
1407     case 11:
1408       vec.push_back(0);
1409       vec.push_back(1);
1410       break;
1411     case 12:
1412       vec.push_back(0);
1413       vec.push_back(1);
1414       break;
1415     case 13:
1416       vec.push_back(0);
1417       vec.push_back(1);
1418       break;
1419     case 14:
1420       vec.push_back(0);
1421       vec.push_back(1);
1422       break;
1423     case 15:
1424       vec.push_back(0);
1425       vec.push_back(1);
1426       break;
1427     case 16:
1428       vec.push_back(0);
1429       vec.push_back(1);
1430       break;
1431     case 17:
1432       vec.push_back(0);
1433       vec.push_back(1);
1434       break;
1435     case 18:
1436       vec.push_back(0);
1437       vec.push_back(1);
1438       break;
1439     case 19:
1440       vec.push_back(0);
1441       vec.push_back(1);
1442       break;
1443     case 20:
1444       vec.push_back(0);
1445       vec.push_back(1);
1446       break;
1447     case 21:
1448       vec.push_back(0);
1449       vec.push_back(1);
1450       break;
1451 
1452     default:
1453       abort();
1454   }
1455   return vec;
1456 }