File indexing completed on 2024-04-06 11:58:07
0001 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0002 #include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
0003 #include "DataFormats/HcalDetId/interface/HcalOtherDetId.h"
0004 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
0005 #include "Geometry/CaloTopology/interface/HcalTopology.h"
0006 #include "CalibCalorimetry/HcalAlgos/interface/HcalLogicalMapGenerator.h"
0007
0008 #include <string>
0009 #include <sstream>
0010 #include <cstdio>
0011 #include <iostream>
0012 #include <cstring>
0013
0014 using namespace std;
0015
0016
0017
0018 HcalLogicalMapGenerator::HcalLogicalMapGenerator() {
0019
0020
0021
0022 for (i = 0; i < NRMFIBR; i++) {
0023 for (j = 0; j < NFCH; j++) {
0024
0025 iadcquiHBHE[i][j][0] = i / 2 + 1;
0026
0027 if (i % 2 == 0)
0028 iadcquiHBHE[i][j][1] = j;
0029 else
0030 iadcquiHBHE[i][j][1] = NFCH + (j + 1) % 3;
0031 }
0032 }
0033 }
0034
0035 HcalLogicalMapGenerator::~HcalLogicalMapGenerator() {}
0036
0037 HcalLogicalMap HcalLogicalMapGenerator::createMap(const HcalTopology* topo, unsigned int mapIOV) {
0038 mapIOV_ = mapIOV;
0039
0040 std::vector<HBHEHFLogicalMapEntry> HBHEHFEntries;
0041 std::vector<HOHXLogicalMapEntry> HOHXEntries;
0042 std::vector<CALIBLogicalMapEntry> CALIBEntries;
0043 std::vector<ZDCLogicalMapEntry> ZDCEntries;
0044 std::vector<HTLogicalMapEntry> HTEntries;
0045 std::vector<uint32_t> LinearIndex2Entry;
0046 std::vector<uint32_t> HbHash2Entry;
0047 std::vector<uint32_t> HeHash2Entry;
0048 std::vector<uint32_t> HfHash2Entry;
0049 std::vector<uint32_t> HtHash2Entry;
0050 std::vector<uint32_t> HoHash2Entry;
0051 std::vector<uint32_t> HxCalibHash2Entry;
0052
0053 std::vector<uint32_t> ZdcHash2Entry;
0054
0055 int HbHalf = 1296;
0056 int HeHalf = 1296;
0057
0058 int HoHalf = 1080;
0059 int HfHalf = 864;
0060 int HtHalf = 2088;
0061 int ZdcHalf = 11;
0062 int CalibFull = 216 + 425 + 8;
0063
0064 uint32_t illegal_value = 0;
0065 for (int i = 0; i <= HcalElectronicsId::maxLinearIndex; i++)
0066 LinearIndex2Entry.push_back(illegal_value);
0067 HbHash2Entry.reserve(2 * HbHalf);
0068 for (int iHb = 0; iHb < 2 * HbHalf; iHb++)
0069 HbHash2Entry.push_back(illegal_value);
0070 HeHash2Entry.reserve(2 * HeHalf);
0071 for (int iHe = 0; iHe < 2 * HeHalf; iHe++)
0072 HeHash2Entry.push_back(illegal_value);
0073 HfHash2Entry.reserve(2 * HfHalf);
0074 for (int iHf = 0; iHf < 2 * HfHalf; iHf++)
0075 HfHash2Entry.push_back(illegal_value);
0076 HtHash2Entry.reserve(2 * HtHalf);
0077 for (int iHt = 0; iHt < 2 * HtHalf; iHt++)
0078 HtHash2Entry.push_back(illegal_value);
0079 HoHash2Entry.reserve(2 * HoHalf);
0080 for (int iHo = 0; iHo < 2 * HoHalf; iHo++)
0081 HoHash2Entry.push_back(illegal_value);
0082 HxCalibHash2Entry.reserve(CalibFull);
0083 for (int iHcalib = 0; iHcalib < CalibFull; iHcalib++)
0084 HxCalibHash2Entry.push_back(illegal_value);
0085 ZdcHash2Entry.reserve(2 * ZdcHalf);
0086 for (int iZdc = 0; iZdc < 2 * ZdcHalf; iZdc++)
0087 ZdcHash2Entry.push_back(illegal_value);
0088
0089 buildHBEFTMap(
0090 topo, HBHEHFEntries, HTEntries, LinearIndex2Entry, HbHash2Entry, HeHash2Entry, HfHash2Entry, HtHash2Entry);
0091 buildHOXMap(topo, HOHXEntries, LinearIndex2Entry, HoHash2Entry, HxCalibHash2Entry);
0092 buildCALIBMap(topo, CALIBEntries, LinearIndex2Entry, HxCalibHash2Entry);
0093 buildZDCMap(topo, ZDCEntries, LinearIndex2Entry, ZdcHash2Entry);
0094
0095 return HcalLogicalMap(topo,
0096 HBHEHFEntries,
0097 HOHXEntries,
0098 CALIBEntries,
0099 ZDCEntries,
0100 HTEntries,
0101 LinearIndex2Entry,
0102 HbHash2Entry,
0103 HeHash2Entry,
0104 HfHash2Entry,
0105 HtHash2Entry,
0106 HoHash2Entry,
0107 HxCalibHash2Entry,
0108 ZdcHash2Entry);
0109 }
0110
0111 void HcalLogicalMapGenerator::buildHBEFTMap(const HcalTopology* topo,
0112 std::vector<HBHEHFLogicalMapEntry>& HBHEHFEntries,
0113 std::vector<HTLogicalMapEntry>& HTEntries,
0114 std::vector<uint32_t>& LinearIndex2Entry,
0115 std::vector<uint32_t>& HbHash2Entry,
0116 std::vector<uint32_t>& HeHash2Entry,
0117 std::vector<uint32_t>& HfHash2Entry,
0118 std::vector<uint32_t>& HtHash2Entry) {
0119
0120
0121 int hbhecrate_loc[NHBHECR] = {0, 1, 4, 5, 10, 11, 14, 15, 17};
0122 memcpy(hbhecrate, hbhecrate_loc, sizeof(int) * NHBHECR);
0123
0124 int fedhbhenum_loc[NHBHECR][2] = {
0125 {702, 703}, {704, 705}, {700, 701}, {706, 707}, {716, 717}, {708, 709}, {714, 715}, {710, 711}, {712, 713}};
0126 memcpy(fedhbhenum, fedhbhenum_loc, sizeof(int) * NHBHECR * 2);
0127
0128 int ihslot_loc[NHSETS] = {2, 5, 13, 16};
0129 memcpy(ihslot, ihslot_loc, sizeof(int) * NHSETS);
0130
0131 int ihbhephis_loc[NHBHECR] = {11, 19, 3, 27, 67, 35, 59, 43, 51};
0132 memcpy(ihbhephis, ihbhephis_loc, sizeof(int) * NHBHECR);
0133
0134 int ihbheetadepth_loc[NHTRS][NTOPBOT][NFBR][NFCH][2] = {{{{{11, 1}, {7, 1}, {3, 1}},
0135 {{5, 1}, {1, 1}, {9, 1}},
0136 {{11, 1}, {7, 1}, {3, 1}},
0137 {{5, 1}, {1, 1}, {9, 1}},
0138 {{10, 1}, {6, 1}, {2, 1}},
0139 {{8, 1}, {4, 1}, {12, 1}},
0140 {{10, 1}, {6, 1}, {2, 1}},
0141 {{8, 1}, {4, 1}, {12, 1}}},
0142 {{{11, 1}, {7, 1}, {3, 1}},
0143 {{5, 1}, {1, 1}, {9, 1}},
0144 {{11, 1}, {7, 1}, {3, 1}},
0145 {{5, 1}, {1, 1}, {9, 1}},
0146 {{10, 1}, {6, 1}, {2, 1}},
0147 {{8, 1}, {4, 1}, {12, 1}},
0148 {{10, 1}, {6, 1}, {2, 1}},
0149 {{8, 1}, {4, 1}, {12, 1}}}},
0150 {{{{16, 2}, {15, 2}, {14, 1}},
0151 {{15, 1}, {13, 1}, {16, 1}},
0152 {{16, 2}, {15, 2}, {14, 1}},
0153 {{15, 1}, {13, 1}, {16, 1}},
0154 {{17, 1}, {16, 3}, {26, 1}},
0155 {{18, 1}, {18, 2}, {26, 2}},
0156 {{17, 1}, {16, 3}, {25, 1}},
0157 {{18, 1}, {18, 2}, {25, 2}}},
0158 {{{16, 2}, {15, 2}, {14, 1}},
0159 {{15, 1}, {13, 1}, {16, 1}},
0160 {{16, 2}, {15, 2}, {14, 1}},
0161 {{15, 1}, {13, 1}, {16, 1}},
0162 {{17, 1}, {16, 3}, {25, 1}},
0163 {{18, 1}, {18, 2}, {25, 2}},
0164 {{17, 1}, {16, 3}, {26, 1}},
0165 {{18, 1}, {18, 2}, {26, 2}}}},
0166 {{{{28, 1}, {28, 2}, {29, 1}},
0167 {{28, 3}, {24, 2}, {24, 1}},
0168 {{27, 1}, {27, 2}, {29, 2}},
0169 {{27, 3}, {23, 2}, {23, 1}},
0170 {{19, 2}, {20, 1}, {22, 2}},
0171 {{19, 1}, {20, 2}, {22, 1}},
0172 {{19, 2}, {20, 1}, {21, 2}},
0173 {{19, 1}, {20, 2}, {21, 1}}},
0174 {{{27, 1}, {27, 2}, {29, 2}},
0175 {{27, 3}, {23, 2}, {23, 1}},
0176 {{28, 1}, {28, 2}, {29, 1}},
0177 {{28, 3}, {24, 2}, {24, 1}},
0178 {{19, 2}, {20, 1}, {21, 2}},
0179 {{19, 1}, {20, 2}, {21, 1}},
0180 {{19, 2}, {20, 1}, {22, 2}},
0181 {{19, 1}, {20, 2}, {22, 1}}}}};
0182 memcpy(ihbheetadepth, ihbheetadepth_loc, sizeof(int) * NHTRS * NTOPBOT * NFBR * NFCH * 2);
0183
0184
0185
0186 int irm_rmfiHBHE_loc[NHTRS][NTOPBOT][NFBR][2] = {
0187 {{{6, 1}, {7, 1}, {6, 2}, {7, 2}, {4, 1}, {5, 1}, {4, 2}, {5, 2}},
0188 {{6, 3}, {7, 3}, {6, 4}, {7, 4}, {4, 3}, {5, 3}, {4, 4}, {5, 4}}},
0189 {{{2, 1}, {3, 1}, {2, 2}, {3, 2}, {2, 1}, {3, 1}, {2, 2}, {3, 2}},
0190 {{2, 3}, {3, 3}, {2, 4}, {3, 4}, {2, 3}, {3, 3}, {2, 4}, {3, 4}}},
0191 {{{4, 1}, {5, 1}, {4, 2}, {5, 2}, {6, 1}, {7, 1}, {6, 2}, {7, 2}},
0192 {{4, 3}, {5, 3}, {4, 4}, {5, 4}, {6, 3}, {7, 3}, {6, 4}, {7, 4}}}
0193 };
0194 memcpy(irm_rmfiHBHE, irm_rmfiHBHE_loc, sizeof(int) * NHTRS * NTOPBOT * NFBR * 2);
0195
0196
0197 int ipixelHB_loc[NRMFIBR][NFCH][NRMSLOT] = {
0198
0199 {{18, 17, 3, 2}, {13, 3, 17, 7}, {14, 1, 19, 6}},
0200 {{19, 2, 18, 1}, {15, 7, 13, 5}, {17, 19, 1, 3}},
0201 {{9, 4, 16, 11}, {5, 8, 12, 15}, {2, 13, 7, 18}},
0202 {{12, 11, 9, 8}, {7, 15, 5, 13}, {16, 6, 14, 4}},
0203 {{8, 5, 15, 12}, {4, 9, 11, 16}, {1, 14, 6, 19}},
0204 {{6, 16, 4, 14}, {3, 18, 2, 17}, {11, 12, 8, 9}}
0205 };
0206 memcpy(ipixelHB, ipixelHB_loc, sizeof(int) * NRMFIBR * NFCH * NRMSLOT);
0207
0208 int ipixelHE_loc[NRMFIBR][NFCH][NRMSLOT] = {
0209
0210 {{12, 12, 12, 12}, {16, 7, 16, 7}, {7, 16, 7, 16}},
0211 {{11, 11, 11, 11}, {19, 3, 19, 3}, {3, 19, 3, 19}},
0212 {{15, 15, 6, 6}, {2, 18, 2, 18}, {6, 6, 15, 15}},
0213 {{5, 14, 5, 14}, {14, 5, 14, 5}, {18, 2, 18, 2}},
0214 {{17, 1, 17, 1}, {9, 9, 9, 9}, {1, 17, 1, 17}},
0215 {{13, 4, 13, 4}, {8, 8, 8, 8}, {4, 13, 4, 13}}
0216 };
0217 memcpy(ipixelHE, ipixelHE_loc, sizeof(int) * NRMFIBR * NFCH * NRMSLOT);
0218
0219
0220
0221
0222
0223 const char* S_slbin_odd_loc[] = {"A1", "B0", "B1", "A0", "A1", "B0", "B1", "A0"};
0224 for (int gg = 0; gg < 8; gg++) {
0225 S_slbin_odd[gg] = S_slbin_odd_loc[gg];
0226 }
0227 const char* S_slbin_even_loc[] = {"C1", "D0", "D1", "C0", "C1", "D0", "D1", "C0"};
0228 for (int gg = 0; gg < 8; gg++) {
0229 S_slbin_even[gg] = S_slbin_even_loc[gg];
0230 }
0231 const char* rct_rackHBHE_loc[] = {"S2E01-RH",
0232 "S2E03-RH",
0233 "S2E05-RH",
0234 "S2E07-RH",
0235 "S2E09-RH",
0236 "S2E08-RL",
0237 "S2E06-RL",
0238 "S2E04-RL",
0239 "S2E02-RL",
0240 "S2E02-RH",
0241 "S2E04-RH",
0242 "S2E06-RH",
0243 "S2E08-RH",
0244 "S2E09-RL",
0245 "S2E07-RL",
0246 "S2E05-RL",
0247 "S2E03-RL",
0248 "S2E01-RL"};
0249 for (int gg = 0; gg < 18; gg++) {
0250 rct_rackHBHE[gg] = rct_rackHBHE_loc[gg];
0251 }
0252
0253 int slb_table_loc[29] = {1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
0254 1, 1, 2, 2, 3, 3, 1, 1,
0255 2, 2, 3, 3, 4, 4, 4, 4, 4};
0256 memcpy(slb_table, slb_table_loc, sizeof(int) * 29);
0257
0258
0259 char tempbuff[30]{0};
0260
0261
0262 stringstream mystream;
0263
0264
0265 for (ic = 0; ic < NHBHECR; ic++) {
0266
0267 for (is = 0; is < NHSETS; is++) {
0268
0269 for (ih = 0; ih < NHTRS; ih++) {
0270
0271 for (itb = 0; itb < NTOPBOT; itb++) {
0272
0273 for (ifb = 0; ifb < NFBR; ifb++) {
0274
0275 for (ifc = 0; ifc < NFCH; ifc++) {
0276 icrate = hbhecrate[ic];
0277 iside = is < NHSETS / 2 ? -1 : 1;
0278 ifwtb = (is / 2 + itb + 1) % 2;
0279 ieta = ihbheetadepth[ih][ifwtb][ifb][ifc][0];
0280 idepth = ihbheetadepth[ih][ifwtb][ifb][ifc][1];
0281 ihtr = ihslot[is] + ih;
0282 (ieta > 16 || idepth > 2) ? det = "HE" : det = "HB";
0283 (itb % 2) == 1 ? fpga = "bot" : fpga = "top";
0284 ihtr_fi = ifb + 1;
0285 ifi_ch = ifc;
0286 iphi = (ieta > 20) ? (ihbhephis[ic] + (is % 2) * 4 + itb * 2 - 1) % 72 + 1
0287 : (ihbhephis[ic] + (is % 2) * 4 + itb * 2 + (ifb / 2 + is / 2 + 1) % 2 - 1) % 72 + 1;
0288 ispigot = (is % 2) * 6 + ih * 2 + itb;
0289 idcc = is < NHSETS / 2 ? 1 : 2;
0290 idcc_sl = idcc == 1 ? 10 : 20;
0291 ifed = fedhbhenum[ic][idcc - 1];
0292
0293
0294
0295
0296 if (iside == -1) {
0297 S_side = '-';
0298 sidesign = 'M';
0299 irm = irm_rmfiHBHE[ih][(itb + 1) % 2][ifb][1];
0300 irm_fi = irm_rmfiHBHE[ih][(itb + 1) % 2][ifb][0];
0301
0302
0303 if (ieta >= 21 && (irm == 1 || irm == 3))
0304 iwedge = (iphi + 1 + irm + 1) / 4;
0305 else
0306 iwedge = (iphi + irm + 1) / 4;
0307
0308
0309 if (iwedge > 18)
0310 iwedge -= 18;
0311 } else {
0312 S_side = '+';
0313 sidesign = 'P';
0314 irm = irm_rmfiHBHE[ih][itb][ifb][1];
0315 irm_fi = irm_rmfiHBHE[ih][itb][ifb][0];
0316
0317
0318 if (ieta >= 21 && (irm == 4 || irm == 2))
0319 iwedge = (iphi + 1 - irm + 6) / 4;
0320 else
0321 iwedge = (iphi - irm + 6) / 4;
0322
0323
0324 if (iwedge > 18)
0325 iwedge -= 18;
0326 }
0327
0328 snprintf(tempbuff, sizeof tempbuff, "%s%c%2.2i", det.c_str(), sidesign, iwedge);
0329 mystream << tempbuff;
0330 rbx = mystream.str();
0331 mystream.str("");
0332
0333
0334
0335
0336
0337 if (ieta > 16 || idepth > 2)
0338 ipixel = ipixelHE[irm_fi - 2][ifc][irm - 1];
0339 else
0340 ipixel = ipixelHB[irm_fi - 2][ifc][irm - 1];
0341
0342 iqie = iadcquiHBHE[irm_fi - 2][ifc][0];
0343 iadc = iadcquiHBHE[irm_fi - 2][ifc][1];
0344
0345 phideg = iphi - 3;
0346 if (phideg < 0)
0347 phideg = phideg + 72;
0348 phideg = (phideg / 4) * 20 + 10;
0349 irctcra = ((89 - phideg + 720) % 360) / 20;
0350 oddcard = irctcra % 2;
0351 irctcra /= 2;
0352 if (iside > 0)
0353 irctcra = irctcra + 9;
0354
0355 etaslb = ((ieta - 1) / 2) * 2 + 1;
0356 if (etaslb > 27)
0357 etaslb = 27;
0358
0359 snprintf(tempbuff, sizeof tempbuff, "SLB_H_%3.3d%c%2.2d", phideg, S_side, etaslb);
0360 mystream << tempbuff;
0361 slnam = mystream.str();
0362 mystream.str("");
0363
0364 islb = slb_table[ieta - 1];
0365
0366
0367 if (ieta <= 24) {
0368 irctcar = 2 * ((ieta - 1) / 8) + oddcard;
0369 irctcon = 2 * (((ieta - 1) / 2) % 4);
0370 } else {
0371 irctcar = 6;
0372 eta2 = ieta;
0373 if (eta2 > 28)
0374 eta2 = 28;
0375 if (oddcard == 0)
0376 eta3 = eta2;
0377 else
0378 eta3 = 57 - eta2;
0379 irctcon = 2 * (((eta3 - 1) / 2) % 4);
0380 }
0381 irctcon = 11 * irctcon + 1;
0382
0383 snprintf(tempbuff, sizeof tempbuff, "%s-%1d-HD%2.2d", rct_rackHBHE[irctcra], irctcar, irctcon);
0384 mystream << tempbuff;
0385 rctnam = mystream.str();
0386 mystream.str("");
0387
0388
0389
0390 phimod8 = iphi % 8;
0391
0392 for (i = 0; i < 18; i++) {
0393 if (iphi < i * 4 + 3) {
0394 crazy = i % 2;
0395 break;
0396 }
0397 }
0398
0399 int ietamod;
0400 if (ieta == 29)
0401 ietamod = 0;
0402 else
0403 ietamod = ieta % 2;
0404 if (ieta < 25) {
0405 if (ietamod == 1)
0406 mystream << S_slbin_odd[phimod8];
0407 else
0408 mystream << S_slbin_even[phimod8];
0409 } else if (crazy == 0) {
0410 if (ietamod == 1)
0411 mystream << S_slbin_odd[phimod8];
0412 else
0413 mystream << S_slbin_even[phimod8];
0414 } else {
0415 if (ietamod == 1)
0416 mystream << S_slbin_even[phimod8];
0417 else
0418 mystream << S_slbin_odd[phimod8];
0419 }
0420
0421 slbin = mystream.str();
0422 mystream.str("");
0423
0424 if (ieta > 20) {
0425 idphi = 2;
0426 slbin2 = slbin;
0427 slbin2[1] = '1';
0428 } else {
0429 idphi = 1;
0430 slbin2 = "NA";
0431 }
0432
0433 HBHEHFLogicalMapEntry hbeflmapentry(ifi_ch,
0434 ihtr_fi,
0435 ispigot,
0436 ifed,
0437 icrate,
0438 ihtr,
0439 fpga,
0440 det,
0441 iside,
0442 ieta,
0443 iphi,
0444 idepth,
0445 idphi,
0446 iwedge,
0447 irm,
0448 irm_fi,
0449 ipixel,
0450 iqie,
0451 iadc,
0452 islb,
0453 irctcra,
0454 irctcar,
0455 irctcon,
0456 rbx,
0457 slbin,
0458 slbin2,
0459 slnam,
0460 rctnam);
0461 HBHEHFEntries.push_back(hbeflmapentry);
0462 LinearIndex2Entry.at(hbeflmapentry.getLinearIndex()) =
0463 HcalLogicalMap::makeEntryNumber(true, 0, HBHEHFEntries.size() - 1);
0464
0465 const HcalGenericDetId hgdi(hbeflmapentry.getDetId());
0466 unsigned int denseId;
0467 if (hgdi.genericSubdet() == HcalGenericDetId::HcalGenBarrel) {
0468 denseId = topo->detId2denseIdHB(hgdi);
0469 HbHash2Entry.at(denseId) = HBHEHFEntries.size();
0470 }
0471 if (hgdi.genericSubdet() == HcalGenericDetId::HcalGenEndcap) {
0472 denseId = topo->detId2denseIdHE(hgdi);
0473 HeHash2Entry.at(denseId) = HBHEHFEntries.size();
0474 }
0475 if (hgdi.genericSubdet() == HcalGenericDetId::HcalGenForward) {
0476 denseId = topo->detId2denseIdHF(hgdi);
0477 HfHash2Entry.at(denseId) = HBHEHFEntries.size();
0478 }
0479
0480 ConstructTriggerTower(topo,
0481 HTEntries,
0482 iside,
0483 ieta,
0484 iphi,
0485 idphi,
0486 idepth,
0487 det,
0488 iwedge,
0489 irm,
0490 ipixel,
0491 iqie,
0492 iadc,
0493 irm_fi,
0494 ifi_ch,
0495 icrate,
0496 ihtr,
0497 fpga,
0498 ihtr_fi,
0499 ispigot,
0500 islb,
0501 slbin,
0502 slbin2,
0503 slnam,
0504 irctcra,
0505 irctcar,
0506 irctcon,
0507 rctnam,
0508 ifed);
0509 }
0510 }
0511 }
0512 }
0513 }
0514 }
0515
0516
0517
0518 int hfcrate_loc[NHFCR] = {2, 9, 12};
0519 memcpy(hfcrate, hfcrate_loc, sizeof(int) * NHFCR);
0520
0521 int fedhfnum_loc[NHFCR][2] = {{718, 719}, {720, 721}, {722, 723}};
0522 memcpy(fedhfnum, fedhfnum_loc, sizeof(int) * NHFCR * 2);
0523
0524 int ihfphis_loc[NHFCR] = {3, 27, 51};
0525 memcpy(ihfphis, ihfphis_loc, sizeof(int) * NHFCR);
0526
0527 int ihfetadepth_loc[NTOPBOT][NFBR][NFCH][2] = {{{{33, 1}, {31, 1}, {29, 1}},
0528 {{32, 1}, {30, 1}, {34, 1}},
0529 {{33, 2}, {31, 2}, {29, 2}},
0530 {{32, 2}, {30, 2}, {34, 2}},
0531 {{34, 2}, {32, 2}, {30, 2}},
0532 {{31, 2}, {29, 2}, {33, 2}},
0533 {{34, 1}, {32, 1}, {30, 1}},
0534 {{31, 1}, {29, 1}, {33, 1}}},
0535 {{{41, 1}, {37, 1}, {35, 1}},
0536 {{38, 1}, {36, 1}, {39, 1}},
0537 {{41, 2}, {37, 2}, {35, 2}},
0538 {{38, 2}, {36, 2}, {39, 2}},
0539 {{40, 2}, {38, 2}, {36, 2}},
0540 {{37, 2}, {35, 2}, {39, 2}},
0541 {{40, 1}, {38, 1}, {36, 1}},
0542 {{37, 1}, {35, 1}, {39, 1}}}};
0543 memcpy(ihfetadepth, ihfetadepth_loc, sizeof(int) * NTOPBOT * NFBR * NFCH * 2);
0544
0545 int irm_rmfiHF_loc[NHTRS][NTOPBOT][NFBR][2] = {
0546 {{{1, 2}, {2, 2}, {3, 2}, {4, 2}, {1, 3}, {2, 3}, {3, 3}, {4, 3}},
0547 {{5, 2}, {6, 2}, {7, 2}, {8, 2}, {5, 3}, {6, 3}, {7, 3}, {8, 3}}},
0548 {{{1, 1}, {2, 1}, {3, 1}, {4, 1}, {1, 2}, {2, 2}, {3, 2}, {4, 2}},
0549 {{5, 1}, {6, 1}, {7, 1}, {8, 1}, {5, 2}, {6, 2}, {7, 2}, {8, 2}}},
0550 {{{1, 3}, {2, 3}, {3, 3}, {4, 3}, {1, 1}, {2, 1}, {3, 1}, {4, 1}},
0551 {{5, 3}, {6, 3}, {7, 3}, {8, 3}, {5, 1}, {6, 1}, {7, 1}, {8, 1}}}
0552 };
0553 memcpy(irm_rmfiHF, irm_rmfiHF_loc, sizeof(int) * NHTRS * NTOPBOT * NFBR * 2);
0554
0555
0556 const char* S_slbin_7_loc[] = {"A0", "A1", "B0", "B1"};
0557 for (int gg = 0; gg < 4; gg++) {
0558 S_slbin_7[gg] = S_slbin_7_loc[gg];
0559 }
0560 const char* S_slbin_3_loc[] = {"C0", "C1", "D0", "D1"};
0561 for (int gg = 0; gg < 4; gg++) {
0562 S_slbin_3[gg] = S_slbin_3_loc[gg];
0563 }
0564 const char* rct_rackHF_loc[] = {"S2E01-FH",
0565 "S2E03-FH",
0566 "S2E05-FH",
0567 "S2E07-FH",
0568 "S2E09-FH",
0569 "S2E08-FL",
0570 "S2E06-FL",
0571 "S2E04-FL",
0572 "S2E02-FL",
0573 "S2E02-FH",
0574 "S2E04-FH",
0575 "S2E06-FH",
0576 "S2E08-FH",
0577 "S2E09-FL",
0578 "S2E07-FL",
0579 "S2E05-FL",
0580 "S2E03-FL",
0581 "S2E01-FL"};
0582 for (int gg = 0; gg < 18; gg++) {
0583 rct_rackHF[gg] = rct_rackHF_loc[gg];
0584 }
0585
0586
0587
0588
0589 for (ic = 0; ic < NHFCR; ic++) {
0590
0591 for (is = 0; is < NHSETS; is++) {
0592
0593 for (ih = 0; ih < NHTRS; ih++) {
0594
0595 for (itb = 0; itb < NTOPBOT; itb++) {
0596
0597 for (ifb = 0; ifb < NFBR; ifb++) {
0598
0599 for (ifc = 0; ifc < NFCH; ifc++) {
0600 icrate = hfcrate[ic];
0601 iside = is < NHSETS / 2 ? -1 : 1;
0602 ieta = ihfetadepth[itb][ifb][ifc][0];
0603 idepth = ihfetadepth[itb][ifb][ifc][1];
0604 ihtr = ihslot[is] + ih;
0605 det = "HF";
0606 (itb % 2) == 1 ? fpga = "bot" : fpga = "top";
0607 ihtr_fi = ifb + 1;
0608 ifi_ch = ifc;
0609 iphi = (ieta > 39) ? (ihfphis[ic] + (is % 2) * 12 + ih * 4 - 1) % 72 + 1
0610 : (ihfphis[ic] + (is % 2) * 12 + ih * 4 + (ifb / 4) * 2 - 1) % 72 + 1;
0611 ispigot = (is % 2) * 6 + ih * 2 + itb;
0612 idcc = is < NHSETS / 2 ? 1 : 2;
0613 idcc_sl = idcc == 1 ? 10 : 20;
0614 ifed = fedhfnum[ic][idcc - 1];
0615
0616 irm_fi = irm_rmfiHF[ih][itb][ifb][0];
0617
0618
0619 if (iside == -1) {
0620 S_side = '-';
0621 sidesign = 'M';
0622
0623 if (ieta < 40) {
0624 if (iphi == 1)
0625 iphi = 71;
0626 else if (iphi == 71)
0627 iphi = 1;
0628 else if (iphi % 4 == 1)
0629 iphi -= 2;
0630 else if (iphi % 4 == 3)
0631 iphi += 2;
0632 else
0633 edm::LogInfo("HcalLogicalMapGenerator") << "Even iphi in HFM" << endl;
0634 }
0635 } else {
0636 S_side = '+';
0637 sidesign = 'P';
0638 }
0639
0640
0641 if ((iside == 1 && ieta == 40) || (iside == -1 && ieta == 41)) {
0642 irm = ((iphi + 1) / 2) % 36 + 1;
0643 hfphi = ((iphi + 1) / 6) % 12 + 1;
0644 } else {
0645 irm = (iphi + 1) / 2;
0646 hfphi = (iphi - 1) / 6 + 1;
0647 }
0648 irm = (irm - 1) % 3 + 1;
0649
0650
0651 if (iphi >= 71)
0652 iwedge = 1;
0653 else
0654 iwedge = (iphi + 1) / 4 + 1;
0655
0656
0657 snprintf(tempbuff, sizeof tempbuff, "%s%c%2.2i", det.c_str(), sidesign, hfphi);
0658 mystream << tempbuff;
0659 rbx = mystream.str();
0660 mystream.str("");
0661
0662
0663 ipixel = 0;
0664
0665
0666 iqie = (irm_fi - 1) / 2 + 1;
0667
0668 if (irm_fi % 2 != 0)
0669 iadc = ifi_ch;
0670 else
0671 iadc = NFCH + (ifi_ch + 1) % 3;
0672
0673
0674
0675 phideg = iphi - 3;
0676 if (phideg < 0)
0677 phideg = phideg + 72;
0678 phideg = (phideg / 4) * 20 + 10;
0679 irctcra = ((89 - phideg + 720) % 360) / 40;
0680 if (iside > 0)
0681 irctcra = irctcra + 9;
0682
0683
0684 irctcar = 99;
0685 irctcon = 0;
0686
0687 etaslb = 29;
0688
0689 snprintf(tempbuff, sizeof tempbuff, "SLB_H_%3.3d%c%2.2d", phideg, S_side, etaslb);
0690 mystream << tempbuff;
0691 slnam = mystream.str();
0692 mystream.str("");
0693
0694 snprintf(tempbuff, sizeof tempbuff, "%s-JSC-HF_IN", rct_rackHF[irctcra]);
0695 mystream << tempbuff;
0696 rctnam = mystream.str();
0697 mystream.str("");
0698
0699 islb = 6;
0700
0701 int phibin = (iphi + 1) % 8;
0702 int etabin = (ieta - 29) / 3;
0703 if (etabin < 0)
0704 etabin = 0;
0705 if (etabin > 3)
0706 etabin = 3;
0707 if (phibin < 4)
0708 mystream << S_slbin_7[etabin];
0709 else
0710 mystream << S_slbin_3[etabin];
0711
0712 slbin = mystream.str();
0713 mystream.str("");
0714
0715 slbin2 = "NA";
0716
0717 if (ieta < 40)
0718 idphi = 2;
0719 else
0720 idphi = 4;
0721
0722 HBHEHFLogicalMapEntry hbeflmapentry(ifi_ch,
0723 ihtr_fi,
0724 ispigot,
0725 ifed,
0726 icrate,
0727 ihtr,
0728 fpga,
0729 det,
0730 iside,
0731 ieta,
0732 iphi,
0733 idepth,
0734 idphi,
0735 iwedge,
0736 irm,
0737 irm_fi,
0738 ipixel,
0739 iqie,
0740 iadc,
0741 islb,
0742 irctcra,
0743 irctcar,
0744 irctcon,
0745 rbx,
0746 slbin,
0747 slbin2,
0748 slnam,
0749 rctnam);
0750 HBHEHFEntries.push_back(hbeflmapentry);
0751 LinearIndex2Entry.at(hbeflmapentry.getLinearIndex()) =
0752 HcalLogicalMap::makeEntryNumber(true, 0, HBHEHFEntries.size() - 1);
0753
0754 const HcalGenericDetId hgdi(hbeflmapentry.getDetId());
0755 unsigned int denseId;
0756 if (hgdi.genericSubdet() == HcalGenericDetId::HcalGenBarrel) {
0757 denseId = topo->detId2denseIdHB(hgdi);
0758 HbHash2Entry.at(denseId) = HBHEHFEntries.size();
0759 }
0760 if (hgdi.genericSubdet() == HcalGenericDetId::HcalGenEndcap) {
0761 denseId = topo->detId2denseIdHE(hgdi);
0762 HeHash2Entry.at(denseId) = HBHEHFEntries.size();
0763 }
0764 if (hgdi.genericSubdet() == HcalGenericDetId::HcalGenForward) {
0765 denseId = topo->detId2denseIdHF(hgdi);
0766 HfHash2Entry.at(denseId) = HBHEHFEntries.size();
0767 }
0768
0769 ConstructTriggerTower(topo,
0770 HTEntries,
0771 iside,
0772 ieta,
0773 iphi,
0774 idphi,
0775 idepth,
0776 det,
0777 iwedge,
0778 irm,
0779 ipixel,
0780 iqie,
0781 iadc,
0782 irm_fi,
0783 ifi_ch,
0784 icrate,
0785 ihtr,
0786 fpga,
0787 ihtr_fi,
0788 ispigot,
0789 islb,
0790 slbin,
0791 slbin2,
0792 slnam,
0793 irctcra,
0794 irctcar,
0795 irctcon,
0796 rctnam,
0797 ifed);
0798 }
0799 }
0800 }
0801 }
0802 }
0803 }
0804 }
0805
0806 void HcalLogicalMapGenerator::buildHOXMap(const HcalTopology* topo,
0807 std::vector<HOHXLogicalMapEntry>& HOHXEntries,
0808 std::vector<uint32_t>& LinearIndex2Entry,
0809 std::vector<uint32_t>& HoHash2Entry,
0810 std::vector<uint32_t>& HxCalibHash2Entry) {
0811
0812
0813 int hocrate_loc[NHOCR] = {3, 7, 6, 13};
0814 memcpy(hocrate, hocrate_loc, sizeof(int) * NHOCR);
0815
0816 int fedhonum_loc[NHOCR][2] = {{724, 725}, {726, 727}, {728, 729}, {730, 731}};
0817 memcpy(fedhonum, fedhonum_loc, sizeof(int) * NHOCR * 2);
0818
0819 int ihslotho_loc[NHSETSHO][NHTRSHO] = {{2, 3, 4, 5}, {6, 7, 13, 14}, {15, 16, 17, 18}};
0820 memcpy(ihslotho, ihslotho_loc, sizeof(int) * NHSETSHO * NHTRSHO);
0821
0822 int ihophis_loc[NHOCR] = {71, 17, 35, 53};
0823 memcpy(ihophis, ihophis_loc, sizeof(int) * NHOCR);
0824
0825
0826
0827
0828 int HO_RM_table_loc[24][16][2] = {{{2, 2},
0829 {2, 2},
0830 {2, 2},
0831 {2, 2},
0832 {2, 2},
0833 {2, 2},
0834 {2, 2},
0835 {2, 2},
0836 {2, 2},
0837 {2, 2},
0838 {4, 2},
0839 {4, 2},
0840 {4, 2},
0841 {4, 2},
0842 {4, 2},
0843 {4, 2}},
0844 {{2, 2},
0845 {2, 2},
0846 {2, 2},
0847 {2, 2},
0848 {4, 4},
0849 {4, 4},
0850 {4, 4},
0851 {4, 4},
0852 {4, 4},
0853 {4, 4},
0854 {2, 4},
0855 {2, 4},
0856 {2, 4},
0857 {2, 4},
0858 {2, 4},
0859 {2, 4}},
0860 {{3, 3},
0861 {3, 3},
0862 {3, 3},
0863 {3, 3},
0864 {4, 4},
0865 {4, 4},
0866 {4, 4},
0867 {4, 4},
0868 {4, 4},
0869 {4, 4},
0870 {2, 4},
0871 {2, 4},
0872 {2, 4},
0873 {2, 4},
0874 {2, 4},
0875 {2, 4}},
0876 {{3, 3},
0877 {3, 3},
0878 {3, 3},
0879 {3, 3},
0880 {4, 4},
0881 {4, 4},
0882 {4, 4},
0883 {4, 4},
0884 {4, 4},
0885 {4, 4},
0886 {2, 4},
0887 {2, 4},
0888 {2, 4},
0889 {2, 4},
0890 {2, 4},
0891 {2, 4}},
0892 {{4, 4},
0893 {4, 4},
0894 {4, 4},
0895 {4, 4},
0896 {3, 3},
0897 {3, 3},
0898 {3, 3},
0899 {3, 3},
0900 {3, 3},
0901 {3, 3},
0902 {1, 3},
0903 {1, 3},
0904 {1, 3},
0905 {1, 3},
0906 {1, 3},
0907 {1, 3}},
0908 {{4, 4},
0909 {4, 4},
0910 {4, 4},
0911 {4, 4},
0912 {3, 3},
0913 {3, 3},
0914 {3, 3},
0915 {3, 3},
0916 {3, 3},
0917 {3, 3},
0918 {1, 3},
0919 {1, 3},
0920 {1, 3},
0921 {1, 3},
0922 {1, 3},
0923 {1, 3}},
0924 {{3, 3},
0925 {3, 3},
0926 {3, 3},
0927 {3, 3},
0928 {3, 3},
0929 {3, 3},
0930 {3, 3},
0931 {3, 3},
0932 {3, 3},
0933 {3, 3},
0934 {1, 3},
0935 {1, 3},
0936 {1, 3},
0937 {1, 3},
0938 {1, 3},
0939 {1, 3}},
0940 {{3, 3},
0941 {3, 3},
0942 {3, 3},
0943 {3, 3},
0944 {1, 1},
0945 {1, 1},
0946 {1, 1},
0947 {1, 1},
0948 {1, 1},
0949 {1, 1},
0950 {3, 1},
0951 {3, 1},
0952 {3, 1},
0953 {3, 1},
0954 {3, 1},
0955 {3, 1}},
0956 {{2, 2},
0957 {2, 2},
0958 {2, 2},
0959 {2, 2},
0960 {1, 1},
0961 {1, 1},
0962 {1, 1},
0963 {1, 1},
0964 {1, 1},
0965 {1, 1},
0966 {3, 1},
0967 {3, 1},
0968 {3, 1},
0969 {3, 1},
0970 {3, 1},
0971 {3, 1}},
0972 {{2, 2},
0973 {2, 2},
0974 {2, 2},
0975 {2, 2},
0976 {1, 1},
0977 {1, 1},
0978 {1, 1},
0979 {1, 1},
0980 {1, 1},
0981 {1, 1},
0982 {3, 1},
0983 {3, 1},
0984 {3, 1},
0985 {3, 1},
0986 {3, 1},
0987 {3, 1}},
0988 {{4, 4},
0989 {4, 4},
0990 {4, 4},
0991 {4, 4},
0992 {2, 2},
0993 {2, 2},
0994 {2, 2},
0995 {2, 2},
0996 {2, 2},
0997 {2, 2},
0998 {4, 2},
0999 {4, 2},
1000 {4, 2},
1001 {4, 2},
1002 {4, 2},
1003 {4, 2}},
1004 {{4, 4},
1005 {4, 4},
1006 {4, 4},
1007 {4, 4},
1008 {2, 2},
1009 {2, 2},
1010 {2, 2},
1011 {2, 2},
1012 {2, 2},
1013 {2, 2},
1014 {4, 2},
1015 {4, 2},
1016 {4, 2},
1017 {4, 2},
1018 {4, 2},
1019 {4, 2}},
1020 {{3, 3},
1021 {3, 3},
1022 {3, 3},
1023 {3, 3},
1024 {2, 2},
1025 {2, 2},
1026 {2, 2},
1027 {2, 2},
1028 {2, 2},
1029 {2, 2},
1030 {4, 2},
1031 {4, 2},
1032 {4, 2},
1033 {4, 2},
1034 {4, 2},
1035 {4, 2}},
1036 {{3, 3},
1037 {3, 3},
1038 {3, 3},
1039 {3, 3},
1040 {4, 4},
1041 {4, 4},
1042 {4, 4},
1043 {4, 4},
1044 {4, 4},
1045 {4, 4},
1046 {2, 4},
1047 {2, 4},
1048 {2, 4},
1049 {2, 4},
1050 {2, 4},
1051 {2, 4}},
1052 {{2, 2},
1053 {2, 2},
1054 {2, 2},
1055 {2, 2},
1056 {4, 4},
1057 {4, 4},
1058 {4, 4},
1059 {4, 4},
1060 {4, 4},
1061 {4, 4},
1062 {2, 4},
1063 {2, 4},
1064 {2, 4},
1065 {2, 4},
1066 {2, 4},
1067 {2, 4}},
1068 {{2, 2},
1069 {2, 2},
1070 {2, 2},
1071 {2, 2},
1072 {4, 4},
1073 {4, 4},
1074 {4, 4},
1075 {4, 4},
1076 {4, 4},
1077 {4, 4},
1078 {2, 4},
1079 {2, 4},
1080 {2, 4},
1081 {2, 4},
1082 {2, 4},
1083 {2, 4}},
1084 {{1, 1},
1085 {1, 1},
1086 {1, 1},
1087 {1, 1},
1088 {3, 3},
1089 {3, 3},
1090 {3, 3},
1091 {3, 3},
1092 {3, 3},
1093 {3, 3},
1094 {1, 3},
1095 {1, 3},
1096 {1, 3},
1097 {1, 3},
1098 {1, 3},
1099 {1, 3}},
1100 {{1, 1},
1101 {1, 1},
1102 {1, 1},
1103 {1, 1},
1104 {3, 3},
1105 {3, 3},
1106 {3, 3},
1107 {3, 3},
1108 {3, 3},
1109 {3, 3},
1110 {1, 3},
1111 {1, 3},
1112 {1, 3},
1113 {1, 3},
1114 {1, 3},
1115 {1, 3}},
1116 {{2, 2},
1117 {2, 2},
1118 {2, 2},
1119 {2, 2},
1120 {3, 3},
1121 {3, 3},
1122 {3, 3},
1123 {3, 3},
1124 {3, 3},
1125 {3, 3},
1126 {1, 3},
1127 {1, 3},
1128 {1, 3},
1129 {1, 3},
1130 {1, 3},
1131 {1, 3}},
1132 {{2, 2},
1133 {2, 2},
1134 {2, 2},
1135 {2, 2},
1136 {1, 1},
1137 {1, 1},
1138 {1, 1},
1139 {1, 1},
1140 {1, 1},
1141 {1, 1},
1142 {3, 1},
1143 {3, 1},
1144 {3, 1},
1145 {3, 1},
1146 {3, 1},
1147 {3, 1}},
1148 {{3, 3},
1149 {3, 3},
1150 {3, 3},
1151 {3, 3},
1152 {1, 1},
1153 {1, 1},
1154 {1, 1},
1155 {1, 1},
1156 {1, 1},
1157 {1, 1},
1158 {3, 1},
1159 {3, 1},
1160 {3, 1},
1161 {3, 1},
1162 {3, 1},
1163 {3, 1}},
1164 {{3, 3},
1165 {3, 3},
1166 {3, 3},
1167 {3, 3},
1168 {1, 1},
1169 {1, 1},
1170 {1, 1},
1171 {1, 1},
1172 {1, 1},
1173 {1, 1},
1174 {3, 1},
1175 {3, 1},
1176 {3, 1},
1177 {3, 1},
1178 {3, 1},
1179 {3, 1}},
1180 {{1, 1},
1181 {1, 1},
1182 {1, 1},
1183 {1, 1},
1184 {2, 2},
1185 {2, 2},
1186 {2, 2},
1187 {2, 2},
1188 {2, 2},
1189 {2, 2},
1190 {4, 2},
1191 {4, 2},
1192 {4, 2},
1193 {4, 2},
1194 {4, 2},
1195 {4, 2}},
1196 {{1, 1},
1197 {1, 1},
1198 {1, 1},
1199 {1, 1},
1200 {2, 2},
1201 {2, 2},
1202 {2, 2},
1203 {2, 2},
1204 {2, 2},
1205 {2, 2},
1206 {4, 2},
1207 {4, 2},
1208 {4, 2},
1209 {4, 2},
1210 {4, 2},
1211 {4, 2}}};
1212 memcpy(HO_RM_table, HO_RM_table_loc, sizeof(int) * 24 * 16 * 2);
1213
1214
1215 int HO_RM_fi_eta5to15_loc[11] = {3, 2, 5, 4, 7, 6, 3, 2, 5, 4, 7};
1216 memcpy(HO_RM_fi_eta5to15, HO_RM_fi_eta5to15_loc, sizeof(int) * 11);
1217
1218 HO_RM_fi_eta16 = 6;
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231 int HO_RM_fi_eta1to4_loc[24][2][2] = {
1232
1233 {{7, 3}, {4, 5}}, {{6, 2}, {4, 5}}, {{7, 3}, {4, 5}}, {{6, 2}, {4, 5}}, {{2, 6}, {5, 4}},
1234 {{3, 7}, {5, 4}}, {{2, 6}, {5, 4}}, {{3, 7}, {5, 4}},
1235 {{2, 6}, {5, 4}}, {{3, 7}, {5, 4}}, {{2, 6}, {5, 4}}, {{3, 7}, {5, 4}}, {{2, 6}, {5, 4}},
1236 {{3, 7}, {5, 4}}, {{2, 6}, {5, 4}}, {{3, 7}, {5, 4}},
1237 {{7, 3}, {4, 5}}, {{6, 2}, {4, 5}}, {{7, 3}, {4, 5}}, {{6, 2}, {4, 5}}, {{7, 3}, {4, 5}},
1238 {{6, 2}, {4, 5}}, {{7, 3}, {4, 5}}, {{6, 2}, {4, 5}}
1239 };
1240 memcpy(HO_RM_fi_eta1to4, HO_RM_fi_eta1to4_loc, sizeof(int) * 24 * 2 * 2);
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251 int HO_RM_fi_eta1to4_sipm_loc[24][4][2] = {
1252
1253 {{5, 3}, {5, 5}, {7, 3}, {6, 3}}, {{4, 2}, {7, 4}, {7, 2}, {6, 2}},
1254 {{5, 3}, {5, 5}, {7, 3}, {6, 3}}, {{4, 2}, {7, 4}, {7, 2}, {6, 2}},
1255 {{2, 4}, {4, 7}, {2, 7}, {2, 6}}, {{3, 5}, {5, 5}, {3, 7}, {3, 6}},
1256 {{2, 4}, {4, 7}, {2, 7}, {2, 6}}, {{3, 5}, {5, 5}, {3, 7}, {3, 6}},
1257 {{2, 4}, {4, 7}, {2, 7}, {2, 6}}, {{3, 5}, {5, 5}, {3, 7}, {3, 6}},
1258 {{2, 4}, {4, 7}, {2, 7}, {2, 6}}, {{3, 5}, {5, 5}, {3, 7}, {3, 6}},
1259 {{2, 4}, {4, 7}, {2, 7}, {2, 6}}, {{3, 5}, {5, 5}, {3, 7}, {3, 6}},
1260 {{2, 4}, {4, 7}, {2, 7}, {2, 6}}, {{3, 5}, {5, 5}, {3, 7}, {3, 6}},
1261 {{5, 3}, {5, 5}, {7, 3}, {6, 3}}, {{4, 2}, {7, 4}, {7, 2}, {6, 2}},
1262 {{5, 3}, {5, 5}, {7, 3}, {6, 3}}, {{4, 2}, {7, 4}, {7, 2}, {6, 2}},
1263 {{5, 3}, {5, 5}, {7, 3}, {6, 3}}, {{4, 2}, {7, 4}, {7, 2}, {6, 2}},
1264 {{5, 3}, {5, 5}, {7, 3}, {6, 3}}, {{4, 2}, {7, 4}, {7, 2}, {6, 2}},
1265 };
1266 memcpy(HO_RM_fi_eta1to4_sipm, HO_RM_fi_eta1to4_sipm_loc, sizeof(int) * 24 * 4 * 2);
1267
1268
1269 int HO_htr_fi_450eta5to15_loc[2][11] = {{2, 2, 4, 6, 8, 2, 4, 6, 8, 4, 6},
1270 {2, 8, 6, 4, 2, 8, 6, 4, 2, 4, 2}};
1271 memcpy(HO_htr_fi_450eta5to15, HO_htr_fi_450eta5to15_loc, sizeof(int) * 2 * 11);
1272
1273
1274 int HO_htr_fi_450eta16M_loc[4] = {7, 7, 8, 8};
1275 memcpy(HO_htr_fi_450eta16M, HO_htr_fi_450eta16M_loc, sizeof(int) * 4);
1276
1277
1278 int HO_htr_fi_450eta16P_loc[4][6] = {
1279 {4, 2, 4, 4, 2, 6}, {2, 6, 6, 2, 6, 4}, {5, 3, 5, 5, 3, 7}, {3, 7, 7, 3, 7, 5}};
1280 memcpy(HO_htr_fi_450eta16P, HO_htr_fi_450eta16P_loc, sizeof(int) * 4 * 6);
1281
1282
1283 int HO_htr_fi_eta4_loc[2][6] = {{6, 6, 8, 8, 7, 7},
1284 {4, 4, 5, 5, 3, 3}};
1285 if (mapIOV_ < 5)
1286 memcpy(HO_htr_fi_eta4, HO_htr_fi_eta4_loc, sizeof(int) * 2 * 6);
1287
1288 int HO_htr_fi_eta123_loc[2][6] = {{6, 5, 4, 3, 8, 7},
1289 {8, 7, 6, 5, 2, 1}};
1290 if (mapIOV_ < 5)
1291 memcpy(HO_htr_fi_eta123, HO_htr_fi_eta123_loc, sizeof(int) * 2 * 6);
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301 int HO_htr_fi_eta1234_sipm[6][5][2][2] = {
1302 {
1303 {{4, 8}, {6, 4}},
1304 {{4, 4}, {4, 7}},
1305 {{6, 8}, {6, 7}},
1306 {{5, 8}, {6, 8}},
1307 {{5, 6}, {-1, -1}}},
1308 {{{6, 7}, {5, 6}}, {{6, 6}, {6, 6}}, {{6, 7}, {5, 7}}, {{5, 7}, {5, 8}}, {{-1, -1}, {4, 8}}},
1309 {{{4, 5}, {5, 6}}, {{5, 5}, {5, 5}}, {{4, 5}, {4, 6}}, {{4, 6}, {3, 6}}, {{-1, -1}, {3, 8}}},
1310 {{{3, 8}, {8, 5}}, {{8, 8}, {4, 8}}, {{3, 5}, {4, 5}}, {{3, 6}, {3, 5}}, {{5, 6}, {-1, -1}}},
1311 {
1312 {{3, 2}, {8, 3}},
1313 {{3, 3}, {3, 1}},
1314 {{8, 2}, {8, 1}},
1315 {{7, 2}, {8, 2}},
1316 {{7, 7}, {-1, -1}}},
1317 {{{7, 1}, {7, 7}}, {{8, 7}, {7, 7}}, {{8, 1}, {7, 1}}, {{7, 1}, {7, 2}}, {{-1, -1}, {3, 2}}},
1318 };
1319
1320
1321
1322
1323
1324
1325 int ipixelHO_loc[NRMFIBR][NFCH][2] = {{{12, 12}, {7, 7}, {6, 3}},
1326 {{4, 4}, {8, 8}, {5, 1}},
1327 {{19, 11}, {18, 6}, {17, 2}},
1328 {{2, 9}, {1, 13}, {3, 5}},
1329 {{11, 19}, {16, 18}, {15, 17}},
1330 {{13, 15}, {9, 14}, {14, 16}}};
1331
1332 int ipixelHO_sipm[NRMFIBR][NFCH][2] = {{{12, 12}, {7, 7}, {3, 3}},
1333 {{4, 4}, {8, 8}, {1, 1}},
1334 {{11, 11}, {6, 6}, {2, 2}},
1335 {{9, 9}, {13, 13}, {5, 5}},
1336 {{19, 19}, {18, 18}, {17, 17}},
1337 {{15, 15}, {14, 14}, {16, 16}}};
1338 if (mapIOV_ < 5)
1339 memcpy(ipixelHO, ipixelHO_loc, sizeof(int) * NRMFIBR * NFCH * 2);
1340 else
1341 memcpy(ipixelHO, ipixelHO_sipm, sizeof(int) * NRMFIBR * NFCH * 2);
1342
1343
1344 std::string letterHO_loc[NRMFIBR][NFCH][2] = {{{"E", "E"}, {"G", "L"}, {"F", "S"}},
1345 {{"Q", "M"}, {"N", "T"}, {"P", "F"}},
1346 {{"A", "C"}, {"X", "J"}, {"J", "Q"}},
1347 {{"X", "K"}, {"R", "R"}, {"H", "D"}},
1348 {{"D", "A"}, {"C", "G"}, {"B", "N"}},
1349 {{"L", "H"}, {"M", "P"}, {"K", "B"}}};
1350
1351 std::string letterHO_sipm[NRMFIBR][NFCH][2] = {{{"E", "E"}, {"G", "L"}, {"H", "S"}},
1352 {{"Q", "M"}, {"N", "T"}, {"R", "F"}},
1353 {{"D", "C"}, {"F", "J"}, {"X", "Q"}},
1354 {{"M", "K"}, {"L", "R"}, {"P", "D"}},
1355 {{"A", "A"}, {"X", "G"}, {"J", "N"}},
1356 {{"B", "H"}, {"K", "P"}, {"C", "B"}}};
1357
1358 for (int jj = 0; jj < NRMFIBR; jj++) {
1359 for (int kk = 0; kk < NFCH; kk++) {
1360 for (int ll = 0; ll < 2; ll++) {
1361 if (mapIOV_ < 5)
1362 letterHO[jj][kk][ll] = letterHO_loc[jj][kk][ll];
1363 else
1364 letterHO[jj][kk][ll] = letterHO_sipm[jj][kk][ll];
1365 }
1366 }
1367 }
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383 if (mapIOV_ == 1) {
1384 int rmspecialeta_loc[6][6] = {
1385
1386 {14, 15, 14, 13, 12, 11},
1387 {14, 15, 14, 13, 12, 11},
1388 {10, 9, 8, 7, 6, 5},
1389 {10, 9, 8, 7, 6, 5},
1390 {14, 15, 14, 13, 12, 11},
1391 {14, 15, 14, 13, 12, 11}
1392 };
1393
1394 std::string rmspeciallet_code_loc[6][6] = {
1395
1396 {"X", "B", "C", "D", "E", "F"},
1397 {"X", "P", "Q", "R", "S", "T"},
1398 {"G", "H", "J", "K", "L", "M"},
1399 {"A", "B", "C", "D", "E", "F"},
1400 {"X", "B", "C", "D", "E", "F"},
1401 {"X", "P", "Q", "R", "S", "T"}
1402 };
1403
1404 std::string rmspecialdet_loc[6][6] = {
1405
1406 {"HOX", "HO", "HO", "HO", "HO", "HO"},
1407 {"HOX", "HO", "HO", "HO", "HO", "HO"},
1408 {"HO", "HO", "HO", "HO", "HO", "HO"},
1409 {"HO", "HO", "HO", "HO", "HO", "HO"},
1410 {"HOX", "HO", "HO", "HO", "HO", "HO"},
1411 {"HOX", "HO", "HO", "HO", "HO", "HO"}
1412 };
1413
1414 memcpy(rmspecialeta, rmspecialeta_loc, sizeof(int) * 6 * 6);
1415
1416
1417 for (int jj = 0; jj < 6; jj++) {
1418 for (int kk = 0; kk < 6; kk++) {
1419 rmspeciallet_code[jj][kk] = rmspeciallet_code_loc[jj][kk];
1420 }
1421 }
1422
1423 for (int jj = 0; jj < 6; jj++) {
1424 for (int kk = 0; kk < 6; kk++) {
1425 rmspecialdet[jj][kk] = rmspecialdet_loc[jj][kk];
1426 }
1427 }
1428 }
1429
1430 else if (mapIOV_ == 2) {
1431 int rmspecialeta_loc[6][6] = {
1432
1433 {11, 12, 13, 14, 15, 15},
1434 {11, 12, 13, 14, 15, 15},
1435 {5, 6, 7, 8, 9, 10},
1436 {5, 6, 7, 8, 9, 10},
1437 {14, 15, 14, 13, 12, 11},
1438 {11, 12, 13, 14, 15, 15}
1439 };
1440
1441 std::string rmspeciallet_code_loc[6][6] = {
1442
1443 {"F", "E", "D", "C", "B", "X"},
1444 {"T", "S", "R", "Q", "P", "X"},
1445 {"M", "L", "K", "J", "H", "G"},
1446 {"F", "E", "D", "C", "B", "A"},
1447 {"X", "B", "C", "D", "E", "F"},
1448 {"T", "S", "R", "Q", "P", "X"}
1449 };
1450
1451 std::string rmspecialdet_loc[6][6] = {
1452
1453 {"HO", "HO", "HO", "HO", "HO", "HOX"},
1454 {"HO", "HO", "HO", "HO", "HO", "HOX"},
1455 {"HO", "HO", "HO", "HO", "HO", "HO"},
1456 {"HO", "HO", "HO", "HO", "HO", "HO"},
1457 {"HOX", "HO", "HO", "HO", "HO", "HO"},
1458 {"HO", "HO", "HO", "HO", "HO", "HOX"}
1459 };
1460
1461 memcpy(rmspecialeta, rmspecialeta_loc, sizeof(int) * 6 * 6);
1462
1463
1464 for (int jj = 0; jj < 6; jj++) {
1465 for (int kk = 0; kk < 6; kk++) {
1466 rmspeciallet_code[jj][kk] = rmspeciallet_code_loc[jj][kk];
1467 }
1468 }
1469
1470 for (int jj = 0; jj < 6; jj++) {
1471 for (int kk = 0; kk < 6; kk++) {
1472 rmspecialdet[jj][kk] = rmspecialdet_loc[jj][kk];
1473 }
1474 }
1475 }
1476
1477 else {
1478 int rmspecialeta_loc[6][6] = {
1479
1480 {11, 12, 13, 14, 15, 15},
1481 {11, 12, 13, 14, 15, 15},
1482 {5, 6, 7, 8, 9, 10},
1483 {5, 6, 7, 8, 9, 10},
1484 {11, 12, 13, 14, 15, 15},
1485 {11, 12, 13, 14, 15, 15}
1486 };
1487
1488 std::string rmspeciallet_code_loc[6][6] = {
1489
1490 {"F", "E", "D", "C", "B", "X"},
1491 {"T", "S", "R", "Q", "P", "X"},
1492 {"M", "L", "K", "J", "H", "G"},
1493 {"F", "E", "D", "C", "B", "A"},
1494 {"F", "E", "D", "C", "B", "X"},
1495 {"T", "S", "R", "Q", "P", "X"}
1496 };
1497
1498 std::string rmspecialdet_loc[6][6] = {
1499
1500 {"HO", "HO", "HO", "HO", "HO", "HOX"},
1501 {"HO", "HO", "HO", "HO", "HO", "HOX"},
1502 {"HO", "HO", "HO", "HO", "HO", "HO"},
1503 {"HO", "HO", "HO", "HO", "HO", "HO"},
1504 {"HO", "HO", "HO", "HO", "HO", "HOX"},
1505 {"HO", "HO", "HO", "HO", "HO", "HOX"}
1506 };
1507
1508 memcpy(rmspecialeta, rmspecialeta_loc, sizeof(int) * 6 * 6);
1509
1510
1511 for (int jj = 0; jj < 6; jj++) {
1512 for (int kk = 0; kk < 6; kk++) {
1513 rmspeciallet_code[jj][kk] = rmspeciallet_code_loc[jj][kk];
1514 }
1515 }
1516
1517 for (int jj = 0; jj < 6; jj++) {
1518 for (int kk = 0; kk < 6; kk++) {
1519 rmspecialdet[jj][kk] = rmspecialdet_loc[jj][kk];
1520 }
1521 }
1522 }
1523
1524
1525
1526 char tempbuff[30]{0};
1527
1528
1529 stringstream mystream;
1530
1531
1532 for (isid = -1; isid < 2; isid += 2) {
1533 for (iph = 0; iph < NHOPHI; iph++) {
1534 for (iet = 0; iet < NHOETA; iet++) {
1535 iphi = iph + 1;
1536 ieta = iet + 1;
1537 iside = isid;
1538
1539 if (iphi >= 71 || iphi < 17)
1540 ic = 0;
1541 else if (iphi >= 17 && iphi < 35)
1542 ic = 1;
1543 else if (iphi >= 35 && iphi < 53)
1544 ic = 2;
1545 else
1546 ic = 3;
1547
1548 icrate = hocrate[ic];
1549 idepth = 4;
1550 det = "HO";
1551
1552
1553
1554
1555 phmod6 = iph % 6;
1556
1557 phmod6e450 = (phmod6 == 4 || phmod6 == 5 || phmod6 == 0);
1558 phmod6e123 = (phmod6 == 1 || phmod6 == 2 || phmod6 == 3);
1559
1560
1561 if (ieta <= 3 && (iside < 0 || phmod6 >= 4))
1562 fpga = "bot";
1563 else if (ieta <= 3 && iside > 0 && phmod6 < 4)
1564 fpga = "top";
1565
1566 else if ((ieta > 15 && iside > 0) && (icrate == 3 || icrate == 6))
1567 fpga = "top";
1568 else if ((ieta > 15 && iside > 0) && (icrate == 7 || icrate == 13))
1569 fpga = "bot";
1570
1571 else if (ieta >= 10 && iside > 0)
1572 fpga = "top";
1573 else if (ieta < 10 && ieta >= 6 && iside > 0)
1574 fpga = "bot";
1575
1576 else if ((ieta == 5 && iside > 0) || ieta == 4)
1577 fpga = "top";
1578 else if ((ieta == 5 || ieta >= 10) && iside < 0)
1579 fpga = "bot";
1580 else if ((ieta < 10 && ieta >= 6) && iside < 0)
1581 fpga = "top";
1582 else
1583 edm::LogInfo("HcalLogicalMapGenerator") << "Bad fpga code" << endl;
1584
1585
1586 if (ieta <= 20)
1587 idphi = 1;
1588 else
1589 idphi = -1000;
1590
1591
1592 if (iside == 1)
1593 sidear = 1;
1594 else
1595 sidear = 0;
1596
1597 phmod24 = iph % 24;
1598
1599
1600 irm = HO_RM_table[phmod24][iet][sidear];
1601
1602
1603
1604 if (ieta == 16)
1605 irm_fi = HO_RM_fi_eta16;
1606 else if (ieta >= 5)
1607 irm_fi = HO_RM_fi_eta5to15[ieta - 5];
1608 else {
1609 if (mapIOV_ < 5) {
1610 if (ieta <= 3)
1611 irm_fi = HO_RM_fi_eta1to4[phmod24][0][sidear];
1612 else if (ieta == 4)
1613 irm_fi = HO_RM_fi_eta1to4[phmod24][1][sidear];
1614 else
1615 irm_fi = -1000;
1616 } else if (mapIOV_ >= 5) {
1617 irm_fi = HO_RM_fi_eta1to4_sipm[phmod24][ieta - 1][sidear];
1618 }
1619 }
1620
1621
1622
1623
1624 if (ieta >= 5 && phmod6e450)
1625 ihtr_fi = HO_htr_fi_450eta5to15[sidear][ieta - 5];
1626 else if (ieta >= 5 && phmod6e123)
1627 ihtr_fi = HO_htr_fi_450eta5to15[sidear][ieta - 5] - 1;
1628 else if (ieta <= 4) {
1629 if (mapIOV_ < 5) {
1630 if (ieta == 4)
1631 ihtr_fi = HO_htr_fi_eta4[sidear][phmod6];
1632 else if (ieta <= 3)
1633 ihtr_fi = HO_htr_fi_eta123[sidear][phmod6];
1634 } else if (mapIOV_ >= 5) {
1635 ihtr_fi = HO_htr_fi_eta1234_sipm[phmod6][ieta - 1][(irm - 1) / 2][sidear];
1636 }
1637 } else
1638 ihtr_fi = -1000;
1639
1640
1641
1642 phi1458 = (iphi % 12 == 1 || iphi % 12 == 4 || iphi % 12 == 5 || iphi % 12 == 8);
1643 phi271011 = (iphi % 12 == 2 || iphi % 12 == 7 || iphi % 12 == 10 || iphi % 12 == 11);
1644
1645
1646 phir0v1 = (iphi % 24 == 0 || iphi % 24 == 2 || iphi % 24 == 4 || iphi % 24 == 18 || iphi % 24 == 20 ||
1647 iphi % 24 == 22);
1648 phir0v2 = (iphi % 24 == 1 || iphi % 24 == 3 || iphi % 24 == 17 || iphi % 24 == 19 || iphi % 24 == 21 ||
1649 iphi % 24 == 23);
1650
1651 phir0v3 = (iphi % 24 == 5 || iphi % 24 == 7 || iphi % 24 == 9 || iphi % 24 == 11 || iphi % 24 == 13 ||
1652 iphi % 24 == 15);
1653 phir0v4 = (iphi % 24 == 6 || iphi % 24 == 8 || iphi % 24 == 10 || iphi % 24 == 12 || iphi % 24 == 14 ||
1654 iphi % 24 == 16);
1655
1656 if (ieta >= 5) {
1657 if (ieta % 2 == 0 && phi1458)
1658 ifi_ch = 0;
1659 else if (ieta % 2 == 0 && iphi % 3 == 0)
1660 ifi_ch = 1;
1661 else if (ieta % 2 == 0 && phi271011)
1662 ifi_ch = 2;
1663 else if (ieta % 2 == 1 && iphi % 3 == 0)
1664 ifi_ch = 0;
1665 else if (ieta % 2 == 1 && phi271011)
1666 ifi_ch = 1;
1667 else if (ieta % 2 == 1 && phi1458)
1668 ifi_ch = 2;
1669 } else {
1670 if (mapIOV_ < 5) {
1671 if (ieta == 4) {
1672 if (iside == -1) {
1673 if (phir0v1)
1674 ifi_ch = 0;
1675 else if (phir0v4)
1676 ifi_ch = 1;
1677 else if (iphi % 2 == 1)
1678 ifi_ch = 2;
1679 } else {
1680 if (phir0v3)
1681 ifi_ch = 0;
1682 else if (phir0v2)
1683 ifi_ch = 1;
1684 else if (iphi % 2 == 0)
1685 ifi_ch = 2;
1686 }
1687 }
1688
1689 else if ((ieta == 3 && iside == -1) || (ieta == 2 && iside == 1)) {
1690 if (phir0v4)
1691 ifi_ch = 0;
1692 else if (phir0v3)
1693 ifi_ch = 1;
1694 else if (phir0v1 || phir0v2)
1695 ifi_ch = 2;
1696 }
1697
1698 else if ((ieta == 3 && iside == 1) || (ieta == 2 && iside == -1)) {
1699 if (phir0v2)
1700 ifi_ch = 0;
1701 else if (phir0v1)
1702 ifi_ch = 1;
1703 else if (phir0v3 || phir0v4)
1704 ifi_ch = 2;
1705 }
1706
1707 else if (ieta == 1) {
1708 if (phir0v1 || phir0v3)
1709 ifi_ch = 0;
1710 else if (phir0v2 || phir0v4)
1711 ifi_ch = 1;
1712 }
1713 } else {
1714
1715
1716 if (ieta == 4) {
1717 if (iside == -1) {
1718 if (phir0v1)
1719 ifi_ch = 0;
1720 else if (phir0v4)
1721 ifi_ch = 2;
1722 else if (iphi % 2 == 1)
1723 ifi_ch = 2;
1724 } else {
1725 if (phir0v3)
1726 ifi_ch = 0;
1727 else if (phir0v2)
1728 ifi_ch = 2;
1729 else if (iphi % 2 == 0)
1730 ifi_ch = 2;
1731 }
1732 }
1733 if (ieta == 2) {
1734 if (iside == -1) {
1735 if (iphi % 2 == 0)
1736 ifi_ch = 2;
1737 else if (iphi % 2 == 1)
1738 ifi_ch = 1;
1739 } else {
1740 if (iphi % 2 == 0)
1741 ifi_ch = 1;
1742 else if (iphi % 2 == 1)
1743 ifi_ch = 2;
1744 }
1745 }
1746 if (ieta == 3) {
1747 if (iside == -1) {
1748 if (iphi % 2 == 0)
1749 ifi_ch = 0;
1750 else if (iphi % 2 == 1)
1751 ifi_ch = 1;
1752 } else {
1753 if (iphi % 2 == 1)
1754 ifi_ch = 0;
1755 else if (iphi % 2 == 0)
1756 ifi_ch = 1;
1757 }
1758 }
1759 if (ieta == 1) {
1760 if (iside == -1) {
1761 if (phir0v1)
1762 ifi_ch = 0;
1763 else if (phir0v4)
1764 ifi_ch = 1;
1765 else if (iphi % 2 == 1)
1766 ifi_ch = 0;
1767 } else {
1768 if (phir0v3)
1769 ifi_ch = 0;
1770 else if (phir0v2)
1771 ifi_ch = 1;
1772 else if (iphi % 2 == 0)
1773 ifi_ch = 0;
1774 }
1775 }
1776 }
1777 }
1778
1779
1780
1781 iqie = (irm_fi - 2) / 2 + 1;
1782
1783 if (irm_fi % 2 == 0)
1784 iadc = ifi_ch;
1785 else
1786 iadc = NFCH + (ifi_ch + 1) % 3;
1787
1788
1789 if (ieta <= 4) {
1790 ipixel = ipixelHO[irm_fi - 2][ifi_ch][0];
1791 letter = letterHO[irm_fi - 2][ifi_ch][0];
1792 } else {
1793 ipixel = ipixelHO[irm_fi - 2][ifi_ch][1];
1794 letter = letterHO[irm_fi - 2][ifi_ch][1];
1795 }
1796
1797
1798 int mytype = -1;
1799 if (ieta <= 4 && mapIOV_ >= 5) {
1800 if (ipixel == 3 || ipixel == 7 || ipixel == 12 || ipixel == 14 || ipixel == 17 || ipixel == 18) {
1801 mytype = 1;
1802 if (phmod6 == 1 || phmod6 == 3)
1803 fpga = "top";
1804 else
1805 fpga = "bot";
1806 } else if (ipixel == 1 || ipixel == 4 || ipixel == 8 || ipixel == 15 || ipixel == 16 || ipixel == 19) {
1807 mytype = 2;
1808 if (phmod6 == 0 || phmod6 == 2)
1809 fpga = "top";
1810 else
1811 fpga = "bot";
1812 } else if (ipixel == 2 || ipixel == 5 || ipixel == 6 || ipixel == 9 || ipixel == 11 || ipixel == 13) {
1813 mytype = 3;
1814 fpga = "top";
1815 }
1816 }
1817
1818 if (fpga == "bot")
1819 itb = 1;
1820 else
1821 itb = 0;
1822
1823
1824
1825
1826 if (ieta <= 3 || (ieta >= 14 && iside == 1))
1827 ih = 0;
1828 else if (ieta <= 13 && ieta >= 6 && iside == 1)
1829 ih = 1;
1830 else if (ieta <= 13 && ieta >= 6 && iside == -1)
1831 ih = 3;
1832 else
1833 ih = 2;
1834
1835
1836
1837
1838
1839 int php2mod18 = (iph + 2) % 18;
1840 int php2mod18ov6 = php2mod18 / 6;
1841
1842
1843
1844
1845 if (iphi % 18 == 17 || iphi % 18 <= 4)
1846 is = 0;
1847 else if (iphi % 18 >= 5 && iphi % 18 <= 10)
1848 is = 1;
1849 else
1850 is = 2;
1851
1852 if (ieta == 16 && iside > 0)
1853 ihtr = 21;
1854 else if (ieta > 4)
1855 ihtr = ihslotho[is][ih];
1856 else {
1857
1858 if (mapIOV_ < 5)
1859 ihtr = ihslotho[is][ih];
1860 else {
1861 if (mytype == 1 || mytype == 2)
1862 ih = 0;
1863 else
1864 ih = 2;
1865 ihtr = ihslotho[php2mod18ov6][ih];
1866 }
1867 }
1868
1869 if ((ieta > 15 && iside > 0) && (icrate == 3 || icrate == 6))
1870 ispigot = 12;
1871 else if ((ieta > 15 && iside > 0) && (icrate == 7 || icrate == 13))
1872 ispigot = 13;
1873 else
1874 ispigot = ihtr < 9 ? (ihtr - 2) * 2 + itb : (ihtr - 13) * 2 + itb;
1875 idcc = ihtr < 9 ? 1 : 2;
1876 idcc_sl = idcc == 1 ? 10 : 20;
1877
1878 ifed = fedhonum[ic][idcc - 1];
1879
1880
1881
1882 if (iside == -1)
1883 sidesign = 'M';
1884 else
1885 sidesign = 'P';
1886
1887 if (ieta <= 4)
1888 ring = 0;
1889 else if (ieta >= 5 && ieta <= 10)
1890 ring = 1;
1891 else
1892 ring = 2;
1893
1894
1895 sector = 0;
1896 for (i = -2; i < iphi; i += 6) {
1897 sector++;
1898 }
1899 if (sector > 12)
1900 sector = 1;
1901
1902 isector = sector;
1903
1904
1905 if (ring != 0 && sector % 2 != 0)
1906 sector++;
1907
1908 if (ring == 0)
1909 snprintf(tempbuff, sizeof tempbuff, "%s%i%2.2d", det.c_str(), ring, sector);
1910 else
1911 snprintf(tempbuff, sizeof tempbuff, "%s%i%c%2.2d", det.c_str(), ring, sidesign, sector);
1912 mystream << tempbuff;
1913 rbx = mystream.str();
1914 mystream.str("");
1915 if (ieta == 16) {
1916 det = "HOX";
1917 letter = "X";
1918 } else
1919 det = "HO";
1920
1921
1922 if (ieta == 16 && isid < 0)
1923 ihtr_fi = HO_htr_fi_450eta16M[irm - 1];
1924 else if (ieta == 16 && isid > 0)
1925 ihtr_fi = HO_htr_fi_450eta16P[irm - 1][sector / 2 - 1];
1926
1927 if ((ieta > 15 && iside > 0) && (icrate == 3 || icrate == 7)) {
1928 icrate = 6;
1929 ifed = 729;
1930 } else if ((ieta > 15 && iside > 0) && (icrate == 6 || icrate == 13)) {
1931 icrate = 7;
1932 ifed = 727;
1933 }
1934
1935 if (ieta == 16)
1936 ieta = 15;
1937
1938 if (iside == 1 && ring == 2) {
1939 if (iphi == 5) {
1940 ieta = rmspecialeta[0][iet - 10];
1941 letter = rmspeciallet_code[0][iet - 10];
1942 det = rmspecialdet[0][iet - 10];
1943 } else if (iphi == 67) {
1944 ieta = rmspecialeta[1][iet - 10];
1945 letter = rmspeciallet_code[1][iet - 10];
1946 det = rmspecialdet[1][iet - 10];
1947 }
1948 } else if (iside == -1) {
1949 if (ring == 1) {
1950 if (iphi == 57) {
1951 ieta = rmspecialeta[2][iet - 4];
1952 letter = rmspeciallet_code[2][iet - 4];
1953 det = rmspecialdet[2][iet - 4];
1954 } else if (iphi == 65) {
1955 ieta = rmspecialeta[3][iet - 4];
1956 letter = rmspeciallet_code[3][iet - 4];
1957 det = rmspecialdet[3][iet - 4];
1958 }
1959 } else if (ring == 2) {
1960 if (iphi == 16) {
1961 ieta = rmspecialeta[4][iet - 10];
1962 letter = rmspeciallet_code[4][iet - 10];
1963 det = rmspecialdet[4][iet - 10];
1964 } else if (iphi == 31) {
1965 ieta = rmspecialeta[5][iet - 10];
1966 letter = rmspeciallet_code[5][iet - 10];
1967 det = rmspecialdet[5][iet - 10];
1968 }
1969 }
1970 }
1971
1972 HOHXLogicalMapEntry hoxlmapentry(ifi_ch,
1973 ihtr_fi,
1974 ispigot,
1975 ifed,
1976 icrate,
1977 ihtr,
1978 fpga,
1979 det,
1980 iside,
1981 ieta,
1982 iphi,
1983 idepth,
1984 idphi,
1985 isector,
1986 irm,
1987 irm_fi,
1988 ipixel,
1989 iqie,
1990 iadc,
1991 rbx,
1992 letter);
1993 HOHXEntries.push_back(hoxlmapentry);
1994 LinearIndex2Entry.at(hoxlmapentry.getLinearIndex()) =
1995 HcalLogicalMap::makeEntryNumber(true, 1, HOHXEntries.size() - 1);
1996
1997 const HcalGenericDetId hgdi(hoxlmapentry.getDetId());
1998 unsigned int denseId;
1999 if (hgdi.genericSubdet() == HcalGenericDetId::HcalGenOuter) {
2000 denseId = topo->detId2denseIdHO(hgdi);
2001 HoHash2Entry.at(denseId) = HOHXEntries.size();
2002 } else if (hgdi.genericSubdet() == HcalGenericDetId::HcalGenCalibration) {
2003 denseId = topo->detId2denseIdCALIB(hgdi);
2004 HxCalibHash2Entry.at(denseId) = HOHXEntries.size();
2005 }
2006
2007 if (ring == 0) {
2008 if (ipixel == 1) {
2009 ipixel = 2;
2010 iadc = 4;
2011 if (mapIOV_ < 5)
2012 ifi_ch = 0;
2013 else {
2014 irm_fi = 4;
2015 ifi_ch = 2;
2016 if (irm_fi % 2 == 0)
2017 iadc = ifi_ch;
2018 else
2019 iadc = NFCH + (ifi_ch + 1) % 3;
2020 iqie = (irm_fi - 2) / 2 + 1;
2021 ihtr_fi = HO_htr_fi_eta1234_sipm[phmod6][4][(irm - 1) / 2][sidear];
2022 itb = 0;
2023 fpga = "top";
2024
2025 ih = 2;
2026 ihtr = ihslotho[php2mod18ov6][ih];
2027 ispigot = ihtr < 9 ? (ihtr - 2) * 2 + itb : (ihtr - 13) * 2 + itb;
2028 idcc = ihtr < 9 ? 1 : 2;
2029 idcc_sl = idcc == 1 ? 10 : 20;
2030 ifed = fedhonum[ic][idcc - 1];
2031 }
2032 letter = "X";
2033 det = "HOX";
2034 HOHXLogicalMapEntry hoxlmapentry(ifi_ch,
2035 ihtr_fi,
2036 ispigot,
2037 ifed,
2038 icrate,
2039 ihtr,
2040 fpga,
2041 det,
2042 iside,
2043 ieta,
2044 iphi,
2045 idepth,
2046 idphi,
2047 isector,
2048 irm,
2049 irm_fi,
2050 ipixel,
2051 iqie,
2052 iadc,
2053 rbx,
2054 letter);
2055 HOHXEntries.push_back(hoxlmapentry);
2056 LinearIndex2Entry.at(hoxlmapentry.getLinearIndex()) =
2057 HcalLogicalMap::makeEntryNumber(true, 1, HOHXEntries.size() - 1);
2058
2059 const HcalGenericDetId hgdi(hoxlmapentry.getDetId());
2060 unsigned int denseId;
2061 if (hgdi.genericSubdet() == HcalGenericDetId::HcalGenOuter) {
2062 denseId = topo->detId2denseIdHO(hgdi);
2063 HoHash2Entry.at(denseId) = HOHXEntries.size();
2064 } else if (hgdi.genericSubdet() == HcalGenericDetId::HcalGenCalibration) {
2065 denseId = topo->detId2denseIdCALIB(hgdi);
2066 HxCalibHash2Entry.at(denseId) = HOHXEntries.size();
2067 }
2068 } else if (ipixel == 17) {
2069 ipixel = 18;
2070 iadc = 1;
2071 if (mapIOV_ < 5)
2072 ifi_ch = 1;
2073 else {
2074 irm_fi = 6;
2075 ifi_ch = 1;
2076 if (irm_fi % 2 == 0)
2077 iadc = ifi_ch;
2078 else
2079 iadc = NFCH + (ifi_ch + 1) % 3;
2080 iqie = (irm_fi - 2) / 2 + 1;
2081 ihtr_fi = HO_htr_fi_eta1234_sipm[phmod6][4][(irm - 1) / 2][sidear];
2082 if (phmod6 == 1 || phmod6 == 3) {
2083 itb = 0;
2084 fpga = "top";
2085 } else {
2086 itb = 1;
2087 fpga = "bot";
2088 }
2089 ispigot = ihtr < 9 ? (ihtr - 2) * 2 + itb : (ihtr - 13) * 2 + itb;
2090 idcc = ihtr < 9 ? 1 : 2;
2091 idcc_sl = idcc == 1 ? 10 : 20;
2092 ifed = fedhonum[ic][idcc - 1];
2093 }
2094 letter = "X";
2095 det = "HOX";
2096 HOHXLogicalMapEntry hoxlmapentry(ifi_ch,
2097 ihtr_fi,
2098 ispigot,
2099 ifed,
2100 icrate,
2101 ihtr,
2102 fpga,
2103 det,
2104 iside,
2105 ieta,
2106 iphi,
2107 idepth,
2108 idphi,
2109 isector,
2110 irm,
2111 irm_fi,
2112 ipixel,
2113 iqie,
2114 iadc,
2115 rbx,
2116 letter);
2117 HOHXEntries.push_back(hoxlmapentry);
2118 LinearIndex2Entry.at(hoxlmapentry.getLinearIndex()) =
2119 HcalLogicalMap::makeEntryNumber(true, 1, HOHXEntries.size() - 1);
2120
2121 const HcalGenericDetId hgdi(hoxlmapentry.getDetId());
2122 unsigned int denseId;
2123 if (hgdi.genericSubdet() == HcalGenericDetId::HcalGenOuter) {
2124 denseId = topo->detId2denseIdHO(hgdi);
2125 HoHash2Entry.at(denseId) = HOHXEntries.size();
2126 } else if (hgdi.genericSubdet() == HcalGenericDetId::HcalGenCalibration) {
2127 denseId = topo->detId2denseIdCALIB(hgdi);
2128 HxCalibHash2Entry.at(denseId) = HOHXEntries.size();
2129 }
2130 }
2131 }
2132 }
2133 }
2134 }
2135 }
2136
2137 void HcalLogicalMapGenerator::buildCALIBMap(const HcalTopology* topo,
2138 std::vector<CALIBLogicalMapEntry>& CALIBEntries,
2139 std::vector<uint32_t>& LinearIndex2Entry,
2140 std::vector<uint32_t>& HxCalibHash2Entry) {
2141
2142
2143 int calibcrate_loc[NCALIBCR] = {4, 0, 1, 5, 11, 15, 17, 14, 10, 9, 7, 6, 13};
2144 memcpy(calibcrate, calibcrate_loc, sizeof(int) * NCALIBCR);
2145
2146 int fedcalibnum_loc[NCALIBCR][2] = {{700, 701},
2147 {702, 703},
2148 {704, 705},
2149 {706, 707},
2150 {708, 709},
2151 {710, 711},
2152 {712, 713},
2153 {714, 715},
2154 {716, 717},
2155 {720, 721},
2156 {726, 727},
2157 {728, 729},
2158 {730, 731}};
2159 memcpy(fedcalibnum, fedcalibnum_loc, sizeof(int) * NCALIBCR * 2);
2160
2161 int icalibphis_loc[NCALIBCR] = {3, 11, 19, 27, 35, 43, 51, 59, 67, 27, 17, 35, 53};
2162 memcpy(icalibphis, icalibphis_loc, sizeof(int) * NCALIBCR);
2163
2164 int icalibsector_min_loc[NCALIBCR] = {2, 4, 6, 8, 10, 12, 14, 16, 18, 1, 4, 7, 10};
2165 memcpy(icalibsector_min, icalibsector_min_loc, sizeof(int) * NCALIBCR);
2166
2167 int icalibsector_max_loc[NCALIBCR] = {3, 5, 7, 9, 11, 13, 15, 17, 1, 4, 6, 9, 12};
2168 memcpy(icalibsector_max, icalibsector_max_loc, sizeof(int) * NCALIBCR);
2169
2170 std::string detIDCALIB_loc[NCALIBCR][NTOPBOT] = {{"HB", "HE"},
2171 {"HB", "HE"},
2172 {"HB", "HE"},
2173 {"HB", "HE"},
2174 {"HB", "HE"},
2175 {"HB", "HE"},
2176 {"HB", "HE"},
2177 {"HB", "HE"},
2178 {"HB", "HE"},
2179 {"HF", "HF"},
2180 {"HO", "HO"},
2181 {"HO", "HO"},
2182 {"HO", "HO"}};
2183 for (int jj = 0; jj < NCALIBCR; jj++) {
2184 for (int kk = 0; kk < NTOPBOT; kk++) {
2185 detIDCALIB[jj][kk] = detIDCALIB_loc[jj][kk];
2186 }
2187 }
2188
2189 int nfbr_max_loc[NCALIBCR][NTOPBOT] = {
2190 {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}};
2191 memcpy(nfbr_max, nfbr_max_loc, sizeof(int) * NCALIBCR * NTOPBOT);
2192
2193 int calibHOinfo_loc[NHOCR][NTOPBOT][NFBR][2] = {
2194
2195 {{{4, 0}, {5, 0}, {6, 0}, {}, {6, -2}, {6, -1}, {6, 1}, {6, 2}},
2196 {{4, -2}, {4, -1}, {4, 1}, {4, 2}, {}, {}, {}, {}}},
2197
2198 {{{7, 0}, {8, 0}, {9, 0}, {}, {8, -2}, {8, -1}, {8, 1}, {8, 2}},
2199 {{1, 0}, {2, 0}, {3, 0}, {}, {2, -2}, {2, -1}, {2, 1}, {2, 2}}},
2200
2201 {{{10, 0}, {11, 0}, {12, 0}, {}, {10, -2}, {10, -1}, {10, 1}, {10, 2}},
2202 {{12, -2}, {12, -1}, {12, 1}, {12, 2}, {}, {}, {}, {}}}
2203 };
2204 memcpy(calibHOinfo, calibHOinfo_loc, sizeof(int) * NHOCR * NTOPBOT * NFBR * 2);
2205
2206
2207
2208 char tempbuff[30]{0};
2209
2210
2211
2212 stringstream mystream;
2213
2214 ihtr = 8;
2215 idcc = 1;
2216 idcc_sl = 10;
2217 irm_fi = 1;
2218 det = "";
2219
2220
2221
2222 for (ic = 0; ic < NHBHECR; ic++) {
2223 icrate = calibcrate[ic];
2224 ifed = fedcalibnum[ic][idcc - 1];
2225
2226 for (itb = 0; itb < NTOPBOT; itb++) {
2227
2228 for (ifb = 0; ifb < nfbr_max[ic][itb]; ifb++) {
2229 det = detIDCALIB[ic][itb];
2230 ihtr_fi = ifb + 1;
2231 irm_fi = 1;
2232 idphi = 4;
2233 if (itb == 1)
2234 if (ihtr_fi % 2 == 0)
2235 irm_fi = 2;
2236 if (det == "HE") {
2237 ispigot = 13;
2238 fpga = "bot";
2239 if (ihtr_fi == 1 || ihtr_fi == 2 || ihtr_fi == 5 || ihtr_fi == 6) {
2240 iwedge = icalibsector_min[ic];
2241 } else if (ihtr_fi == 3 || ihtr_fi == 4 || ihtr_fi == 7 || ihtr_fi == 8) {
2242 iwedge = icalibsector_max[ic];
2243 }
2244 if (ihtr_fi < 5) {
2245 sidesign = 'M';
2246 S_side = '1';
2247 ieta = -1;
2248 iside = -1;
2249 } else {
2250 sidesign = 'P';
2251 S_side = '1';
2252 ieta = 1;
2253 iside = 1;
2254 }
2255 } else if (det == "HB") {
2256 ispigot = 12;
2257 fpga = "top";
2258 (ihtr_fi % 2 == 1) ? iwedge = icalibsector_min[ic] : iwedge = icalibsector_max[ic];
2259 if (ihtr_fi < 3) {
2260 sidesign = 'M';
2261 S_side = '1';
2262 ieta = -1;
2263 iside = -1;
2264 } else {
2265 sidesign = 'P';
2266 S_side = '1';
2267 ieta = 1;
2268 iside = 1;
2269 }
2270 }
2271 iphi = ((iwedge * idphi) + 71 - idphi) % 72;
2272 subdet = "CALIB_" + det;
2273 snprintf(tempbuff, sizeof tempbuff, "%s%c%2.2i", det.c_str(), sidesign, iwedge);
2274 mystream << tempbuff;
2275 rbx = mystream.str();
2276 mystream.str("");
2277
2278 for (ifc = 0; ifc < NFCH; ifc++) {
2279 ifi_ch = ifc;
2280 if (irm_fi == 1) {
2281 if (ifc == 0)
2282 ich_type = 0;
2283 else if (ifc == 1)
2284 ich_type = 1;
2285 else if (ifc == 2) {
2286 if (det == "HB")
2287 ich_type = 2;
2288 else if (det == "HE")
2289 ich_type = 3;
2290 }
2291 } else if (irm_fi == 2) {
2292 if (ifc == 0)
2293 ich_type = 4;
2294 else if (ifc == 1)
2295 ich_type = 5;
2296 else if (ifc == 2)
2297 ich_type = 6;
2298 }
2299 CALIBLogicalMapEntry caliblmapentry(ifi_ch,
2300 ihtr_fi,
2301 ispigot,
2302 ifed,
2303 icrate,
2304 ihtr,
2305 fpga,
2306 det,
2307 ieta,
2308 iphi,
2309 ich_type,
2310 iside,
2311 idphi,
2312 rbx,
2313 iwedge,
2314 irm_fi,
2315 subdet);
2316 CALIBEntries.push_back(caliblmapentry);
2317 LinearIndex2Entry.at(caliblmapentry.getLinearIndex()) =
2318 HcalLogicalMap::makeEntryNumber(true, 2, CALIBEntries.size() - 1);
2319
2320 const HcalGenericDetId hgdi(caliblmapentry.getDetId());
2321 const unsigned int hashedId = topo->detId2denseIdCALIB(hgdi);
2322 if (hgdi.genericSubdet() == HcalGenericDetId::HcalGenCalibration)
2323 HxCalibHash2Entry.at(hashedId) = CALIBEntries.size();
2324 }
2325 }
2326 }
2327 }
2328
2329
2330
2331 for (itb = 0; itb < NTOPBOT; itb++) {
2332
2333 for (ifb = 0; ifb < 4; ifb++) {
2334
2335 for (ifc = 0; ifc < NFCH; ifc++) {
2336 icrate = calibcrate[ic];
2337 det = "HF";
2338 ihtr_fi = ifb + 1;
2339 ifi_ch = ifc;
2340 (ihtr_fi == 1) ? iphi = 1 : ((ihtr_fi == 2) ? iphi = 19 : ((ihtr_fi == 3) ? iphi = 37 : iphi = 55));
2341 idphi = 18;
2342 ifed = fedcalibnum[ic][idcc - 1];
2343 (ifc == 0) ? ich_type = 8 : (ifc == 1 ? ich_type = 0 : ich_type = 1);
2344
2345 irm_fi = 1;
2346
2347
2348 iwedge = 2 + (ifb * 3);
2349 if (itb == 0) {
2350 ispigot = 12;
2351 fpga = "top";
2352 sidesign = 'P';
2353 iside = 1;
2354 ieta = 1;
2355 } else {
2356 ispigot = 13;
2357 fpga = "bot";
2358 sidesign = 'M';
2359 iside = -1;
2360 ieta = -1;
2361 }
2362 subdet = "CALIB_" + det;
2363 snprintf(tempbuff, sizeof tempbuff, "%s%c%2.2i", det.c_str(), sidesign, iwedge);
2364 mystream << tempbuff;
2365 rbx = mystream.str();
2366 mystream.str("");
2367 CALIBLogicalMapEntry caliblmapentry(ifi_ch,
2368 ihtr_fi,
2369 ispigot,
2370 ifed,
2371 icrate,
2372 ihtr,
2373 fpga,
2374 det,
2375 ieta,
2376 iphi,
2377 ich_type,
2378 iside,
2379 idphi,
2380 rbx,
2381 iwedge,
2382 irm_fi,
2383 subdet);
2384 CALIBEntries.push_back(caliblmapentry);
2385 LinearIndex2Entry.at(caliblmapentry.getLinearIndex()) =
2386 HcalLogicalMap::makeEntryNumber(true, 2, CALIBEntries.size() - 1);
2387
2388 const HcalGenericDetId hgdi(caliblmapentry.getDetId());
2389 const unsigned int hashedId = topo->detId2denseIdCALIB(hgdi);
2390 if (hgdi.genericSubdet() == HcalGenericDetId::HcalGenCalibration)
2391 HxCalibHash2Entry.at(hashedId) = CALIBEntries.size();
2392 }
2393 }
2394 }
2395
2396
2397 for (ic = ic + 1; ic < NCALIBCR; ic++) {
2398 icrate = calibcrate[ic];
2399 irm_fi = 1;
2400 ifed = fedcalibnum[ic][idcc - 1];
2401
2402 for (itb = 0; itb < NTOPBOT; itb++) {
2403 det = detIDCALIB[ic][itb];
2404
2405 for (ifb = 0; ifb < nfbr_max[ic][itb]; ifb++) {
2406 if (itb == 1) {
2407 ispigot = 13;
2408 fpga = "bot";
2409 } else {
2410 ispigot = 12;
2411 fpga = "top";
2412 }
2413 ihtr_fi = ifb + 1;
2414 iwedge = calibHOinfo[ic - 10][itb][ifb][0];
2415 ieta = calibHOinfo[ic - 10][itb][ifb][1];
2416 if (ieta < 0) {
2417 iside = -1;
2418 sidesign = 'M';
2419 } else if (ieta > 0) {
2420 iside = 1;
2421 sidesign = 'P';
2422 } else {
2423 iside = 0;
2424 sidesign = '0';
2425 }
2426 if (ieta == -2)
2427 S_side = '2';
2428 else if (ieta == -1)
2429 S_side = '1';
2430 else if (ieta == 1)
2431 S_side = '1';
2432 else if (ieta == 2)
2433 S_side = '2';
2434
2435 subdet = "CALIB_" + det;
2436 if (ieta == 0)
2437 snprintf(tempbuff, sizeof tempbuff, "%s%c%2.2i", det.c_str(), sidesign, iwedge);
2438 else
2439 snprintf(tempbuff, sizeof tempbuff, "%s%c%c%2.2i", det.c_str(), S_side, sidesign, iwedge);
2440 mystream << tempbuff;
2441 rbx = mystream.str();
2442 mystream.str("");
2443
2444
2445
2446
2447 int NFCH_HO;
2448
2449 (ieta == -2) ? (iwedge == 12 ? NFCH_HO = 3 : NFCH_HO = 2) : (iwedge == 10) ? NFCH_HO = 3 : NFCH_HO = 2;
2450 for (ifc = 0; ifc < NFCH_HO; ifc++) {
2451 ifi_ch = ifc;
2452 (ifi_ch == 2) ? ich_type = 7 : ich_type = ifi_ch;
2453 (ieta == 0) ? idphi = 6 : idphi = 12;
2454
2455 (ieta == 0) ? iphi = ((iwedge * idphi) + 71 - idphi) % 72 : iphi = (((iwedge / 2) * idphi) + 71 - idphi) % 72;
2456
2457
2458 if (iside == 0 && ifb == 3)
2459 continue;
2460 CALIBLogicalMapEntry caliblmapentry(ifi_ch,
2461 ihtr_fi,
2462 ispigot,
2463 ifed,
2464 icrate,
2465 ihtr,
2466 fpga,
2467 det,
2468 ieta,
2469 iphi,
2470 ich_type,
2471 iside,
2472 idphi,
2473 rbx,
2474 iwedge,
2475 irm_fi,
2476 subdet);
2477 CALIBEntries.push_back(caliblmapentry);
2478 LinearIndex2Entry.at(caliblmapentry.getLinearIndex()) =
2479 HcalLogicalMap::makeEntryNumber(true, 2, CALIBEntries.size() - 1);
2480
2481 const HcalGenericDetId hgdi(caliblmapentry.getDetId());
2482 const unsigned int hashedId = topo->detId2denseIdCALIB(hgdi);
2483 if (hgdi.genericSubdet() == HcalGenericDetId::HcalGenCalibration)
2484 HxCalibHash2Entry.at(hashedId) = CALIBEntries.size();
2485
2486 }
2487 }
2488 }
2489 }
2490 }
2491
2492 void HcalLogicalMapGenerator::buildZDCMap(const HcalTopology* topo,
2493 std::vector<ZDCLogicalMapEntry>& ZDCEntries,
2494 std::vector<uint32_t>& LinearIndex2Entry,
2495 std::vector<uint32_t>& ZdcHash2Entry) {
2496
2497
2498
2499 stringstream mystream;
2500
2501 ifed = 722;
2502 iy = 1;
2503 ihtr = 8;
2504 icrate = 12;
2505 idcc = 1;
2506 idcc_sl = 10;
2507 ispigot = 12;
2508
2509 for (itb = 0; itb < NTOPBOT; itb++) {
2510 if (itb == 0) {
2511 iside = 1;
2512 irm = 1;
2513 fpga = "top";
2514 } else {
2515 iside = -1;
2516 irm = 2;
2517 if (mapIOV_ < 4) {
2518 fpga = "top";
2519 ispigot = 12;
2520 } else {
2521 fpga = "bot";
2522 ispigot = 13;
2523 }
2524 }
2525
2526 for (icab = 1; icab < NZDCCAB + 1; icab++) {
2527 if (icab < 4) {
2528 irm_fi = 1;
2529 iadc = icab - 1;
2530 ifi_ch = iadc;
2531 } else if (icab < 7) {
2532 irm_fi = 2;
2533 iadc = icab - 1;
2534 ifi_ch = iadc - 3;
2535 } else {
2536 irm_fi = 3;
2537 iadc = icab - 7;
2538 ifi_ch = iadc;
2539 }
2540 if (itb == 0) {
2541 ihtr_fi = irm_fi;
2542 } else {
2543 if (mapIOV_ < 4)
2544 ihtr_fi = irm_fi + 3;
2545 else
2546 ihtr_fi = irm_fi;
2547 }
2548 if (icab < 6) {
2549 ix = icab;
2550 idepth = 1;
2551 idx = 1;
2552 det = "ZDC_EM";
2553 idet_ch = ix;
2554 iqie = 1;
2555 } else {
2556 ix = 1;
2557 idepth = icab - 4;
2558 idx = 5;
2559 det = "ZDC_HAD";
2560 idet_ch = icab - 5;
2561 if (icab == 6)
2562 iqie = 1;
2563 else
2564 iqie = 2;
2565 }
2566 ZDCLogicalMapEntry zdclmapentry(ifi_ch,
2567 ihtr_fi,
2568 ispigot,
2569 ifed,
2570 icrate,
2571 ihtr,
2572 fpga,
2573 det,
2574 iside,
2575 idepth,
2576 ix,
2577 iy,
2578 idx,
2579 idet_ch,
2580 icab,
2581 irm,
2582 iqie,
2583 iadc,
2584 irm_fi);
2585 ZDCEntries.push_back(zdclmapentry);
2586 LinearIndex2Entry.at(zdclmapentry.getLinearIndex()) =
2587 HcalLogicalMap::makeEntryNumber(true, 3, ZDCEntries.size() - 1);
2588 }
2589 }
2590 }
2591
2592
2593 void HcalLogicalMapGenerator::ConstructTriggerTower(const HcalTopology* topo,
2594 std::vector<HTLogicalMapEntry>& HTEntries,
2595 int iside,
2596 int ieta,
2597 int iphi,
2598 int idphi,
2599 int idepth,
2600 std::string det,
2601 int iwedge,
2602 int irm,
2603 int ipixel,
2604 int iqie,
2605 int iadc,
2606 int irm_fi,
2607 int ifi_ch,
2608 int icrate,
2609 int ihtr,
2610 std::string fpga,
2611 int ihtr_fi,
2612 int ispigot,
2613 int islb,
2614 std::string slbin,
2615 std::string slbin2,
2616 std::string slnam,
2617 int irctcra,
2618 int irctcar,
2619 int irctcon,
2620 std::string rctnam,
2621 int ifed) {
2622 string t_chDet, t_fpga;
2623 string t_slnam, t_rctnam, t_slbin, t_slbin2;
2624
2625 int t_nDat = -1;
2626 int t_side, t_iEta, t_iPhi, t_jPhi, t_iDep, t_topbot;
2627 int t_wedge, t_crate, t_htr;
2628
2629 int t_spigo, t_slb, t_rctcra, t_rctcar, t_rctcon, t_fedid;
2630
2631
2632 (fpga == "bot") ? t_topbot = 1 : t_topbot = 0;
2633 t_side = iside;
2634 t_iEta = ieta;
2635 t_iPhi = iphi;
2636 t_jPhi = idphi;
2637 t_iDep = idepth;
2638 t_chDet = det;
2639 t_wedge = iwedge;
2640
2641
2642
2643
2644
2645
2646 t_crate = icrate;
2647 t_htr = ihtr;
2648 t_fpga = fpga;
2649
2650 t_spigo = ispigot;
2651 t_slb = islb;
2652 t_slbin = slbin;
2653 t_slbin2 = slbin2;
2654 t_slnam = slnam;
2655 t_rctcra = irctcra;
2656 t_rctcar = irctcar;
2657 t_rctcon = irctcon;
2658 t_rctnam = rctnam;
2659 t_fedid = ifed;
2660
2661 do {
2662 if (t_iDep != 1)
2663 break;
2664 if (t_chDet == "HE" && t_iEta == 29)
2665 break;
2666
2667 if (t_chDet == "HF") {
2668 t_jPhi = 4;
2669 if (t_iEta == 30 || t_iEta == 31 || t_iEta == 33 || t_iEta == 34 || t_iEta == 36 || t_iEta == 37 ||
2670 t_iEta == 39 || t_iEta == 40 || t_iEta == 41)
2671 break;
2672
2673 else if (t_iEta == 32)
2674 t_iEta = 30;
2675 else if (t_iEta == 35)
2676 t_iEta = 31;
2677 else if (t_iEta == 38)
2678 t_iEta = 32;
2679
2680 if (t_iPhi == 3 || t_iPhi == 7 || t_iPhi == 11 || t_iPhi == 15 || t_iPhi == 19 || t_iPhi == 23 || t_iPhi == 27 ||
2681 t_iPhi == 31 || t_iPhi == 35 || t_iPhi == 39 || t_iPhi == 43 || t_iPhi == 47 || t_iPhi == 51 ||
2682 t_iPhi == 55 || t_iPhi == 59 || t_iPhi == 63 || t_iPhi == 67 || t_iPhi == 71)
2683 break;
2684 }
2685
2686 if (t_side < 0)
2687 t_iEta = -t_iEta;
2688 t_chDet = "HT";
2689
2690 if (t_slbin != "NA") {
2691 if (t_slbin2 != "NA")
2692 t_jPhi = 1;
2693 if (t_slbin == "A0" || t_slbin == "B0")
2694 t_nDat = 0;
2695 else if (t_slbin == "A1" || t_slbin == "B1")
2696 t_nDat = 1;
2697 else if (t_slbin == "C0" || t_slbin == "D0")
2698 t_nDat = 2;
2699 else if (t_slbin == "C1" || t_slbin == "D1")
2700 t_nDat = 3;
2701
2702 HTLogicalMapEntry htlmapentry(t_iEta,
2703 t_iPhi,
2704 t_side,
2705 t_jPhi,
2706 t_iDep,
2707 t_chDet,
2708 t_wedge,
2709 t_crate,
2710 t_htr,
2711 t_topbot,
2712 t_spigo,
2713 t_slb,
2714 t_slbin,
2715 t_slbin2,
2716 t_nDat,
2717 t_slnam,
2718 t_rctcra,
2719 t_rctcar,
2720 t_rctcon,
2721 t_rctnam,
2722 t_fedid);
2723 HTEntries.push_back(htlmapentry);
2724 }
2725 if (t_slbin2 != "NA") {
2726 if (t_slbin2 == "A0" || t_slbin2 == "B0")
2727 t_nDat = 0;
2728 else if (t_slbin2 == "A1" || t_slbin2 == "B1")
2729 t_nDat = 1;
2730 else if (t_slbin2 == "C0" || t_slbin2 == "D0")
2731 t_nDat = 2;
2732 else if (t_slbin2 == "C1" || t_slbin2 == "D1")
2733 t_nDat = 3;
2734 t_jPhi = 1;
2735 t_iPhi += 1;
2736
2737 HTLogicalMapEntry htlmapentry(t_iEta,
2738 t_iPhi,
2739 t_side,
2740 t_jPhi,
2741 t_iDep,
2742 t_chDet,
2743 t_wedge,
2744 t_crate,
2745 t_htr,
2746 t_topbot,
2747 t_spigo,
2748 t_slb,
2749 t_slbin,
2750 t_slbin2,
2751 t_nDat,
2752 t_slnam,
2753 t_rctcra,
2754 t_rctcar,
2755 t_rctcon,
2756 t_rctnam,
2757 t_fedid);
2758 HTEntries.push_back(htlmapentry);
2759 }
2760 } while (1 != 1);
2761 }