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 }
29 
30 bool
32  PMTDParameters& ptp)
33 {
34  std::array<std::string,2> mtdSubdet { { "BTL", "ETL" } };
35  int subdet(0);
36  for( const auto& name : mtdSubdet )
37  {
39  {
40  subdet += 1;
41  std::vector<int> subdetPars = dbl_to_int( DDVectorGetter::get( name ));
42  putOne( subdet, subdetPars, ptp );
43  }
44  }
45 
46  ptp.vpars_ = dbl_to_int( DDVectorGetter::get( "vPars" ));
47 
48  std::string attribute = "OnlyForMTDRecNumbering";
49  DDSpecificsHasNamedValueFilter filter1{attribute};
50  DDFilteredView fv1(*cvp,filter1);
51  bool ok = fv1.firstChild();
52  if (ok) {
54  int topoMode = getMTDTopologyMode("TopologyMode", sv);
55  ptp.topologyMode_ = topoMode;
56  } else {
57  throw cms::Exception( "MTDParametersFromDD" ) << "Not found "<< attribute.c_str() << " but needed."; }
58 
59  return true;
60 }
61 
62 void
63 MTDParametersFromDD::putOne( int subdet, std::vector<int> & vpars, PMTDParameters& ptp )
64 {
66  item.id_ = subdet;
67  item.vpars_ = vpars;
68  ptp.vitems_.emplace_back( item );
69 }
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:81
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_
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 &)
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
Definition: DDsvalues.h:12
bool firstChild()
set the current node to the first child ...