Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:49:07

0001 #include "Geometry/TrackerGeometryBuilder/interface/TrackerParametersFromDD.h"
0002 #include "CondFormats/GeometryObjects/interface/PTrackerParameters.h"
0003 #include "DetectorDescription/Core/interface/DDCompactView.h"
0004 #include "DetectorDescription/DDCMS/interface/DDCompactView.h"
0005 #include "DetectorDescription/Core/interface/DDutils.h"
0006 #include <DD4hep/Filter.h>
0007 
0008 bool TrackerParametersFromDD::build(const DDCompactView* cvp, PTrackerParameters& ptp) {
0009   for (int subdet = 1; subdet <= 6; ++subdet) {
0010     std::stringstream sstm;
0011     sstm << "Subdetector" << subdet;
0012     std::string name = sstm.str();
0013 
0014     auto const& v = cvp->vector(name);
0015     if (!v.empty()) {
0016       std::vector<int> subdetPars = dbl_to_int(v);
0017       putOne(subdet, subdetPars, ptp);
0018     }
0019   }
0020 
0021   ptp.vpars = dbl_to_int(cvp->vector("vPars"));
0022 
0023   return true;
0024 }
0025 
0026 bool TrackerParametersFromDD::build(const cms::DDCompactView* cpv, PTrackerParameters& ptp) {
0027   const auto& vmap = cpv->detector()->vectors();
0028   for (int subdet = 1; subdet <= 6; ++subdet) {
0029     const auto& v = vmap.at("trackerParameters:Subdetector" + std::to_string(subdet));
0030     std::vector<int> subdetPars;
0031     std::transform(v.begin(), v.end(), std::back_inserter(subdetPars), [](int i) -> int { return std::round(i); });
0032     putOne(subdet, subdetPars, ptp);
0033   }
0034 
0035   // get "vPars" parameter block from XMLs.
0036   const auto& vPars = vmap.at("trackerParameters:vPars");
0037   std::transform(vPars.begin(), vPars.end(), std::back_inserter(ptp.vpars), [](int i) -> int { return std::round(i); });
0038 
0039   return true;
0040 }
0041 
0042 void TrackerParametersFromDD::putOne(int subdet, std::vector<int>& vpars, PTrackerParameters& ptp) {
0043   PTrackerParameters::Item item;
0044   item.id = subdet;
0045   item.vpars = vpars;
0046   ptp.vitems.emplace_back(item);
0047 }