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" 12 #include "XML/Utilities.h" 21 #include "TGeoManager.h" 22 #include "TGeoMaterial.h" 29 #include "tbb/concurrent_unordered_map.h" 30 #include "tbb/concurrent_vector.h" 41 atomic<UInt_t> unique_mat_id = 0xAFFEFEED;
44 class include_constants;
49 class ConstantsSection;
53 tbb::concurrent_vector<xml::Document>
includes;
57 class MaterialSection;
61 class RotationSection;
63 class DDLReflectionRotation;
72 class LogicalPartSection;
76 class DDLExtrudedPolygon;
93 class DDLIntersectionSolid;
94 class DDLSubtractionSolid;
111 iRot.GetComponents(elements);
113 r.SetMatrix(elements);
115 TGeoTranslation
t(iTrans.x(), iTrans.y(), iTrans.z());
117 return new TGeoCombiTrans(
t, r);
122 void Converter<debug>::operator()(xml_h element)
const;
124 void Converter<print_xml_doc>::operator()(xml_h element)
const;
126 void Converter<disabled_algo>::operator()(xml_h element)
const;
130 void Converter<ConstantsSection>::operator()(xml_h element)
const;
132 void Converter<DDLConstant>::operator()(xml_h element)
const;
134 void Converter<DDRegistry>::operator()(xml_h element)
const;
138 void Converter<vissection>::operator()(xml_h element)
const;
141 void Converter<vis>::operator()(xml_h element)
const;
145 void Converter<MaterialSection>::operator()(xml_h element)
const;
147 void Converter<DDLElementaryMaterial>::operator()(xml_h element)
const;
149 void Converter<DDLCompositeMaterial>::operator()(xml_h element)
const;
153 void Converter<RotationSection>::operator()(xml_h element)
const;
156 void Converter<DDLRotation>::operator()(xml_h element)
const;
159 void Converter<DDLReflectionRotation>::operator()(xml_h element)
const;
162 void Converter<DDLRotationSequence>::operator()(xml_h element)
const;
165 void Converter<DDLRotationByAxis>::operator()(xml_h element)
const;
167 void Converter<DDLTransform3D>::operator()(xml_h element)
const;
171 void Converter<LogicalPartSection>::operator()(xml_h element)
const;
173 void Converter<DDLLogicalPart>::operator()(xml_h element)
const;
177 void Converter<PosPartSection>::operator()(xml_h element)
const;
180 void Converter<DDLPosPart>::operator()(xml_h element)
const;
183 void Converter<DDLDivision>::operator()(xml_h element)
const;
187 void Converter<SpecParSection>::operator()(xml_h element)
const;
189 void Converter<SpecPar>::operator()(xml_h element)
const;
191 void Converter<PartSelector>::operator()(xml_h element)
const;
193 void Converter<Parameter>::operator()(xml_h element)
const;
197 void Converter<SolidSection>::operator()(xml_h element)
const;
200 void Converter<DDLUnionSolid>::operator()(xml_h element)
const;
203 void Converter<DDLSubtractionSolid>::operator()(xml_h element)
const;
206 void Converter<DDLIntersectionSolid>::operator()(xml_h element)
const;
209 void Converter<DDLPseudoTrap>::operator()(xml_h element)
const;
212 void Converter<DDLExtrudedPolygon>::operator()(xml_h element)
const;
215 void Converter<DDLShapeless>::operator()(xml_h element)
const;
218 void Converter<DDLTrapezoid>::operator()(xml_h element)
const;
221 void Converter<DDLPolycone>::operator()(xml_h element)
const;
224 void Converter<DDLPolyhedra>::operator()(xml_h element)
const;
227 void Converter<DDLEllipticalTube>::operator()(xml_h element)
const;
230 void Converter<DDLTorus>::operator()(xml_h element)
const;
233 void Converter<DDLTubs>::operator()(xml_h element)
const;
236 void Converter<DDLCutTubs>::operator()(xml_h element)
const;
239 void Converter<DDLTruncTubs>::operator()(xml_h element)
const;
242 void Converter<DDLSphere>::operator()(xml_h element)
const;
245 void Converter<DDLTrd1>::operator()(xml_h element)
const;
248 void Converter<DDLTrd2>::operator()(xml_h element)
const;
251 void Converter<DDLCone>::operator()(xml_h element)
const;
254 void Converter<DDLBox>::operator()(xml_h element)
const;
257 void Converter<DDLAlgorithm>::operator()(xml_h element)
const;
260 void Converter<DDLVector>::operator()(xml_h element)
const;
264 void Converter<include_load>::operator()(xml_h element)
const;
267 void Converter<include_unload>::operator()(xml_h element)
const;
270 void Converter<include_constants>::operator()(xml_h element)
const;
275 void Converter<ConstantsSection>::operator()(xml_h element)
const {
284 void Converter<vissection>::operator()(xml_h element)
const {
291 void Converter<MaterialSection>::operator()(xml_h element)
const {
293 xml_coll_t(element,
DD_CMU(ElementaryMaterial))
295 xml_coll_t(element,
DD_CMU(CompositeMaterial))
300 void Converter<RotationSection>::operator()(xml_h element)
const {
303 xml_coll_t(element,
DD_CMU(ReflectionRotation))
305 xml_coll_t(element,
DD_CMU(RotationSequence))
307 xml_coll_t(element,
DD_CMU(RotationByAxis))
312 void Converter<PosPartSection>::operator()(xml_h element)
const {
320 void Converter<SpecParSection>::operator()(xml_h element)
const {
326 void Converter<SpecPar>::operator()(xml_h element)
const {
334 void Converter<LogicalPartSection>::operator()(xml_h element)
const {
340 void Converter<disabled_algo>::operator()(xml_h element)
const {
347 void Converter<SolidSection>::operator()(xml_h element)
const {
349 for (xml_coll_t solid(element, _U(star)); solid; ++solid) {
350 string tag = solid.tag();
352 switch (
hash(solid.tag())) {
356 case hash(
"Polycone"):
359 case hash(
"Polyhedra"):
365 case hash(
"CutTubs"):
368 case hash(
"TruncTubs"):
386 case hash(
"EllipticalTube"):
392 case hash(
"PseudoTrap"):
395 case hash(
"ExtrudedPolygon"):
398 case hash(
"Trapezoid"):
401 case hash(
"UnionSolid"):
404 case hash(
"SubtractionSolid"):
407 case hash(
"IntersectionSolid"):
410 case hash(
"ShapelessSolid"):
414 throw std::runtime_error(
"Request to process unknown shape '" + xml_dim_t(solid).nameStr() +
"' [" + tag +
"]");
422 void Converter<DDLConstant>::operator()(xml_h element)
const {
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();
431 string typ = eval ?
"number" :
"string";
432 size_t idx = val.find(
'[');
434 if (constant.hasAttr(_U(
type)))
435 typ = constant.typeStr();
437 if (idx == string::npos || typ ==
"string") {
440 res->allConst[real] =
val;
441 res->originalConst[real] =
val;
445 "++ Unresolved constant: %s = %s [%s]. Try to resolve later. [%s]",
454 while (idx != string::npos) {
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)
462 idx = val.find(
'[', idx);
466 res->allConst[real] =
val;
467 res->originalConst[real] =
val;
468 res->unresolvedConst[real] =
val;
480 void Converter<vis>::operator()(xml_h
e)
const {
482 VisAttr attr(e.attr<
string>(_U(
name)));
483 float red = e.hasAttr(_U(
r)) ? e.attr<
float>(_U(
r)) : 1.0
f;
484 float green = e.hasAttr(_U(
g)) ? e.attr<
float>(_U(
g)) : 1.0
f;
485 float blue = e.hasAttr(_U(
b)) ? e.attr<
float>(_U(
b)) : 1.0
f;
489 "++ Converting VisAttr structure: %-16s. R=%.3f G=%.3f B=%.3f",
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)));
501 if (ls ==
"unbroken")
502 attr.setLineStyle(VisAttr::SOLID);
503 else if (ls ==
"broken")
504 attr.setLineStyle(VisAttr::DASHED);
506 attr.setLineStyle(VisAttr::SOLID);
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);
515 attr.setDrawingStyle(VisAttr::SOLID);
517 if (e.hasAttr(_U(showDaughters)))
518 attr.setShowDaughters(e.attr<
bool>(_U(showDaughters)));
520 attr.setShowDaughters(
true);
526 void Converter<DDLElementaryMaterial>::operator()(xml_h element)
const {
528 xml_dim_t xmat(element);
529 string nam = ns.
prepend(xmat.nameStr());
531 TGeoMaterial* mat = mgr.GetMaterial(nam.c_str());
532 if (
nullptr == mat) {
533 const char* matname = nam.c_str();
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 TGeoMixture*
mix =
new TGeoMixture(nam.c_str(), 1,
density);
539 TGeoElement* elt = tab->FindElement(xmat.nameStr().c_str());
543 "+++ Converting material %-48s Atomic weight %8.3f [g/mol], Atomic number %u, Density: %8.3f [g/cm3] " 544 "ROOT: %8.3f [g/cm3]",
545 (
'"' + nam +
'"').c_str(),
551 bool newMatDef =
false;
557 " ROOT definition of %-50s Atomic weight %.3f, Atomic number %u, Number of nucleons %u",
562 if (atomicNumber != elt->Z() || atomicWeight != elt->A())
566 if (!elt || newMatDef) {
570 "+++ Converter<ElementaryMaterial> Different definition of a default element with name:%s [CREATE NEW " 576 "+++ Converter<ElementaryMaterial> No default element present with name:%s [CREATE NEW MATERIAL]",
578 elt =
new TGeoElement(xmat.nameStr().c_str(),
"CMS element", atomicNumber, atomicWeight);
581 mix->AddElement(elt, 1.0);
584 TGeoMedium* medium = mgr.GetMedium(matname);
585 if (
nullptr == medium) {
587 medium =
new TGeoMedium(matname, unique_mat_id, mix);
588 medium->SetTitle(
"material");
589 medium->SetUniqueID(unique_mat_id);
596 void Converter<DDLCompositeMaterial>::operator()(xml_h element)
const {
598 xml_dim_t xmat(element);
599 string nam = ns.
prepend(xmat.nameStr());
602 TGeoMaterial* mat = mgr.GetMaterial(nam.c_str());
603 if (
nullptr == mat) {
604 const char* matname = nam.c_str();
606 xml_coll_t composites(xmat,
DD_CMU(MaterialFraction));
607 TGeoMixture*
mix =
new TGeoMixture(nam.c_str(), composites.size(),
density);
611 "++ Converting material %-48s Density: %8.3f [g/cm3] ROOT: %8.3f [g/cm3]",
612 (
'"' + nam +
'"').c_str(),
616 for (composites.reset(); composites; ++composites) {
617 xml_dim_t xfrac(composites);
618 xml_dim_t xfrac_mat(xfrac.child(
DD_CMU(rMaterial)));
620 string fracname = ns.
realName(xfrac_mat.nameStr());
622 TGeoMaterial* frac_mat = mgr.GetMaterial(fracname.c_str());
623 if (frac_mat ==
nullptr)
624 frac_mat = mgr.GetMaterial(ns.
prepend(fracname).c_str());
626 mix->AddElement(frac_mat, fraction);
632 "+++ Composite material \"%s\" [nor \"%s\"] not present! [delay resolution]",
640 TGeoMedium* medium = mgr.GetMedium(matname);
641 if (
nullptr == medium) {
643 medium =
new TGeoMedium(matname, unique_mat_id, mix);
644 medium->SetTitle(
"material");
645 medium->SetUniqueID(unique_mat_id);
652 void Converter<DDLRotation>::operator()(xml_h element)
const {
655 xml_dim_t xrot(element);
656 string nam = xrot.nameStr();
657 double thetaX = xrot.hasAttr(
DD_CMU(thetaX)) ? ns.attr<
double>(xrot,
DD_CMU(thetaX)) : 0e0;
658 double phiX = xrot.hasAttr(
DD_CMU(phiX)) ? ns.attr<
double>(xrot,
DD_CMU(phiX)) : 0e0;
659 double thetaY = xrot.hasAttr(
DD_CMU(thetaY)) ? ns.attr<
double>(xrot,
DD_CMU(thetaY)) : 0e0;
660 double phiY = xrot.hasAttr(
DD_CMU(phiY)) ? ns.attr<
double>(xrot,
DD_CMU(phiY)) : 0e0;
661 double thetaZ = xrot.hasAttr(
DD_CMU(thetaZ)) ? ns.attr<
double>(xrot,
DD_CMU(thetaZ)) : 0e0;
662 double phiZ = xrot.hasAttr(
DD_CMU(phiZ)) ? ns.attr<
double>(xrot,
DD_CMU(phiZ)) : 0e0;
666 "+++ Adding rotation: %-32s: (theta/phi)[rad] X: %6.3f %6.3f Y: %6.3f %6.3f Z: %6.3f %6.3f",
667 ns.prepend(nam).c_str(),
674 ns.addRotation(nam, rot);
679 void Converter<DDLReflectionRotation>::operator()(xml_h element)
const {
682 xml_dim_t xrot(element);
683 string name = xrot.nameStr();
684 double thetaX = xrot.hasAttr(
DD_CMU(thetaX)) ? ns.attr<
double>(xrot,
DD_CMU(thetaX)) : 0e0;
685 double phiX = xrot.hasAttr(
DD_CMU(phiX)) ? ns.attr<
double>(xrot,
DD_CMU(phiX)) : 0e0;
686 double thetaY = xrot.hasAttr(
DD_CMU(thetaY)) ? ns.attr<
double>(xrot,
DD_CMU(thetaY)) : 0e0;
687 double phiY = xrot.hasAttr(
DD_CMU(phiY)) ? ns.attr<
double>(xrot,
DD_CMU(phiY)) : 0e0;
688 double thetaZ = xrot.hasAttr(
DD_CMU(thetaZ)) ? ns.attr<
double>(xrot,
DD_CMU(thetaZ)) : 0e0;
689 double phiZ = xrot.hasAttr(
DD_CMU(phiZ)) ? ns.attr<
double>(xrot,
DD_CMU(phiZ)) : 0e0;
692 "+++ Adding reflection rotation: %-32s: (theta/phi)[rad] X: %6.3f %6.3f Y: %6.3f %6.3f Z: %6.3f %6.3f",
693 ns.prepend(name).c_str(),
701 ns.addRotation(name, rot);
706 void Converter<DDLRotationSequence>::operator()(xml_h element)
const {
709 xml_dim_t xrot(element);
710 string nam = xrot.nameStr();
712 xml_coll_t rotations(xrot,
DD_CMU(RotationByAxis));
713 for (rotations.reset(); rotations; ++rotations) {
714 string axis = ns.attr<
string>(rotations,
DD_CMU(axis));
715 double angle = ns.attr<
double>(rotations, _U(angle));
719 "+ Adding rotation to: %-29s: (axis/angle)[rad] Axis: %s Angle: %6.3f",
727 rot.GetComponents(xx, xy, xz, yx, yy, yz, zx, zy, zz);
730 "+++ Adding rotation sequence: %-23s: %6.3f %6.3f %6.3f, %6.3f %6.3f %6.3f, %6.3f %6.3f %6.3f",
731 ns.prepend(nam).c_str(),
741 ns.addRotation(nam, rot);
746 void Converter<DDLRotationByAxis>::operator()(xml_h element)
const {
749 xml_dim_t xrot(element);
750 xml_dim_t par(xrot.parent());
751 if (xrot.hasAttr(_U(
name))) {
752 string nam = xrot.nameStr();
753 string axis = ns.attr<
string>(xrot,
DD_CMU(axis));
754 double angle = ns.attr<
double>(xrot, _U(angle));
759 "+++ Adding rotation: %-32s: (axis/angle)[rad] Axis: %s Angle: %6.3f",
760 ns.prepend(nam).c_str(),
763 ns.addRotation(nam, rot);
769 void Converter<DDLLogicalPart>::operator()(xml_h element)
const {
771 xml_dim_t
e(element);
772 string sol = e.child(
DD_CMU(rSolid)).attr<
string>(_U(
name));
773 string mat = e.child(
DD_CMU(rMaterial)).attr<
string>(_U(
name));
774 string volName = e.attr<
string>(_U(
name));
775 Solid solid = ns.
solid(sol);
780 "+++ %s Volume: %-24s [%s] Shape: %-32s [%s] Material: %-40s [%s]",
783 volume.isValid() ?
"VALID" :
"INVALID",
785 solid.isValid() ?
"VALID" :
"INVALID",
787 material.isValid() ?
"VALID" :
"INVALID");
792 void Converter<DDLTransform3D>::operator()(xml_h element)
const {
794 Transform3D* tr = _option<Transform3D>();
795 xml_dim_t
e(element);
798 xml_dim_t refRotation = e.child(
DD_CMU(rRotation),
false);
799 xml_dim_t refReflectionRotation = e.child(
DD_CMU(rReflectionRotation),
false);
803 if (translation.ptr()) {
804 double x = ns.
attr<
double>(translation, _U(x));
805 double y = ns.
attr<
double>(translation, _U(y));
806 double z = ns.
attr<
double>(translation, _U(z));
807 pos = Position(x, y, z);
809 if (rotation.ptr()) {
813 rot = RotationZYX(z, y, x);
814 }
else if (refRotation.ptr()) {
815 string rotName = refRotation.nameStr();
817 rotName = ns.
name() + rotName;
820 }
else if (refReflectionRotation.ptr()) {
821 string rotName = refReflectionRotation.nameStr();
823 rotName = ns.
name() + rotName;
827 *tr = Transform3D(rot, pos);
832 void Converter<DDLPosPart>::operator()(xml_h element)
const {
834 xml_dim_t
e(element);
836 string parentName = ns.
attr<
string>(e.child(
DD_CMU(rParent)), _U(
name));
837 string childName = ns.
attr<
string>(e.child(
DD_CMU(rChild)), _U(
name));
842 "+++ %s Parent: %-24s [%s] Child: %-32s [%s] copy:%d",
845 parent.isValid() ?
"VALID" :
"INVALID",
847 child.isValid() ?
"VALID" :
"INVALID",
850 if (!parent.isValid() && strchr(parentName.c_str(),
NAMESPACE_SEP) ==
nullptr)
851 parentName = ns.
name() + parentName;
852 parent = ns.
volume(parentName);
854 if (!child.isValid() && strchr(childName.c_str(),
NAMESPACE_SEP) ==
nullptr)
855 childName = ns.
name() + childName;
856 child = ns.
volume(childName,
false);
860 "+++ %s Parent: %-24s [%s] Child: %-32s [%s] copy:%d",
863 parent.isValid() ?
"VALID" :
"INVALID",
865 child.isValid() ?
"VALID" :
"INVALID",
869 if (child.isValid()) {
877 except(
"dd4hep",
"Volume: Attempt to assign daughters to an invalid physical parent volume.");
880 except(
"dd4hep",
"Volume: Attempt to assign an invalid physical daughter volume.");
882 TGeoShape* shape = child->GetShape();
885 TGeoShapeAssembly* as = (TGeoShapeAssembly*)shape;
889 as->NeedsBBoxRecompute();
894 TString nam_id = TString::Format(
"%s_%d", child->GetName(),
copy);
895 n =
static_cast<TGeoNode*
>(parent->GetNode(nam_id));
897 printout(
ERROR,
"PlacedVolume",
"++ Attempt to add already exiting node %s", (
const char*)nam_id);
900 Rotation3D
rot(transform.Rotation());
901 Translation3D trans(transform.Translation());
903 trans.GetComponents(x, y, z);
904 Position
pos(x, y, z);
907 n =
static_cast<TGeoNode*
>(parent->GetNode(nam_id));
908 n->TGeoNode::SetUserExtension(
new PlacedVolume::Object());
914 "+++ Placement FAILED! Parent:%s Child:%s Valid:%s",
917 yes_no(child.isValid()));
923 void Converter<PartSelector>::operator()(xml_h element)
const {
927 xml_dim_t
e(element);
928 xml_dim_t specPar = e.parent();
929 string specParName = specPar.attr<
string>(_U(
name));
933 "+++ PartSelector for %s path: %s",
936 registry.
specpars[specParName].paths.emplace_back(path);
941 void Converter<Parameter>::operator()(xml_h element)
const {
945 xml_dim_t
e(element);
946 xml_dim_t specPar = e.parent();
947 xml_dim_t specParSect = specPar.parent();
948 string specParName = specPar.attr<
string>(_U(
name));
949 string name = e.nameStr();
951 bool eval = e.hasAttr(_U(eval)) ? e.attr<
bool>(_U(eval))
952 : (specParSect.hasAttr(_U(eval)) ? specParSect.attr<
bool>(_U(eval)) :
false);
953 string type = eval ?
"number" :
"string";
957 "+++ Parameter for %s: %s value %s is a %s",
963 size_t idx = value.find(
'[');
964 if (idx == string::npos || type ==
"string") {
965 registry.
specpars[specParName].spars[
name].emplace_back(value);
969 while (idx != string::npos) {
971 size_t idp = value.find(
':', idx);
972 size_t idq = value.find(
']', idx);
973 if (idp == string::npos || idp > idq)
974 value.insert(idx, ns.
name());
975 else if (idp != string::npos && idp < idq)
977 idx = value.find(
'[', idx);
983 for (idx = v.find(
'[', 0); idx != string::npos; idx = v.find(
'[', idx + 1)) {
984 idq = v.find(
']', idx + 1);
985 rep = v.substr(idx + 1, idq - idx - 1);
988 rep =
"(" +
r->second->type +
")";
989 v.replace(idx, idq - idx + 1, rep);
992 registry.
specpars[specParName].numpars[
name].emplace_back(_toDouble(value));
995 template <
typename TYPE>
998 xml_dim_t
e(element);
999 string nam = e.nameStr();
1000 string solidName[2];
1004 if (e.hasChild(
DD_CMU(rSolid))) {
1005 for (xml_coll_t
c(element,
DD_CMU(rSolid)); cnt < 2 &&
c; ++
c, ++cnt) {
1006 solidName[cnt] = c.attr<
string>(_U(
name));
1007 solids[cnt] = ns.
solid(c.attr<
string>(_U(
name)));
1010 solidName[0] = e.attr<
string>(
DD_CMU(firstSolid));
1011 if ((solids[0] = ns.
solid(e.attr<
string>(
DD_CMU(firstSolid)))).isValid())
1013 solidName[1] = e.attr<
string>(
DD_CMU(secondSolid));
1014 if ((solids[1] = ns.
solid(e.attr<
string>(
DD_CMU(secondSolid)))).isValid())
1018 except(
"DD4CMS",
"+++ Failed to create boolean solid %s. Found only %d parts.", nam.c_str(), cnt);
1023 "+++ BooleanSolid: %s Left: %-32s Right: %-32s",
1025 ((solids[0].ptr() ==
nullptr) ? solidName[0].c_str() : solids[0]->GetName()),
1026 ((solids[1].ptr() ==
nullptr) ? solidName[1].c_str() : solids[1]->GetName()));
1028 if (solids[0].isValid() && solids[1].isValid()) {
1030 Converter<DDLTransform3D>(*context->
description, context, &trafo)(element);
1031 boolean =
TYPE(solids[0], solids[1], trafo);
1035 Converter<DDLTransform3D>(*context->
description, context, &trafo)(element);
1039 if (!
boolean.isValid()) {
1048 void Converter<DDLUnionSolid>::operator()(xml_h element)
const {
1049 convert_boolean<UnionSolid>(_param<cms::DDParsingContext>(), element);
1054 void Converter<DDLSubtractionSolid>::operator()(xml_h element)
const {
1055 convert_boolean<SubtractionSolid>(_param<cms::DDParsingContext>(), element);
1060 void Converter<DDLIntersectionSolid>::operator()(xml_h element)
const {
1061 convert_boolean<IntersectionSolid>(_param<cms::DDParsingContext>(), element);
1066 void Converter<DDLPolycone>::operator()(xml_h element)
const {
1068 xml_dim_t
e(element);
1069 string nam = e.nameStr();
1070 double startPhi = ns.
attr<
double>(
e,
DD_CMU(startPhi));
1072 vector<double>
z, rmin, rmax,
r;
1074 for (xml_coll_t rzpoint(element,
DD_CMU(RZPoint)); rzpoint; ++rzpoint) {
1075 z.emplace_back(ns.
attr<
double>(rzpoint, _U(z)));
1076 r.emplace_back(ns.
attr<
double>(rzpoint, _U(r)));
1079 for (xml_coll_t zplane(element,
DD_CMU(ZSection)); zplane; ++zplane) {
1082 z.emplace_back(ns.
attr<
double>(zplane, _U(z)));
1086 "+ Polycone: startPhi=%10.3f [rad] deltaPhi=%10.3f [rad] %4ld z-planes",
1090 ns.
addSolid(nam, Polycone(startPhi, deltaPhi, rmin, rmax, z));
1094 "+ Polycone: startPhi=%10.3f [rad] deltaPhi=%10.3f [rad] %4ld z-planes and %4ld radii",
1099 ns.
addSolid(nam, Polycone(startPhi, deltaPhi, r, z));
1105 void Converter<DDLExtrudedPolygon>::operator()(xml_h element)
const {
1107 xml_dim_t
e(element);
1108 string nam = e.nameStr();
1109 vector<double> pt_x, pt_y, sec_x, sec_y, sec_z, sec_scale;
1112 sec_z.emplace_back(ns.
attr<
double>(
sec, _U(
z)));
1113 sec_x.emplace_back(ns.
attr<
double>(
sec, _U(
x)));
1114 sec_y.emplace_back(ns.
attr<
double>(
sec, _U(
y)));
1117 for (xml_coll_t
pt(element,
DD_CMU(XYPoint));
pt; ++
pt) {
1118 pt_x.emplace_back(ns.
attr<
double>(
pt, _U(
x)));
1119 pt_y.emplace_back(ns.
attr<
double>(
pt, _U(
y)));
1123 "+ ExtrudedPolygon: %4ld points %4ld zxy sections",
1131 void Converter<DDLPolyhedra>::operator()(xml_h element)
const {
1133 xml_dim_t
e(element);
1134 string nam = e.nameStr();
1135 double numSide = ns.
attr<
int>(
e,
DD_CMU(numSide));
1136 double startPhi = ns.
attr<
double>(
e,
DD_CMU(startPhi));
1138 vector<double>
z, rmin, rmax;
1140 for (xml_coll_t zplane(element,
DD_CMU(RZPoint)); zplane; ++zplane) {
1141 rmin.emplace_back(0.0);
1142 rmax.emplace_back(ns.
attr<
double>(zplane, _U(
r)));
1143 z.emplace_back(ns.
attr<
double>(zplane, _U(z)));
1145 for (xml_coll_t zplane(element,
DD_CMU(ZSection)); zplane; ++zplane) {
1148 z.emplace_back(ns.
attr<
double>(zplane, _U(z)));
1152 "+ Polyhedra:startPhi=%8.3f [rad] deltaPhi=%8.3f [rad] %4d sides %4ld z-planes",
1162 void Converter<DDLSphere>::operator()(xml_h element)
const {
1164 xml_dim_t
e(element);
1165 string nam = e.nameStr();
1168 double startPhi = ns.
attr<
double>(
e,
DD_CMU(startPhi));
1170 double startTheta = ns.
attr<
double>(
e,
DD_CMU(startTheta));
1171 double deltaTheta = ns.
attr<
double>(
e,
DD_CMU(deltaTheta));
1174 "+ Sphere: r_inner=%8.3f [cm] r_outer=%8.3f [cm]" 1175 " startPhi=%8.3f [rad] deltaPhi=%8.3f startTheta=%8.3f delteTheta=%8.3f [rad]",
1182 ns.
addSolid(nam, Sphere(rinner, router, startTheta, deltaTheta, startPhi, deltaPhi));
1187 void Converter<DDLTorus>::operator()(xml_h element)
const {
1189 xml_dim_t
e(element);
1190 string nam = e.nameStr();
1194 double startPhi = ns.
attr<
double>(
e,
DD_CMU(startPhi));
1198 "+ Torus: r=%10.3f [cm] r_inner=%10.3f [cm] r_outer=%10.3f [cm]" 1199 " startPhi=%10.3f [rad] deltaPhi=%10.3f [rad]",
1205 ns.
addSolid(nam, Torus(r, rinner, router, startPhi, deltaPhi));
1210 void Converter<DDLPseudoTrap>::operator()(xml_h element)
const {
1212 xml_dim_t
e(element);
1213 string nam = e.nameStr();
1218 double dz = ns.
attr<
double>(
e, _U(dz));
1220 bool atMinusZ = ns.
attr<
bool>(
e,
DD_CMU(atMinusZ));
1223 "+ Pseudotrap: dz=%8.3f [cm] dx1:%.3f dy1:%.3f dx2=%.3f dy2=%.3f radius:%.3f atMinusZ:%s",
1231 ns.
addSolid(nam, PseudoTrap(dx1, dx2, dy1, dy2, dz, r, atMinusZ));
1236 void Converter<DDLTrapezoid>::operator()(xml_h element)
const {
1238 xml_dim_t
e(element);
1239 string nam = e.nameStr();
1240 double dz = ns.
attr<
double>(
e, _U(dz));
1249 double phi = ns.
attr<
double>(
e, _U(phi), 0.0);
1250 double theta = ns.
attr<
double>(
e, _U(theta), 0.0);
1254 "+ Trapezoid: dz=%10.3f [cm] alp1:%.3f bl1=%.3f tl1=%.3f alp2=%.3f bl2=%.3f tl2=%.3f h2=%.3f phi=%.3f " 1267 ns.
addSolid(nam, Trap(dz, theta, phi, h1, bl1, tl1, alp1, h2, bl2, tl2, alp2));
1272 void Converter<DDLTrd1>::operator()(xml_h element)
const {
1274 xml_dim_t
e(element);
1275 string nam = e.nameStr();
1278 double dx2 = ns.
attr<
double>(
e,
DD_CMU(dx2), 0.0);
1279 double dy2 = ns.
attr<
double>(
e,
DD_CMU(dy2), dy1);
1284 "+ Trd1: dz=%8.3f [cm] dx1:%.3f dy1:%.3f dx2:%.3f dy2:%.3f",
1290 ns.
addSolid(nam, Trd1(dx1, dx2, dy1, dz));
1294 "+ Trd1(which is actually Trd2): dz=%8.3f [cm] dx1:%.3f dy1:%.3f dx2:%.3f dy2:%.3f",
1300 ns.
addSolid(nam, Trd2(dx1, dx2, dy1, dy2, dz));
1306 void Converter<DDLTrd2>::operator()(xml_h element)
const {
1308 xml_dim_t
e(element);
1309 string nam = e.nameStr();
1312 double dx2 = ns.
attr<
double>(
e,
DD_CMU(dx2), 0.0);
1313 double dy2 = ns.
attr<
double>(
e,
DD_CMU(dy2), dy1);
1317 "+ Trd1: dz=%8.3f [cm] dx1:%.3f dy1:%.3f dx2:%.3f dy2:%.3f",
1323 ns.
addSolid(nam, Trd2(dx1, dx2, dy1, dy2, dz));
1328 void Converter<DDLTubs>::operator()(xml_h element)
const {
1330 xml_dim_t
e(element);
1331 string nam = e.nameStr();
1335 double startPhi = ns.
attr<
double>(
e,
DD_CMU(startPhi), 0.0);
1339 "+ Tubs: dz=%8.3f [cm] rmin=%8.3f [cm] rmax=%8.3f [cm]" 1340 " startPhi=%8.3f [rad] deltaPhi=%8.3f [rad]",
1346 ns.
addSolid(nam, Tube(rmin, rmax, dz, startPhi, startPhi + deltaPhi));
1351 void Converter<DDLCutTubs>::operator()(xml_h element)
const {
1353 xml_dim_t
e(element);
1354 string nam = e.nameStr();
1358 double startPhi = ns.
attr<
double>(
e,
DD_CMU(startPhi));
1368 "+ CutTube: dz=%8.3f [cm] rmin=%8.3f [cm] rmax=%8.3f [cm]" 1369 " startPhi=%8.3f [rad] deltaPhi=%8.3f [rad]...",
1375 ns.
addSolid(nam, CutTube(rmin, rmax, dz, startPhi, startPhi + deltaPhi, lx, ly, lz, tx, ty, tz));
1380 void Converter<DDLTruncTubs>::operator()(xml_h element)
const {
1382 xml_dim_t
e(element);
1383 string nam = e.nameStr();
1387 double startPhi = ns.
attr<
double>(
e,
DD_CMU(startPhi));
1389 double cutAtStart = ns.
attr<
double>(
e,
DD_CMU(cutAtStart));
1390 double cutAtDelta = ns.
attr<
double>(
e,
DD_CMU(cutAtDelta));
1391 bool cutInside = ns.
attr<
bool>(
e,
DD_CMU(cutInside));
1394 "+ TruncTube:zHalf=%8.3f [cm] rmin=%8.3f [cm] rmax=%8.3f [cm]" 1395 " startPhi=%8.3f [rad] deltaPhi=%8.3f [rad] atStart=%8.3f [cm] atDelta=%8.3f [cm] inside:%s",
1404 ns.
addSolid(nam, TruncatedTube(zhalf, rmin, rmax, startPhi, deltaPhi, cutAtStart, cutAtDelta, cutInside));
1409 void Converter<DDLEllipticalTube>::operator()(xml_h element)
const {
1411 xml_dim_t
e(element);
1412 string nam = e.nameStr();
1418 "+ EllipticalTube xSemiAxis=%8.3f [cm] ySemiAxis=%8.3f [cm] zHeight=%8.3f [cm]",
1422 ns.
addSolid(nam, EllipticalTube(dx, dy, dz));
1427 void Converter<DDLCone>::operator()(xml_h element)
const {
1429 xml_dim_t
e(element);
1430 string nam = e.nameStr();
1436 double startPhi = ns.
attr<
double>(
e,
DD_CMU(startPhi));
1441 "+ Cone: dz=%8.3f [cm]" 1442 " rmin1=%8.3f [cm] rmax1=%8.3f [cm]" 1443 " rmin2=%8.3f [cm] rmax2=%8.3f [cm]" 1444 " startPhi=%8.3f [rad] deltaPhi=%8.3f [rad]",
1452 ns.
addSolid(nam, ConeSegment(dz, rmin1, rmax1, rmin2, rmax2, startPhi, phi2));
1457 void Converter<DDLShapeless>::operator()(xml_h element)
const {
1459 xml_dim_t
e(element);
1460 string nam = e.nameStr();
1463 "+ Shapeless: THIS ONE CAN ONLY BE USED AT THE VOLUME LEVEL -> Assembly%s",
1470 void Converter<DDLBox>::operator()(xml_h element)
const {
1472 xml_dim_t
e(element);
1473 string nam = e.nameStr();
1479 "+ Box: dx=%10.3f [cm] dy=%10.3f [cm] dz=%10.3f [cm]",
1488 void Converter<include_load>::operator()(xml_h element)
const {
1489 string fname = element.attr<
string>(_U(ref));
1492 doc = xml::DocumentHandler().load(fp.fullPath());
1493 printout(_param<cms::DDParsingContext>()->debug_includes ? ALWAYS :
DEBUG,
1495 "+++ Processing the CMS detector description %s",
1497 _option<DDRegistry>()->
includes.emplace_back(doc);
1502 void Converter<include_unload>::operator()(xml_h element)
const {
1503 string fname = xml::DocumentHandler::system_path(element);
1504 xml::DocumentHolder(xml_elt_t(element).document()).assign(
nullptr);
1505 printout(_param<cms::DDParsingContext>()->debug_includes ? ALWAYS :
DEBUG,
1507 "+++ Finished processing %s",
1513 void Converter<include_constants>::operator()(xml_h element)
const {
1526 const std::map<std::string, DDAxes> axesmap{{
"x",
DDAxes::x},
1536 void Converter<DDLDivision>::operator()(xml_h element)
const {
1538 xml_dim_t
e(element);
1539 string childName = e.nameStr();
1541 childName = ns.
name() + childName;
1545 parentName = ns.
name() + parentName;
1552 int nReplicas = e.hasAttr(
DD_CMU(nReplicas)) ? ns.
attr<
int>(
e,
DD_CMU(nReplicas)) : 0;
1556 "+++ Start executing Division of %s along %s (%d) with offset %6.3f and %6.3f to produce %s....",
1566 const TGeoShape* shape = parent.solid();
1567 TClass*
cl = shape->IsA();
1569 const TGeoTubeSeg* sh = (
const TGeoTubeSeg*)shape;
1572 int numCopies = (
int)((sh->GetPhi2() - sh->GetPhi1()) / widthInDeg);
1575 "+++ ...divide %s along %s (%d) with offset %6.3f deg and %6.3f deg to produce %d copies",
1576 parent.solid().type(),
1582 Volume child = parent.divide(childName, static_cast<int>(axesmap.at(axis)), numCopies, startInDeg, widthInDeg);
1588 "+++ %s Parent: %-24s [%s] Child: %-32s [%s] is multivolume [%s]",
1591 parent.isValid() ?
"VALID" :
"INVALID",
1593 child.isValid() ?
"VALID" :
"INVALID",
1594 child->IsVolumeMulti() ?
"YES" :
"NO");
1597 double dy =
static_cast<const TGeoTrd1*
>(shape)->GetDy();
1600 "+++ ...divide %s along %s (%d) with offset %6.3f cm and %6.3f cm to produce %d copies in %6.3f",
1601 parent.solid().type(),
1604 -dy + offset +
width,
1608 Volume child = parent.divide(childName, static_cast<int>(axesmap.at(axis)), nReplicas, -dy + offset + width, width);
1614 "+++ %s Parent: %-24s [%s] Child: %-32s [%s] is multivolume [%s]",
1617 parent.isValid() ?
"VALID" :
"INVALID",
1619 child.isValid() ?
"VALID" :
"INVALID",
1620 child->IsVolumeMulti() ?
"YES" :
"NO");
1622 printout(
ERROR,
"DD4CMS",
"++ FAILED Division of a %s is not implemented yet!", parent.solid().type());
1628 void Converter<DDLAlgorithm>::operator()(xml_h element)
const {
1630 xml_dim_t
e(element);
1631 string name = e.nameStr();
1635 printout(
INFO,
"DD4CMS",
"+++ Skip disabled algorithms: %s", name.c_str());
1655 "+++ Executed algorithm: %08lX = %s",
1660 printout(
ERROR,
"DD4CMS",
"++ FAILED NOT ADDING SUBDETECTOR %08lX = %s", ret, name.c_str());
1663 template <
class InputIt,
class ForwardIt,
class BinOp>
1665 while (first != last) {
1666 const auto pos = std::find_first_of(first, last, s_first, s_last);
1667 binary_op(first,
pos);
1676 tbb::concurrent_vector<double> splitNumeric(
const string&
str,
const string& delims =
",") {
1677 tbb::concurrent_vector<double>
output;
1685 output.emplace_back(dd4hep::_toDouble(
string(
first,
second)));
1695 void Converter<DDLVector>::operator()(xml_h element)
const {
1699 xml_dim_t
e(element);
1701 string type = ns.
attr<
string>(
e, _U(type));
1702 string nEntries = ns.
attr<
string>(
e,
DD_CMU(nEntries));
1703 string val = e.text();
1704 val.erase(remove_if(val.begin(), val.end(), [](
unsigned char x) {
return isspace(x); }), val.end());
1708 "+++ Vector<%s>: %s[%s]: %s",
1714 tbb::concurrent_vector<double>
results = splitNumeric(val);
1715 registry->insert({
name, results});
1719 void Converter<debug>::operator()(xml_h dbg)
const {
1721 if (dbg.hasChild(
DD_CMU(debug_visattr)))
1723 if (dbg.hasChild(
DD_CMU(debug_constants)))
1725 if (dbg.hasChild(
DD_CMU(debug_materials)))
1727 if (dbg.hasChild(
DD_CMU(debug_rotations)))
1729 if (dbg.hasChild(
DD_CMU(debug_shapes)))
1731 if (dbg.hasChild(
DD_CMU(debug_volumes)))
1733 if (dbg.hasChild(
DD_CMU(debug_placements)))
1735 if (dbg.hasChild(
DD_CMU(debug_namespaces)))
1737 if (dbg.hasChild(
DD_CMU(debug_includes)))
1739 if (dbg.hasChild(
DD_CMU(debug_algorithms)))
1741 if (dbg.hasChild(
DD_CMU(debug_specpars)))
1746 void Converter<DDRegistry>::operator()(xml_h )
const {
1748 DDRegistry*
res = _option<DDRegistry>();
1754 "+++ RESOLVING %ld unknown constants.....",
1755 res->unresolvedConst.size());
1757 while (!res->unresolvedConst.empty()) {
1758 for (
auto i : res->unresolvedConst) {
1759 const string&
n =
i.first;
1761 string&
v =
i.second;
1763 for (idx = v.find(
'[', 0); idx != string::npos; idx = v.find(
'[', idx + 1)) {
1764 idq = v.find(
']', idx + 1);
1765 rep = v.substr(idx + 1, idq - idx - 1);
1766 auto r = res->allConst.find(rep);
1767 if (
r != res->allConst.end()) {
1768 rep =
"(" + (*r).second +
")";
1769 v.replace(idx, idq - idx + 1, rep);
1772 if (v.find(
']') == string::npos) {
1773 if (v.find(
"-+") != string::npos || v.find(
"+-") != string::npos) {
1774 while ((idx = v.find(
"-+")) != string::npos)
1775 v.replace(idx, 2,
"-");
1776 while ((idx = v.find(
"+-")) != string::npos)
1777 v.replace(idx, 2,
"-");
1781 "+++ [%06ld] ---------- %-40s = %s",
1782 res->unresolvedConst.size() - 1,
1784 res->originalConst[
n].c_str());
1785 ns.addConstantNS(n, v,
"number");
1786 res->unresolvedConst.unsafe_erase(n);
1790 if (++count > 10000)
1793 if (!res->unresolvedConst.empty()) {
1794 for (
const auto&
e : res->unresolvedConst)
1795 printout(
ERROR,
"DD4CMS",
"+++ Unresolved constant: %-40s = %s.",
e.first.c_str(),
e.second.c_str());
1796 except(
"DD4CMS",
"++ FAILED to resolve %ld constant entries:", res->unresolvedConst.size());
1798 res->unresolvedConst.clear();
1799 res->originalConst.clear();
1800 res->allConst.clear();
1804 void Converter<print_xml_doc>::operator()(xml_h element)
const {
1805 string fname = xml::DocumentHandler::system_path(element);
1806 printout(_param<cms::DDParsingContext>()->debug_includes ? ALWAYS :
DEBUG,
1808 "+++ Processing data from: %s",
1824 xml_elt_t dddef(element);
1825 string fname = xml::DocumentHandler::system_path(element);
1826 bool open_geometry = dddef.hasChild(
DD_CMU(open_geometry)) ? dddef.child(
DD_CMU(open_geometry)) :
true;
1827 bool close_geometry = dddef.hasChild(
DD_CMU(close_geometry)) ? dddef.hasChild(
DD_CMU(close_geometry)) :
true;
1829 xml_coll_t(dddef, _U(
debug)).for_each(Converter<debug>(det, &context));
1834 printout(
INFO,
"DD4CMS",
"+++ Processing the CMS detector description %s", fname.c_str());
1837 Converter<print_xml_doc> print_doc(det, &context);
1840 print_doc((doc = dddef.document()).
root());
1841 xml_coll_t(dddef,
DD_CMU(DisabledAlgo)).for_each(Converter<disabled_algo>(det, &context, &res));
1842 xml_coll_t(dddef,
DD_CMU(ConstantsSection)).for_each(Converter<ConstantsSection>(det, &context, &res));
1843 xml_coll_t(dddef,
DD_CMU(VisSection)).for_each(Converter<vissection>(det, &context));
1844 xml_coll_t(dddef,
DD_CMU(RotationSection)).for_each(Converter<RotationSection>(det, &context));
1845 xml_coll_t(dddef,
DD_CMU(MaterialSection)).for_each(Converter<MaterialSection>(det, &context));
1847 xml_coll_t(dddef,
DD_CMU(IncludeSection)).for_each(
DD_CMU(Include), Converter<include_load>(det, &context, &res));
1849 for (xml::Document
d : res.includes) {
1850 print_doc((doc = d).
root());
1851 Converter<include_constants>(det, &context, &res)((doc = d).root());
1854 Converter<DDRegistry>(det, &context, &res)(dddef);
1856 for (xml::Document d : res.includes) {
1857 print_doc((doc = d).
root());
1858 xml_coll_t(d.root(),
DD_CMU(MaterialSection)).for_each(Converter<MaterialSection>(det, &context));
1861 printout(context.debug_materials ? ALWAYS :
DEBUG,
1863 "+++ RESOLVING %ld unknown material constituents.....",
1864 context.unresolvedMaterials.size());
1868 while (!context.unresolvedMaterials.empty()) {
1869 for (
auto it = context.unresolvedMaterials.begin(); it != context.unresolvedMaterials.end();) {
1870 auto const&
name = it->first;
1871 std::vector<bool>
valid;
1873 printout(context.debug_materials ? ALWAYS : DEBUG,
1875 "+++ [%06ld] ---------- %s",
1876 context.unresolvedMaterials.size(),
1880 for (
auto& mit : it->second) {
1881 printout(context.debug_materials ? ALWAYS : DEBUG,
1883 "+++ component %-48s Fraction: %.6f",
1887 if (
nullptr != fmat.ptr()) {
1888 if (mat.ptr()->GetMaterial()->IsMixture()) {
1889 valid.emplace_back(
true);
1890 static_cast<TGeoMixture*
>(mat.ptr()->GetMaterial())->AddElement(fmat.ptr()->GetMaterial(), mit.fraction);
1895 if (valid.size() == it->second.size())
1896 it = context.unresolvedMaterials.erase(it);
1904 if (open_geometry) {
1905 context.geo_inited =
true;
1909 for (xml::Document d : res.includes) {
1910 print_doc((doc = d).
root());
1911 xml_coll_t(d.root(),
DD_CMU(RotationSection)).for_each(Converter<RotationSection>(det, &context));
1913 for (xml::Document d : res.includes) {
1914 print_doc((doc = d).
root());
1915 xml_coll_t(d.root(),
DD_CMU(SolidSection)).for_each(Converter<SolidSection>(det, &context));
1917 for (xml::Document d : res.includes) {
1918 print_doc((doc = d).
root());
1919 xml_coll_t(d.root(),
DD_CMU(LogicalPartSection)).for_each(Converter<LogicalPartSection>(det, &context));
1921 for (xml::Document d : res.includes) {
1922 print_doc((doc = d).
root());
1923 xml_coll_t(d.root(),
DD_CMU(
Algorithm)).for_each(Converter<DDLAlgorithm>(det, &context));
1925 for (xml::Document d : res.includes) {
1926 print_doc((doc = d).
root());
1927 xml_coll_t(d.root(),
DD_CMU(PosPartSection)).for_each(Converter<PosPartSection>(det, &context));
1929 for (xml::Document d : res.includes) {
1930 print_doc((doc = d).
root());
1931 xml_coll_t(d.root(),
DD_CMU(SpecParSection)).for_each(Converter<SpecParSection>(det, &context));
1935 for (xml::Document d : res.includes)
1936 Converter<include_unload>(det, &context, &res)(d.root());
1938 print_doc((doc = dddef.document()).
root());
1940 xml_coll_t(dddef,
DD_CMU(SolidSection)).for_each(Converter<SolidSection>(det, &context));
1947 while (!context.unresolvedShapes.empty()) {
1948 for (
auto it = context.unresolvedShapes.begin(); it != context.unresolvedShapes.end();) {
1949 auto const&
name = it->first;
1950 auto const& aname = std::visit([](
auto&&
arg) ->
std::string {
return arg.firstSolidName; }, it->second);
1951 auto const& bname = std::visit([](
auto&&
arg) ->
std::string {
return arg.secondSolidName; }, it->second);
1953 auto const& ait = context.shapes.find(aname);
1954 if (ait->second.isValid()) {
1955 auto const& bit = context.shapes.find(bname);
1956 if (bit->second.isValid()) {
1957 dd4hep::Solid shape = std::visit(
1958 [&ait, &bit](
auto&&
arg) -> dd4hep::Solid {
return arg.make(ait->second, bit->second); }, it->second);
1959 context.shapes[
name] = shape;
1960 it = context.unresolvedShapes.erase(it);
1968 xml_coll_t(dddef,
DD_CMU(LogicalPartSection)).for_each(Converter<LogicalPartSection>(det, &context));
1969 xml_coll_t(dddef,
DD_CMU(
Algorithm)).for_each(Converter<DDLAlgorithm>(det, &context));
1970 xml_coll_t(dddef,
DD_CMU(PosPartSection)).for_each(Converter<PosPartSection>(det, &context));
1971 xml_coll_t(dddef,
DD_CMU(SpecParSection)).for_each(Converter<SpecParSection>(det, &context));
1973 printout(
ERROR,
"DD4CMS",
"Exception while processing xml source:%s", doc.uri().c_str());
1974 printout(
ERROR,
"DD4CMS",
"----> %s", e.what());
1979 if (close_geometry) {
1980 Volume wv = det.worldVolume();
1982 if (geomv.isValid())
1983 wv.placeVolume(geomv, 1);
1984 Volume mfv = ns.
volume(
"cmsMagneticField:MAGF",
false);
1986 wv.placeVolume(mfv, 1);
1987 Volume mfv1 = ns.
volume(
"MagneticFieldVolumes:MAGF",
false);
1989 wv.placeVolume(mfv1, 1);
1993 printout(
INFO,
"DDDefinition",
"+++ Finished processing %s", fname.c_str());
DDLPosPart handles PosPart elements.
dd4hep::Volume volume(const std::string &name, bool exc=true) const
DDLSphere processes all Sphere elements.
tbb::concurrent_vector< xml::Document > includes
tbb::concurrent_unordered_map< std::string, std::string > allConst
DDLDivision processes Division elements.
ROOT::Math::Plane3D::Vector Vector
DDLVector handles Rotation and ReflectionRotation elements.
ret
prodAgent to be discontinued
tbb::concurrent_unordered_map< std::string, std::string > originalConst
constexpr NumType convertRadToDeg(NumType radians)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >> Translation
Geom::Theta< T > theta() const
tbb::concurrent_vector< std::string > disabledAlgs
DDLEllipticalTube processes all EllipticalTube elements.
dd4hep::Volume addVolume(dd4hep::Volume vol) const
Add rotation matrix to current namespace.
TGeoCombiTrans * createPlacement(const Rotation3D &iRot, const Position &iTrans)
dd4hep::Solid solid(const std::string &name) const
std::map< std::string, std::vector< CompositeMaterial > > unresolvedMaterials
std::atomic< dd4hep::Detector * > description
DDLAlgorithm processes Algorithm elements.
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
dd4hep::Rotation3D makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
DDParsingContext *const context() const
std::string_view name() const
U second(std::pair< T, U > const &p)
void addConstantNS(const std::string &name, const std::string &value, const std::string &type) const
DDLBox processes Box elements.
DDLElementaryMaterial processes ElementaryMaterial elements.
std::string realName(const std::string &) const
static constexpr long s_executed
T attr(xml_elt_t element, const xml_tag_t &name) const
DDLCone processes all Cone elements.
dd4hep::PlacedVolume PlacedVolume
dd4hep::Rotation3D makeRotReflect(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
tbb::concurrent_unordered_map< std::string, tbb::concurrent_vector< double >> DDVectorsMap
dd4hep::Material material(const std::string &name) const
tbb::concurrent_unordered_map< std::string, dd4hep::Volume > volumes
constexpr unsigned int hash(const char *str, int h=0)
static void convert_boolean(cms::DDParsingContext *context, xml_h element)
std::string prepend(const std::string &) const
Namespace of DDCMS conversion namespace.
DDLTubs processes Tubs elements.
std::map< std::string, std::variant< BooleanShape< dd4hep::UnionSolid >, BooleanShape< dd4hep::SubtractionSolid >, BooleanShape< dd4hep::IntersectionSolid > > > unresolvedShapes
dd4hep::Solid addSolid(const std::string &name, dd4hep::Solid solid) const
DDLLogicalPart processes LogicalPart elements.
tbb::concurrent_unordered_map< std::string, dd4hep::Solid > shapes
DDLRotationByAxis handles RotationByAxis elements.
DDLCompositeMaterial processes all CompositeMaterial elements.
const dd4hep::Rotation3D & rotation(const std::string &name) const
static long load_dddefinition(Detector &det, xml_h element)
Converter for <DDDefinition> tags.
DDAxes
analagous to geant4/source/global/HEPGeometry/include/geomdefs.hh
alpha
zGenParticlesMatch = cms.InputTag(""),
tbb::concurrent_unordered_map< std::string, std::string > unresolvedConst
DDLRotationSequence handles a set of Rotations.
void addConstant(const std::string &name, const std::string &value, const std::string &type) const
void for_each_token(InputIt first, InputIt last, ForwardIt s_first, ForwardIt s_last, BinOp binary_op)
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
DDParsingContext * setContext()