CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions
MTDParametersFromDD Class Reference

#include <MTDParametersFromDD.h>

Public Member Functions

bool build (const DDCompactView *, PMTDParameters &)
 
bool build (const cms::DDCompactView *, PMTDParameters &)
 
 MTDParametersFromDD ()
 
virtual ~MTDParametersFromDD ()
 

Private Member Functions

void putOne (int, std::vector< int > &, PMTDParameters &)
 

Detailed Description

Definition at line 14 of file MTDParametersFromDD.h.

Constructor & Destructor Documentation

◆ MTDParametersFromDD()

MTDParametersFromDD::MTDParametersFromDD ( )
inline

Definition at line 16 of file MTDParametersFromDD.h.

16 {}

◆ ~MTDParametersFromDD()

virtual MTDParametersFromDD::~MTDParametersFromDD ( )
inlinevirtual

Definition at line 17 of file MTDParametersFromDD.h.

17 {}

Member Function Documentation

◆ build() [1/2]

bool MTDParametersFromDD::build ( const DDCompactView cvp,
PMTDParameters ptp 
)

Definition at line 33 of file MTDParametersFromDD.cc.

References dbl_to_int(), MTDTopologyMode::etlLayoutFromTopoMode(), Exception, DDFilteredView::firstChild(), DDFilteredView::mergedSpecifics(), Skims_PA_cff::name, convertSQLiteXML::ok, nano_mu_digi_cff::sector, AlCaHLTBitMon_QueryRunRegistry::string, pfDeepBoostedJetPreprocessParams_cfi::sv, PMTDParameters::topologyMode_, findQualityFiles::v, ETLDetId::v5, ETLDetId::v8, DDCompactView::vector(), and PMTDParameters::vpars_.

Referenced by MTDParametersESModule::produce().

33  {
34  std::array<std::string, 2> mtdSubdet{{"BTL", "ETL"}};
35  int subdet(0);
36  for (const auto& name : mtdSubdet) {
37  auto const& v = cvp->vector(name);
38  if (!v.empty()) {
39  subdet++;
40  std::vector<int> subdetPars = dbl_to_int(v);
41  putOne(subdet, subdetPars, ptp);
42  } else {
43  throw cms::Exception("MTDParametersFromDD") << "Not found " << name << " but needed.";
44  }
45  }
46 
47  ptp.vpars_ = dbl_to_int(cvp->vector("vPars"));
48 
49  std::string attribute = "OnlyForMTDRecNumbering";
50  DDSpecificsHasNamedValueFilter filter1{attribute};
51  DDFilteredView fv1(*cvp, filter1);
52  bool ok = fv1.firstChild();
53  int topoMode(-1);
54  if (ok) {
55  DDsvalues_type sv(fv1.mergedSpecifics());
56  topoMode = getMTDTopologyMode("TopologyMode", sv);
57  ptp.topologyMode_ = topoMode;
58  } else {
59  throw cms::Exception("MTDParametersFromDD") << "Not found " << attribute.c_str() << " but needed.";
60  }
61 
64  std::array<std::string, 8> etlLayout{{
65  "StartCopyNo_Front_Left",
66  "StartCopyNo_Front_Right",
67  "StartCopyNo_Back_Left",
68  "StartCopyNo_Back_Right",
69  "Offset_Front_Left",
70  "Offset_Front_Right",
71  "Offset_Back_Left",
72  "Offset_Back_Right",
73  }};
74  int sector(10);
75  for (const auto& name : etlLayout) {
76  auto const& v = cvp->vector(name);
77  if (!v.empty()) {
78  sector++;
79  std::vector<int> ipos = dbl_to_int(v);
80  putOne(sector, ipos, ptp);
81  } else {
82  throw cms::Exception("MTDParametersFromDD") << "Not found " << name << " but needed.";
83  }
84  }
85  }
86 
87  return true;
88 }
std::vector< double > const & vector(std::string_view iKey) const
returns an empty container if not found
void putOne(int, std::vector< int > &, PMTDParameters &)
std::vector< int > vpars_
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
Definition: DDsvalues.h:12
ETLDetId::EtlLayout etlLayoutFromTopoMode(const int &topoMode)
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

◆ build() [2/2]

bool MTDParametersFromDD::build ( const cms::DDCompactView cvp,
PMTDParameters ptp 
)

Definition at line 90 of file MTDParametersFromDD.cc.

References cms::DDCompactView::detector(), MTDTopologyMode::etlLayoutFromTopoMode(), Exception, newFWLiteAna::found, mps_fire::i, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, MTDTopologyMode::MTDStringToEnumParser(), Skims_PA_cff::name, nano_mu_digi_cff::sector, cms::DDCompactView::specpars(), AlCaHLTBitMon_QueryRunRegistry::string, PMTDParameters::topologyMode_, ETLDetId::v5, ETLDetId::v8, cms::DDDetector::vectors(), and PMTDParameters::vpars_.

