CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Static Private Attributes
DDCmsMTDConstruction Class Reference

#include <DDCmsMTDConstruction.h>

Public Member Functions

 DDCmsMTDConstruction ()=delete
 

Static Public Member Functions

static std::unique_ptr< GeometricTimingDetconstruct (const DDCompactView &cpv)
 
static std::unique_ptr< GeometricTimingDetconstruct (const cms::DDCompactView &cpv)
 

Static Private Attributes

static constexpr size_t kNLayerPreTDR = 3
 
static constexpr size_t kNLayerTDR = 5
 

Detailed Description

High level class to build a tracker. It will only build subdets, then call subdet builders

Definition at line 22 of file DDCmsMTDConstruction.h.

Constructor & Destructor Documentation

◆ DDCmsMTDConstruction()

DDCmsMTDConstruction::DDCmsMTDConstruction ( )
delete

Member Function Documentation

◆ construct() [1/2]

std::unique_ptr< GeometricTimingDet > DDCmsMTDConstruction::construct ( const DDCompactView cpv)
static

Definition at line 46 of file DDCmsMTDConstruction.cc.

References CmsMTDConstruction< FilteredView >::buildBTLModule(), CmsMTDConstruction< FilteredView >::buildETLModule(), CmsMTDConstruction< FilteredView >::buildLayer(), CmsMTDConstruction< FilteredView >::buildSubdet(), AlCaHLTBitMon_QueryRunRegistry::comp, angle_units::operators::convertRadToDeg(), Exception, ALCARECOTkAlBeamHalo_cff::filter, DDFilteredView::firstChild(), ExtractStringFromDD< FilteredView >::getString(), recoMuon::in, CmsMTDConstruction< FilteredView >::isBTLV2(), CmsMTDStringToEnum::kModStrLen, kNLayerPreTDR, kNLayerTDR, nano_mu_digi_cff::layer, remoteMonitoring_LASER_era2018_cfg::limit, angle0to2pi::make0To2pi(), DDFilteredView::name(), EgammaValidation_cff::num, MillePedeFileConverter_cfg::out, DDFilteredView::parent(), AlCaHLTBitMon_QueryRunRegistry::string, and CmsMTDStringToEnum::type().

Referenced by MTDGeometricTimingDetESModule::produce().

