Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:14:51

0001 #include "Geometry/HcalTowerAlgo/interface/HcalHardcodeGeometryLoader.h"
0002 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
0003 #include "Geometry/CaloGeometry/interface/IdealObliquePrism.h"
0004 #include "Geometry/CaloGeometry/interface/IdealZPrism.h"
0005 #include "Geometry/HcalTowerAlgo/interface/HcalGeometry.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 
0008 #include <algorithm>
0009 #include <vector>
0010 #include <sstream>
0011 
0012 using CCGFloat = CaloCellGeometry::CCGFloat;
0013 //#define EDM_ML_DEBUG
0014 // ==============> Loader Itself <==========================
0015 
0016 HcalHardcodeGeometryLoader::HcalHardcodeGeometryLoader() {
0017   MAX_HCAL_PHI = 72;
0018   DEGREE2RAD = M_PI / 180.;
0019 #ifdef EDM_ML_DEBUG
0020   edm::LogVerbatim("HCalGeom") << "Instantiate HcalHardCodeGeometryLoader";
0021 #endif
0022 }
0023 
0024 CaloSubdetectorGeometry* HcalHardcodeGeometryLoader::load(const HcalTopology& fTopology) {
0025   int maxEta = fTopology.lastHERing();
0026   m_segmentation.resize(maxEta);
0027   for (int i = 0; i < maxEta; i++) {
0028     fTopology.getDepthSegmentation(i + 1, m_segmentation[i]);
0029 #ifdef EDM_ML_DEBUG
0030     std::ostringstream st1;
0031     st1 << "Eta" << i + 1;
0032     for (unsigned int k = 0; k < m_segmentation[i].size(); ++k) {
0033       st1 << " [" << k << "] " << m_segmentation[i][k];
0034     }
0035     edm::LogVerbatim("HCalGeom") << st1.str();
0036 #endif
0037   }
0038   HcalGeometry* hcalGeometry = new HcalGeometry(fTopology);
0039   if (nullptr == hcalGeometry->cornersMgr())
0040     hcalGeometry->allocateCorners(fTopology.ncells() + fTopology.getHFSize());
0041   if (nullptr == hcalGeometry->parMgr())
0042     hcalGeometry->allocatePar(hcalGeometry->numberOfShapes(), HcalGeometry::k_NumberOfParametersPerShape);
0043   if (fTopology.mode() == HcalTopologyMode::H2) {  // TB geometry
0044     fillHBHO(hcalGeometry, makeHBCells(fTopology), true);
0045     fillHBHO(hcalGeometry, makeHOCells(), false);
0046     fillHE(hcalGeometry, makeHECells_H2());
0047   } else {  // regular geometry
0048     fillHBHO(hcalGeometry, makeHBCells(fTopology), true);
0049     fillHBHO(hcalGeometry, makeHOCells(), false);
0050     fillHF(hcalGeometry, makeHFCells());
0051     fillHE(hcalGeometry, makeHECells(fTopology));
0052   }
0053   //fast insertion of valid ids requires sort at end
0054   hcalGeometry->sortValidIds();
0055   return hcalGeometry;
0056 }
0057 
0058 // ----------> HB <-----------
0059 std::vector<HcalHardcodeGeometryLoader::HBHOCellParameters> HcalHardcodeGeometryLoader::makeHBCells(
0060     const HcalTopology& topology) {
0061   const float HBRMIN = 181.1;
0062   const float HBRMAX = 288.8;
0063 
0064   float normalDepths[2] = {HBRMIN, HBRMAX};
0065   float ring15Depths[3] = {HBRMIN, 258.4, HBRMAX};
0066   float ring16Depths[3] = {HBRMIN, 190.4, 232.6};
0067   float layerDepths[18] = {HBRMIN,
0068                            188.7,
0069                            194.7,
0070                            200.7,
0071                            206.7,
0072                            212.7,
0073                            218.7,
0074                            224.7,
0075                            230.7,
0076                            236.7,
0077                            242.7,
0078                            249.3,
0079                            255.9,
0080                            262.5,
0081                            269.1,
0082                            275.7,
0083                            282.3,
0084                            HBRMAX};
0085   float slhcDepths[4] = {HBRMIN, 214., 239., HBRMAX};
0086 #ifdef EDM_ML_DEBUG
0087   edm::LogVerbatim("HCalGeom") << "FlexiGeometryLoader called for " << topology.mode() << ":" << HcalTopologyMode::SLHC;
0088 #endif
0089   std::vector<HcalHardcodeGeometryLoader::HBHOCellParameters> result;
0090   for (int iring = 1; iring <= 16; ++iring) {
0091     std::vector<float> depths;
0092     if (topology.mode() != HcalTopologyMode::SLHC) {
0093       if (iring == 15) {
0094         for (float ring15Depth : ring15Depths)
0095           depths.emplace_back(ring15Depth);
0096       } else if (iring == 16) {
0097         for (float ring16Depth : ring16Depths)
0098           depths.emplace_back(ring16Depth);
0099       } else {
0100         for (float normalDepth : normalDepths)
0101           depths.emplace_back(normalDepth);
0102       }
0103     } else {
0104       if (m_segmentation.size() >= (unsigned int)(iring)) {
0105         int depth = m_segmentation[iring - 1][0];
0106         depths.emplace_back(layerDepths[depth]);
0107         int layer = 1;
0108         for (unsigned int i = 1; i < m_segmentation[iring - 1].size(); ++i) {
0109           if (depth != m_segmentation[iring - 1][i]) {
0110             depth = m_segmentation[iring - 1][i];
0111             layer = i;
0112             if (iring != 16 || depth < 3)
0113               depths.emplace_back(layerDepths[depth]);
0114           }
0115           if (i >= 17)
0116             break;
0117         }
0118         if (layer <= 17)
0119           depths.emplace_back(HBRMAX);
0120       } else {
0121         for (int i = 0; i < 4; ++i) {
0122           if (iring != 16 || i < 3) {
0123             depths.emplace_back(slhcDepths[i]);
0124           }
0125         }
0126       }
0127     }
0128     unsigned int ndepth = depths.size() - 1;
0129     unsigned int startingDepth = 1;
0130     float etaMin = (iring - 1) * 0.087;
0131     float etaMax = iring * 0.087;
0132     // topology.depthBinInformation(HcalBarrel, iring, ndepth, startingDepth);
0133 #ifdef EDM_ML_DEBUG
0134     std::ostringstream st2;
0135     st2 << "HBRing " << iring << " eta " << etaMin << ":" << etaMax << " depths " << ndepth << ":" << startingDepth;
0136     for (unsigned int i = 0; i < depths.size(); ++i)
0137       st2 << ":" << depths[i];
0138     edm::LogVerbatim("HCalGeom") << st2.str();
0139 #endif
0140     for (unsigned int idepth = startingDepth; idepth <= ndepth; ++idepth) {
0141       float rmin = depths[idepth - 1];
0142       float rmax = depths[idepth];
0143 #ifdef EDM_ML_DEBUG
0144       edm::LogVerbatim("HCalGeom") << "HB " << idepth << " R " << rmin << ":" << rmax;
0145 #endif
0146       result.emplace_back(
0147           HcalHardcodeGeometryLoader::HBHOCellParameters(iring, (int)idepth, 1, 1, 5, rmin, rmax, etaMin, etaMax));
0148     }
0149   }
0150   return result;
0151 }
0152 
0153 // ----------> HO <-----------
0154 std::vector<HcalHardcodeGeometryLoader::HBHOCellParameters> HcalHardcodeGeometryLoader::makeHOCells() {
0155   const float HORMIN0 = 390.0;
0156   const float HORMIN1 = 412.6;
0157   const float HORMAX = 413.6;
0158 
0159   HcalHardcodeGeometryLoader::HBHOCellParameters cells[] = {
0160       // eta, depth, firstPhi, stepPhi, deltaPhi, rMin, rMax, etaMin, etaMax
0161       HcalHardcodeGeometryLoader::HBHOCellParameters(1, 4, 1, 1, 5, HORMIN0, HORMAX, 0.087 * 0, 0.087 * 1),
0162       HcalHardcodeGeometryLoader::HBHOCellParameters(2, 4, 1, 1, 5, HORMIN0, HORMAX, 0.087 * 1, 0.087 * 2),
0163       HcalHardcodeGeometryLoader::HBHOCellParameters(3, 4, 1, 1, 5, HORMIN0, HORMAX, 0.087 * 2, 0.087 * 3),
0164       HcalHardcodeGeometryLoader::HBHOCellParameters(4, 4, 1, 1, 5, HORMIN0, HORMAX, 0.087 * 3, 0.3075),
0165       HcalHardcodeGeometryLoader::HBHOCellParameters(5, 4, 1, 1, 5, HORMIN1, HORMAX, 0.3395, 0.087 * 5),
0166       HcalHardcodeGeometryLoader::HBHOCellParameters(6, 4, 1, 1, 5, HORMIN1, HORMAX, 0.087 * 5, 0.087 * 6),
0167       HcalHardcodeGeometryLoader::HBHOCellParameters(7, 4, 1, 1, 5, HORMIN1, HORMAX, 0.087 * 6, 0.087 * 7),
0168       HcalHardcodeGeometryLoader::HBHOCellParameters(8, 4, 1, 1, 5, HORMIN1, HORMAX, 0.087 * 7, 0.087 * 8),
0169       HcalHardcodeGeometryLoader::HBHOCellParameters(9, 4, 1, 1, 5, HORMIN1, HORMAX, 0.087 * 8, 0.087 * 9),
0170       HcalHardcodeGeometryLoader::HBHOCellParameters(10, 4, 1, 1, 5, HORMIN1, HORMAX, 0.087 * 9, 0.8494),
0171       HcalHardcodeGeometryLoader::HBHOCellParameters(11, 4, 1, 1, 5, HORMIN1, HORMAX, 0.873, 0.087 * 11),
0172       HcalHardcodeGeometryLoader::HBHOCellParameters(12, 4, 1, 1, 5, HORMIN1, HORMAX, 0.087 * 11, 0.087 * 12),
0173       HcalHardcodeGeometryLoader::HBHOCellParameters(13, 4, 1, 1, 5, HORMIN1, HORMAX, 0.087 * 12, 0.087 * 13),
0174       HcalHardcodeGeometryLoader::HBHOCellParameters(14, 4, 1, 1, 5, HORMIN1, HORMAX, 0.087 * 13, 0.087 * 14),
0175       HcalHardcodeGeometryLoader::HBHOCellParameters(15, 4, 1, 1, 5, HORMIN1, HORMAX, 0.087 * 14, 0.087 * 15)};
0176   int nCells = sizeof(cells) / sizeof(HcalHardcodeGeometryLoader::HBHOCellParameters);
0177   std::vector<HcalHardcodeGeometryLoader::HBHOCellParameters> result;
0178   result.reserve(nCells);
0179   for (int i = 0; i < nCells; ++i)
0180     result.emplace_back(cells[i]);
0181   return result;
0182 }
0183 
0184 //
0185 // Convert constants to appropriate cells
0186 //
0187 void HcalHardcodeGeometryLoader::fillHBHO(HcalGeometry* fGeometry,
0188                                           const std::vector<HcalHardcodeGeometryLoader::HBHOCellParameters>& fCells,
0189                                           bool fHB) {
0190   fGeometry->increaseReserve(fCells.size());
0191   for (const auto& param : fCells) {
0192     for (int iPhi = param.phiFirst; iPhi <= MAX_HCAL_PHI; iPhi += param.phiStep) {
0193       for (int iside = -1; iside <= 1; iside += 2) {  // both detector sides are identical
0194         HcalDetId hid(fHB ? HcalBarrel : HcalOuter, param.eta * iside, iPhi, param.depth);
0195         float phiCenter = ((iPhi - 1) * 360. / MAX_HCAL_PHI + 0.5 * param.dphi) * DEGREE2RAD;  // middle of the cell
0196         float etaCenter = 0.5 * (param.etaMin + param.etaMax);
0197         float x = param.rMin * cos(phiCenter);
0198         float y = param.rMin * sin(phiCenter);
0199         float z = iside * param.rMin * sinh(etaCenter);
0200         // make cell geometry
0201         GlobalPoint refPoint(x, y, z);  // center of the cell's face
0202         std::vector<CCGFloat> cellParams;
0203         cellParams.reserve(5);
0204         cellParams.emplace_back(0.5 * (param.etaMax - param.etaMin));                // deta_half
0205         cellParams.emplace_back(0.5 * param.dphi * DEGREE2RAD);                      // dphi_half
0206         cellParams.emplace_back(0.5 * (param.rMax - param.rMin) * cosh(etaCenter));  // dr_half
0207         cellParams.emplace_back(fabs(refPoint.eta()));
0208         cellParams.emplace_back(fabs(refPoint.z()));
0209 #ifdef EDM_ML_DEBUG
0210         edm::LogVerbatim("HCalGeom") << "HcalHardcodeGeometryLoader::fillHBHO-> " << hid << hid.ieta() << '/'
0211                                      << hid.iphi() << '/' << hid.depth() << refPoint << '/' << cellParams[0] << '/'
0212                                      << cellParams[1] << '/' << cellParams[2];
0213 #endif
0214         fGeometry->newCellFast(refPoint,
0215                                refPoint,
0216                                refPoint,
0217                                CaloCellGeometry::getParmPtr(cellParams, fGeometry->parMgr(), fGeometry->parVecVec()),
0218                                hid);
0219       }
0220     }
0221   }
0222 }
0223 
0224 // ----------> HE <-----------
0225 std::vector<HcalHardcodeGeometryLoader::HECellParameters> HcalHardcodeGeometryLoader::makeHECells(
0226     const HcalTopology& topology) {
0227   std::vector<HcalHardcodeGeometryLoader::HECellParameters> result;
0228   const float HEZMIN = 400.458;
0229   const float HEZMID = 436.168;
0230   const float HEZMAX = 549.268;
0231   float normalDepths[3] = {HEZMIN, HEZMID, HEZMAX};
0232   float tripleDepths[4] = {HEZMIN, 418.768, HEZMID, HEZMAX};
0233   float slhcDepths[5] = {HEZMIN, 418.768, HEZMID, 493., HEZMAX};
0234   float ring16Depths[2] = {418.768, 470.968};
0235   float ring16slhcDepths[3] = {418.768, 450., 470.968};
0236   float ring17Depths[2] = {409.698, 514.468};
0237   float ring17slhcDepths[5] = {409.698, 435., 460., 495., 514.468};
0238   float ring18Depths[3] = {391.883, 427.468, 540.568};
0239   float ring18slhcDepths[5] = {391.883, 439., 467., 504., 540.568};
0240   float etaBounds[] = {0.087 * 15,
0241                        0.087 * 16,
0242                        0.087 * 17,
0243                        0.087 * 18,
0244                        0.087 * 19,
0245                        1.74,
0246                        1.83,
0247                        1.93,
0248                        2.043,
0249                        2.172,
0250                        2.322,
0251                        2.500,
0252                        2.650,
0253                        2.868,
0254                        3.000};
0255   float layerDepths[19] = {HEZMIN,
0256                            408.718,
0257                            416.978,
0258                            425.248,
0259                            433.508,
0260                            441.768,
0261                            450.038,
0262                            458.298,
0263                            466.558,
0264                            474.828,
0265                            483.088,
0266                            491.348,
0267                            499.618,
0268                            507.878,
0269                            516.138,
0270                            524.398,
0271                            532.668,
0272                            540.928,
0273                            HEZMAX};
0274 
0275   // count by ring - 16
0276   for (int iringm16 = 0; iringm16 <= 13; ++iringm16) {
0277     int iring = iringm16 + 16;
0278     std::vector<float> depths;
0279     unsigned int startingDepth = 1;
0280     if (topology.mode() != HcalTopologyMode::SLHC) {
0281       if (iring == 16) {
0282         for (float ring16Depth : ring16Depths)
0283           depths.emplace_back(ring16Depth);
0284         startingDepth = 3;
0285       } else if (iring == 17)
0286         for (float ring17Depth : ring17Depths)
0287           depths.emplace_back(ring17Depth);
0288       else if (iring == 18)
0289         for (float ring18Depth : ring18Depths)
0290           depths.emplace_back(ring18Depth);
0291       else if (iring == topology.lastHERing())
0292         for (int i = 0; i < 3; ++i)
0293           depths.emplace_back(tripleDepths[i]);
0294       else if (iring >= topology.firstHETripleDepthRing())
0295         for (float tripleDepth : tripleDepths)
0296           depths.emplace_back(tripleDepth);
0297       else
0298         for (float normalDepth : normalDepths)
0299           depths.emplace_back(normalDepth);
0300     } else {
0301       if (m_segmentation.size() >= (unsigned int)(iring)) {
0302         int depth = m_segmentation[iring - 1][0];
0303         if (iring == 16)
0304           depths.emplace_back(ring16Depths[0]);
0305         else if (iring == 17)
0306           depths.emplace_back(ring17Depths[0]);
0307         else if (iring == 18)
0308           depths.emplace_back(ring18Depths[0]);
0309         else
0310           depths.emplace_back(layerDepths[depth]);
0311         int layer = 1;
0312         float lastDepth = depths[0];
0313         for (unsigned int i = 1; i < m_segmentation[iring - 1].size(); ++i) {
0314           if (depth != m_segmentation[iring - 1][i]) {
0315             depth = m_segmentation[iring - 1][i];
0316             layer = i;
0317             if (layerDepths[depth] > lastDepth && (iring != 16 || depth > 3)) {
0318               depths.emplace_back(layerDepths[depth]);
0319               lastDepth = layerDepths[depth];
0320             }
0321           }
0322         }
0323         if (layer <= 17)
0324           depths.emplace_back(HEZMAX);
0325         if (iring == 16)
0326           startingDepth = 3;
0327       } else {
0328         if (iring == 16) {
0329           for (float ring16slhcDepth : ring16slhcDepths)
0330             depths.emplace_back(ring16slhcDepth);
0331           startingDepth = 3;
0332         } else if (iring == 17)
0333           for (float ring17slhcDepth : ring17slhcDepths)
0334             depths.emplace_back(ring17slhcDepth);
0335         else if (iring == 18)
0336           for (float ring18slhcDepth : ring18slhcDepths)
0337             depths.emplace_back(ring18slhcDepth);
0338         else
0339           for (float slhcDepth : slhcDepths)
0340             depths.emplace_back(slhcDepth);
0341       }
0342     }
0343     float etamin = etaBounds[iringm16];
0344     float etamax = etaBounds[iringm16 + 1];
0345     unsigned int ndepth = depths.size() - 1;
0346     //    topology.depthBinInformation(HcalEndcap, iring, ndepth, startingDepth);
0347 #ifdef EDM_ML_DEBUG
0348     std::ostringstream st3;
0349     st3 << "HERing " << iring << " eta " << etamin << ":" << etamax << " depths " << ndepth << ":" << startingDepth;
0350     for (unsigned int i = 0; i < depths.size(); ++i)
0351       st3 << ":" << depths[i];
0352     edm::LogVerbatim("HCalGeom") << st3.str();
0353 #endif
0354     for (unsigned int idepth = 0; idepth < ndepth; ++idepth) {
0355       int depthIndex = (int)(idepth + startingDepth);
0356       float zmin = depths[idepth];
0357       float zmax = depths[idepth + 1];
0358       if (depthIndex <= 7) {
0359 #ifdef EDM_ML_DEBUG
0360         edm::LogVerbatim("HCalGeom") << "HE Depth " << idepth << ":" << depthIndex << " Z " << zmin << ":" << zmax;
0361 #endif
0362         int stepPhi = (iring >= topology.firstHEDoublePhiRing() ? 2 : 1);
0363         int deltaPhi = (iring >= topology.firstHEDoublePhiRing() ? 10 : 5);
0364         if (topology.mode() != HcalTopologyMode::SLHC && iring == topology.lastHERing() - 1 && idepth == ndepth - 1) {
0365 #ifdef EDM_ML_DEBUG
0366           edm::LogVerbatim("HCalGeom") << "HE iEta " << iring << " Depth " << depthIndex << " Eta " << etamin << ":"
0367                                        << etaBounds[iringm16 + 2];
0368 #endif
0369           result.emplace_back(HcalHardcodeGeometryLoader::HECellParameters(
0370               iring, depthIndex, 1, stepPhi, deltaPhi, zmin, zmax, etamin, etaBounds[iringm16 + 2]));
0371         } else {
0372 #ifdef EDM_ML_DEBUG
0373           edm::LogVerbatim("HCalGeom") << "HE iEta " << iring << " Depth " << depthIndex << " Eta " << etamin << ":"
0374                                        << etamax;
0375 #endif
0376           result.emplace_back(HcalHardcodeGeometryLoader::HECellParameters(
0377               iring, depthIndex, 1, stepPhi, deltaPhi, zmin, zmax, etamin, etamax));
0378         }
0379       }
0380     }
0381   }
0382 
0383   return result;
0384 }
0385 
0386 // ----------> HE @ H2 <-----------
0387 std::vector<HcalHardcodeGeometryLoader::HECellParameters> HcalHardcodeGeometryLoader::makeHECells_H2() {
0388   const float HEZMIN_H2 = 400.715;
0389   const float HEZMID_H2 = 436.285;
0390   const float HEZMAX_H2 = 541.885;
0391 
0392   HcalHardcodeGeometryLoader::HECellParameters cells[] = {
0393       // eta, depth, firstPhi, stepPhi, deltaPhi, zMin, zMax, etaMin, etaMax
0394       HcalHardcodeGeometryLoader::HECellParameters(16, 3, 1, 1, 5, 409.885, 462.685, 1.305, 1.373),
0395       HcalHardcodeGeometryLoader::HECellParameters(17, 1, 1, 1, 5, HEZMIN_H2, 427.485, 1.373, 1.444),
0396       HcalHardcodeGeometryLoader::HECellParameters(17, 2, 1, 1, 5, 427.485, 506.685, 1.373, 1.444),
0397       HcalHardcodeGeometryLoader::HECellParameters(18, 1, 1, 1, 5, HEZMIN_H2, HEZMID_H2, 1.444, 1.521),
0398       HcalHardcodeGeometryLoader::HECellParameters(18, 2, 1, 1, 5, HEZMID_H2, 524.285, 1.444, 1.521),
0399       HcalHardcodeGeometryLoader::HECellParameters(19, 1, 1, 1, 5, HEZMIN_H2, HEZMID_H2, 1.521, 1.603),
0400       HcalHardcodeGeometryLoader::HECellParameters(19, 2, 1, 1, 5, HEZMID_H2, HEZMAX_H2, 1.521, 1.603),
0401       HcalHardcodeGeometryLoader::HECellParameters(20, 1, 1, 1, 5, HEZMIN_H2, HEZMID_H2, 1.603, 1.693),
0402       HcalHardcodeGeometryLoader::HECellParameters(20, 2, 1, 1, 5, HEZMID_H2, HEZMAX_H2, 1.603, 1.693),
0403       HcalHardcodeGeometryLoader::HECellParameters(21, 1, 1, 2, 5, HEZMIN_H2, HEZMID_H2, 1.693, 1.79),
0404       HcalHardcodeGeometryLoader::HECellParameters(21, 2, 1, 2, 5, HEZMID_H2, HEZMAX_H2, 1.693, 1.79),
0405       HcalHardcodeGeometryLoader::HECellParameters(22, 1, 1, 2, 10, HEZMIN_H2, HEZMID_H2, 1.79, 1.88),
0406       HcalHardcodeGeometryLoader::HECellParameters(22, 2, 1, 2, 10, HEZMID_H2, HEZMAX_H2, 1.79, 1.88),
0407       HcalHardcodeGeometryLoader::HECellParameters(23, 1, 1, 2, 10, HEZMIN_H2, HEZMID_H2, 1.88, 1.98),
0408       HcalHardcodeGeometryLoader::HECellParameters(23, 2, 1, 2, 10, HEZMID_H2, HEZMAX_H2, 1.88, 1.98),
0409       HcalHardcodeGeometryLoader::HECellParameters(24, 1, 1, 2, 10, HEZMIN_H2, 418.685, 1.98, 2.09),
0410       HcalHardcodeGeometryLoader::HECellParameters(24, 2, 1, 2, 10, 418.685, HEZMID_H2, 1.98, 2.09),
0411       HcalHardcodeGeometryLoader::HECellParameters(24, 3, 1, 2, 10, HEZMID_H2, HEZMAX_H2, 1.98, 2.09),
0412       HcalHardcodeGeometryLoader::HECellParameters(25, 1, 1, 2, 10, HEZMIN_H2, 418.685, 2.09, 2.21),
0413       HcalHardcodeGeometryLoader::HECellParameters(25, 2, 1, 2, 10, 418.685, HEZMID_H2, 2.09, 2.21),
0414       HcalHardcodeGeometryLoader::HECellParameters(25, 3, 1, 2, 10, HEZMID_H2, HEZMAX_H2, 2.09, 2.21)};
0415   int nCells = sizeof(cells) / sizeof(HcalHardcodeGeometryLoader::HECellParameters);
0416   std::vector<HcalHardcodeGeometryLoader::HECellParameters> result;
0417   result.reserve(nCells);
0418   for (int i = 0; i < nCells; ++i)
0419     result.emplace_back(cells[i]);
0420   return result;
0421 }
0422 
0423 // ----------> HF <-----------
0424 std::vector<HcalHardcodeGeometryLoader::HFCellParameters> HcalHardcodeGeometryLoader::makeHFCells() {
0425   const float HFZMIN1 = 1115.;
0426   const float HFZMIN2 = 1137.;
0427   const float HFZMAX = 1280.1;
0428 
0429   HcalHardcodeGeometryLoader::HFCellParameters cells[] = {
0430       // eta, depth, firstPhi, stepPhi, deltaPhi, zMin, zMax, rMin, rMax
0431       HcalHardcodeGeometryLoader::HFCellParameters(29, 1, 1, 2, 10, HFZMIN1, HFZMAX, 116.2, 130.0),
0432       HcalHardcodeGeometryLoader::HFCellParameters(29, 2, 1, 2, 10, HFZMIN2, HFZMAX, 116.2, 130.0),
0433       HcalHardcodeGeometryLoader::HFCellParameters(30, 1, 1, 2, 10, HFZMIN1, HFZMAX, 97.5, 116.2),
0434       HcalHardcodeGeometryLoader::HFCellParameters(30, 2, 1, 2, 10, HFZMIN2, HFZMAX, 97.5, 116.2),
0435       HcalHardcodeGeometryLoader::HFCellParameters(31, 1, 1, 2, 10, HFZMIN1, HFZMAX, 81.8, 97.5),
0436       HcalHardcodeGeometryLoader::HFCellParameters(31, 2, 1, 2, 10, HFZMIN2, HFZMAX, 81.8, 97.5),
0437       HcalHardcodeGeometryLoader::HFCellParameters(32, 1, 1, 2, 10, HFZMIN1, HFZMAX, 68.6, 81.8),
0438       HcalHardcodeGeometryLoader::HFCellParameters(32, 2, 1, 2, 10, HFZMIN2, HFZMAX, 68.6, 81.8),
0439       HcalHardcodeGeometryLoader::HFCellParameters(33, 1, 1, 2, 10, HFZMIN1, HFZMAX, 57.6, 68.6),
0440       HcalHardcodeGeometryLoader::HFCellParameters(33, 2, 1, 2, 10, HFZMIN2, HFZMAX, 57.6, 68.6),
0441       HcalHardcodeGeometryLoader::HFCellParameters(34, 1, 1, 2, 10, HFZMIN1, HFZMAX, 48.3, 57.6),
0442       HcalHardcodeGeometryLoader::HFCellParameters(34, 2, 1, 2, 10, HFZMIN2, HFZMAX, 48.3, 57.6),
0443       HcalHardcodeGeometryLoader::HFCellParameters(35, 1, 1, 2, 10, HFZMIN1, HFZMAX, 40.6, 48.3),
0444       HcalHardcodeGeometryLoader::HFCellParameters(35, 2, 1, 2, 10, HFZMIN2, HFZMAX, 40.6, 48.3),
0445       HcalHardcodeGeometryLoader::HFCellParameters(36, 1, 1, 2, 10, HFZMIN1, HFZMAX, 34.0, 40.6),
0446       HcalHardcodeGeometryLoader::HFCellParameters(36, 2, 1, 2, 10, HFZMIN2, HFZMAX, 34.0, 40.6),
0447       HcalHardcodeGeometryLoader::HFCellParameters(37, 1, 1, 2, 10, HFZMIN1, HFZMAX, 28.6, 34.0),
0448       HcalHardcodeGeometryLoader::HFCellParameters(37, 2, 1, 2, 10, HFZMIN2, HFZMAX, 28.6, 34.0),
0449       HcalHardcodeGeometryLoader::HFCellParameters(38, 1, 1, 2, 10, HFZMIN1, HFZMAX, 24.0, 28.6),
0450       HcalHardcodeGeometryLoader::HFCellParameters(38, 2, 1, 2, 10, HFZMIN2, HFZMAX, 24.0, 28.6),
0451       HcalHardcodeGeometryLoader::HFCellParameters(39, 1, 1, 2, 10, HFZMIN1, HFZMAX, 20.1, 24.0),
0452       HcalHardcodeGeometryLoader::HFCellParameters(39, 2, 1, 2, 10, HFZMIN2, HFZMAX, 20.1, 24.0),
0453       HcalHardcodeGeometryLoader::HFCellParameters(40, 1, 3, 4, 20, HFZMIN1, HFZMAX, 16.9, 20.1),
0454       HcalHardcodeGeometryLoader::HFCellParameters(40, 2, 3, 4, 20, HFZMIN2, HFZMAX, 16.9, 20.1),
0455       HcalHardcodeGeometryLoader::HFCellParameters(41, 1, 3, 4, 20, HFZMIN1, HFZMAX, 12.5, 16.9),
0456       HcalHardcodeGeometryLoader::HFCellParameters(41, 2, 3, 4, 20, HFZMIN2, HFZMAX, 12.5, 16.9)};
0457   int nCells = sizeof(cells) / sizeof(HcalHardcodeGeometryLoader::HFCellParameters);
0458   std::vector<HcalHardcodeGeometryLoader::HFCellParameters> result;
0459   result.reserve(nCells);
0460   for (int i = 0; i < nCells; ++i)
0461     result.emplace_back(cells[i]);
0462   return result;
0463 }
0464 
0465 void HcalHardcodeGeometryLoader::fillHE(HcalGeometry* fGeometry,
0466                                         const std::vector<HcalHardcodeGeometryLoader::HECellParameters>& fCells) {
0467   fGeometry->increaseReserve(fCells.size());
0468   for (const auto& param : fCells) {
0469     for (int iPhi = param.phiFirst; iPhi <= MAX_HCAL_PHI; iPhi += param.phiStep) {
0470       for (int iside = -1; iside <= 1; iside += 2) {  // both detector sides are identical
0471         HcalDetId hid(HcalEndcap, param.eta * iside, iPhi, param.depth);
0472         float phiCenter = ((iPhi - 1) * 360. / MAX_HCAL_PHI + 0.5 * param.dphi) * DEGREE2RAD;  // middle of the cell
0473         float etaCenter = 0.5 * (param.etaMin + param.etaMax);
0474 
0475         float perp = param.zMin / sinh(etaCenter);
0476         float x = perp * cos(phiCenter);
0477         float y = perp * sin(phiCenter);
0478         float z = iside * param.zMin;
0479         // make cell geometry
0480         GlobalPoint refPoint(x, y, z);  // center of the cell's face
0481         std::vector<CCGFloat> cellParams;
0482         cellParams.reserve(5);
0483         cellParams.emplace_back(0.5 * (param.etaMax - param.etaMin));                 //deta_half
0484         cellParams.emplace_back(0.5 * param.dphi * DEGREE2RAD);                       // dphi_half
0485         cellParams.emplace_back(-0.5 * (param.zMax - param.zMin) / tanh(etaCenter));  // dz_half, "-" means edges in Z
0486         cellParams.emplace_back(fabs(refPoint.eta()));
0487         cellParams.emplace_back(fabs(refPoint.z()));
0488 #ifdef EDM_ML_DEBUG
0489         edm::LogVerbatim("HCalGeom") << "HcalHardcodeGeometryLoader::fillHE-> " << hid << refPoint << '/'
0490                                      << cellParams[0] << '/' << cellParams[1] << '/' << cellParams[2];
0491 #endif
0492         fGeometry->newCellFast(refPoint,
0493                                refPoint,
0494                                refPoint,
0495                                CaloCellGeometry::getParmPtr(cellParams, fGeometry->parMgr(), fGeometry->parVecVec()),
0496                                hid);
0497       }
0498     }
0499   }
0500 }
0501 
0502 void HcalHardcodeGeometryLoader::fillHF(HcalGeometry* fGeometry,
0503                                         const std::vector<HcalHardcodeGeometryLoader::HFCellParameters>& fCells) {
0504   fGeometry->increaseReserve(fCells.size());
0505   for (const auto& param : fCells) {
0506     for (int iPhi = param.phiFirst; iPhi <= MAX_HCAL_PHI; iPhi += param.phiStep) {
0507       for (int iside = -1; iside <= 1; iside += 2) {  // both detector sides are identical
0508         HcalDetId hid(HcalForward, param.eta * iside, iPhi, param.depth);
0509         float phiCenter = ((iPhi - 1) * 360. / MAX_HCAL_PHI + 0.5 * param.dphi) * DEGREE2RAD;  // middle of the cell
0510         GlobalPoint inner(param.rMin, 0, param.zMin);
0511         GlobalPoint outer(param.rMax, 0, param.zMin);
0512         float iEta = inner.eta();
0513         float oEta = outer.eta();
0514         float etaCenter = 0.5 * (iEta + oEta);
0515 
0516         float perp = param.zMin / sinh(etaCenter);
0517         float x = perp * cos(phiCenter);
0518         float y = perp * sin(phiCenter);
0519         float z = iside * param.zMin;
0520         // make cell geometry
0521         GlobalPoint refPoint(x, y, z);  // center of the cell's face
0522         std::vector<CCGFloat> cellParams;
0523         cellParams.reserve(5);
0524         cellParams.emplace_back(0.5 * (iEta - oEta));              // deta_half
0525         cellParams.emplace_back(0.5 * param.dphi * DEGREE2RAD);    // dphi_half
0526         cellParams.emplace_back(0.5 * (param.zMax - param.zMin));  // dz_half
0527         cellParams.emplace_back(fabs(refPoint.eta()));
0528         cellParams.emplace_back(fabs(refPoint.z()));
0529 #ifdef EDM_ML_DEBUG
0530         edm::LogVerbatim("HCalGeom") << "HcalHardcodeGeometryLoader::fillHF-> " << hid << refPoint << '/'
0531                                      << cellParams[0] << '/' << cellParams[1] << '/' << cellParams[2];
0532 #endif
0533         fGeometry->newCellFast(refPoint,
0534                                refPoint,
0535                                refPoint,
0536                                CaloCellGeometry::getParmPtr(cellParams, fGeometry->parMgr(), fGeometry->parVecVec()),
0537                                hid);
0538       }
0539     }
0540   }
0541 }