Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:07:58

0001 #include "Geometry/CaloGeometry/interface/TruncatedPyramid.h"
0002 #include "Geometry/EcalAlgo/interface/EcalEndcapGeometry.h"
0003 #include "Geometry/CaloEventSetup/interface/CaloGeometryLoader.h"
0004 #include "DetectorDescription/Core/interface/DDFilteredView.h"
0005 
0006 typedef CaloGeometryLoader<EcalEndcapGeometry> EcalEGL;
0007 
0008 template <>
0009 void EcalEGL::fillGeom(EcalEndcapGeometry* geom,
0010                        const EcalEGL::ParmVec& vv,
0011                        const HepGeom::Transform3D& tr,
0012                        const DetId& id,
0013                        const double& scale);
0014 template <>
0015 void EcalEGL::fillNamedParams(const DDFilteredView& fv, EcalEndcapGeometry* geom);
0016 template <>
0017 void EcalEGL::fillNamedParams(const cms::DDFilteredView& fv, EcalEndcapGeometry* geom);
0018 
0019 #include "Geometry/CaloEventSetup/interface/CaloGeometryLoader.icc"
0020 
0021 template class CaloGeometryLoader<EcalEndcapGeometry>;
0022 typedef CaloCellGeometry::CCGFloat CCGFloat;
0023 
0024 template <>
0025 void EcalEGL::fillGeom(EcalEndcapGeometry* geom,
0026                        const EcalEGL::ParmVec& vv,
0027                        const HepGeom::Transform3D& tr,
0028                        const DetId& id,
0029                        const double& scale) {
0030   static constexpr uint32_t maxSize = 11;
0031   std::vector<CCGFloat> pv;
0032   unsigned int size = (vv.size() > maxSize) ? maxSize : vv.size();
0033   unsigned int ioff = (vv.size() > maxSize) ? (vv.size() - maxSize) : 0;
0034   pv.reserve(size);
0035   for (unsigned int i(0); i != size; ++i) {
0036     const CCGFloat factor(1 == i || 2 == i || 6 == i || 10 == i ? 1 : static_cast<CCGFloat>(scale));
0037     pv.emplace_back(factor * vv[i + ioff]);
0038   }
0039 
0040   std::vector<GlobalPoint> corners(8);
0041 
0042   TruncatedPyramid::createCorners(pv, tr, corners);
0043 
0044   const CCGFloat* parmPtr(CaloCellGeometry::getParmPtr(pv, geom->parMgr(), geom->parVecVec()));
0045 
0046   const GlobalPoint front(0.25 * (corners[0].x() + corners[1].x() + corners[2].x() + corners[3].x()),
0047                           0.25 * (corners[0].y() + corners[1].y() + corners[2].y() + corners[3].y()),
0048                           0.25 * (corners[0].z() + corners[1].z() + corners[2].z() + corners[3].z()));
0049 
0050   const GlobalPoint back(0.25 * (corners[4].x() + corners[5].x() + corners[6].x() + corners[7].x()),
0051                          0.25 * (corners[4].y() + corners[5].y() + corners[6].y() + corners[7].y()),
0052                          0.25 * (corners[4].z() + corners[5].z() + corners[6].z() + corners[7].z()));
0053 
0054   geom->newCell(front, back, corners[0], parmPtr, id);
0055 }
0056 
0057 template <>
0058 void EcalEGL::fillNamedParams(const DDFilteredView& _fv, EcalEndcapGeometry* geom) {
0059   DDFilteredView fv = _fv;
0060   bool doSubDets = fv.firstChild();
0061   while (doSubDets) {
0062     DDsvalues_type sv(fv.mergedSpecifics());
0063 
0064     //ncrys
0065     DDValue valNcrys("ncrys");
0066     if (DDfetch(&sv, valNcrys)) {
0067       const std::vector<double>& fvec = valNcrys.doubles();
0068 
0069       // this parameter can only appear once
0070       assert(fvec.size() == 1);
0071       geom->setNumberOfCrystalPerModule(static_cast<int>(fvec[0]));
0072     } else
0073       continue;
0074 
0075     //nmods
0076     DDValue valNmods("nmods");
0077     if (DDfetch(&sv, valNmods)) {
0078       const std::vector<double>& fmvec = valNmods.doubles();
0079 
0080       // there can only be one such value
0081       assert(fmvec.size() == 1);
0082       geom->setNumberOfModules(static_cast<int>(fmvec[0]));
0083     }
0084 
0085     break;
0086 
0087     doSubDets = fv.nextSibling();  // go to next layer
0088   }
0089 }
0090 
0091 template <>
0092 void EcalEGL::fillNamedParams(const cms::DDFilteredView& fv, EcalEndcapGeometry* geom) {
0093   const std::string specName = "ecal_ee";
0094 
0095   //ncrys
0096   std::vector<double> tempD = fv.get<std::vector<double> >(specName, "ncrys");
0097   assert(tempD.size() == 1);
0098   geom->setNumberOfCrystalPerModule(static_cast<int>(tempD[0]));
0099 
0100   //nmods
0101   tempD = fv.get<std::vector<double> >(specName, "nmods");
0102   assert(tempD.size() == 1);
0103   geom->setNumberOfModules(static_cast<int>(tempD[0]));
0104 }