46  {
47  std::string attribute{"CMSCutsRegion"};
49  filter.add("mtd:");
50  filter.add("btl:");
51  filter.add("etl:");
52 
53  std::vector<std::string> volnames = {"FSide", "SupportPlate"};
54  for (auto const& theVol : volnames) {
55  filter.veto(theVol);
56  }
57 
58  DDFilteredView fv(cpv, filter);
59 
60  CmsMTDStringToEnum theCmsMTDStringToEnum;
61  // temporary workaround to distinguish BTL scenarios ordering without introducing a dependency on MTDTopologyMode
62  auto isBTLV2 = false;
63 
64  auto check_root = theCmsMTDStringToEnum.type(ExtractStringFromDD<DDFilteredView>::getString(attribute, &fv));
65  if (check_root != GeometricTimingDet::MTD) {
66  fv.firstChild();
67  auto check_child = theCmsMTDStringToEnum.type(ExtractStringFromDD<DDFilteredView>::getString(attribute, &fv));
68  if (check_child != GeometricTimingDet::MTD) {
69  throw cms::Exception("Configuration") << " The first child of the DDFilteredView is not what is expected \n"
70  << ExtractStringFromDD<DDFilteredView>::getString(attribute, &fv) << "\n";
71  }
72  fv.parent();
73  }
74 
75 #ifdef EDM_ML_DEBUG
76  edm::LogInfo("MTDNumbering") << "Top level node = " << fv.name();
77 #endif
78 
79  auto mtd = std::make_unique<GeometricTimingDet>(&fv, GeometricTimingDet::MTD);
80  size_t limit = 0;
81  CmsMTDConstruction<DDFilteredView> theCmsMTDConstruction;
82 
83  std::vector<GeometricTimingDet*> subdet;
84  std::vector<GeometricTimingDet*> layer;
85 
86  do {
87  GeometricTimingDet::GeometricTimingEnumType fullNode = theCmsMTDStringToEnum.type(fv.name());
89  theCmsMTDStringToEnum.type(fv.name().substr(0, CmsMTDStringToEnum::kModStrLen));
90  size_t num = fv.geoHistory().size();
91 
92 #ifdef EDM_ML_DEBUG
93  edm::LogVerbatim("MTDNumbering") << "Module = " << fv.name() << " fullNode = " << fullNode
94  << " thisNode = " << thisNode;
95 #endif
96 
97  if (fullNode == GeometricTimingDet::BTL || fullNode == GeometricTimingDet::ETL) {
98  limit = 0;
99 
100  // define subdetectors as GeometricTimingDet components
101 
102  subdet.emplace_back(theCmsMTDConstruction.buildSubdet(fv));
103  }
104  if (fullNode == GeometricTimingDet::BTLLayer || fullNode == GeometricTimingDet::ETLDisc) {
105  layer.emplace_back(theCmsMTDConstruction.buildLayer(fv));
106 #ifdef EDM_ML_DEBUG
107  edm::LogVerbatim("MTDNumbering") << "Number of layers: " << layer.size();
108 #endif
109  }
110  //
111  // workaround to make old and TDR structure to cohexist until needed
112  // the level chosen for old corresponds to wafers for D50 and previous scenarios
113  //
114  if ((thisNode == GeometricTimingDet::BTLModule) && limit == 0) {
115  if (theCmsMTDConstruction.isBTLV2(fv)) {
116  limit = num;
117  isBTLV2 = true;
118  } else {
119  limit = num + 1;
120  }
121  } else if ((thisNode == GeometricTimingDet::ETLModule) && limit == 0) {
122  limit = num;
123  }
124  if (num != limit && limit > 0) {
125  continue;
126  }
127  if (thisNode == GeometricTimingDet::BTLModule) {
128 #ifdef EDM_ML_DEBUG
129  edm::LogVerbatim("MTDNumbering") << "Registered in GeometricTimingDet as type " << thisNode;
130 #endif
131  theCmsMTDConstruction.buildBTLModule(fv, layer.back());
132  limit = num;
133  } else if (thisNode == GeometricTimingDet::ETLModule) {
134 #ifdef EDM_ML_DEBUG
135  edm::LogVerbatim("MTDNumbering") << "Registered in GeometricTimingDet as type " << thisNode;
136 #endif
137  theCmsMTDConstruction.buildETLModule(fv, layer.back());
138  limit = num;
139  }
140  } while (fv.next());
141 
142  // sort GeometricTimingDet
143 
144 #ifdef EDM_ML_DEBUG
145  auto comp = mtd->deepComponents();
146  std::stringstream before(std::stringstream::in | std::stringstream::out);
147  for (const auto& it : comp) {
148  before << "ORDER1 " << it->geographicalId().rawId() << " " << it->type() << " " << it->translation().z() << "\n";
149  }
150  edm::LogVerbatim("MTDNumbering") << "GeometricTimingDet order before sorting \n" << before.str();
151 #endif
152 
153  if (!isBTLV2) {
154  for (size_t index = 0; index < layer.size(); index++) {
156  std::stable_sort(icomp.begin(), icomp.end(), CmsMTDConstruction<DDFilteredView>::mtdOrderZ);
157  std::stable_sort(icomp.begin(), icomp.end(), CmsMTDConstruction<DDFilteredView>::mtdOrderRR);
158  if (index > 0) {
159  std::stable_sort(icomp.begin(), icomp.end(), CmsMTDConstruction<DDFilteredView>::mtdOrderPhi);
160  }
161  }
162  } else {
163  for (size_t index = 0; index < layer.size(); index++) {
165  if (index > 0) {
166  std::stable_sort(icomp.begin(), icomp.end(), CmsMTDConstruction<DDFilteredView>::mtdOrderZ);
167  std::stable_sort(icomp.begin(), icomp.end(), CmsMTDConstruction<DDFilteredView>::mtdOrderRR);
168  std::stable_sort(icomp.begin(), icomp.end(), CmsMTDConstruction<DDFilteredView>::mtdOrderPhi);
169  } else {
170  std::stable_sort(icomp.begin(), icomp.end(), CmsMTDConstruction<DDFilteredView>::btlOrderPhi);
171  std::stable_sort(icomp.begin(), icomp.end(), CmsMTDConstruction<DDFilteredView>::btlOrderZ);
172  }
173  }
174  }
175 
176  // Add layers to subdetectors:
177  // first BTL (one layer only)
178 
179  subdet[0]->addComponent(layer[0]);
180 
181  // then ETL (number of layers depend on preTDR design or not)
182 
183  if (layer.size() == kNLayerPreTDR) {
184  subdet[1]->addComponent(layer[1]);
185  subdet[2]->addComponent(layer[2]);
186  } else if (layer.size() == kNLayerTDR) {
187  subdet[1]->addComponent(layer[1]);
188  subdet[1]->addComponent(layer[2]);
189  subdet[2]->addComponent(layer[3]);
190  subdet[2]->addComponent(layer[4]);
191  } else {
192  throw cms::Exception("MTDNumbering") << "Wrong number of layers: " << layer.size();
193  }
194 
195  // Add subdetectors to MTD
196 
197  mtd.get()->addComponents(subdet);
198 
199 #ifdef EDM_ML_DEBUG
200  comp.clear();
201  comp = mtd->deepComponents();
202  std::stringstream after(std::stringstream::in | std::stringstream::out);
203  for (const auto& it : comp) {
204  after << "ORDER2 " << it->geographicalId().rawId() << " " << static_cast<MTDDetId>(it->geographicalId()).mtdRR()
205  << " " << it->type() << " " << it->translation().z() << " "
206  << convertRadToDeg(angle0to2pi::make0To2pi(it->phi())) << "\n";
207  }
208  edm::LogVerbatim("MTDNumbering") << "GeometricTimingDet order after sorting \n" << after.str();
209 #endif
210 
211  return mtd;
212 }
Log< level::Info, true > LogVerbatim
bool isBTLV2(FilteredView &)
void buildBTLModule(FilteredView &, GeometricTimingDet *)
GeometricTimingDet * buildSubdet(FilteredView &)
GeometricTimingDet::GeometricTimingEnumType type(std::string const &) const
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
static constexpr size_t kNLayerTDR
static constexpr size_t kModStrLen
static constexpr size_t kNLayerPreTDR
Detector identifier base class for the MIP Timing Layer.
Definition: MTDDetId.h:21
static std::string getString(const std::string &, FilteredView *)
GeometricTimingDet * buildLayer(FilteredView &)
Log< level::Info, false > LogInfo
void buildETLModule(FilteredView &, GeometricTimingDet *)
constexpr valType make0To2pi(valType angle)
Definition: deltaPhi.h:67
enum GTDEnumType { unknown=100, MTD=0, BTL=1, BTLLayer=2, BTLTray=3, BTLModule=4, BTLSensor=5, BTLCrystal=6, ETL=7, ETLDisc=8, ETLRing=9, ETLModule=10, ETLSensor=11 } GeometricTimingEnumType
std::vector< GeometricTimingDet const * > ConstGeometricTimingDetContainer

