Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:57:34

0001 //
0002 // F.Ratnikov (UMd), Dec 14, 2005
0003 // Adapted for Castor by L. Mundim
0004 //
0005 #include <vector>
0006 #include <string>
0007 
0008 #include "CLHEP/Random/RandGauss.h"
0009 #include "CondFormats/CastorObjects/interface/CastorElectronicsMap.h"
0010 #include "CalibCalorimetry/CastorCalib/interface/CastorDbHardcode.h"
0011 
0012 CastorPedestal CastorDbHardcode::makePedestal(HcalGenericDetId fId, bool fSmear) {
0013   CastorPedestalWidth width = makePedestalWidth(fId);
0014   float value0 = fId.genericSubdet() == HcalGenericDetId::HcalGenForward ? 11. : 4.;  // fC
0015   float value[4] = {value0, value0, value0, value0};
0016   if (fSmear) {
0017     for (int i = 0; i < 4; i++) {
0018       value[i] =
0019           CLHEP::RandGauss::shoot(value0, width.getWidth(i) / 100.);  // ignore correlations, assume 10K pedestal run
0020       while (value[i] <= 0)
0021         value[i] = CLHEP::RandGauss::shoot(value0, width.getWidth(i));
0022     }
0023   }
0024   CastorPedestal result(fId.rawId(), value[0], value[1], value[2], value[3]);
0025   return result;
0026 }
0027 
0028 CastorPedestalWidth CastorDbHardcode::makePedestalWidth(HcalGenericDetId fId) {
0029   float value = 0;
0030   /*
0031   if (fId.genericSubdet() == HcalGenericDetId::HcalGenBarrel || 
0032       fId.genericSubdet() == HcalGenericDetId::HcalGenOuter) value = 0.7;
0033   else if (fId.genericSubdet() == HcalGenericDetId::HcalGenEndcap) value = 0.9;
0034   else if (fId.genericSubdet() == HcalGenericDetId::HcalGenForward) value = 2.5;
0035   */
0036   // everything in fC
0037   CastorPedestalWidth result(fId.rawId());
0038   for (int i = 0; i < 4; i++) {
0039     double width = value;
0040     for (int j = 0; j < 4; j++) {
0041       result.setSigma(i, j, i == j ? width * width : 0);
0042     }
0043   }
0044   return result;
0045 }
0046 
0047 CastorGain CastorDbHardcode::makeGain(HcalGenericDetId fId, bool fSmear) {
0048   CastorGainWidth width = makeGainWidth(fId);
0049   float value0 = 0;
0050   if (fId.genericSubdet() != HcalGenericDetId::HcalGenForward)
0051     value0 = 0.177;  // GeV/fC
0052   else {
0053     if (HcalDetId(fId).depth() == 1)
0054       value0 = 0.2146;
0055     else if (HcalDetId(fId).depth() == 2)
0056       value0 = 0.3375;
0057   }
0058   float value[4] = {value0, value0, value0, value0};
0059   if (fSmear)
0060     for (int i = 0; i < 4; i++)
0061       value[i] = CLHEP::RandGauss::shoot(value0, width.getValue(i));
0062   CastorGain result(fId.rawId(), value[0], value[1], value[2], value[3]);
0063   return result;
0064 }
0065 
0066 CastorGainWidth CastorDbHardcode::makeGainWidth(HcalGenericDetId fId) {
0067   float value = 0;
0068   CastorGainWidth result(fId.rawId(), value, value, value, value);
0069   return result;
0070 }
0071 
0072 CastorQIECoder CastorDbHardcode::makeQIECoder(HcalGenericDetId fId) {
0073   CastorQIECoder result(fId.rawId());
0074   float offset = 0;
0075   float slope = fId.genericSubdet() == HcalGenericDetId::HcalGenForward ? 0.36 : 0.92;  // ADC/fC
0076   for (unsigned range = 0; range < 4; range++) {
0077     for (unsigned capid = 0; capid < 4; capid++) {
0078       result.setOffset(capid, range, offset);
0079       result.setSlope(capid, range, slope);
0080     }
0081   }
0082   return result;
0083 }
0084 
0085 CastorCalibrationQIECoder CastorDbHardcode::makeCalibrationQIECoder(HcalGenericDetId fId) {
0086   CastorCalibrationQIECoder result(fId.rawId());
0087   float lowEdges[32];
0088   for (int i = 0; i < 32; i++)
0089     lowEdges[i] = -1.5 + i * 0.35;
0090   result.setMinCharges(lowEdges);
0091   return result;
0092 }
0093 
0094 CastorQIEShape CastorDbHardcode::makeQIEShape() { return CastorQIEShape(); }
0095 
0096 CastorRecoParam CastorDbHardcode::makeRecoParam(HcalGenericDetId fId) {
0097   CastorRecoParam result(fId.rawId(), 4, 2);
0098   return result;
0099 }
0100 
0101 CastorSaturationCorr CastorDbHardcode::makeSaturationCorr(HcalGenericDetId fId) {
0102   CastorSaturationCorr result(fId.rawId(), 1);
0103   return result;
0104 }
0105 
0106 #define EMAP_NHBHECR 9
0107 #define EMAP_NHFCR 3
0108 #define EMAP_NHOCR 4
0109 #define EMAP_NFBR 8
0110 #define EMAP_NFCH 3
0111 #define EMAP_NHTRS 3
0112 #define EMAP_NHSETS 4
0113 #define EMAP_NTOPBOT 2
0114 #define EMAP_NHTRSHO 4
0115 #define EMAP_NHSETSHO 3
0116 
0117 void CastorDbHardcode::makeHardcodeMap(CastorElectronicsMap& emap) {
0118   /* HBHE crate numbering */
0119   int hbhecrate[EMAP_NHBHECR] = {0, 1, 4, 5, 10, 11, 14, 15, 17};
0120   /* HF crate numbering */
0121   int hfcrate[EMAP_NHFCR] = {2, 9, 12};
0122   /* HO crate numbering */
0123   int hocrate[EMAP_NHOCR] = {3, 7, 6, 13};
0124   /* HBHE FED numbering of DCCs */
0125   int fedhbhenum[EMAP_NHBHECR][2] = {
0126       {702, 703}, {704, 705}, {700, 701}, {706, 707}, {716, 717}, {708, 709}, {714, 715}, {710, 711}, {712, 713}};
0127   /* HF FED numbering of DCCs */
0128   int fedhfnum[EMAP_NHFCR][2] = {{718, 719}, {720, 721}, {722, 723}};
0129   /* HO FED numbering of DCCs */
0130   int fedhonum[EMAP_NHOCR][2] = {{724, 725}, {726, 727}, {728, 729}, {730, 731}};
0131   /* HBHE/HF htr slot offsets for set of three htrs */
0132   int ihslot[EMAP_NHSETS] = {2, 5, 13, 16};
0133   /* HO htr slot offsets for three sets of four htrs */
0134   int ihslotho[EMAP_NHSETSHO][EMAP_NHTRSHO] = {{2, 3, 4, 5}, {6, 7, 13, 14}, {15, 16, 17, 18}};
0135   /* iphi (lower) starting index for each HBHE crate */
0136   int ihbhephis[EMAP_NHBHECR] = {11, 19, 3, 27, 67, 35, 59, 43, 51};
0137   /* iphi (lower) starting index for each HF crate */
0138   int ihfphis[EMAP_NHFCR] = {3, 27, 51};
0139   /* iphi (lower) starting index for each HO crate */
0140   int ihophis[EMAP_NHOCR] = {71, 17, 35, 53};
0141   /* ihbheetadepth - unique HBHE {eta,depth} assignments per fiber and fiber channel */
0142   int ihbheetadepth[EMAP_NHTRS][EMAP_NTOPBOT][EMAP_NFBR][EMAP_NFCH][2] = {
0143       {{{{11, 1}, {7, 1}, {3, 1}}, /* htr 0 (HB) -bot(+top) */
0144         {{5, 1}, {1, 1}, {9, 1}},
0145         {{11, 1}, {7, 1}, {3, 1}},
0146         {{5, 1}, {1, 1}, {9, 1}},
0147         {{10, 1}, {6, 1}, {2, 1}},
0148         {{8, 1}, {4, 1}, {12, 1}},
0149         {{10, 1}, {6, 1}, {2, 1}},
0150         {{8, 1}, {4, 1}, {12, 1}}},
0151        {{{11, 1}, {7, 1}, {3, 1}}, /* htr 0 (HB) +bot(-top) */
0152         {{5, 1}, {1, 1}, {9, 1}},
0153         {{11, 1}, {7, 1}, {3, 1}},
0154         {{5, 1}, {1, 1}, {9, 1}},
0155         {{10, 1}, {6, 1}, {2, 1}},
0156         {{8, 1}, {4, 1}, {12, 1}},
0157         {{10, 1}, {6, 1}, {2, 1}},
0158         {{8, 1}, {4, 1}, {12, 1}}}},
0159       {{{{16, 2}, {15, 2}, {14, 1}}, /* htr 1 (HBHE) -bot(+top) */
0160         {{15, 1}, {13, 1}, {16, 1}},
0161         {{16, 2}, {15, 2}, {14, 1}},
0162         {{15, 1}, {13, 1}, {16, 1}},
0163         {{17, 1}, {16, 3}, {26, 1}},
0164         {{18, 1}, {18, 2}, {26, 2}},
0165         {{17, 1}, {16, 3}, {25, 1}},
0166         {{18, 1}, {18, 2}, {25, 2}}},
0167        {{{16, 2}, {15, 2}, {14, 1}}, /* htr 1 (HBHE) +bot(-top) */
0168         {{15, 1}, {13, 1}, {16, 1}},
0169         {{16, 2}, {15, 2}, {14, 1}},
0170         {{15, 1}, {13, 1}, {16, 1}},
0171         {{17, 1}, {16, 3}, {25, 1}},
0172         {{18, 1}, {18, 2}, {25, 2}},
0173         {{17, 1}, {16, 3}, {26, 1}},
0174         {{18, 1}, {18, 2}, {26, 2}}}},
0175       {{{{28, 1}, {28, 2}, {29, 1}}, /* htr 2 (HE) -bot(+top) */
0176         {{28, 3}, {24, 2}, {24, 1}},
0177         {{27, 1}, {27, 2}, {29, 2}},
0178         {{27, 3}, {23, 2}, {23, 1}},
0179         {{19, 2}, {20, 1}, {22, 2}},
0180         {{19, 1}, {20, 2}, {22, 1}},
0181         {{19, 2}, {20, 1}, {21, 2}},
0182         {{19, 1}, {20, 2}, {21, 1}}},
0183        {{{27, 1}, {27, 2}, {29, 2}}, /* htr 2 (HE) +bot(-top) */
0184         {{27, 3}, {23, 2}, {23, 1}},
0185         {{28, 1}, {28, 2}, {29, 1}},
0186         {{28, 3}, {24, 2}, {24, 1}},
0187         {{19, 2}, {20, 1}, {21, 2}},
0188         {{19, 1}, {20, 2}, {21, 1}},
0189         {{19, 2}, {20, 1}, {22, 2}},
0190         {{19, 1}, {20, 2}, {22, 1}}}}};
0191   /* ihfetadepth - unique HF {eta,depth} assignments per fiber and fiber channel */
0192   int ihfetadepth[EMAP_NTOPBOT][EMAP_NFBR][EMAP_NFCH][2] = {{{{33, 1}, {31, 1}, {29, 1}}, /* top */
0193                                                              {{32, 1}, {30, 1}, {34, 1}},
0194                                                              {{33, 2}, {31, 2}, {29, 2}},
0195                                                              {{32, 2}, {30, 2}, {34, 2}},
0196                                                              {{34, 2}, {32, 2}, {30, 2}},
0197                                                              {{31, 2}, {29, 2}, {33, 2}},
0198                                                              {{34, 1}, {32, 1}, {30, 1}},
0199                                                              {{31, 1}, {29, 1}, {33, 1}}},
0200                                                             {{{41, 1}, {37, 1}, {35, 1}}, /* bot */
0201                                                              {{38, 1}, {36, 1}, {39, 1}},
0202                                                              {{41, 2}, {37, 2}, {35, 2}},
0203                                                              {{38, 2}, {36, 2}, {39, 2}},
0204                                                              {{40, 2}, {38, 2}, {36, 2}},
0205                                                              {{37, 2}, {35, 2}, {39, 2}},
0206                                                              {{40, 1}, {38, 1}, {36, 1}},
0207                                                              {{37, 1}, {35, 1}, {39, 1}}}};
0208   /* ihoetasidephi - unique HO {eta,side,phi} assignments per fiber and fiber channel */
0209   int ihoetasidephi[EMAP_NHTRSHO][EMAP_NTOPBOT][EMAP_NFBR][EMAP_NFCH][3] = {
0210       {{{{1, -1, 0}, {2, -1, 0}, {3, -1, 0}}, /* htr 0 (HO) top */
0211         {{1, -1, 1}, {2, -1, 1}, {3, -1, 1}},
0212         {{1, -1, 2}, {2, -1, 2}, {3, -1, 2}},
0213         {{1, -1, 3}, {2, -1, 3}, {3, -1, 3}},
0214         {{1, -1, 4}, {2, -1, 4}, {3, -1, 4}},
0215         {{1, -1, 5}, {2, -1, 5}, {3, -1, 5}},
0216         {{14, 1, 0}, {14, 1, 1}, {14, 1, 2}},
0217         {{14, 1, 3}, {14, 1, 4}, {14, 1, 5}}},
0218        {{{1, 1, 0}, {2, 1, 0}, {3, 1, 0}}, /* htr 0 (HO) bot */
0219         {{1, 1, 1}, {2, 1, 1}, {3, 1, 1}},
0220         {{1, 1, 2}, {2, 1, 2}, {3, 1, 2}},
0221         {{1, 1, 3}, {2, 1, 3}, {3, 1, 3}},
0222         {{1, 1, 4}, {2, 1, 4}, {3, 1, 4}},
0223         {{1, 1, 5}, {2, 1, 5}, {3, 1, 5}},
0224         {{15, 1, 0}, {15, 1, 1}, {15, 1, 2}},
0225         {{15, 1, 3}, {15, 1, 4}, {15, 1, 5}}}},
0226       {{{{6, 1, 0}, {6, 1, 1}, {6, 1, 2}}, /* htr 1 (HO) top */
0227         {{6, 1, 3}, {6, 1, 4}, {6, 1, 5}},
0228         {{7, 1, 0}, {7, 1, 1}, {7, 1, 2}},
0229         {{7, 1, 3}, {7, 1, 4}, {7, 1, 5}},
0230         {{8, 1, 0}, {8, 1, 1}, {8, 1, 2}},
0231         {{8, 1, 3}, {8, 1, 4}, {8, 1, 5}},
0232         {{9, 1, 0}, {9, 1, 1}, {9, 1, 2}},
0233         {{9, 1, 3}, {9, 1, 4}, {9, 1, 5}}},
0234        {{{10, 1, 0}, {10, 1, 1}, {10, 1, 2}}, /* htr 1 (HO) bot */
0235         {{10, 1, 3}, {10, 1, 4}, {10, 1, 5}},
0236         {{11, 1, 0}, {11, 1, 1}, {11, 1, 2}},
0237         {{11, 1, 3}, {11, 1, 4}, {11, 1, 5}},
0238         {{12, 1, 0}, {12, 1, 1}, {12, 1, 2}},
0239         {{12, 1, 3}, {12, 1, 4}, {12, 1, 5}},
0240         {{13, 1, 0}, {13, 1, 1}, {13, 1, 2}},
0241         {{13, 1, 3}, {13, 1, 4}, {13, 1, 5}}}},
0242       {{{{4, -1, 0}, {4, -1, 1}, {0, 0, 0}}, /* htr 2 (HO) top */
0243         {{4, -1, 2}, {4, -1, 3}, {0, 0, 0}},
0244         {{4, -1, 4}, {4, -1, 5}, {0, 0, 0}},
0245         {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}},
0246         {{5, -1, 0}, {5, -1, 1}, {5, -1, 2}},
0247         {{5, -1, 3}, {5, -1, 4}, {5, -1, 5}},
0248         {{14, -1, 0}, {14, -1, 1}, {14, -1, 2}},
0249         {{14, -1, 3}, {14, -1, 4}, {14, -1, 5}}},
0250        {{{4, 1, 0}, {4, 1, 1}, {0, 0, 0}}, /* htr 2 (HO) bot */
0251         {{4, 1, 2}, {4, 1, 3}, {0, 0, 0}},
0252         {{4, 1, 4}, {4, 1, 5}, {0, 0, 0}},
0253         {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}},
0254         {{5, 1, 0}, {5, 1, 1}, {5, 1, 2}},
0255         {{5, 1, 3}, {5, 1, 4}, {5, 1, 5}},
0256         {{15, -1, 0}, {15, -1, 1}, {15, -1, 2}},
0257         {{15, -1, 3}, {15, -1, 4}, {15, -1, 5}}}},
0258       {{{{6, -1, 0}, {6, -1, 1}, {6, -1, 2}}, /* htr 3 (HO) top */
0259         {{6, -1, 3}, {6, -1, 4}, {6, -1, 5}},
0260         {{7, -1, 0}, {7, -1, 1}, {7, -1, 2}},
0261         {{7, -1, 3}, {7, -1, 4}, {7, -1, 5}},
0262         {{8, -1, 0}, {8, -1, 1}, {8, -1, 2}},
0263         {{8, -1, 3}, {8, -1, 4}, {8, -1, 5}},
0264         {{9, -1, 0}, {9, -1, 1}, {9, -1, 2}},
0265         {{9, -1, 3}, {9, -1, 4}, {9, -1, 5}}},
0266        {{{10, -1, 0}, {10, -1, 1}, {10, -1, 2}}, /* htr 3 (HO) bot */
0267         {{10, -1, 3}, {10, -1, 4}, {10, -1, 5}},
0268         {{11, -1, 0}, {11, -1, 1}, {11, -1, 2}},
0269         {{11, -1, 3}, {11, -1, 4}, {11, -1, 5}},
0270         {{12, -1, 0}, {12, -1, 1}, {12, -1, 2}},
0271         {{12, -1, 3}, {12, -1, 4}, {12, -1, 5}},
0272         {{13, -1, 0}, {13, -1, 1}, {13, -1, 2}},
0273         {{13, -1, 3}, {13, -1, 4}, {13, -1, 5}}}}};
0274   int ic, is, ih, itb, ifb, ifc, ifwtb, iphi_loc;
0275   int iside, ieta, iphi, idepth, icrate, ihtr, ihtr_fi, ifi_ch, ispigot, idcc, /*idcc_sl,*/ ifed;
0276   std::string det;
0277   std::string fpga;
0278   // printf("      side       eta       phi     depth       det     crate       htr      fpga    htr_fi     fi_ch     spigo       dcc    dcc_sl     fedid\n");
0279   /* all HBHE crates */
0280   for (ic = 0; ic < EMAP_NHBHECR; ic++) {
0281     /* four sets of three htrs per crate */
0282     for (is = 0; is < EMAP_NHSETS; is++) {
0283       /* three htrs per set */
0284       for (ih = 0; ih < EMAP_NHTRS; ih++) {
0285         /* top and bottom */
0286         for (itb = 0; itb < EMAP_NTOPBOT; itb++) {
0287           /* eight fibers per HTR FPGA */
0288           for (ifb = 0; ifb < EMAP_NFBR; ifb++) {
0289             /* three channels per fiber */
0290             for (ifc = 0; ifc < EMAP_NFCH; ifc++) {
0291               icrate = hbhecrate[ic];
0292               iside = is < EMAP_NHSETS / 2 ? -1 : 1;
0293               ifwtb = (is / 2 + itb + 1) % 2;
0294               ieta = ihbheetadepth[ih][ifwtb][ifb][ifc][0];
0295               idepth = ihbheetadepth[ih][ifwtb][ifb][ifc][1];
0296               ihtr = ihslot[is] + ih;
0297               det = ((ieta > 16 || idepth > 2) ? ("HE") : ("HB"));
0298               fpga = ((itb % 2) == 1) ? ("bot") : ("top");
0299               ihtr_fi = ifb + 1;
0300               ifi_ch = ifc;
0301               iphi = (ieta > 20) ? (ihbhephis[ic] + (is % 2) * 4 + itb * 2 - 1) % 72 + 1
0302                                  : (ihbhephis[ic] + (is % 2) * 4 + itb * 2 + (ifb / 2 + is / 2 + 1) % 2 - 1) % 72 + 1;
0303               ispigot = (is % 2) * 6 + ih * 2 + itb;
0304               idcc = is < EMAP_NHSETS / 2 ? 1 : 2;
0305               //idcc_sl=idcc==1?9:19;
0306               ifed = fedhbhenum[ic][idcc - 1];
0307               /// load map
0308               CastorElectronicsId elId(ifi_ch, ihtr_fi, ispigot, ifed - 700);
0309               elId.setHTR(icrate, ihtr, (fpga == "top") ? (1) : (0));
0310               HcalDetId hId((det == "HB") ? (HcalBarrel) : (HcalEndcap), ieta * iside, iphi, idepth);
0311               emap.mapEId2chId(elId, hId);
0312 
0313               //          printf(" %9d %9d %9d %9d %9s %9d %9d %9s %9d %9d %9d %9d %9d %9d\n",iside,ieta,iphi,idepth,&det,icrate,ihtr,&fpga,ihtr_fi,ifi_ch,ispigot,idcc,idcc_sl,ifed);
0314             }
0315           }
0316         }
0317       }
0318     }
0319   }
0320   /* all HF crates */
0321   for (ic = 0; ic < EMAP_NHFCR; ic++) {
0322     /* four sets of three htrs per crate */
0323     for (is = 0; is < EMAP_NHSETS; is++) {
0324       /* three htrs per set */
0325       for (ih = 0; ih < EMAP_NHTRS; ih++) {
0326         /* top and bottom */
0327         for (itb = 0; itb < EMAP_NTOPBOT; itb++) {
0328           /* eight fibers per HTR FPGA */
0329           for (ifb = 0; ifb < EMAP_NFBR; ifb++) {
0330             /* three channels per fiber */
0331             for (ifc = 0; ifc < EMAP_NFCH; ifc++) {
0332               icrate = hfcrate[ic];
0333               iside = is < EMAP_NHSETS / 2 ? -1 : 1;
0334               ieta = ihfetadepth[itb][ifb][ifc][0];
0335               idepth = ihfetadepth[itb][ifb][ifc][1];
0336               ihtr = ihslot[is] + ih;
0337               det = "HF";
0338               fpga = ((itb % 2) == 1) ? ("bot") : ("top");
0339               ihtr_fi = ifb + 1;
0340               ifi_ch = ifc;
0341               iphi = (ieta > 39) ? (ihfphis[ic] + (is % 2) * 12 + ih * 4 - 3) % 72 + 1
0342                                  : (ihfphis[ic] + (is % 2) * 12 + ih * 4 + (ifb / 4) * 2 - 1) % 72 + 1;
0343               ispigot = (is % 2) * 6 + ih * 2 + itb;
0344               idcc = is < EMAP_NHSETS / 2 ? 1 : 2;
0345               //idcc_sl=idcc==1?9:19;
0346               ifed = fedhfnum[ic][idcc - 1];
0347               CastorElectronicsId elId(ifi_ch, ihtr_fi, ispigot, ifed - 700);
0348               elId.setHTR(icrate, ihtr, (fpga == "top") ? (1) : (0));
0349               HcalDetId hId(HcalForward, ieta * iside, iphi, idepth);
0350               emap.mapEId2chId(elId, hId);
0351               // printf(" %9d %9d %9d %9d %9s %9d %9d %9s %9d %9d %9d %9d %9d %9d\n",iside,ieta,iphi,idepth,&det,icrate,ihtr,&fpga,ihtr_fi,ifi_ch,ispigot,idcc,idcc_sl,ifed);
0352             }
0353           }
0354         }
0355       }
0356     }
0357   }
0358   /* all HO crates */
0359   for (ic = 0; ic < EMAP_NHOCR; ic++) {
0360     /* three sets of four htrs per crate */
0361     for (is = 0; is < EMAP_NHSETSHO; is++) {
0362       /* four htrs per set */
0363       for (ih = 0; ih < EMAP_NHTRSHO; ih++) {
0364         /* top and bottom */
0365         for (itb = 0; itb < EMAP_NTOPBOT; itb++) {
0366           /* eight fibers per HTR FPGA */
0367           for (ifb = 0; ifb < EMAP_NFBR; ifb++) {
0368             /* three channels per fiber */
0369             for (ifc = 0; ifc < EMAP_NFCH; ifc++) {
0370               icrate = hocrate[ic];
0371               idepth = 1;
0372               ieta = ihoetasidephi[ih][itb][ifb][ifc][0];
0373               iside = ihoetasidephi[ih][itb][ifb][ifc][1];
0374               iphi_loc = ihoetasidephi[ih][itb][ifb][ifc][2];
0375               ihtr = ihslotho[is][ih];
0376               det = "HO";
0377               fpga = ((itb % 2) == 1) ? ("bot") : ("top");
0378               ihtr_fi = ifb + 1;
0379               ifi_ch = ifc;
0380               iphi = (ihophis[ic] + is * 6 + iphi_loc - 1) % 72 + 1;
0381               ispigot = ihtr < 9 ? (ihtr - 2) * 2 + itb : (ihtr - 13) * 2 + itb;
0382               idcc = ihtr < 9 ? 1 : 2;
0383               //idcc_sl=idcc==1?9:19;
0384               ifed = fedhonum[ic][idcc - 1];
0385               CastorElectronicsId elId(ifi_ch, ihtr_fi, ispigot, ifed - 700);
0386               elId.setHTR(icrate, ihtr, (fpga == "top") ? (1) : (0));
0387               if (ieta == 0) {  // unmapped
0388                 emap.mapEId2chId(elId, DetId(HcalDetId::Undefined));
0389               } else {
0390                 HcalDetId hId(HcalOuter, ieta * iside, iphi, 4);  // HO is officially "depth=4"
0391                 emap.mapEId2chId(elId, hId);
0392               }
0393               // printf(" %9d %9d %9d %9d %9s %9d %9d %9s %9d %9d %9d %9d %9d %9d\n",iside,ieta,iphi,idepth,&det,icrate,ihtr,&fpga,ihtr_fi,ifi_ch,ispigot,idcc,idcc_sl,ifed);
0394             }
0395           }
0396         }
0397       }
0398     }
0399   }
0400 
0401   emap.sort();
0402 }