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 #include "Geometry/CaloTopology/interface/HcalTopology.h"
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( const HcalTopology* topo, 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(topo,HBHEHFEntries,HTEntries,LinearIndex2Entry,HbHash2Entry,HeHash2Entry,HfHash2Entry,HtHash2Entry);
00077 buildHOXMap(topo,HOHXEntries,LinearIndex2Entry,HoHash2Entry,HxCalibHash2Entry);
00078 buildCALIBMap(topo,CALIBEntries,LinearIndex2Entry,HxCalibHash2Entry);
00079 buildZDCMap(topo,ZDCEntries,LinearIndex2Entry,ZdcHash2Entry);
00080
00081 return HcalLogicalMap(topo,HBHEHFEntries,HOHXEntries,CALIBEntries,ZDCEntries,HTEntries,
00082 LinearIndex2Entry,HbHash2Entry,HeHash2Entry,HfHash2Entry,HtHash2Entry,
00083 HoHash2Entry,HxCalibHash2Entry,ZdcHash2Entry);
00084 }
00085
00086 void HcalLogicalMapGenerator::buildHBEFTMap(const HcalTopology* topo,
00087 std::vector <HBHEHFLogicalMapEntry>& HBHEHFEntries,
00088 std::vector <HTLogicalMapEntry>& HTEntries,
00089 std::vector <uint32_t>& LinearIndex2Entry,
00090 std::vector <uint32_t>& HbHash2Entry,
00091 std::vector <uint32_t>& HeHash2Entry,
00092 std::vector <uint32_t>& HfHash2Entry,
00093 std::vector <uint32_t>& HtHash2Entry) {
00094
00095
00096
00097 int hbhecrate_loc[NHBHECR]={0,1,4,5,10,11,14,15,17};
00098 memcpy( hbhecrate, hbhecrate_loc, sizeof(int)*NHBHECR );
00099
00100 int fedhbhenum_loc[NHBHECR][2]={{702,703},{704,705},{700,701},
00101 {706,707},{716,717},{708,709},
00102 {714,715},{710,711},{712,713}};
00103 memcpy( fedhbhenum, fedhbhenum_loc, sizeof(int)*NHBHECR*2 );
00104
00105 int ihslot_loc[NHSETS]={2,5,13,16};
00106 memcpy( ihslot, ihslot_loc, sizeof(int)*NHSETS );
00107
00108 int ihbhephis_loc[NHBHECR]={11,19,3,27,67,35,59,43,51};
00109 memcpy( ihbhephis, ihbhephis_loc, sizeof(int)*NHBHECR );
00110
00111 int ihbheetadepth_loc[NHTRS][NTOPBOT][NFBR][NFCH][2]={
00112 {{{{11,1},{ 7,1},{ 3,1}},
00113 {{ 5,1},{ 1,1},{ 9,1}},
00114 {{11,1},{ 7,1},{ 3,1}},
00115 {{ 5,1},{ 1,1},{ 9,1}},
00116 {{10,1},{ 6,1},{ 2,1}},
00117 {{ 8,1},{ 4,1},{12,1}},
00118 {{10,1},{ 6,1},{ 2,1}},
00119 {{ 8,1},{ 4,1},{12,1}}},
00120 {{{11,1},{ 7,1},{ 3,1}},
00121 {{ 5,1},{ 1,1},{ 9,1}},
00122 {{11,1},{ 7,1},{ 3,1}},
00123 {{ 5,1},{ 1,1},{ 9,1}},
00124 {{10,1},{ 6,1},{ 2,1}},
00125 {{ 8,1},{ 4,1},{12,1}},
00126 {{10,1},{ 6,1},{ 2,1}},
00127 {{ 8,1},{ 4,1},{12,1}}}},
00128 {{{{16,2},{15,2},{14,1}},
00129 {{15,1},{13,1},{16,1}},
00130 {{16,2},{15,2},{14,1}},
00131 {{15,1},{13,1},{16,1}},
00132 {{17,1},{16,3},{26,1}},
00133 {{18,1},{18,2},{26,2}},
00134 {{17,1},{16,3},{25,1}},
00135 {{18,1},{18,2},{25,2}}},
00136 {{{16,2},{15,2},{14,1}},
00137 {{15,1},{13,1},{16,1}},
00138 {{16,2},{15,2},{14,1}},
00139 {{15,1},{13,1},{16,1}},
00140 {{17,1},{16,3},{25,1}},
00141 {{18,1},{18,2},{25,2}},
00142 {{17,1},{16,3},{26,1}},
00143 {{18,1},{18,2},{26,2}}}},
00144 {{{{28,1},{28,2},{29,1}},
00145 {{28,3},{24,2},{24,1}},
00146 {{27,1},{27,2},{29,2}},
00147 {{27,3},{23,2},{23,1}},
00148 {{19,2},{20,1},{22,2}},
00149 {{19,1},{20,2},{22,1}},
00150 {{19,2},{20,1},{21,2}},
00151 {{19,1},{20,2},{21,1}}},
00152 {{{27,1},{27,2},{29,2}},
00153 {{27,3},{23,2},{23,1}},
00154 {{28,1},{28,2},{29,1}},
00155 {{28,3},{24,2},{24,1}},
00156 {{19,2},{20,1},{21,2}},
00157 {{19,1},{20,2},{21,1}},
00158 {{19,2},{20,1},{22,2}},
00159 {{19,1},{20,2},{22,1}}}}
00160 };
00161 memcpy( ihbheetadepth, ihbheetadepth_loc, sizeof(int)*NHTRS*NTOPBOT*NFBR*NFCH*2 );
00162
00163
00164
00165 int irm_rmfiHBHE_loc[NHTRS][NTOPBOT][NFBR][2]={
00166 {{{6,1},{7,1},{6,2},{7,2},{4,1},{5,1},{4,2},{5,2}},
00167 {{6,3},{7,3},{6,4},{7,4},{4,3},{5,3},{4,4},{5,4}}},
00168 {{{2,1},{3,1},{2,2},{3,2},{2,1},{3,1},{2,2},{3,2}},
00169 {{2,3},{3,3},{2,4},{3,4},{2,3},{3,3},{2,4},{3,4}}},
00170 {{{4,1},{5,1},{4,2},{5,2},{6,1},{7,1},{6,2},{7,2}},
00171 {{4,3},{5,3},{4,4},{5,4},{6,3},{7,3},{6,4},{7,4}}}
00172 };
00173 memcpy( irm_rmfiHBHE, irm_rmfiHBHE_loc, sizeof(int)*NHTRS*NTOPBOT*NFBR*2 );
00174
00175
00176 int ipixelHB_loc[NRMFIBR][NFCH][NRMSLOT] = {
00177 {{18, 17, 3, 2 }, {13, 3, 17, 7 }, {14, 1, 19, 6 }},
00178 {{19, 2, 18, 1 }, {15, 7, 13, 5 }, {17, 19, 1, 3 }},
00179 {{9, 4, 16, 11}, {5, 8, 12, 15}, {2, 13, 7, 18}},
00180 {{12, 11, 9, 8 }, {7, 15, 5, 13}, {16, 6, 14, 4 }},
00181 {{8, 5, 15, 12}, {4, 9, 11, 16}, {1, 14, 6, 19}},
00182 {{6, 16, 4, 14}, {3, 18, 2, 17}, {11, 12, 8, 9 }}
00183 };
00184 memcpy( ipixelHB, ipixelHB_loc, sizeof(int)*NRMFIBR*NFCH*NRMSLOT );
00185
00186 int ipixelHE_loc[NRMFIBR][NFCH][NRMSLOT] = {
00187 {{12, 12, 12, 12}, {16, 7, 16, 7 }, {7, 16, 7, 16}},
00188 {{11, 11, 11, 11}, {19, 3, 19, 3 }, {3, 19, 3, 19}},
00189 {{15, 15, 6, 6 }, {2, 18, 2, 18}, {6, 6, 15, 15}},
00190 {{5, 14, 5, 14}, {14, 5, 14, 5 }, {18, 2, 18, 2 }},
00191 {{17, 1, 17, 1 }, {9, 9, 9, 9 }, {1, 17, 1, 17}},
00192 {{13, 4, 13, 4 }, {8, 8, 8, 8 }, {4, 13, 4, 13}}
00193 };
00194 memcpy( ipixelHE, ipixelHE_loc, sizeof(int)*NRMFIBR*NFCH*NRMSLOT );
00195
00196
00197
00198
00199
00200 const char* S_slbin_odd_loc[] ={"A1","B0","B1","A0","A1","B0","B1","A0"};
00201 for (int gg = 0; gg < 8; gg++) {
00202 S_slbin_odd[gg] = S_slbin_odd_loc[gg];
00203 }
00204 const char* S_slbin_even_loc[]={"C1","D0","D1","C0","C1","D0","D1","C0"};
00205 for (int gg = 0; gg < 8; gg++) {
00206 S_slbin_even[gg] = S_slbin_even_loc[gg];
00207 }
00208 const char* rct_rackHBHE_loc[]={"S2E01-RH","S2E03-RH","S2E05-RH","S2E07-RH","S2E09-RH","S2E08-RL","S2E06-RL","S2E04-RL","S2E02-RL",
00209 "S2E02-RH","S2E04-RH","S2E06-RH","S2E08-RH","S2E09-RL","S2E07-RL","S2E05-RL","S2E03-RL","S2E01-RL"};
00210 for (int gg = 0; gg < 18; gg++) {
00211 rct_rackHBHE[gg] = rct_rackHBHE_loc[gg];
00212 }
00213
00214 int slb_table_loc[29] = {1,1,2,2,3,3,4,4,5,5,6,6,
00215 1,1,2,2,3,3,1,1,
00216 2,2,3,3,4,4,4,4,4};
00217 memcpy( slb_table, slb_table_loc, sizeof(int)*29 );
00218
00219
00220
00221 stringstream mystream;
00222
00223
00224 for(ic=0; ic<NHBHECR; ic++){
00225
00226 for(is=0; is<NHSETS; is++){
00227
00228 for(ih=0; ih<NHTRS; ih++){
00229
00230 for(itb=0; itb<NTOPBOT; itb++){
00231
00232 for(ifb=0; ifb<NFBR; ifb++){
00233
00234 for(ifc=0; ifc<NFCH; ifc++){
00235 icrate=hbhecrate[ic];
00236 iside=is<NHSETS/2?-1:1;
00237 ifwtb=(is/2+itb+1)%2;
00238 ieta=ihbheetadepth[ih][ifwtb][ifb][ifc][0];
00239 idepth=ihbheetadepth[ih][ifwtb][ifb][ifc][1];
00240 ihtr=ihslot[is]+ih;
00241 (ieta>16||idepth>2) ? det = "HE": det = "HB";
00242 (itb%2)==1 ? fpga = "bot" : fpga = "top";
00243 ihtr_fi=ifb+1;
00244 ifi_ch=ifc;
00245 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;
00246 ispigot=(is%2)*6+ih*2+itb;
00247 idcc=is<NHSETS/2?1:2;
00248 idcc_sl=idcc==1?10:20;
00249 ifed=fedhbhenum[ic][idcc-1];
00250
00251
00252
00253
00254 if (iside == -1){
00255 S_side = '-';
00256 sidesign = 'M';
00257 irm = irm_rmfiHBHE[ih][(itb + 1) % 2][ifb][1];
00258 irm_fi = irm_rmfiHBHE[ih][(itb + 1) % 2][ifb][0];
00259
00260
00261 if (ieta >= 21 && (irm == 1 || irm == 3)) iwedge = (iphi + 1 + irm + 1) / 4;
00262 else iwedge = (iphi + irm + 1) / 4;
00263
00264
00265 if (iwedge > 18) iwedge -= 18;
00266 }
00267 else{
00268 S_side = '+';
00269 sidesign = 'P';
00270 irm = irm_rmfiHBHE[ih][itb][ifb][1];
00271 irm_fi = irm_rmfiHBHE[ih][itb][ifb][0];
00272
00273
00274 if (ieta >= 21 && (irm == 4 || irm == 2)) iwedge = (iphi + 1 - irm + 6) / 4;
00275 else iwedge = (iphi - irm + 6) / 4;
00276
00277
00278 if (iwedge > 18) iwedge -= 18;
00279 }
00280
00281 sprintf (tempbuff, "%s%c%2.2i%c", det.c_str(), sidesign, iwedge,'\0');
00282 mystream<<tempbuff;
00283 rbx = mystream.str();
00284 mystream.str("");
00285
00286
00287
00288
00289
00290 if (ieta > 16 || idepth > 2) ipixel = ipixelHE[irm_fi - 2][ifc][irm - 1];
00291 else ipixel = ipixelHB[irm_fi - 2][ifc][irm - 1];
00292
00293 iqie = iadcquiHBHE[irm_fi - 2][ifc][0];
00294 iadc = iadcquiHBHE[irm_fi - 2][ifc][1];
00295
00296 phideg = iphi - 3;
00297 if (phideg < 0) phideg = phideg + 72;
00298 phideg = (phideg / 4) * 20 + 10;
00299 irctcra = (( 89 - phideg + 720)%360)/20;
00300 oddcard = irctcra % 2;
00301 irctcra /= 2;
00302 if (iside > 0) irctcra = irctcra + 9;
00303
00304 etaslb = ((ieta - 1) / 2) * 2 + 1;
00305 if (etaslb > 27) etaslb = 27;
00306
00307
00308 sprintf(tempbuff,"SLB_H_%3.3d%c%2.2d%c",phideg,S_side,etaslb,'\0');
00309 mystream<<tempbuff;
00310 slnam = mystream.str();
00311 mystream.str("");
00312
00313 islb = slb_table[ieta - 1];
00314
00315
00316 if (ieta <= 24) {
00317 irctcar = 2 * ((ieta - 1)/8) + oddcard;
00318 irctcon = 2 * (((ieta - 1)/2)%4);
00319 }
00320 else {
00321 irctcar = 6;
00322 eta2 = ieta;
00323 if (eta2 > 28) eta2 = 28;
00324 if (oddcard == 0) eta3 = eta2;
00325 else eta3 = 57 - eta2;
00326 irctcon = 2 * (((eta3 - 1) / 2) % 4);
00327 }
00328 irctcon = 11 * irctcon + 1;
00329
00330 sprintf(tempbuff,"%s-%1d-HD%2.2d",rct_rackHBHE[irctcra],irctcar,irctcon);
00331 mystream<<tempbuff;
00332 rctnam = mystream.str();
00333 mystream.str("");
00334
00335
00336
00337 phimod8 = iphi % 8;
00338
00339 for (i = 0; i < 18; i++) {
00340 if (iphi < i * 4 + 3) {
00341 crazy = i % 2;
00342 break;
00343 }
00344 }
00345
00346 int ietamod;
00347 if (ieta == 29) ietamod = 0;
00348 else ietamod = ieta % 2;
00349 if (ieta < 25) {
00350 if (ietamod == 1) mystream<<S_slbin_odd[phimod8];
00351 else mystream<<S_slbin_even[phimod8];
00352 }
00353 else if (crazy == 0) {
00354 if (ietamod == 1) mystream<<S_slbin_odd[phimod8];
00355 else mystream<<S_slbin_even[phimod8];
00356 }
00357 else {
00358 if (ietamod == 1) mystream<<S_slbin_even[phimod8];
00359 else mystream<<S_slbin_odd[phimod8];
00360 }
00361
00362 slbin = mystream.str();
00363 mystream.str("");
00364
00365 if (ieta > 20){
00366 idphi = 2;
00367 slbin2 = slbin;
00368 slbin2[1] = '1';
00369 }
00370 else{
00371 idphi = 1;
00372 slbin2 = "NA";
00373 }
00374
00375 HBHEHFLogicalMapEntry hbeflmapentry(
00376 ifi_ch, ihtr_fi, ispigot, ifed, icrate, ihtr, fpga,
00377 det, iside, ieta, iphi, idepth,
00378 idphi, iwedge, irm, irm_fi, ipixel, iqie, iadc,
00379 islb, irctcra, irctcar, irctcon,
00380 rbx, slbin, slbin2, slnam, rctnam
00381 );
00382 HBHEHFEntries.push_back(hbeflmapentry);
00383 LinearIndex2Entry.at(hbeflmapentry.getLinearIndex())=HcalLogicalMap::makeEntryNumber(1,0,HBHEHFEntries.size()-1);
00384
00385 const HcalGenericDetId hgdi(hbeflmapentry.getDetId());
00386 unsigned int denseId;
00387 if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenBarrel) {
00388 denseId=topo->detId2denseIdHB(hgdi);
00389 HbHash2Entry.at(denseId)=HBHEHFEntries.size();
00390 }
00391 if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenEndcap) {
00392 denseId=topo->detId2denseIdHE(hgdi);
00393 HeHash2Entry.at(denseId)=HBHEHFEntries.size();
00394 }
00395 if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenForward) {
00396 denseId=topo->detId2denseIdHF(hgdi);
00397 HfHash2Entry.at(denseId)=HBHEHFEntries.size();
00398 }
00399
00400 ConstructTriggerTower(topo,
00401 HTEntries,
00402 iside, ieta, iphi, idphi, idepth, det, iwedge, irm,
00403 ipixel, iqie, iadc, irm_fi, ifi_ch, icrate, ihtr, fpga,
00404 ihtr_fi, ispigot, islb, slbin, slbin2,
00405 slnam, irctcra, irctcar, irctcon, rctnam, ifed
00406 );
00407 }
00408 }
00409 }
00410 }
00411 }
00412 }
00413
00414
00415
00416 int hfcrate_loc[NHFCR]={2,9,12};
00417 memcpy( hfcrate, hfcrate_loc, sizeof(int)*NHFCR );
00418
00419 int fedhfnum_loc[NHFCR][2]={{718,719},{720,721},{722,723}};
00420 memcpy( fedhfnum, fedhfnum_loc, sizeof(int)*NHFCR*2 );
00421
00422 int ihfphis_loc[NHFCR]={3,27,51};
00423 memcpy( ihfphis, ihfphis_loc, sizeof(int)*NHFCR );
00424
00425 int ihfetadepth_loc[NTOPBOT][NFBR][NFCH][2]={
00426 {{{33,1},{31,1},{29,1}},
00427 {{32,1},{30,1},{34,1}},
00428 {{33,2},{31,2},{29,2}},
00429 {{32,2},{30,2},{34,2}},
00430 {{34,2},{32,2},{30,2}},
00431 {{31,2},{29,2},{33,2}},
00432 {{34,1},{32,1},{30,1}},
00433 {{31,1},{29,1},{33,1}}},
00434 {{{41,1},{37,1},{35,1}},
00435 {{38,1},{36,1},{39,1}},
00436 {{41,2},{37,2},{35,2}},
00437 {{38,2},{36,2},{39,2}},
00438 {{40,2},{38,2},{36,2}},
00439 {{37,2},{35,2},{39,2}},
00440 {{40,1},{38,1},{36,1}},
00441 {{37,1},{35,1},{39,1}}}
00442 };
00443 memcpy( ihfetadepth, ihfetadepth_loc, sizeof(int)*NTOPBOT*NFBR*NFCH*2 );
00444
00445
00446 int irm_rmfiHF_loc[NHTRS][NTOPBOT][NFBR][2]={
00447 {{{1,2},{2,2},{3,2},{4,2},{1,3},{2,3},{3,3},{4,3}},
00448 {{5,2},{6,2},{7,2},{8,2},{5,3},{6,3},{7,3},{8,3}}},
00449 {{{1,1},{2,1},{3,1},{4,1},{1,2},{2,2},{3,2},{4,2}},
00450 {{5,1},{6,1},{7,1},{8,1},{5,2},{6,2},{7,2},{8,2}}},
00451 {{{1,3},{2,3},{3,3},{4,3},{1,1},{2,1},{3,1},{4,1}},
00452 {{5,3},{6,3},{7,3},{8,3},{5,1},{6,1},{7,1},{8,1}}}
00453 };
00454 memcpy( irm_rmfiHF, irm_rmfiHF_loc, sizeof(int)*NHTRS*NTOPBOT*NFBR*2 );
00455
00456
00457 const char* S_slbin_7_loc[] ={"A0","A1","B0","B1"};
00458 for (int gg = 0; gg < 4; gg++) {
00459 S_slbin_7[gg] = S_slbin_7_loc[gg];
00460 }
00461 const char* S_slbin_3_loc[] ={"C0","C1","D0","D1"};
00462 for (int gg = 0; gg < 4; gg++) {
00463 S_slbin_3[gg] = S_slbin_3_loc[gg];
00464 }
00465 const char* rct_rackHF_loc[]={"S2E01-FH","S2E03-FH","S2E05-FH","S2E07-FH","S2E09-FH","S2E08-FL","S2E06-FL","S2E04-FL","S2E02-FL",
00466 "S2E02-FH","S2E04-FH","S2E06-FH","S2E08-FH","S2E09-FL","S2E07-FL","S2E05-FL","S2E03-FL","S2E01-FL"};
00467 for (int gg = 0; gg < 18; gg++) {
00468 rct_rackHF[gg] = rct_rackHF_loc[gg];
00469 }
00470
00471
00472
00473
00474
00475 for(ic=0; ic<NHFCR; ic++){
00476
00477 for(is=0; is<NHSETS; is++){
00478
00479 for(ih=0; ih<NHTRS; ih++){
00480
00481 for(itb=0; itb<NTOPBOT; itb++){
00482
00483 for(ifb=0; ifb<NFBR; ifb++){
00484
00485 for(ifc=0; ifc<NFCH; ifc++){
00486 icrate=hfcrate[ic];
00487 iside=is<NHSETS/2?-1:1;
00488 ieta=ihfetadepth[itb][ifb][ifc][0];
00489 idepth=ihfetadepth[itb][ifb][ifc][1];
00490 ihtr=ihslot[is]+ih;
00491 det = "HF";
00492 (itb%2)== 1 ? fpga = "bot" : fpga = "top";
00493 ihtr_fi=ifb+1;
00494 ifi_ch=ifc;
00495 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;
00496 ispigot=(is%2)*6+ih*2+itb;
00497 idcc=is<NHSETS/2?1:2;
00498 idcc_sl=idcc==1?10:20;
00499 ifed=fedhfnum[ic][idcc-1];
00500
00501 irm_fi = irm_rmfiHF[ih][itb][ifb][0];
00502
00503
00504 if (iside == -1){
00505 S_side = '-';
00506 sidesign = 'M';
00507
00508 if (ieta < 40){
00509 if (iphi == 1) iphi = 71;
00510 else if (iphi == 71) iphi = 1;
00511 else if (iphi % 4 == 1) iphi -= 2;
00512 else if (iphi % 4 == 3) iphi += 2;
00513 else edm::LogInfo( "HcalLogicalMapGenerator") <<"Even iphi in HFM"<<endl;
00514 }
00515 }
00516 else{
00517 S_side = '+';
00518 sidesign = 'P';
00519 }
00520
00521
00522 if ((iside == 1 && ieta == 40) || (iside == -1 && ieta == 41)){
00523 irm = ((iphi + 1) / 2) % 36 + 1;
00524 hfphi = ((iphi + 1) / 6) % 12 + 1;
00525 }
00526 else{
00527 irm = ( iphi + 1) / 2;
00528 hfphi = (iphi - 1) / 6 + 1;
00529 }
00530 irm = (irm - 1) % 3 + 1;
00531
00532
00533 if (iphi >= 71) iwedge = 1;
00534 else iwedge = (iphi + 1) / 4 + 1;
00535
00536
00537 sprintf (tempbuff, "%s%c%2.2i%c", det.c_str(), sidesign, hfphi,'\0');
00538 mystream<<tempbuff;
00539 rbx = mystream.str();
00540 mystream.str("");
00541
00542
00543 ipixel = 0;
00544
00545
00546 iqie = (irm_fi - 1) / 2 + 1;
00547
00548 if (irm_fi % 2 != 0) iadc = ifi_ch;
00549 else iadc = NFCH + (ifi_ch + 1) % 3;
00550
00551
00552
00553 phideg = iphi - 3;
00554 if (phideg < 0) phideg = phideg + 72;
00555 phideg = (phideg / 4) * 20 + 10;
00556 irctcra = (( 89 - phideg + 720)%360)/40;
00557 if (iside > 0) irctcra = irctcra + 9;
00558
00559
00560 irctcar = 99;
00561 irctcon = 0;
00562
00563 etaslb = 29;
00564
00565 sprintf(tempbuff,"SLB_H_%3.3d%c%2.2d",phideg,S_side,etaslb);
00566 mystream<<tempbuff;
00567 slnam = mystream.str();
00568 mystream.str("");
00569
00570 sprintf(tempbuff,"%s-JSC-HF_IN",rct_rackHF[irctcra]);
00571 mystream<<tempbuff;
00572 rctnam = mystream.str();
00573 mystream.str("");
00574
00575 islb = 6;
00576
00577 int phibin = (iphi + 1) % 8 ;
00578 int etabin = (ieta - 29) / 3;
00579 if (etabin < 0) etabin = 0;
00580 if (etabin > 3) etabin = 3;
00581 if (phibin < 4) mystream<<S_slbin_7[etabin];
00582 else mystream<<S_slbin_3[etabin];
00583
00584 slbin = mystream.str();
00585 mystream.str("");
00586
00587 slbin2 = "NA";
00588
00589 if (ieta < 40) idphi = 2;
00590 else idphi = 4;
00591
00592 HBHEHFLogicalMapEntry hbeflmapentry(
00593 ifi_ch, ihtr_fi, ispigot, ifed, icrate, ihtr, fpga,
00594 det, iside, ieta, iphi, idepth,
00595 idphi, iwedge, irm, irm_fi, ipixel, iqie, iadc,
00596 islb, irctcra, irctcar, irctcon,
00597 rbx, slbin, slbin2, slnam, rctnam
00598 );
00599 HBHEHFEntries.push_back(hbeflmapentry);
00600 LinearIndex2Entry.at(hbeflmapentry.getLinearIndex())=HcalLogicalMap::makeEntryNumber(1,0,HBHEHFEntries.size()-1);
00601
00602 const HcalGenericDetId hgdi(hbeflmapentry.getDetId());
00603 unsigned int denseId;
00604 if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenBarrel) {
00605 denseId=topo->detId2denseIdHB(hgdi);
00606 HbHash2Entry.at(denseId)=HBHEHFEntries.size();
00607 }
00608 if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenEndcap) {
00609 denseId=topo->detId2denseIdHE(hgdi);
00610 HeHash2Entry.at(denseId)=HBHEHFEntries.size();
00611 }
00612 if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenForward) {
00613 denseId=topo->detId2denseIdHF(hgdi);
00614 HfHash2Entry.at(denseId)=HBHEHFEntries.size();
00615 }
00616
00617 ConstructTriggerTower(topo,
00618 HTEntries,
00619 iside, ieta, iphi, idphi, idepth, det, iwedge, irm,
00620 ipixel, iqie, iadc, irm_fi, ifi_ch, icrate, ihtr, fpga,
00621 ihtr_fi, ispigot, islb, slbin, slbin2,
00622 slnam, irctcra, irctcar, irctcon, rctnam, ifed
00623 );
00624 }
00625 }
00626 }
00627 }
00628 }
00629 }
00630 }
00631
00632 void HcalLogicalMapGenerator::buildHOXMap(const HcalTopology* topo,
00633 std::vector <HOHXLogicalMapEntry>& HOHXEntries,
00634 std::vector <uint32_t>& LinearIndex2Entry,
00635 std::vector <uint32_t>& HoHash2Entry,
00636 std::vector <uint32_t>& HxCalibHash2Entry) {
00637
00638
00639 int hocrate_loc[NHOCR]={3,7,6,13};
00640 memcpy( hocrate, hocrate_loc, sizeof(int)*NHOCR );
00641
00642 int fedhonum_loc[NHOCR][2]={{724,725},{726,727},{728,729},{730,731}};
00643 memcpy( fedhonum, fedhonum_loc, sizeof(int)*NHOCR*2 );
00644
00645 int ihslotho_loc[NHSETSHO][NHTRSHO]={{2,3,4,5},{6,7,13,14},{15,16,17,18}};
00646 memcpy( ihslotho, ihslotho_loc, sizeof(int)*NHSETSHO*NHTRSHO );
00647
00648 int ihophis_loc[NHOCR]={71,17,35,53};
00649 memcpy( ihophis, ihophis_loc, sizeof(int)*NHOCR );
00650
00651
00652
00653 int HO_RM_table_loc[24][16][2] =
00654 {
00655 {{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}},
00656 {{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}},
00657 {{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}},
00658 {{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}},
00659 {{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}},
00660 {{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}},
00661 {{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}},
00662 {{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}},
00663 {{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}},
00664 {{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}},
00665 {{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}},
00666 {{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}},
00667 {{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}},
00668 {{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}},
00669 {{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}},
00670 {{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}},
00671 {{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}},
00672 {{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}},
00673 {{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}},
00674 {{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}},
00675 {{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}},
00676 {{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}},
00677 {{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}},
00678 {{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}}
00679 };
00680 memcpy( HO_RM_table, HO_RM_table_loc, sizeof(int)*24*16*2 );
00681
00682
00683 int HO_RM_fi_eta5to15_loc[11] = {3, 2, 5, 4, 7, 6, 3, 2, 5, 4, 7};
00684 memcpy( HO_RM_fi_eta5to15, HO_RM_fi_eta5to15_loc, sizeof(int)*11 );
00685
00686 HO_RM_fi_eta16 = 6;
00687
00688
00689
00690
00691 int HO_htr_fi_450eta5to15_loc[2][11] = {{2, 2, 4, 6, 8, 2, 4, 6, 8, 4, 6},
00692 {2, 8, 6, 4, 2, 8, 6, 4, 2, 4, 2}};
00693 memcpy( HO_htr_fi_450eta5to15, HO_htr_fi_450eta5to15_loc, sizeof(int)*2*11 );
00694
00695
00696 int HO_htr_fi_450eta16M_loc[4] = {7, 7, 8, 8};
00697 memcpy( HO_htr_fi_450eta16M, HO_htr_fi_450eta16M_loc, sizeof(int)*4 );
00698
00699
00700 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} };
00701 memcpy( HO_htr_fi_450eta16P, HO_htr_fi_450eta16P_loc, sizeof(int)*4*6 );
00702
00703
00704 int HO_htr_fi_eta4_loc[2][6] = {{6, 6, 8, 8, 7, 7},
00705 {4, 4, 5, 5, 3, 3}};
00706 memcpy( HO_htr_fi_eta4, HO_htr_fi_eta4_loc, sizeof(int)*2*6 );
00707
00708 int HO_htr_fi_eta123_loc[2][6] = {{6, 5, 4, 3, 8, 7},
00709 {8, 7, 6, 5, 2, 1}};
00710 memcpy( HO_htr_fi_eta123, HO_htr_fi_eta123_loc, sizeof(int)*2*6 );
00711
00712
00713
00714
00715
00716 int HO_RM_fi_eta1to4_loc[72][2][2] =
00717 {
00718 {{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}},
00719 {{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}},
00720 {{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}},
00721 {{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}},
00722 {{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}},
00723 {{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}},
00724 {{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}},
00725 {{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}},
00726 {{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}}
00727 };
00728 memcpy( HO_RM_fi_eta1to4, HO_RM_fi_eta1to4_loc, sizeof(int)*72*2*2 );
00729
00730
00731
00732
00733
00734 int ipixelHO_loc[NRMFIBR][NFCH][2] = {{{12,12},{ 7, 7},{ 6, 3}}, {{ 4, 4},{ 8, 8},{ 5, 1}}, {{19,11},{18, 6},{17, 2}},
00735 {{ 2, 9},{ 1,13},{ 3, 5}}, {{11,19},{16,18},{15,17}}, {{13,15},{ 9,14},{14,16}}};
00736 memcpy( ipixelHO, ipixelHO_loc, sizeof(int)*NRMFIBR*NFCH*2 );
00737
00738 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"}},
00739 {{"X","K"},{"R","R"},{"H","D"}}, {{"D","A"},{"C","G"},{"B","N"}}, {{"L","H"},{"M","P"},{"K","B"}}};
00740
00741 for (int jj = 0; jj < NRMFIBR; jj++) {
00742 for (int kk = 0; kk < NFCH; kk++) {
00743 for (int ll = 0; ll < 2; ll++) {
00744 letterHO[jj][kk][ll] = letterHO_loc[jj][kk][ll];
00745 }
00746 }
00747 }
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761 if(mapIOV_==1) {
00762 int rmspecialeta_loc[6][6] = {
00763 { 14, 15, 14, 13, 12, 11 },
00764 { 14, 15, 14, 13, 12, 11 },
00765 { 10, 9, 8, 7, 6, 5 },
00766 { 10, 9, 8, 7, 6, 5 },
00767 { 14, 15, 14, 13, 12, 11 },
00768 { 14, 15, 14, 13, 12, 11 }
00769 };
00770
00771 std::string rmspeciallet_code_loc[6][6] = {
00772 { "X", "B", "C", "D", "E", "F" },
00773 { "X", "P", "Q", "R", "S", "T" },
00774 { "G", "H", "J", "K", "L", "M" },
00775 { "A", "B", "C", "D", "E", "F" },
00776 { "X", "B", "C", "D", "E", "F" },
00777 { "X", "P", "Q", "R", "S", "T" }
00778 };
00779
00780 std::string rmspecialdet_loc[6][6] = {
00781 { "HOX", "HO", "HO", "HO", "HO", "HO" },
00782 { "HOX", "HO", "HO", "HO", "HO", "HO" },
00783 { "HO", "HO", "HO", "HO", "HO", "HO" },
00784 { "HO", "HO", "HO", "HO", "HO", "HO" },
00785 { "HOX", "HO", "HO", "HO", "HO", "HO" },
00786 { "HOX", "HO", "HO", "HO", "HO", "HO" }
00787 };
00788
00789 memcpy( rmspecialeta, rmspecialeta_loc, sizeof(int)*6*6 );
00790
00791
00792 for (int jj = 0; jj < 6; jj++) {
00793 for (int kk = 0; kk < 6; kk++) {
00794 rmspeciallet_code[jj][kk] = rmspeciallet_code_loc[jj][kk];}}
00795
00796 for (int jj = 0; jj < 6; jj++) {
00797 for (int kk = 0; kk < 6; kk++) {
00798 rmspecialdet[jj][kk] = rmspecialdet_loc[jj][kk];}}
00799 }
00800
00801 else if (mapIOV_==2) {
00802 int rmspecialeta_loc[6][6] = {
00803 { 11, 12, 13, 14, 15, 15 },
00804 { 11, 12, 13, 14, 15, 15 },
00805 { 5, 6, 7, 8, 9, 10 },
00806 { 5, 6, 7, 8, 9, 10 },
00807 { 14, 15, 14, 13, 12, 11 },
00808 { 11, 12, 13, 14, 15, 15 }
00809 };
00810
00811 std::string rmspeciallet_code_loc[6][6] = {
00812 { "F", "E", "D", "C", "B", "X" },
00813 { "T", "S", "R", "Q", "P", "X" },
00814 { "M", "L", "K", "J", "H", "G" },
00815 { "F", "E", "D", "C", "B", "A" },
00816 { "X", "B", "C", "D", "E", "F" },
00817 { "T", "S", "R", "Q", "P", "X" }
00818 };
00819
00820 std::string rmspecialdet_loc[6][6] = {
00821 { "HO", "HO", "HO", "HO", "HO", "HOX" },
00822 { "HO", "HO", "HO", "HO", "HO", "HOX" },
00823 { "HO", "HO", "HO", "HO", "HO", "HO" },
00824 { "HO", "HO", "HO", "HO", "HO", "HO" },
00825 { "HOX", "HO", "HO", "HO", "HO", "HO" },
00826 { "HO", "HO", "HO", "HO", "HO", "HOX" }
00827 };
00828
00829 memcpy( rmspecialeta, rmspecialeta_loc, sizeof(int)*6*6 );
00830
00831
00832 for (int jj = 0; jj < 6; jj++) {
00833 for (int kk = 0; kk < 6; kk++) {
00834 rmspeciallet_code[jj][kk] = rmspeciallet_code_loc[jj][kk];}}
00835
00836 for (int jj = 0; jj < 6; jj++) {
00837 for (int kk = 0; kk < 6; kk++) {
00838 rmspecialdet[jj][kk] = rmspecialdet_loc[jj][kk];}}
00839 }
00840
00841 else {
00842 int rmspecialeta_loc[6][6] = {
00843 { 11, 12, 13, 14, 15, 15 },
00844 { 11, 12, 13, 14, 15, 15 },
00845 { 5, 6, 7, 8, 9, 10 },
00846 { 5, 6, 7, 8, 9, 10 },
00847 { 11, 12, 13, 14, 15, 15 },
00848 { 11, 12, 13, 14, 15, 15 }
00849 };
00850
00851 std::string rmspeciallet_code_loc[6][6] = {
00852 { "F", "E", "D", "C", "B", "X" },
00853 { "T", "S", "R", "Q", "P", "X" },
00854 { "M", "L", "K", "J", "H", "G" },
00855 { "F", "E", "D", "C", "B", "A" },
00856 { "F", "E", "D", "C", "B", "X" },
00857 { "T", "S", "R", "Q", "P", "X" }
00858 };
00859
00860 std::string rmspecialdet_loc[6][6] = {
00861 { "HO", "HO", "HO", "HO", "HO", "HOX" },
00862 { "HO", "HO", "HO", "HO", "HO", "HOX" },
00863 { "HO", "HO", "HO", "HO", "HO", "HO" },
00864 { "HO", "HO", "HO", "HO", "HO", "HO" },
00865 { "HO", "HO", "HO", "HO", "HO", "HOX" },
00866 { "HO", "HO", "HO", "HO", "HO", "HOX" }
00867 };
00868
00869 memcpy( rmspecialeta, rmspecialeta_loc, sizeof(int)*6*6 );
00870
00871
00872 for (int jj = 0; jj < 6; jj++) {
00873 for (int kk = 0; kk < 6; kk++) {
00874 rmspeciallet_code[jj][kk] = rmspeciallet_code_loc[jj][kk];}}
00875
00876 for (int jj = 0; jj < 6; jj++) {
00877 for (int kk = 0; kk < 6; kk++) {
00878 rmspecialdet[jj][kk] = rmspecialdet_loc[jj][kk];}}
00879 }
00880
00881
00882
00883
00884 stringstream mystream;
00885
00886
00887 for(isid = -1; isid < 2; isid+=2){
00888 for (iph = 0; iph < NHOPHI; iph++){
00889 for (iet = 0; iet < NHOETA; iet++){
00890
00891 iphi = iph + 1;
00892 ieta = iet + 1;
00893 iside = isid;
00894
00895 if (iphi >= 71 || iphi < 17) ic = 0;
00896 else if (iphi >= 17 && iphi < 35) ic = 1;
00897 else if (iphi >= 35 && iphi < 53) ic = 2;
00898 else ic = 3;
00899
00900 icrate=hocrate[ic];
00901 idepth=4;
00902 det = "HO";
00903
00904
00905
00906
00907 phmod6 = iph % 6;
00908
00909 phmod6e450 = (phmod6 == 4 || phmod6 == 5 || phmod6 == 0);
00910 phmod6e123 = (phmod6 == 1 || phmod6 == 2 || phmod6 == 3);
00911
00912
00913 if (ieta <= 3 && (iside < 0 || phmod6 >= 4)) fpga = "bot";
00914 else if (ieta <= 3 && iside > 0 && phmod6 < 4) fpga = "top";
00915
00916 else if ((ieta > 15 && iside > 0) && (icrate == 3 || icrate == 6)) fpga = "top";
00917 else if ((ieta > 15 && iside > 0) && (icrate == 7 || icrate == 13)) fpga = "bot";
00918
00919 else if (ieta >= 10 && iside > 0) fpga = "top";
00920 else if (ieta < 10 && ieta >= 6 && iside > 0) fpga = "bot";
00921
00922 else if ((ieta == 5 && iside > 0) || ieta == 4) fpga = "top";
00923 else if ((ieta == 5 || ieta >= 10) && iside < 0) fpga = "bot";
00924 else if ((ieta < 10 && ieta >= 6) && iside < 0) fpga = "top";
00925 else edm::LogInfo( "HcalLogicalMapGenerator") <<"Bad fpga code"<<endl;
00926
00927
00928 if (ieta <= 20) idphi = 1;
00929 else idphi = -1000;
00930
00931
00932 if (iside == 1) sidear = 1;
00933 else sidear = 0;
00934
00935 if (fpga == "bot") itb = 1;
00936 else itb = 0;
00937
00938
00939 phmod24 = iph % 24;
00940
00941
00942 irm = HO_RM_table[phmod24][iet][sidear];
00943
00944
00945
00946 if (ieta==16) irm_fi = HO_RM_fi_eta16;
00947 else if (ieta >= 5) irm_fi = HO_RM_fi_eta5to15[ieta - 5];
00948 else if (ieta <= 3) irm_fi = HO_RM_fi_eta1to4[iph][0][sidear];
00949 else if (ieta == 4) irm_fi = HO_RM_fi_eta1to4[iph][1][sidear];
00950 else irm_fi = -1000;
00951
00952
00953
00954
00955
00956 if (ieta <= 3 || (ieta >= 14 && iside == 1)) ih = 0;
00957 else if (ieta <= 13 && ieta >= 6 && iside == 1) ih = 1;
00958 else if (ieta <= 13 && ieta >= 6 && iside == -1) ih = 3;
00959 else ih = 2;
00960
00961
00962
00963
00964 if (iphi % 18 == 17 || iphi % 18 <= 4) is = 0;
00965 else if (iphi % 18 >= 5 && iphi % 18 <= 10) is = 1;
00966 else is = 2;
00967
00968 if ( ieta == 16 && iside > 0 ) ihtr=21;
00969 else ihtr=ihslotho[is][ih];
00970
00971 if ((ieta > 15 && iside > 0) && (icrate == 3 || icrate == 6)) ispigot = 12;
00972 else if ((ieta > 15 && iside > 0) && (icrate == 7 || icrate == 13)) ispigot = 13;
00973 else ispigot=ihtr<9?(ihtr-2)*2+itb:(ihtr-13)*2+itb;
00974 idcc=ihtr<9?1:2;
00975 idcc_sl = idcc == 1 ?10:20;
00976
00977 ifed=fedhonum[ic][idcc-1];
00978
00979
00980
00981
00982 if (ieta >= 5 && phmod6e450) ihtr_fi = HO_htr_fi_450eta5to15[sidear][ieta - 5];
00983 else if (ieta >= 5 && phmod6e123) ihtr_fi = HO_htr_fi_450eta5to15[sidear][ieta - 5] - 1;
00984 else if (ieta == 4) ihtr_fi = HO_htr_fi_eta4[sidear][phmod6];
00985 else if (ieta <= 3) ihtr_fi = HO_htr_fi_eta123[sidear][phmod6];
00986 else ihtr_fi = -1000;
00987
00988
00989
00990 phi1458 = (iphi % 12 == 1 || iphi % 12 == 4 || iphi % 12 == 5 || iphi % 12 == 8);
00991 phi271011 = (iphi % 12 == 2 || iphi % 12 == 7 || iphi % 12 == 10 || iphi % 12 == 11);
00992
00993
00994 phir0v1 = (iphi % 24 == 0 || iphi % 24 == 2 || iphi % 24 == 4 || iphi % 24 == 18 || iphi % 24 == 20 || iphi % 24 == 22);
00995 phir0v2 = (iphi % 24 == 1 || iphi % 24 == 3 || iphi % 24 == 17 || iphi % 24 == 19 || iphi % 24 == 21 || iphi % 24 == 23);
00996
00997 phir0v3 = (iphi % 24 == 5 || iphi % 24 == 7 || iphi % 24 == 9 || iphi % 24 == 11 || iphi % 24 == 13 || iphi % 24 == 15);
00998 phir0v4 = (iphi % 24 == 6 || iphi % 24 == 8 || iphi % 24 == 10 || iphi % 24 == 12 || iphi % 24 == 14 || iphi % 24 == 16);
00999
01000 if (ieta >= 5){
01001 if (ieta % 2 == 0 && phi1458) ifi_ch = 0;
01002 else if (ieta % 2 == 0 && iphi % 3 == 0) ifi_ch = 1;
01003 else if (ieta % 2 == 0 && phi271011) ifi_ch = 2;
01004 else if (ieta % 2 == 1 && iphi % 3 == 0) ifi_ch = 0;
01005 else if (ieta % 2 == 1 && phi271011) ifi_ch = 1;
01006 else if (ieta % 2 == 1 && phi1458) ifi_ch = 2;
01007 }
01008 else if (ieta == 4){
01009 if (iside == -1){
01010 if (phir0v1) ifi_ch = 0;
01011 else if (phir0v4) ifi_ch = 1;
01012 else if (iphi % 2 == 1) ifi_ch = 2;
01013 }
01014 else{
01015 if (phir0v3) ifi_ch = 0;
01016 else if (phir0v2) ifi_ch = 1;
01017 else if (iphi % 2 == 0) ifi_ch = 2;
01018 }
01019 }
01020
01021 else if ((ieta == 3 && iside == -1) || (ieta == 2 && iside == 1)){
01022 if (phir0v4) ifi_ch = 0;
01023 else if (phir0v3) ifi_ch = 1;
01024 else if (phir0v1 || phir0v2) ifi_ch = 2;
01025 }
01026
01027 else if ((ieta == 3 && iside == 1) || (ieta == 2 && iside == -1)){
01028 if (phir0v2) ifi_ch = 0;
01029 else if (phir0v1) ifi_ch = 1;
01030 else if (phir0v3 || phir0v4) ifi_ch = 2;
01031 }
01032
01033 else if (ieta == 1){
01034 if (phir0v1 || phir0v3) ifi_ch = 0;
01035 else if (phir0v2 || phir0v4) ifi_ch = 1;
01036 }
01037
01038
01039
01040 iqie = (irm_fi - 2) / 2 + 1;
01041
01042 if (irm_fi % 2 == 0) iadc = ifi_ch;
01043 else iadc = NFCH + (ifi_ch + 1) % 3;
01044
01045
01046 if (ieta <= 4){
01047 ipixel = ipixelHO[irm_fi - 2][ifi_ch][0];
01048 letter = letterHO[irm_fi - 2][ifi_ch][0];
01049 }
01050 else{
01051 ipixel = ipixelHO[irm_fi - 2][ifi_ch][1];
01052 letter = letterHO[irm_fi - 2][ifi_ch][1];
01053 }
01054
01055
01056
01057 if (iside == -1) sidesign = 'M';
01058 else sidesign = 'P';
01059
01060 if (ieta <= 4) ring = 0;
01061 else if (ieta >= 5 && ieta <= 10) ring = 1;
01062 else ring = 2;
01063
01064
01065 sector = 0;
01066 for (i = -2; i < iphi; i+=6){
01067 sector++;
01068 }
01069 if (sector > 12) sector = 1;
01070
01071 isector = sector;
01072
01073
01074 if (ring != 0 && sector % 2 != 0) sector++;
01075
01076 if (ring == 0) sprintf (tempbuff, "%s%i%2.2d", det.c_str(), ring, sector);
01077 else sprintf (tempbuff, "%s%i%c%2.2d", det.c_str(), ring, sidesign, sector);
01078 mystream<<tempbuff;
01079 rbx = mystream.str();
01080 mystream.str("");
01081 if (ieta == 16) {
01082 det = "HOX";
01083 letter = "X";}
01084 else det = "HO";
01085
01086
01087 if (ieta==16 && isid<0) ihtr_fi = HO_htr_fi_450eta16M[irm - 1];
01088 else if (ieta==16 && isid>0) ihtr_fi = HO_htr_fi_450eta16P[irm - 1][sector/2-1];
01089
01090 if ((ieta > 15 && iside > 0) && (icrate == 3 || icrate == 7)) {
01091 icrate = 6;
01092 ifed = 729;
01093 }
01094 else if ((ieta > 15 && iside > 0) && (icrate == 6 || icrate == 13)) {
01095 icrate = 7;
01096 ifed = 727;
01097 }
01098
01099 if ( ieta == 16 ) ieta = 15;
01100
01101 if ( iside == 1 && ring == 2 ) {
01102 if ( iphi == 5 ) {
01103 ieta = rmspecialeta[0][iet - 10];
01104 letter = rmspeciallet_code[0][iet - 10];
01105 det = rmspecialdet[0][iet - 10];
01106 }
01107 else if ( iphi == 67 ) {
01108 ieta = rmspecialeta[1][iet - 10];
01109 letter = rmspeciallet_code[1][iet - 10];
01110 det = rmspecialdet[1][iet - 10];
01111 }
01112 }
01113 else if ( iside == -1) {
01114 if ( ring == 1 ) {
01115 if ( iphi == 57 ) {
01116 ieta = rmspecialeta[2][iet - 4];
01117 letter = rmspeciallet_code[2][iet - 4];
01118 det = rmspecialdet[2][iet - 4];
01119 }
01120 else if ( iphi == 65 ) {
01121 ieta = rmspecialeta[3][iet - 4];
01122 letter = rmspeciallet_code[3][iet - 4];
01123 det = rmspecialdet[3][iet - 4];
01124 }
01125 }
01126 else if ( ring == 2 ) {
01127 if ( iphi == 16 ) {
01128 ieta = rmspecialeta[4][iet - 10];
01129 letter = rmspeciallet_code[4][iet - 10];
01130 det = rmspecialdet[4][iet - 10];
01131 }
01132 else if ( iphi == 31 ) {
01133 ieta = rmspecialeta[5][iet - 10];
01134 letter = rmspeciallet_code[5][iet - 10];
01135 det = rmspecialdet[5][iet - 10];
01136 }
01137 }
01138 }
01139
01140 HOHXLogicalMapEntry hoxlmapentry(
01141 ifi_ch, ihtr_fi, ispigot, ifed, icrate, ihtr, fpga,
01142 det, iside, ieta, iphi, idepth,
01143 idphi, isector, irm, irm_fi, ipixel, iqie, iadc,
01144 rbx, letter
01145 );
01146 HOHXEntries.push_back(hoxlmapentry);
01147 LinearIndex2Entry.at(hoxlmapentry.getLinearIndex())=HcalLogicalMap::makeEntryNumber(1,1,HOHXEntries.size()-1);
01148
01149 const HcalGenericDetId hgdi(hoxlmapentry.getDetId());
01150 unsigned int denseId;
01151 if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenOuter) {
01152 denseId=topo->detId2denseIdHO(hgdi);
01153 HoHash2Entry.at(denseId)=HOHXEntries.size();
01154 } else if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenCalibration) {
01155 denseId=topo->detId2denseIdCALIB(hgdi);
01156 HxCalibHash2Entry.at(denseId)=HOHXEntries.size();
01157 }
01158
01159 if (ring==0){
01160 if (ipixel==1){
01161 ipixel = 2;
01162 iadc = 4;
01163 ifi_ch = 0;
01164 letter = "X";
01165 det = "HOX";
01166 HOHXLogicalMapEntry hoxlmapentry(
01167 ifi_ch, ihtr_fi, ispigot, ifed, icrate, ihtr, fpga,
01168 det, iside, ieta, iphi, idepth,
01169 idphi, isector, irm, irm_fi, ipixel, iqie, iadc,
01170 rbx, letter
01171 );
01172 HOHXEntries.push_back(hoxlmapentry);
01173 LinearIndex2Entry.at(hoxlmapentry.getLinearIndex())=HcalLogicalMap::makeEntryNumber(1,1,HOHXEntries.size()-1);
01174
01175 const HcalGenericDetId hgdi(hoxlmapentry.getDetId());
01176 unsigned int denseId;
01177 if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenOuter) {
01178 denseId=topo->detId2denseIdHO(hgdi);
01179 HoHash2Entry.at(denseId)=HOHXEntries.size();
01180 } else if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenCalibration) {
01181 denseId=topo->detId2denseIdCALIB(hgdi);
01182 HxCalibHash2Entry.at(denseId)=HOHXEntries.size();
01183 }
01184 }
01185 else if (ipixel==17){
01186 ipixel = 18;
01187 iadc = 1;
01188 ifi_ch = 1;
01189 letter = "X";
01190 det = "HOX";
01191 HOHXLogicalMapEntry hoxlmapentry(
01192 ifi_ch, ihtr_fi, ispigot, ifed, icrate, ihtr, fpga,
01193 det, iside, ieta, iphi, idepth,
01194 idphi, isector, irm, irm_fi, ipixel, iqie, iadc,
01195 rbx, letter
01196 );
01197 HOHXEntries.push_back(hoxlmapentry);
01198 LinearIndex2Entry.at(hoxlmapentry.getLinearIndex())=HcalLogicalMap::makeEntryNumber(1,1,HOHXEntries.size()-1);
01199
01200 const HcalGenericDetId hgdi(hoxlmapentry.getDetId());
01201 unsigned int denseId;
01202 if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenOuter) {
01203 denseId=topo->detId2denseIdHO(hgdi);
01204 HoHash2Entry.at(denseId)=HOHXEntries.size();
01205 } else if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenCalibration) {
01206 denseId=topo->detId2denseIdCALIB(hgdi);
01207 HxCalibHash2Entry.at(denseId)=HOHXEntries.size();
01208 }
01209 }
01210 }
01211 }
01212 }
01213 }
01214 }
01215
01216 void HcalLogicalMapGenerator::buildCALIBMap(const HcalTopology* topo,
01217 std::vector <CALIBLogicalMapEntry>& CALIBEntries,
01218 std::vector <uint32_t>& LinearIndex2Entry,
01219 std::vector <uint32_t>& HxCalibHash2Entry) {
01220
01221
01222
01223 int calibcrate_loc[NCALIBCR]={4,0,1,5,11,15,17,14,10,9,7,6,13};
01224 memcpy( calibcrate, calibcrate_loc, sizeof(int)*NCALIBCR );
01225
01226 int fedcalibnum_loc[NCALIBCR][2]={{700,701},{702,703},{704,705},{706,707},{708,709},{710,711},{712,713},{714,715},{716,717},
01227 {720,721},
01228 {726,727},{728,729},{730,731}};
01229 memcpy( fedcalibnum, fedcalibnum_loc, sizeof(int)*NCALIBCR*2 );
01230
01231 int icalibphis_loc[NCALIBCR]={3,11,19,27,35,43,51,59,67,27,17,35,53};
01232 memcpy( icalibphis, icalibphis_loc, sizeof(int)*NCALIBCR );
01233
01234 int icalibsector_min_loc[NCALIBCR]={2,4,6,8,10,12,14,16,18,1,4,7,10};
01235 memcpy( icalibsector_min, icalibsector_min_loc, sizeof(int)*NCALIBCR );
01236
01237 int icalibsector_max_loc[NCALIBCR]={3,5,7,9,11,13,15,17,1,4,6,9,12};
01238 memcpy( icalibsector_max, icalibsector_max_loc, sizeof(int)*NCALIBCR );
01239
01240 std::string detIDCALIB_loc[NCALIBCR][NTOPBOT] = {{"HB","HE"},
01241 {"HB","HE"},
01242 {"HB","HE"},
01243 {"HB","HE"},
01244 {"HB","HE"},
01245 {"HB","HE"},
01246 {"HB","HE"},
01247 {"HB","HE"},
01248 {"HB","HE"},
01249 {"HF","HF"},
01250 {"HO","HO"},
01251 {"HO","HO"},
01252 {"HO","HO"}};
01253 for (int jj = 0; jj < NCALIBCR; jj++) {
01254 for (int kk = 0; kk < NTOPBOT; kk++) {
01255 detIDCALIB[jj][kk] = detIDCALIB_loc[jj][kk];
01256 }
01257 }
01258
01259 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}};
01260 memcpy( nfbr_max, nfbr_max_loc, sizeof(int)*NCALIBCR*NTOPBOT );
01261
01262 int calibHOinfo_loc[NHOCR][NTOPBOT][NFBR][2]={
01263 {{{4,0},{5,0},{6,0},{},{6,-2},{6,-1},{6,1},{6,2}},
01264 {{4,-2},{4,-1},{4,1},{4,2},{},{},{},{}}},
01265
01266 {{{7,0},{8,0},{9,0},{},{8,-2},{8,-1},{8,1},{8,2}},
01267 {{1,0},{2,0},{3,0},{},{2,-2},{2,-1},{2,1},{2,2}}},
01268
01269 {{{10,0},{11,0},{12,0},{},{10,-2},{10,-1},{10,1},{10,2}},
01270 {{12,-2},{12,-1},{12,1},{12,2},{},{},{},{}}}
01271 };
01272 memcpy( calibHOinfo, calibHOinfo_loc, sizeof(int)*NHOCR*NTOPBOT*NFBR*2 );
01273
01274
01275
01276
01277
01278 stringstream mystream;
01279
01280 ihtr=8;
01281 idcc=1;
01282 idcc_sl=10;
01283 irm_fi = 1;
01284 det = "";
01285
01286
01287
01288 for(ic=0; ic<NHBHECR; ic++){
01289 icrate=calibcrate[ic];
01290 ifed=fedcalibnum[ic][idcc-1];
01291
01292 for(itb=0; itb<NTOPBOT; itb++){
01293
01294 for(ifb=0; ifb<nfbr_max[ic][itb]; ifb++){
01295 det = detIDCALIB[ic][itb];
01296 ihtr_fi=ifb+1;
01297 irm_fi = 1;
01298 idphi=4;
01299 if (itb==1) if(ihtr_fi%2==0) irm_fi = 2;
01300 if (det=="HE"){
01301 ispigot=13;
01302 fpga="bot";
01303 if (ihtr_fi==1||ihtr_fi==2||ihtr_fi==5||ihtr_fi==6) {
01304 iwedge = icalibsector_min[ic];
01305 }
01306 else if (ihtr_fi==3||ihtr_fi==4||ihtr_fi==7||ihtr_fi==8) {
01307 iwedge = icalibsector_max[ic];
01308 }
01309 if (ihtr_fi<5) {
01310 sidesign = 'M';
01311 S_side = '1';
01312 ieta = -1;
01313 iside=-1;
01314 }
01315 else {
01316 sidesign = 'P';
01317 S_side = '1';
01318 ieta = 1;
01319 iside=1;
01320 }
01321 }
01322 else if (det=="HB"){
01323 ispigot=12;
01324 fpga="top";
01325 (ihtr_fi%2==1) ? iwedge = icalibsector_min[ic] : iwedge = icalibsector_max[ic];
01326 if (ihtr_fi<3) {
01327 sidesign = 'M';
01328 S_side = '1';
01329 ieta = -1;
01330 iside=-1;
01331 }
01332 else {
01333 sidesign = 'P';
01334 S_side = '1';
01335 ieta = 1;
01336 iside=1;
01337 }
01338 }
01339 iphi = ((iwedge*idphi) + 71 - idphi)%72;
01340 subdet = "CALIB_"+det;
01341 sprintf (tempbuff, "%s%c%2.2i%c", det.c_str(), sidesign, iwedge,'\0');
01342 mystream<<tempbuff;
01343 rbx = mystream.str();
01344 mystream.str("");
01345
01346 for(ifc=0; ifc<NFCH; ifc++){
01347 ifi_ch=ifc;
01348 if (irm_fi==1){
01349 if (ifc==0) ich_type=0;
01350 else if (ifc==1) ich_type=1;
01351 else if (ifc==2) {
01352 if (det=="HB") ich_type=2;
01353 else if(det=="HE") ich_type=3;
01354 }
01355 }
01356 else if (irm_fi==2){
01357 if (ifc==0) ich_type=4;
01358 else if (ifc==1) ich_type=5;
01359 else if (ifc==2) ich_type=6;
01360 }
01361 CALIBLogicalMapEntry caliblmapentry(
01362 ifi_ch, ihtr_fi, ispigot, ifed, icrate, ihtr, fpga,
01363 det, ieta, iphi, ich_type,
01364 iside, idphi, rbx, iwedge, irm_fi,
01365 subdet
01366 );
01367 CALIBEntries.push_back(caliblmapentry);
01368 LinearIndex2Entry.at(caliblmapentry.getLinearIndex())=HcalLogicalMap::makeEntryNumber(1,2,CALIBEntries.size()-1);
01369
01370 const HcalGenericDetId hgdi(caliblmapentry.getDetId());
01371 const unsigned int hashedId=topo->detId2denseIdCALIB(hgdi);
01372 if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenCalibration) HxCalibHash2Entry.at(hashedId)=CALIBEntries.size();
01373 }
01374 }
01375 }
01376 }
01377
01378
01379
01380 for(itb=0; itb<NTOPBOT; itb++){
01381
01382 for(ifb=0; ifb<4; ifb++){
01383
01384 for(ifc=0; ifc<NFCH; ifc++){
01385 icrate=calibcrate[ic];
01386 det = "HF";
01387 ihtr_fi=ifb+1;
01388 ifi_ch=ifc;
01389 (ihtr_fi==1)?iphi=1:((ihtr_fi==2)?iphi=19:((ihtr_fi==3)?iphi=37:iphi=55));
01390 idphi=18;
01391 ifed=fedcalibnum[ic][idcc-1];
01392 (ifc==0)?ich_type=8:(ifc==1?ich_type=0:ich_type=1);
01393
01394 irm_fi = 1;
01395
01396
01397 iwedge=2+(ifb*3);
01398 if (itb==0){
01399 ispigot=12;
01400 fpga="top";
01401 sidesign='P';
01402 iside=1;
01403 ieta=1;
01404 }
01405 else {
01406 ispigot=13;
01407 fpga="bot";
01408 sidesign='M';
01409 iside=-1;
01410 ieta=-1;
01411 }
01412 subdet = "CALIB_"+det;
01413 sprintf (tempbuff, "%s%c%2.2i%c", det.c_str(), sidesign, iwedge,'\0');
01414 mystream<<tempbuff;
01415 rbx = mystream.str();
01416 mystream.str("");
01417 CALIBLogicalMapEntry caliblmapentry(
01418 ifi_ch, ihtr_fi, ispigot, ifed, icrate, ihtr, fpga,
01419 det, ieta, iphi, ich_type,
01420 iside, idphi, rbx, iwedge, irm_fi,
01421 subdet
01422 );
01423 CALIBEntries.push_back(caliblmapentry);
01424 LinearIndex2Entry.at(caliblmapentry.getLinearIndex())=HcalLogicalMap::makeEntryNumber(1,2,CALIBEntries.size()-1);
01425
01426 const HcalGenericDetId hgdi(caliblmapentry.getDetId());
01427 const unsigned int hashedId=topo->detId2denseIdCALIB(hgdi);
01428 if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenCalibration) HxCalibHash2Entry.at(hashedId)=CALIBEntries.size();
01429
01430 }
01431 }
01432 }
01433 ic++;
01434
01435
01436 for(ic=ic; ic<NCALIBCR; ic++){
01437 icrate=calibcrate[ic];
01438 irm_fi = 1;
01439 ifed=fedcalibnum[ic][idcc-1];
01440
01441 for(itb=0; itb<NTOPBOT; itb++){
01442 det=detIDCALIB[ic][itb];
01443
01444 for(ifb=0; ifb<nfbr_max[ic][itb]; ifb++){
01445 if (itb==1) {
01446 ispigot = 13;
01447 fpga = "bot";
01448 }
01449 else{
01450 ispigot = 12;
01451 fpga = "top";
01452 }
01453 ihtr_fi=ifb+1;
01454 iwedge=calibHOinfo[ic-10][itb][ifb][0];
01455 ieta=calibHOinfo[ic-10][itb][ifb][1];
01456 if (ieta<0) {
01457 iside=-1;
01458 sidesign='M';
01459 }
01460 else if (ieta>0){
01461 iside=1;
01462 sidesign='P';
01463 }
01464 else {
01465 iside=0;
01466 sidesign='0';
01467 }
01468 if (ieta==-2) S_side='2';
01469 else if (ieta==-1) S_side='1';
01470 else if (ieta==1) S_side='1';
01471 else if (ieta==2) S_side='2';
01472
01473 subdet ="CALIB_"+det;
01474 if (ieta==0) sprintf (tempbuff, "%s%c%2.2i%c", det.c_str(), sidesign, iwedge,'\0');
01475 else sprintf (tempbuff, "%s%c%c%2.2i%c", det.c_str(), S_side, sidesign, iwedge,'\0');
01476 mystream<<tempbuff;
01477 rbx = mystream.str();
01478 mystream.str("");
01479
01480
01481
01482
01483 int NFCH_HO;
01484
01485 ( ieta == -2 ) ? ( iwedge == 12 ? NFCH_HO = 3 : NFCH_HO = 2 ) : ( iwedge == 10) ? NFCH_HO = 3 : NFCH_HO = 2;
01486 for(ifc=0; ifc<NFCH_HO; ifc++){
01487 ifi_ch=ifc;
01488 (ifi_ch == 2) ? ich_type = 7 : ich_type = ifi_ch;
01489 (ieta==0) ? idphi = 6 : idphi = 12;
01490
01491 (ieta==0) ? iphi=((iwedge*idphi)+71-idphi)%72 : iphi=(((iwedge/2)*idphi)+71-idphi)%72;
01492
01493 do {
01494 if (iside==0&&ifb==3) break;
01495 CALIBLogicalMapEntry caliblmapentry(
01496 ifi_ch, ihtr_fi, ispigot, ifed, icrate, ihtr, fpga,
01497 det, ieta, iphi, ich_type,
01498 iside, idphi, rbx, iwedge, irm_fi,
01499 subdet
01500 );
01501 CALIBEntries.push_back(caliblmapentry);
01502 LinearIndex2Entry.at(caliblmapentry.getLinearIndex())=HcalLogicalMap::makeEntryNumber(1,2,CALIBEntries.size()-1);
01503
01504 const HcalGenericDetId hgdi(caliblmapentry.getDetId());
01505 const unsigned int hashedId=topo->detId2denseIdCALIB(hgdi);
01506 if (hgdi.genericSubdet()==HcalGenericDetId::HcalGenCalibration) HxCalibHash2Entry.at(hashedId)=CALIBEntries.size();
01507 } while (ifb!=ifb);
01508 }
01509 }
01510 }
01511 }
01512 }
01513
01514 void HcalLogicalMapGenerator::buildZDCMap(const HcalTopology* topo, std::vector <ZDCLogicalMapEntry>& ZDCEntries,
01515 std::vector <uint32_t>& LinearIndex2Entry,
01516 std::vector <uint32_t>& ZdcHash2Entry) {
01517
01518
01519
01520 stringstream mystream;
01521
01522 ifed=722;
01523 iy=1;
01524 ihtr=8;
01525 icrate=12;
01526 idcc=1;
01527 idcc_sl=10;
01528 ispigot=12;
01529
01530 for(itb=0; itb<NTOPBOT; itb++){
01531 if (itb==0) {
01532 iside = 1;
01533 irm = 1;
01534 fpga = "top";
01535 }
01536 else {
01537 iside = -1;
01538 irm = 2;
01539 if (mapIOV_<4) {
01540 fpga = "top";
01541 ispigot = 12;}
01542 else {
01543 fpga = "bot";
01544 ispigot = 13;}
01545 }
01546
01547 for(icab=1; icab<NZDCCAB+1; icab++){
01548 if (icab < 4) {
01549 irm_fi = 1;
01550 iadc = icab - 1;
01551 ifi_ch = iadc;
01552 }
01553 else if (icab < 7) {
01554 irm_fi = 2;
01555 iadc = icab - 1;
01556 ifi_ch = iadc - 3;
01557 }
01558 else {
01559 irm_fi = 3;
01560 iadc = icab - 7;
01561 ifi_ch = iadc;
01562 }
01563 if (itb==0) {
01564 ihtr_fi = irm_fi;
01565 }
01566 else {
01567 if (mapIOV_<4) ihtr_fi = irm_fi + 3;
01568 else ihtr_fi = irm_fi;
01569 }
01570 if (icab < 6) {
01571 ix = icab;
01572 idepth = 1;
01573 idx = 1;
01574 det = "ZDC_EM";
01575 idet_ch = ix;
01576 iqie = 1;
01577 }
01578 else {
01579 ix = 1;
01580 idepth = icab - 4;
01581 idx = 5;
01582 det = "ZDC_HAD";
01583 idet_ch = icab - 5;
01584 if (icab==6) iqie = 1;
01585 else iqie = 2;
01586 }
01587 ZDCLogicalMapEntry zdclmapentry(
01588 ifi_ch, ihtr_fi, ispigot, ifed, icrate, ihtr, fpga,
01589 det, iside, idepth,
01590 ix, iy, idx, idet_ch, icab, irm, iqie,
01591 iadc, irm_fi
01592 );
01593 ZDCEntries.push_back(zdclmapentry);
01594 LinearIndex2Entry.at(zdclmapentry.getLinearIndex())=HcalLogicalMap::makeEntryNumber(1,3,ZDCEntries.size()-1);
01595 }
01596 }
01597 }
01598
01599
01600
01601 void HcalLogicalMapGenerator::ConstructTriggerTower(const HcalTopology* topo,
01602 std::vector <HTLogicalMapEntry>& HTEntries,
01603 int iside, int ieta, int iphi, int idphi, int idepth, std::string det, int iwedge, int irm,
01604 int ipixel, int iqie, int iadc, int irm_fi, int ifi_ch, int icrate, int ihtr, std::string fpga,
01605 int ihtr_fi, int ispigot, int islb, std::string slbin, std::string slbin2,
01606 std::string slnam, int irctcra, int irctcar, int irctcon, std::string rctnam, int ifed
01607 )
01608 {
01609
01610 string t_chDet,t_fpga;
01611 string t_slnam,t_rctnam,t_slbin,t_slbin2;
01612
01613 int t_nDat=-1;
01614 int t_side,t_iEta,t_iPhi,t_jPhi,t_iDep,t_topbot;
01615 int t_wedge,t_crate,t_htr;
01616
01617 int t_spigo,t_slb,t_rctcra,t_rctcar,t_rctcon,t_fedid;
01618
01619
01620 (fpga=="bot") ? t_topbot = 1 : t_topbot = 0;
01621 t_side = iside;
01622 t_iEta = ieta;
01623 t_iPhi = iphi;
01624 t_jPhi = idphi;
01625 t_iDep = idepth;
01626 t_chDet = det;
01627 t_wedge = iwedge;
01628
01629
01630
01631
01632
01633
01634 t_crate = icrate;
01635 t_htr = ihtr;
01636 t_fpga = fpga;
01637
01638 t_spigo = ispigot;
01639 t_slb = islb;
01640 t_slbin = slbin;
01641 t_slbin2 = slbin2;
01642 t_slnam = slnam;
01643 t_rctcra = irctcra;
01644 t_rctcar = irctcar;
01645 t_rctcon = irctcon;
01646 t_rctnam = rctnam;
01647 t_fedid = ifed;
01648
01649 do {
01650 if(t_iDep!=1) break;
01651 if(t_chDet=="HE"&&t_iEta==29) break;
01652
01653 if(t_chDet=="HF") {
01654 t_jPhi=4;
01655 if(t_iEta==30||t_iEta==31||t_iEta==33||
01656 t_iEta==34||t_iEta==36||t_iEta==37||
01657 t_iEta==39||t_iEta==40||t_iEta==41) break;
01658
01659 else if(t_iEta==32)t_iEta=30;
01660 else if(t_iEta==35)t_iEta=31;
01661 else if(t_iEta==38)t_iEta=32;
01662
01663 if(t_iPhi==3||t_iPhi==7||t_iPhi==11||t_iPhi==15||t_iPhi==19||
01664 t_iPhi==23||t_iPhi==27||t_iPhi==31||t_iPhi==35||t_iPhi==39||
01665 t_iPhi==43||t_iPhi==47||t_iPhi==51||t_iPhi==55||t_iPhi==59||
01666 t_iPhi==63||t_iPhi==67||t_iPhi==71) break;
01667 }
01668
01669 if(t_side<0) t_iEta=-t_iEta;
01670 t_chDet="HT";
01671
01672 if(t_slbin!="NA") {
01673 if(t_slbin2!="NA") t_jPhi=1;
01674 if(t_slbin=="A0"||t_slbin=="B0") t_nDat=0;
01675 else if(t_slbin=="A1"||t_slbin=="B1") t_nDat=1;
01676 else if(t_slbin=="C0"||t_slbin=="D0") t_nDat=2;
01677 else if(t_slbin=="C1"||t_slbin=="D1") t_nDat=3;
01678
01679 HTLogicalMapEntry htlmapentry(
01680 t_iEta, t_iPhi,
01681 t_side, t_jPhi, t_iDep, t_chDet, t_wedge, t_crate, t_htr, t_topbot,
01682 t_spigo, t_slb, t_slbin, t_slbin2, t_nDat,
01683 t_slnam, t_rctcra, t_rctcar, t_rctcon, t_rctnam, t_fedid
01684 );
01685 HTEntries.push_back(htlmapentry);
01686 }
01687 if(t_slbin2!="NA") {
01688 if(t_slbin2=="A0"||t_slbin2=="B0") t_nDat=0;
01689 else if(t_slbin2=="A1"||t_slbin2=="B1") t_nDat=1;
01690 else if(t_slbin2=="C0"||t_slbin2=="D0") t_nDat=2;
01691 else if(t_slbin2=="C1"||t_slbin2=="D1") t_nDat=3;
01692 t_jPhi=1;
01693 t_iPhi+=1;
01694
01695 HTLogicalMapEntry htlmapentry(
01696 t_iEta, t_iPhi,
01697 t_side, t_jPhi, t_iDep, t_chDet, t_wedge, t_crate, t_htr, t_topbot,
01698 t_spigo, t_slb, t_slbin, t_slbin2, t_nDat,
01699 t_slnam, t_rctcra, t_rctcar, t_rctcon, t_rctnam, t_fedid
01700 );
01701 HTEntries.push_back(htlmapentry);
01702 }
01703 } while(1!=1);
01704 }