◆ construct() [2/2]

std::unique_ptr< GeometricTimingDet > DDCmsMTDConstruction::construct ( const cms::DDCompactView cpv)
static

Definition at line 214 of file DDCmsMTDConstruction.cc.

References CmsMTDConstruction< FilteredView >::buildBTLModule(), CmsMTDConstruction< FilteredView >::buildETLModule(), CmsMTDConstruction< FilteredView >::buildLayer(), CmsMTDConstruction< FilteredView >::buildSubdet(), AlCaHLTBitMon_QueryRunRegistry::comp, angle_units::operators::convertRadToDeg(), cms::DDCompactView::detector(), Exception, recoMuon::in, CmsMTDConstruction< FilteredView >::isBTLV2(), CmsMTDStringToEnum::kModStrLen, kNLayerPreTDR, kNLayerTDR, nano_mu_digi_cff::layer, dqm-mbProfile::log, angle0to2pi::make0To2pi(), cms::DDFilteredView::next(), MillePedeFileConverter_cfg::out, cms::DDCompactView::specpars(), AlCaHLTBitMon_QueryRunRegistry::string, submitPVValidationJobs::t, CmsMTDStringToEnum::type(), and cms::DDDetector::worldVolume().

214  {
215  cms::DDFilteredView fv(cpv.detector(), cpv.detector()->worldVolume());
216 
217  fv.next(0);
218  edm::LogVerbatim("DD4hep_MTDNumbering") << fv.path();
219  auto mtd = std::make_unique<GeometricTimingDet>(&fv, GeometricTimingDet::MTD);
220 
221  cms::DDSpecParRefs ref;
222  const cms::DDSpecParRegistry& mypar = cpv.specpars();
223  std::string attribute("MtdDDStructure");
224  mypar.filter(ref, attribute, "BarrelTimingLayer");
225  mypar.filter(ref, attribute, "EndcapTimingLayer");
226  fv.mergedSpecifics(ref);
227 
228 #ifdef EDM_ML_DEBUG
229  edm::LogVerbatim("DD4hep_MTDNumbering") << "Active filters using " << attribute << ":";
230  fv.printFilter();
231  edm::LogVerbatim("Geometry").log([&ref](auto& log) {
232  log << "Filtered DD SpecPar Registry size: " << ref.size() << "\n";
233  for (const auto& t : ref) {
234  log << "\nSpecPar " << t.first << ":\nRegExps { ";
235  for (const auto& ki : t.second->paths)
236  log << ki << " ";
237  log << "};\n ";
238  for (const auto& kl : t.second->spars) {
239  log << kl.first << " = ";
240  for (const auto& kil : kl.second) {
241  log << kil << " ";
242  }
243  log << "\n ";
244  }
245  }
246  });
247 #endif
248 
249  bool doSubdet = fv.firstChild();
250  edm::LogVerbatim("DD4hep_MTDNumbering") << fv.path();
251 
252  CmsMTDStringToEnum theCmsMTDStringToEnum;
253 
254  CmsMTDConstruction<cms::DDFilteredView> theCmsMTDConstruction;
255  // temporary workaround to distinguish BTL scenarios ordering without introducing a dependency on MTDTopologyMode
256  auto isBTLV2 = false;
257 
258  std::vector<GeometricTimingDet*> subdet;
259  std::vector<GeometricTimingDet*> layer;
260 
261  while (doSubdet) {
262  std::string nodeName(fv.name());
263  GeometricTimingDet::GeometricTimingEnumType fullNode = theCmsMTDStringToEnum.type(nodeName);
265  theCmsMTDStringToEnum.type(nodeName.substr(0, CmsMTDStringToEnum::kModStrLen));
266 
267 #ifdef EDM_ML_DEBUG
268  edm::LogVerbatim("DD4hep_MTDNumbering") << fv.path();
269  edm::LogVerbatim("DD4hep_MTDNumbering")
270  << "Module = " << fv.name() << " fullNode = " << fullNode << " thisNode = " << thisNode;
271 #endif
272 
273  if (fullNode == GeometricTimingDet::BTL || fullNode == GeometricTimingDet::ETL) {
274  // define subdetectors as GeometricTimingDet components
275 
276  subdet.emplace_back(theCmsMTDConstruction.buildSubdet(fv));
277  }
278  if (fullNode == GeometricTimingDet::BTLLayer || fullNode == GeometricTimingDet::ETLDisc) {
279  layer.emplace_back(theCmsMTDConstruction.buildLayer(fv));
280 #ifdef EDM_ML_DEBUG
281  edm::LogVerbatim("DD4hep_MTDNumbering") << "Number of layers: " << layer.size();
282 #endif
283  }
284  if (thisNode == GeometricTimingDet::BTLModule) {
285 #ifdef EDM_ML_DEBUG
286  edm::LogVerbatim("DD4hep_MTDNumbering") << "Registered in GeometricTimingDet as type " << thisNode;
287 #endif
288  if (isBTLV2 == false) {
289  if (theCmsMTDConstruction.isBTLV2(fv)) {
290  isBTLV2 = true;
291  }
292  }
293  theCmsMTDConstruction.buildBTLModule(fv, layer.back());
294  } else if (thisNode == GeometricTimingDet::ETLModule) {
295 #ifdef EDM_ML_DEBUG
296  edm::LogVerbatim("DD4hep_MTDNumbering") << "Registered in GeometricTimingDet as type " << thisNode;
297 #endif
298  theCmsMTDConstruction.buildETLModule(fv, layer.back());
299  }
300 
301  doSubdet = fv.firstChild();
302  }
303 
304  // sort GeometricTimingDet
305 
306 #ifdef EDM_ML_DEBUG
307  auto comp = mtd->deepComponents();
308  std::stringstream before(std::stringstream::in | std::stringstream::out);
309  for (const auto& it : comp) {
310  before << "ORDER1 " << it->geographicalId().rawId() << " " << it->type() << " " << it->translation().z() << "\n";
311  }
312  edm::LogVerbatim("DD4hep_MTDNumbering") << "GeometricTimingDet order before sorting \n" << before.str();
313 #endif
314 
315  if (!isBTLV2) {
316  for (size_t index = 0; index < layer.size(); index++) {
318  std::stable_sort(icomp.begin(), icomp.end(), CmsMTDConstruction<DDFilteredView>::mtdOrderZ);
319  std::stable_sort(icomp.begin(), icomp.end(), CmsMTDConstruction<DDFilteredView>::mtdOrderRR);
320  if (index > 0) {
321  std::stable_sort(icomp.begin(), icomp.end(), CmsMTDConstruction<DDFilteredView>::mtdOrderPhi);
322  }
323  }
324  } else {
325  for (size_t index = 0; index < layer.size(); index++) {
327  if (index > 0) {
328  std::stable_sort(icomp.begin(), icomp.end(), CmsMTDConstruction<DDFilteredView>::mtdOrderZ);
329  std::stable_sort(icomp.begin(), icomp.end(), CmsMTDConstruction<DDFilteredView>::mtdOrderRR);
330  std::stable_sort(icomp.begin(), icomp.end(), CmsMTDConstruction<DDFilteredView>::mtdOrderPhi);
331  } else {
332  std::stable_sort(icomp.begin(), icomp.end(), CmsMTDConstruction<DDFilteredView>::btlOrderPhi);
333  std::stable_sort(icomp.begin(), icomp.end(), CmsMTDConstruction<DDFilteredView>::btlOrderZ);
334  }
335  }
336  }
337 
338  // Add layers to subdetectors:
339  // first BTL (one layer only)
340 
341  subdet[0]->addComponent(layer[0]);
342 
343  // then ETL (number of layers depend on preTDR design or not)
344 
345  if (layer.size() == kNLayerPreTDR) {
346  subdet[1]->addComponent(layer[1]);
347  subdet[2]->addComponent(layer[2]);
348  } else if (layer.size() == kNLayerTDR) {
349  subdet[1]->addComponent(layer[1]);
350  subdet[1]->addComponent(layer[2]);
351  subdet[2]->addComponent(layer[3]);
352  subdet[2]->addComponent(layer[4]);
353  } else {
354  throw cms::Exception("DD4hep_MTDNumbering") << "Wrong number of layers: " << layer.size();
355  }
356 
357  // Add subdetectors to MTD
358 
359  mtd.get()->addComponents(subdet);
360 
361 #ifdef EDM_ML_DEBUG
362  comp.clear();
363  comp = mtd->deepComponents();
364  std::stringstream after(std::stringstream::in | std::stringstream::out);
365  for (const auto& it : comp) {
366  after << "ORDER2 " << it->geographicalId().rawId() << " " << static_cast<MTDDetId>(it->geographicalId()).mtdRR()
367  << " " << it->type() << " " << it->translation().z() << " "
368  << convertRadToDeg(angle0to2pi::make0To2pi(it->phi())) << "\n";
369  }
370  edm::LogVerbatim("DD4hep_MTDNumbering") << "GeometricTimingDet order after sorting \n" << after.str();
371 #endif
372 
373  return mtd;
374 }
Log< level::Info, true > LogVerbatim
bool isBTLV2(FilteredView &)
void buildBTLModule(FilteredView &, GeometricTimingDet *)
GeometricTimingDet * buildSubdet(FilteredView &)
GeometricTimingDet::GeometricTimingEnumType type(std::string const &) const
dd4hep::SpecParRefs DDSpecParRefs
Definition: DDCompactView.h:29
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
const cms::DDDetector * detector() const
Definition: DDCompactView.h:34
DDSpecParRegistry const & specpars() const
Definition: DDCompactView.h:35
static constexpr size_t kNLayerTDR
static constexpr size_t kModStrLen
static constexpr size_t kNLayerPreTDR
Detector identifier base class for the MIP Timing Layer.
Definition: MTDDetId.h:21
dd4hep::SpecParRegistry DDSpecParRegistry
Definition: DDCompactView.h:28
GeometricTimingDet * buildLayer(FilteredView &)
bool next(int)
set current node to the next node in the filtered tree
void buildETLModule(FilteredView &, GeometricTimingDet *)
dd4hep::Volume worldVolume() const
Handle to the world volume containing everything.
Definition: DDDetector.cc:67
constexpr valType make0To2pi(valType angle)
Definition: deltaPhi.h:67
enum GTDEnumType { unknown=100, MTD=0, BTL=1, BTLLayer=2, BTLTray=3, BTLModule=4, BTLSensor=5, BTLCrystal=6, ETL=7, ETLDisc=8, ETLRing=9, ETLModule=10, ETLSensor=11 } GeometricTimingEnumType
std::vector< GeometricTimingDet const * > ConstGeometricTimingDetContainer

Member Data Documentation

◆ kNLayerPreTDR

constexpr size_t DDCmsMTDConstruction::kNLayerPreTDR = 3
staticprivate

Definition at line 29 of file DDCmsMTDConstruction.h.

Referenced by construct().

◆ kNLayerTDR

constexpr size_t DDCmsMTDConstruction::kNLayerTDR = 5
staticprivate

Definition at line 30 of file DDCmsMTDConstruction.h.

Referenced by construct().