CMS 3D CMS Logo

TrackerParametersFromDD.cc
Go to the documentation of this file.
6 #include <DD4hep/Filter.h>
7 
9  for (int subdet = 1; subdet <= 6; ++subdet) {
10  std::stringstream sstm;
11  sstm << "Subdetector" << subdet;
12  std::string name = sstm.str();
13 
14  auto const& v = cvp->vector(name);
15  if (!v.empty()) {
16  std::vector<int> subdetPars = dbl_to_int(v);
17  putOne(subdet, subdetPars, ptp);
18  }
19  }
20 
21  ptp.vpars = dbl_to_int(cvp->vector("vPars"));
22 
23  return true;
24 }
25 
27  const auto& vmap = cpv->detector()->vectors();
28  for (int subdet = 1; subdet <= 6; ++subdet) {
29  const auto& v = vmap.at("trackerParameters:Subdetector" + std::to_string(subdet));
30  std::vector<int> subdetPars;
31  std::transform(v.begin(), v.end(), std::back_inserter(subdetPars), [](int i) -> int { return std::round(i); });
32  putOne(subdet, subdetPars, ptp);
33  }
34 
35  // get "vPars" parameter block from XMLs.
36  const auto& vPars = vmap.at("trackerParameters:vPars");
37  std::transform(vPars.begin(), vPars.end(), std::back_inserter(ptp.vpars), [](int i) -> int { return std::round(i); });
38 
39  return true;
40 }
41 
42 void TrackerParametersFromDD::putOne(int subdet, std::vector<int>& vpars, PTrackerParameters& ptp) {
44  item.id = subdet;
45  item.vpars = vpars;
46  ptp.vitems.emplace_back(item);
47 }
std::vector< int > vpars
void putOne(int, std::vector< int > &, PTrackerParameters &)
std::vector< Item > vitems
std::vector< double > const & vector(std::string_view iKey) const
returns an empty container if not found
const cms::DDDetector * detector() const
Definition: DDCompactView.h:34
std::string to_string(const V &value)
Definition: OMSAccess.h:71
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
std::vector< int > dbl_to_int(const std::vector< double > &vecdbl)
Converts a std::vector of doubles to a std::vector of int.
Definition: DDutils.h:7
bool build(const DDCompactView *, PTrackerParameters &)
cms::DDVectorsMap const & vectors() const
Definition: DDDetector.h:17
unsigned transform(const HcalDetId &id, unsigned transformCode)