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
00021
00022
00023 for (i = 0; i < NRMFIBR; i++){
00024 for (j = 0; j < NFCH; j++){
00025
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
00055 std::vector <uint32_t> ZdcHash2Entry;
00056
00057 int HbHalf = 1296;
00058 int HeHalf = 1296;
00059
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,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
00096 int hbhecrate_loc[NHBHECR]={0,1,4,5,10,11,14,15,17};
00097 memcpy( hbhecrate, hbhecrate_loc, sizeof(int)*NHBHECR );
00098
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
00104 int ihslot_loc[NHSETS]={2,5,13,16};
00105 memcpy( ihslot, ihslot_loc, sizeof(int)*NHSETS );
00106
00107 int ihbhephis_loc[NHBHECR]={11,19,3,27,67,35,59,43,51};
00108 memcpy( ihbhephis, ihbhephis_loc, sizeof(int)*NHBHECR );
00109
00110 int ihbheetadepth_loc[NHTRS][NTOPBOT][NFBR][NFCH][2]={
00111 {{{{11,1},{ 7,1},{ 3,1}},
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}},
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}},
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}},
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}},
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}},
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
00163
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}},
00166 {{6,3},{7,3},{6,4},{7,4},{4,3},{5,3},{4,4},{5,4}}},
00167 {{{2,1},{3,1},{2,2},{3,2},{2,1},{3,1},{2,2},{3,2}},
00168 {{2,3},{3,3},{2,4},{3,4},{2,3},{3,3},{2,4},{3,4}}},
00169 {{{4,1},{5,1},{4,2},{5,2},{6,1},{7,1},{6,2},{7,2}},
00170 {{4,3},{5,3},{4,4},{5,4},{6,3},{7,3},{6,4},{7,4}}}
00171 };
00172 memcpy( irm_rmfiHBHE, irm_rmfiHBHE_loc, sizeof(int)*NHTRS*NTOPBOT*NFBR*2 );
00173
00174
00175 int ipixelHB_loc[NRMFIBR][NFCH][NRMSLOT] = {
00176 {{18, 17, 3, 2 }, {13, 3, 17, 7 }, {14, 1, 19, 6 }},
00177 {{19, 2, 18, 1 }, {15, 7, 13, 5 }, {17, 19, 1, 3 }},
00178 {{9, 4, 16, 11}, {5, 8, 12, 15}, {2, 13, 7, 18}},
00179 {{12, 11, 9, 8 }, {7, 15, 5, 13}, {16, 6, 14, 4 }},
00180 {{8, 5, 15, 12}, {4, 9, 11, 16}, {1, 14, 6, 19}},
00181 {{6, 16, 4, 14}, {3, 18, 2, 17}, {11, 12, 8, 9 }}
00182 };
00183 memcpy( ipixelHB, ipixelHB_loc, sizeof(int)*NRMFIBR*NFCH*NRMSLOT );
00184
00185 int ipixelHE_loc[NRMFIBR][NFCH][NRMSLOT] = {
00186 {{12, 12, 12, 12}, {16, 7, 16, 7 }, {7, 16, 7, 16}},
00187 {{11, 11, 11, 11}, {19, 3, 19, 3 }, {3, 19, 3, 19}},
00188 {{15, 15, 6, 6 }, {2, 18, 2, 18}, {6, 6, 15, 15}},
00189 {{5, 14, 5, 14}, {14, 5, 14, 5 }, {18, 2, 18, 2 }},
00190 {{17, 1, 17, 1 }, {9, 9, 9, 9 }, {1, 17, 1, 17}},
00191 {{13, 4, 13, 4 }, {8, 8, 8, 8 }, {4, 13, 4, 13}}
00192 };
00193 memcpy( ipixelHE, ipixelHE_loc, sizeof(int)*NRMFIBR*NFCH*NRMSLOT );
00194
00195
00196
00197
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,
00214 1,1,2,2,3,3,1,1,
00215 2,2,3,3,4,4,4,4,4};
00216 memcpy( slb_table, slb_table_loc, sizeof(int)*29 );
00217
00218
00219
00220 stringstream mystream;
00221
00222
00223 for(ic=0; ic<NHBHECR; ic++){
00224
00225 for(is=0; is<NHSETS; is++){
00226
00227 for(ih=0; ih<NHTRS; ih++){
00228
00229 for(itb=0; itb<NTOPBOT; itb++){
00230
00231 for(ifb=0; ifb<NFBR; ifb++){
00232
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
00250
00251
00252
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
00260 if (ieta >= 21 && (irm == 1 || irm == 3)) iwedge = (iphi + 1 + irm + 1) / 4;
00261 else iwedge = (iphi + irm + 1) / 4;
00262
00263
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
00273 if (ieta >= 21 && (irm == 4 || irm == 2)) iwedge = (iphi + 1 - irm + 6) / 4;
00274 else iwedge = (iphi - irm + 6) / 4;
00275
00276
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
00286
00287
00288
00289 if (ieta > 16 || idepth > 2) ipixel = ipixelHE[irm_fi - 2][ifc][irm - 1];
00290 else ipixel = ipixelHB[irm_fi - 2][ifc][irm - 1];
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
00315 if (ieta <= 24) {
00316 irctcar = 2 * ((ieta - 1)/8) + oddcard;
00317 irctcon = 2 * (((ieta - 1)/2)%4);
00318 }
00319 else {
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
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;
00346 if (ieta == 29) ietamod = 0;
00347 else ietamod = ieta % 2;
00348 if (ieta < 25) {
00349 if (ietamod == 1) mystream<<S_slbin_odd[phimod8];
00350 else mystream<<S_slbin_even[phimod8];
00351 }
00352 else if (crazy == 0) {
00353 if (ietamod == 1) mystream<<S_slbin_odd[phimod8];
00354 else mystream<<S_slbin_even[phimod8];
00355 }
00356 else {
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
00406 int hfcrate_loc[NHFCR]={2,9,12};
00407 memcpy( hfcrate, hfcrate_loc, sizeof(int)*NHFCR );
00408
00409 int fedhfnum_loc[NHFCR][2]={{718,719},{720,721},{722,723}};
00410 memcpy( fedhfnum, fedhfnum_loc, sizeof(int)*NHFCR*2 );
00411
00412 int ihfphis_loc[NHFCR]={3,27,51};
00413 memcpy( ihfphis, ihfphis_loc, sizeof(int)*NHFCR );
00414
00415 int ihfetadepth_loc[NTOPBOT][NFBR][NFCH][2]={
00416 {{{33,1},{31,1},{29,1}},
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}},
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}},
00438 {{5,2},{6,2},{7,2},{8,2},{5,3},{6,3},{7,3},{8,3}}},
00439 {{{1,1},{2,1},{3,1},{4,1},{1,2},{2,2},{3,2},{4,2}},
00440 {{5,1},{6,1},{7,1},{8,1},{5,2},{6,2},{7,2},{8,2}}},
00441 {{{1,3},{2,3},{3,3},{4,3},{1,1},{2,1},{3,1},{4,1}},
00442 {{5,3},{6,3},{7,3},{8,3},{5,1},{6,1},{7,1},{8,1}}}
00443 };
00444 memcpy( irm_rmfiHF, irm_rmfiHF_loc, sizeof(int)*NHTRS*NTOPBOT*NFBR*2 );
00445
00446
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
00465 for(ic=0; ic<NHFCR; ic++){
00466
00467 for(is=0; is<NHSETS; is++){
00468
00469 for(ih=0; ih<NHTRS; ih++){
00470
00471 for(itb=0; itb<NTOPBOT; itb++){
00472
00473 for(ifb=0; ifb<NFBR; ifb++){
00474
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
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
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
00523 if (iphi >= 71) iwedge = 1;
00524 else iwedge = (iphi + 1) / 4 + 1;
00525
00526
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
00533 ipixel = 0;
00534
00535
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
00542
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
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
00619 int hocrate_loc[NHOCR]={3,7,6,13};
00620 memcpy( hocrate, hocrate_loc, sizeof(int)*NHOCR );
00621
00622 int fedhonum_loc[NHOCR][2]={{724,725},{726,727},{728,729},{730,731}};
00623 memcpy( fedhonum, fedhonum_loc, sizeof(int)*NHOCR*2 );
00624
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
00628 int ihophis_loc[NHOCR]={71,17,35,53};
00629 memcpy( ihophis, ihophis_loc, sizeof(int)*NHOCR );
00630
00631
00632
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
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
00666 HO_RM_fi_eta16 = 6;
00667
00668
00669
00670
00671 int HO_htr_fi_450eta5to15_loc[2][11] = {{2, 2, 4, 6, 8, 2, 4, 6, 8, 4, 6},
00672 {2, 8, 6, 4, 2, 8, 6, 4, 2, 4, 2}};
00673 memcpy( HO_htr_fi_450eta5to15, HO_htr_fi_450eta5to15_loc, sizeof(int)*2*11 );
00674
00675
00676 int HO_htr_fi_450eta16M_loc[4] = {7, 7, 8, 8};
00677 memcpy( HO_htr_fi_450eta16M, HO_htr_fi_450eta16M_loc, sizeof(int)*4 );
00678
00679
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} };
00681 memcpy( HO_htr_fi_450eta16P, HO_htr_fi_450eta16P_loc, sizeof(int)*4*6 );
00682
00683
00684 int HO_htr_fi_eta4_loc[2][6] = {{6, 6, 8, 8, 7, 7},
00685 {4, 4, 5, 5, 3, 3}};
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},
00689 {8, 7, 6, 5, 2, 1}};
00690 memcpy( HO_htr_fi_eta123, HO_htr_fi_eta123_loc, sizeof(int)*2*6 );
00691
00692
00693
00694
00695
00696 int HO_RM_fi_eta1to4_loc[72][2][2] =
00697 {
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}},
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}},
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}},
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}},
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}},
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}},
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}},
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}},
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}}
00707 };
00708 memcpy( HO_RM_fi_eta1to4, HO_RM_fi_eta1to4_loc, sizeof(int)*72*2*2 );
00709
00710
00711
00712
00713
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}},
00715 {{ 2, 9},{ 1,13},{ 3, 5}}, {{11,19},{16,18},{15,17}}, {{13,15},{ 9,14},{14,16}}};
00716 memcpy( ipixelHO, ipixelHO_loc, sizeof(int)*NRMFIBR*NFCH*2 );
00717
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
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741 if(mapIOV_==1) {
00742 int rmspecialeta_loc[6][6] = {
00743 { 14, 15, 14, 13, 12, 11 },
00744 { 14, 15, 14, 13, 12, 11 },
00745 { 10, 9, 8, 7, 6, 5 },
00746 { 10, 9, 8, 7, 6, 5 },
00747 { 14, 15, 14, 13, 12, 11 },
00748 { 14, 15, 14, 13, 12, 11 }
00749 };
00750
00751 std::string rmspeciallet_code_loc[6][6] = {
00752 { "X", "B", "C", "D", "E", "F" },
00753 { "X", "P", "Q", "R", "S", "T" },
00754 { "G", "H", "J", "K", "L", "M" },
00755 { "A", "B", "C", "D", "E", "F" },
00756 { "X", "B", "C", "D", "E", "F" },
00757 { "X", "P", "Q", "R", "S", "T" }
00758 };
00759
00760 std::string rmspecialdet_loc[6][6] = {
00761 { "HOX", "HO", "HO", "HO", "HO", "HO" },
00762 { "HOX", "HO", "HO", "HO", "HO", "HO" },
00763 { "HO", "HO", "HO", "HO", "HO", "HO" },
00764 { "HO", "HO", "HO", "HO", "HO", "HO" },
00765 { "HOX", "HO", "HO", "HO", "HO", "HO" },
00766 { "HOX", "HO", "HO", "HO", "HO", "HO" }
00767 };
00768
00769 memcpy( rmspecialeta, rmspecialeta_loc, sizeof(int)*6*6 );
00770
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] = {
00783 { 11, 12, 13, 14, 15, 15 },
00784 { 11, 12, 13, 14, 15, 15 },
00785 { 5, 6, 7, 8, 9, 10 },
00786 { 5, 6, 7, 8, 9, 10 },
00787 { 14, 15, 14, 13, 12, 11 },
00788 { 11, 12, 13, 14, 15, 15 }
00789 };
00790
00791 std::string rmspeciallet_code_loc[6][6] = {
00792 { "F", "E", "D", "C", "B", "X" },
00793 { "T", "S", "R", "Q", "P", "X" },
00794 { "M", "L", "K", "J", "H", "G" },
00795 { "F", "E", "D", "C", "B", "A" },
00796 { "X", "B", "C", "D", "E", "F" },
00797 { "T", "S", "R", "Q", "P", "X" }
00798 };
00799
00800 std::string rmspecialdet_loc[6][6] = {
00801 { "HO", "HO", "HO", "HO", "HO", "HOX" },
00802 { "HO", "HO", "HO", "HO", "HO", "HOX" },
00803 { "HO", "HO", "HO", "HO", "HO", "HO" },
00804 { "HO", "HO", "HO", "HO", "HO", "HO" },
00805 { "HOX", "HO", "HO", "HO", "HO", "HO" },
00806 { "HO", "HO", "HO", "HO", "HO", "HOX" }
00807 };
00808
00809 memcpy( rmspecialeta, rmspecialeta_loc, sizeof(int)*6*6 );
00810
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] = {
00823 { 11, 12, 13, 14, 15, 15 },
00824 { 11, 12, 13, 14, 15, 15 },
00825 { 5, 6, 7, 8, 9, 10 },
00826 { 5, 6, 7, 8, 9, 10 },
00827 { 11, 12, 13, 14, 15, 15 },
00828 { 11, 12, 13, 14, 15, 15 }
00829 };
00830
00831 std::string rmspeciallet_code_loc[6][6] = {
00832 { "F", "E", "D", "C", "B", "X" },
00833 { "T", "S", "R", "Q", "P", "X" },
00834 { "M", "L", "K", "J", "H", "G" },
00835 { "F", "E", "D", "C", "B", "A" },
00836 { "F", "E", "D", "C", "B", "X" },
00837 { "T", "S", "R", "Q", "P", "X" }
00838 };
00839
00840 std::string rmspecialdet_loc[6][6] = {
00841 { "HO", "HO", "HO", "HO", "HO", "HOX" },
00842 { "HO", "HO", "HO", "HO", "HO", "HOX" },
00843 { "HO", "HO", "HO", "HO", "HO", "HO" },
00844 { "HO", "HO", "HO", "HO", "HO", "HO" },
00845 { "HO", "HO", "HO", "HO", "HO", "HOX" },
00846 { "HO", "HO", "HO", "HO", "HO", "HOX" }
00847 };
00848
00849 memcpy( rmspecialeta, rmspecialeta_loc, sizeof(int)*6*6 );
00850
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
00864 stringstream mystream;
00865
00866
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
00885
00886
00887 phmod6 = iph % 6;
00888
00889 phmod6e450 = (phmod6 == 4 || phmod6 == 5 || phmod6 == 0);
00890 phmod6e123 = (phmod6 == 1 || phmod6 == 2 || phmod6 == 3);
00891
00892
00893 if (ieta <= 3 && (iside < 0 || phmod6 >= 4)) fpga = "bot";
00894 else if (ieta <= 3 && iside > 0 && phmod6 < 4) fpga = "top";
00895
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
00899 else if (ieta >= 10 && iside > 0) fpga = "top";
00900 else if (ieta < 10 && ieta >= 6 && iside > 0) fpga = "bot";
00901
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
00908 if (ieta <= 20) idphi = 1;
00909 else idphi = -1000;
00910
00911
00912 if (iside == 1) sidear = 1;
00913 else sidear = 0;
00914
00915 if (fpga == "bot") itb = 1;
00916 else itb = 0;
00917
00918
00919 phmod24 = iph % 24;
00920
00921
00922 irm = HO_RM_table[phmod24][iet][sidear];
00923
00924
00925
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
00933
00934
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
00942
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
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
00969
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
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
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
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
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
01013 else if (ieta == 1){
01014 if (phir0v1 || phir0v3) ifi_ch = 0;
01015 else if (phir0v2 || phir0v4) ifi_ch = 1;
01016 }
01017
01018
01019
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
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
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
01045 sector = 0;
01046 for (i = -2; i < iphi; i+=6){
01047 sector++;
01048 }
01049 if (sector > 12) sector = 1;
01050
01051 isector = sector;
01052
01053
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
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
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
01189 int calibcrate_loc[NCALIBCR]={4,0,1,5,11,15,17,14,10,9,7,6,13};
01190 memcpy( calibcrate, calibcrate_loc, sizeof(int)*NCALIBCR );
01191
01192 int fedcalibnum_loc[NCALIBCR][2]={{700,701},{702,703},{704,705},{706,707},{708,709},{710,711},{712,713},{714,715},{716,717},
01193 {720,721},
01194 {726,727},{728,729},{730,731}};
01195 memcpy( fedcalibnum, fedcalibnum_loc, sizeof(int)*NCALIBCR*2 );
01196
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
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
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
01206 std::string detIDCALIB_loc[NCALIBCR][NTOPBOT] = {{"HB","HE"},
01207 {"HB","HE"},
01208 {"HB","HE"},
01209 {"HB","HE"},
01210 {"HB","HE"},
01211 {"HB","HE"},
01212 {"HB","HE"},
01213 {"HB","HE"},
01214 {"HB","HE"},
01215 {"HF","HF"},
01216 {"HO","HO"},
01217 {"HO","HO"},
01218 {"HO","HO"}};
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
01228 int calibHOinfo_loc[NHOCR][NTOPBOT][NFBR][2]={
01229 {{{4,0},{5,0},{6,0},{},{6,-2},{6,-1},{6,1},{6,2}},
01230 {{4,-2},{4,-1},{4,1},{4,2},{},{},{},{}}},
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}}},
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},{},{},{},{}}}
01237 };
01238 memcpy( calibHOinfo, calibHOinfo_loc, sizeof(int)*NHOCR*NTOPBOT*NFBR*2 );
01239
01240
01241
01242
01243
01244 stringstream mystream;
01245
01246 ihtr=8;
01247 idcc=1;
01248 idcc_sl=10;
01249 irm_fi = 1;
01250 det = "";
01251
01252
01253
01254 for(ic=0; ic<NHBHECR; ic++){
01255 icrate=calibcrate[ic];
01256 ifed=fedcalibnum[ic][idcc-1];
01257
01258 for(itb=0; itb<NTOPBOT; itb++){
01259
01260 for(ifb=0; ifb<nfbr_max[ic][itb]; ifb++){
01261 det = detIDCALIB[ic][itb];
01262 ihtr_fi=ifb+1;
01263 irm_fi = 1;
01264 idphi=4;
01265 if (itb==1) if(ihtr_fi%2==0) irm_fi = 2;
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
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
01345
01346 for(itb=0; itb<NTOPBOT; itb++){
01347
01348 for(ifb=0; ifb<4; ifb++){
01349
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
01360 irm_fi = 1;
01361
01362
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
01401 for(ic=ic; ic<NCALIBCR; ic++){
01402 icrate=calibcrate[ic];
01403 irm_fi = 1;
01404 ifed=fedcalibnum[ic][idcc-1];
01405
01406 for(itb=0; itb<NTOPBOT; itb++){
01407 det=detIDCALIB[ic][itb];
01408
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
01445
01446
01447
01448 int NFCH_HO;
01449
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
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
01484
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
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
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
01586 int t_spigo,t_slb,t_rctcra,t_rctcar,t_rctcon,t_fedid;
01587
01588
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
01598
01599
01600
01601
01602
01603 t_crate = icrate;
01604 t_htr = ihtr;
01605 t_fpga = fpga;
01606
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;
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;
01662 t_iPhi+=1;
01663
01664 HTLogicalMapEntry htlmapentry(
01665 t_iEta, t_iPhi,
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 }