Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-18 05:06:59

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