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/EcalBarrelGeometry.h"
0003 #include "Geometry/CaloEventSetup/interface/CaloGeometryLoader.h"
0004 #include "DetectorDescription/DDCMS/interface/DDFilteredView.h"
0005 #include "DetectorDescription/Core/interface/DDFilteredView.h"
0006 #include "DetectorDescription/Core/interface/DDutils.h"
0007 
0008 typedef CaloGeometryLoader<EcalBarrelGeometry> EcalBGL;
0009 
0010 template <>
0011 void EcalBGL::fillGeom(EcalBarrelGeometry* geom,
0012                        const EcalBGL::ParmVec& vv,
0013                        const HepGeom::Transform3D& tr,
0014                        const DetId& id,
0015                        const double& scale);
0016 template <>
0017 void EcalBGL::fillNamedParams(const DDFilteredView& fv, EcalBarrelGeometry* geom);
0018 template <>
0019 void EcalBGL::fillNamedParams(const cms::DDFilteredView& fv, EcalBarrelGeometry* geom);
0020 
0021 #include "Geometry/CaloEventSetup/interface/CaloGeometryLoader.icc"
0022 
0023 template class CaloGeometryLoader<EcalBarrelGeometry>;
0024 typedef CaloCellGeometry::CCGFloat CCGFloat;
0025 
0026 template <>
0027 void EcalBGL::fillGeom(EcalBarrelGeometry* geom,
0028                        const EcalBGL::ParmVec& vv,
0029                        const HepGeom::Transform3D& tr,
0030                        const DetId& id,
0031                        const double& scale) {
0032   static constexpr uint32_t maxSize = 11;
0033   std::vector<CCGFloat> pv;
0034   unsigned int size = (vv.size() > maxSize) ? maxSize : vv.size();
0035   unsigned int ioff = (vv.size() > maxSize) ? (vv.size() - maxSize) : 0;
0036   pv.reserve(size);
0037   for (unsigned int i(0); i != size; ++i) {
0038     const CCGFloat factor(1 == i || 2 == i || 6 == i || 10 == i ? 1 : static_cast<CCGFloat>(scale));
0039     pv.emplace_back(factor * vv[i + ioff]);
0040   }
0041 
0042   std::vector<GlobalPoint> corners(8);
0043 
0044   TruncatedPyramid::createCorners(pv, tr, corners);
0045 
0046   const CCGFloat* parmPtr(CaloCellGeometry::getParmPtr(pv, geom->parMgr(), geom->parVecVec()));
0047 
0048   const GlobalPoint front(0.25 * (corners[0].x() + corners[1].x() + corners[2].x() + corners[3].x()),
0049                           0.25 * (corners[0].y() + corners[1].y() + corners[2].y() + corners[3].y()),
0050                           0.25 * (corners[0].z() + corners[1].z() + corners[2].z() + corners[3].z()));
0051 
0052   const GlobalPoint back(0.25 * (corners[4].x() + corners[5].x() + corners[6].x() + corners[7].x()),
0053                          0.25 * (corners[4].y() + corners[5].y() + corners[6].y() + corners[7].y()),
0054                          0.25 * (corners[4].z() + corners[5].z() + corners[6].z() + corners[7].z()));
0055 
0056   geom->newCell(front, back, corners[0], parmPtr, id);
0057 }
0058 
0059 template <>
0060 void EcalBGL::fillNamedParams(const DDFilteredView& _fv, EcalBarrelGeometry* geom) {
0061   DDFilteredView fv = _fv;
0062   bool doSubDets = fv.firstChild();
0063 
0064   while (doSubDets) {
0065     DDsvalues_type sv(fv.mergedSpecifics());
0066 
0067     //nxtalPhi
0068     DDValue valnPhi("nxtalPhi");
0069     if (DDfetch(&sv, valnPhi)) {
0070       const std::vector<double>& fvec = valnPhi.doubles();
0071 
0072       // this parameter can only appear once
0073       assert(fvec.size() == 1);
0074       geom->setNumXtalsPhiDirection(static_cast<int>(fvec[0]));
0075     } else
0076       continue;
0077 
0078     DDValue valnEta("nxtalEta");
0079     if (DDfetch(&sv, valnEta)) {
0080       const std::vector<double>& fmvec = valnEta.doubles();
0081 
0082       // there can only be one such value
0083       assert(fmvec.size() == 1);
0084 
0085       geom->setNumXtalsEtaDirection(static_cast<int>(fmvec[0]));
0086     } else
0087       // once we find nxtalPhi, the rest must also be defined
0088       assert(1 == 0);
0089 
0090     //EtaBaskets
0091     DDValue valEtaB("EtaBaskets");
0092     if (DDfetch(&sv, valEtaB)) {
0093       const std::vector<double>& ebvec = valEtaB.doubles();
0094       assert(!ebvec.empty());
0095       std::vector<int> EtaBaskets;
0096       EtaBaskets.reserve(ebvec.size());
0097       for (const auto& ebv : ebvec)
0098         EtaBaskets.emplace_back(static_cast<int>(ebv));
0099       geom->setEtaBaskets(EtaBaskets);
0100     } else
0101       // once we find nxtalPhi, the rest must also be defined
0102       assert(1 == 0);
0103 
0104     //PhiBaskets
0105     DDValue valPhi("PhiBaskets");
0106     if (DDfetch(&sv, valPhi)) {
0107       const std::vector<double>& pvec = valPhi.doubles();
0108       assert(!pvec.empty());
0109       geom->setBasketSizeInPhi(static_cast<int>(pvec[0]));
0110     } else
0111       // once we find nxtalPhi, the rest must also be defined
0112       assert(1 == 0);
0113 
0114     break;
0115 
0116     doSubDets = fv.nextSibling();  // go to next layer
0117   }
0118 }
0119 
0120 template <>
0121 void EcalBGL::fillNamedParams(const cms::DDFilteredView& fv, EcalBarrelGeometry* geom) {
0122   const std::string specName = "ecal_eb";
0123 
0124   //nxtalEta
0125   std::vector<double> tempD = fv.get<std::vector<double> >(specName, "nxtalEta");
0126   assert(tempD.size() == 1);
0127   geom->setNumXtalsEtaDirection(static_cast<int>(tempD[0]));
0128 
0129   //nxtalPhi
0130   tempD = fv.get<std::vector<double> >(specName, "nxtalPhi");
0131   assert(tempD.size() == 1);
0132   geom->setNumXtalsPhiDirection(static_cast<int>(tempD[0]));
0133 
0134   //EtaBaskets
0135   tempD = fv.get<std::vector<double> >(specName, "EtaBaskets");
0136   assert(!tempD.empty());
0137   geom->setEtaBaskets(dbl_to_int(tempD));
0138 
0139   //PhiBaskets
0140   tempD = fv.get<std::vector<double> >(specName, "PhiBaskets");
0141   assert(!tempD.empty());
0142   geom->setBasketSizeInPhi(static_cast<int>(tempD[0]));
0143 }