CMS 3D CMS Logo

DDDefinitions2Objects.cc
Go to the documentation of this file.
1 #include "DD4hep/DetFactoryHelper.h"
2 #include "DD4hep/DetectorHelper.h"
3 #include "DD4hep/DD4hepUnits.h"
4 #include "DD4hep/GeoHandler.h"
5 #include "DD4hep/Printout.h"
6 #include "DD4hep/Plugins.h"
7 #include "DD4hep/detail/SegmentationsInterna.h"
8 #include "DD4hep/detail/DetectorInterna.h"
9 #include "DD4hep/detail/ObjectsInterna.h"
10 #include "DD4hep/MatrixHelpers.h"
11 
12 #include "XML/Utilities.h"
20 
21 #include "TGeoManager.h"
22 #include "TGeoMaterial.h"
23 
24 #include <climits>
25 #include <iostream>
26 #include <iomanip>
27 #include <map>
28 #include <utility>
29 #include "tbb/concurrent_unordered_map.h"
30 #include "tbb/concurrent_vector.h"
31 
32 using namespace std;
33 using namespace dd4hep;
34 using namespace cms;
35 using namespace cms_units::operators;
36 
37 namespace dd4hep {
38 
39  namespace {
40 
41  atomic<UInt_t> unique_mat_id = 0xAFFEFEED;
42 
43  class disabled_algo;
44  class include_constants;
45  class include_load;
46  class include_unload;
47  class print_xml_doc;
48 
49  class ConstantsSection;
50  class DDLConstant;
51 
52  struct DDRegistry {
53  tbb::concurrent_vector<xml::Document> includes;
54  tbb::concurrent_unordered_map<std::string, std::string> unresolvedConst, allConst, originalConst;
55  };
56 
57  class MaterialSection;
60 
61  class RotationSection;
62  class DDLRotation;
63  class DDLReflectionRotation;
64  class DDLRotationSequence;
65  class DDLRotationByAxis;
66  class DDLTransform3D;
67 
68  class PosPartSection;
69  class DDLPosPart;
70  class DDLDivision;
71 
72  class LogicalPartSection;
73  class DDLLogicalPart;
74 
75  class SolidSection;
76  class DDLExtrudedPolygon;
77  class DDLShapeless;
78  class DDLTrapezoid;
79  class DDLEllipticalTube;
80  class DDLPseudoTrap;
81  class DDLPolyhedra;
82  class DDLPolycone;
83  class DDLTorus;
84  class DDLTrd1;
85  class DDLTrd2;
86  class DDLTruncTubs;
87  class DDLCutTubs;
88  class DDLTubs;
89  class DDLBox;
90  class DDLCone;
91  class DDLSphere;
92  class DDLUnionSolid;
93  class DDLIntersectionSolid;
94  class DDLSubtractionSolid;
95 
96  class DDLAlgorithm;
97  class DDLVector;
98 
99  class SpecParSection;
100  class SpecPar;
101  class PartSelector;
102  class Parameter;
103 
104  class vissection;
105  class vis;
106  class debug;
107  } // namespace
108 
109  TGeoCombiTrans* createPlacement(const Rotation3D& iRot, const Position& iTrans) {
110  double elements[9];
111  iRot.GetComponents(elements);
112  TGeoRotation r;
113  r.SetMatrix(elements);
114 
115  TGeoTranslation t(iTrans.x(), iTrans.y(), iTrans.z());
116 
117  return new TGeoCombiTrans(t, r);
118  }
119 
121  template <>
122  void Converter<debug>::operator()(xml_h element) const;
123  template <>
124  void Converter<print_xml_doc>::operator()(xml_h element) const;
125  template <>
126  void Converter<disabled_algo>::operator()(xml_h element) const;
127 
129  template <>
130  void Converter<ConstantsSection>::operator()(xml_h element) const;
131  template <>
132  void Converter<DDLConstant>::operator()(xml_h element) const;
133  template <>
134  void Converter<DDRegistry>::operator()(xml_h element) const;
135 
137  template <>
138  void Converter<vissection>::operator()(xml_h element) const;
140  template <>
141  void Converter<vis>::operator()(xml_h element) const;
142 
144  template <>
145  void Converter<MaterialSection>::operator()(xml_h element) const;
146  template <>
147  void Converter<DDLElementaryMaterial>::operator()(xml_h element) const;
148  template <>
149  void Converter<DDLCompositeMaterial>::operator()(xml_h element) const;
150 
152  template <>
153  void Converter<RotationSection>::operator()(xml_h element) const;
155  template <>
156  void Converter<DDLRotation>::operator()(xml_h element) const;
158  template <>
159  void Converter<DDLReflectionRotation>::operator()(xml_h element) const;
161  template <>
162  void Converter<DDLRotationSequence>::operator()(xml_h element) const;
164  template <>
165  void Converter<DDLRotationByAxis>::operator()(xml_h element) const;
166  template <>
167  void Converter<DDLTransform3D>::operator()(xml_h element) const;
168 
170  template <>
171  void Converter<LogicalPartSection>::operator()(xml_h element) const;
172  template <>
173  void Converter<DDLLogicalPart>::operator()(xml_h element) const;
174 
176  template <>
177  void Converter<PosPartSection>::operator()(xml_h element) const;
179  template <>
180  void Converter<DDLPosPart>::operator()(xml_h element) const;
182  template <>
183  void Converter<DDLDivision>::operator()(xml_h element) const;
184 
186  template <>
187  void Converter<SpecParSection>::operator()(xml_h element) const;
188  template <>
189  void Converter<SpecPar>::operator()(xml_h element) const;
190  template <>
191  void Converter<PartSelector>::operator()(xml_h element) const;
192  template <>
193  void Converter<Parameter>::operator()(xml_h element) const;
194 
196  template <>
197  void Converter<SolidSection>::operator()(xml_h element) const;
199  template <>
200  void Converter<DDLUnionSolid>::operator()(xml_h element) const;
202  template <>
203  void Converter<DDLSubtractionSolid>::operator()(xml_h element) const;
205  template <>
206  void Converter<DDLIntersectionSolid>::operator()(xml_h element) const;
208  template <>
209  void Converter<DDLPseudoTrap>::operator()(xml_h element) const;
211  template <>
212  void Converter<DDLExtrudedPolygon>::operator()(xml_h element) const;
214  template <>
215  void Converter<DDLShapeless>::operator()(xml_h element) const;
217  template <>
218  void Converter<DDLTrapezoid>::operator()(xml_h element) const;
220  template <>
221  void Converter<DDLPolycone>::operator()(xml_h element) const;
223  template <>
224  void Converter<DDLPolyhedra>::operator()(xml_h element) const;
226  template <>
227  void Converter<DDLEllipticalTube>::operator()(xml_h element) const;
229  template <>
230  void Converter<DDLTorus>::operator()(xml_h element) const;
232  template <>
233  void Converter<DDLTubs>::operator()(xml_h element) const;
235  template <>
236  void Converter<DDLCutTubs>::operator()(xml_h element) const;
238  template <>
239  void Converter<DDLTruncTubs>::operator()(xml_h element) const;
241  template <>
242  void Converter<DDLSphere>::operator()(xml_h element) const;
244  template <>
245  void Converter<DDLTrd1>::operator()(xml_h element) const;
247  template <>
248  void Converter<DDLTrd2>::operator()(xml_h element) const;
250  template <>
251  void Converter<DDLCone>::operator()(xml_h element) const;
253  template <>
254  void Converter<DDLBox>::operator()(xml_h element) const;
256  template <>
257  void Converter<DDLAlgorithm>::operator()(xml_h element) const;
259  template <>
260  void Converter<DDLVector>::operator()(xml_h element) const;
261 
263  template <>
264  void Converter<include_load>::operator()(xml_h element) const;
266  template <>
267  void Converter<include_unload>::operator()(xml_h element) const;
269  template <>
270  void Converter<include_constants>::operator()(xml_h element) const;
271 } // namespace dd4hep
272 
274 template <>
275 void Converter<ConstantsSection>::operator()(xml_h element) const {
276  cms::DDNamespace ns(_param<cms::DDParsingContext>(), element);
277  cms::DDParsingContext* const context = ns.context();
278  xml_coll_t(element, DD_CMU(Constant)).for_each(Converter<DDLConstant>(description, context, optional));
279  xml_coll_t(element, DD_CMU(Vector)).for_each(Converter<DDLVector>(description, context, optional));
280 }
281 
283 template <>
284 void Converter<vissection>::operator()(xml_h element) const {
285  cms::DDNamespace ns(_param<cms::DDParsingContext>(), element);
286  xml_coll_t(element, DD_CMU(vis)).for_each(Converter<vis>(description, ns.context(), optional));
287 }
288 
290 template <>
291 void Converter<MaterialSection>::operator()(xml_h element) const {
292  cms::DDNamespace ns(_param<cms::DDParsingContext>(), element);
293  xml_coll_t(element, DD_CMU(ElementaryMaterial))
294  .for_each(Converter<DDLElementaryMaterial>(description, ns.context(), optional));
295  xml_coll_t(element, DD_CMU(CompositeMaterial))
296  .for_each(Converter<DDLCompositeMaterial>(description, ns.context(), optional));
297 }
298 
299 template <>
300 void Converter<RotationSection>::operator()(xml_h element) const {
301  cms::DDNamespace ns(_param<cms::DDParsingContext>(), element);
302  xml_coll_t(element, DD_CMU(Rotation)).for_each(Converter<DDLRotation>(description, ns.context(), optional));
303  xml_coll_t(element, DD_CMU(ReflectionRotation))
304  .for_each(Converter<DDLReflectionRotation>(description, ns.context(), optional));
305  xml_coll_t(element, DD_CMU(RotationSequence))
306  .for_each(Converter<DDLRotationSequence>(description, ns.context(), optional));
307  xml_coll_t(element, DD_CMU(RotationByAxis))
308  .for_each(Converter<DDLRotationByAxis>(description, ns.context(), optional));
309 }
310 
311 template <>
312 void Converter<PosPartSection>::operator()(xml_h element) const {
313  cms::DDNamespace ns(_param<cms::DDParsingContext>(), element);
314  xml_coll_t(element, DD_CMU(Division)).for_each(Converter<DDLDivision>(description, ns.context(), optional));
315  xml_coll_t(element, DD_CMU(PosPart)).for_each(Converter<DDLPosPart>(description, ns.context(), optional));
316  xml_coll_t(element, DD_CMU(Algorithm)).for_each(Converter<DDLAlgorithm>(description, ns.context(), optional));
317 }
318 
319 template <>
320 void Converter<SpecParSection>::operator()(xml_h element) const {
321  cms::DDNamespace ns(_param<cms::DDParsingContext>(), element);
322  xml_coll_t(element, DD_CMU(SpecPar)).for_each(Converter<SpecPar>(description, ns.context(), optional));
323 }
324 
325 template <>
326 void Converter<SpecPar>::operator()(xml_h element) const {
327  cms::DDNamespace ns(_param<cms::DDParsingContext>(), element);
328  xml_coll_t(element, DD_CMU(PartSelector)).for_each(Converter<PartSelector>(description, ns.context(), optional));
329  xml_coll_t(element, DD_CMU(Parameter)).for_each(Converter<Parameter>(description, ns.context(), optional));
330 }
331 
333 template <>
334 void Converter<LogicalPartSection>::operator()(xml_h element) const {
335  cms::DDNamespace ns(_param<cms::DDParsingContext>(), element);
336  xml_coll_t(element, DD_CMU(LogicalPart)).for_each(Converter<DDLLogicalPart>(description, ns.context(), optional));
337 }
338 
339 template <>
340 void Converter<disabled_algo>::operator()(xml_h element) const {
341  cms::DDParsingContext* c = _param<cms::DDParsingContext>();
342  c->disabledAlgs.emplace_back(element.attr<string>(_U(name)));
343 }
344 
346 template <>
347 void Converter<SolidSection>::operator()(xml_h element) const {
348  cms::DDNamespace ns(_param<cms::DDParsingContext>(), element);
349  for (xml_coll_t solid(element, _U(star)); solid; ++solid) {
350  string tag = solid.tag();
351  using cms::hash;
352  switch (hash(solid.tag())) {
353  case hash("Box"):
354  Converter<DDLBox>(description, ns.context(), optional)(solid);
355  break;
356  case hash("Polycone"):
357  Converter<DDLPolycone>(description, ns.context(), optional)(solid);
358  break;
359  case hash("Polyhedra"):
360  Converter<DDLPolyhedra>(description, ns.context(), optional)(solid);
361  break;
362  case hash("Tubs"):
363  Converter<DDLTubs>(description, ns.context(), optional)(solid);
364  break;
365  case hash("CutTubs"):
366  Converter<DDLCutTubs>(description, ns.context(), optional)(solid);
367  break;
368  case hash("TruncTubs"):
369  Converter<DDLTruncTubs>(description, ns.context(), optional)(solid);
370  break;
371  case hash("Tube"):
372  Converter<DDLTubs>(description, ns.context(), optional)(solid);
373  break;
374  case hash("Trd1"):
375  Converter<DDLTrd1>(description, ns.context(), optional)(solid);
376  break;
377  case hash("Trd2"):
378  Converter<DDLTrd2>(description, ns.context(), optional)(solid);
379  break;
380  case hash("Cone"):
381  Converter<DDLCone>(description, ns.context(), optional)(solid);
382  break;
383  case hash("Sphere"):
384  Converter<DDLSphere>(description, ns.context(), optional)(solid);
385  break;
386  case hash("EllipticalTube"):
387  Converter<DDLEllipticalTube>(description, ns.context(), optional)(solid);
388  break;
389  case hash("Torus"):
390  Converter<DDLTorus>(description, ns.context(), optional)(solid);
391  break;
392  case hash("PseudoTrap"):
393  Converter<DDLPseudoTrap>(description, ns.context(), optional)(solid);
394  break;
395  case hash("ExtrudedPolygon"):
396  Converter<DDLExtrudedPolygon>(description, ns.context(), optional)(solid);
397  break;
398  case hash("Trapezoid"):
399  Converter<DDLTrapezoid>(description, ns.context(), optional)(solid);
400  break;
401  case hash("UnionSolid"):
402  Converter<DDLUnionSolid>(description, ns.context(), optional)(solid);
403  break;
404  case hash("SubtractionSolid"):
405  Converter<DDLSubtractionSolid>(description, ns.context(), optional)(solid);
406  break;
407  case hash("IntersectionSolid"):
408  Converter<DDLIntersectionSolid>(description, ns.context(), optional)(solid);
409  break;
410  case hash("ShapelessSolid"):
411  Converter<DDLShapeless>(description, ns.context(), optional)(solid);
412  break;
413  default:
414  throw std::runtime_error("Request to process unknown shape '" + xml_dim_t(solid).nameStr() + "' [" + tag + "]");
415  break;
416  }
417  }
418 }
419 
421 template <>
422 void Converter<DDLConstant>::operator()(xml_h element) const {
423  cms::DDNamespace ns(_param<cms::DDParsingContext>());
424  DDRegistry* res = _option<DDRegistry>();
425  xml_dim_t constant = element;
426  xml_dim_t par = constant.parent();
427  bool eval = par.hasAttr(_U(eval)) ? par.attr<bool>(_U(eval)) : false;
428  string val = constant.valueStr();
429  string nam = constant.nameStr();
430  string real = ns.prepend(nam);
431  string typ = eval ? "number" : "string";
432  size_t idx = val.find('[');
433 
434  if (constant.hasAttr(_U(type)))
435  typ = constant.typeStr();
436 
437  if (idx == string::npos || typ == "string") {
438  try {
439  ns.addConstant(nam, val, typ);
440  res->allConst[real] = val;
441  res->originalConst[real] = val;
442  } catch (const exception& e) {
443  printout(INFO,
444  "DD4CMS",
445  "++ Unresolved constant: %s = %s [%s]. Try to resolve later. [%s]",
446  real.c_str(),
447  val.c_str(),
448  typ.c_str(),
449  e.what());
450  }
451  return;
452  }
453  // Setup the resolution mechanism in Converter<resolve>
454  while (idx != string::npos) {
455  ++idx;
456  size_t idp = val.find(':', idx);
457  size_t idq = val.find(']', idx);
458  if (idp == string::npos || idp > idq)
459  val.insert(idx, ns.name());
460  else if (idp != string::npos && idp < idq)
461  val[idp] = NAMESPACE_SEP;
462  idx = val.find('[', idx);
463  }
464  printout(
465  ns.context()->debug_constants ? ALWAYS : DEBUG, "Constant", "Unresolved: %s -> %s", real.c_str(), val.c_str());
466  res->allConst[real] = val;
467  res->originalConst[real] = val;
468  res->unresolvedConst[real] = val;
469 }
470 
479 template <>
480 void Converter<vis>::operator()(xml_h e) const {
481  cms::DDNamespace ns(_param<cms::DDParsingContext>());
482  VisAttr attr(e.attr<string>(_U(name)));
483  float red = e.hasAttr(_U(r)) ? e.attr<float>(_U(r)) : 1.0f;
484  float green = e.hasAttr(_U(g)) ? e.attr<float>(_U(g)) : 1.0f;
485  float blue = e.hasAttr(_U(b)) ? e.attr<float>(_U(b)) : 1.0f;
486 
487  printout(ns.context()->debug_visattr ? ALWAYS : DEBUG,
488  "Compact",
489  "++ Converting VisAttr structure: %-16s. R=%.3f G=%.3f B=%.3f",
490  attr.name(),
491  red,
492  green,
493  blue);
494  attr.setColor(red, green, blue);
495  if (e.hasAttr(_U(alpha)))
496  attr.setAlpha(e.attr<float>(_U(alpha)));
497  if (e.hasAttr(_U(visible)))
498  attr.setVisible(e.attr<bool>(_U(visible)));
499  if (e.hasAttr(_U(lineStyle))) {
500  string ls = e.attr<string>(_U(lineStyle));
501  if (ls == "unbroken")
502  attr.setLineStyle(VisAttr::SOLID);
503  else if (ls == "broken")
504  attr.setLineStyle(VisAttr::DASHED);
505  } else {
506  attr.setLineStyle(VisAttr::SOLID);
507  }
508  if (e.hasAttr(_U(drawingStyle))) {
509  string ds = e.attr<string>(_U(drawingStyle));
510  if (ds == "wireframe")
511  attr.setDrawingStyle(VisAttr::WIREFRAME);
512  else if (ds == "solid")
513  attr.setDrawingStyle(VisAttr::SOLID);
514  } else {
515  attr.setDrawingStyle(VisAttr::SOLID);
516  }
517  if (e.hasAttr(_U(showDaughters)))
518  attr.setShowDaughters(e.attr<bool>(_U(showDaughters)));
519  else
520  attr.setShowDaughters(true);
521  description.addVisAttribute(attr);
522 }
523 
525 template <>
526 void Converter<DDLElementaryMaterial>::operator()(xml_h element) const {
527  cms::DDNamespace ns(_param<cms::DDParsingContext>());
528  xml_dim_t xmat(element);
529  string nam = ns.prepend(xmat.nameStr());
530  TGeoManager& mgr = description.manager();
531  TGeoMaterial* mat = mgr.GetMaterial(nam.c_str());
532  if (nullptr == mat) {
533  const char* matname = nam.c_str();
534  double density = xmat.attr<double>(DD_CMU(density)) / (dd4hep::g / dd4hep::cm3);
535  int atomicNumber = xmat.attr<int>(DD_CMU(atomicNumber));
536  double atomicWeight = xmat.attr<double>(DD_CMU(atomicWeight)) / (dd4hep::g / dd4hep::mole);
537  TGeoElementTable* tab = mgr.GetElementTable();
538  int nElem = tab->GetNelements();
539  printout(ns.context()->debug_materials ? ALWAYS : DEBUG, "DD4CMS", "+++ Element table size = %d", nElem);
540 
541  if (nElem <= 1) { // Restore the element table DD4hep destroyed.
542  tab->TGeoElementTable::~TGeoElementTable();
543  new (tab) TGeoElementTable();
544  tab->BuildDefaultElements();
545  }
546  TGeoMixture* mix = new TGeoMixture(nam.c_str(), 1, density);
547  TGeoElement* elt = tab->FindElement(xmat.nameStr().c_str());
548  printout(ns.context()->debug_materials ? ALWAYS : DEBUG,
549  "DD4CMS",
550  "+++ Searching for material %-48s elt_ptr = %ld",
551  xmat.nameStr().c_str(),
552  elt);
553 
554  printout(ns.context()->debug_materials ? ALWAYS : DEBUG,
555  "DD4CMS",
556  "+++ Converting material %-48s Atomic weight %8.3f [g/mol], Atomic number %u, Density: %8.3f [g/cm3] "
557  "ROOT: %8.3f [g/cm3]",
558  ('"' + nam + '"').c_str(),
559  atomicWeight,
560  atomicNumber,
561  density,
562  mix->GetDensity());
563 
564  bool newMatDef = false;
565 
566  if (elt) {
567  // A is Mass of a mole in Geant4 units for atoms with atomic shell
568  printout(ns.context()->debug_materials ? ALWAYS : DEBUG,
569  "DD4CMS",
570  " ROOT definition of %-50s Atomic weight %g, Atomic number %u, Number of nucleons %u",
571  elt->GetName(),
572  elt->A(),
573  elt->Z(),
574  elt->N());
575  printout(ns.context()->debug_materials ? ALWAYS : DEBUG,
576  "DD4CMS",
577  "+++ Compared to XML values: Atomic weight %g, Atomic number %u",
578  atomicWeight,
579  atomicNumber);
580  static const double weightTolerance = 1.0e-6;
581  if (atomicNumber != elt->Z() ||
582  (std::abs(atomicWeight - elt->A()) > (weightTolerance * (atomicWeight + elt->A()))))
583  newMatDef = true;
584  }
585 
586  if (!elt || newMatDef) {
587  if (newMatDef)
588  printout(WARNING,
589  "DD4CMS",
590  "+++ Converter<ElementaryMaterial> Different definition of a default element with name:%s [CREATE NEW "
591  "MATERIAL]",
592  matname);
593  else
594  printout(WARNING,
595  "DD4CMS",
596  "+++ Converter<ElementaryMaterial> No default element present with name:%s [CREATE NEW MATERIAL]",
597  matname);
598  elt = new TGeoElement(xmat.nameStr().c_str(), "CMS element", atomicNumber, atomicWeight);
599  }
600 
601  mix->AddElement(elt, 1.0);
602 
604  TGeoMedium* medium = mgr.GetMedium(matname);
605  if (nullptr == medium) {
606  --unique_mat_id;
607  medium = new TGeoMedium(matname, unique_mat_id, mix);
608  medium->SetTitle("material");
609  medium->SetUniqueID(unique_mat_id);
610  }
611  }
612 }
613 
615 template <>
616 void Converter<DDLCompositeMaterial>::operator()(xml_h element) const {
617  cms::DDNamespace ns(_param<cms::DDParsingContext>());
618  xml_dim_t xmat(element);
619  string nam = ns.prepend(xmat.nameStr());
620 
621  TGeoManager& mgr = description.manager();
622  TGeoMaterial* mat = mgr.GetMaterial(nam.c_str());
623  if (nullptr == mat) {
624  const char* matname = nam.c_str();
625  double density = xmat.attr<double>(DD_CMU(density)) / (dd4hep::g / dd4hep::cm3);
626  xml_coll_t composites(xmat, DD_CMU(MaterialFraction));
627  TGeoMixture* mix = new TGeoMixture(nam.c_str(), composites.size(), density);
628 
629  printout(ns.context()->debug_materials ? ALWAYS : DEBUG,
630  "DD4CMS",
631  "++ Converting material %-48s Density: %8.3f [g/cm3] ROOT: %8.3f [g/cm3]",
632  ('"' + nam + '"').c_str(),
633  density,
634  mix->GetDensity());
635 
636  for (composites.reset(); composites; ++composites) {
637  xml_dim_t xfrac(composites);
638  xml_dim_t xfrac_mat(xfrac.child(DD_CMU(rMaterial)));
639  double fraction = xfrac.fraction();
640  string fracname = ns.realName(xfrac_mat.nameStr());
641 
642  TGeoMaterial* frac_mat = mgr.GetMaterial(fracname.c_str());
643  if (frac_mat == nullptr) // Try to find it within this namespace
644  frac_mat = mgr.GetMaterial(ns.prepend(fracname).c_str());
645  if (frac_mat) {
646  mix->AddElement(frac_mat, fraction);
647  continue;
648  }
649 
650  printout(WARNING,
651  "DD4CMS",
652  "+++ Composite material \"%s\" [nor \"%s\"] not present! [delay resolution]",
653  fracname.c_str(),
654  ns.prepend(fracname).c_str());
655  ns.context()->unresolvedMaterials[nam].emplace_back(
656  cms::DDParsingContext::CompositeMaterial(ns.prepend(fracname), fraction));
657  }
658  mix->SetRadLen(0e0);
660  TGeoMedium* medium = mgr.GetMedium(matname);
661  if (nullptr == medium) {
662  --unique_mat_id;
663  medium = new TGeoMedium(matname, unique_mat_id, mix);
664  medium->SetTitle("material");
665  medium->SetUniqueID(unique_mat_id);
666  }
667  }
668 }
669 
671 template <>
672 void Converter<DDLRotation>::operator()(xml_h element) const {
673  cms::DDParsingContext* context = _param<cms::DDParsingContext>();
674  cms::DDNamespace ns(context);
675  xml_dim_t xrot(element);
676  string nam = xrot.nameStr();
677  double thetaX = xrot.hasAttr(DD_CMU(thetaX)) ? ns.attr<double>(xrot, DD_CMU(thetaX)) : 0e0;
678  double phiX = xrot.hasAttr(DD_CMU(phiX)) ? ns.attr<double>(xrot, DD_CMU(phiX)) : 0e0;
679  double thetaY = xrot.hasAttr(DD_CMU(thetaY)) ? ns.attr<double>(xrot, DD_CMU(thetaY)) : 0e0;
680  double phiY = xrot.hasAttr(DD_CMU(phiY)) ? ns.attr<double>(xrot, DD_CMU(phiY)) : 0e0;
681  double thetaZ = xrot.hasAttr(DD_CMU(thetaZ)) ? ns.attr<double>(xrot, DD_CMU(thetaZ)) : 0e0;
682  double phiZ = xrot.hasAttr(DD_CMU(phiZ)) ? ns.attr<double>(xrot, DD_CMU(phiZ)) : 0e0;
683  Rotation3D rot = makeRotation3D(thetaX, phiX, thetaY, phiY, thetaZ, phiZ);
684  printout(context->debug_rotations ? ALWAYS : DEBUG,
685  "DD4CMS",
686  "+++ Adding rotation: %-32s: (theta/phi)[rad] X: %6.3f %6.3f Y: %6.3f %6.3f Z: %6.3f %6.3f",
687  ns.prepend(nam).c_str(),
688  thetaX,
689  phiX,
690  thetaY,
691  phiY,
692  thetaZ,
693  phiZ);
694  ns.addRotation(nam, rot);
695 }
696 
698 template <>
699 void Converter<DDLReflectionRotation>::operator()(xml_h element) const {
700  cms::DDParsingContext* context = _param<cms::DDParsingContext>();
701  cms::DDNamespace ns(context);
702  xml_dim_t xrot(element);
703  string name = xrot.nameStr();
704  double thetaX = xrot.hasAttr(DD_CMU(thetaX)) ? ns.attr<double>(xrot, DD_CMU(thetaX)) : 0e0;
705  double phiX = xrot.hasAttr(DD_CMU(phiX)) ? ns.attr<double>(xrot, DD_CMU(phiX)) : 0e0;
706  double thetaY = xrot.hasAttr(DD_CMU(thetaY)) ? ns.attr<double>(xrot, DD_CMU(thetaY)) : 0e0;
707  double phiY = xrot.hasAttr(DD_CMU(phiY)) ? ns.attr<double>(xrot, DD_CMU(phiY)) : 0e0;
708  double thetaZ = xrot.hasAttr(DD_CMU(thetaZ)) ? ns.attr<double>(xrot, DD_CMU(thetaZ)) : 0e0;
709  double phiZ = xrot.hasAttr(DD_CMU(phiZ)) ? ns.attr<double>(xrot, DD_CMU(phiZ)) : 0e0;
710  printout(context->debug_rotations ? ALWAYS : DEBUG,
711  "DD4CMS",
712  "+++ Adding reflection rotation: %-32s: (theta/phi)[rad] X: %6.3f %6.3f Y: %6.3f %6.3f Z: %6.3f %6.3f",
713  ns.prepend(name).c_str(),
714  thetaX,
715  phiX,
716  thetaY,
717  phiY,
718  thetaZ,
719  phiZ);
720  Rotation3D rot = makeRotReflect(thetaX, phiX, thetaY, phiY, thetaZ, phiZ);
721  ns.addRotation(name, rot);
722 }
723 
725 template <>
726 void Converter<DDLRotationSequence>::operator()(xml_h element) const {
727  cms::DDParsingContext* context = _param<cms::DDParsingContext>();
728  cms::DDNamespace ns(context);
729  xml_dim_t xrot(element);
730  string nam = xrot.nameStr();
731  Rotation3D rot;
732  xml_coll_t rotations(xrot, DD_CMU(RotationByAxis));
733  for (rotations.reset(); rotations; ++rotations) {
734  string axis = ns.attr<string>(rotations, DD_CMU(axis));
735  double angle = ns.attr<double>(rotations, _U(angle));
736  rot = makeRotation3D(rot, axis, angle);
737  printout(context->debug_rotations ? ALWAYS : DEBUG,
738  "DD4CMS",
739  "+ Adding rotation to: %-29s: (axis/angle)[rad] Axis: %s Angle: %6.3f",
740  nam.c_str(),
741  axis.c_str(),
742  angle);
743  }
744  double xx, xy, xz;
745  double yx, yy, yz;
746  double zx, zy, zz;
747  rot.GetComponents(xx, xy, xz, yx, yy, yz, zx, zy, zz);
748  printout(context->debug_rotations ? ALWAYS : DEBUG,
749  "DD4CMS",
750  "+++ Adding rotation sequence: %-23s: %6.3f %6.3f %6.3f, %6.3f %6.3f %6.3f, %6.3f %6.3f %6.3f",
751  ns.prepend(nam).c_str(),
752  xx,
753  xy,
754  xz,
755  yx,
756  yy,
757  yz,
758  zx,
759  zy,
760  zz);
761  ns.addRotation(nam, rot);
762 }
763 
765 template <>
766 void Converter<DDLRotationByAxis>::operator()(xml_h element) const {
767  cms::DDParsingContext* context = _param<cms::DDParsingContext>();
768  cms::DDNamespace ns(context);
769  xml_dim_t xrot(element);
770  xml_dim_t par(xrot.parent());
771  if (xrot.hasAttr(_U(name))) {
772  string nam = xrot.nameStr(); // + string("Rotation"); // xrot.hasAttr(_U(name)) ? xrot.nameStr() : par.nameStr();
773  string axis = ns.attr<string>(xrot, DD_CMU(axis));
774  double angle = ns.attr<double>(xrot, _U(angle));
775  Rotation3D rot;
776  rot = makeRotation3D(rot, axis, angle);
777  printout(context->debug_rotations ? ALWAYS : DEBUG,
778  "DD4CMS",
779  "+++ Adding rotation: %-32s: (axis/angle)[rad] Axis: %s Angle: %6.3f",
780  ns.prepend(nam).c_str(),
781  axis.c_str(),
782  angle);
783  ns.addRotation(nam, rot);
784  }
785 }
786 
788 template <>
789 void Converter<DDLLogicalPart>::operator()(xml_h element) const {
790  cms::DDNamespace ns(_param<cms::DDParsingContext>());
791  xml_dim_t e(element);
792  string sol = e.child(DD_CMU(rSolid)).attr<string>(_U(name));
793  string mat = e.child(DD_CMU(rMaterial)).attr<string>(_U(name));
794  string volName = e.attr<string>(_U(name));
795  Solid solid = ns.solid(sol);
796  Material material = ns.material(mat);
797  Volume volume = ns.addVolume(Volume(volName, solid, material));
798  printout(ns.context()->debug_volumes ? ALWAYS : DEBUG,
799  "DD4CMS",
800  "+++ %s Volume: %-24s [%s] Shape: %-32s [%s] Material: %-40s [%s]",
801  e.tag().c_str(),
802  volName.c_str(),
803  volume.isValid() ? "VALID" : "INVALID",
804  sol.c_str(),
805  solid.isValid() ? "VALID" : "INVALID",
806  mat.c_str(),
807  material.isValid() ? "VALID" : "INVALID");
808 }
809 
811 template <>
812 void Converter<DDLTransform3D>::operator()(xml_h element) const {
813  cms::DDNamespace ns(_param<cms::DDParsingContext>());
814  Transform3D* tr = _option<Transform3D>();
815  xml_dim_t e(element);
816  xml_dim_t translation = e.child(DD_CMU(Translation), false);
817  xml_dim_t rotation = e.child(DD_CMU(Rotation), false);
818  xml_dim_t refRotation = e.child(DD_CMU(rRotation), false);
819  xml_dim_t refReflectionRotation = e.child(DD_CMU(rReflectionRotation), false);
820  Position pos;
821  Rotation3D rot;
822 
823  if (translation.ptr()) {
824  double x = ns.attr<double>(translation, _U(x));
825  double y = ns.attr<double>(translation, _U(y));
826  double z = ns.attr<double>(translation, _U(z));
827  pos = Position(x, y, z);
828  }
829  if (rotation.ptr()) {
830  double x = ns.attr<double>(rotation, _U(x));
831  double y = ns.attr<double>(rotation, _U(y));
832  double z = ns.attr<double>(rotation, _U(z));
833  rot = RotationZYX(z, y, x);
834  } else if (refRotation.ptr()) {
835  string rotName = ns.prepend(refRotation.nameStr());
836  rot = ns.rotation(rotName);
837  } else if (refReflectionRotation.ptr()) {
838  string rotName = ns.prepend(refReflectionRotation.nameStr());
839  rot = ns.rotation(rotName);
840  }
841  *tr = Transform3D(rot, pos);
842 }
843 
845 template <>
846 void Converter<DDLPosPart>::operator()(xml_h element) const {
847  cms::DDNamespace ns(_param<cms::DDParsingContext>()); //, element, true );
848  xml_dim_t e(element);
849  int copy = e.attr<int>(DD_CMU(copyNumber));
850  string parentName = ns.attr<string>(e.child(DD_CMU(rParent)), _U(name));
851  string childName = ns.attr<string>(e.child(DD_CMU(rChild)), _U(name));
852  Volume parent = ns.volume(parentName, false);
853  Volume child = ns.volume(childName, false);
854  printout(ns.context()->debug_placements ? ALWAYS : DEBUG,
855  "DD4CMS",
856  "+++ %s Parent: %-24s [%s] Child: %-32s [%s] copy:%d",
857  e.tag().c_str(),
858  parentName.c_str(),
859  parent.isValid() ? "VALID" : "INVALID",
860  childName.c_str(),
861  child.isValid() ? "VALID" : "INVALID",
862  copy);
863 
864  if (!parent.isValid() && strchr(parentName.c_str(), NAMESPACE_SEP) == nullptr)
865  parentName = ns.prepend(parentName);
866  parent = ns.volume(parentName);
867 
868  if (!child.isValid() && strchr(childName.c_str(), NAMESPACE_SEP) == nullptr)
869  childName = ns.prepend(childName);
870  child = ns.volume(childName, false);
871 
872  printout(ns.context()->debug_placements ? ALWAYS : DEBUG,
873  "DD4CMS",
874  "+++ %s Parent: %-24s [%s] Child: %-32s [%s] copy:%d",
875  e.tag().c_str(),
876  parentName.c_str(),
877  parent.isValid() ? "VALID" : "INVALID",
878  childName.c_str(),
879  child.isValid() ? "VALID" : "INVALID",
880  copy);
881 
883  if (child.isValid()) {
884  Transform3D transform;
885  Converter<DDLTransform3D>(description, param, &transform)(element);
886 
887  // FIXME: workaround for Reflection rotation
888  // copy from DDCore/src/Volumes.cpp to replace
889  // static PlacedVolume _addNode(TGeoVolume* par, TGeoVolume* daughter, int id, TGeoMatrix* transform)
890  if (!parent) {
891  except("dd4hep", "Volume: Attempt to assign daughters to an invalid physical parent volume.");
892  }
893  if (!child) {
894  except("dd4hep", "Volume: Attempt to assign an invalid physical daughter volume.");
895  }
896  TGeoShape* shape = child->GetShape();
897  // Need to fix the daughter's BBox of assemblies, if the BBox was not calculated....
898  if (shape->IsA() == TGeoShapeAssembly::Class()) {
899  TGeoShapeAssembly* as = (TGeoShapeAssembly*)shape;
900  if (std::fabs(as->GetDX()) < numeric_limits<double>::epsilon() &&
901  std::fabs(as->GetDY()) < numeric_limits<double>::epsilon() &&
902  std::fabs(as->GetDZ()) < numeric_limits<double>::epsilon()) {
903  as->NeedsBBoxRecompute();
904  as->ComputeBBox();
905  }
906  }
907  TGeoNode* n;
908  TString nam_id = TString::Format("%s_%d", child->GetName(), copy);
909  n = static_cast<TGeoNode*>(parent->GetNode(nam_id));
910  if (n != nullptr) {
911  printout(ERROR, "PlacedVolume", "++ Attempt to add already exiting node %s", (const char*)nam_id);
912  }
913 
914  Rotation3D rot(transform.Rotation());
915  Translation3D trans(transform.Translation());
916  double x, y, z;
917  trans.GetComponents(x, y, z);
918  Position pos(x, y, z);
919  parent->AddNode(child, copy, createPlacement(rot, pos));
920 
921  n = static_cast<TGeoNode*>(parent->GetNode(nam_id));
922  n->TGeoNode::SetUserExtension(new PlacedVolume::Object());
923  pv = PlacedVolume(n);
924  }
925  if (!pv.isValid()) {
926  printout(ERROR,
927  "DD4CMS",
928  "+++ Placement FAILED! Parent:%s Child:%s Valid:%s",
929  parent.name(),
930  childName.c_str(),
931  yes_no(child.isValid()));
932  }
933 }
934 
936 template <>
937 void Converter<PartSelector>::operator()(xml_h element) const {
938  cms::DDNamespace ns(_param<cms::DDParsingContext>());
939  cms::DDParsingContext* const context = ns.context();
940  DDSpecParRegistry& registry = *context->description.load()->extension<DDSpecParRegistry>();
941  xml_dim_t e(element);
942  xml_dim_t specPar = e.parent();
943  string specParName = specPar.attr<string>(_U(name));
944  string path = e.attr<string>(DD_CMU(path));
945  printout(ns.context()->debug_specpars ? ALWAYS : DEBUG,
946  "DD4CMS",
947  "+++ PartSelector for %s path: %s",
948  specParName.c_str(),
949  path.c_str());
950  registry.specpars[specParName].paths.emplace_back(path);
951 }
952 
954 template <>
955 void Converter<Parameter>::operator()(xml_h element) const {
956  cms::DDNamespace ns(_param<cms::DDParsingContext>());
957  cms::DDParsingContext* const context = ns.context();
958  DDSpecParRegistry& registry = *context->description.load()->extension<DDSpecParRegistry>();
959  xml_dim_t e(element);
960  xml_dim_t specPar = e.parent();
961  xml_dim_t specParSect = specPar.parent();
962  string specParName = specPar.attr<string>(_U(name));
963  string name = e.nameStr();
964  string value = e.attr<string>(DD_CMU(value));
965  bool eval = e.hasAttr(_U(eval)) ? e.attr<bool>(_U(eval))
966  : (specParSect.hasAttr(_U(eval)) ? specParSect.attr<bool>(_U(eval)) : false);
967  string type = eval ? "number" : "string";
968 
969  printout(ns.context()->debug_specpars ? ALWAYS : DEBUG,
970  "DD4CMS",
971  "+++ Parameter for %s: %s value %s is a %s",
972  specParName.c_str(),
973  name.c_str(),
974  value.c_str(),
975  type.c_str());
976 
977  size_t idx = value.find('[');
978  if (idx == string::npos || type == "string") {
979  registry.specpars[specParName].spars[name].emplace_back(value);
980  return;
981  }
982 
983  while (idx != string::npos) {
984  ++idx;
985  size_t idp = value.find(':', idx);
986  size_t idq = value.find(']', idx);
987  if (idp == string::npos || idp > idq)
988  value.insert(idx, ns.name());
989  else if (idp != string::npos && idp < idq)
990  value[idp] = NAMESPACE_SEP;
991  idx = value.find('[', idx);
992  }
993 
994  string rep;
995  string& v = value;
996  size_t idq;
997  for (idx = v.find('[', 0); idx != string::npos; idx = v.find('[', idx + 1)) {
998  idq = v.find(']', idx + 1);
999  rep = v.substr(idx + 1, idq - idx - 1);
1000  auto r = ns.context()->description.load()->constants().find(rep);
1001  if (r != ns.context()->description.load()->constants().end()) {
1002  rep = "(" + r->second->type + ")";
1003  v.replace(idx, idq - idx + 1, rep);
1004  }
1005  }
1006  registry.specpars[specParName].numpars[name].emplace_back(_toDouble(value));
1007 }
1008 
1009 template <typename TYPE>
1010 static void convert_boolean(cms::DDParsingContext* context, xml_h element) {
1011  cms::DDNamespace ns(context);
1012  xml_dim_t e(element);
1013  string nam = e.nameStr();
1014  string solidName[2];
1015  Solid solids[2];
1016  Solid boolean;
1017  int cnt = 0;
1018  if (e.hasChild(DD_CMU(rSolid))) {
1019  for (xml_coll_t c(element, DD_CMU(rSolid)); cnt < 2 && c; ++c, ++cnt) {
1020  solidName[cnt] = c.attr<string>(_U(name));
1021  solids[cnt] = ns.solid(c.attr<string>(_U(name)));
1022  }
1023  } else {
1024  solidName[0] = e.attr<string>(DD_CMU(firstSolid));
1025  if ((solids[0] = ns.solid(e.attr<string>(DD_CMU(firstSolid)))).isValid())
1026  ++cnt;
1027  solidName[1] = e.attr<string>(DD_CMU(secondSolid));
1028  if ((solids[1] = ns.solid(e.attr<string>(DD_CMU(secondSolid)))).isValid())
1029  ++cnt;
1030  }
1031  if (cnt != 2) {
1032  except("DD4CMS", "+++ Failed to create boolean solid %s. Found only %d parts.", nam.c_str(), cnt);
1033  }
1034 
1035  printout(ns.context()->debug_placements ? ALWAYS : DEBUG,
1036  "DD4CMS",
1037  "+++ BooleanSolid: %s Left: %-32s Right: %-32s",
1038  nam.c_str(),
1039  ((solids[0].ptr() == nullptr) ? solidName[0].c_str() : solids[0]->GetName()),
1040  ((solids[1].ptr() == nullptr) ? solidName[1].c_str() : solids[1]->GetName()));
1041 
1042  if (solids[0].isValid() && solids[1].isValid()) {
1043  Transform3D trafo;
1044  Converter<DDLTransform3D>(*context->description, context, &trafo)(element);
1045  boolean = TYPE(solids[0], solids[1], trafo);
1046  } else {
1047  // Register it for later processing
1048  Transform3D trafo;
1049  Converter<DDLTransform3D>(*context->description, context, &trafo)(element);
1050  ns.context()->unresolvedShapes.emplace(nam,
1051  DDParsingContext::BooleanShape<TYPE>(solidName[0], solidName[1], trafo));
1052  }
1053  if (!boolean.isValid()) {
1054  // Delay processing the shape
1055  ns.context()->shapes.emplace(nam, dd4hep::Solid(nullptr));
1056  } else
1057  ns.addSolid(nam, boolean);
1058 }
1059 
1061 template <>
1062 void Converter<DDLUnionSolid>::operator()(xml_h element) const {
1063  convert_boolean<UnionSolid>(_param<cms::DDParsingContext>(), element);
1064 }
1065 
1067 template <>
1068 void Converter<DDLSubtractionSolid>::operator()(xml_h element) const {
1069  convert_boolean<SubtractionSolid>(_param<cms::DDParsingContext>(), element);
1070 }
1071 
1073 template <>
1074 void Converter<DDLIntersectionSolid>::operator()(xml_h element) const {
1075  convert_boolean<IntersectionSolid>(_param<cms::DDParsingContext>(), element);
1076 }
1077 
1079 template <>
1080 void Converter<DDLPolycone>::operator()(xml_h element) const {
1081  cms::DDNamespace ns(_param<cms::DDParsingContext>());
1082  xml_dim_t e(element);
1083  string nam = e.nameStr();
1084  double startPhi = ns.attr<double>(e, DD_CMU(startPhi));
1085  double deltaPhi = ns.attr<double>(e, DD_CMU(deltaPhi));
1086  vector<double> z, rmin, rmax, r;
1087 
1088  for (xml_coll_t rzpoint(element, DD_CMU(RZPoint)); rzpoint; ++rzpoint) {
1089  z.emplace_back(ns.attr<double>(rzpoint, _U(z)));
1090  r.emplace_back(ns.attr<double>(rzpoint, _U(r)));
1091  }
1092  if (z.empty()) {
1093  for (xml_coll_t zplane(element, DD_CMU(ZSection)); zplane; ++zplane) {
1094  rmin.emplace_back(ns.attr<double>(zplane, DD_CMU(rMin)));
1095  rmax.emplace_back(ns.attr<double>(zplane, DD_CMU(rMax)));
1096  z.emplace_back(ns.attr<double>(zplane, _U(z)));
1097  }
1098  printout(ns.context()->debug_shapes ? ALWAYS : DEBUG,
1099  "DD4CMS",
1100  "+ Polycone: startPhi=%10.3f [rad] deltaPhi=%10.3f [rad] %4ld z-planes",
1101  startPhi,
1102  deltaPhi,
1103  z.size());
1104  ns.addSolid(nam, Polycone(startPhi, deltaPhi, rmin, rmax, z));
1105  } else {
1106  printout(ns.context()->debug_shapes ? ALWAYS : DEBUG,
1107  "DD4CMS",
1108  "+ Polycone: startPhi=%10.3f [rad] deltaPhi=%10.3f [rad] %4ld z-planes and %4ld radii",
1109  startPhi,
1110  deltaPhi,
1111  z.size(),
1112  r.size());
1113  ns.addSolid(nam, Polycone(startPhi, deltaPhi, r, z));
1114  }
1115 }
1116 
1118 template <>
1119 void Converter<DDLExtrudedPolygon>::operator()(xml_h element) const {
1120  cms::DDNamespace ns(_param<cms::DDParsingContext>());
1121  xml_dim_t e(element);
1122  string nam = e.nameStr();
1123  vector<double> pt_x, pt_y, sec_x, sec_y, sec_z, sec_scale;
1124 
1125  for (xml_coll_t sec(element, DD_CMU(ZXYSection)); sec; ++sec) {
1126  sec_z.emplace_back(ns.attr<double>(sec, _U(z)));
1127  sec_x.emplace_back(ns.attr<double>(sec, _U(x)));
1128  sec_y.emplace_back(ns.attr<double>(sec, _U(y)));
1129  sec_scale.emplace_back(ns.attr<double>(sec, DD_CMU(scale), 1.0));
1130  }
1131  for (xml_coll_t pt(element, DD_CMU(XYPoint)); pt; ++pt) {
1132  pt_x.emplace_back(ns.attr<double>(pt, _U(x)));
1133  pt_y.emplace_back(ns.attr<double>(pt, _U(y)));
1134  }
1135  printout(ns.context()->debug_shapes ? ALWAYS : DEBUG,
1136  "DD4CMS",
1137  "+ ExtrudedPolygon: %4ld points %4ld zxy sections",
1138  pt_x.size(),
1139  sec_z.size());
1140  ns.addSolid(nam, ExtrudedPolygon(pt_x, pt_y, sec_z, sec_x, sec_y, sec_scale));
1141 }
1142 
1144 template <>
1145 void Converter<DDLPolyhedra>::operator()(xml_h element) const {
1146  cms::DDNamespace ns(_param<cms::DDParsingContext>());
1147  xml_dim_t e(element);
1148  string nam = e.nameStr();
1149  double numSide = ns.attr<int>(e, DD_CMU(numSide));
1150  double startPhi = ns.attr<double>(e, DD_CMU(startPhi));
1151  double deltaPhi = ns.attr<double>(e, DD_CMU(deltaPhi));
1152  vector<double> z, rmin, rmax;
1153 
1154  for (xml_coll_t zplane(element, DD_CMU(RZPoint)); zplane; ++zplane) {
1155  rmin.emplace_back(0.0);
1156  rmax.emplace_back(ns.attr<double>(zplane, _U(r)));
1157  z.emplace_back(ns.attr<double>(zplane, _U(z)));
1158  }
1159  for (xml_coll_t zplane(element, DD_CMU(ZSection)); zplane; ++zplane) {
1160  rmin.emplace_back(ns.attr<double>(zplane, DD_CMU(rMin)));
1161  rmax.emplace_back(ns.attr<double>(zplane, DD_CMU(rMax)));
1162  z.emplace_back(ns.attr<double>(zplane, _U(z)));
1163  }
1164  printout(ns.context()->debug_shapes ? ALWAYS : DEBUG,
1165  "DD4CMS",
1166  "+ Polyhedra:startPhi=%8.3f [rad] deltaPhi=%8.3f [rad] %4d sides %4ld z-planes",
1167  startPhi,
1168  deltaPhi,
1169  numSide,
1170  z.size());
1171  ns.addSolid(nam, Polyhedra(numSide, startPhi, deltaPhi, z, rmin, rmax));
1172 }
1173 
1175 template <>
1176 void Converter<DDLSphere>::operator()(xml_h element) const {
1177  cms::DDNamespace ns(_param<cms::DDParsingContext>());
1178  xml_dim_t e(element);
1179  string nam = e.nameStr();
1180  double rinner = ns.attr<double>(e, DD_CMU(innerRadius));
1181  double router = ns.attr<double>(e, DD_CMU(outerRadius));
1182  double startPhi = ns.attr<double>(e, DD_CMU(startPhi));
1183  double deltaPhi = ns.attr<double>(e, DD_CMU(deltaPhi));
1184  double startTheta = ns.attr<double>(e, DD_CMU(startTheta));
1185  double deltaTheta = ns.attr<double>(e, DD_CMU(deltaTheta));
1186  printout(ns.context()->debug_shapes ? ALWAYS : DEBUG,
1187  "DD4CMS",
1188  "+ Sphere: r_inner=%8.3f [cm] r_outer=%8.3f [cm]"
1189  " startPhi=%8.3f [rad] deltaPhi=%8.3f startTheta=%8.3f delteTheta=%8.3f [rad]",
1190  rinner,
1191  router,
1192  startPhi,
1193  deltaPhi,
1194  startTheta,
1195  deltaTheta);
1196  ns.addSolid(nam, Sphere(rinner, router, startTheta, deltaTheta, startPhi, deltaPhi));
1197 }
1198 
1200 template <>
1201 void Converter<DDLTorus>::operator()(xml_h element) const {
1202  cms::DDNamespace ns(_param<cms::DDParsingContext>());
1203  xml_dim_t e(element);
1204  string nam = e.nameStr();
1205  double r = ns.attr<double>(e, DD_CMU(torusRadius));
1206  double rinner = ns.attr<double>(e, DD_CMU(innerRadius));
1207  double router = ns.attr<double>(e, DD_CMU(outerRadius));
1208  double startPhi = ns.attr<double>(e, DD_CMU(startPhi));
1209  double deltaPhi = ns.attr<double>(e, DD_CMU(deltaPhi));
1210  printout(ns.context()->debug_shapes ? ALWAYS : DEBUG,
1211  "DD4CMS",
1212  "+ Torus: r=%10.3f [cm] r_inner=%10.3f [cm] r_outer=%10.3f [cm]"
1213  " startPhi=%10.3f [rad] deltaPhi=%10.3f [rad]",
1214  r,
1215  rinner,
1216  router,
1217  startPhi,
1218  deltaPhi);
1219  ns.addSolid(nam, Torus(r, rinner, router, startPhi, deltaPhi));
1220 }
1221 
1223 template <>
1224 void Converter<DDLPseudoTrap>::operator()(xml_h element) const {
1225  cms::DDNamespace ns(_param<cms::DDParsingContext>());
1226  xml_dim_t e(element);
1227  string nam = e.nameStr();
1228  double dx1 = ns.attr<double>(e, DD_CMU(dx1));
1229  double dy1 = ns.attr<double>(e, DD_CMU(dy1));
1230  double dx2 = ns.attr<double>(e, DD_CMU(dx2));
1231  double dy2 = ns.attr<double>(e, DD_CMU(dy2));
1232  double dz = ns.attr<double>(e, _U(dz));
1233  double r = ns.attr<double>(e, _U(radius));
1234  bool atMinusZ = ns.attr<bool>(e, DD_CMU(atMinusZ));
1235  printout(ns.context()->debug_shapes ? ALWAYS : DEBUG,
1236  "DD4CMS",
1237  "+ Pseudotrap: dz=%8.3f [cm] dx1:%.3f dy1:%.3f dx2=%.3f dy2=%.3f radius:%.3f atMinusZ:%s",
1238  dz,
1239  dx1,
1240  dy1,
1241  dx2,
1242  dy2,
1243  r,
1244  yes_no(atMinusZ));
1245  ns.addSolid(nam, PseudoTrap(dx1, dx2, dy1, dy2, dz, r, atMinusZ));
1246 }
1247 
1249 template <>
1250 void Converter<DDLTrapezoid>::operator()(xml_h element) const {
1251  cms::DDNamespace ns(_param<cms::DDParsingContext>());
1252  xml_dim_t e(element);
1253  string nam = e.nameStr();
1254  double dz = ns.attr<double>(e, _U(dz));
1255  double alp1 = ns.attr<double>(e, DD_CMU(alp1));
1256  double bl1 = ns.attr<double>(e, DD_CMU(bl1));
1257  double tl1 = ns.attr<double>(e, DD_CMU(tl1));
1258  double h1 = ns.attr<double>(e, DD_CMU(h1));
1259  double alp2 = ns.attr<double>(e, DD_CMU(alp2));
1260  double bl2 = ns.attr<double>(e, DD_CMU(bl2));
1261  double tl2 = ns.attr<double>(e, DD_CMU(tl2));
1262  double h2 = ns.attr<double>(e, DD_CMU(h2));
1263  double phi = ns.attr<double>(e, _U(phi), 0.0);
1264  double theta = ns.attr<double>(e, _U(theta), 0.0);
1265 
1266  printout(ns.context()->debug_shapes ? ALWAYS : DEBUG,
1267  "DD4CMS",
1268  "+ Trapezoid: dz=%10.3f [cm] alp1:%.3f bl1=%.3f tl1=%.3f alp2=%.3f bl2=%.3f tl2=%.3f h2=%.3f phi=%.3f "
1269  "theta=%.3f",
1270  dz,
1271  alp1,
1272  bl1,
1273  tl1,
1274  h1,
1275  alp2,
1276  bl2,
1277  tl2,
1278  h2,
1279  phi,
1280  theta);
1281  ns.addSolid(nam, Trap(dz, theta, phi, h1, bl1, tl1, alp1, h2, bl2, tl2, alp2));
1282 }
1283 
1285 template <>
1286 void Converter<DDLTrd1>::operator()(xml_h element) const {
1287  cms::DDNamespace ns(_param<cms::DDParsingContext>());
1288  xml_dim_t e(element);
1289  string nam = e.nameStr();
1290  double dx1 = ns.attr<double>(e, DD_CMU(dx1));
1291  double dy1 = ns.attr<double>(e, DD_CMU(dy1));
1292  double dx2 = ns.attr<double>(e, DD_CMU(dx2), 0.0);
1293  double dy2 = ns.attr<double>(e, DD_CMU(dy2), dy1);
1294  double dz = ns.attr<double>(e, DD_CMU(dz));
1295  if (dy1 == dy2) {
1296  printout(ns.context()->debug_shapes ? ALWAYS : DEBUG,
1297  "DD4CMS",
1298  "+ Trd1: dz=%8.3f [cm] dx1:%.3f dy1:%.3f dx2:%.3f dy2:%.3f",
1299  dz,
1300  dx1,
1301  dy1,
1302  dx2,
1303  dy2);
1304  ns.addSolid(nam, Trd1(dx1, dx2, dy1, dz));
1305  } else {
1306  printout(ns.context()->debug_shapes ? ALWAYS : DEBUG,
1307  "DD4CMS",
1308  "+ Trd1(which is actually Trd2): dz=%8.3f [cm] dx1:%.3f dy1:%.3f dx2:%.3f dy2:%.3f",
1309  dz,
1310  dx1,
1311  dy1,
1312  dx2,
1313  dy2);
1314  ns.addSolid(nam, Trd2(dx1, dx2, dy1, dy2, dz));
1315  }
1316 }
1317 
1319 template <>
1320 void Converter<DDLTrd2>::operator()(xml_h element) const {
1321  cms::DDNamespace ns(_param<cms::DDParsingContext>());
1322  xml_dim_t e(element);
1323  string nam = e.nameStr();
1324  double dx1 = ns.attr<double>(e, DD_CMU(dx1));
1325  double dy1 = ns.attr<double>(e, DD_CMU(dy1));
1326  double dx2 = ns.attr<double>(e, DD_CMU(dx2), 0.0);
1327  double dy2 = ns.attr<double>(e, DD_CMU(dy2), dy1);
1328  double dz = ns.attr<double>(e, DD_CMU(dz));
1329  printout(ns.context()->debug_shapes ? ALWAYS : DEBUG,
1330  "DD4CMS",
1331  "+ Trd1: dz=%8.3f [cm] dx1:%.3f dy1:%.3f dx2:%.3f dy2:%.3f",
1332  dz,
1333  dx1,
1334  dy1,
1335  dx2,
1336  dy2);
1337  ns.addSolid(nam, Trd2(dx1, dx2, dy1, dy2, dz));
1338 }
1339 
1341 template <>
1342 void Converter<DDLTubs>::operator()(xml_h element) const {
1343  cms::DDNamespace ns(_param<cms::DDParsingContext>());
1344  xml_dim_t e(element);
1345  string nam = e.nameStr();
1346  double dz = ns.attr<double>(e, DD_CMU(dz));
1347  double rmin = ns.attr<double>(e, DD_CMU(rMin));
1348  double rmax = ns.attr<double>(e, DD_CMU(rMax));
1349  double startPhi = ns.attr<double>(e, DD_CMU(startPhi), 0.0);
1350  double deltaPhi = ns.attr<double>(e, DD_CMU(deltaPhi), 2 * M_PI);
1351  printout(ns.context()->debug_shapes ? ALWAYS : DEBUG,
1352  "DD4CMS",
1353  "+ Tubs: dz=%8.3f [cm] rmin=%8.3f [cm] rmax=%8.3f [cm]"
1354  " startPhi=%8.3f [rad] deltaPhi=%8.3f [rad]",
1355  dz,
1356  rmin,
1357  rmax,
1358  startPhi,
1359  deltaPhi);
1360  ns.addSolid(nam, Tube(rmin, rmax, dz, startPhi, startPhi + deltaPhi));
1361 }
1362 
1364 template <>
1365 void Converter<DDLCutTubs>::operator()(xml_h element) const {
1366  cms::DDNamespace ns(_param<cms::DDParsingContext>());
1367  xml_dim_t e(element);
1368  string nam = e.nameStr();
1369  double dz = ns.attr<double>(e, DD_CMU(dz));
1370  double rmin = ns.attr<double>(e, DD_CMU(rMin));
1371  double rmax = ns.attr<double>(e, DD_CMU(rMax));
1372  double startPhi = ns.attr<double>(e, DD_CMU(startPhi));
1373  double deltaPhi = ns.attr<double>(e, DD_CMU(deltaPhi));
1374  double lx = ns.attr<double>(e, DD_CMU(lx));
1375  double ly = ns.attr<double>(e, DD_CMU(ly));
1376  double lz = ns.attr<double>(e, DD_CMU(lz));
1377  double tx = ns.attr<double>(e, DD_CMU(tx));
1378  double ty = ns.attr<double>(e, DD_CMU(ty));
1379  double tz = ns.attr<double>(e, DD_CMU(tz));
1380  printout(ns.context()->debug_shapes ? ALWAYS : DEBUG,
1381  "DD4CMS",
1382  "+ CutTube: dz=%8.3f [cm] rmin=%8.3f [cm] rmax=%8.3f [cm]"
1383  " startPhi=%8.3f [rad] deltaPhi=%8.3f [rad]...",
1384  dz,
1385  rmin,
1386  rmax,
1387  startPhi,
1388  deltaPhi);
1389  ns.addSolid(nam, CutTube(rmin, rmax, dz, startPhi, startPhi + deltaPhi, lx, ly, lz, tx, ty, tz));
1390 }
1391 
1393 template <>
1394 void Converter<DDLTruncTubs>::operator()(xml_h element) const {
1395  cms::DDNamespace ns(_param<cms::DDParsingContext>());
1396  xml_dim_t e(element);
1397  string nam = e.nameStr();
1398  double zhalf = ns.attr<double>(e, DD_CMU(zHalf));
1399  double rmin = ns.attr<double>(e, DD_CMU(rMin));
1400  double rmax = ns.attr<double>(e, DD_CMU(rMax));
1401  double startPhi = ns.attr<double>(e, DD_CMU(startPhi));
1402  double deltaPhi = ns.attr<double>(e, DD_CMU(deltaPhi));
1403  double cutAtStart = ns.attr<double>(e, DD_CMU(cutAtStart));
1404  double cutAtDelta = ns.attr<double>(e, DD_CMU(cutAtDelta));
1405  bool cutInside = ns.attr<bool>(e, DD_CMU(cutInside));
1406  printout(ns.context()->debug_shapes ? ALWAYS : DEBUG,
1407  "DD4CMS",
1408  "+ TruncTube:zHalf=%8.3f [cm] rmin=%8.3f [cm] rmax=%8.3f [cm]"
1409  " startPhi=%8.3f [rad] deltaPhi=%8.3f [rad] atStart=%8.3f [cm] atDelta=%8.3f [cm] inside:%s",
1410  zhalf,
1411  rmin,
1412  rmax,
1413  startPhi,
1414  deltaPhi,
1415  cutAtStart,
1416  cutAtDelta,
1417  yes_no(cutInside));
1418  ns.addSolid(nam, TruncatedTube(zhalf, rmin, rmax, startPhi, deltaPhi, cutAtStart, cutAtDelta, cutInside));
1419 }
1420 
1422 template <>
1423 void Converter<DDLEllipticalTube>::operator()(xml_h element) const {
1424  cms::DDNamespace ns(_param<cms::DDParsingContext>());
1425  xml_dim_t e(element);
1426  string nam = e.nameStr();
1427  double dx = ns.attr<double>(e, DD_CMU(xSemiAxis));
1428  double dy = ns.attr<double>(e, DD_CMU(ySemiAxis));
1429  double dz = ns.attr<double>(e, DD_CMU(zHeight));
1430  printout(ns.context()->debug_shapes ? ALWAYS : DEBUG,
1431  "DD4CMS",
1432  "+ EllipticalTube xSemiAxis=%8.3f [cm] ySemiAxis=%8.3f [cm] zHeight=%8.3f [cm]",
1433  dx,
1434  dy,
1435  dz);
1436  ns.addSolid(nam, EllipticalTube(dx, dy, dz));
1437 }
1438 
1440 template <>
1441 void Converter<DDLCone>::operator()(xml_h element) const {
1442  cms::DDNamespace ns(_param<cms::DDParsingContext>());
1443  xml_dim_t e(element);
1444  string nam = e.nameStr();
1445  double dz = ns.attr<double>(e, DD_CMU(dz));
1446  double rmin1 = ns.attr<double>(e, DD_CMU(rMin1));
1447  double rmin2 = ns.attr<double>(e, DD_CMU(rMin2));
1448  double rmax1 = ns.attr<double>(e, DD_CMU(rMax1));
1449  double rmax2 = ns.attr<double>(e, DD_CMU(rMax2));
1450  double startPhi = ns.attr<double>(e, DD_CMU(startPhi));
1451  double deltaPhi = ns.attr<double>(e, DD_CMU(deltaPhi));
1452  double phi2 = startPhi + deltaPhi;
1453  printout(ns.context()->debug_shapes ? ALWAYS : DEBUG,
1454  "DD4CMS",
1455  "+ Cone: dz=%8.3f [cm]"
1456  " rmin1=%8.3f [cm] rmax1=%8.3f [cm]"
1457  " rmin2=%8.3f [cm] rmax2=%8.3f [cm]"
1458  " startPhi=%8.3f [rad] deltaPhi=%8.3f [rad]",
1459  dz,
1460  rmin1,
1461  rmax1,
1462  rmin2,
1463  rmax2,
1464  startPhi,
1465  deltaPhi);
1466  ns.addSolid(nam, ConeSegment(dz, rmin1, rmax1, rmin2, rmax2, startPhi, phi2));
1467 }
1468 
1470 template <>
1471 void Converter<DDLShapeless>::operator()(xml_h element) const {
1472  cms::DDNamespace ns(_param<cms::DDParsingContext>());
1473  xml_dim_t e(element);
1474  string nam = e.nameStr();
1475  printout(ns.context()->debug_shapes ? ALWAYS : DEBUG,
1476  "DD4CMS",
1477  "+ Shapeless: THIS ONE CAN ONLY BE USED AT THE VOLUME LEVEL -> Assembly%s",
1478  nam.c_str());
1479  ns.addSolid(nam, Box(1, 1, 1));
1480 }
1481 
1483 template <>
1484 void Converter<DDLBox>::operator()(xml_h element) const {
1485  cms::DDNamespace ns(_param<cms::DDParsingContext>());
1486  xml_dim_t e(element);
1487  string nam = e.nameStr();
1488  double dx = ns.attr<double>(e, DD_CMU(dx));
1489  double dy = ns.attr<double>(e, DD_CMU(dy));
1490  double dz = ns.attr<double>(e, DD_CMU(dz));
1491  printout(ns.context()->debug_shapes ? ALWAYS : DEBUG,
1492  "DD4CMS",
1493  "+ Box: dx=%10.3f [cm] dy=%10.3f [cm] dz=%10.3f [cm]",
1494  dx,
1495  dy,
1496  dz);
1497  ns.addSolid(nam, Box(dx, dy, dz));
1498 }
1499 
1501 template <>
1502 void Converter<include_load>::operator()(xml_h element) const {
1503  string fname = element.attr<string>(_U(ref));
1505  xml::Document doc;
1506  doc = xml::DocumentHandler().load(fp.fullPath());
1507  printout(_param<cms::DDParsingContext>()->debug_includes ? ALWAYS : DEBUG,
1508  "DD4CMS",
1509  "+++ Processing the CMS detector description %s",
1510  fname.c_str());
1511  _option<DDRegistry>()->includes.emplace_back(doc);
1512 }
1513 
1515 template <>
1516 void Converter<include_unload>::operator()(xml_h element) const {
1517  string fname = xml::DocumentHandler::system_path(element);
1518  xml::DocumentHolder(xml_elt_t(element).document()).assign(nullptr);
1519  printout(_param<cms::DDParsingContext>()->debug_includes ? ALWAYS : DEBUG,
1520  "DD4CMS",
1521  "+++ Finished processing %s",
1522  fname.c_str());
1523 }
1524 
1526 template <>
1527 void Converter<include_constants>::operator()(xml_h element) const {
1528  xml_coll_t(element, DD_CMU(ConstantsSection)).for_each(Converter<ConstantsSection>(description, param, optional));
1529 }
1530 
1531 namespace {
1532 
1533  // The meaning of the axis index is the following:
1534  // for all volumes having shapes like box, trd1, trd2, trap, gtra or para - 1,2,3 means X,Y,Z;
1535  // for tube, tubs, cone, cons - 1 means Rxy, 2 means phi and 3 means Z;
1536  // for pcon and pgon - 2 means phi and 3 means Z;
1537  // for spheres 1 means R and 2 means phi.
1538 
1539  enum class DDAxes { x = 1, y = 2, z = 3, rho = 1, phi = 2, undefined };
1540  const std::map<std::string, DDAxes> axesmap{{"x", DDAxes::x},
1541  {"y", DDAxes::y},
1542  {"z", DDAxes::z},
1543  {"rho", DDAxes::rho},
1544  {"phi", DDAxes::phi},
1545  {"undefined", DDAxes::undefined}};
1546 } // namespace
1547 
1549 template <>
1550 void Converter<DDLDivision>::operator()(xml_h element) const {
1551  cms::DDNamespace ns(_param<cms::DDParsingContext>(), element);
1552  xml_dim_t e(element);
1553  string childName = e.nameStr();
1554  if (strchr(childName.c_str(), NAMESPACE_SEP) == nullptr)
1555  childName = ns.prepend(childName);
1556 
1557  string parentName = ns.attr<string>(e, DD_CMU(parent));
1558  if (strchr(parentName.c_str(), NAMESPACE_SEP) == nullptr)
1559  parentName = ns.prepend(parentName);
1560  string axis = ns.attr<string>(e, DD_CMU(axis));
1561 
1562  // If you divide a tube of 360 degrees the offset displaces
1563  // the starting angle, but you still fill the 360 degrees
1564  double offset = e.hasAttr(DD_CMU(offset)) ? ns.attr<double>(e, DD_CMU(offset)) : 0e0;
1565  double width = e.hasAttr(DD_CMU(width)) ? ns.attr<double>(e, DD_CMU(width)) : 0e0;
1566  int nReplicas = e.hasAttr(DD_CMU(nReplicas)) ? ns.attr<int>(e, DD_CMU(nReplicas)) : 0;
1567 
1568  printout(ns.context()->debug_placements ? ALWAYS : DEBUG,
1569  "DD4CMS",
1570  "+++ Start executing Division of %s along %s (%d) with offset %6.3f and %6.3f to produce %s....",
1571  parentName.c_str(),
1572  axis.c_str(),
1573  axesmap.at(axis),
1574  offset,
1575  width,
1576  childName.c_str());
1577 
1578  Volume parent = ns.volume(parentName);
1579 
1580  const TGeoShape* shape = parent.solid();
1581  TClass* cl = shape->IsA();
1582  if (cl == TGeoTubeSeg::Class()) {
1583  const TGeoTubeSeg* sh = (const TGeoTubeSeg*)shape;
1584  double widthInDeg = convertRadToDeg(width);
1585  double startInDeg = convertRadToDeg(offset);
1586  int numCopies = (int)((sh->GetPhi2() - sh->GetPhi1()) / widthInDeg);
1587  printout(ns.context()->debug_placements ? ALWAYS : DEBUG,
1588  "DD4CMS",
1589  "+++ ...divide %s along %s (%d) with offset %6.3f deg and %6.3f deg to produce %d copies",
1590  parent.solid().type(),
1591  axis.c_str(),
1592  axesmap.at(axis),
1593  startInDeg,
1594  widthInDeg,
1595  numCopies);
1596  Volume child = parent.divide(childName, static_cast<int>(axesmap.at(axis)), numCopies, startInDeg, widthInDeg);
1597 
1598  ns.context()->volumes[childName] = child;
1599 
1600  printout(ns.context()->debug_placements ? ALWAYS : DEBUG,
1601  "DD4CMS",
1602  "+++ %s Parent: %-24s [%s] Child: %-32s [%s] is multivolume [%s]",
1603  e.tag().c_str(),
1604  parentName.c_str(),
1605  parent.isValid() ? "VALID" : "INVALID",
1606  child.name(),
1607  child.isValid() ? "VALID" : "INVALID",
1608  child->IsVolumeMulti() ? "YES" : "NO");
1609 
1610  } else if (cl == TGeoTrd1::Class()) {
1611  double dy = static_cast<const TGeoTrd1*>(shape)->GetDy();
1612  printout(ns.context()->debug_placements ? ALWAYS : DEBUG,
1613  "DD4CMS",
1614  "+++ ...divide %s along %s (%d) with offset %6.3f cm and %6.3f cm to produce %d copies in %6.3f",
1615  parent.solid().type(),
1616  axis.c_str(),
1617  axesmap.at(axis),
1618  -dy + offset + width,
1619  width,
1620  nReplicas,
1621  dy);
1622  Volume child = parent.divide(childName, static_cast<int>(axesmap.at(axis)), nReplicas, -dy + offset + width, width);
1623 
1624  ns.context()->volumes[childName] = child;
1625 
1626  printout(ns.context()->debug_placements ? ALWAYS : DEBUG,
1627  "DD4CMS",
1628  "+++ %s Parent: %-24s [%s] Child: %-32s [%s] is multivolume [%s]",
1629  e.tag().c_str(),
1630  parentName.c_str(),
1631  parent.isValid() ? "VALID" : "INVALID",
1632  child.name(),
1633  child.isValid() ? "VALID" : "INVALID",
1634  child->IsVolumeMulti() ? "YES" : "NO");
1635  } else {
1636  printout(ERROR, "DD4CMS", "++ FAILED Division of a %s is not implemented yet!", parent.solid().type());
1637  }
1638 }
1639 
1641 template <>
1642 void Converter<DDLAlgorithm>::operator()(xml_h element) const {
1643  cms::DDNamespace ns(_param<cms::DDParsingContext>());
1644  xml_dim_t e(element);
1645  string name = e.nameStr();
1646  for (auto const& i : ns.context()->disabledAlgs) {
1647  if (name == i) {
1648  // if(ns.context()->disabledAlgs.find( name ) != ns.context()->disabledAlgs.end()) {
1649  printout(INFO, "DD4CMS", "+++ Skip disabled algorithms: %s", name.c_str());
1650  return;
1651  }
1652  }
1653 
1654  size_t idx;
1656  string type = "DDCMS_" + ns.realName(name);
1657  while ((idx = type.find(NAMESPACE_SEP)) != string::npos)
1658  type[idx] = '_';
1659 
1660  // SensitiveDetector and Segmentation currently are undefined. Let's keep it like this
1661  // until we found something better.....
1662  printout(
1663  ns.context()->debug_algorithms ? ALWAYS : DEBUG, "DD4CMS", "+++ Start executing algorithm %s....", type.c_str());
1664 
1665  long ret = PluginService::Create<long>(type, &description, ns.context(), &element, &sd);
1666  if (ret == s_executed) {
1667  printout(ns.context()->debug_algorithms ? ALWAYS : DEBUG,
1668  "DD4CMS",
1669  "+++ Executed algorithm: %08lX = %s",
1670  ret,
1671  name.c_str());
1672  return;
1673  }
1674  printout(ERROR, "DD4CMS", "++ FAILED NOT ADDING SUBDETECTOR %08lX = %s", ret, name.c_str());
1675 }
1676 
1677 template <class InputIt, class ForwardIt, class BinOp>
1678 void for_each_token(InputIt first, InputIt last, ForwardIt s_first, ForwardIt s_last, BinOp binary_op) {
1679  while (first != last) {
1680  const auto pos = std::find_first_of(first, last, s_first, s_last);
1681  binary_op(first, pos);
1682  if (pos == last)
1683  break;
1684  first = std::next(pos);
1685  }
1686 }
1687 
1688 namespace {
1689 
1690  std::vector<string> splitString(const string& str, const string& delims = ",") {
1691  std::vector<string> output;
1692 
1693  for_each_token(cbegin(str), cend(str), cbegin(delims), cend(delims), [&output](auto first, auto second) {
1694  if (first != second) {
1695  if (string(first, second).front() == '[' && string(first, second).back() == ']') {
1696  first++;
1697  second--;
1698  }
1699  output.emplace_back(string(first, second));
1700  }
1701  });
1702  return output;
1703  }
1704 
1705  tbb::concurrent_vector<double> splitNumeric(const string& str, const string& delims = ",") {
1706  tbb::concurrent_vector<double> output;
1707 
1708  for_each_token(cbegin(str), cend(str), cbegin(delims), cend(delims), [&output](auto first, auto second) {
1709  if (first != second) {
1710  if (string(first, second).front() == '[' && string(first, second).back() == ']') {
1711  first++;
1712  second--;
1713  }
1714  output.emplace_back(dd4hep::_toDouble(string(first, second)));
1715  }
1716  });
1717  return output;
1718  }
1719 } // namespace
1720 
1723 template <>
1724 void Converter<DDLVector>::operator()(xml_h element) const {
1725  cms::DDNamespace ns(_param<cms::DDParsingContext>());
1726  cms::DDParsingContext* const context = ns.context();
1727  DDVectorsMap* registry = context->description.load()->extension<DDVectorsMap>();
1728  xml_dim_t e(element);
1729  string name = ns.prepend(e.nameStr());
1730  string type = ns.attr<string>(e, _U(type));
1731  string nEntries = ns.attr<string>(e, DD_CMU(nEntries));
1732  string val = e.text();
1733  val.erase(remove_if(val.begin(), val.end(), [](unsigned char x) { return isspace(x); }), val.end());
1734 
1735  printout(ns.context()->debug_constants ? ALWAYS : DEBUG,
1736  "DD4CMS",
1737  "+++ Vector<%s>: %s[%s]: %s",
1738  type.c_str(),
1739  name.c_str(),
1740  nEntries.c_str(),
1741  val.c_str());
1742  try {
1743  tbb::concurrent_vector<double> results = splitNumeric(val);
1744  registry->insert({name, results});
1745  } catch (const exception& e) {
1746  printout(INFO,
1747  "DD4CMS",
1748  "++ Unresolved Vector<%s>: %s[%s]: %s. Try to resolve later. [%s]",
1749  type.c_str(),
1750  name.c_str(),
1751  nEntries.c_str(),
1752  val.c_str(),
1753  e.what());
1754 
1755  std::vector<string> results = splitString(val);
1756  context->unresolvedVectors.insert({name, results});
1757  }
1758 }
1759 
1760 template <>
1761 void Converter<debug>::operator()(xml_h dbg) const {
1762  cms::DDNamespace ns(_param<cms::DDParsingContext>());
1763  if (dbg.hasChild(DD_CMU(debug_visattr)))
1764  ns.setContext()->debug_visattr = true;
1765  if (dbg.hasChild(DD_CMU(debug_constants)))
1766  ns.setContext()->debug_constants = true;
1767  if (dbg.hasChild(DD_CMU(debug_materials)))
1768  ns.setContext()->debug_materials = true;
1769  if (dbg.hasChild(DD_CMU(debug_rotations)))
1770  ns.setContext()->debug_rotations = true;
1771  if (dbg.hasChild(DD_CMU(debug_shapes)))
1772  ns.setContext()->debug_shapes = true;
1773  if (dbg.hasChild(DD_CMU(debug_volumes)))
1774  ns.setContext()->debug_volumes = true;
1775  if (dbg.hasChild(DD_CMU(debug_placements)))
1776  ns.setContext()->debug_placements = true;
1777  if (dbg.hasChild(DD_CMU(debug_namespaces)))
1778  ns.setContext()->debug_namespaces = true;
1779  if (dbg.hasChild(DD_CMU(debug_includes)))
1780  ns.setContext()->debug_includes = true;
1781  if (dbg.hasChild(DD_CMU(debug_algorithms)))
1782  ns.setContext()->debug_algorithms = true;
1783  if (dbg.hasChild(DD_CMU(debug_specpars)))
1784  ns.setContext()->debug_specpars = true;
1785 }
1786 
1787 template <>
1788 void Converter<DDRegistry>::operator()(xml_h /* element */) const {
1789  cms::DDParsingContext* context = _param<cms::DDParsingContext>();
1790  DDRegistry* res = _option<DDRegistry>();
1791  cms::DDNamespace ns(context);
1792  int count = 0;
1793 
1794  printout(context->debug_constants ? ALWAYS : DEBUG,
1795  "DD4CMS",
1796  "+++ RESOLVING %ld unknown constants.....",
1797  res->unresolvedConst.size());
1798 
1799  while (!res->unresolvedConst.empty()) {
1800  for (auto i : res->unresolvedConst) {
1801  const string& n = i.first;
1802  string rep;
1803  string& v = i.second;
1804  size_t idx, idq;
1805  for (idx = v.find('[', 0); idx != string::npos; idx = v.find('[', idx + 1)) {
1806  idq = v.find(']', idx + 1);
1807  rep = v.substr(idx + 1, idq - idx - 1);
1808  auto r = res->allConst.find(rep);
1809  if (r != res->allConst.end()) {
1810  rep = "(" + (*r).second + ")";
1811  v.replace(idx, idq - idx + 1, rep);
1812  }
1813  }
1814  if (v.find(']') == string::npos) {
1815  if (v.find("-+") != string::npos || v.find("+-") != string::npos) {
1816  while ((idx = v.find("-+")) != string::npos)
1817  v.replace(idx, 2, "-");
1818  while ((idx = v.find("+-")) != string::npos)
1819  v.replace(idx, 2, "-");
1820  }
1821  printout(context->debug_constants ? ALWAYS : DEBUG,
1822  "DD4CMS",
1823  "+++ [%06ld] ---------- %-40s = %s",
1824  res->unresolvedConst.size() - 1,
1825  n.c_str(),
1826  res->originalConst[n].c_str());
1827  ns.addConstantNS(n, v, "number");
1828  res->unresolvedConst.unsafe_erase(n);
1829  break;
1830  }
1831  }
1832  if (++count > 10000)
1833  break;
1834  }
1835  if (!res->unresolvedConst.empty()) {
1836  for (const auto& e : res->unresolvedConst)
1837  printout(ERROR, "DD4CMS", "+++ Unresolved constant: %-40s = %s.", e.first.c_str(), e.second.c_str());
1838  except("DD4CMS", "++ FAILED to resolve %ld constant entries:", res->unresolvedConst.size());
1839  }
1840  res->unresolvedConst.clear();
1841  res->originalConst.clear();
1842  res->allConst.clear();
1843 }
1844 
1845 template <>
1846 void Converter<print_xml_doc>::operator()(xml_h element) const {
1847  string fname = xml::DocumentHandler::system_path(element);
1848  printout(_param<cms::DDParsingContext>()->debug_includes ? ALWAYS : DEBUG,
1849  "DD4CMS",
1850  "+++ Processing data from: %s",
1851  fname.c_str());
1852 }
1853 
1855 static long load_dddefinition(Detector& det, xml_h element) {
1856  cms::DDParsingContext context(&det);
1857  cms::DDNamespace ns(context);
1858  ns.addConstantNS("world_x", "101*m", "number");
1859  ns.addConstantNS("world_y", "101*m", "number");
1860  ns.addConstantNS("world_z", "450*m", "number");
1861  ns.addConstantNS("Air", "materials:Air", "string");
1862  ns.addConstantNS("Vacuum", "materials:Vacuum", "string");
1863  ns.addConstantNS("fm", "1e-12*m", "number");
1864  ns.addConstantNS("mum", "1e-6*m", "number");
1865 
1866  xml_elt_t dddef(element);
1867  string fname = xml::DocumentHandler::system_path(element);
1868  bool open_geometry = dddef.hasChild(DD_CMU(open_geometry)) ? dddef.child(DD_CMU(open_geometry)) : true;
1869  bool close_geometry = dddef.hasChild(DD_CMU(close_geometry)) ? dddef.hasChild(DD_CMU(close_geometry)) : true;
1870 
1871  xml_coll_t(dddef, _U(debug)).for_each(Converter<debug>(det, &context));
1872 
1873  // Here we define the order how XML elements are processed.
1874  // Be aware of dependencies. This can only defined once.
1875  // At the end it is a limitation of DOM....
1876  printout(INFO, "DD4CMS", "+++ Processing the CMS detector description %s", fname.c_str());
1877 
1878  xml::Document doc;
1879  Converter<print_xml_doc> print_doc(det, &context);
1880  try {
1881  DDRegistry res;
1882  print_doc((doc = dddef.document()).root());
1883  xml_coll_t(dddef, DD_CMU(DisabledAlgo)).for_each(Converter<disabled_algo>(det, &context, &res));
1884  xml_coll_t(dddef, DD_CMU(ConstantsSection)).for_each(Converter<ConstantsSection>(det, &context, &res));
1885  xml_coll_t(dddef, DD_CMU(VisSection)).for_each(Converter<vissection>(det, &context));
1886  xml_coll_t(dddef, DD_CMU(RotationSection)).for_each(Converter<RotationSection>(det, &context));
1887  xml_coll_t(dddef, DD_CMU(MaterialSection)).for_each(Converter<MaterialSection>(det, &context));
1888 
1889  xml_coll_t(dddef, DD_CMU(IncludeSection)).for_each(DD_CMU(Include), Converter<include_load>(det, &context, &res));
1890 
1891  for (xml::Document d : res.includes) {
1892  print_doc((doc = d).root());
1893  Converter<include_constants>(det, &context, &res)((doc = d).root());
1894  }
1895  // Before we continue, we have to resolve all constants NOW!
1896  Converter<DDRegistry>(det, &context, &res)(dddef);
1897  {
1898  DDVectorsMap* registry = context.description.load()->extension<DDVectorsMap>();
1899 
1900  printout(context.debug_constants ? ALWAYS : DEBUG,
1901  "DD4CMS",
1902  "+++ RESOLVING %ld Vectors.....",
1903  context.unresolvedVectors.size());
1904 
1905  while (!context.unresolvedVectors.empty()) {
1906  for (auto it = context.unresolvedVectors.begin(); it != context.unresolvedVectors.end();) {
1907  auto const& name = it->first;
1908  tbb::concurrent_vector<double> result;
1909  for (const auto& i : it->second) {
1910  result.emplace_back(dd4hep::_toDouble(i));
1911  }
1912  registry->insert({name, result});
1913  // All components are resolved
1914  it = context.unresolvedVectors.erase(it);
1915  }
1916  }
1917  }
1918  // Now we can process the include files one by one.....
1919  for (xml::Document d : res.includes) {
1920  print_doc((doc = d).root());
1921  xml_coll_t(d.root(), DD_CMU(MaterialSection)).for_each(Converter<MaterialSection>(det, &context));
1922  }
1923  {
1924  printout(context.debug_materials ? ALWAYS : DEBUG,
1925  "DD4CMS",
1926  "+++ RESOLVING %ld unknown material constituents.....",
1927  context.unresolvedMaterials.size());
1928 
1929  // Resolve referenced materials (if any)
1930 
1931  while (!context.unresolvedMaterials.empty()) {
1932  for (auto it = context.unresolvedMaterials.begin(); it != context.unresolvedMaterials.end();) {
1933  auto const& name = it->first;
1934  std::vector<bool> valid;
1935 
1936  printout(context.debug_materials ? ALWAYS : DEBUG,
1937  "DD4CMS",
1938  "+++ [%06ld] ---------- %s",
1939  context.unresolvedMaterials.size(),
1940  name.c_str());
1941 
1942  auto mat = ns.material(name);
1943  for (auto& mit : it->second) {
1944  printout(context.debug_materials ? ALWAYS : DEBUG,
1945  "DD4CMS",
1946  "+++ component %-48s Fraction: %.6f",
1947  mit.name.c_str(),
1948  mit.fraction);
1949  auto fmat = ns.material(mit.name);
1950  if (nullptr != fmat.ptr()) {
1951  if (mat.ptr()->GetMaterial()->IsMixture()) {
1952  valid.emplace_back(true);
1953  static_cast<TGeoMixture*>(mat.ptr()->GetMaterial())->AddElement(fmat.ptr()->GetMaterial(), mit.fraction);
1954  }
1955  }
1956  }
1957  // All components are resolved
1958  if (valid.size() == it->second.size())
1959  it = context.unresolvedMaterials.erase(it);
1960  else
1961  ++it;
1962  }
1963  // Do it again if there are unresolved
1964  // materials left after this pass
1965  }
1966  }
1967  if (open_geometry) {
1968  context.geo_inited = true;
1969  det.init();
1970  ns.addVolume(det.worldVolume());
1971  }
1972  for (xml::Document d : res.includes) {
1973  print_doc((doc = d).root());
1974  xml_coll_t(d.root(), DD_CMU(RotationSection)).for_each(Converter<RotationSection>(det, &context));
1975  }
1976  for (xml::Document d : res.includes) {
1977  print_doc((doc = d).root());
1978  xml_coll_t(d.root(), DD_CMU(SolidSection)).for_each(Converter<SolidSection>(det, &context));
1979  }
1980  for (xml::Document d : res.includes) {
1981  print_doc((doc = d).root());
1982  xml_coll_t(d.root(), DD_CMU(LogicalPartSection)).for_each(Converter<LogicalPartSection>(det, &context));
1983  }
1984  for (xml::Document d : res.includes) {
1985  print_doc((doc = d).root());
1986  xml_coll_t(d.root(), DD_CMU(Algorithm)).for_each(Converter<DDLAlgorithm>(det, &context));
1987  }
1988  for (xml::Document d : res.includes) {
1989  print_doc((doc = d).root());
1990  xml_coll_t(d.root(), DD_CMU(PosPartSection)).for_each(Converter<PosPartSection>(det, &context));
1991  }
1992  for (xml::Document d : res.includes) {
1993  print_doc((doc = d).root());
1994  xml_coll_t(d.root(), DD_CMU(SpecParSection)).for_each(Converter<SpecParSection>(det, &context));
1995  }
1996 
1998  for (xml::Document d : res.includes)
1999  Converter<include_unload>(det, &context, &res)(d.root());
2000 
2001  print_doc((doc = dddef.document()).root());
2002  // Now process the actual geometry items
2003  xml_coll_t(dddef, DD_CMU(SolidSection)).for_each(Converter<SolidSection>(det, &context));
2004  {
2005  // Before we continue, we have to resolve all shapes NOW!
2006  // Note: This only happens in a legacy DB payloads where
2007  // boolean shapes can be defined before thier
2008  // component shapes
2009 
2010  while (!context.unresolvedShapes.empty()) {
2011  for (auto it = context.unresolvedShapes.begin(); it != context.unresolvedShapes.end();) {
2012  auto const& name = it->first;
2013  auto const& aname = std::visit([](auto&& arg) -> std::string { return arg.firstSolidName; }, it->second);
2014  auto const& bname = std::visit([](auto&& arg) -> std::string { return arg.secondSolidName; }, it->second);
2015 
2016  auto const& ait = context.shapes.find(aname);
2017  if (ait->second.isValid()) {
2018  auto const& bit = context.shapes.find(bname);
2019  if (bit->second.isValid()) {
2020  dd4hep::Solid shape = std::visit(
2021  [&ait, &bit](auto&& arg) -> dd4hep::Solid { return arg.make(ait->second, bit->second); }, it->second);
2022  context.shapes[name] = shape;
2023  it = context.unresolvedShapes.erase(it);
2024  } else
2025  ++it;
2026  } else
2027  ++it;
2028  }
2029  }
2030  }
2031  xml_coll_t(dddef, DD_CMU(LogicalPartSection)).for_each(Converter<LogicalPartSection>(det, &context));
2032  xml_coll_t(dddef, DD_CMU(Algorithm)).for_each(Converter<DDLAlgorithm>(det, &context));
2033  xml_coll_t(dddef, DD_CMU(PosPartSection)).for_each(Converter<PosPartSection>(det, &context));
2034  xml_coll_t(dddef, DD_CMU(SpecParSection)).for_each(Converter<SpecParSection>(det, &context));
2035  } catch (const exception& e) {
2036  printout(ERROR, "DD4CMS", "Exception while processing xml source:%s", doc.uri().c_str());
2037  printout(ERROR, "DD4CMS", "----> %s", e.what());
2038  throw;
2039  }
2040 
2042  if (close_geometry) {
2043  Volume wv = det.worldVolume();
2044  Volume geomv = ns.volume("cms:OCMS", false);
2045  if (geomv.isValid())
2046  wv.placeVolume(geomv, 1);
2047  Volume mfv = ns.volume("cmsMagneticField:MAGF", false);
2048  if (mfv.isValid())
2049  wv.placeVolume(mfv, 1);
2050  Volume mfv1 = ns.volume("MagneticFieldVolumes:MAGF", false);
2051  if (mfv1.isValid())
2052  wv.placeVolume(mfv1, 1);
2053 
2054  det.endDocument();
2055  }
2056  printout(INFO, "DDDefinition", "+++ Finished processing %s", fname.c_str());
2057  return 1;
2058 }
2059 
2060 // Now declare the factory entry for the plugin mechanism
2061 DECLARE_XML_DOC_READER(DDDefinition, load_dddefinition)
DDLVector
DDLVector handles Rotation and ReflectionRotation elements.
Definition: DDLVector.h:29
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:355
eostools.ls
def ls(path, rec=False)
Definition: eostools.py:349
DDAxes::y
photonAnalyzer_cfi.rMax
rMax
Definition: photonAnalyzer_cfi.py:91
ApeEstimator_cff.width
width
Definition: ApeEstimator_cff.py:24
common_cff.doc
doc
Definition: common_cff.py:54
mps_fire.i
i
Definition: mps_fire.py:355
cms_units::operators
Definition: CMSUnits.h:13
geometryCSVtoXML.zz
zz
Definition: geometryCSVtoXML.py:19
geometryCSVtoXML.yz
yz
Definition: geometryCSVtoXML.py:19
g4SimHits_cfi.Material
Material
Definition: g4SimHits_cfi.py:547
cms::DDParsingContext::geo_inited
bool geo_inited
Definition: DDParsingContext.h:73
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
funct::Constant
Polynomial< 0 > Constant
Definition: Constant.h:6
for_each_token
void for_each_token(InputIt first, InputIt last, ForwardIt s_first, ForwardIt s_last, BinOp binary_op)
Definition: DDDefinitions2Objects.cc:1678
cms::DDNamespace::solid
dd4hep::Solid solid(const std::string &name) const
Definition: DDNamespace.cc:225
cms::hash
constexpr unsigned int hash(const char *str, int h=0)
Definition: DDAlgoArguments.h:18
cms::DDNamespace::material
dd4hep::Material material(const std::string &name) const
Definition: DDNamespace.cc:121
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
DDLSphere
DDLSphere processes all Sphere elements.
Definition: DDLSphere.h:24
DDParsingContext.h
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
cms::DDVectorsMap
tbb::concurrent_unordered_map< std::string, tbb::concurrent_vector< double > > DDVectorsMap
Definition: DDNamespace.h:14
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:32
DDLTubs
DDLTubs processes Tubs elements.
Definition: DDLTubs.h:21
cond::hash
Definition: Time.h:19
cms::DDParsingContext
Definition: DDParsingContext.h:14
zMuMuMuonUserData.alpha
alpha
zGenParticlesMatch = cms.InputTag(""),
Definition: zMuMuMuonUserData.py:9
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
cms::DDNamespace
Definition: DDNamespace.h:16
edmLumisInFiles.description
description
Definition: edmLumisInFiles.py:11
pos
Definition: PixelAliasList.h:18
cms::DDParsingContext::unresolvedMaterials
std::map< std::string, std::vector< CompositeMaterial > > unresolvedMaterials
Definition: DDParsingContext.h:70
cms::DDParsingContext::debug_placements
bool debug_placements
Definition: DDParsingContext.h:82
interestingEgammaIsoDetIdsSequence_cff.outerRadius
outerRadius
Definition: interestingEgammaIsoDetIdsSequence_cff.py:14
Types.optional
optional
Definition: Types.py:167
cms::DDSpecParRegistry
Definition: DDSpecParRegistry.h:32
cms::makeRotation3D
dd4hep::Rotation3D makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
Definition: DDAlgoArguments.cc:20
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
bookConverter.results
results
Definition: bookConverter.py:144
splitString
std::vector< std::string > splitString(const std::string &fLine)
Definition: HcalDbASCIIIO.cc:58
DDLPseudoTrap
Definition: DDLPseudoTrap.h:23
personalPlayback.fp
fp
Definition: personalPlayback.py:523
SensitiveDetector
Definition: SensitiveDetector.h:25
cms::DDNamespace::addConstantNS
void addConstantNS(const std::string &name, const std::string &value, const std::string &type) const
Definition: DDNamespace.cc:107
DDLLogicalPart
DDLLogicalPart processes LogicalPart elements.
Definition: DDLLogicalPart.h:34
HLT_2018_cff.Class
Class
Definition: HLT_2018_cff.py:7110
cms::DDParsingContext::CompositeMaterial
Definition: DDParsingContext.h:63
DDAxes::x
cms::PlacedVolume
dd4hep::PlacedVolume PlacedVolume
Definition: DDFilteredView.h:46
findQualityFiles.v
v
Definition: findQualityFiles.py:179
DDLElementaryMaterial
DDLElementaryMaterial processes ElementaryMaterial elements.
Definition: DDLElementaryMaterial.h:28
cms::DDParsingContext::unresolvedVectors
std::map< std::string, std::vector< std::string > > unresolvedVectors
Definition: DDParsingContext.h:71
training_settings.idx
idx
Definition: training_settings.py:16
DDDetector.h
dqmdumpme.first
first
Definition: dqmdumpme.py:55
validateGeometry_cfg.valid
valid
Definition: validateGeometry_cfg.py:21
electronCompare.red
red
Definition: electronCompare.py:135
DDLCompositeMaterial
DDLCompositeMaterial processes all CompositeMaterial elements.
Definition: DDLCompositeMaterial.h:31
geometryDiff.epsilon
int epsilon
Definition: geometryDiff.py:26
FileInPath.h
Vector
ROOT::Math::Plane3D::Vector Vector
Definition: EcalHitMaker.cc:29
DDLCone
DDLCone processes all Cone elements.
Definition: DDLCone.h:27
GetRecoTauVFromDQM_MC_cff.cl
cl
Definition: GetRecoTauVFromDQM_MC_cff.py:38
edm::FileInPath
Definition: FileInPath.h:64
cms::DDParsingContext::description
std::atomic< dd4hep::Detector * > description
Definition: DDParsingContext.h:36
dqmdumpme.last
last
Definition: dqmdumpme.py:56
debug
#define debug
Definition: HDRShower.cc:19
convert_boolean
static void convert_boolean(cms::DDParsingContext *context, xml_h element)
Definition: DDDefinitions2Objects.cc:1010
DDAxes::undefined
cms::DDParsingContext::debug_materials
bool debug_materials
Definition: DDParsingContext.h:78
DDLEllipticalTube
DDLEllipticalTube processes all EllipticalTube elements.
Definition: DDLEllipticalTube.h:24
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
DDLBox
DDLBox processes Box elements.
Definition: DDLBox.h:27
vertices_cff.x
x
Definition: vertices_cff.py:29
DDAxes::z
runTauDisplay.vis
vis
Definition: runTauDisplay.py:328
str
#define str(s)
Definition: TestProcessor.cc:48
DDLRotationByAxis
DDLRotationByAxis handles RotationByAxis elements.
Definition: DDLRotationByAxis.h:25
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
HcalDetIdTransform::transform
unsigned transform(const HcalDetId &id, unsigned transformCode)
Definition: HcalDetIdTransform.cc:7
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:62
DDLTorus
Definition: DDLTorus.h:23
OrderedSet.t
t
Definition: OrderedSet.py:90
DDLAlgorithm
DDLAlgorithm processes Algorithm elements.
Definition: DDLAlgorithm.h:25
b
double b
Definition: hdecay.h:118
HLT_2018_cff.Algorithm
Algorithm
Definition: HLT_2018_cff.py:8159
RecoTauValidation_cfi.lineStyle
lineStyle
Definition: RecoTauValidation_cfi.py:304
DDLPosPart
DDLPosPart handles PosPart elements.
Definition: DDLPosPart.h:27
geometryCSVtoXML.xy
xy
Definition: geometryCSVtoXML.py:19
DEBUG
#define DEBUG
Definition: GeneralPurposeTrackAnalyzer.cc:79
DDAlgoArguments.h
DDAxes::rho
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
unpackBuffers-CaloStage2.INFO
INFO
Definition: unpackBuffers-CaloStage2.py:169
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:45
Scenarios_cff.scale
scale
Definition: Scenarios_cff.py:2186
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
geometryCSVtoXML.yy
yy
Definition: geometryCSVtoXML.py:19
includes
tbb::concurrent_vector< xml::Document > includes
Definition: DDDefinitions2Objects.cc:53
cms::DDParsingContext::BooleanShape
Definition: DDParsingContext.h:44
DDAxes
DDAxes
analagous to geant4/source/global/HEPGeometry/include/geomdefs.hh
Definition: DDAxes.h:11
KineDebug3::count
void count()
Definition: KinematicConstrainedVertexUpdatorT.h:21
geometryCSVtoXML.xz
xz
Definition: geometryCSVtoXML.py:19
thread_safety_macros.h
interestingEgammaIsoDetIdsSequence_cff.innerRadius
innerRadius
Definition: interestingEgammaIsoDetIdsSequence_cff.py:15
remoteMonitoring_LED_IterMethod_cfg.WARNING
WARNING
Definition: remoteMonitoring_LED_IterMethod_cfg.py:427
createfilelist.int
int
Definition: createfilelist.py:10
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
load_dddefinition
static long load_dddefinition(Detector &det, xml_h element)
Converter for <DDDefinition> tags.
Definition: DDDefinitions2Objects.cc:1855
value
Definition: value.py:1
electronCompare.blue
blue
Definition: electronCompare.py:137
cuy.rep
rep
Definition: cuy.py:1190
cms::DDNamespace::addVolume
dd4hep::Volume addVolume(dd4hep::Volume vol) const
Add rotation matrix to current namespace.
Definition: DDNamespace.cc:170
root
Definition: RooFitFunction.h:10
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:50
DDLRotationSequence
DDLRotationSequence handles a set of Rotations.
Definition: DDLRotationSequence.h:24
cms::DDNamespace::addSolid
dd4hep::Solid addSolid(const std::string &name, dd4hep::Solid solid) const
Definition: DDNamespace.cc:221
PVValHelper::dy
Definition: PVValidationHelpers.h:49
DOFs::thetaY
Definition: AlignPCLThresholdsWriter.cc:37
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
DDLTrapezoid
Definition: DDLTrapezoid.h:23
res
Definition: Electron.h:6
allConst
tbb::concurrent_unordered_map< std::string, std::string > allConst
Definition: DDDefinitions2Objects.cc:54
fileinputsource_cfi.sec
sec
Definition: fileinputsource_cfi.py:87
cms::s_executed
static constexpr long s_executed
Definition: DDAlgoArguments.h:16
alignCSCRings.r
r
Definition: alignCSCRings.py:93
DDAxes::phi
alignmentValidation.fname
string fname
main script
Definition: alignmentValidation.py:959
DOFs::thetaX
Definition: AlignPCLThresholdsWriter.cc:37
align::Detector
Definition: StructureType.h:86
bookConverter.elements
elements
Definition: bookConverter.py:147
type
type
Definition: HCALResponse.h:21
heppy_batch.val
val
Definition: heppy_batch.py:351
std
Definition: JetResolutionObject.h:76
cms::DDParsingContext::debug_constants
bool debug_constants
Definition: DDParsingContext.h:77
DDLDivision
DDLDivision processes Division elements.
Definition: DDLDivision.h:27
PVValHelper::dz
Definition: PVValidationHelpers.h:50
cms::DDParsingContext::debug_rotations
bool debug_rotations
Definition: DDParsingContext.h:79
cms::DDNamespace::context
DDParsingContext *const context() const
Definition: DDNamespace.h:65
DOFs::thetaZ
Definition: AlignPCLThresholdsWriter.cc:37
HGCalGeometryMode::Polyhedra
Definition: HGCalGeometryMode.h:26
relativeConstraints.value
value
Definition: relativeConstraints.py:53
cms::DDParsingContext::unresolvedShapes
std::map< std::string, std::variant< BooleanShape< dd4hep::UnionSolid >, BooleanShape< dd4hep::SubtractionSolid >, BooleanShape< dd4hep::IntersectionSolid > > > unresolvedShapes
Definition: DDParsingContext.h:61
cms::DDParsingContext::shapes
tbb::concurrent_unordered_map< std::string, dd4hep::Solid > shapes
Definition: DDParsingContext.h:38
dd4hep
Definition: DDPlugins.h:8
runonSM.TYPE
TYPE
Definition: runonSM.py:21
DD_CMU
#define DD_CMU(a)
Definition: DDXMLTags.h:189
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
CosmicsPD_Skims.radius
radius
Definition: CosmicsPD_Skims.py:135
HGCalGeometryMode::ExtrudedPolygon
Definition: HGCalGeometryMode.h:26
angle
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
CMSUnits.h
DDNamespace.h
cms::DDSpecParRegistry::specpars
DDSpecParMap specpars
Definition: DDSpecParRegistry.h:39
sd
double sd
Definition: CascadeWrapper.h:113
NAMESPACE_SEP
#define NAMESPACE_SEP
Definition: DDNamespace.h:79
photonAnalyzer_cfi.rMin
rMin
Definition: photonAnalyzer_cfi.py:90
funct::arg
A arg
Definition: Factorize.h:36
ztail.d
d
Definition: ztail.py:151
class-composition.child
child
Definition: class-composition.py:91
mps_fire.result
result
Definition: mps_fire.py:303
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
child
Definition: simpleInheritance.h:11
dqm::qstatus::ERROR
static const int ERROR
Definition: MonitorElement.h:54
cms::Translation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > Translation
Definition: DDFilteredView.h:51
GeneratorMix_cff.mix
mix
Definition: GeneratorMix_cff.py:6
dd4hep::createPlacement
TGeoCombiTrans * createPlacement(const Rotation3D &iRot, const Position &iTrans)
Definition: DDDefinitions2Objects.cc:109
class-composition.parent
parent
Definition: class-composition.py:88
HLT_2018_cff.fraction
fraction
Definition: HLT_2018_cff.py:51317
originalConst
tbb::concurrent_unordered_map< std::string, std::string > originalConst
Definition: DDDefinitions2Objects.cc:54
cms::DDNamespace::volume
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:190
PVValHelper::dx
Definition: PVValidationHelpers.h:48
geometryCSVtoXML.xx
xx
Definition: geometryCSVtoXML.py:19
unresolvedConst
tbb::concurrent_unordered_map< std::string, std::string > unresolvedConst
Definition: DDDefinitions2Objects.cc:54
g
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
fastSimProducer_cff.density
density
Definition: fastSimProducer_cff.py:61
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
cms::makeRotReflect
dd4hep::Rotation3D makeRotReflect(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
Definition: DDAlgoArguments.cc:32