CMS 3D CMS Logo

MTDParametersFromDD.cc
Go to the documentation of this file.
10 
11 using namespace MTDTopologyMode;
12 
13 namespace {
14  int getMTDTopologyMode(const char* s, const DDsvalues_type& sv) {
15  DDValue val(s);
16  if (DDfetch(&sv, val)) {
17  const std::vector<std::string>& fvec = val.strings();
18  if (fvec.empty()) {
19  throw cms::Exception("MTDParametersFromDD") << "Failed to get " << s << " tag.";
20  }
21 
22  int result(-1);
24  result = static_cast<int>(eparser);
25  return result;
26  } else {
27  throw cms::Exception("MTDParametersFromDD") << "Failed to get " << s << " tag.";
28  }
29  }
30 } // namespace
31 
33  std::array<std::string, 2> mtdSubdet{{"BTL", "ETL"}};
34  int subdet(0);
35  for (const auto& name : mtdSubdet) {
37  subdet += 1;
38  std::vector<int> subdetPars = dbl_to_int(DDVectorGetter::get(name));
39  putOne(subdet, subdetPars, ptp);
40  }
41  }
42 
43  ptp.vpars_ = dbl_to_int(DDVectorGetter::get("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) {
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 }
DDVectorGetter.h
PMTDParameters
Definition: PMTDParameters.h:6
PMTDParameters::vpars_
std::vector< int > vpars_
Definition: PMTDParameters.h:19
mps_fire.i
i
Definition: mps_fire.py:355
PMTDParameters::vitems_
std::vector< Item > vitems_
Definition: PMTDParameters.h:18
cms::DDVectorsMap
tbb::concurrent_unordered_map< std::string, tbb::concurrent_vector< double > > DDVectorsMap
Definition: DDNamespace.h:14
DDFilteredView::mergedSpecifics
DDsvalues_type mergedSpecifics() const
Definition: DDFilteredView.cc:42
cms::DDSpecParRegistry::specPar
const DDSpecPar * specPar(std::string_view) const
Definition: DDSpecparRegistry.cc:145
cms::DDSpecParRegistry
Definition: DDSpecParRegistry.h:32
MTDTopologyMode::MTDStringToEnumParser
Mode MTDStringToEnumParser(const std::string &)
Definition: MTDTopologyMode.cc:7
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
DDVectorGetter::get
std::vector< double > get(const std::string &)
Definition: DDVectorGetter.h:28
end
#define end
Definition: vmac.h:39
alignCSCRings.s
s
Definition: alignCSCRings.py:92
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:80
pfDeepBoostedJetPreprocessParams_cfi.sv
sv
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:226
cms::dd::noNamespace
std::string_view noNamespace(std::string_view)
Definition: Filter.cc:63
DDfetch
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:79
DDFilteredView.h
DDCompactView.h
cms::DDSpecParRefs
std::vector< const DDSpecPar * > DDSpecParRefs
Definition: DDSpecParRegistry.h:30
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
MTDTopologyMode
Definition: MTDTopologyMode.h:11
cms::DDSpecPar::strValue
std::string_view strValue(const std::string &) const
Definition: DDSpecparRegistry.cc:10
DDVectorGetter::check
bool check(const std::string &)
Definition: DDVectorGetter.h:13
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
cms::dd::compareEqual
bool compareEqual(std::string_view, std::string_view)
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:33
heppy_batch.val
val
Definition: heppy_batch.py:351
DDValue
Definition: DDValue.h:21
cms::DDSpecParRegistry::filter
void filter(DDSpecParRefs &, const std::string &, const std::string &="") const
Definition: DDSpecparRegistry.cc:98
Exception
Definition: hltDiff.cc:246
cms::DDCompactView
Definition: DDCompactView.h:29
PMTDParameters.h
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
MTDParametersFromDD::build
bool build(const DDCompactView *, PMTDParameters &)
Definition: MTDParametersFromDD.cc:32
DDFilteredView
Definition: DDFilteredView.h:20
mps_fire.result
result
Definition: mps_fire.py:303
DDsvalues_type
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
Definition: DDsvalues.h:12
cms::DDDetector::vectors
DDVectorsMap const & vectors() const
Definition: DDDetector.h:22
cms::DDCompactView::detector
const cms::DDDetector * detector() const
Definition: DDCompactView.h:32