90  {
91  cms::DDVectorsMap vmap = cvp->detector()->vectors();
92 
93  std::array<std::string, 2> mtdSubdet{{"BTL", "ETL"}};
94  int subdet(0);
95  for (const auto& name : mtdSubdet) {
96  bool found(false);
97  for (auto const& it : vmap) {
98  if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first), name)) {
99  subdet++;
100  std::vector<int> subdetPars;
101  subdetPars.reserve(it.second.size());
102  for (const auto& i : it.second)
103  subdetPars.emplace_back(std::round(i));
104  putOne(subdet, subdetPars, ptp);
105  found = true;
106  break;
107  }
108  }
109  if (!found) {
110  throw cms::Exception("MTDParametersFromDD") << "Not found " << name << " but needed.";
111  }
112  }
113 
114  auto it = vmap.find("vPars");
115  if (it != end(vmap)) {
116  std::vector<int> tmpVec;
117  for (const auto& i : it->second)
118  tmpVec.emplace_back(std::round(i));
119  ptp.vpars_ = tmpVec;
120  }
121 
122  cms::DDSpecParRefs ref;
123  const cms::DDSpecParRegistry& mypar = cvp->specpars();
124  std::string attribute = "OnlyForMTDRecNumbering";
125  mypar.filter(ref, attribute, "MTD");
126 
127  std::string topoModeS(mypar.specPar("mtdNumbering")->strValue("TopologyMode"));
128  int topoMode(-1);
129  if (!topoModeS.empty()) {
131  topoMode = static_cast<int>(eparser);
132  ptp.topologyMode_ = topoMode;
133  } else {
134  throw cms::Exception("MTDParametersFromDD") << "Not found " << attribute.c_str() << " but needed.";
135  }
136 
139  std::array<std::string, 8> etlLayout{{
140  "StartCopyNo_Front_Left",
141  "StartCopyNo_Front_Right",
142  "StartCopyNo_Back_Left",
143  "StartCopyNo_Back_Right",
144  "Offset_Front_Left",
145  "Offset_Front_Right",
146  "Offset_Back_Left",
147  "Offset_Back_Right",
148  }};
149  int sector(10); // add vector index with offset, to distinguish from subdet
150  for (const auto& name : etlLayout) {
151  bool found(false);
152  for (auto const& it : vmap) {
153  if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first), name)) {
154  sector++;
155  std::vector<int> ipos;
156  ipos.reserve(it.second.size());
157  for (const auto& i : it.second)
158  ipos.emplace_back(std::round(i));
159  putOne(sector, ipos, ptp);
160  found = true;
161  break;
162  }
163  }
164  if (!found) {
165  throw cms::Exception("MTDParametersFromDD") << "Not found " << name << " but needed.";
166  }
167  }
168  }
169 
170  return true;
171 }
dd4hep::SpecParRefs DDSpecParRefs
Definition: DDCompactView.h:29
const cms::DDDetector * detector() const
Definition: DDCompactView.h:34
DDSpecParRegistry const & specpars() const
Definition: DDCompactView.h:35
void putOne(int, std::vector< int > &, PMTDParameters &)
std::vector< int > vpars_
std::unordered_map< std::string, std::vector< double > > DDVectorsMap
Definition: DDNamespace.h:20
dd4hep::SpecParRegistry DDSpecParRegistry
Definition: DDCompactView.h:28
Mode MTDStringToEnumParser(const std::string &)
ETLDetId::EtlLayout etlLayoutFromTopoMode(const int &topoMode)
cms::DDVectorsMap const & vectors() const
Definition: DDDetector.h:17

◆ putOne()

void MTDParametersFromDD::putOne ( int  subdet,
std::vector< int > &  vpars,
PMTDParameters ptp 
)
private

Definition at line 173 of file MTDParametersFromDD.cc.

References B2GTnPMonitor_cfi::item, contentValuesCheck::ss, and PMTDParameters::vitems_.

173  {
175  item.id_ = subdet;
176  item.vpars_ = vpars;
177  ptp.vitems_.emplace_back(item);
178 #ifdef EDM_ML_DEBUG
179  auto print_item = [&]() {
180  std::stringstream ss;
181  ss << item.id_ << " with " << item.vpars_.size() << " elements:";
182  for (const auto& thePar : item.vpars_) {
183  ss << " " << thePar;
184  }
185  return ss.str();
186  };
187  edm::LogInfo("MTDParametersFromDD") << "Adding PMTDParameters item: " << print_item();
188 #endif
189 }
std::vector< Item > vitems_
Log< level::Info, false > LogInfo