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" 11 #include "XML/Utilities.h" 20 #include "TGeoManager.h" 21 #include "TGeoMaterial.h" 28 #include "tbb/concurrent_unordered_map.h" 29 #include "tbb/concurrent_vector.h" 40 atomic<UInt_t> unique_mat_id = 0xAFFEFEED;
43 class include_constants;
48 class ConstantsSection;
51 tbb::concurrent_vector<xml::Document>
includes;
55 class MaterialSection;
59 class RotationSection;
61 class DDLReflectionRotation;
70 class LogicalPartSection;
74 class DDLExtrudedPolygon;
91 class DDLIntersectionSolid;
92 class DDLSubtractionSolid;
108 template <>
void Converter<debug>::operator()(xml_h element)
const;
109 template <>
void Converter<print_xml_doc>::operator()(xml_h element)
const;
110 template <>
void Converter<disabled_algo>::operator()(xml_h element)
const;
113 template <>
void Converter<ConstantsSection>::operator()(xml_h element)
const;
114 template <>
void Converter<DDLConstant>::operator()(xml_h element)
const;
115 template <>
void Converter<DDRegistry>::operator()(xml_h element)
const;
118 template <>
void Converter<vissection>::operator()(xml_h element)
const;
120 template <>
void Converter<vis>::operator()(xml_h element)
const;
123 template <>
void Converter<MaterialSection>::operator()(xml_h element)
const;
124 template <>
void Converter<DDLElementaryMaterial>::operator()(xml_h element)
const;
125 template <>
void Converter<DDLCompositeMaterial>::operator()(xml_h element)
const;
128 template <>
void Converter<RotationSection>::operator()(xml_h element)
const;
130 template <>
void Converter<DDLRotation>::operator()(xml_h element)
const;
132 template <>
void Converter<DDLReflectionRotation>::operator()(xml_h element)
const;
134 template <>
void Converter<DDLRotationSequence>::operator()(xml_h element)
const;
136 template <>
void Converter<DDLRotationByAxis>::operator()(xml_h element)
const;
137 template <>
void Converter<DDLTransform3D>::operator()(xml_h element)
const;
140 template <>
void Converter<LogicalPartSection>::operator()(xml_h element)
const;
141 template <>
void Converter<DDLLogicalPart>::operator()(xml_h element)
const;
144 template <>
void Converter<PosPartSection>::operator()(xml_h element)
const;
146 template <>
void Converter<DDLPosPart>::operator()(xml_h element)
const;
148 template <>
void Converter<DDLDivision>::operator()(xml_h element)
const;
151 template <>
void Converter<SpecParSection>::operator()(xml_h element)
const;
152 template <>
void Converter<SpecPar>::operator()(xml_h element)
const;
153 template <>
void Converter<PartSelector>::operator()(xml_h element)
const;
154 template <>
void Converter<Parameter>::operator()(xml_h element)
const;
157 template <>
void Converter<SolidSection>::operator()(xml_h element)
const;
159 template <>
void Converter<DDLUnionSolid>::operator()(xml_h element)
const;
161 template <>
void Converter<DDLSubtractionSolid>::operator()(xml_h element)
const;
163 template <>
void Converter<DDLIntersectionSolid>::operator()(xml_h element)
const;
165 template <>
void Converter<DDLPseudoTrap>::operator()(xml_h element)
const;
167 template <>
void Converter<DDLExtrudedPolygon>::operator()(xml_h element)
const;
169 template <>
void Converter<DDLShapeless>::operator()(xml_h element)
const;
171 template <>
void Converter<DDLTrapezoid>::operator()(xml_h element)
const;
173 template <>
void Converter<DDLPolycone>::operator()(xml_h element)
const;
175 template <>
void Converter<DDLPolyhedra>::operator()(xml_h element)
const;
177 template <>
void Converter<DDLEllipticalTube>::operator()(xml_h element)
const;
179 template <>
void Converter<DDLTorus>::operator()(xml_h element)
const;
181 template <>
void Converter<DDLTubs>::operator()(xml_h element)
const;
183 template <>
void Converter<DDLCutTubs>::operator()(xml_h element)
const;
185 template <>
void Converter<DDLTruncTubs>::operator()(xml_h element)
const;
187 template <>
void Converter<DDLSphere>::operator()(xml_h element)
const;
189 template <>
void Converter<DDLTrd1>::operator()(xml_h element)
const;
191 template <>
void Converter<DDLTrd2>::operator()(xml_h element)
const;
193 template <>
void Converter<DDLCone>::operator()(xml_h element)
const;
195 template <>
void Converter<DDLBox>::operator()(xml_h element)
const;
197 template <>
void Converter<DDLAlgorithm>::operator()(xml_h element)
const;
199 template <>
void Converter<DDLVector>::operator()(xml_h element)
const;
202 template <>
void Converter<include_load>::operator()(xml_h element)
const;
204 template <>
void Converter<include_unload>::operator()(xml_h element)
const;
206 template <>
void Converter<include_constants>::operator()(xml_h element)
const;
210 template <>
void Converter<ConstantsSection>::operator()( xml_h element )
const {
218 template <>
void Converter<vissection>::operator()(xml_h element)
const {
224 template <>
void Converter<MaterialSection>::operator()(xml_h element)
const {
226 xml_coll_t( element,
DD_CMU(ElementaryMaterial)).for_each(Converter<DDLElementaryMaterial>(
description,ns.context(),optional));
227 xml_coll_t( element,
DD_CMU(CompositeMaterial)).for_each(Converter<DDLCompositeMaterial>(
description,ns.context(),optional));
230 template <>
void Converter<RotationSection>::operator()(xml_h element)
const {
232 xml_coll_t( element,
DD_CMU(Rotation)).for_each(Converter<DDLRotation>(
description,ns.context(),optional));
233 xml_coll_t( element,
DD_CMU(ReflectionRotation)).for_each(Converter<DDLReflectionRotation>(
description,ns.context(),optional));
234 xml_coll_t( element,
DD_CMU(RotationSequence)).for_each(Converter<DDLRotationSequence>(
description,ns.context(),optional));
235 xml_coll_t( element,
DD_CMU(RotationByAxis)).for_each(Converter<DDLRotationByAxis>(
description,ns.context(),optional));
238 template <>
void Converter<PosPartSection>::operator()( xml_h element )
const {
240 xml_coll_t( element,
DD_CMU( Division )).for_each( Converter<DDLDivision>(
description, ns.context(), optional ));
241 xml_coll_t( element,
DD_CMU( PosPart )).for_each( Converter<DDLPosPart>(
description, ns.context(), optional ));
245 template <>
void Converter<SpecParSection>::operator()( xml_h element )
const {
247 xml_coll_t( element,
DD_CMU( SpecPar )).for_each( Converter<SpecPar>(
description, ns.context(), optional ));
250 template <>
void Converter<SpecPar>::operator()( xml_h element )
const {
252 xml_coll_t( element,
DD_CMU( PartSelector )).for_each( Converter<PartSelector>(
description, ns.context(), optional ));
253 xml_coll_t( element,
DD_CMU( Parameter )).for_each( Converter<Parameter>(
description, ns.context(), optional ));
257 template <>
void Converter<LogicalPartSection>::operator()(xml_h element)
const {
259 xml_coll_t( element,
DD_CMU(LogicalPart)).for_each(Converter<DDLLogicalPart>(
description,ns.context(),optional));
262 template <>
void Converter<disabled_algo>::operator()(xml_h element)
const {
268 template <>
void Converter<SolidSection>::operator()(xml_h element)
const {
270 for(xml_coll_t solid(element, _U(star)); solid; ++solid) {
271 string tag = solid.tag();
273 switch(
hash( solid.tag()))
278 case hash(
"Polycone"):
279 Converter<DDLPolycone>(
description,ns.context(),optional)(solid);
281 case hash(
"Polyhedra"):
282 Converter<DDLPolyhedra>(
description,ns.context(),optional)(solid);
287 case hash(
"CutTubs"):
288 Converter<DDLCutTubs>(
description,ns.context(),optional)(solid);
290 case hash(
"TruncTubs"):
291 Converter<DDLTruncTubs>(
description,ns.context(),optional)(solid);
297 Converter<DDLTrd1>(
description,ns.context(),optional)(solid);
300 Converter<DDLTrd2>(
description,ns.context(),optional)(solid);
308 case hash(
"EllipticalTube"):
314 case hash(
"PseudoTrap"):
317 case hash(
"ExtrudedPolygon"):
318 Converter<DDLExtrudedPolygon>(
description,ns.context(),optional)(solid);
320 case hash(
"Trapezoid"):
323 case hash(
"UnionSolid"):
324 Converter<DDLUnionSolid>(
description,ns.context(),optional)(solid);
326 case hash(
"SubtractionSolid"):
327 Converter<DDLSubtractionSolid>(
description,ns.context(),optional)(solid);
329 case hash(
"IntersectionSolid"):
330 Converter<DDLIntersectionSolid>(
description,ns.context(),optional)(solid);
332 case hash(
"ShapelessSolid"):
333 Converter<DDLShapeless>(
description,ns.context(),optional)(solid);
336 throw std::runtime_error(
"Request to process unknown shape '" + xml_dim_t(solid).nameStr() +
"' [" + tag +
"]");
343 template <>
void Converter<DDLConstant>::operator()(xml_h element)
const {
345 DDRegistry*
res = _option<DDRegistry>();
346 xml_dim_t constant = element;
347 xml_dim_t par = constant.parent();
348 bool eval = par.hasAttr(_U(eval)) ? par.attr<
bool>(_U(eval)) :
false;
349 string val = constant.valueStr();
350 string nam = constant.nameStr();
351 string real = ns.prepend(nam);
352 string typ = eval ?
"number" :
"string";
353 size_t idx = val.find(
'[');
355 if( constant.hasAttr(_U(
type)) )
356 typ = constant.typeStr();
358 if( idx == string::npos || typ ==
"string" ) {
360 ns.addConstant( nam, val, typ );
361 res->allConst[real] =
val;
362 res->originalConst[real] =
val;
365 printout(
INFO,
"DD4CMS",
"++ Unresolved constant: %s = %s [%s]. Try to resolve later. [%s]",
366 real.c_str(), val.c_str(), typ.c_str(), e.what());
371 while ( idx != string::npos ) {
373 size_t idp = val.find(
':',idx);
374 size_t idq = val.find(
']',idx);
375 if( idp == string::npos || idp > idq )
376 val.insert(idx,ns.name());
377 else if( idp != string::npos && idp < idq )
379 idx = val.find(
'[',idx);
381 printout(ns.context()->debug_constants ? ALWAYS :
DEBUG,
382 "Constant",
"Unresolved: %s -> %s",real.c_str(),val.c_str());
383 res->allConst[real] =
val;
384 res->originalConst[real] =
val;
385 res->unresolvedConst[real] =
val;
396 template <>
void Converter<vis>::operator()(xml_h e)
const {
398 VisAttr attr(e.attr<
string>(_U(
name)));
399 float red = e.hasAttr(_U(
r)) ? e.attr<
float>(_U(
r)) : 1.0
f;
400 float green = e.hasAttr(_U(
g)) ? e.attr<
float>(_U(
g)) : 1.0
f;
401 float blue = e.hasAttr(_U(
b)) ? e.attr<
float>(_U(
b)) : 1.0
f;
403 printout(ns.context()->debug_visattr ? ALWAYS :
DEBUG,
"Compact",
404 "++ Converting VisAttr structure: %-16s. R=%.3f G=%.3f B=%.3f",
406 attr.setColor(red, green, blue);
407 if(e.hasAttr(_U(
alpha)))
408 attr.setAlpha(e.attr<
float>(_U(
alpha)));
409 if(e.hasAttr(_U(visible)))
410 attr.setVisible(e.attr<
bool>(_U(visible)));
414 attr.setLineStyle(VisAttr::SOLID);
415 else if(ls ==
"broken")
416 attr.setLineStyle(VisAttr::DASHED);
419 attr.setLineStyle(VisAttr::SOLID);
421 if(e.hasAttr(_U(drawingStyle))) {
422 string ds = e.attr<
string>(_U(drawingStyle));
423 if(ds ==
"wireframe")
424 attr.setDrawingStyle(VisAttr::WIREFRAME);
425 else if(ds ==
"solid")
426 attr.setDrawingStyle(VisAttr::SOLID);
429 attr.setDrawingStyle(VisAttr::SOLID);
431 if(e.hasAttr(_U(showDaughters)))
432 attr.setShowDaughters(e.attr<
bool>(_U(showDaughters)));
434 attr.setShowDaughters(
true);
439 template <>
void Converter<DDLElementaryMaterial>::operator()(xml_h element)
const {
441 xml_dim_t xmat( element);
442 string nam = ns.prepend(xmat.nameStr());
444 TGeoMaterial* mat = mgr.GetMaterial(nam.c_str());
445 if(
nullptr == mat ) {
446 const char* matname = nam.c_str();
447 double density = xmat.density();
448 double atomicNumber = xmat.attr<
double>(
DD_CMU(atomicNumber));
449 TGeoElementTable* tab = mgr.GetElementTable();
450 TGeoMixture*
mix =
new TGeoMixture(nam.c_str(), 1, density);
451 TGeoElement* elt = tab->FindElement(xmat.nameStr().c_str());
453 printout(ns.context()->debug_materials ? ALWAYS :
DEBUG,
"DD4CMS",
454 "+++ Converting material %-48s Density: %.3f.",
455 (
'"'+nam+
'"').c_str(), density);
459 "+++ Converter<ElementaryMaterial> No element present with name:%s [FAKE IT]",
461 int n =
int(atomicNumber/2e0);
463 elt =
new TGeoElement(xmat.nameStr().c_str(),
"CMS element",
n,atomicNumber);
465 if( elt->Z() == 0 ) {
466 int n =
int(atomicNumber/2e0);
468 elt =
new TGeoElement((xmat.nameStr()+
"-CMS").c_str(),
"CMS element",
n,atomicNumber);
470 mix->AddElement(elt, 1.0);
473 TGeoMedium* medium = mgr.GetMedium(matname);
474 if(
nullptr == medium) {
476 medium =
new TGeoMedium(matname, unique_mat_id, mix);
477 medium->SetTitle(
"material");
478 medium->SetUniqueID(unique_mat_id);
484 template <>
void Converter<DDLCompositeMaterial>::operator()(xml_h element)
const {
486 xml_dim_t xmat( element);
487 string nam = ns.prepend(xmat.nameStr());
489 TGeoMaterial* mat = mgr.GetMaterial(nam.c_str());
490 if(
nullptr == mat ) {
491 const char* matname = nam.c_str();
492 double density = xmat.density();
493 xml_coll_t composites(xmat,
DD_CMU(MaterialFraction));
494 TGeoMixture* mix =
new TGeoMixture(nam.c_str(), composites.size(), density);
496 printout(ns.context()->debug_materials ? ALWAYS :
DEBUG,
"DD4CMS",
497 "++ Converting material %-48s Density: %.3f.",
498 (
'"'+nam+
'"').c_str(), density);
500 for( composites.reset(); composites; ++composites ) {
501 xml_dim_t xfrac(composites);
502 xml_dim_t xfrac_mat(xfrac.child(
DD_CMU(rMaterial)));
504 string fracname = ns.realName(xfrac_mat.nameStr());
506 TGeoMaterial* frac_mat = mgr.GetMaterial(fracname.c_str());
508 mix->AddElement(frac_mat, fraction);
511 printout(
WARNING,
"DD4CMS",
"+++ Composite material \"%s\" not present!",
516 TGeoMedium* medium = mgr.GetMedium(matname);
517 if(
nullptr == medium ) {
519 medium =
new TGeoMedium(matname, unique_mat_id, mix);
520 medium->SetTitle(
"material");
521 medium->SetUniqueID(unique_mat_id);
527 template <>
void Converter<DDLRotation>::operator()(xml_h element)
const {
530 xml_dim_t xrot( element);
531 string nam = xrot.nameStr();
532 double thetaX = xrot.hasAttr(
DD_CMU(thetaX)) ? ns.attr<
double>(xrot,
DD_CMU(thetaX)) : 0e0;
533 double phiX = xrot.hasAttr(
DD_CMU(phiX)) ? ns.attr<
double>(xrot,
DD_CMU(phiX)) : 0e0;
534 double thetaY = xrot.hasAttr(
DD_CMU(thetaY)) ? ns.attr<
double>(xrot,
DD_CMU(thetaY)) : 0e0;
535 double phiY = xrot.hasAttr(
DD_CMU(phiY)) ? ns.attr<
double>(xrot,
DD_CMU(phiY)) : 0e0;
536 double thetaZ = xrot.hasAttr(
DD_CMU(thetaZ)) ? ns.attr<
double>(xrot,
DD_CMU(thetaZ)) : 0e0;
537 double phiZ = xrot.hasAttr(
DD_CMU(phiZ)) ? ns.attr<
double>(xrot,
DD_CMU(phiZ)) : 0e0;
540 "DD4CMS",
"+++ Adding rotation: %-32s: (theta/phi)[rad] X: %6.3f %6.3f Y: %6.3f %6.3f Z: %6.3f %6.3f",
542 ns.addRotation(nam, rot);
546 template <>
void Converter<DDLReflectionRotation>::operator()( xml_h element )
const {
549 xml_dim_t xrot( element );
550 string name = xrot.nameStr();
551 double thetaX = xrot.hasAttr(
DD_CMU( thetaX )) ? ns.attr<
double>( xrot,
DD_CMU( thetaX )) : 0e0;
552 double phiX = xrot.hasAttr(
DD_CMU( phiX )) ? ns.attr<
double>( xrot,
DD_CMU( phiX )) : 0e0;
553 double thetaY = xrot.hasAttr(
DD_CMU( thetaY )) ? ns.attr<
double>( xrot,
DD_CMU( thetaY )) : 0e0;
554 double phiY = xrot.hasAttr(
DD_CMU( phiY )) ? ns.attr<
double>( xrot,
DD_CMU( phiY )) : 0e0;
555 double thetaZ = xrot.hasAttr(
DD_CMU( thetaZ )) ? ns.attr<
double>( xrot,
DD_CMU( thetaZ )) : 0e0;
556 double phiZ = xrot.hasAttr(
DD_CMU( phiZ )) ? ns.attr<
double>( xrot,
DD_CMU( phiZ )) : 0e0;
558 "DD4CMS",
"+++ Adding reflection rotation: %-32s: (theta/phi)[rad] X: %6.3f %6.3f Y: %6.3f %6.3f Z: %6.3f %6.3f",
560 Rotation3D rot =
makeRotReflect( thetaX, phiX, thetaY, phiY, thetaZ, phiZ );
561 ns.addRotation( name, rot );
565 template <>
void Converter<DDLRotationSequence>::operator()(xml_h element)
const {
568 xml_dim_t xrot( element);
569 string nam = xrot.nameStr();
571 xml_coll_t rotations(xrot,
DD_CMU(RotationByAxis));
572 for( rotations.reset(); rotations; ++rotations ) {
573 string axis = ns.attr<
string>(rotations,
DD_CMU(axis));
574 double angle = ns.attr<
double>(rotations,_U(angle));
577 "DD4CMS",
"+ Adding rotation to: %-29s: (axis/angle)[rad] Axis: %s Angle: %6.3f",
578 nam.c_str(), axis.c_str(),
angle);
583 rot.GetComponents(xx,xy,xz,yx,yy,yz,zx,zy,zz);
585 "DD4CMS",
"+++ Adding rotation sequence: %-23s: %6.3f %6.3f %6.3f, %6.3f %6.3f %6.3f, %6.3f %6.3f %6.3f",
586 ns.prepend(nam).c_str(),
xx,
xy,
xz, yx,
yy,
yz, zx, zy,
zz);
587 ns.addRotation(nam, rot);
591 template <>
void Converter<DDLRotationByAxis>::operator()(xml_h element)
const {
594 xml_dim_t xrot( element);
595 xml_dim_t par(xrot.parent());
596 if( xrot.hasAttr(_U(name))) {
597 string nam = xrot.nameStr();
598 string axis = ns.attr<
string>(xrot,
DD_CMU(axis));
599 double angle = ns.attr<
double>(xrot,_U(angle));
603 "DD4CMS",
"+++ Adding rotation: %-32s: (axis/angle)[rad] Axis: %s Angle: %6.3f",
604 ns.prepend(nam).c_str(), axis.c_str(),
angle);
605 ns.addRotation(nam, rot);
610 template <>
void Converter<DDLLogicalPart>::operator()(xml_h element)
const {
612 xml_dim_t
e(element);
613 string sol = e.child(
DD_CMU(rSolid)).attr<
string>(_U(name));
614 string mat = e.child(
DD_CMU(rMaterial)).attr<
string>(_U(name));
615 ns.addVolume(
Volume(e.nameStr(), ns.solid(sol), ns.material(mat)));
619 template <>
void Converter<DDLTransform3D>::operator()( xml_h element )
const {
621 Transform3D* tr = _option<Transform3D>();
622 xml_dim_t
e(element);
623 xml_dim_t translation = e.child(
DD_CMU( Translation ),
false );
625 xml_dim_t refRotation = e.child(
DD_CMU( rRotation ),
false );
629 if( translation.ptr()) {
630 double x = ns.attr<
double>( translation, _U( x ));
631 double y = ns.attr<
double>( translation, _U( y ));
632 double z = ns.attr<
double>( translation, _U( z ));
633 pos = Position(x,y,z);
635 if( rotation.ptr()) {
636 double x = ns.attr<
double>(
rotation, _U( x ));
637 double y = ns.attr<
double>(
rotation, _U( y ));
638 double z = ns.attr<
double>(
rotation, _U( z ));
639 rot = RotationZYX(z,y,x);
641 else if( refRotation.ptr()) {
642 string rotName = refRotation.nameStr();
644 rotName = ns.name() + rotName;
646 rot = ns.rotation( rotName );
648 *tr = Transform3D( rot, pos );
652 template <>
void Converter<DDLPosPart>::operator()( xml_h element )
const {
654 xml_dim_t
e( element );
655 int copy = e.attr<
int>(
DD_CMU( copyNumber ));
656 string parentName = ns.attr<
string>( e.child(
DD_CMU( rParent )), _U( name ));
657 string childName = ns.attr<
string>( e.child(
DD_CMU( rChild )), _U( name ));
660 parentName = ns.name() + parentName;
664 childName = ns.name() + childName;
667 printout( ns.context()->debug_placements ? ALWAYS :
DEBUG,
"DD4CMS",
668 "+++ %s Parent: %-24s [%s] Child: %-32s [%s] copy:%d",
670 parentName.c_str(), parent.isValid() ?
"VALID" :
"INVALID",
671 childName.c_str(), child.isValid() ?
"VALID" :
"INVALID",
675 if( child.isValid()) {
678 pv = parent.placeVolume( child, copy, transform );
681 printout(
ERROR,
"DD4CMS",
"+++ Placement FAILED! Parent:%s Child:%s Valid:%s",
682 parent.name(), childName.c_str(), yes_no( child.isValid()));
687 template <>
void Converter<PartSelector>::operator()(xml_h element)
const {
691 xml_dim_t
e(element);
692 xml_dim_t specPar = e.parent();
693 string specParName = specPar.attr<
string>(_U(name));
695 printout(ns.context()->debug_specpars ? ALWAYS :
DEBUG,
"DD4CMS",
696 "+++ PartSelector for %s path: %s", specParName.c_str(), path.c_str());
697 registry.
specpars[specParName].paths.emplace_back(path);
701 template <>
void Converter<Parameter>::operator()(xml_h element)
const {
705 xml_dim_t
e(element);
706 xml_dim_t specPar = e.parent();
707 xml_dim_t specParSect = specPar.parent();
708 string specParName = specPar.attr<
string>(_U(name));
709 string name = e.nameStr();
711 bool eval = e.hasAttr(_U(eval)) ? e.attr<
bool>(_U(eval)) : (specParSect.hasAttr(_U(eval)) ? specParSect.attr<
bool>(_U(eval)) :
false);
712 string type = eval ?
"number" :
"string";
714 printout(ns.context()->debug_specpars ? ALWAYS :
DEBUG,
"DD4CMS",
715 "+++ Parameter for %s: %s value %s is a %s", specParName.c_str(), name.c_str(), value.c_str(), type.c_str());
717 size_t idx = value.find(
'[');
718 if(idx == string::npos || type ==
"string") {
719 registry.
specpars[specParName].spars[
name].emplace_back(value);
723 while(idx != string::npos) {
725 size_t idp = value.find(
':', idx);
726 size_t idq = value.find(
']', idx);
727 if(idp == string::npos || idp > idq)
728 value.insert(idx, ns.name());
729 else if(idp != string::npos && idp < idq)
731 idx = value.find(
'[',idx);
737 for(idx = v.find(
'[', 0); idx != string::npos; idx = v.find(
'[', idx + 1)) {
738 idq = v.find(
']', idx + 1);
739 rep = v.substr(idx + 1, idq - idx - 1);
740 auto r = ns.context()->description.load()->constants().find(rep);
741 if(
r != ns.context()->description.load()->constants().end()) {
742 rep =
"(" +
r->second->type +
")";
743 v.replace(idx, idq - idx + 1, rep);
746 registry.
specpars[specParName].numpars[
name].emplace_back(_toDouble(value));
749 template <
typename TYPE>
752 xml_dim_t
e(element);
753 string nam = e.nameStr();
758 if( e.hasChild(
DD_CMU(rSolid)) ) {
759 for(xml_coll_t
c(element,
DD_CMU(rSolid)); cnt<2 &&
c; ++
c, ++cnt)
760 solids[cnt] = ns.
solid(c.attr<
string>(_U(name)));
763 if( (solids[0] = ns.
solid(e.attr<
string>(
DD_CMU(firstSolid)))).isValid() ) ++cnt;
764 if( (solids[1] = ns.
solid(e.attr<
string>(
DD_CMU(secondSolid)))).isValid() ) ++cnt;
767 except(
"DD4CMS",
"+++ Failed to create boolean solid %s. Found only %d parts.",nam.c_str(), cnt);
770 "+++ BooleanSolid: %s Left: %-32s Right: %-32s",
771 nam.c_str(), solids[0]->GetName(), solids[1]->GetName());
773 if( solids[0].isValid() && solids[1].isValid() ) {
775 Converter<DDLTransform3D>(*context->
description,context,&trafo)(element);
776 boolean = TYPE(solids[0],solids[1],trafo);
778 if( !
boolean.isValid() )
779 except(
"DD4CMS",
"+++ FAILED to construct subtraction solid: %s",nam.c_str());
784 template <>
void Converter<DDLUnionSolid>::operator()(xml_h element)
const {
785 convert_boolean<UnionSolid>(_param<cms::DDParsingContext>(),element);
789 template <>
void Converter<DDLSubtractionSolid>::operator()(xml_h element)
const {
790 convert_boolean<SubtractionSolid>(_param<cms::DDParsingContext>(),element);
794 template <>
void Converter<DDLIntersectionSolid>::operator()(xml_h element)
const {
795 convert_boolean<IntersectionSolid>(_param<cms::DDParsingContext>(),element);
799 template <>
void Converter<DDLPolycone>::operator()(xml_h element)
const {
801 xml_dim_t
e(element);
802 string nam = e.nameStr();
803 double startPhi = ns.
attr<
double>(
e,
DD_CMU(startPhi));
805 vector<double>
z, rmin, rmax,
r;
807 for(xml_coll_t rzpoint( element,
DD_CMU(RZPoint)); rzpoint; ++rzpoint) {
808 z.emplace_back(ns.
attr<
double>(rzpoint,_U(z)));
809 r.emplace_back(ns.
attr<
double>(rzpoint,_U(r)));
812 for(xml_coll_t zplane(element,
DD_CMU(ZSection)); zplane; ++zplane) {
815 z.emplace_back(ns.
attr<
double>(zplane,_U(z)));
818 "+ Polycone: startPhi=%10.3f [rad] deltaPhi=%10.3f [rad] %4ld z-planes",
820 ns.
addSolid(nam, Polycone(startPhi,deltaPhi,rmin,rmax,z));
824 "+ Polycone: startPhi=%10.3f [rad] deltaPhi=%10.3f [rad] %4ld z-planes and %4ld radii",
825 startPhi,
deltaPhi, z.size(), r.size());
826 ns.
addSolid(nam, Polycone(startPhi,deltaPhi,r,z));
831 template <>
void Converter<DDLExtrudedPolygon>::operator()(xml_h element)
const {
833 xml_dim_t
e(element);
834 string nam = e.nameStr();
835 vector<double> pt_x, pt_y, sec_x, sec_y, sec_z, sec_scale;
837 for(xml_coll_t sec(element,
DD_CMU(ZXYSection)); sec; ++sec) {
838 sec_z.emplace_back(ns.
attr<
double>(sec,_U(
z)));
839 sec_x.emplace_back(ns.
attr<
double>(sec,_U(
x)));
840 sec_y.emplace_back(ns.
attr<
double>(sec,_U(
y)));
843 for(xml_coll_t
pt( element,
DD_CMU(XYPoint));
pt; ++
pt) {
844 pt_x.emplace_back(ns.
attr<
double>(
pt,_U(
x)));
845 pt_y.emplace_back(ns.
attr<
double>(
pt,_U(
y)));
848 "+ ExtrudedPolygon: %4ld points %4ld zxy sections",
849 pt_x.size(), sec_z.size());
854 template <>
void Converter<DDLPolyhedra>::operator()(xml_h element)
const {
856 xml_dim_t
e(element);
857 string nam = e.nameStr();
858 double numSide = ns.
attr<
int>(
e,
DD_CMU(numSide));
859 double startPhi = ns.
attr<
double>(
e,
DD_CMU(startPhi));
861 vector<double>
z, rmin, rmax;
863 for(xml_coll_t zplane(element,
DD_CMU(RZPoint)); zplane; ++zplane) {
864 rmin.emplace_back(0.0);
865 rmax.emplace_back(ns.
attr<
double>(zplane,_U(
r)));
866 z.emplace_back(ns.
attr<
double>(zplane,_U(z)));
868 for(xml_coll_t zplane(element,
DD_CMU(ZSection)); zplane; ++zplane) {
871 z.emplace_back(ns.
attr<
double>(zplane,_U(z)));
874 "+ Polyhedra:startPhi=%8.3f [rad] deltaPhi=%8.3f [rad] %4d sides %4ld z-planes",
875 startPhi,
deltaPhi, numSide, z.size());
880 template <>
void Converter<DDLSphere>::operator()(xml_h element)
const {
882 xml_dim_t
e(element);
883 string nam = e.nameStr();
886 double startPhi = ns.
attr<
double>(
e,
DD_CMU(startPhi));
888 double startTheta = ns.
attr<
double>(
e,
DD_CMU(startTheta));
889 double deltaTheta = ns.
attr<
double>(
e,
DD_CMU(deltaTheta));
891 "+ Sphere: r_inner=%8.3f [cm] r_outer=%8.3f [cm]" 892 " startPhi=%8.3f [rad] deltaPhi=%8.3f startTheta=%8.3f delteTheta=%8.3f [rad]",
893 rinner, router, startPhi,
deltaPhi, startTheta, deltaTheta);
894 ns.
addSolid(nam, Sphere(rinner, router, startTheta, deltaTheta, startPhi, deltaPhi));
898 template <>
void Converter<DDLTorus>::operator()(xml_h element)
const {
900 xml_dim_t
e(element);
901 string nam = e.nameStr();
905 double startPhi = ns.
attr<
double>(
e,
DD_CMU(startPhi));
908 "+ Torus: r=%10.3f [cm] r_inner=%10.3f [cm] r_outer=%10.3f [cm]" 909 " startPhi=%10.3f [rad] deltaPhi=%10.3f [rad]",
911 ns.
addSolid(nam, Torus(r, rinner, router, startPhi, deltaPhi));
915 template <>
void Converter<DDLPseudoTrap>::operator()(xml_h element)
const {
917 xml_dim_t
e(element);
918 string nam = e.nameStr();
923 double dz = ns.
attr<
double>(
e,_U(dz));
925 bool atMinusZ = ns.
attr<
bool> (
e,
DD_CMU(atMinusZ));
927 "+ Pseudotrap: dz=%8.3f [cm] dx1:%.3f dy1:%.3f dx2=%.3f dy2=%.3f radius:%.3f atMinusZ:%s",
928 dz, dx1, dy1, dx2, dy2,
r, yes_no(atMinusZ));
929 ns.
addSolid(nam, PseudoTrap(dx1, dx2, dy1, dy2, dz, r, atMinusZ));
933 template <>
void Converter<DDLTrapezoid>::operator()(xml_h element)
const {
935 xml_dim_t
e(element);
936 string nam = e.nameStr();
937 double dz = ns.
attr<
double>(
e,_U(dz));
946 double phi = ns.
attr<
double>(
e,_U(phi),0.0);
947 double theta = ns.
attr<
double>(
e,_U(theta),0.0);
950 "+ Trapezoid: dz=%10.3f [cm] alp1:%.3f bl1=%.3f tl1=%.3f alp2=%.3f bl2=%.3f tl2=%.3f h2=%.3f phi=%.3f theta=%.3f",
951 dz, alp1, bl1, tl1, h1, alp2, bl2, tl2, h2,
phi,
theta);
952 ns.
addSolid( nam, Trap( dz, theta, phi, h1, bl1, tl1, alp1, h2, bl2, tl2, alp2 ));
956 template <>
void Converter<DDLTrd1>::operator()(xml_h element)
const {
958 xml_dim_t
e( element );
959 string nam = e.nameStr();
962 double dx2 = ns.
attr<
double>(
e,
DD_CMU( dx2 ), 0.0 );
963 double dy2 = ns.
attr<
double>(
e,
DD_CMU( dy2 ), dy1 );
964 assert( dy1 == dy2 );
967 "+ Trd1: dz=%8.3f [cm] dx1:%.3f dy1:%.3f dx2:%.3f dy2:%.3f",
968 dz, dx1, dy1, dx2, dy2);
969 ns.
addSolid( nam, Trd1( dx1, dx2, dy1, dz ));
973 template <>
void Converter<DDLTrd2>::operator()(xml_h element)
const {
975 xml_dim_t
e( element );
976 string nam = e.nameStr();
979 double dx2 = ns.
attr<
double>(
e,
DD_CMU( dx2 ), 0.0 );
980 double dy2 = ns.
attr<
double>(
e,
DD_CMU( dy2 ), dy1 );
983 "+ Trd1: dz=%8.3f [cm] dx1:%.3f dy1:%.3f dx2:%.3f dy2:%.3f",
984 dz, dx1, dy1, dx2, dy2);
985 ns.
addSolid( nam, Trd2( dx1, dx2, dy1, dy2, dz ));
989 template <>
void Converter<DDLTubs>::operator()(xml_h element)
const {
991 xml_dim_t
e(element);
992 string nam = e.nameStr();
996 double startPhi = ns.
attr<
double>(
e,
DD_CMU(startPhi),0.0);
999 "+ Tubs: dz=%8.3f [cm] rmin=%8.3f [cm] rmax=%8.3f [cm]" 1000 " startPhi=%8.3f [rad] deltaPhi=%8.3f [rad]",
dz, rmin, rmax, startPhi,
deltaPhi );
1001 ns.
addSolid(nam, Tube( rmin, rmax, dz, startPhi, startPhi + deltaPhi ));
1005 template <>
void Converter<DDLCutTubs>::operator()(xml_h element)
const {
1007 xml_dim_t
e(element);
1008 string nam = e.nameStr();
1012 double startPhi = ns.
attr<
double>(
e,
DD_CMU(startPhi));
1021 "+ CutTube: dz=%8.3f [cm] rmin=%8.3f [cm] rmax=%8.3f [cm]" 1022 " startPhi=%8.3f [rad] deltaPhi=%8.3f [rad]...",
1024 ns.
addSolid(nam, CutTube(rmin,rmax,dz,startPhi,deltaPhi,lx,ly,lz,tx,ty,tz));
1028 template <>
void Converter<DDLTruncTubs>::operator()(xml_h element)
const {
1030 xml_dim_t
e(element);
1031 string nam = e.nameStr();
1032 double zhalf = ns.
attr<
double>(
e,
DD_CMU(zHalf));
1035 double startPhi = ns.
attr<
double>(
e,
DD_CMU(startPhi));
1037 double cutAtStart = ns.
attr<
double>(
e,
DD_CMU(cutAtStart));
1038 double cutAtDelta = ns.
attr<
double>(
e,
DD_CMU(cutAtDelta));
1039 bool cutInside = ns.
attr<
bool>(
e,
DD_CMU(cutInside));
1041 "+ TruncTube:zHalf=%8.3f [cm] rmin=%8.3f [cm] rmax=%8.3f [cm]" 1042 " startPhi=%8.3f [rad] deltaPhi=%8.3f [rad] atStart=%8.3f [cm] atDelta=%8.3f [cm] inside:%s",
1043 zhalf, rmin, rmax, startPhi,
deltaPhi, cutAtStart, cutAtDelta, yes_no(cutInside));
1044 ns.
addSolid(nam, TruncatedTube(zhalf,rmin,rmax,startPhi,deltaPhi,cutAtStart,cutAtDelta,cutInside));
1048 template <>
void Converter<DDLEllipticalTube>::operator()(xml_h element)
const {
1050 xml_dim_t
e(element);
1051 string nam = e.nameStr();
1056 "+ EllipticalTube xSemiAxis=%8.3f [cm] ySemiAxis=%8.3f [cm] zHeight=%8.3f [cm]",
dx,
dy,
dz);
1057 ns.
addSolid(nam, EllipticalTube(dx,dy,dz));
1061 template <>
void Converter<DDLCone>::operator()(xml_h element)
const {
1063 xml_dim_t
e(element);
1064 string nam = e.nameStr();
1066 double rmin1 = ns.
attr<
double>(
e,
DD_CMU(rMin1));
1067 double rmin2 = ns.
attr<
double>(
e,
DD_CMU(rMin2));
1068 double rmax1 = ns.
attr<
double>(
e,
DD_CMU(rMax1));
1069 double rmax2 = ns.
attr<
double>(
e,
DD_CMU(rMax2));
1070 double startPhi = ns.
attr<
double>(
e,
DD_CMU(startPhi));
1074 "+ Cone: dz=%8.3f [cm]" 1075 " rmin1=%8.3f [cm] rmax1=%8.3f [cm]" 1076 " rmin2=%8.3f [cm] rmax2=%8.3f [cm]" 1077 " startPhi=%8.3f [rad] deltaPhi=%8.3f [rad]",
1078 dz, rmin1, rmax1, rmin2, rmax2, startPhi,
deltaPhi);
1079 ns.
addSolid(nam, ConeSegment(dz,rmin1,rmax1,rmin2,rmax2,startPhi,phi2));
1083 template <>
void Converter<DDLShapeless>::operator()(xml_h element)
const {
1085 xml_dim_t
e(element);
1086 string nam = e.nameStr();
1088 "+ Shapeless: THIS ONE CAN ONLY BE USED AT THE VOLUME LEVEL -> Assembly%s", nam.c_str());
1093 template <>
void Converter<DDLBox>::operator()(xml_h element)
const {
1095 xml_dim_t
e(element);
1096 string nam = e.nameStr();
1101 "+ Box: dx=%10.3f [cm] dy=%10.3f [cm] dz=%10.3f [cm]",
dx,
dy,
dz);
1106 template <>
void Converter<include_load>::operator()(xml_h element)
const {
1107 string fname = element.attr<
string>(_U(ref));
1110 doc = xml::DocumentHandler().load( fp.fullPath());
1111 printout(_param<cms::DDParsingContext>()->debug_includes ? ALWAYS : DEBUG,
1112 "DD4CMS",
"+++ Processing the CMS detector description %s", fname.c_str());
1113 _option<DDRegistry>()->
includes.emplace_back( doc );
1117 template <>
void Converter<include_unload>::operator()(xml_h element)
const {
1118 string fname = xml::DocumentHandler::system_path(element);
1119 xml::DocumentHolder(xml_elt_t( element).document()).assign(
nullptr);
1120 printout(_param<cms::DDParsingContext>()->debug_includes ? ALWAYS : DEBUG,
1121 "DD4CMS",
"+++ Finished processing %s",fname.c_str());
1125 template <>
void Converter<include_constants>::operator()(xml_h element)
const {
1126 xml_coll_t( element,
DD_CMU(ConstantsSection)).for_each(Converter<ConstantsSection>(description,param,optional));
1138 const std::map<std::string, DDAxes> axesmap {{
"x",
DDAxes::x },
1147 template <>
void Converter<DDLDivision>::operator()( xml_h element )
const {
1149 xml_dim_t
e( element );
1150 string childName = e.nameStr();
1152 childName = ns.
name() + childName;
1154 string parentName = ns.
attr<
string>(
e,
DD_CMU( parent ));
1155 if( strchr( parentName.c_str(),
NAMESPACE_SEP ) ==
nullptr )
1156 parentName = ns.
name() + parentName;
1157 string axis = ns.
attr<
string>(
e,
DD_CMU( axis ));
1163 int nReplicas = e.hasAttr(
DD_CMU( nReplicas )) ? ns.
attr<
int>(
e,
DD_CMU( nReplicas )) : 0;
1166 "DD4CMS",
"+++ Start executing Division of %s along %s (%d) with offset %6.3f and %6.3f to produce %s....",
1167 parentName.c_str(), axis.c_str(), axesmap.at(axis),
offset,
width, childName.c_str());
1171 const TGeoShape* shape = parent.solid();
1172 TClass*
cl = shape->IsA();
1174 const TGeoTubeSeg* sh = (
const TGeoTubeSeg* )shape;
1177 int numCopies = (
int )(( sh->GetPhi2() - sh->GetPhi1())/ widthInDeg );
1179 "DD4CMS",
"+++ ...divide %s along %s (%d) with offset %6.3f deg and %6.3f deg to produce %d copies",
1180 parent.solid().type(), axis.c_str(), axesmap.at(axis), startInDeg, widthInDeg, numCopies );
1181 Volume child = parent.divide( childName, static_cast<int>( axesmap.at(axis)),
1182 numCopies, startInDeg, widthInDeg );
1187 "+++ %s Parent: %-24s [%s] Child: %-32s [%s] is multivolume [%s]",
1189 parentName.c_str(), parent.isValid() ?
"VALID" :
"INVALID",
1190 child.name(), child.isValid() ?
"VALID" :
"INVALID",
1191 child->IsVolumeMulti() ?
"YES" :
"NO" );
1194 double dy =
static_cast<const TGeoTrd1*
>(shape)->GetDy();
1196 "DD4CMS",
"+++ ...divide %s along %s (%d) with offset %6.3f cm and %6.3f cm to produce %d copies in %6.3f",
1197 parent.solid().type(), axis.c_str(), axesmap.at(axis), -dy + offset +
width,
width, nReplicas,
dy );
1198 Volume child = parent.divide( childName, static_cast<int>( axesmap.at(axis)),
1199 nReplicas, -dy + offset + width, width );
1204 "+++ %s Parent: %-24s [%s] Child: %-32s [%s] is multivolume [%s]",
1206 parentName.c_str(), parent.isValid() ?
"VALID" :
"INVALID",
1207 child.name(), child.isValid() ?
"VALID" :
"INVALID",
1208 child->IsVolumeMulti() ?
"YES" :
"NO" );
1211 printout(
ERROR,
"DD4CMS",
"++ FAILED Division of a %s is not implemented yet!", parent.solid().type());
1216 template <>
void Converter<DDLAlgorithm>::operator()(xml_h element)
const {
1218 xml_dim_t
e(element);
1219 string name = e.nameStr();
1223 printout(
INFO,
"DD4CMS",
"+++ Skip disabled algorithms: %s", name.c_str());
1230 string type =
"DDCMS_" + ns.
realName( name );
1236 "DD4CMS",
"+++ Start executing algorithm %s....", type.c_str());
1241 "DD4CMS",
"+++ Executed algorithm: %08lX = %s", ret, name.c_str());
1244 printout(
ERROR,
"DD4CMS",
"++ FAILED NOT ADDING SUBDETECTOR %08lX = %s", ret, name.c_str());
1247 template <
class InputIt,
class ForwardIt,
class BinOp>
1249 ForwardIt s_first, ForwardIt s_last,
1252 while( first != last ) {
1253 const auto pos = std::find_first_of( first, last, s_first, s_last );
1254 binary_op( first, pos );
1255 if( pos == last )
break;
1262 tbb::concurrent_vector<double>
1263 splitNumeric(
const string&
str,
const string& delims =
"," )
1265 tbb::concurrent_vector<double>
output;
1268 cbegin( delims ), cend( delims ),
1271 output.emplace_back(stod(
string(
first,
second )));
1280 template <>
void Converter<DDLVector>::operator()( xml_h element )
const {
1284 xml_dim_t
e( element );
1285 string name = e.nameStr();
1286 string type = ns.
attr<
string>(
e, _U( type ));
1287 string nEntries = ns.
attr<
string>(
e,
DD_CMU( nEntries ));
1288 string val = e.text();
1289 val.erase( remove_if( val.begin(), val.end(), [](
unsigned char x ){
return isspace( x ); }), val.end());
1292 "DD4CMS",
"+++ Vector<%s>: %s[%s]: %s", type.c_str(), name.c_str(),
1293 nEntries.c_str(), val.c_str());
1295 tbb::concurrent_vector<double> results = splitNumeric(val);
1296 registry->insert( {
name, results } );
1299 template <>
void Converter<debug>::operator()(xml_h dbg)
const {
1314 template <>
void Converter<DDRegistry>::operator()(xml_h )
const {
1316 DDRegistry* res = _option<DDRegistry>();
1321 "DD4CMS",
"+++ RESOLVING %ld unknown constants.....", res->unresolvedConst.size());
1323 while( !res->unresolvedConst.empty()) {
1324 for(
auto i : res->unresolvedConst ) {
1325 const string& n =
i.first;
1327 string& v =
i.second;
1329 for( idx = v.find(
'[', 0 ); idx != string::npos; idx = v.find(
'[', idx + 1 )) {
1330 idq = v.find(
']', idx + 1 );
1331 rep = v.substr( idx + 1, idq - idx - 1 );
1332 auto r = res->allConst.find( rep );
1333 if(
r != res->allConst.end()) {
1334 rep =
"(" + (*r).second +
")";
1335 v.replace( idx, idq - idx + 1, rep );
1338 if( v.find(
']') == string::npos ) {
1339 if( v.find(
"-+") != string::npos || v.find(
"+-") != string::npos ) {
1340 while(( idx = v.find(
"-+" )) != string::npos )
1341 v.replace( idx, 2,
"-" );
1342 while(( idx = v.find(
"+-" )) != string::npos )
1343 v.replace( idx, 2,
"-" );
1346 "DD4CMS",
"+++ [%06ld] ---------- %-40s = %s",
1347 res->unresolvedConst.size() - 1, n.c_str(), res->originalConst[
n].c_str());
1348 ns.addConstantNS( n, v,
"number" );
1349 res->unresolvedConst.unsafe_erase(n);
1353 if( ++count > 10000)
break;
1355 if( !res->unresolvedConst.empty()) {
1356 for(
const auto& e : res->unresolvedConst)
1357 printout(
ERROR,
"DD4CMS",
"+++ Unresolved constant: %-40s = %s.", e.first.c_str(), e.second.c_str());
1358 except(
"DD4CMS",
"++ FAILED to resolve %ld constant entries:", res->unresolvedConst.size());
1360 res->unresolvedConst.clear();
1361 res->originalConst.clear();
1362 res->allConst.clear();
1365 template <>
void Converter<print_xml_doc>::operator()(xml_h element)
const {
1366 string fname = xml::DocumentHandler::system_path(element);
1367 printout(_param<cms::DDParsingContext>()->debug_includes ? ALWAYS : DEBUG,
1368 "DD4CMS",
"+++ Processing data from: %s",fname.c_str());
1382 xml_elt_t dddef(element);
1383 string fname = xml::DocumentHandler::system_path(element);
1384 bool open_geometry = dddef.hasChild(
DD_CMU(open_geometry));
1385 bool close_geometry = dddef.hasChild(
DD_CMU(close_geometry));
1387 xml_coll_t(dddef, _U(
debug)).for_each(Converter<debug>(det,&context));
1392 printout(
INFO,
"DD4CMS",
"+++ Processing the CMS detector description %s",fname.c_str());
1395 Converter<print_xml_doc> print_doc(det,&context);
1398 print_doc((doc=dddef.document()).
root());
1399 xml_coll_t(dddef,
DD_CMU(DisabledAlgo)).for_each(Converter<disabled_algo>(det,&context,&res));
1400 xml_coll_t(dddef,
DD_CMU(ConstantsSection)).for_each(Converter<ConstantsSection>(det,&context,&res));
1401 xml_coll_t(dddef,
DD_CMU(VisSection)).for_each(Converter<vissection>(det,&context));
1402 xml_coll_t(dddef,
DD_CMU(RotationSection)).for_each(Converter<RotationSection>(det,&context));
1403 xml_coll_t(dddef,
DD_CMU(MaterialSection)).for_each(Converter<MaterialSection>(det,&context));
1405 xml_coll_t(dddef,
DD_CMU(IncludeSection)).for_each(
DD_CMU(Include), Converter<include_load>(det,&context,&res));
1407 for(xml::Document
d : res.includes) {
1408 print_doc((doc=d).
root());
1409 Converter<include_constants>(det,&context,&res)((doc=d).root());
1412 Converter<DDRegistry>(det,&context,&res)(dddef);
1414 for(xml::Document d : res.includes) {
1415 print_doc((doc=d).
root());
1416 xml_coll_t(d.root(),
DD_CMU(MaterialSection)).for_each(Converter<MaterialSection>(det,&context));
1419 context.geo_inited =
true;
1423 for(xml::Document d : res.includes) {
1424 print_doc((doc=d).
root());
1425 xml_coll_t(d.root(),
DD_CMU(RotationSection)).for_each(Converter<RotationSection>(det,&context));
1427 for(xml::Document d : res.includes) {
1428 print_doc((doc=d).
root());
1429 xml_coll_t(d.root(),
DD_CMU(SolidSection)).for_each(Converter<SolidSection>(det,&context));
1431 for(xml::Document d : res.includes) {
1432 print_doc((doc=d).
root());
1433 xml_coll_t(d.root(),
DD_CMU(LogicalPartSection)).for_each(Converter<LogicalPartSection>(det,&context));
1435 for(xml::Document d : res.includes) {
1436 print_doc((doc=d).
root());
1437 xml_coll_t(d.root(),
DD_CMU(
Algorithm)).for_each(Converter<DDLAlgorithm>(det,&context));
1439 for(xml::Document d : res.includes) {
1440 print_doc((doc=d).
root());
1441 xml_coll_t(d.root(),
DD_CMU(PosPartSection)).for_each(Converter<PosPartSection>(det,&context));
1443 for(xml::Document d : res.includes) {
1444 print_doc((doc=d).
root());
1445 xml_coll_t(d.root(),
DD_CMU(SpecParSection)).for_each(Converter<SpecParSection>(det,&context));
1449 for(xml::Document d : res.includes) Converter<include_unload>(det,&context,&res)(d.root());
1451 print_doc((doc=dddef.document()).
root());
1453 xml_coll_t(dddef,
DD_CMU(SolidSection)).for_each(Converter<SolidSection>(det,&context));
1454 xml_coll_t(dddef,
DD_CMU(LogicalPartSection)).for_each(Converter<LogicalPartSection>(det,&context));
1455 xml_coll_t(dddef,
DD_CMU(
Algorithm)).for_each(Converter<DDLAlgorithm>(det,&context));
1456 xml_coll_t(dddef,
DD_CMU(PosPartSection)).for_each(Converter<PosPartSection>(det,&context));
1457 xml_coll_t(dddef,
DD_CMU(SpecParSection)).for_each(Converter<SpecParSection>(det,&context));
1460 printout(
ERROR,
"DD4CMS",
"Exception while processing xml source:%s",doc.uri().c_str());
1461 printout(
ERROR,
"DD4CMS",
"----> %s", e.what());
1466 if(close_geometry) {
1469 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.
tbb::concurrent_unordered_map< std::string, std::string > originalConst
Geom::Theta< T > theta() const
constexpr NumType convertRadToDeg(NumType radians)
DDLEllipticalTube processes all EllipticalTube elements.
dd4hep::Volume addVolume(dd4hep::Volume vol) const
Add rotation matrix to current namespace.
dd4hep::Solid solid(const std::string &name) const
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
tbb::concurrent_unordered_map< std::string, tbb::concurrent_vector< double >> DDVectorsMap
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)
constexpr unsigned int hash(const char *str, int h=0)
static void convert_boolean(cms::DDParsingContext *context, xml_h element)
tbb::concurrent_unordered_map< std::string, dd4hep::Volume > volumes
Namespace of DDCMS conversion namespace.
DDLTubs processes Tubs elements.
dd4hep::Solid addSolid(const std::string &name, dd4hep::Solid solid) const
DDLLogicalPart processes LogicalPart elements.
DDLRotationByAxis handles RotationByAxis elements.
DDLCompositeMaterial processes all CompositeMaterial elements.
tbb::concurrent_vector< std::string > disabledAlgs
static long load_dddefinition(Detector &det, xml_h element)
Converter for <DDDefinition> tags.
DDAxes
analagous to geant4/source/global/HEPGeometry/include/geomdefs.hh
tbb::concurrent_unordered_map< std::string, std::string > unresolvedConst
DDLRotationSequence handles a set of Rotations.
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()