CMS 3D CMS Logo

MTDParametersFromDD.cc
Go to the documentation of this file.
9 
10 using namespace MTDTopologyMode;
11 
12 namespace {
13  int getMTDTopologyMode(const char* s, const DDsvalues_type& sv) {
14  DDValue val(s);
15  if (DDfetch(&sv, val)) {
16  const std::vector<std::string>& fvec = val.strings();
17  if (fvec.empty()) {
18  throw cms::Exception("MTDParametersFromDD") << "Failed to get " << s << " tag.";
19  }
20 
21  int result(-1);
23  result = static_cast<int>(eparser);
24  return result;
25  } else {
26  throw cms::Exception("MTDParametersFromDD") << "Failed to get " << s << " tag.";
27  }
28  }
29 } // namespace
30 
32  std::array<std::string, 2> mtdSubdet{{"BTL", "ETL"}};
33  int subdet(0);
34  for (const auto& name : mtdSubdet) {
35  auto const& v = cvp->vector(name);
36  if (!v.empty()) {
37  subdet += 1;
38  std::vector<int> subdetPars = dbl_to_int(v);
39  putOne(subdet, subdetPars, ptp);
40  }
41  }
42 
43  ptp.vpars_ = dbl_to_int(cvp->vector("vPars"));
44 
45  std::string attribute = "OnlyForMTDRecNumbering";
46  DDSpecificsHasNamedValueFilter filter1{attribute};
47  DDFilteredView fv1(*cvp, filter1);
48  bool ok = fv1.firstChild();
49  if (ok) {
51  int topoMode = getMTDTopologyMode("TopologyMode", sv);
52  ptp.topologyMode_ = topoMode;
53  } else {
54  throw cms::Exception("MTDParametersFromDD") << "Not found " << attribute.c_str() << " but needed.";
55  }
56 
57  return true;
58 }
59 
61  cms::DDVectorsMap vmap = cvp->detector()->vectors();
62 
63  std::array<std::string, 2> mtdSubdet{{"BTL", "ETL"}};
64  int subdet(0);
65  for (const auto& name : mtdSubdet) {
66  subdet += 1;
67  for (auto const& it : vmap) {
68  if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first), name)) {
69  std::vector<int> subdetPars;
70  for (const auto& i : it.second)
71  subdetPars.emplace_back(std::round(i));
72  putOne(subdet, subdetPars, ptp);
73  }
74  }
75  }
76 
77  auto it = vmap.find("vPars");
78  if (it != end(vmap)) {
79  std::vector<int> tmpVec;
80  for (const auto& i : it->second)
81  tmpVec.emplace_back(std::round(i));
82  ptp.vpars_ = tmpVec;
83  }
84 
86  const cms::DDSpecParRegistry& mypar = cvp->specpars();
87  std::string attribute = "OnlyForMTDRecNumbering";
88  mypar.filter(ref, attribute, "MTD");
89 
90  std::string topoModeS(mypar.specPar("mtdNumbering")->strValue("TopologyMode"));
91  if (!topoModeS.empty()) {
92  int topoMode(-1);
94  topoMode = static_cast<int>(eparser);
95  ptp.topologyMode_ = topoMode;
96  } else {
97  throw cms::Exception("MTDParametersFromDD") << "Not found " << attribute.c_str() << " but needed.";
98  }
99 
100  return true;
101 }
102 
103 void MTDParametersFromDD::putOne(int subdet, std::vector<int>& vpars, PMTDParameters& ptp) {
105  item.id_ = subdet;
106  item.vpars_ = vpars;
107  ptp.vitems_.emplace_back(item);
108 }
PMTDParameters
Definition: PMTDParameters.h:6
PMTDParameters::vpars_
std::vector< int > vpars_
Definition: PMTDParameters.h:19
mps_fire.i
i
Definition: mps_fire.py:428
PMTDParameters::vitems_
std::vector< Item > vitems_
Definition: PMTDParameters.h:18
cms::DDDetector::vectors
cms::DDVectorsMap const & vectors() const
Definition: DDDetector.h:17
DDFilteredView::mergedSpecifics
DDsvalues_type mergedSpecifics() const
Definition: DDFilteredView.cc:42
cms::DDSpecParRefs
dd4hep::SpecParRefs DDSpecParRefs
Definition: DDCompactView.h:29
MTDTopologyMode::MTDStringToEnumParser
Mode MTDStringToEnumParser(const std::string &)
Definition: MTDTopologyMode.cc:7
DDCompactView::vector
std::vector< double > const & vector(std::string_view iKey) const
returns an empty container if not found
Definition: DDCompactView.cc:67
findQualityFiles.v
v
Definition: findQualityFiles.py:179
MTDTopologyMode.h
dbl_to_int
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
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
DDCompactView.h
alignCSCRings.s
s
Definition: alignCSCRings.py:92
cms::DDSpecParRegistry
dd4hep::SpecParRegistry DDSpecParRegistry
Definition: DDCompactView.h:28
DDFilteredView::firstChild
bool firstChild()
set the current node to the first child ...
Definition: DDFilteredView.cc:86
DDFilteredView.h
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
pfDeepBoostedJetPreprocessParams_cfi.sv
sv
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:352
mps_fire.end
end
Definition: mps_fire.py:242
DDfetch
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:79
DDFilteredView.h
DDCompactView.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
MTDTopologyMode
Definition: MTDTopologyMode.h:11
MTDParametersFromDD::putOne
void putOne(int, std::vector< int > &, PMTDParameters &)
Definition: MTDParametersFromDD.cc:103
DDutils.h
DDSpecificsHasNamedValueFilter
Definition: DDFilter.h:60
PMTDParameters::topologyMode_
int topologyMode_
Definition: PMTDParameters.h:20
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
MTDParametersFromDD.h
MTDTopologyMode::Mode
Mode
Definition: MTDTopologyMode.h:13
PMTDParameters::Item
Definition: PMTDParameters.h:11
cms::DDCompactView::specpars
DDSpecParRegistry const & specpars() const
Definition: DDCompactView.h:35
heppy_batch.val
val
Definition: heppy_batch.py:351
DDValue
Definition: DDValue.h:21
Exception
Definition: hltDiff.cc:246
cms::DDVectorsMap
std::unordered_map< std::string, std::vector< double > > DDVectorsMap
Definition: DDNamespace.h:14
cms::DDCompactView
Definition: DDCompactView.h:31
PMTDParameters.h
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
MTDParametersFromDD::build
bool build(const DDCompactView *, PMTDParameters &)
Definition: MTDParametersFromDD.cc:31
DDFilteredView
Definition: DDFilteredView.h:20
mps_fire.result
result
Definition: mps_fire.py:311
DDsvalues_type
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
Definition: DDsvalues.h:12
cms::DDCompactView::detector
const cms::DDDetector * detector() const
Definition: DDCompactView.h:34