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 cms::DDCompactView *, PMTDParameters &)
 
bool build (const 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 cms::DDCompactView cvp,
PMTDParameters ptp 
)

Definition at line 89 of file MTDParametersFromDD.cc.

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

References MTDTopologyMode::btlv1etlv5, cms::DDCompactView::detector(), mps_fire::end, Exception, newFWLiteAna::found, mps_fire::i, MTDTopologyMode::MTDStringToEnumParser(), Skims_PA_cff::name, cms::DDCompactView::specpars(), AlCaHLTBitMon_QueryRunRegistry::string, PMTDParameters::topologyMode_, cms::DDDetector::vectors(), and PMTDParameters::vpars_.

◆ build() [2/2]

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

Definition at line 33 of file MTDParametersFromDD.cc.

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 
62  if (topoMode >= static_cast<int>(MTDTopologyMode::Mode::btlv1etlv5)) {
63  std::array<std::string, 8> etlLayout{{
64  "StartCopyNo_Front_Left",
65  "StartCopyNo_Front_Right",
66  "StartCopyNo_Back_Left",
67  "StartCopyNo_Back_Right",
68  "Offset_Front_Left",
69  "Offset_Front_Right",
70  "Offset_Back_Left",
71  "Offset_Back_Right",
72  }};
73  int sector(10);
74  for (const auto& name : etlLayout) {
75  auto const& v = cvp->vector(name);
76  if (!v.empty()) {
77  sector++;
78  std::vector<int> ipos = dbl_to_int(v);
79  putOne(sector, ipos, ptp);
80  } else {
81  throw cms::Exception("MTDParametersFromDD") << "Not found " << name << " but needed.";
82  }
83  }
84  }
85 
86  return true;
87 }

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

Referenced by MTDParametersESModule::produce().

◆ putOne()

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

Definition at line 169 of file MTDParametersFromDD.cc.

169  {
171  item.id_ = subdet;
172  item.vpars_ = vpars;
173  ptp.vitems_.emplace_back(item);
174 #ifdef EDM_ML_DEBUG
175  auto print_item = [&]() {
176  std::stringstream ss;
177  ss << item.id_ << " with " << item.vpars_.size() << " elements:";
178  for (const auto& thePar : item.vpars_) {
179  ss << " " << thePar;
180  }
181  return ss.str();
182  };
183  edm::LogInfo("MTDParametersFromDD") << "Adding PMTDParameters item: " << print_item();
184 #endif
185 }

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

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
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
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
findQualityFiles.v
v
Definition: findQualityFiles.py:179
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
MTDTopologyMode::Mode::btlv1etlv5
cms::DDSpecParRegistry
dd4hep::SpecParRegistry DDSpecParRegistry
Definition: DDCompactView.h:28
pfDeepBoostedJetPreprocessParams_cfi.sv
sv
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:352
mps_fire.end
end
Definition: mps_fire.py:242
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
MTDParametersFromDD::putOne
void putOne(int, std::vector< int > &, PMTDParameters &)
Definition: MTDParametersFromDD.cc:169
DDSpecificsHasNamedValueFilter
Definition: DDFilter.h:60
PMTDParameters::topologyMode_
int topologyMode_
Definition: PMTDParameters.h:20
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
MTDTopologyMode::Mode
Mode
Definition: MTDTopologyMode.h:13
PMTDParameters::Item
Definition: PMTDParameters.h:11
cms::DDCompactView::specpars
DDSpecParRegistry const & specpars() const
Definition: DDCompactView.h:35
Exception
Definition: hltDiff.cc:245
cms::DDVectorsMap
std::unordered_map< std::string, std::vector< double > > DDVectorsMap
Definition: DDNamespace.h:14
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
DDFilteredView
Definition: DDFilteredView.h:20
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
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