CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/src/CalibCalorimetry/HcalAlgos/src/HcalLogicalMapGenerator.cc

Go to the documentation of this file.
00001 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00002 #include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
00003 #include "DataFormats/HcalDetId/interface/HcalOtherDetId.h"
00004 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
00005 
00006 #include "CalibCalorimetry/HcalAlgos/interface/HcalLogicalMapGenerator.h"
00007 
00008 #include <string>
00009 #include <sstream>
00010 #include <stdio.h>
00011 #include <iostream>
00012 #include <cstring>
00013 
00014 using namespace std;
00015 
00016 /***************************************/
00017 
00018 HcalLogicalMapGenerator::HcalLogicalMapGenerator() {
00019   
00020   //adc and qie table; qie is entry 0, adc is entry 1. Constant across HB, HE, HO
00021   //  int iadcquiHBHE[NRMFIBR][NFCH][2];
00022  
00023   for (i = 0; i < NRMFIBR; i++){
00024     for (j = 0; j < NFCH; j++){
00025       //Intentionally relying on integer truncation here
00026       iadcquiHBHE[i][j][0] = i / 2 + 1;
00027       
00028       if (i % 2 == 0) iadcquiHBHE[i][j][1] = j;
00029       else            iadcquiHBHE[i][j][1] = NFCH + (j + 1) % 3;
00030     }
00031   }
00032 }
00033 
00034 HcalLogicalMapGenerator::~HcalLogicalMapGenerator() {
00035 
00036 }
00037 
00038 HcalLogicalMap HcalLogicalMapGenerator::createMap( unsigned int mapIOV ) {
00039 
00040   mapIOV_ = mapIOV;
00041 
00042   std::vector <HBHEHFLogicalMapEntry> HBHEHFEntries;
00043   std::vector <HOHXLogicalMapEntry> HOHXEntries;
00044   std::vector <CALIBLogicalMapEntry> CALIBEntries;
00045   std::vector <ZDCLogicalMapEntry> ZDCEntries;
00046   std::vector <HTLogicalMapEntry> HTEntries;
00047   std::vector <uint32_t> LinearIndex2Entry;
00048   std::vector <uint32_t> HbHash2Entry;
00049   std::vector <uint32_t> HeHash2Entry;
00050   std::vector <uint32_t> HfHash2Entry;
00051   std::vector <uint32_t> HtHash2Entry;
00052   std::vector <uint32_t> HoHash2Entry;
00053   std::vector <uint32_t> HxCalibHash2Entry;
00054   //std::vector <uint32_t> CalibHash2Entry;
00055   std::vector <uint32_t> ZdcHash2Entry;
00056 
00057   int HbHalf = 1296;
00058   int HeHalf = 1296;
00059   //if (h2mode_) HeHalf = 4032;
00060   int HoHalf = 1080;
00061   int HfHalf = 864;
00062   int HtHalf = 2088;
00063   int ZdcHalf = 11;
00064   int CalibFull=216+425+8;
00065 
00066   uint32_t illegal_value=0;
00067   for (int i=0;i<=HcalElectronicsId::maxLinearIndex;i++) LinearIndex2Entry.push_back(illegal_value);
00068   for (int iHb=0;iHb<2*HbHalf;iHb++) HbHash2Entry.push_back(illegal_value);
00069   for (int iHe=0;iHe<2*HeHalf;iHe++) HeHash2Entry.push_back(illegal_value);
00070   for (int iHf=0;iHf<2*HfHalf;iHf++) HfHash2Entry.push_back(illegal_value);
00071   for (int iHt=0;iHt<2*HtHalf;iHt++) HtHash2Entry.push_back(illegal_value);
00072   for (int iHo=0;iHo<2*HoHalf;iHo++) HoHash2Entry.push_back(illegal_value);
00073   for (int iHcalib=0;iHcalib<CalibFull;iHcalib++) HxCalibHash2Entry.push_back(illegal_value);
00074   for (int iZdc=0;iZdc<2*ZdcHalf;iZdc++) ZdcHash2Entry.push_back(illegal_value);
00075 
00076   buildHBEFTMap(HBHEHFEntries,HTEntries,LinearIndex2Entry,HbHash2Entry,HeHash2Entry,HfHash2Entry,HtHash2Entry);
00077   buildHOXMap(HOHXEntries,LinearIndex2Entry,HoHash2Entry,HxCalibHash2Entry);
00078   buildCALIBMap(CALIBEntries,LinearIndex2Entry,HxCalibHash2Entry);
00079   buildZDCMap(ZDCEntries,LinearIndex2Entry,ZdcHash2Entry);
00080 
00081   return HcalLogicalMap(HBHEHFEntries,HOHXEntries,CALIBEntries,ZDCEntries,HTEntries,
00082                         LinearIndex2Entry,HbHash2Entry,HeHash2Entry,HfHash2Entry,HtHash2Entry,
00083                         HoHash2Entry,HxCalibHash2Entry,/*CalibHash2Entry,*/ZdcHash2Entry);
00084 } 
00085 
00086 void HcalLogicalMapGenerator::buildHBEFTMap(std::vector <HBHEHFLogicalMapEntry>& HBHEHFEntries,
00087                                             std::vector <HTLogicalMapEntry>& HTEntries,
00088                                             std::vector <uint32_t>& LinearIndex2Entry,
00089                                             std::vector <uint32_t>& HbHash2Entry,
00090                                             std::vector <uint32_t>& HeHash2Entry,
00091                                             std::vector <uint32_t>& HfHash2Entry,
00092                                             std::vector <uint32_t>& HtHash2Entry) {
00093 
00094   /******************************/
00095   /* HBHE crate numbering */
00096   int hbhecrate_loc[NHBHECR]={0,1,4,5,10,11,14,15,17};
00097   memcpy( hbhecrate, hbhecrate_loc, sizeof(int)*NHBHECR );
00098   /* HBHE FED numbering of DCCs */
00099   int fedhbhenum_loc[NHBHECR][2]={{702,703},{704,705},{700,701},
00100                                   {706,707},{716,717},{708,709},
00101                                   {714,715},{710,711},{712,713}};
00102   memcpy( fedhbhenum, fedhbhenum_loc, sizeof(int)*NHBHECR*2 );
00103   /* HBHE/HF htr slot offsets for set of three htrs */
00104   int ihslot_loc[NHSETS]={2,5,13,16};
00105   memcpy( ihslot, ihslot_loc, sizeof(int)*NHSETS );
00106   /* iphi (lower) starting index for each HBHE crate */
00107   int ihbhephis_loc[NHBHECR]={11,19,3,27,67,35,59,43,51};
00108   memcpy( ihbhephis, ihbhephis_loc, sizeof(int)*NHBHECR );
00109   /* ihbheetadepth - unique HBHE {eta,depth} assignments per fiber and fiber channel */
00110   int ihbheetadepth_loc[NHTRS][NTOPBOT][NFBR][NFCH][2]={
00111     {{{{11,1},{ 7,1},{ 3,1}},  /* htr 0 (HB) -bot(+top) */
00112       {{ 5,1},{ 1,1},{ 9,1}},
00113       {{11,1},{ 7,1},{ 3,1}},
00114       {{ 5,1},{ 1,1},{ 9,1}},
00115       {{10,1},{ 6,1},{ 2,1}},
00116       {{ 8,1},{ 4,1},{12,1}},
00117       {{10,1},{ 6,1},{ 2,1}},
00118       {{ 8,1},{ 4,1},{12,1}}},
00119      {{{11,1},{ 7,1},{ 3,1}},  /* htr 0 (HB) +bot(-top) */
00120       {{ 5,1},{ 1,1},{ 9,1}},
00121       {{11,1},{ 7,1},{ 3,1}},
00122       {{ 5,1},{ 1,1},{ 9,1}},
00123       {{10,1},{ 6,1},{ 2,1}},
00124       {{ 8,1},{ 4,1},{12,1}},
00125       {{10,1},{ 6,1},{ 2,1}},
00126       {{ 8,1},{ 4,1},{12,1}}}},
00127     {{{{16,2},{15,2},{14,1}},  /* htr 1 (HBHE) -bot(+top) */
00128       {{15,1},{13,1},{16,1}},
00129       {{16,2},{15,2},{14,1}},
00130       {{15,1},{13,1},{16,1}},
00131       {{17,1},{16,3},{26,1}},
00132       {{18,1},{18,2},{26,2}},
00133       {{17,1},{16,3},{25,1}},
00134       {{18,1},{18,2},{25,2}}},
00135      {{{16,2},{15,2},{14,1}},  /* htr 1 (HBHE) +bot(-top) */
00136       {{15,1},{13,1},{16,1}},
00137       {{16,2},{15,2},{14,1}},
00138       {{15,1},{13,1},{16,1}},
00139       {{17,1},{16,3},{25,1}},
00140       {{18,1},{18,2},{25,2}},
00141       {{17,1},{16,3},{26,1}},
00142       {{18,1},{18,2},{26,2}}}},
00143     {{{{28,1},{28,2},{29,1}},  /* htr 2 (HE) -bot(+top) */
00144       {{28,3},{24,2},{24,1}},
00145       {{27,1},{27,2},{29,2}},
00146       {{27,3},{23,2},{23,1}},
00147       {{19,2},{20,1},{22,2}},
00148       {{19,1},{20,2},{22,1}},
00149       {{19,2},{20,1},{21,2}},
00150       {{19,1},{20,2},{21,1}}},
00151      {{{27,1},{27,2},{29,2}},  /* htr 2 (HE) +bot(-top) */
00152       {{27,3},{23,2},{23,1}},
00153       {{28,1},{28,2},{29,1}},
00154       {{28,3},{24,2},{24,1}},
00155       {{19,2},{20,1},{21,2}},
00156       {{19,1},{20,2},{21,1}},
00157       {{19,2},{20,1},{22,2}},
00158       {{19,1},{20,2},{22,1}}}}
00159   };
00160   memcpy( ihbheetadepth, ihbheetadepth_loc, sizeof(int)*NHTRS*NTOPBOT*NFBR*NFCH*2 );
00161                                     
00162   //Aram's insert: I shall now define an array which contains the RM and the RM fiber for HB HE
00163   //and variables associated with this table
00164   int irm_rmfiHBHE_loc[NHTRS][NTOPBOT][NFBR][2]={
00165     {{{6,1},{7,1},{6,2},{7,2},{4,1},{5,1},{4,2},{5,2}},  // HTR 0 top
00166      {{6,3},{7,3},{6,4},{7,4},{4,3},{5,3},{4,4},{5,4}}}, // HTR 0 bot
00167     {{{2,1},{3,1},{2,2},{3,2},{2,1},{3,1},{2,2},{3,2}},  // HTR 1 top
00168      {{2,3},{3,3},{2,4},{3,4},{2,3},{3,3},{2,4},{3,4}}}, // HTR 1 bot
00169     {{{4,1},{5,1},{4,2},{5,2},{6,1},{7,1},{6,2},{7,2}},  // HTR 2 top
00170      {{4,3},{5,3},{4,4},{5,4},{6,3},{7,3},{6,4},{7,4}}}  // HTR 2 bot
00171   };
00172   memcpy( irm_rmfiHBHE, irm_rmfiHBHE_loc, sizeof(int)*NHTRS*NTOPBOT*NFBR*2 );
00173   //Pixel tables as a function of rm, rm fiber and fiber channel
00174 
00175   int ipixelHB_loc[NRMFIBR][NFCH][NRMSLOT] = {  //  fch = 0           fch = 1           fch = 2
00176     {{18, 17, 3,  2 }, {13, 3,  17, 7 }, {14, 1,  19, 6 }}, //rmfiber = 2
00177     {{19, 2,  18, 1 }, {15, 7,  13, 5 }, {17, 19, 1,  3 }}, //rmfiber = 3
00178     {{9,  4,  16, 11}, {5,  8,  12, 15}, {2,  13, 7,  18}}, //rmfiber = 4
00179     {{12, 11, 9,  8 }, {7,  15, 5,  13}, {16, 6,  14, 4 }}, //rmfiber = 5
00180     {{8,  5,  15, 12}, {4,  9,  11, 16}, {1,  14, 6,  19}}, //rmfiber = 6
00181     {{6,  16, 4,  14}, {3,  18, 2,  17}, {11, 12, 8,  9 }}  //rmfiber = 7
00182   };
00183   memcpy( ipixelHB, ipixelHB_loc, sizeof(int)*NRMFIBR*NFCH*NRMSLOT );
00184                                      
00185   int ipixelHE_loc[NRMFIBR][NFCH][NRMSLOT] = {  //  fch = 0           fch = 1           fch = 2
00186     {{12, 12, 12, 12}, {16, 7,  16, 7 }, {7,  16, 7,  16}}, //rmfiber = 2
00187     {{11, 11, 11, 11}, {19, 3,  19, 3 }, {3,  19, 3,  19}}, //rmfiber = 3
00188     {{15, 15, 6,  6 }, {2,  18, 2,  18}, {6,  6,  15, 15}}, //rmfiber = 4
00189     {{5,  14, 5,  14}, {14, 5,  14, 5 }, {18, 2,  18, 2 }}, //rmfiber = 5
00190     {{17, 1,  17, 1 }, {9,  9,  9,  9 }, {1,  17, 1,  17}}, //rmfiber = 6
00191     {{13, 4,  13, 4 }, {8,  8,  8,  8 }, {4,  13, 4,  13}}  //rmfiber = 7
00192   };
00193   memcpy( ipixelHE, ipixelHE_loc, sizeof(int)*NRMFIBR*NFCH*NRMSLOT );
00194   
00195   //slb and rct tables
00196 
00197   //HB and HE
00198  
00199   const char* S_slbin_odd_loc[] ={"A1","B0","B1","A0","A1","B0","B1","A0"};
00200   for (int gg = 0; gg < 8; gg++) {
00201     S_slbin_odd[gg] = S_slbin_odd_loc[gg];
00202   }
00203   const char* S_slbin_even_loc[]={"C1","D0","D1","C0","C1","D0","D1","C0"};
00204   for (int gg = 0; gg < 8; gg++) {
00205     S_slbin_even[gg] = S_slbin_even_loc[gg];
00206   }
00207   const char* rct_rackHBHE_loc[]={"S2E01-RH","S2E03-RH","S2E05-RH","S2E07-RH","S2E09-RH","S2E08-RL","S2E06-RL","S2E04-RL","S2E02-RL",
00208                             "S2E02-RH","S2E04-RH","S2E06-RH","S2E08-RH","S2E09-RL","S2E07-RL","S2E05-RL","S2E03-RL","S2E01-RL"};
00209   for (int gg = 0; gg < 18; gg++) {
00210     rct_rackHBHE[gg] = rct_rackHBHE_loc[gg];
00211   }
00212 
00213   int slb_table_loc[29] = {1,1,2,2,3,3,4,4,5,5,6,6,       // 1<=eta<=12
00214                            1,1,2,2,3,3,1,1,               // 13<=eta<=20
00215                            2,2,3,3,4,4,4,4,4};            // 21<=eta<=29
00216   memcpy( slb_table, slb_table_loc, sizeof(int)*29 );
00217   /********************/
00218 
00219   //Stream variable
00220   stringstream mystream;
00221 
00222   /* all HBHE crates */
00223   for(ic=0; ic<NHBHECR; ic++){
00224     /* four sets of three htrs per crate */
00225     for(is=0; is<NHSETS; is++){
00226       /* three htrs per set */
00227       for(ih=0; ih<NHTRS; ih++){
00228         /* top and bottom */
00229         for(itb=0; itb<NTOPBOT; itb++){
00230           /* eight fibers per HTR FPGA */
00231           for(ifb=0; ifb<NFBR; ifb++){
00232             /* three channels per fiber */
00233             for(ifc=0; ifc<NFCH; ifc++){
00234               icrate=hbhecrate[ic];
00235               iside=is<NHSETS/2?-1:1;
00236               ifwtb=(is/2+itb+1)%2;
00237               ieta=ihbheetadepth[ih][ifwtb][ifb][ifc][0];
00238               idepth=ihbheetadepth[ih][ifwtb][ifb][ifc][1];
00239               ihtr=ihslot[is]+ih;
00240               (ieta>16||idepth>2) ? det = "HE": det = "HB";
00241               (itb%2)==1 ? fpga = "bot" : fpga = "top";
00242               ihtr_fi=ifb+1;
00243               ifi_ch=ifc;
00244               iphi=(ieta>20)?(ihbhephis[ic]+(is%2)*4+itb*2-1)%72+1:(ihbhephis[ic]+(is%2)*4+itb*2+(ifb/2+is/2+1)%2-1)%72+1;
00245               ispigot=(is%2)*6+ih*2+itb;
00246               idcc=is<NHSETS/2?1:2;
00247               idcc_sl=idcc==1?10:20;
00248               ifed=fedhbhenum[ic][idcc-1];
00249               //Aram's insert: rm variables, rbx, wedge
00250               //Careful here: per Pawel's map, the rm fiber is the first entry an the rm itself is the second.
00251               
00252               //If iside == -1, switch top and bottom. Why?
00253               if (iside == -1){
00254                 S_side = '-';
00255                 sidesign = 'M';
00256                 irm    = irm_rmfiHBHE[ih][(itb + 1) % 2][ifb][1];
00257                 irm_fi = irm_rmfiHBHE[ih][(itb + 1) % 2][ifb][0];
00258                 
00259                 //For eta >=21, the phi's cover 10 degrees rather than 5 (see HCAL TDR)
00260                 if (ieta >= 21 && (irm == 1 || irm == 3)) iwedge = (iphi + 1 + irm + 1) / 4;
00261                 else                                      iwedge = (iphi + irm + 1) / 4;
00262                 
00263                 //Roll over the wedge
00264                 if (iwedge > 18) iwedge -= 18;
00265               }
00266               else{
00267                 S_side = '+';
00268                 sidesign = 'P';
00269                 irm    = irm_rmfiHBHE[ih][itb][ifb][1];
00270                 irm_fi = irm_rmfiHBHE[ih][itb][ifb][0];
00271                 
00272                 //For eta >=21, the phi's cover 10 degrees rather than 5 (see HCAL TDR)
00273                 if (ieta >= 21 && (irm == 4 || irm == 2)) iwedge = (iphi + 1 - irm + 6) / 4;
00274                 else                                      iwedge = (iphi - irm + 6) / 4;
00275                 
00276                 //Roll over the wedge
00277                 if (iwedge > 18) iwedge -= 18;
00278               }
00279               
00280               sprintf (tempbuff, "%s%c%2.2i%c", det.c_str(), sidesign, iwedge,'\0');
00281               mystream<<tempbuff;
00282               rbx = mystream.str();
00283               mystream.str("");
00284 
00285               //Note that irm_fi ranges from 2 to 7 whereas arrays start at 0 so 
00286               //I use irm_fi - 2. Likewise, irm goes from 1 to 4 so use irm - 1
00287               
00288               //Pixel is split by HB and HE
00289               if (ieta > 16 || idepth > 2) ipixel = ipixelHE[irm_fi - 2][ifc][irm - 1]; //HE
00290               else                         ipixel = ipixelHB[irm_fi - 2][ifc][irm - 1]; //HB
00291                     
00292               iqie = iadcquiHBHE[irm_fi - 2][ifc][0];
00293               iadc = iadcquiHBHE[irm_fi - 2][ifc][1];
00294  
00295               phideg = iphi - 3;
00296               if (phideg < 0) phideg = phideg + 72;
00297               phideg = (phideg / 4) * 20 + 10;
00298               irctcra = (( 89 - phideg  + 720)%360)/20;
00299               oddcard = irctcra % 2;
00300               irctcra /= 2;
00301               if (iside > 0) irctcra = irctcra + 9;
00302               
00303               etaslb = ((ieta - 1) / 2) * 2 + 1;
00304               if (etaslb > 27) etaslb = 27;
00305               
00306               
00307               sprintf(tempbuff,"SLB_H_%3.3d%c%2.2d%c",phideg,S_side,etaslb,'\0');
00308               mystream<<tempbuff;
00309               slnam = mystream.str();
00310               mystream.str("");
00311 
00312               islb = slb_table[ieta - 1];
00313               
00314               // calculate RCT destination (that is, rctcon, rctcar and rctnam
00315               if (ieta <= 24) { // these are the normal cards 0-5
00316                 irctcar = 2 * ((ieta - 1)/8) + oddcard;
00317                 irctcon = 2 * (((ieta - 1)/2)%4);
00318               }
00319               else {            // these are on the special card 6 which folds back eta on the odd card half
00320                 irctcar = 6;
00321                 eta2 = ieta;
00322                 if (eta2 > 28) eta2 = 28;
00323                 if (oddcard == 0) eta3 = eta2;
00324                 else              eta3 = 57 - eta2;
00325                 irctcon =  2 * (((eta3 - 1) / 2) % 4);
00326               }
00327               irctcon = 11 * irctcon + 1;
00328 
00329               sprintf(tempbuff,"%s-%1d-HD%2.2d",rct_rackHBHE[irctcra],irctcar,irctcon);
00330               mystream<<tempbuff;
00331               rctnam = mystream.str();
00332               mystream.str("");
00333 
00334               //Finally, the slbin
00335               
00336               phimod8 = iphi % 8;
00337 
00338               for (i = 0; i < 18; i++) {
00339                 if (iphi < i * 4 + 3) {
00340                   crazy = i % 2;
00341                   break;
00342                 }
00343               } 
00344               
00345               int ietamod;   // determine if eta is "odd" or "even". 
00346               if (ieta == 29) ietamod = 0;
00347               else            ietamod = ieta % 2;
00348               if (ieta < 25) {         // use the regular table
00349                 if (ietamod == 1) mystream<<S_slbin_odd[phimod8];
00350                 else              mystream<<S_slbin_even[phimod8];
00351               }
00352               else if (crazy == 0) {   // use the regular table
00353                 if (ietamod == 1) mystream<<S_slbin_odd[phimod8];
00354                 else              mystream<<S_slbin_even[phimod8];
00355               }
00356               else {                   // swap odd/even!!!
00357                 if (ietamod == 1) mystream<<S_slbin_even[phimod8];
00358                 else              mystream<<S_slbin_odd[phimod8];
00359               }  
00360               
00361               slbin = mystream.str();
00362               mystream.str(""); 
00363 
00364               if (ieta > 20){
00365                 idphi = 2;
00366                 slbin2 = slbin;
00367                 slbin2[1] = '1';
00368               }
00369               else{
00370                 idphi = 1;
00371                 slbin2 = "NA";
00372               }
00373 
00374               HBHEHFLogicalMapEntry hbeflmapentry( 
00375                                                   ifi_ch, ihtr_fi, ispigot, ifed, icrate, ihtr, fpga,
00376                                                   det, iside, ieta, iphi, idepth,
00377                                                   idphi, iwedge, irm, irm_fi, ipixel, iqie, iadc,
00378                                                   islb, irctcra, irctcar, irctcon,
00379                                                   rbx, slbin, slbin2, slnam, rctnam
00380                                                   );
00381               HBHEHFEntries.push_back(hbeflmapentry);
00382               LinearIndex2Entry.at(hbeflmapentry.getLinearIndex())=HcalLogicalMap::makeEntryNumber(1,0,HBHEHFEntries.size()-1);
00383 
00384               const HcalGenericDetId hgdi(hbeflmapentry.getDetId());
00385               const int hashedId=hgdi.hashedId(false);
00386               if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenBarrel) HbHash2Entry.at(hashedId)=HBHEHFEntries.size();
00387               if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenEndcap) HeHash2Entry.at(hashedId)=HBHEHFEntries.size();
00388               if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenForward) HfHash2Entry.at(hashedId)=HBHEHFEntries.size();
00389 
00390               ConstructTriggerTower(
00391                                     HTEntries,
00392                                     iside, ieta, iphi, idphi, idepth, det, iwedge, irm,
00393                                     ipixel, iqie, iadc, irm_fi, ifi_ch, icrate, ihtr, fpga,
00394                                     ihtr_fi, ispigot, islb, slbin, slbin2,
00395                                     slnam, irctcra, irctcar, irctcon, rctnam, ifed
00396                                     );
00397             }
00398           }
00399         }
00400       }
00401     }
00402   }
00403 
00404   /********************/
00405   /* HF crate numbering */
00406   int hfcrate_loc[NHFCR]={2,9,12};
00407   memcpy( hfcrate, hfcrate_loc, sizeof(int)*NHFCR );
00408   /* HF FED numbering of DCCs */
00409   int fedhfnum_loc[NHFCR][2]={{718,719},{720,721},{722,723}};
00410   memcpy( fedhfnum, fedhfnum_loc, sizeof(int)*NHFCR*2 );
00411   /* iphi (lower) starting index for each HF crate */
00412   int ihfphis_loc[NHFCR]={3,27,51};
00413   memcpy( ihfphis, ihfphis_loc, sizeof(int)*NHFCR );
00414   /* ihfetadepth - unique HF {eta,depth} assignments per fiber and fiber channel */
00415   int ihfetadepth_loc[NTOPBOT][NFBR][NFCH][2]={
00416     {{{33,1},{31,1},{29,1}},  /* top */
00417      {{32,1},{30,1},{34,1}},
00418      {{33,2},{31,2},{29,2}},
00419      {{32,2},{30,2},{34,2}},
00420      {{34,2},{32,2},{30,2}},
00421      {{31,2},{29,2},{33,2}},
00422      {{34,1},{32,1},{30,1}},
00423      {{31,1},{29,1},{33,1}}},
00424     {{{41,1},{37,1},{35,1}},  /* bot */
00425      {{38,1},{36,1},{39,1}},
00426      {{41,2},{37,2},{35,2}},
00427      {{38,2},{36,2},{39,2}},
00428      {{40,2},{38,2},{36,2}},
00429      {{37,2},{35,2},{39,2}},
00430      {{40,1},{38,1},{36,1}},
00431      {{37,1},{35,1},{39,1}}}
00432   };
00433   memcpy( ihfetadepth, ihfetadepth_loc, sizeof(int)*NTOPBOT*NFBR*NFCH*2 );
00434 
00435 
00436   int irm_rmfiHF_loc[NHTRS][NTOPBOT][NFBR][2]={
00437     {{{1,2},{2,2},{3,2},{4,2},{1,3},{2,3},{3,3},{4,3}},  // HTR 0 top
00438      {{5,2},{6,2},{7,2},{8,2},{5,3},{6,3},{7,3},{8,3}}}, // HTR 0 bot
00439     {{{1,1},{2,1},{3,1},{4,1},{1,2},{2,2},{3,2},{4,2}},  // HTR 1 top
00440      {{5,1},{6,1},{7,1},{8,1},{5,2},{6,2},{7,2},{8,2}}}, // HTR 1 bot
00441     {{{1,3},{2,3},{3,3},{4,3},{1,1},{2,1},{3,1},{4,1}},  // HTR 2 top
00442      {{5,3},{6,3},{7,3},{8,3},{5,1},{6,1},{7,1},{8,1}}}  // HTR 2 bot
00443   };
00444   memcpy( irm_rmfiHF, irm_rmfiHF_loc, sizeof(int)*NHTRS*NTOPBOT*NFBR*2 );
00445 
00446   //HF
00447   const char* S_slbin_7_loc[] ={"A0","A1","B0","B1"};
00448   for (int gg = 0; gg < 4; gg++) {
00449     S_slbin_7[gg] = S_slbin_7_loc[gg];
00450   }
00451   const char* S_slbin_3_loc[] ={"C0","C1","D0","D1"};
00452   for (int gg = 0; gg < 4; gg++) {
00453     S_slbin_3[gg] = S_slbin_3_loc[gg];
00454   }
00455   const char* rct_rackHF_loc[]={"S2E01-FH","S2E03-FH","S2E05-FH","S2E07-FH","S2E09-FH","S2E08-FL","S2E06-FL","S2E04-FL","S2E02-FL",
00456                           "S2E02-FH","S2E04-FH","S2E06-FH","S2E08-FH","S2E09-FL","S2E07-FL","S2E05-FL","S2E03-FL","S2E01-FL"};
00457   for (int gg = 0; gg < 18; gg++) {
00458     rct_rackHF[gg] = rct_rackHF_loc[gg];
00459   }
00460  
00461 
00462   /***************/
00463   
00464   /* all HF crates */
00465   for(ic=0; ic<NHFCR; ic++){
00466     /* four sets of three htrs per crate */
00467     for(is=0; is<NHSETS; is++){
00468       /* three htrs per set */
00469       for(ih=0; ih<NHTRS; ih++){
00470         /* top and bottom */
00471         for(itb=0; itb<NTOPBOT; itb++){
00472           /* eight fibers per HTR FPGA */
00473           for(ifb=0; ifb<NFBR; ifb++){
00474             /* three channels per fiber */
00475             for(ifc=0; ifc<NFCH; ifc++){
00476               icrate=hfcrate[ic];
00477               iside=is<NHSETS/2?-1:1;
00478               ieta=ihfetadepth[itb][ifb][ifc][0];
00479               idepth=ihfetadepth[itb][ifb][ifc][1];
00480               ihtr=ihslot[is]+ih;
00481               det = "HF";
00482               (itb%2)== 1 ? fpga = "bot" : fpga = "top";
00483               ihtr_fi=ifb+1;
00484               ifi_ch=ifc;
00485               iphi=(ieta>39)?(ihfphis[ic]+(is%2)*12+ih*4-1)%72+1:(ihfphis[ic]+(is%2)*12+ih*4+(ifb/4)*2-1)%72+1;
00486               ispigot=(is%2)*6+ih*2+itb;
00487               idcc=is<NHSETS/2?1:2;
00488               idcc_sl=idcc==1?10:20;
00489               ifed=fedhfnum[ic][idcc-1];
00490               
00491               irm_fi = irm_rmfiHF[ih][itb][ifb][0];
00492               
00493               //Don't switch in the HF. Why?
00494               if (iside == -1){
00495                 S_side = '-';
00496                 sidesign = 'M';
00497                 
00498                 if (ieta < 40){
00499                   if      (iphi == 1)     iphi = 71;
00500                   else if (iphi == 71)    iphi = 1;
00501                   else if (iphi % 4 == 1) iphi -= 2;
00502                   else if (iphi % 4 == 3) iphi += 2;
00503                   else                    edm::LogInfo( "HcalLogicalMapGenerator") <<"Even iphi in HFM"<<endl;
00504                 }
00505               }
00506               else{
00507                 S_side = '+';
00508                 sidesign = 'P';
00509               }
00510               
00511               //RM and RBX number
00512               if ((iside == 1 && ieta == 40) || (iside == -1 && ieta == 41)){
00513                 irm = ((iphi + 1) / 2) % 36 + 1;
00514                 hfphi = ((iphi + 1) / 6) % 12 + 1; 
00515               }
00516               else{
00517                 irm = ( iphi + 1) / 2;
00518                 hfphi = (iphi - 1) / 6 + 1;
00519               }
00520               irm = (irm - 1) % 3 + 1;
00521               
00522               //Wedge
00523               if (iphi >= 71) iwedge = 1;
00524               else            iwedge = (iphi + 1) / 4 + 1;
00525               
00526               //RBX
00527               sprintf (tempbuff, "%s%c%2.2i%c", det.c_str(), sidesign, hfphi,'\0');
00528               mystream<<tempbuff;
00529               rbx = mystream.str();
00530               mystream.str("");
00531              
00532               //No pixel in HF, follow Fedor's convention
00533               ipixel = 0;
00534               
00535               //Integer truncation again consistent with Fedor's map. 
00536               iqie = (irm_fi - 1) / 2 + 1;
00537               
00538               if (irm_fi % 2 != 0) iadc = ifi_ch;
00539               else                 iadc = NFCH + (ifi_ch + 1) % 3;
00540                  
00541               //slb and rct variables
00542               //rctcrate
00543               phideg = iphi - 3;
00544               if (phideg < 0) phideg = phideg + 72;
00545               phideg = (phideg / 4) * 20 + 10;
00546               irctcra = (( 89 - phideg  + 720)%360)/40;
00547               if (iside > 0) irctcra = irctcra + 9;
00548               
00549               //rct card and rct connector appear to be dummy here -- again, I follow Fedor's convention
00550               irctcar = 99;
00551               irctcon = 0;
00552               
00553               etaslb = 29;
00554               
00555               sprintf(tempbuff,"SLB_H_%3.3d%c%2.2d",phideg,S_side,etaslb);
00556               mystream<<tempbuff;
00557               slnam = mystream.str();
00558               mystream.str("");
00559               
00560               sprintf(tempbuff,"%s-JSC-HF_IN",rct_rackHF[irctcra]);
00561               mystream<<tempbuff;
00562               rctnam = mystream.str();
00563               mystream.str("");
00564               
00565               islb = 6;
00566               
00567               int phibin = (iphi + 1) % 8 ;
00568               int etabin = (ieta - 29) / 3;
00569               if (etabin < 0) etabin = 0;
00570               if (etabin > 3) etabin = 3;
00571               if (phibin < 4) mystream<<S_slbin_7[etabin];
00572               else            mystream<<S_slbin_3[etabin];
00573               
00574               slbin = mystream.str();
00575               mystream.str("");
00576  
00577               slbin2 = "NA";
00578              
00579               if (ieta < 40) idphi = 2;
00580               else           idphi = 4;
00581 
00582               HBHEHFLogicalMapEntry hbeflmapentry( 
00583                                                   ifi_ch, ihtr_fi, ispigot, ifed, icrate, ihtr, fpga,
00584                                                   det, iside, ieta, iphi, idepth,
00585                                                   idphi, iwedge, irm, irm_fi, ipixel, iqie, iadc,
00586                                                   islb, irctcra, irctcar, irctcon,
00587                                                   rbx, slbin, slbin2, slnam, rctnam
00588                                                   );
00589               HBHEHFEntries.push_back(hbeflmapentry);
00590               LinearIndex2Entry.at(hbeflmapentry.getLinearIndex())=HcalLogicalMap::makeEntryNumber(1,0,HBHEHFEntries.size()-1);
00591 
00592               const HcalGenericDetId hgdi(hbeflmapentry.getDetId());
00593               const int hashedId=hgdi.hashedId(false);
00594               if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenBarrel) HbHash2Entry.at(hashedId)=HBHEHFEntries.size();
00595               if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenEndcap) HeHash2Entry.at(hashedId)=HBHEHFEntries.size();
00596               if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenForward) HfHash2Entry.at(hashedId)=HBHEHFEntries.size();
00597 
00598               ConstructTriggerTower(
00599                                     HTEntries,
00600                                     iside, ieta, iphi, idphi, idepth, det, iwedge, irm,
00601                                     ipixel, iqie, iadc, irm_fi, ifi_ch, icrate, ihtr, fpga,
00602                                     ihtr_fi, ispigot, islb, slbin, slbin2,
00603                                     slnam, irctcra, irctcar, irctcon, rctnam, ifed
00604                                     );
00605             }
00606           }
00607         }
00608       }
00609     }
00610   }
00611 } 
00612 
00613 void HcalLogicalMapGenerator::buildHOXMap(std::vector <HOHXLogicalMapEntry>& HOHXEntries,
00614                                           std::vector <uint32_t>& LinearIndex2Entry,
00615                                           std::vector <uint32_t>& HoHash2Entry,
00616                                           std::vector <uint32_t>& HxCalibHash2Entry) {
00617   /******************************/
00618   /* HO crate numbering */
00619   int hocrate_loc[NHOCR]={3,7,6,13};
00620   memcpy( hocrate, hocrate_loc, sizeof(int)*NHOCR );
00621   /* HO FED numbering of DCCs */
00622   int fedhonum_loc[NHOCR][2]={{724,725},{726,727},{728,729},{730,731}};
00623   memcpy( fedhonum, fedhonum_loc, sizeof(int)*NHOCR*2 );
00624   /* HO htr slot offsets for three sets of four htrs */
00625   int ihslotho_loc[NHSETSHO][NHTRSHO]={{2,3,4,5},{6,7,13,14},{15,16,17,18}};
00626   memcpy( ihslotho, ihslotho_loc, sizeof(int)*NHSETSHO*NHTRSHO );
00627   /* iphi (lower) starting index for each HO crate */
00628   int ihophis_loc[NHOCR]={71,17,35,53};
00629   memcpy( ihophis, ihophis_loc, sizeof(int)*NHOCR );
00630   //RM for the HO as a function of eta, phi and side as implemented in complete_ho_map.txt
00631   //There are only 24 phi columns because after that it begins to repeat. The relevant variable is phi mod 24.
00632   //HX as the 16th eta entry
00633   int HO_RM_table_loc[24][16][2] = 
00634     {
00635       {{2,2},{2,2},{2,2},{2,2},{2,2},{2,2},{2,2},{2,2},{2,2},{2,2},{4,2},{4,2},{4,2},{4,2},{4,2},{4,2}},
00636       {{2,2},{2,2},{2,2},{2,2},{4,4},{4,4},{4,4},{4,4},{4,4},{4,4},{2,4},{2,4},{2,4},{2,4},{2,4},{2,4}},
00637       {{3,3},{3,3},{3,3},{3,3},{4,4},{4,4},{4,4},{4,4},{4,4},{4,4},{2,4},{2,4},{2,4},{2,4},{2,4},{2,4}},
00638       {{3,3},{3,3},{3,3},{3,3},{4,4},{4,4},{4,4},{4,4},{4,4},{4,4},{2,4},{2,4},{2,4},{2,4},{2,4},{2,4}},
00639       {{4,4},{4,4},{4,4},{4,4},{3,3},{3,3},{3,3},{3,3},{3,3},{3,3},{1,3},{1,3},{1,3},{1,3},{1,3},{1,3}},
00640       {{4,4},{4,4},{4,4},{4,4},{3,3},{3,3},{3,3},{3,3},{3,3},{3,3},{1,3},{1,3},{1,3},{1,3},{1,3},{1,3}},
00641       {{3,3},{3,3},{3,3},{3,3},{3,3},{3,3},{3,3},{3,3},{3,3},{3,3},{1,3},{1,3},{1,3},{1,3},{1,3},{1,3}},
00642       {{3,3},{3,3},{3,3},{3,3},{1,1},{1,1},{1,1},{1,1},{1,1},{1,1},{3,1},{3,1},{3,1},{3,1},{3,1},{3,1}},
00643       {{2,2},{2,2},{2,2},{2,2},{1,1},{1,1},{1,1},{1,1},{1,1},{1,1},{3,1},{3,1},{3,1},{3,1},{3,1},{3,1}},
00644       {{2,2},{2,2},{2,2},{2,2},{1,1},{1,1},{1,1},{1,1},{1,1},{1,1},{3,1},{3,1},{3,1},{3,1},{3,1},{3,1}},
00645       {{4,4},{4,4},{4,4},{4,4},{2,2},{2,2},{2,2},{2,2},{2,2},{2,2},{4,2},{4,2},{4,2},{4,2},{4,2},{4,2}},
00646       {{4,4},{4,4},{4,4},{4,4},{2,2},{2,2},{2,2},{2,2},{2,2},{2,2},{4,2},{4,2},{4,2},{4,2},{4,2},{4,2}},
00647       {{3,3},{3,3},{3,3},{3,3},{2,2},{2,2},{2,2},{2,2},{2,2},{2,2},{4,2},{4,2},{4,2},{4,2},{4,2},{4,2}},
00648       {{3,3},{3,3},{3,3},{3,3},{4,4},{4,4},{4,4},{4,4},{4,4},{4,4},{2,4},{2,4},{2,4},{2,4},{2,4},{2,4}},
00649       {{2,2},{2,2},{2,2},{2,2},{4,4},{4,4},{4,4},{4,4},{4,4},{4,4},{2,4},{2,4},{2,4},{2,4},{2,4},{2,4}},
00650       {{2,2},{2,2},{2,2},{2,2},{4,4},{4,4},{4,4},{4,4},{4,4},{4,4},{2,4},{2,4},{2,4},{2,4},{2,4},{2,4}},
00651       {{1,1},{1,1},{1,1},{1,1},{3,3},{3,3},{3,3},{3,3},{3,3},{3,3},{1,3},{1,3},{1,3},{1,3},{1,3},{1,3}},
00652       {{1,1},{1,1},{1,1},{1,1},{3,3},{3,3},{3,3},{3,3},{3,3},{3,3},{1,3},{1,3},{1,3},{1,3},{1,3},{1,3}},
00653       {{2,2},{2,2},{2,2},{2,2},{3,3},{3,3},{3,3},{3,3},{3,3},{3,3},{1,3},{1,3},{1,3},{1,3},{1,3},{1,3}},
00654       {{2,2},{2,2},{2,2},{2,2},{1,1},{1,1},{1,1},{1,1},{1,1},{1,1},{3,1},{3,1},{3,1},{3,1},{3,1},{3,1}},
00655       {{3,3},{3,3},{3,3},{3,3},{1,1},{1,1},{1,1},{1,1},{1,1},{1,1},{3,1},{3,1},{3,1},{3,1},{3,1},{3,1}},
00656       {{3,3},{3,3},{3,3},{3,3},{1,1},{1,1},{1,1},{1,1},{1,1},{1,1},{3,1},{3,1},{3,1},{3,1},{3,1},{3,1}},
00657       {{1,1},{1,1},{1,1},{1,1},{2,2},{2,2},{2,2},{2,2},{2,2},{2,2},{4,2},{4,2},{4,2},{4,2},{4,2},{4,2}},
00658       {{1,1},{1,1},{1,1},{1,1},{2,2},{2,2},{2,2},{2,2},{2,2},{2,2},{4,2},{4,2},{4,2},{4,2},{4,2},{4,2}}
00659     };
00660   memcpy( HO_RM_table, HO_RM_table_loc, sizeof(int)*24*16*2 );
00661 
00662   //For |eta| 5 to 15, rm_fi is a function of |eta| only while htr_fi is a function of side and |eta|
00663   int HO_RM_fi_eta5to15_loc[11] = {3, 2, 5, 4, 7, 6, 3, 2, 5, 4, 7};
00664   memcpy( HO_RM_fi_eta5to15, HO_RM_fi_eta5to15_loc, sizeof(int)*11 );
00665   //For eta=16 it is 6, declared in the header
00666   HO_RM_fi_eta16 = 6;
00667   //For eta in the YB0 region, rm_fi is dependent on side, 4 for -1, and 5 for +1
00668   //but the values won't be any different than when the regular loop is executed
00669   //int HO_RM_fi_etaYB0[2] = {4, 5}
00670   
00671   int HO_htr_fi_450eta5to15_loc[2][11] = {{2, 2, 4, 6, 8, 2, 4, 6, 8, 4, 6},   //iside = -1
00672                                           {2, 8, 6, 4, 2, 8, 6, 4, 2, 4, 2}};  //iside = +1
00673   memcpy( HO_htr_fi_450eta5to15, HO_htr_fi_450eta5to15_loc, sizeof(int)*2*11 );
00674   // for the minus side, htr_fi is determined by the RM, will have to shift up one since rm is 
00675   //numbered 1-4 not 0-3        
00676   int HO_htr_fi_450eta16M_loc[4] = {7, 7, 8, 8};//iside = -1
00677   memcpy( HO_htr_fi_450eta16M, HO_htr_fi_450eta16M_loc, sizeof(int)*4 );
00678   //For the plus side, there is a new htr so all values can be used, but only 6 are used
00679   //Depend on phi, but also on rm and sector (2,4,6,8,10,12)
00680   int HO_htr_fi_450eta16P_loc[4][6] = { {4,2,4,4,2,6},{2,6,6,2,6,4},{5,3,5,5,3,7},{3,7,7,3,7,5} };                 //iside = +1
00681   memcpy( HO_htr_fi_450eta16P, HO_htr_fi_450eta16P_loc, sizeof(int)*4*6 );
00682                                       
00683   //for |eta| <= 4, htr_fi is a function of side and phmod6
00684   int HO_htr_fi_eta4_loc[2][6] = {{6, 6, 8, 8, 7, 7},   //iside = -1
00685                                   {4, 4, 5, 5, 3, 3}};  //iside = +1
00686   memcpy( HO_htr_fi_eta4, HO_htr_fi_eta4_loc, sizeof(int)*2*6 );
00687 
00688   int HO_htr_fi_eta123_loc[2][6] = {{6, 5, 4, 3, 8, 7},   //iside = -1
00689                                     {8, 7, 6, 5, 2, 1}};  //iside = +1
00690   memcpy( HO_htr_fi_eta123, HO_htr_fi_eta123_loc, sizeof(int)*2*6 );
00691   
00692   //HO_htr_fi_123eta5to15[2][11] is unnecessary because HO_htr_fi_123eta5to15[i][j] == int HO_htr_fi_450eta5to15[i][j] - 1
00693     
00694   //For |eta| 1 to 4, it is a function of phi, eta and side. eta 1-3 always have the same value given a side, eta 4 is separate
00695   //and thus gets its own box
00696   int HO_RM_fi_eta1to4_loc[72][2][2] = 
00697     {           //side = -1            side = 1
00698       {{7,3},{4,5}},{{6,2},{4,5}},{{7,3},{4,5}},{{6,2},{4,5}},{{2,6},{5,4}},{{3,7},{5,4}},{{2,6},{5,4}},{{3,7},{5,4}}, //Phi 1  to 8
00699       {{2,6},{5,4}},{{3,7},{5,4}},{{2,6},{5,4}},{{3,7},{5,4}},{{2,6},{5,4}},{{3,7},{5,4}},{{2,6},{5,4}},{{3,7},{5,4}}, //Phi 9  to 16
00700       {{7,3},{4,5}},{{6,2},{4,5}},{{7,3},{4,5}},{{6,2},{4,5}},{{7,3},{4,5}},{{6,2},{4,5}},{{7,3},{4,5}},{{6,2},{4,5}}, //Phi 17 to 24
00701       {{7,3},{4,5}},{{6,2},{4,5}},{{7,3},{4,5}},{{6,2},{4,5}},{{2,6},{5,4}},{{3,7},{5,4}},{{2,6},{5,4}},{{3,7},{5,4}}, //Phi 25 to 32
00702       {{2,6},{5,4}},{{3,7},{5,4}},{{2,6},{5,4}},{{3,7},{5,4}},{{2,6},{5,4}},{{3,7},{5,4}},{{2,6},{5,4}},{{3,7},{5,4}}, //Phi 33 to 40
00703       {{7,3},{4,5}},{{6,2},{4,5}},{{7,3},{4,5}},{{6,2},{4,5}},{{7,3},{4,5}},{{6,2},{4,5}},{{7,3},{4,5}},{{6,2},{4,5}}, //Phi 41 to 48
00704       {{7,3},{4,5}},{{6,2},{4,5}},{{7,3},{4,5}},{{6,2},{4,5}},{{2,6},{5,4}},{{3,7},{5,4}},{{2,6},{5,4}},{{3,7},{5,4}}, //Phi 49 to 56
00705       {{2,6},{5,4}},{{3,7},{5,4}},{{2,6},{5,4}},{{3,7},{5,4}},{{2,6},{5,4}},{{3,7},{5,4}},{{2,6},{5,4}},{{3,7},{5,4}}, //Phi 57 to 64
00706       {{7,3},{4,5}},{{6,2},{4,5}},{{7,3},{4,5}},{{6,2},{4,5}},{{7,3},{4,5}},{{6,2},{4,5}},{{7,3},{4,5}},{{6,2},{4,5}}  //Phi 65 to 72
00707     };
00708   memcpy( HO_RM_fi_eta1to4, HO_RM_fi_eta1to4_loc, sizeof(int)*72*2*2 );
00709 
00710   //Pixel and letter code for the HO. Ring 0 is separate and goes into entry 0, Rings +/- 1,2 are all the same and go to entry 1.
00711   //Pixel and let_code for HO ring 0 on the crosstalk channels: on rm_fi 4, pixel = 18, let_code = X
00712   //Pixel and let_code for HO ring 0 on the crosstalk channels: on rm_fi 5, pixel = 2, let_code = X
00713   //                    Fiber Channel       0        1       2         0       1       2          0       1       2
00714   int ipixelHO_loc[NRMFIBR][NFCH][2] = {{{12,12},{ 7, 7},{ 6, 3}}, {{ 4, 4},{ 8, 8},{ 5, 1}}, {{19,11},{18, 6},{17, 2}},   //RM fibers 2,3,4
00715                                         {{ 2, 9},{ 1,13},{ 3, 5}}, {{11,19},{16,18},{15,17}}, {{13,15},{ 9,14},{14,16}}}; //RM fibers 5,6,7
00716   memcpy( ipixelHO, ipixelHO_loc, sizeof(int)*NRMFIBR*NFCH*2 );
00717   //                            Fiber Channel        0         1         2            0         1         2            0       Y 1         2
00718   std::string letterHO_loc[NRMFIBR][NFCH][2] = {{{"E","E"},{"G","L"},{"F","S"}}, {{"Q","M"},{"N","T"},{"P","F"}}, {{"A","C"},{"X","J"},{"J","Q"}},
00719                                                 {{"X","K"},{"R","R"},{"H","D"}}, {{"D","A"},{"C","G"},{"B","N"}}, {{"L","H"},{"M","P"},{"K","B"}}}; 
00720 
00721   for (int jj = 0; jj < NRMFIBR; jj++) {
00722     for (int kk = 0; kk < NFCH; kk++) {
00723       for (int ll = 0; ll < 2; ll++) {
00724         letterHO[jj][kk][ll] = letterHO_loc[jj][kk][ll];
00725       }
00726     }
00727   }
00728 
00729   /******************************************************************************************/
00730   //  Here is the section that deals with the miscabled HO RBXs.
00731   //  To modify the code between IOVs, just note that inverted corresponds to -infinity to end of 2008
00732   //  and otherwise, to 2009 to infinity.
00733   //  Except for some small but major caveats:
00734   //    HO2M04 (phi=16) was not able to be corrected, thus it is still inverted
00735   //    HO2M06 (phi=31) has not been active in 2009, and the cables have not been switched officially
00736   //    HO2P12 (phi=67) has not been active in 2009, and the cables have not been switched officially
00737   //  In the map, the inactive RBXs have been switched since the changes will be effected when the HO SiPMs
00738   //  are installed, also at that time, if it is possible, HO2M04 will be corrected as well.
00739 
00740   //              switched HO RM's need reversed eta values
00741   if(mapIOV_==1) {
00742     int rmspecialeta_loc[6][6] = { //there are 6 special cases, corresponding to 6 values of phi
00743       { 14, 15, 14, 13, 12, 11 }, // ring +2 phi = 5, inverted
00744       { 14, 15, 14, 13, 12, 11 }, // ring +2 phi = 67, inverted
00745       { 10, 9, 8, 7, 6, 5 },      // ring -1 phi = 57, inverted
00746       { 10, 9, 8, 7, 6, 5 },      // ring -1 phi = 65, inverted
00747       { 14, 15, 14, 13, 12, 11 }, // ring -2 phi = 16, inverted
00748       { 14, 15, 14, 13, 12, 11 }  // ring -2 phi = 31, inverted
00749     };
00750 
00751     std::string rmspeciallet_code_loc[6][6] = { //there are 6 special cases, corresponding to 6 values of phi
00752       { "X", "B", "C", "D", "E", "F" },  // ring +2 phi = 5, inverted
00753       { "X", "P", "Q", "R", "S", "T" },  // ring +2 phi = 67, inverted
00754       { "G", "H", "J", "K", "L", "M" },  // ring -1 phi = 57, inverted
00755       { "A", "B", "C", "D", "E", "F" },  // ring -1 phi = 65, inverted
00756       { "X", "B", "C", "D", "E", "F" },  // ring -2 phi = 16, inverted
00757       { "X", "P", "Q", "R", "S", "T" }   // ring -2 phi = 31, inverted
00758     };
00759 
00760     std::string rmspecialdet_loc[6][6] = { //there are 6 special cases, corresponding to 6 values of phi
00761       { "HOX", "HO", "HO", "HO", "HO", "HO" }, // ring +2 phi = 5, inverted
00762       { "HOX", "HO", "HO", "HO", "HO", "HO" }, // ring +2 phi = 67, inverted
00763       { "HO", "HO", "HO", "HO", "HO", "HO" },  // ring -1 phi = 57, inverted
00764       { "HO", "HO", "HO", "HO", "HO", "HO" },  // ring -1 phi = 65, inverted
00765       { "HOX", "HO", "HO", "HO", "HO", "HO" }, // ring -2 phi = 16, inverted
00766       { "HOX", "HO", "HO", "HO", "HO", "HO" }  // ring -2 phi = 31, inverted
00767     };
00768 
00769     memcpy( rmspecialeta, rmspecialeta_loc, sizeof(int)*6*6 );
00770     //              switched HO RM's need revised letter codes
00771   
00772     for (int jj = 0; jj < 6; jj++) {
00773       for (int kk = 0; kk < 6; kk++) {
00774         rmspeciallet_code[jj][kk] = rmspeciallet_code_loc[jj][kk];}}
00775   
00776     for (int jj = 0; jj < 6; jj++) {
00777       for (int kk = 0; kk < 6; kk++) {
00778         rmspecialdet[jj][kk] = rmspecialdet_loc[jj][kk];}}
00779   }
00780 
00781   else if (mapIOV_==2) {
00782     int rmspecialeta_loc[6][6] = { //there are 6 special cases, corresponding to 6 values of phi
00783       { 11, 12, 13, 14, 15, 15 }, // ring +2 phi = 5
00784       { 11, 12, 13, 14, 15, 15 }, // ring +2 phi = 67
00785       { 5, 6, 7, 8, 9, 10 },      // ring -1 phi = 57
00786       { 5, 6, 7, 8, 9, 10 },      // ring -1 phi = 65
00787       { 14, 15, 14, 13, 12, 11 }, // ring -2 phi = 16, still inverted
00788       { 11, 12, 13, 14, 15, 15 }  // ring -2 phi = 31
00789     };
00790 
00791     std::string rmspeciallet_code_loc[6][6] = { //there are 6 special cases, corresponding to 6 values of phi
00792       { "F", "E", "D", "C", "B", "X" },  // ring +2 phi = 5
00793       { "T", "S", "R", "Q", "P", "X" },  // ring +2 phi = 67
00794       { "M", "L", "K", "J", "H", "G" },  // ring -1 phi = 57
00795       { "F", "E", "D", "C", "B", "A" },  // ring -1 phi = 65
00796       { "X", "B", "C", "D", "E", "F" },  // ring -2 phi = 16,still  inverted
00797       { "T", "S", "R", "Q", "P", "X" }   // ring -2 phi = 31
00798     };
00799 
00800     std::string rmspecialdet_loc[6][6] = { //there are 6 special cases, corresponding to 6 values of phi
00801       { "HO", "HO", "HO", "HO", "HO", "HOX" }, // ring +2 phi = 5
00802       { "HO", "HO", "HO", "HO", "HO", "HOX" }, // ring +2 phi = 67
00803       { "HO", "HO", "HO", "HO", "HO", "HO" },  // ring -1 phi = 57
00804       { "HO", "HO", "HO", "HO", "HO", "HO" },  // ring -1 phi = 65
00805       { "HOX", "HO", "HO", "HO", "HO", "HO" }, // ring -2 phi = 16, still inverted
00806       { "HO", "HO", "HO", "HO", "HO", "HOX" }  // ring -2 phi = 31
00807     };
00808 
00809     memcpy( rmspecialeta, rmspecialeta_loc, sizeof(int)*6*6 );
00810     //              switched HO RM's need revised letter codes
00811   
00812     for (int jj = 0; jj < 6; jj++) {
00813       for (int kk = 0; kk < 6; kk++) {
00814         rmspeciallet_code[jj][kk] = rmspeciallet_code_loc[jj][kk];}}
00815   
00816     for (int jj = 0; jj < 6; jj++) {
00817       for (int kk = 0; kk < 6; kk++) {
00818         rmspecialdet[jj][kk] = rmspecialdet_loc[jj][kk];}}
00819   }
00820 
00821   else {
00822     int rmspecialeta_loc[6][6] = { //there are 6 special cases, corresponding to 6 values of phi
00823       { 11, 12, 13, 14, 15, 15 }, // ring +2 phi = 5
00824       { 11, 12, 13, 14, 15, 15 }, // ring +2 phi = 67
00825       { 5, 6, 7, 8, 9, 10 },      // ring -1 phi = 57
00826       { 5, 6, 7, 8, 9, 10 },      // ring -1 phi = 65
00827       { 11, 12, 13, 14, 15, 15 }, // ring -2 phi = 16
00828       { 11, 12, 13, 14, 15, 15 }  // ring -2 phi = 31
00829     };
00830 
00831     std::string rmspeciallet_code_loc[6][6] = { //there are 6 special cases, corresponding to 6 values of phi
00832       { "F", "E", "D", "C", "B", "X" },  // ring +2 phi = 5
00833       { "T", "S", "R", "Q", "P", "X" },  // ring +2 phi = 67
00834       { "M", "L", "K", "J", "H", "G" },  // ring -1 phi = 57
00835       { "F", "E", "D", "C", "B", "A" },  // ring -1 phi = 65
00836       { "F", "E", "D", "C", "B", "X" },  // ring -2 phi = 16
00837       { "T", "S", "R", "Q", "P", "X" }   // ring -2 phi = 31
00838     };
00839 
00840     std::string rmspecialdet_loc[6][6] = { //there are 6 special cases, corresponding to 6 values of phi
00841       { "HO", "HO", "HO", "HO", "HO", "HOX" }, // ring +2 phi = 5
00842       { "HO", "HO", "HO", "HO", "HO", "HOX" }, // ring +2 phi = 67
00843       { "HO", "HO", "HO", "HO", "HO", "HO" },  // ring -1 phi = 57
00844       { "HO", "HO", "HO", "HO", "HO", "HO" },  // ring -1 phi = 65
00845       { "HO", "HO", "HO", "HO", "HO", "HOX" }, // ring -2 phi = 16
00846       { "HO", "HO", "HO", "HO", "HO", "HOX" }  // ring -2 phi = 31
00847     };
00848 
00849     memcpy( rmspecialeta, rmspecialeta_loc, sizeof(int)*6*6 );
00850     //              switched HO RM's need revised letter codes
00851   
00852     for (int jj = 0; jj < 6; jj++) {
00853       for (int kk = 0; kk < 6; kk++) {
00854         rmspeciallet_code[jj][kk] = rmspeciallet_code_loc[jj][kk];}}
00855   
00856     for (int jj = 0; jj < 6; jj++) {
00857       for (int kk = 0; kk < 6; kk++) {
00858         rmspecialdet[jj][kk] = rmspecialdet_loc[jj][kk];}}
00859   }
00860 
00861   /******************************/  
00862 
00863   //Stream variable
00864   stringstream mystream;
00865 
00866   //Radical change: HO iterates over eta and phi rather than crate, HTR, etc. 
00867   for(isid = -1; isid < 2; isid+=2){
00868     for (iph = 0; iph < NHOPHI; iph++){
00869       for (iet = 0; iet < NHOETA; iet++){
00870         
00871         iphi = iph + 1;
00872         ieta = iet + 1;
00873         iside = isid;
00874         
00875         if (iphi >= 71 || iphi < 17)      ic = 0;
00876         else if (iphi >= 17 && iphi < 35) ic = 1;
00877         else if (iphi >= 35 && iphi < 53) ic = 2;
00878         else                              ic = 3;
00879                 
00880         icrate=hocrate[ic];
00881         idepth=4;
00882         det = "HO";
00883         
00884         //fpga = top/bottom for Ring 0 depends on a pattern that repeats every 30 degrees (6 phi)
00885         //Hence, phmod6 (not phi mod 6 because I don't want to separate 71 and 72, etc.)
00886         
00887         phmod6 = iph % 6;
00888         //Bools associated with phmod6 to be used with htr_fi and the patch panel
00889         phmod6e450 = (phmod6 == 4 || phmod6 == 5 || phmod6 == 0); 
00890         phmod6e123 = (phmod6 == 1 || phmod6 == 2 || phmod6 == 3); 
00891         
00892         //Ring 0 (HTR type 0) is special
00893         if      (ieta <= 3  && (iside < 0 || phmod6 >= 4)) fpga = "bot";
00894         else if (ieta <= 3  && iside > 0 && phmod6 < 4)  fpga = "top";
00895         //new HX HTR
00896         else if ((ieta > 15 && iside > 0) && (icrate == 3 || icrate == 6))   fpga = "top";
00897         else if ((ieta > 15 && iside > 0) && (icrate == 7 || icrate == 13))   fpga = "bot";
00898         //HTR types 0 and 1
00899         else if (ieta >= 10 && iside > 0)                 fpga = "top";
00900         else if (ieta <  10 && ieta >= 6 && iside > 0)    fpga = "bot";
00901         //HTR types 2 and 3 
00902         else if ((ieta == 5 && iside > 0) || ieta == 4)   fpga = "top";
00903         else if ((ieta == 5 || ieta >= 10) && iside < 0)  fpga = "bot";
00904         else if ((ieta < 10 && ieta >= 6) && iside < 0)   fpga = "top";
00905         else    edm::LogInfo( "HcalLogicalMapGenerator") <<"Bad fpga code"<<endl;
00906         
00907         //dphi
00908         if      (ieta <= 20) idphi = 1;
00909         else                 idphi = -1000;
00910         
00911         //create values usable in arrays from side and fpga
00912         if   (iside == 1) sidear = 1;
00913         else              sidear = 0;
00914         
00915         if (fpga == "bot") itb = 1;//convention different than for the
00916         else               itb = 0;//electronics id, modified in the 
00917         //MapEntry code
00918 
00919         phmod24 = iph % 24;
00920         
00921         //Again, x - 1 because the array starts at 0 while the variables start at 1
00922         irm = HO_RM_table[phmod24][iet][sidear];
00923         
00924         //x - 5 for the eta array for the same reason
00925         //  the new stuff for HX
00926         if          (ieta==16) irm_fi = HO_RM_fi_eta16;
00927         else if (ieta >= 5) irm_fi = HO_RM_fi_eta5to15[ieta - 5];
00928         else if (ieta <= 3) irm_fi = HO_RM_fi_eta1to4[iph][0][sidear];
00929         else if (ieta == 4) irm_fi = HO_RM_fi_eta1to4[iph][1][sidear];
00930         else                irm_fi = -1000;
00931         
00932         //Determine which of HTR in the set belongs here. It depends only on eta and side.
00933         //  the new stuff for HX
00934         //if          (ieta==16)
00935         //
00936         if (ieta <= 3 || (ieta >= 14 && iside == 1))     ih = 0;
00937         else if (ieta <= 13 && ieta >= 6 && iside == 1)  ih = 1;
00938         else if (ieta <= 13 && ieta >= 6 && iside == -1) ih = 3;
00939         else                                             ih = 2;
00940         
00941         //Each value of "is" covers 30 degrees (that is, 6 values of phi). To calculate which ones,
00942         //I use phi % 18. Crates start at phi = 71, 17, 35, 53
00943         
00944         if (iphi % 18 == 17 || iphi % 18 <= 4)      is = 0;
00945         else if (iphi % 18 >= 5 && iphi % 18 <= 10) is = 1;
00946         else                                        is = 2;
00947         
00948         if ( ieta == 16 && iside > 0 ) ihtr=21;
00949         else ihtr=ihslotho[is][ih];
00950         
00951         if ((ieta > 15 && iside > 0) && (icrate == 3 || icrate == 6))   ispigot = 12;
00952         else if ((ieta > 15 && iside > 0) && (icrate == 7 || icrate == 13))   ispigot = 13;
00953         else ispigot=ihtr<9?(ihtr-2)*2+itb:(ihtr-13)*2+itb;
00954         idcc=ihtr<9?1:2;
00955         idcc_sl = idcc == 1 ?10:20;
00956         
00957         ifed=fedhonum[ic][idcc-1];
00958         
00959         //HTR fiber
00960         
00961         //
00962         if (ieta >= 5 && phmod6e450) ihtr_fi = HO_htr_fi_450eta5to15[sidear][ieta - 5];
00963         else if (ieta >= 5 && phmod6e123) ihtr_fi = HO_htr_fi_450eta5to15[sidear][ieta - 5] - 1;
00964         else if (ieta == 4)               ihtr_fi = HO_htr_fi_eta4[sidear][phmod6];
00965         else if (ieta <= 3)               ihtr_fi = HO_htr_fi_eta123[sidear][phmod6];
00966         else                              ihtr_fi = -1000;
00967         
00968         //Fiber Channel
00969         //Eta >= 5 bools
00970         phi1458   = (iphi % 12 == 1 || iphi % 12 == 4 || iphi % 12 == 5  || iphi % 12 == 8);
00971         phi271011 = (iphi % 12 == 2 || iphi % 12 == 7 || iphi % 12 == 10 || iphi % 12 == 11);
00972         
00973         //Ring 0 bools
00974         phir0v1 = (iphi % 24 == 0 || iphi % 24 == 2 || iphi % 24 == 4  || iphi % 24 == 18 || iphi % 24 == 20 || iphi % 24 == 22);
00975         phir0v2 = (iphi % 24 == 1 || iphi % 24 == 3 || iphi % 24 == 17 || iphi % 24 == 19 || iphi % 24 == 21 || iphi % 24 == 23);
00976         //v3: phi 5 to 15 odd; v4: phi 6 to 16 even
00977         phir0v3 = (iphi % 24 == 5 || iphi % 24 == 7 || iphi % 24 == 9  || iphi % 24 == 11 || iphi % 24 == 13 || iphi % 24 == 15);
00978         phir0v4 = (iphi % 24 == 6 || iphi % 24 == 8 || iphi % 24 == 10 || iphi % 24 == 12 || iphi % 24 == 14 || iphi % 24 == 16);
00979         
00980         if (ieta >= 5){
00981           if      (ieta % 2 == 0 && phi1458)       ifi_ch = 0; 
00982           else if (ieta % 2 == 0 && iphi % 3 == 0) ifi_ch = 1;
00983           else if (ieta % 2 == 0 && phi271011)     ifi_ch = 2;
00984           else if (ieta % 2 == 1 && iphi % 3 == 0) ifi_ch = 0; 
00985           else if (ieta % 2 == 1 && phi271011)     ifi_ch = 1;
00986           else if (ieta % 2 == 1 && phi1458)       ifi_ch = 2;
00987         }
00988         else if (ieta == 4){
00989           if (iside == -1){
00990             if      (phir0v1)       ifi_ch = 0;
00991             else if (phir0v4)       ifi_ch = 1;
00992             else if (iphi % 2 == 1) ifi_ch = 2;
00993           }
00994           else{
00995             if      (phir0v3)       ifi_ch = 0;
00996             else if (phir0v2)       ifi_ch = 1;
00997             else if (iphi % 2 == 0) ifi_ch = 2;
00998           }
00999         }
01000         //eta = -3 and eta = +2
01001         else if ((ieta == 3 && iside == -1) || (ieta == 2 && iside == 1)){
01002           if      (phir0v4)            ifi_ch = 0;
01003           else if (phir0v3)            ifi_ch = 1;
01004           else if (phir0v1 || phir0v2) ifi_ch = 2;
01005         }
01006         //eta = -2 and eta = +3
01007         else if ((ieta == 3 && iside == 1) || (ieta == 2 && iside == -1)){
01008           if      (phir0v2)            ifi_ch = 0;
01009           else if (phir0v1)            ifi_ch = 1;
01010           else if (phir0v3 || phir0v4) ifi_ch = 2;
01011         }
01012         //ieta = 1
01013         else if (ieta == 1){
01014           if      (phir0v1 || phir0v3) ifi_ch = 0;
01015           else if (phir0v2 || phir0v4) ifi_ch = 1;
01016         }
01017                 
01018         //Intentional integer truncation; iqie and iadc are the same across all subdetectors
01019         //(Although irm_fi for HF starts at 1 and for HO it starts at 2, so one can't just copy and paste)
01020         iqie = (irm_fi - 2) / 2 + 1;
01021         
01022         if (irm_fi % 2 == 0) iadc = ifi_ch;
01023         else                 iadc = NFCH + (ifi_ch + 1) % 3;
01024         
01025         //Pixel and Letter Code (Ring 0 is separate)
01026         if (ieta <= 4){
01027           ipixel = ipixelHO[irm_fi - 2][ifi_ch][0];
01028           letter = letterHO[irm_fi - 2][ifi_ch][0];
01029         }
01030         else{
01031           ipixel = ipixelHO[irm_fi - 2][ifi_ch][1];
01032           letter = letterHO[irm_fi - 2][ifi_ch][1];
01033         }
01034         
01035         //RBX and sector
01036         
01037         if (iside == -1) sidesign = 'M';
01038         else             sidesign = 'P';
01039         
01040         if      (ieta <= 4)                ring = 0;
01041         else if (ieta >= 5 && ieta <= 10)  ring = 1;
01042         else                               ring = 2;
01043         
01044         //Sector ranges from 1 to 12 depending on phi. Sector 1 goes 71,72,1,2,3,4 so I start at -2
01045         sector = 0;
01046         for (i = -2; i < iphi; i+=6){
01047           sector++;
01048         }
01049         if (sector > 12) sector = 1; //It rolls over for phi = 71,72 
01050         
01051         isector = sector;
01052         
01053         //For rings 1 and 2, we only want even sectors for the rbx
01054         if (ring != 0 && sector % 2 != 0) sector++;
01055         
01056         if (ring == 0)  sprintf (tempbuff, "%s%i%2.2d", det.c_str(), ring, sector);
01057         else            sprintf (tempbuff, "%s%i%c%2.2d", det.c_str(), ring, sidesign, sector);
01058         mystream<<tempbuff;
01059         rbx = mystream.str();
01060         mystream.str("");
01061         if (ieta == 16) {
01062           det = "HOX";
01063           letter = "X";}
01064         else det = "HO";
01065         
01066         //  the new htr_fi stuff for HX
01067         if (ieta==16 && isid<0) ihtr_fi = HO_htr_fi_450eta16M[irm - 1];
01068         else if (ieta==16 && isid>0) ihtr_fi = HO_htr_fi_450eta16P[irm - 1][sector/2-1];
01069         
01070         if ((ieta > 15 && iside > 0) && (icrate == 3 || icrate == 7))   {
01071           icrate = 6;
01072           ifed = 729;
01073         }
01074         else if ((ieta > 15 && iside > 0) && (icrate == 6 || icrate == 13))   {
01075           icrate = 7;
01076           ifed = 727;
01077         }
01078         
01079         if ( ieta == 16 ) ieta = 15;
01080         // fixing the switched RM's
01081         if ( iside == 1 && ring == 2 ) {
01082           if ( iphi == 5 ) {
01083             ieta = rmspecialeta[0][iet - 10];
01084             letter = rmspeciallet_code[0][iet - 10];
01085             det = rmspecialdet[0][iet - 10];
01086           }
01087           else if ( iphi == 67 ) {
01088             ieta = rmspecialeta[1][iet - 10];
01089             letter = rmspeciallet_code[1][iet - 10];
01090             det = rmspecialdet[1][iet - 10];
01091           }
01092         }
01093         else if ( iside == -1) {
01094           if ( ring == 1 ) {
01095             if ( iphi == 57 ) {
01096               ieta = rmspecialeta[2][iet - 4];
01097               letter = rmspeciallet_code[2][iet - 4];
01098               det = rmspecialdet[2][iet - 4];
01099             }
01100             else if ( iphi == 65 ) {
01101               ieta = rmspecialeta[3][iet - 4];
01102               letter = rmspeciallet_code[3][iet - 4];
01103               det = rmspecialdet[3][iet - 4];
01104             }
01105           }
01106           else if ( ring == 2 ) {
01107             if ( iphi == 16 ) {
01108               ieta = rmspecialeta[4][iet - 10];
01109               letter = rmspeciallet_code[4][iet - 10];
01110               det = rmspecialdet[4][iet - 10];
01111             }
01112             else if ( iphi == 31 ) {
01113               ieta = rmspecialeta[5][iet - 10];
01114               letter = rmspeciallet_code[5][iet - 10];
01115               det = rmspecialdet[5][iet - 10];
01116             }
01117           }
01118         }
01119 
01120         HOHXLogicalMapEntry hoxlmapentry(
01121                                          ifi_ch, ihtr_fi, ispigot, ifed, icrate, ihtr, fpga,
01122                                          det, iside, ieta, iphi, idepth,
01123                                          idphi, isector, irm, irm_fi, ipixel, iqie, iadc,
01124                                          rbx, letter
01125                                          );
01126         HOHXEntries.push_back(hoxlmapentry);
01127         LinearIndex2Entry.at(hoxlmapentry.getLinearIndex())=HcalLogicalMap::makeEntryNumber(1,1,HOHXEntries.size()-1);
01128 
01129         const HcalGenericDetId hgdi(hoxlmapentry.getDetId());
01130         const int hashedId=hgdi.hashedId(false);
01131         if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenOuter) HoHash2Entry.at(hashedId)=HOHXEntries.size();
01132         if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenCalibration) HxCalibHash2Entry.at(hashedId)=HOHXEntries.size();
01133 
01134         if (ring==0){
01135           if (ipixel==1){
01136             ipixel = 2;
01137             iadc = 4;
01138             ifi_ch = 0;
01139             letter = "X";
01140             det = "HOX";
01141             HOHXLogicalMapEntry hoxlmapentry(
01142                                              ifi_ch, ihtr_fi, ispigot, ifed, icrate, ihtr, fpga,
01143                                              det, iside, ieta, iphi, idepth,
01144                                              idphi, isector, irm, irm_fi, ipixel, iqie, iadc,
01145                                              rbx, letter
01146                                              );
01147             HOHXEntries.push_back(hoxlmapentry);
01148             LinearIndex2Entry.at(hoxlmapentry.getLinearIndex())=HcalLogicalMap::makeEntryNumber(1,1,HOHXEntries.size()-1);
01149 
01150             const HcalGenericDetId hgdi(hoxlmapentry.getDetId());
01151             const int hashedId=hgdi.hashedId(false);
01152             if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenOuter) HoHash2Entry.at(hashedId)=HOHXEntries.size();
01153             if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenCalibration) HxCalibHash2Entry.at(hashedId)=HOHXEntries.size();
01154 
01155           }
01156           else if (ipixel==17){
01157             ipixel = 18;
01158             iadc = 1;
01159             ifi_ch = 1;
01160             letter = "X";
01161             det = "HOX";
01162             HOHXLogicalMapEntry hoxlmapentry(
01163                                              ifi_ch, ihtr_fi, ispigot, ifed, icrate, ihtr, fpga,
01164                                              det, iside, ieta, iphi, idepth,
01165                                              idphi, isector, irm, irm_fi, ipixel, iqie, iadc,
01166                                              rbx, letter
01167                                              );
01168             HOHXEntries.push_back(hoxlmapentry);
01169             LinearIndex2Entry.at(hoxlmapentry.getLinearIndex())=HcalLogicalMap::makeEntryNumber(1,1,HOHXEntries.size()-1);
01170 
01171             const HcalGenericDetId hgdi(hoxlmapentry.getDetId());
01172             const int hashedId=hgdi.hashedId(false);
01173             if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenOuter) HoHash2Entry.at(hashedId)=HOHXEntries.size();
01174             if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenCalibration) HxCalibHash2Entry.at(hashedId)=HOHXEntries.size();
01175 
01176           }
01177         }
01178       }
01179     }
01180   }
01181 } 
01182 
01183 void HcalLogicalMapGenerator::buildCALIBMap(std::vector <CALIBLogicalMapEntry>& CALIBEntries,
01184                                             std::vector <uint32_t>& LinearIndex2Entry,
01185                                             std::vector <uint32_t>& HxCalibHash2Entry) {
01186   
01187   /******************************/
01188   /* CALIB crate numbering in order of FEDID*/
01189   int calibcrate_loc[NCALIBCR]={4,0,1,5,11,15,17,14,10,9,7,6,13};//HBHE,HF,HO
01190   memcpy( calibcrate, calibcrate_loc, sizeof(int)*NCALIBCR );
01191   /* CALIB FED numbering of DCCs */
01192   int fedcalibnum_loc[NCALIBCR][2]={{700,701},{702,703},{704,705},{706,707},{708,709},{710,711},{712,713},{714,715},{716,717},/*calib_hbhe 4,0,1,5,11,15,17,14,10*/
01193                                     {720,721},/*calib_hf 9*/
01194                                     {726,727},{728,729},{730,731}};//calib_ho 7,6,13
01195   memcpy( fedcalibnum, fedcalibnum_loc, sizeof(int)*NCALIBCR*2 );
01196   /* iphi (lower) starting index for each CALIB crate */
01197   int icalibphis_loc[NCALIBCR]={3,11,19,27,35,43,51,59,67,27,17,35,53};
01198   memcpy( icalibphis, icalibphis_loc, sizeof(int)*NCALIBCR );
01199   /* icalibsector_min minimum sector on each crate {0,1,4,5,10,11,14,15,17,9,7,6,13}*/
01200   int icalibsector_min_loc[NCALIBCR]={2,4,6,8,10,12,14,16,18,1,4,7,10};
01201   memcpy( icalibsector_min, icalibsector_min_loc, sizeof(int)*NCALIBCR );
01202   /* icalibsector_max maximum sector on each crate */
01203   int icalibsector_max_loc[NCALIBCR]={3,5,7,9,11,13,15,17,1,4,6,9,12};
01204   memcpy( icalibsector_max, icalibsector_max_loc, sizeof(int)*NCALIBCR );
01205   //detectors represented on each crate (0 for top, 1 for bot)
01206   std::string detIDCALIB_loc[NCALIBCR][NTOPBOT] = {{"HB","HE"},/*crate 4*/ 
01207                                                    {"HB","HE"},/*crate 0*/
01208                                                    {"HB","HE"},/*crate 1*/
01209                                                    {"HB","HE"},/*crate 5*/
01210                                                    {"HB","HE"},/*crate 11*/
01211                                                    {"HB","HE"},/*crate 15*/
01212                                                    {"HB","HE"},/*crate 17*/
01213                                                    {"HB","HE"},/*crate 14*/
01214                                                    {"HB","HE"},/*crate 10*/
01215                                                    {"HF","HF"},/*crate 9*/
01216                                                    {"HO","HO"},/*crate 7*/
01217                                                    {"HO","HO"},/*crate 6*/
01218                                                    {"HO","HO"}};/*crate 13*/
01219   for (int jj = 0; jj < NCALIBCR; jj++) {
01220     for (int kk = 0; kk < NTOPBOT; kk++) {
01221       detIDCALIB[jj][kk] = detIDCALIB_loc[jj][kk];
01222     } 
01223   }
01224                                                          
01225   int nfbr_max_loc[NCALIBCR][NTOPBOT] = {{4,8},{4,8},{4,8},{4,8},{4,8},{4,8},{4,8},{4,8},{4,8},{4,4},{8,4},{8,8},{8,4}};
01226   memcpy( nfbr_max, nfbr_max_loc, sizeof(int)*NCALIBCR*NTOPBOT );
01227   //HB only utilizes 4 htr_fibers HE all 8
01228   int calibHOinfo_loc[NHOCR][NTOPBOT][NFBR][2]={/*sector and ring of HO for the calib channel*/
01229     {{{4,0},{5,0},{6,0},{},{6,-2},{6,-1},{6,1},{6,2}},
01230      {{4,-2},{4,-1},{4,1},{4,2},{},{},{},{}}},/*crate 7*/
01231 
01232     {{{7,0},{8,0},{9,0},{},{8,-2},{8,-1},{8,1},{8,2}},
01233      {{1,0},{2,0},{3,0},{},{2,-2},{2,-1},{2,1},{2,2}}},/*crate 6*/
01234 
01235     {{{10,0},{11,0},{12,0},{},{10,-2},{10,-1},{10,1},{10,2}},
01236      {{12,-2},{12,-1},{12,1},{12,2},{},{},{},{}}}/*crate 13*/
01237   };
01238   memcpy( calibHOinfo, calibHOinfo_loc, sizeof(int)*NHOCR*NTOPBOT*NFBR*2 );
01239 
01240   /*********************************/
01241 
01242   //Stream variable
01243 
01244   stringstream mystream;
01245   
01246   ihtr=8; //calibration units are housed on htr slot 8
01247   idcc=1;
01248   idcc_sl=10;
01249   irm_fi = 1;// everything other than HE is on A
01250   det = "";
01251 
01252   /*****************************************************/
01253   /*HBHE calibration channels*/
01254   for(ic=0; ic<NHBHECR; ic++){
01255     icrate=calibcrate[ic];
01256     ifed=fedcalibnum[ic][idcc-1];
01257     /* top and bottom */
01258     for(itb=0; itb<NTOPBOT; itb++){
01259       /* 4 or 8 fibers used per HTR FPGA */
01260       for(ifb=0; ifb<nfbr_max[ic][itb]; ifb++){
01261         det = detIDCALIB[ic][itb];
01262         ihtr_fi=ifb+1;
01263         irm_fi = 1;// everything other than he is on A
01264         idphi=4;
01265         if (itb==1) if(ihtr_fi%2==0) irm_fi = 2;  //all of the even fibers in HE are on B rather than A
01266         if (det=="HE"){
01267           ispigot=13;
01268           fpga="bot";
01269           if (ihtr_fi==1||ihtr_fi==2||ihtr_fi==5||ihtr_fi==6) {
01270             iwedge = icalibsector_min[ic];
01271           }
01272           else if (ihtr_fi==3||ihtr_fi==4||ihtr_fi==7||ihtr_fi==8) {
01273             iwedge = icalibsector_max[ic];
01274           }
01275           if (ihtr_fi<5) {
01276             sidesign = 'M';
01277             S_side = '1';
01278             ieta = -1;
01279             iside=-1;
01280           }
01281           else {
01282             sidesign = 'P';
01283             S_side = '1';
01284             ieta = 1;
01285             iside=1;
01286           }
01287         }
01288         else if (det=="HB"){
01289           ispigot=12;
01290           fpga="top";
01291           (ihtr_fi%2==1) ? iwedge = icalibsector_min[ic] : iwedge = icalibsector_max[ic];
01292           if (ihtr_fi<3) {
01293             sidesign = 'M';
01294             S_side = '1';
01295             ieta = -1;
01296             iside=-1;
01297           }
01298           else {
01299             sidesign = 'P';
01300             S_side = '1';
01301             ieta = 1;
01302             iside=1;
01303           }
01304         }
01305         iphi = ((iwedge*idphi) + 71 - idphi)%72;
01306         subdet = "CALIB_"+det;
01307         sprintf (tempbuff, "%s%c%2.2i%c", det.c_str(), sidesign, iwedge,'\0');
01308         mystream<<tempbuff;
01309         rbx = mystream.str();
01310         mystream.str("");
01311         /* three channels per fiber */
01312         for(ifc=0; ifc<NFCH; ifc++){
01313           ifi_ch=ifc;
01314           if (irm_fi==1){
01315             if (ifc==0) ich_type=0;
01316             else if (ifc==1) ich_type=1;
01317             else if (ifc==2) {
01318               if (det=="HB") ich_type=2;
01319               else if(det=="HE") ich_type=3;
01320             }
01321           }
01322           else if (irm_fi==2){
01323             if (ifc==0) ich_type=4;
01324             else if (ifc==1) ich_type=5;
01325             else if (ifc==2) ich_type=6;
01326           }
01327           CALIBLogicalMapEntry caliblmapentry(
01328                                               ifi_ch, ihtr_fi, ispigot, ifed, icrate, ihtr, fpga,
01329                                               det, ieta, iphi, ich_type, 
01330                                               iside, idphi, rbx, iwedge, irm_fi,
01331                                               subdet
01332                                               );
01333           CALIBEntries.push_back(caliblmapentry);
01334           LinearIndex2Entry.at(caliblmapentry.getLinearIndex())=HcalLogicalMap::makeEntryNumber(1,2,CALIBEntries.size()-1);
01335 
01336           const HcalGenericDetId hgdi(caliblmapentry.getDetId());
01337           const int hashedId=hgdi.hashedId(false);
01338           if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenCalibration) HxCalibHash2Entry.at(hashedId)=CALIBEntries.size();
01339         }
01340       }
01341     }
01342   }
01343   
01344   /* only one CALIB HF crate */
01345   /* top and bottom */
01346   for(itb=0; itb<NTOPBOT; itb++){
01347     /* four CALIB HF fibers per HTR FPGA */
01348     for(ifb=0; ifb<4; ifb++){
01349       /* three channels per fiber */
01350       for(ifc=0; ifc<NFCH; ifc++){
01351         icrate=calibcrate[ic];
01352         det = "HF";
01353         ihtr_fi=ifb+1;
01354         ifi_ch=ifc;
01355         (ihtr_fi==1)?iphi=1:((ihtr_fi==2)?iphi=19:((ihtr_fi==3)?iphi=37:iphi=55));
01356         idphi=18;
01357         ifed=fedcalibnum[ic][idcc-1];
01358         (ifc==0)?ich_type=8:(ifc==1?ich_type=0:ich_type=1);
01359         //changed ch_type of fibre channel 0 from 2 to 8, as per HcalCalibDetId specification
01360         irm_fi = 1;
01361         //Wedge has steps of 3, HF(P/M)2,5,8,11
01362         //iwedge=ihtr_fi;
01363         iwedge=2+(ifb*3);
01364         if (itb==0){
01365           ispigot=12;
01366           fpga="top";
01367           sidesign='P';
01368           iside=1;
01369           ieta=1;
01370         }
01371         else {
01372           ispigot=13;
01373           fpga="bot";
01374           sidesign='M';
01375           iside=-1;
01376           ieta=-1;
01377         }
01378         subdet = "CALIB_"+det;
01379         sprintf (tempbuff, "%s%c%2.2i%c", det.c_str(), sidesign, iwedge,'\0');
01380         mystream<<tempbuff;
01381         rbx = mystream.str();
01382         mystream.str("");
01383         CALIBLogicalMapEntry caliblmapentry(
01384                                             ifi_ch, ihtr_fi, ispigot, ifed, icrate, ihtr, fpga,
01385                                             det, ieta, iphi, ich_type, 
01386                                             iside, idphi, rbx, iwedge, irm_fi,
01387                                             subdet
01388                                             );
01389         CALIBEntries.push_back(caliblmapentry);
01390         LinearIndex2Entry.at(caliblmapentry.getLinearIndex())=HcalLogicalMap::makeEntryNumber(1,2,CALIBEntries.size()-1);
01391 
01392         const HcalGenericDetId hgdi(caliblmapentry.getDetId());
01393         const int hashedId=hgdi.hashedId(false);
01394         if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenCalibration) HxCalibHash2Entry.at(hashedId)=CALIBEntries.size();  
01395       }
01396     }
01397   }
01398   ic++;
01399 
01400   /*HO calibration channels*/
01401   for(ic=ic; ic<NCALIBCR; ic++){
01402     icrate=calibcrate[ic];
01403     irm_fi = 1;// everything other than he is on A
01404     ifed=fedcalibnum[ic][idcc-1];
01405     /* top and bottom */
01406     for(itb=0; itb<NTOPBOT; itb++){
01407       det=detIDCALIB[ic][itb];
01408       /* 4 or 8 fibers used per HTR FPGA */
01409       for(ifb=0; ifb<nfbr_max[ic][itb]; ifb++){
01410         if (itb==1) {
01411           ispigot = 13;
01412           fpga = "bot";
01413         }
01414         else{
01415           ispigot = 12;
01416           fpga = "top";
01417         }
01418         ihtr_fi=ifb+1;
01419         iwedge=calibHOinfo[ic-10][itb][ifb][0];
01420         ieta=calibHOinfo[ic-10][itb][ifb][1];
01421         if (ieta<0) {
01422           iside=-1;
01423           sidesign='M';
01424         }
01425         else if (ieta>0){
01426           iside=1;
01427           sidesign='P';
01428         }
01429         else {
01430           iside=0;
01431           sidesign='0';
01432         }
01433         if (ieta==-2) S_side='2';
01434         else if (ieta==-1) S_side='1';
01435         else if (ieta==1) S_side='1';
01436         else if (ieta==2) S_side='2';
01437 
01438         subdet ="CALIB_"+det;
01439         if (ieta==0) sprintf (tempbuff, "%s%c%2.2i%c", det.c_str(), sidesign, iwedge,'\0');
01440         else  sprintf (tempbuff, "%s%c%c%2.2i%c", det.c_str(), S_side, sidesign, iwedge,'\0');
01441         mystream<<tempbuff;
01442         rbx = mystream.str();
01443         mystream.str("");
01444         /* only two channels used in HO per fiber */
01445         //now new information suggests that the third channel is used for x-talk
01446         //but only in some of the rm's, seems to be dependent on whether nfbr_max
01447         //sector 10 on YB+2,1,0,-1, sector 12 on YB-2
01448         int NFCH_HO;
01449         //( nfbr_max[ic][itb] == 4 ) ? NFCH_HO = 2 : NFCH_HO = 3;
01450         ( ieta == -2 ) ? ( iwedge == 12 ? NFCH_HO = 3 : NFCH_HO = 2 ) : ( iwedge == 10) ? NFCH_HO = 3 : NFCH_HO = 2;
01451         for(ifc=0; ifc<NFCH_HO; ifc++){
01452           ifi_ch=ifc;
01453           (ifi_ch == 2) ? ich_type = 7 : ich_type = ifi_ch;
01454           (ieta==0) ? idphi = 6 : idphi = 12;
01455           
01456           (ieta==0) ? iphi=((iwedge*idphi)+71-idphi)%72 : iphi=(((iwedge/2)*idphi)+71-idphi)%72;
01457           //nothing on htr_fi=4 for the top
01458           do {
01459             if (iside==0&&ifb==3) break;
01460             CALIBLogicalMapEntry caliblmapentry(
01461                                                 ifi_ch, ihtr_fi, ispigot, ifed, icrate, ihtr, fpga,
01462                                                 det, ieta, iphi, ich_type, 
01463                                                 iside, idphi, rbx, iwedge, irm_fi,
01464                                                 subdet
01465                                                 );
01466             CALIBEntries.push_back(caliblmapentry);
01467             LinearIndex2Entry.at(caliblmapentry.getLinearIndex())=HcalLogicalMap::makeEntryNumber(1,2,CALIBEntries.size()-1);
01468 
01469             const HcalGenericDetId hgdi(caliblmapentry.getDetId());
01470             const int hashedId=hgdi.hashedId(false);
01471             if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenCalibration) HxCalibHash2Entry.at(hashedId)=CALIBEntries.size();
01472           } while (ifb!=ifb);
01473         }
01474       }
01475     }
01476   }
01477 } 
01478 
01479 void HcalLogicalMapGenerator::buildZDCMap(std::vector <ZDCLogicalMapEntry>& ZDCEntries,
01480                                           std::vector <uint32_t>& LinearIndex2Entry,
01481                                           std::vector <uint32_t>& ZdcHash2Entry) {
01482   /******************************/
01483   /*ZDC channels*/
01484   //Stream variable
01485   stringstream mystream;
01486 
01487   ifed=722;
01488   iy=1;
01489   ihtr=8;
01490   icrate=12;
01491   idcc=1;
01492   idcc_sl=10;
01493   ispigot=12;
01494   /* side plus and minus */
01495   for(itb=0; itb<NTOPBOT; itb++){
01496     if (itb==0) {
01497       iside = 1;
01498       irm = 1;
01499       fpga = "top";
01500     }
01501     else {
01502       iside = -1;
01503       irm = 2;
01504       if (mapIOV_<4) {
01505         fpga = "top";
01506         ispigot = 12;}
01507       else {
01508         fpga = "bot";
01509         ispigot = 13;}
01510     }
01511     /*loop over ZDC cables*/
01512     for(icab=1; icab<NZDCCAB+1; icab++){
01513       if (icab < 4) {
01514         irm_fi = 1;
01515         iadc = icab - 1;
01516         ifi_ch = iadc;  
01517       }
01518       else if (icab < 7) {
01519         irm_fi = 2;
01520         iadc = icab - 1;
01521         ifi_ch = iadc - 3;
01522       }
01523       else {
01524         irm_fi = 3;
01525         iadc = icab - 7;
01526         ifi_ch = iadc;
01527       }
01528       if (itb==0) {
01529         ihtr_fi = irm_fi;
01530         if(mapIOV_==4) {
01531           if(icab == 4) { iadc = 5; ifi_ch = 2; }
01532           if(icab == 6) { iadc = 3; ifi_ch = 0; }
01533         }
01534       }
01535       else {
01536         if (mapIOV_<4) ihtr_fi = irm_fi + 3;
01537         else ihtr_fi = irm_fi;
01538       }
01539       if (icab < 6) {
01540         ix = icab;
01541         idepth = 1;
01542         idx = 1;
01543         det = "ZDC_EM";
01544         idet_ch = ix;
01545         iqie = 1;
01546       }
01547       else {
01548         ix = 1;
01549         idepth = icab - 4;
01550         idx = 5;
01551         det = "ZDC_HAD";
01552         idet_ch = icab - 5;
01553         if (icab==6) iqie = 1;
01554         else iqie =  2;
01555       }
01556       ZDCLogicalMapEntry zdclmapentry(
01557                                       ifi_ch, ihtr_fi, ispigot, ifed, icrate, ihtr, fpga,
01558                                       det, iside, idepth, 
01559                                       ix, iy, idx, idet_ch, icab, irm, iqie, 
01560                                       iadc, irm_fi
01561                                       );
01562       ZDCEntries.push_back(zdclmapentry);
01563       LinearIndex2Entry.at(zdclmapentry.getLinearIndex())=HcalLogicalMap::makeEntryNumber(1,3,ZDCEntries.size()-1);
01564     }
01565   }
01566 }
01567 
01568 
01569 /********************************************************/
01570 void HcalLogicalMapGenerator::ConstructTriggerTower(
01571                                                     std::vector <HTLogicalMapEntry>& HTEntries,
01572                                                     int iside, int ieta, int iphi, int idphi, int idepth, std::string det, int iwedge, int irm,
01573                                                     int ipixel, int iqie, int iadc, int irm_fi, int ifi_ch, int icrate, int ihtr, std::string fpga,
01574                                                     int ihtr_fi, int ispigot, int islb, std::string slbin, std::string slbin2,
01575                                                     std::string slnam, int irctcra, int irctcar, int irctcon, std::string rctnam, int ifed
01576                                                     )
01577 {
01578         
01579   string t_chDet,t_fpga;
01580   string t_slnam,t_rctnam,t_slbin,t_slbin2;
01581 
01582   int t_nDat=-1;
01583   int t_side,t_iEta,t_iPhi,t_jPhi,t_iDep,t_topbot;
01584   int t_wedge,t_crate,t_htr;
01585   //  int t_rm,t_pixel,t_qie,t_adc,t_rm_fi,t_fi_ch,t_htr_fi;
01586   int t_spigo,t_slb,t_rctcra,t_rctcar,t_rctcon,t_fedid;
01587 
01588   //making global variables local for modification
01589   (fpga=="bot") ? t_topbot = 1 : t_topbot = 0;
01590   t_side   = iside;
01591   t_iEta   = ieta;
01592   t_iPhi   = iphi;
01593   t_jPhi   = idphi;
01594   t_iDep   = idepth;
01595   t_chDet  = det;
01596   t_wedge  = iwedge;
01597   //  t_rm     = irm;
01598   //  t_pixel  = ipixel;
01599   //  t_qie    = iqie;
01600   //  t_adc    = iadc;
01601   //  t_rm_fi  = irm_fi;
01602   //  t_fi_ch  = ifi_ch;
01603   t_crate  = icrate;
01604   t_htr    = ihtr;
01605   t_fpga   = fpga;
01606   //  t_htr_fi = ihtr_fi;
01607   t_spigo  = ispigot;
01608   t_slb    = islb;
01609   t_slbin  = slbin;
01610   t_slbin2 = slbin2;
01611   t_slnam  = slnam;
01612   t_rctcra = irctcra;
01613   t_rctcar = irctcar;
01614   t_rctcon = irctcon;
01615   t_rctnam = rctnam;
01616   t_fedid  = ifed;
01617 
01618   do {
01619     if(t_iDep!=1) break;
01620     if(t_chDet=="HE"&&t_iEta==29) break;
01621 
01622     if(t_chDet=="HF") {
01623       t_jPhi=4;//20 degree slices in HF
01624       if(t_iEta==30||t_iEta==31||t_iEta==33||
01625          t_iEta==34||t_iEta==36||t_iEta==37||
01626          t_iEta==39||t_iEta==40||t_iEta==41) break;
01627 
01628       else if(t_iEta==32)t_iEta=30;
01629       else if(t_iEta==35)t_iEta=31;
01630       else if(t_iEta==38)t_iEta=32;
01631 
01632       if(t_iPhi==3||t_iPhi==7||t_iPhi==11||t_iPhi==15||t_iPhi==19||
01633          t_iPhi==23||t_iPhi==27||t_iPhi==31||t_iPhi==35||t_iPhi==39||
01634          t_iPhi==43||t_iPhi==47||t_iPhi==51||t_iPhi==55||t_iPhi==59||
01635          t_iPhi==63||t_iPhi==67||t_iPhi==71) break;
01636     }
01637   
01638     if(t_side<0) t_iEta=-t_iEta;
01639     t_chDet="HT";
01640     
01641     if(t_slbin!="NA") {
01642       if(t_slbin2!="NA") t_jPhi=1;
01643       if(t_slbin=="A0"||t_slbin=="B0")  t_nDat=0;
01644       else if(t_slbin=="A1"||t_slbin=="B1")  t_nDat=1;
01645       else if(t_slbin=="C0"||t_slbin=="D0")  t_nDat=2;
01646       else if(t_slbin=="C1"||t_slbin=="D1")  t_nDat=3;
01647       
01648       HTLogicalMapEntry htlmapentry(
01649                                     t_iEta, t_iPhi,
01650                                     t_side, t_jPhi, t_iDep, t_chDet, t_wedge, t_crate, t_htr, t_topbot, 
01651                                     t_spigo, t_slb, t_slbin, t_slbin2, t_nDat,
01652                                     t_slnam, t_rctcra, t_rctcar, t_rctcon, t_rctnam, t_fedid
01653                                     );
01654       HTEntries.push_back(htlmapentry);
01655     }
01656     if(t_slbin2!="NA") {
01657       if(t_slbin2=="A0"||t_slbin2=="B0")  t_nDat=0;
01658       else if(t_slbin2=="A1"||t_slbin2=="B1")  t_nDat=1;
01659       else if(t_slbin2=="C0"||t_slbin2=="D0")  t_nDat=2;
01660       else if(t_slbin2=="C1"||t_slbin2=="D1")  t_nDat=3;
01661       t_jPhi=1;//after splitting up these towers, each half should have dphi of 1
01662       t_iPhi+=1;
01663 
01664       HTLogicalMapEntry htlmapentry(
01665                                     t_iEta, t_iPhi,//changed from t_iPhi + 1 here to the spot above
01666                                     t_side, t_jPhi, t_iDep, t_chDet, t_wedge, t_crate, t_htr, t_topbot, 
01667                                     t_spigo, t_slb, t_slbin, t_slbin2, t_nDat,
01668                                     t_slnam, t_rctcra, t_rctcar, t_rctcon, t_rctnam, t_fedid
01669                                     );
01670       HTEntries.push_back(htlmapentry);
01671     }
01672   } while(1!=1);
01673 }