CMS 3D CMS Logo

DDCompactView.cc
Go to the documentation of this file.
3 #include <DD4hep/Filter.h>
4 
5 #include <cmath>
6 #include <vector>
7 
8 template <>
9 std::vector<int> cms::DDCompactView::getVector<int>(const std::string& key) const {
10  std::vector<int> result;
11  const auto& vmap = this->detector()->vectors();
12  for (auto const& it : vmap) {
13  if (dd4hep::dd::noNamespace(it.first) == key) {
15  it.second.begin(), it.second.end(), std::back_inserter(result), [](int n) -> int { return (int)n; });
16  return result;
17  }
18  }
19  return result;
20 }
21 
22 template <>
23 std::vector<double> cms::DDCompactView::getVector<double>(const std::string& key) const {
24  const auto& vmap = this->detector()->vectors();
25  for (auto const& it : vmap) {
26  if (dd4hep::dd::noNamespace(it.first) == key) {
27  return it.second;
28  }
29  }
30  return std::vector<double>();
31 }
32 
33 template <>
34 std::vector<double> const& cms::DDCompactView::get<std::vector<double>>(const std::string& key) const {
35  const auto& vmap = this->detector()->vectors();
36  for (auto const& it : vmap) {
37  if (dd4hep::dd::noNamespace(it.first) == key) {
38  return it.second;
39  }
40  }
41  throw cms::Exception("DDError") << "no vector<double> with name " << key;
42 }
43 
44 template <>
45 std::vector<double> const& cms::DDCompactView::get<std::vector<double>>(const std::string& name,
46  const std::string& key) const {
47  const auto& spec = specpars().specPar(name);
48  if (spec != nullptr) {
49  auto const& nitem = spec->numpars.find(key);
50  if (nitem != end(spec->numpars)) {
51  return nitem->second;
52  }
53  }
54  throw cms::Exception("DDError") << "no SpecPar with name " << name << " and vector<double> key " << key;
55 }
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
cms::DDDetector::vectors
cms::DDVectorsMap const & vectors() const
Definition: DDDetector.h:17
mps_fire.end
end
Definition: mps_fire.py:242
HcalDetIdTransform::transform
unsigned transform(const HcalDetId &id, unsigned transformCode)
Definition: HcalDetIdTransform.cc:7
DDCompactView.h
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Exception
Definition: hltDiff.cc:245
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
Exception.h
hgcalTestNeighbor_cfi.detector
detector
Definition: hgcalTestNeighbor_cfi.py:6
mps_fire.result
result
Definition: mps_fire.py:311
crabWrapper.key
key
Definition: crabWrapper.py:19
cms::DDCompactView::detector
const cms::DDDetector * detector() const
Definition: DDCompactView.h:34