CMS 3D CMS Logo

MTDParametersFromDD.cc
Go to the documentation of this file.
8 
9 using namespace MTDTopologyMode;
10 
11 namespace {
12  int getMTDTopologyMode(const char* s, const DDsvalues_type& sv) {
13  DDValue val(s);
14  if (DDfetch(&sv, val)) {
15  const std::vector<std::string>& fvec = val.strings();
16  if (fvec.empty()) {
17  throw cms::Exception("MTDParametersFromDD") << "Failed to get " << s << " tag.";
18  }
19 
20  int result(-1);
22  result = static_cast<int>(eparser);
23  return result;
24  } else {
25  throw cms::Exception("MTDParametersFromDD") << "Failed to get " << s << " tag.";
26  }
27  }
28 } // namespace
29 
31  std::array<std::string, 2> mtdSubdet{{"BTL", "ETL"}};
32  int subdet(0);
33  for (const auto& name : mtdSubdet) {
35  subdet += 1;
36  std::vector<int> subdetPars = dbl_to_int(DDVectorGetter::get(name));
37  putOne(subdet, subdetPars, ptp);
38  }
39  }
40 
41  ptp.vpars_ = dbl_to_int(DDVectorGetter::get("vPars"));
42 
43  std::string attribute = "OnlyForMTDRecNumbering";
44  DDSpecificsHasNamedValueFilter filter1{attribute};
45  DDFilteredView fv1(*cvp, filter1);
46  bool ok = fv1.firstChild();
47  if (ok) {
49  int topoMode = getMTDTopologyMode("TopologyMode", sv);
50  ptp.topologyMode_ = topoMode;
51  } else {
52  throw cms::Exception("MTDParametersFromDD") << "Not found " << attribute.c_str() << " but needed.";
53  }
54 
55  return true;
56 }
57 
58 void MTDParametersFromDD::putOne(int subdet, std::vector<int>& vpars, PMTDParameters& ptp) {
60  item.id_ = subdet;
61  item.vpars_ = vpars;
62  ptp.vitems_.emplace_back(item);
63 }
std::vector< Item > vitems_
void putOne(int, std::vector< int > &, PMTDParameters &)
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:79
std::vector< int > vpars_
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
std::vector< int > vpars_
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
Definition: DDsvalues.h:12
bool check(const std::string &)
Mode MTDStringToEnumParser(const std::string &)
std::vector< double > get(const std::string &)
DDsvalues_type mergedSpecifics() const
bool build(const DDCompactView *, PMTDParameters &)
bool firstChild()
set the current node to the first child ...