CMS 3D CMS Logo

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

#include <DDCoreToDDXMLOutput.h>

Public Member Functions

void element (const TGeoMaterial *element, std::ostream &xos)
 
void logicalPart (const DDLogicalPart &lp, std::ostream &xos)
 
void logicalPart (const std::string &asName, std::ostream &xos)
 
void logicalPart (const TGeoVolume &lp, std::ostream &xos)
 
void material (const DDMaterial &material, std::ostream &xos)
 
void material (const std::string &matName, double density, const std::vector< cms::DDParsingContext::CompositeMaterial > &matRefs, std::ostream &xos)
 
void position (const DDLogicalPart &parent, const DDLogicalPart &child, DDPosData *edgeToChild, int &rotNameSeed, std::ostream &xos)
 
void position (const TGeoVolume &parent, const TGeoNode &child, const std::string &childName, cms::DDParsingContext &context, std::ostream &xos)
 
void rotation (const DDRotation &rotation, std::ostream &xos, const std::string &rotn="")
 
void rotation (const dd4hep::Rotation3D &rotation, std::ostream &xos, const cms::DDParsingContext &context, const std::string &rotn)
 
void solid (const DDSolid &solid, std::ostream &xos)
 
void solid (const dd4hep::Solid &solid, const cms::DDParsingContext &context, std::ostream &xos)
 
void specpar (const DDSpecifics &sp, std::ostream &xos)
 
void specpar (const std::pair< DDsvalues_type, std::set< const DDPartSelection *>> &pssv, std::ostream &xos)
 
void specpar (const std::string &name, const dd4hep::SpecPar &specPar, std::ostream &xos)
 

Static Public Member Functions

static std::string trimShapeName (const std::string &solidName)
 

Public Attributes

std::string ns_
 

Detailed Description

Author
: Michael Case Revison for DD4hep
Version
: 1.0

Description: The idea is to store one large XML file containing the XML elements in DDL (Detector Description Language). In doing so, all DDAlgorithms or other code generated DD in-memory components should be reproduced without the need for them to run again if the geometry is read into DDLParser again.

Definition at line 40 of file DDCoreToDDXMLOutput.h.

Member Function Documentation

◆ element()

void DDCoreToDDXMLOutput::element ( const TGeoMaterial *  element,
std::ostream &  xos 
)

Definition at line 648 of file DDCoreToDDXMLOutput.cc.

References convertGPerCcToMgPerCc(), alignBH_cfg::fixed, and AlCaHLTBitMon_QueryRunRegistry::string.

648  {
649  int noc = material->GetNelements();
650  if (noc == 1) {
651  TGeoElement* elem = material->GetElement();
652  std::string nameLowerCase(elem->GetTitle());
653  // Leave first letter capitalized
654  for (size_t index = 1; index < nameLowerCase.size(); ++index) {
655  nameLowerCase[index] = tolower(nameLowerCase[index]);
656  }
657  std::string trimName(dd4hep::dd::noNamespace(material->GetName()));
658 
659  // Element title contains element name in all uppercase.
660  // Convert to lowercase and check that material name matches element name.
661  // Hydrogen is used for vacuum materials. Phosphorus is called "Phosphor"
662  // Boron is a special case because there are two isotopes defined: "Bor 10" and "Bor 11".
663  if (trimName == nameLowerCase || nameLowerCase == "Hydrogen" || nameLowerCase == "Phosphorus" ||
664  (nameLowerCase == "Boron" && trimName.compare(0, 3, "Bor") == 0)) {
665  xos << "<ElementaryMaterial name=\"" << material->GetName() << "\""
666  << " density=\"" << std::scientific << std::setprecision(5) << convertGPerCcToMgPerCc(material->GetDensity())
667  << "*mg/cm3\""
668  << " atomicWeight=\"" << std::fixed << material->GetA() << "*g/mole\"" << std::setprecision(0) << std::fixed
669  << " atomicNumber=\"" << material->GetZ() << "\"/>" << std::endl;
670  }
671  }
672 }
static constexpr NumType convertGPerCcToMgPerCc(NumType gPerCc)
void material(const DDMaterial &material, std::ostream &xos)

◆ logicalPart() [1/3]

void DDCoreToDDXMLOutput::logicalPart ( const DDLogicalPart lp,
std::ostream &  xos 
)

Definition at line 750 of file DDCoreToDDXMLOutput.cc.

References DDLogicalPart::material(), DDLogicalPart::solid(), and DDBase< N, C >::toString().

750  {
751  xos << "<LogicalPart name=\"" << lp.toString() << "\">" << std::endl;
752  xos << "<rSolid name=\"" << lp.solid().toString() << "\"/>" << std::endl;
753  xos << "<rMaterial name=\"" << lp.material().toString() << "\"/>" << std::endl;
754  xos << "</LogicalPart>" << std::endl;
755 }
std::string toString() const
Definition: DDBase.h:63
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.

◆ logicalPart() [2/3]

void DDCoreToDDXMLOutput::logicalPart ( const std::string &  asName,
std::ostream &  xos 
)

Definition at line 757 of file DDCoreToDDXMLOutput.cc.

757  {
758  xos << "<LogicalPart name=\"" << asName << "\">" << std::endl;
759  xos << "<rSolid name=\"" << asName << "\"/>" << std::endl;
760  xos << "<rMaterial name=\"materials:Air\"/>" << std::endl;
761  xos << "</LogicalPart>" << std::endl;
762 }

◆ logicalPart() [3/3]

void DDCoreToDDXMLOutput::logicalPart ( const TGeoVolume &  lp,
std::ostream &  xos 
)

Definition at line 764 of file DDCoreToDDXMLOutput.cc.

764  {
765  xos << "<LogicalPart name=\"" << lp.GetName() << "\">" << std::endl;
766  auto solid = lp.GetShape();
767  if (solid != nullptr) {
768  xos << "<rSolid name=\"" << trimShapeName(solid->GetName()) << "\"/>" << std::endl;
769  }
770  auto material = lp.GetMaterial();
771  if (material != nullptr) {
772  xos << "<rMaterial name=\"" << material->GetName() << "\"/>" << std::endl;
773  }
774  xos << "</LogicalPart>" << std::endl;
775 }
static std::string trimShapeName(const std::string &solidName)
void material(const DDMaterial &material, std::ostream &xos)
void solid(const DDSolid &solid, std::ostream &xos)

◆ material() [1/2]

void DDCoreToDDXMLOutput::material ( const DDMaterial material,
std::ostream &  xos 
)

Definition at line 606 of file DDCoreToDDXMLOutput.cc.

References DDMaterial::a(), DDMaterial::constituent(), geant_units::operators::convertUnitsTo(), DDMaterial::density(), alignBH_cfg::fixed, dqmiolumiharvest::j, DDMaterial::noOfConstituents(), DDBase< N, C >::toString(), and DDMaterial::z().

606  {
607  int noc = material.noOfConstituents();
608  if (noc == 0) {
609  xos << "<ElementaryMaterial name=\"" << material.toString() << "\""
610  << " density=\"" << std::scientific << std::setprecision(5) << convertUnitsTo(1._mg_per_cm3, material.density())
611  << "*mg/cm3\""
612  << " atomicWeight=\"" << std::fixed << convertUnitsTo(1._g_per_mole, material.a()) << "*g/mole\""
613  << std::setprecision(0) << std::fixed << " atomicNumber=\"" << material.z() << "\"/>" << std::endl;
614  } else {
615  xos << "<CompositeMaterial name=\"" << material.toString() << "\""
616  << " density=\"" << std::scientific << std::setprecision(5) << convertUnitsTo(1._mg_per_cm3, material.density())
617  << "*mg/cm3\""
618  << " method=\"mixture by weight\">" << std::endl;
619 
620  int j = 0;
621  for (; j < noc; ++j) {
622  xos << "<MaterialFraction fraction=\"" << std::fixed << std::setprecision(9) << material.constituent(j).second
623  << "\">" << std::endl;
624  xos << "<rMaterial name=\"" << material.constituent(j).first.name() << "\"/>" << std::endl;
625  xos << "</MaterialFraction>" << std::endl;
626  }
627  xos << "</CompositeMaterial>" << std::endl;
628  }
629 }
constexpr NumType convertUnitsTo(double desiredUnits, NumType val)
Definition: GeantUnits.h:73
void material(const DDMaterial &material, std::ostream &xos)

◆ material() [2/2]

void DDCoreToDDXMLOutput::material ( const std::string &  matName,
double  density,
const std::vector< cms::DDParsingContext::CompositeMaterial > &  matRefs,
std::ostream &  xos 
)

Definition at line 631 of file DDCoreToDDXMLOutput.cc.

References convertGPerCcToMgPerCc(), fastSimProducer_cff::density, and alignBH_cfg::fixed.

634  {
635  xos << "<CompositeMaterial name=\"" << matName << "\""
636  << " density=\"" << std::scientific << std::setprecision(5) << convertGPerCcToMgPerCc(density) << "*mg/cm3\""
637  << " method=\"mixture by weight\">" << std::endl;
638 
639  for (auto compIter = matRefs.begin(); compIter != matRefs.end(); ++compIter) {
640  xos << "<MaterialFraction fraction=\"" << std::fixed << std::setprecision(9) << compIter->fraction << "\">"
641  << std::endl;
642  xos << "<rMaterial name=\"" << compIter->name << "\"/>" << std::endl;
643  xos << "</MaterialFraction>" << std::endl;
644  }
645  xos << "</CompositeMaterial>" << std::endl;
646 }
static constexpr NumType convertGPerCcToMgPerCc(NumType gPerCc)

◆ position() [1/2]

void DDCoreToDDXMLOutput::position ( const DDLogicalPart parent,
const DDLogicalPart child,
DDPosData edgeToChild,
int &  rotNameSeed,
std::ostream &  xos 
)

Definition at line 809 of file DDCoreToDDXMLOutput.cc.

References DDPosData::copyno(), DDPosData::ddrot(), class-composition::parent, idealTransformation::rotation, DDRotation::rotation(), cms::rotation_utils::rotName(), cms_rounding::roundIfNear0(), AlCaHLTBitMon_QueryRunRegistry::string, DDBase< N, C >::toString(), and DDPosData::translation().

813  {
814  std::string rotName = edgeToChild->ddrot().toString();
815  DDRotationMatrix myIDENT;
816 
817  xos << "<PosPart copyNumber=\"" << edgeToChild->copyno() << "\">" << std::endl;
818  xos << "<rParent name=\"" << parent.toString() << "\"/>" << std::endl;
819  xos << "<rChild name=\"" << child.toString() << "\"/>" << std::endl;
820  if ((edgeToChild->ddrot().rotation()) != myIDENT) {
821  if (rotName == ":") {
822  rotation(edgeToChild->ddrot(), xos);
823  } else {
824  xos << "<rRotation name=\"" << rotName << "\"/>" << std::endl;
825  }
826  } // else let default Rotation matrix be created?
827  using namespace cms_rounding;
828  xos << "<Translation x=\"" << roundIfNear0(edgeToChild->translation().x()) << "*mm\""
829  << " y=\"" << roundIfNear0(edgeToChild->translation().y()) << "*mm\""
830  << " z=\"" << roundIfNear0(edgeToChild->translation().z()) << "*mm\"/>" << std::endl;
831  xos << "</PosPart>" << std::endl;
832 }
const DDTranslation & translation() const
Definition: DDPosData.h:27
static const std::string & rotName(const T &rot, const cms::DDParsingContext &context)
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
std::string toString() const
Definition: DDBase.h:63
constexpr valType roundIfNear0(valType value, double tolerance=1.e-7)
Definition: Rounding.h:11
const DDRotationMatrix & rotation() const
Returns the read-only rotation-matrix.
Definition: DDTransform.h:81
int copyno() const
Definition: DDPosData.h:33
void rotation(const DDRotation &rotation, std::ostream &xos, const std::string &rotn="")
const DDRotation & ddrot() const
Definition: DDPosData.h:32

◆ position() [2/2]

void DDCoreToDDXMLOutput::position ( const TGeoVolume &  parent,
const TGeoNode &  child,
const std::string &  childName,
cms::DDParsingContext context,
std::ostream &  xos 
)

Definition at line 777 of file DDCoreToDDXMLOutput.cc.

References cms::rotation_utils::addRotWithNewName(), visDQMUpload::context, cms::rotation_utils::identityHash(), makeMuonMisalignmentScenario::matrix, class-composition::parent, makeMuonMisalignmentScenario::rot, cms::rotation_utils::rotHash(), cms::rotation_utils::rotName(), cms_rounding::roundIfNear0(), and AlCaHLTBitMon_QueryRunRegistry::string.

781  {
782  xos << "<PosPart copyNumber=\"" << child.GetNumber() << "\">" << std::endl;
783  xos << "<rParent name=\"" << parent.GetName() << "\"/>" << std::endl;
784  xos << "<rChild name=\"" << childVolName << "\"/>" << std::endl;
785 
786  const auto matrix = child.GetMatrix();
787  if (matrix != nullptr && !matrix->IsIdentity()) {
788  auto rot = matrix->GetRotationMatrix();
791  if (rotNameStr == "NULL") {
792  rotNameStr = child.GetName(); // Phys vol name
793  rotNameStr += parent.GetName();
794  cms::DDNamespace nameSpace(context);
795  cms::rotation_utils::addRotWithNewName(nameSpace, rotNameStr, rot);
796  }
797  xos << "<rRotation name=\"" << rotNameStr << "\"/>" << std::endl;
798  }
799  }
800  auto trans = matrix->GetTranslation();
801  using namespace cms_rounding;
802  xos << "<Translation x=\"" << roundIfNear0(trans[0]) << "*mm\"";
803  xos << " y=\"" << roundIfNear0(trans[1]) << "*mm\"";
804  xos << " z=\"" << roundIfNear0(trans[2]) << "*mm\"";
805  xos << "/>" << std::endl;
806  xos << "</PosPart>" << std::endl;
807 }
std::string rotHash(const Double_t *rot)
Definition: DDNamespace.cc:26
static const std::string identityHash("1.00000000.00000000.00000000.00000001.00000000.00000000.00000000.00000001.0000000")
static const std::string & rotName(const T &rot, const cms::DDParsingContext &context)
constexpr valType roundIfNear0(valType value, double tolerance=1.e-7)
Definition: Rounding.h:11
static void addRotWithNewName(cms::DDNamespace &ns, std::string &name, const dd4hep::Rotation3D &rot)

◆ rotation() [1/2]

void DDCoreToDDXMLOutput::rotation ( const DDRotation rotation,
std::ostream &  xos,
const std::string &  rotn = "" 
)

Definition at line 674 of file DDCoreToDDXMLOutput.cc.

References a, b, c, RPCNoise_example::check, angle_units::operators::convertRadToDeg(), gather_cfg::cout, reflectTol, makeMuonMisalignmentScenario::rot, idealTransformation::rotation, cms::rotation_utils::rotName(), cms_rounding::roundIfNear0(), AlCaHLTBitMon_QueryRunRegistry::string, tol0, and x.

674  {
675  DD3Vector x, y, z;
676  rotation.rotation().GetComponents(x, y, z);
677  double a, b, c;
678  x.GetCoordinates(a, b, c);
679  x.SetCoordinates(
681  y.GetCoordinates(a, b, c);
682  y.SetCoordinates(
684  z.GetCoordinates(a, b, c);
685  z.SetCoordinates(
687  double check = (x.Cross(y)).Dot(z); // in case of a LEFT-handed orthogonal system
688  // this must be -1
689  bool reflection((1. - check) > reflectTol);
690  std::string rotName = rotation.toString();
691  if (rotName == ":") {
692  if (!rotn.empty()) {
693  rotName = rotn;
694  std::cout << "about to try to make a new DDRotation... should fail!" << std::endl;
695  DDRotation rot(DDName(rotn), std::make_unique<DDRotationMatrix>(rotation.rotation()));
696  std::cout << "new rotation: " << rot << std::endl;
697  } else {
698  std::cout << "WARNING: MAKING AN UNNAMED ROTATION" << std::endl;
699  }
700  }
701  if (!reflection) {
702  xos << "<Rotation ";
703  } else {
704  xos << "<ReflectionRotation ";
705  }
706  using namespace cms_rounding;
707  xos << "name=\"" << rotName << "\""
708  << " phiX=\"" << roundIfNear0(convertRadToDeg(x.phi()), tol0) << "*deg\""
709  << " thetaX=\"" << roundIfNear0(convertRadToDeg(x.theta()), tol0) << "*deg\""
710  << " phiY=\"" << roundIfNear0(convertRadToDeg(y.phi()), tol0) << "*deg\""
711  << " thetaY=\"" << roundIfNear0(convertRadToDeg(y.theta()), tol0) << "*deg\""
712  << " phiZ=\"" << roundIfNear0(convertRadToDeg(z.phi()), tol0) << "*deg\""
713  << " thetaZ=\"" << roundIfNear0(convertRadToDeg(z.theta()), tol0) << "*deg\"/>" << std::endl;
714 }
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
static constexpr double reflectTol
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
static const std::string & rotName(const T &rot, const cms::DDParsingContext &context)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
static constexpr double tol0
constexpr valType roundIfNear0(valType value, double tolerance=1.e-7)
Definition: Rounding.h:11
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119
void rotation(const DDRotation &rotation, std::ostream &xos, const std::string &rotn="")

◆ rotation() [2/2]

void DDCoreToDDXMLOutput::rotation ( const dd4hep::Rotation3D &  rotation,
std::ostream &  xos,
const cms::DDParsingContext context,
const std::string &  rotn 
)

Definition at line 716 of file DDCoreToDDXMLOutput.cc.

References a, b, c, RPCNoise_example::check, angle_units::operators::convertRadToDeg(), reflectTol, idealTransformation::rotation, cms_rounding::roundIfNear0(), tol0, and x.

719  {
721  rotation.GetComponents(x, y, z);
722  double a, b, c;
723  x.GetCoordinates(a, b, c);
724  x.SetCoordinates(
726  y.GetCoordinates(a, b, c);
727  y.SetCoordinates(
729  z.GetCoordinates(a, b, c);
730  z.SetCoordinates(
732  double check = (x.Cross(y)).Dot(z); // in case of a LEFT-handed orthogonal system
733  // this must be -1
734  bool reflection((1. - check) > reflectTol);
735  if (!reflection) {
736  xos << "<Rotation ";
737  } else {
738  xos << "<ReflectionRotation ";
739  }
740  using namespace cms_rounding;
741  xos << "name=\"" << rotn << "\""
742  << " phiX=\"" << roundIfNear0(convertRadToDeg(x.phi()), tol0) << "*deg\""
743  << " thetaX=\"" << roundIfNear0(convertRadToDeg(x.theta()), tol0) << "*deg\""
744  << " phiY=\"" << roundIfNear0(convertRadToDeg(y.phi()), tol0) << "*deg\""
745  << " thetaY=\"" << roundIfNear0(convertRadToDeg(y.theta()), tol0) << "*deg\""
746  << " phiZ=\"" << roundIfNear0(convertRadToDeg(z.phi()), tol0) << "*deg\""
747  << " thetaZ=\"" << roundIfNear0(convertRadToDeg(z.theta()), tol0) << "*deg\"/>" << std::endl;
748 }
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
static constexpr double reflectTol
static constexpr double tol0
constexpr valType roundIfNear0(valType value, double tolerance=1.e-7)
Definition: Rounding.h:11
Transform3DPJ::Vector XYZVector
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119
void rotation(const DDRotation &rotation, std::ostream &xos, const std::string &rotn="")

◆ solid() [1/2]

void DDCoreToDDXMLOutput::solid ( const DDSolid solid,
std::ostream &  xos 
)

Definition at line 342 of file DDCoreToDDXMLOutput.cc.

References DDTrap::alpha1(), DDTrap::alpha2(), DDPseudoTrap::atMinusZ(), angle_units::operators::convertRadToDeg(), DDTruncTubs::cutAtDelta(), DDTruncTubs::cutAtStart(), DDTruncTubs::cutInside(), dd_not_init, ddbox, ddcons, ddcuttubs, ddellipticaltube, ddextrudedpolygon, ddintersection, ddpolycone_rrz, ddpolycone_rz, ddpolyhedra_rrz, ddpolyhedra_rz, ddpseudotrap, ddshapeless, ddsubtraction, ddtorus, ddtrap, ddtrunctubs, ddtubs, ddunion, DDTruncTubs::deltaPhi(), DDPolycone::deltaPhi(), DDPolyhedra::deltaPhi(), DDTubs::deltaPhi(), DDCutTubs::deltaPhi(), DDCons::deltaPhi(), DDTorus::deltaPhi(), Exception, DDBox::halfX(), DDBox::halfY(), DDTrap::halfZ(), DDPseudoTrap::halfZ(), DDBox::halfZ(), DDCutTubs::highNorm(), mps_fire::i, dqmdumpme::k, DDCutTubs::lowNorm(), DDBase< N, C >::name(), DDTrap::phi(), DDCons::phiFrom(), DDPseudoTrap::radius(), DDTruncTubs::rIn(), DDTubs::rIn(), DDCutTubs::rIn(), DDCons::rInMinusZ(), DDCons::rInPlusZ(), DDTorus::rMax(), DDPolycone::rMaxVec(), DDPolyhedra::rMaxVec(), DDTorus::rMin(), DDPolycone::rMinVec(), DDPolyhedra::rMinVec(), DDBooleanSolid::rotation(), cms::rotation_utils::rotName(), DDTruncTubs::rOut(), DDTubs::rOut(), DDCutTubs::rOut(), DDCons::rOutMinusZ(), DDCons::rOutPlusZ(), DDTorus::rTorus(), DDPolycone::rVec(), DDPolyhedra::rVec(), DDSolid::shape(), DDPolyhedra::sides(), DDBooleanSolid::solidA(), DDBooleanSolid::solidB(), DDTruncTubs::startPhi(), DDPolycone::startPhi(), DDPolyhedra::startPhi(), DDTubs::startPhi(), DDCutTubs::startPhi(), DDTorus::startPhi(), AlCaHLTBitMon_QueryRunRegistry::string, DDTrap::theta(), DDBase< N, C >::toString(), DDBooleanSolid::translation(), x, DDTrap::x1(), DDPseudoTrap::x1(), DDTrap::x2(), DDPseudoTrap::x2(), DDTrap::x3(), DDTrap::x4(), DDEllipticalTube::xSemiAxis(), DDExtrudedPolygon::xVec(), DDTrap::y1(), DDPseudoTrap::y1(), DDTrap::y2(), DDPseudoTrap::y2(), DDEllipticalTube::ySemiAxis(), DDExtrudedPolygon::yVec(), DDTruncTubs::zHalf(), DDTubs::zhalf(), DDCutTubs::zhalf(), DDCons::zhalf(), DDEllipticalTube::zHeight(), DDExtrudedPolygon::zscaleVec(), DDPolycone::zVec(), DDPolyhedra::zVec(), DDExtrudedPolygon::zVec(), DDExtrudedPolygon::zxVec(), and DDExtrudedPolygon::zyVec().

342  {
343  switch (solid.shape()) {
347  DDBooleanSolid rs(solid);
348  if (solid.shape() == DDSolidShape::ddunion) {
349  xos << "<UnionSolid ";
350  } else if (solid.shape() == DDSolidShape::ddsubtraction) {
351  xos << "<SubtractionSolid ";
352  } else if (solid.shape() == DDSolidShape::ddintersection) {
353  xos << "<IntersectionSolid ";
354  }
355  xos << "name=\"" << rs.toString() << "\">" << std::endl;
356  // if translation is == identity there are no parameters.
357  // if there is no rotation the name will be ":"
358  xos << "<rSolid name=\"" << rs.solidA().toString() << "\"/>" << std::endl;
359  xos << "<rSolid name=\"" << rs.solidB().toString() << "\"/>" << std::endl;
360  xos << "<Translation x=\"" << rs.translation().X() << "*mm\"";
361  xos << " y=\"" << rs.translation().Y() << "*mm\"";
362  xos << " z=\"" << rs.translation().Z() << "*mm\"";
363  xos << "/>" << std::endl;
364  std::string rotName = rs.rotation().toString();
365  if (rotName == ":") {
366  rotName = "gen:ID";
367  }
368  xos << "<rRotation name=\"" << rs.rotation().toString() << "\"/>" << std::endl;
369  if (solid.shape() == DDSolidShape::ddunion) {
370  xos << "</UnionSolid>" << std::endl;
371  } else if (solid.shape() == DDSolidShape::ddsubtraction) {
372  xos << "</SubtractionSolid>" << std::endl;
373  } else if (solid.shape() == DDSolidShape::ddintersection) {
374  xos << "</IntersectionSolid>" << std::endl;
375  }
376  break;
377  }
378  case DDSolidShape::ddbox: {
379  // <Box name="box1" dx="10*cm" dy="10*cm" dz="10*cm"/>
380  DDBox rs(solid);
381  xos << "<Box name=\"" << rs.toString() << "\"" //<< rs.toString() << "\"" //
382  << " dx=\"" << rs.halfX() << "*mm\""
383  << " dy=\"" << rs.halfY() << "*mm\""
384  << " dz=\"" << rs.halfZ() << "*mm\"/>" << std::endl;
385  break;
386  }
387  case DDSolidShape::ddtubs: {
388  // <Tubs name="TrackerSupportTubeNomex" rMin="[SupportTubeR1]+[Tol]"
389  // rMax="[SupportTubeR2]-[Tol]" dz="[SupportTubeL]"
390  // startPhi="0*deg" deltaPhi="360*deg"/>
391  DDTubs rs(solid);
392  xos << "<Tubs name=\"" << rs.toString() << "\""
393  << " rMin=\"" << rs.rIn() << "*mm\""
394  << " rMax=\"" << rs.rOut() << "*mm\""
395  << " dz=\"" << rs.zhalf() << "*mm\""
396  << " startPhi=\"" << convertRadToDeg(rs.startPhi()) << "*deg\""
397  << " deltaPhi=\"" << convertRadToDeg(rs.deltaPhi()) << "*deg\"/>" << std::endl;
398  break;
399  }
400  case DDSolidShape::ddtrap: {
401  // <Trapezoid name="UpL_CSC_for_TotemT1_Plane_2_5_7" dz="[PCB_Epoxy_Thick_3P]/2."
402  // alp1="-[Up_Signal_Side_alpL_3P]" alp2="-[Up_Signal_Side_alpL_3P]"
403  // bl1="[Max_Base_Signal_SideL_3P]/2." tl1="[Up_Min_Base_Signal_SideL_3P]/2." h1="[Up_Height_Signal_SideL_3P]/2."
404  // h2="[Up_Height_Signal_SideL_3P]/2." bl2="[Max_Base_Signal_SideL_3P]/2." tl2="[Up_Min_Base_Signal_SideL_3P]/2."/>
405  DDTrap rs(solid);
406  xos << "<Trapezoid name=\"" << rs.toString() << "\""
407  << " dz=\"" << rs.halfZ() << "*mm\""
408  << " theta=\"" << convertRadToDeg(rs.theta()) << "*deg\""
409  << " phi=\"" << convertRadToDeg(rs.phi()) << "*deg\""
410  << " h1=\"" << rs.y1() << "*mm\""
411  << " bl1=\"" << rs.x1() << "*mm\""
412  << " tl1=\"" << rs.x2() << "*mm\""
413  << " alp1=\"" << convertRadToDeg(rs.alpha1()) << "*deg\""
414  << " h2=\"" << rs.y2() << "*mm\""
415  << " bl2=\"" << rs.x3() << "*mm\""
416  << " tl2=\"" << rs.x4() << "*mm\""
417  << " alp2=\"" << convertRadToDeg(rs.alpha2()) << "*deg\"/>" << std::endl;
418  break;
419  }
420  case DDSolidShape::ddcons: {
421  DDCons rs(solid);
422  xos << "<Cone name=\"" << rs.toString() << "\""
423  << " dz=\"" << rs.zhalf() << "*mm\""
424  << " rMin1=\"" << rs.rInMinusZ() << "*mm\""
425  << " rMax1=\"" << rs.rOutMinusZ() << "*mm\""
426  << " rMin2=\"" << rs.rInPlusZ() << "*mm\""
427  << " rMax2=\"" << rs.rOutPlusZ() << "*mm\""
428  << " startPhi=\"" << convertRadToDeg(rs.phiFrom()) << "*deg\""
429  << " deltaPhi=\"" << convertRadToDeg(rs.deltaPhi()) << "*deg\"/>" << std::endl;
430  break;
431  }
433  DDPolycone rs(solid);
434  xos << "<Polycone name=\"" << rs.toString() << "\""
435  << " startPhi=\"" << convertRadToDeg(rs.startPhi()) << "*deg\""
436  << " deltaPhi=\"" << convertRadToDeg(rs.deltaPhi()) << "*deg\">" << std::endl;
437  const std::vector<double>& zV(rs.zVec());
438  const std::vector<double>& rV(rs.rVec());
439  for (size_t i = 0; i < zV.size(); ++i) {
440  xos << "<RZPoint r=\"" << rV[i] << "*mm\""
441  << " z=\"" << zV[i] << "*mm\"/>" << std::endl;
442  }
443  xos << "</Polycone>" << std::endl;
444  break;
445  }
447  DDPolyhedra rs(solid);
448  xos << "<Polyhedra name=\"" << rs.toString() << "\""
449  << " numSide=\"" << rs.sides() << "\""
450  << " startPhi=\"" << convertRadToDeg(rs.startPhi()) << "*deg\""
451  << " deltaPhi=\"" << convertRadToDeg(rs.deltaPhi()) << "*deg\">" << std::endl;
452  const std::vector<double>& zV(rs.zVec());
453  const std::vector<double>& rV(rs.rVec());
454  for (size_t i = 0; i < zV.size(); ++i) {
455  xos << "<RZPoint r=\"" << rV[i] << "*mm\""
456  << " z=\"" << zV[i] << "*mm\"/>" << std::endl;
457  }
458  xos << "</Polyhedra>" << std::endl;
459  break;
460  }
462  // <Polycone name="OCMS" startPhi="0*deg" deltaPhi="360*deg" >
463  // <ZSection z="-[CMSZ1]" rMin="[Rmin]" rMax="[CMSR2]" />
464  // <ZSection z="-[HallZ]" rMin="[Rmin]" rMax="[CMSR2]" />
465  // <ZSection z="-[HallZ]" rMin="[Rmin]" rMax="[HallR]" />
466  // <ZSection z="[HallZ]" rMin="[Rmin]" rMax="[HallR]" />
467  // <ZSection z="[HallZ]" rMin="[Rmin]" rMax="[CMSR2]" />
468  // <ZSection z="[CMSZ1]" rMin="[Rmin]" rMax="[CMSR2]" />
469  DDPolycone rs(solid);
470  xos << "<Polycone name=\"" << rs.toString() << "\""
471  << " startPhi=\"" << convertRadToDeg(rs.startPhi()) << "*deg\""
472  << " deltaPhi=\"" << convertRadToDeg(rs.deltaPhi()) << "*deg\">" << std::endl;
473  const std::vector<double>& zV(rs.zVec());
474  const std::vector<double>& rMinV(rs.rMinVec());
475  const std::vector<double>& rMaxV(rs.rMaxVec());
476  for (size_t i = 0; i < zV.size(); ++i) {
477  xos << "<ZSection z=\"" << zV[i] << "*mm\""
478  << " rMin=\"" << rMinV[i] << "*mm\""
479  << " rMax=\"" << rMaxV[i] << "*mm\"/>" << std::endl;
480  }
481  xos << "</Polycone>" << std::endl;
482  break;
483  }
485  DDPolyhedra rs(solid);
486  xos << "<Polyhedra name=\"" << rs.toString() << "\""
487  << " numSide=\"" << rs.sides() << "\""
488  << " startPhi=\"" << convertRadToDeg(rs.startPhi()) << "*deg\""
489  << " deltaPhi=\"" << convertRadToDeg(rs.deltaPhi()) << "*deg\">" << std::endl;
490  const std::vector<double>& zV(rs.zVec());
491  const std::vector<double>& rMinV(rs.rMinVec());
492  const std::vector<double>& rMaxV(rs.rMaxVec());
493  for (size_t i = 0; i < zV.size(); ++i) {
494  xos << "<ZSection z=\"" << zV[i] << "*mm\""
495  << " rMin=\"" << rMinV[i] << "*mm\""
496  << " rMax=\"" << rMaxV[i] << "*mm\"/>" << std::endl;
497  }
498  xos << "</Polyhedra>" << std::endl;
499  break;
500  }
502  // <PseudoTrap name="YE3_b" dx1="0.395967*m" dx2="1.86356*m" dy1="0.130*m" dy2="0.130*m" dz="2.73857*m" radius="-1.5300*m" atMinusZ="true"/>
503  DDPseudoTrap rs(solid);
504  xos << "<PseudoTrap name=\"" << rs.toString() << "\""
505  << " dx1=\"" << rs.x1() << "*mm\""
506  << " dx2=\"" << rs.x2() << "*mm\""
507  << " dy1=\"" << rs.y1() << "*mm\""
508  << " dy2=\"" << rs.y2() << "*mm\""
509  << " dz=\"" << rs.halfZ() << "*mm\""
510  << " radius=\"" << rs.radius() << "*mm\""
511  << " atMinusZ=\"" << (rs.atMinusZ() ? "true" : "false") << "\"/>" << std::endl;
512  break;
513  }
515  // <TruncTubs name="trunctubs1" zHalf="50*cm" rMin="20*cm" rMax="40*cm"
516  // startPhi="0*deg" deltaPhi="90*deg"
517  // cutAtStart="25*cm" cutAtDelta="35*cm"/>
518  DDTruncTubs rs(solid);
519  xos << "<TruncTubs name=\"" << rs.toString() << "\""
520  << " zHalf=\"" << rs.zHalf() << "*mm\""
521  << " rMin=\"" << rs.rIn() << "*mm\""
522  << " rMax=\"" << rs.rOut() << "*mm\""
523  << " startPhi=\"" << convertRadToDeg(rs.startPhi()) << "*deg\""
524  << " deltaPhi=\"" << convertRadToDeg(rs.deltaPhi()) << "*deg\""
525  << " cutAtStart=\"" << rs.cutAtStart() << "*mm\""
526  << " cutAtDelta=\"" << rs.cutAtDelta() << "*mm\""
527  << " cutInside=\"" << (rs.cutInside() ? "true" : "false") << "\"/>" << std::endl;
528  break;
529  }
532  xos << "<ShapelessSolid name=\"" << rs.toString() << "\"/>" << std::endl;
533  break;
534  }
535  case DDSolidShape::ddtorus: {
536  // <Torus name="torus" innerRadius="7.5*cm" outerRadius="10*cm"
537  // torusRadius="30*cm" startPhi="0*deg" deltaPhi="360*deg"/>
538  DDTorus rs(solid);
539  xos << "<Torus name=\"" << rs.toString() << "\""
540  << " innerRadius=\"" << rs.rMin() << "*mm\""
541  << " outerRadius=\"" << rs.rMax() << "*mm\""
542  << " torusRadius=\"" << rs.rTorus() << "*mm\""
543  << " startPhi=\"" << convertRadToDeg(rs.startPhi()) << "*deg\""
544  << " deltaPhi=\"" << convertRadToDeg(rs.deltaPhi()) << "*deg\"/>" << std::endl;
545  break;
546  }
548  // <EllipticalTube name="CMSWall" xSemiAxis="[cavernData:CMSWallEDX]"
549  // ySemiAxis="[cavernData:CMSWallEDY]"
550  // zHeight="[cms:HallZ]"/>
552  xos << "<EllipticalTube name=\"" << rs.toString() << "\""
553  << " xSemiAxis=\"" << rs.xSemiAxis() << "*mm\""
554  << " ySemiAxis=\"" << rs.ySemiAxis() << "*mm\""
555  << " zHeight=\"" << rs.zHeight() << "*mm\"/>" << std::endl;
556  break;
557  }
559  // <Tubs name="TrackerSupportTubeNomex" rMin="[SupportTubeR1]+[Tol]"
560  // rMax="[SupportTubeR2]-[Tol]" dz="[SupportTubeL]"
561  // startPhi="0*deg" deltaPhi="360*deg"/>
562  DDCutTubs rs(solid);
563  const std::array<double, 3>& pLowNorm(rs.lowNorm());
564  const std::array<double, 3>& pHighNorm(rs.highNorm());
565 
566  xos << "<CutTubs name=\"" << rs.toString() << "\""
567  << " dz=\"" << rs.zhalf() << "*mm\""
568  << " rMin=\"" << rs.rIn() << "*mm\""
569  << " rMax=\"" << rs.rOut() << "*mm\""
570  << " startPhi=\"" << convertRadToDeg(rs.startPhi()) << "*deg\""
571  << " deltaPhi=\"" << convertRadToDeg(rs.deltaPhi()) << "*deg\""
572  << " lx=\"" << pLowNorm[0] << "\""
573  << " ly=\"" << pLowNorm[1] << "\""
574  << " lz=\"" << pLowNorm[2] << "\""
575  << " tx=\"" << pHighNorm[0] << "\""
576  << " ty=\"" << pHighNorm[1] << "\""
577  << " tz=\"" << pHighNorm[2] << "\"/>" << std::endl;
578  break;
579  }
582  std::vector<double> x = rs.xVec();
583  std::vector<double> y = rs.yVec();
584  std::vector<double> z = rs.zVec();
585  std::vector<double> zx = rs.zxVec();
586  std::vector<double> zy = rs.zyVec();
587  std::vector<double> zs = rs.zscaleVec();
588 
589  xos << "<ExtrudedPolygon name=\"" << rs.toString() << "\"";
590  for (unsigned int i = 0; i < x.size(); ++i)
591  xos << " <XYPoint x=\"" << x[i] << "*mm\" y=\"" << y[i] << "*mm\"/>\n";
592  for (unsigned int k = 0; k < z.size(); ++k)
593  xos << " <ZXYSection z=\"" << z[k] << "*mm\" x=\"" << zx[k] << "*mm\" y=\"" << zy[k] << "*mm scale=" << zs[k]
594  << "*mm\"/>\n";
595  xos << "</ExtrudedPolygon>\n";
596  break;
597  }
599  default:
600  throw cms::Exception("DDException")
601  << "DDCoreToDDXMLOutput::solid(...) " << solid.name() << " either not inited or no such solid.";
602  break;
603  }
604 }
A truncated tube section.
Definition: DDSolid.h:139
This is simply a handle on the solid.
Definition: DDSolid.h:178
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
static const std::string & rotName(const T &rot, const cms::DDParsingContext &context)
Interface to a Trapezoid.
Definition: DDSolid.h:88
Interface to a Box.
Definition: DDSolid.h:167
void solid(const DDSolid &solid, std::ostream &xos)

◆ solid() [2/2]

void DDCoreToDDXMLOutput::solid ( const dd4hep::Solid &  solid,
const cms::DDParsingContext context,
std::ostream &  xos 
)

Definition at line 100 of file DDCoreToDDXMLOutput.cc.

References visDQMUpload::context, angle_units::operators::convertRadToDeg(), cms::dd_not_init, cms::ddbox, cms::ddcons, cms::ddcuttubs, cms::ddellipticaltube, cms::ddextrudedpolygon, cms::ddintersection, cms::ddpolycone, cms::ddpolyhedra, cms::DDSolidShapeMap, cms::ddsubtraction, cms::ddtorus, cms::ddtrap, cms::ddtrd1, cms::ddtrd2, cms::ddtrunctubs, cms::ddtubs, cms::ddunion, Exception, HGCalGeometryMode::ExtrudedPolygon, mps_fire::i, cms::rotation_utils::identityHash(), dqmdumpme::k, HGCalGeometryMode::Polyhedra, makeMuonMisalignmentScenario::rot, cms::rotation_utils::rotHash(), cms::rotation_utils::rotName(), AlCaHLTBitMon_QueryRunRegistry::string, cms::dd::value(), and x.

100  {
102  switch (shape) {
106  dd4hep::BooleanSolid rs(solid);
107  if (shape == cms::DDSolidShape::ddunion) {
108  xos << "<UnionSolid ";
109  } else if (shape == cms::DDSolidShape::ddsubtraction) {
110  xos << "<SubtractionSolid ";
111  } else if (shape == cms::DDSolidShape::ddintersection) {
112  xos << "<IntersectionSolid ";
113  }
114  xos << "name=\"" << trimShapeName(solid.name()) << "\">" << std::endl;
115  xos << "<rSolid name=\"" << trimShapeName(rs.leftShape().name()) << "\"/>" << std::endl;
116  xos << "<rSolid name=\"" << trimShapeName(rs.rightShape().name()) << "\"/>" << std::endl;
117  const Double_t* trans = rs.rightMatrix()->GetTranslation();
118  xos << "<Translation x=\"" << trans[0] << "*mm\"";
119  xos << " y=\"" << trans[1] << "*mm\"";
120  xos << " z=\"" << trans[2] << "*mm\"";
121  xos << "/>" << std::endl;
122  auto rot = rs.rightMatrix()->GetRotationMatrix();
123  // The identity rotation can be omitted.
126  xos << "<rRotation name=\"" << rotNameStr << "\"/>" << std::endl;
127  }
128  if (shape == cms::DDSolidShape::ddunion) {
129  xos << "</UnionSolid>" << std::endl;
130  } else if (shape == cms::DDSolidShape::ddsubtraction) {
131  xos << "</SubtractionSolid>" << std::endl;
132  } else if (shape == cms::DDSolidShape::ddintersection) {
133  xos << "</IntersectionSolid>" << std::endl;
134  }
135  break;
136  }
138  dd4hep::Box rs(solid);
139  xos << "<Box name=\"" << trimShapeName(rs.name()) << "\""
140  << " dx=\"" << rs.x() << "*mm\""
141  << " dy=\"" << rs.y() << "*mm\""
142  << " dz=\"" << rs.z() << "*mm\"/>" << std::endl;
143  break;
144  }
146  dd4hep::Tube rs(solid);
147  double startPhi = convertRadToDeg(rs.startPhi());
148  if (startPhi > 180. && startPhi <= 360.)
149  startPhi -= 360.;
150  // Convert large positive angles to small negative ones
151  // to match how they are usually defined
152 
153  xos << "<Tubs name=\"" << trimShapeName(rs.name()) << "\""
154  << " rMin=\"" << rs.rMin() << "*mm\""
155  << " rMax=\"" << rs.rMax() << "*mm\""
156  << " dz=\"" << rs.dZ() << "*mm\""
157  << " startPhi=\"" << startPhi << "*deg\""
158  << " deltaPhi=\"" << convertRadToDeg(rs.endPhi() - rs.startPhi()) << "*deg\"/>" << std::endl;
159  break;
160  }
162  dd4hep::Trd1 rs(solid);
163  xos << "<Trd1 name=\"" << trimShapeName(rs.name()) << "\""
164  << " dz=\"" << rs.dZ() << "*mm\""
165  << " dy1=\"" << rs.dY() << "*mm\""
166  << " dy2=\"" << rs.dY() << "*mm\""
167  << " dx1=\"" << rs.dX1() << "*mm\""
168  << " dx2=\"" << rs.dX2() << "*mm\"/>" << std::endl;
169  break;
170  }
172  dd4hep::Trd2 rs(solid);
173  xos << "<Trd1 name=\"" << trimShapeName(rs.name()) << "\""
174  << " dz=\"" << rs.dZ() << "*mm\""
175  << " dy1=\"" << rs.dY1() << "*mm\""
176  << " dy2=\"" << rs.dY2() << "*mm\""
177  << " dx1=\"" << rs.dX1() << "*mm\""
178  << " dx2=\"" << rs.dX2() << "*mm\"/>" << std::endl;
179  break;
180  }
182  dd4hep::Trap rs(solid);
183  xos << std::setprecision(8);
184  // Precision of 8 is needed to prevent complaints from Native Geant4 10.7 about
185  // small deviations from planarity of trapezoid faces.
186 
187  xos << "<Trapezoid name=\"" << trimShapeName(rs.name()) << "\""
188  << " dz=\"" << rs.dZ() << "*mm\""
189  << " theta=\"" << convertRadToDeg(rs.theta()) << "*deg\""
190  << " phi=\"" << convertRadToDeg(rs.phi()) << "*deg\""
191  << " h1=\"" << rs.high1() << "*mm\""
192  << " bl1=\"" << rs.bottomLow1() << "*mm\""
193  << " tl1=\"" << rs.topLow1() << "*mm\""
194  << " alp1=\"" << convertRadToDeg(rs.alpha1()) << "*deg\""
195  << " h2=\"" << rs.high2() << "*mm\""
196  << " bl2=\"" << rs.bottomLow2() << "*mm\""
197  << " tl2=\"" << rs.topLow2() << "*mm\""
198  << " alp2=\"" << convertRadToDeg(rs.alpha2()) << "*deg\"/>" << std::endl;
199  xos << std::setprecision(5);
200  // Before CMSSW_12_1_0_pre5, all solids, including Trapezoids, had precision of 5.
201  // In tests With Native Geant4 10.7, this precision caused complaints, as explained above.
202  // To minimize changes, the precision was increased only for Trapezoids.
203  // In future, when there is an opportunity to revise the geometry, it might be
204  // desirable to use precision of 8 for all solids for consistency.
205  break;
206  }
208  dd4hep::ConeSegment rs(solid);
209  double startPhi = convertRadToDeg(rs.startPhi());
210  if (startPhi > 180. && startPhi <= 360.)
211  startPhi -= 360.;
212  // Convert large positive angles to small negative ones
213  // to match how they are usually defined
214  //
215  xos << "<Cone name=\"" << trimShapeName(rs.name()) << "\""
216  << " dz=\"" << rs.dZ() << "*mm\""
217  << " rMin1=\"" << rs.rMin1() << "*mm\""
218  << " rMax1=\"" << rs.rMax1() << "*mm\""
219  << " rMin2=\"" << rs.rMin2() << "*mm\""
220  << " rMax2=\"" << rs.rMax2() << "*mm\""
221  << " startPhi=\"" << startPhi << "*deg\""
222  << " deltaPhi=\"" << convertRadToDeg(rs.endPhi() - rs.startPhi()) << "*deg\"/>" << std::endl;
223  break;
224  }
226  // <Polycone name="OCMS" startPhi="0*deg" deltaPhi="360*deg" >
227  // <ZSection z="-[CMSZ1]" rMin="[Rmin]" rMax="[CMSR2]" />
228  // <ZSection z="-[HallZ]" rMin="[Rmin]" rMax="[CMSR2]" />
229  // <ZSection z="-[HallZ]" rMin="[Rmin]" rMax="[HallR]" />
230  // <ZSection z="[HallZ]" rMin="[Rmin]" rMax="[HallR]" />
231  // <ZSection z="[HallZ]" rMin="[Rmin]" rMax="[CMSR2]" />
232  // <ZSection z="[CMSZ1]" rMin="[Rmin]" rMax="[CMSR2]" />
233  dd4hep::Polycone rs(solid);
234  xos << "<Polycone name=\"" << trimShapeName(rs.name()) << "\""
235  << " startPhi=\"" << convertRadToDeg(rs.startPhi()) << "*deg\""
236  << " deltaPhi=\"" << convertRadToDeg(rs.deltaPhi()) << "*deg\">" << std::endl;
237  const std::vector<double>& zV(rs.zPlaneZ());
238  const std::vector<double>& rMinV(rs.zPlaneRmin());
239  const std::vector<double>& rMaxV(rs.zPlaneRmax());
240  for (size_t i = 0; i < zV.size(); ++i) {
241  xos << "<ZSection z=\"" << zV[i] << "*mm\""
242  << " rMin=\"" << rMinV[i] << "*mm\""
243  << " rMax=\"" << rMaxV[i] << "*mm\"/>" << std::endl;
244  }
245  xos << "</Polycone>" << std::endl;
246  break;
247  }
250  xos << "<Polyhedra name=\"" << trimShapeName(rs.name()) << "\""
251  << " numSide=\"" << rs.numEdges() << "\""
252  << " startPhi=\"" << convertRadToDeg(rs.startPhi()) << "*deg\""
253  << " deltaPhi=\"" << convertRadToDeg(rs.deltaPhi()) << "*deg\">" << std::endl;
254  const std::vector<double>& zV(rs.zPlaneZ());
255  const std::vector<double>& rMinV(rs.zPlaneRmin());
256  const std::vector<double>& rMaxV(rs.zPlaneRmax());
257  for (size_t i = 0; i < zV.size(); ++i) {
258  xos << "<ZSection z=\"" << zV[i] << "*mm\""
259  << " rMin=\"" << rMinV[i] << "*mm\""
260  << " rMax=\"" << rMaxV[i] << "*mm\"/>" << std::endl;
261  }
262  xos << "</Polyhedra>" << std::endl;
263  break;
264  }
266  dd4hep::TruncatedTube rs(solid);
267  xos << "<TruncTubs name=\"" << trimShapeName(rs.name()) << "\""
268  << " zHalf=\"" << rs.dZ() << "*mm\""
269  << " rMin=\"" << rs.rMin() << "*mm\""
270  << " rMax=\"" << rs.rMax() << "*mm\""
271  << " startPhi=\"" << convertRadToDeg(rs.startPhi()) << "*deg\""
272  << " deltaPhi=\"" << convertRadToDeg(rs.deltaPhi()) << "*deg\""
273  << " cutAtStart=\"" << rs.cutAtStart() << "*mm\""
274  << " cutAtDelta=\"" << rs.cutAtDelta() << "*mm\""
275  << " cutInside=\"" << (rs.cutInside() ? "true" : "false") << "\"/>" << std::endl;
276  break;
277  }
279  dd4hep::Torus rs(solid);
280  xos << "<Torus name=\"" << trimShapeName(rs.name()) << "\""
281  << " innerRadius=\"" << rs.rMin() << "*mm\""
282  << " outerRadius=\"" << rs.rMax() << "*mm\""
283  << " torusRadius=\"" << rs.r() << "*mm\""
284  << " startPhi=\"" << convertRadToDeg(rs.startPhi()) << "*deg\""
285  << " deltaPhi=\"" << convertRadToDeg(rs.deltaPhi()) << "*deg\"/>" << std::endl;
286  break;
287  }
289  dd4hep::EllipticalTube rs(solid);
290  xos << "<EllipticalTube name=\"" << trimShapeName(rs.name()) << "\""
291  << " xSemiAxis=\"" << rs.a() << "*mm\""
292  << " ySemiAxis=\"" << rs.b() << "*mm\""
293  << " zHeight=\"" << rs.dZ() << "*mm\"/>" << std::endl;
294  break;
295  }
297  dd4hep::CutTube rs(solid);
298  const std::vector<double>& pLowNorm(rs.lowNormal());
299  const std::vector<double>& pHighNorm(rs.highNormal());
300 
301  xos << "<CutTubs name=\"" << trimShapeName(solid.name()) << "\""
302  << " dz=\"" << rs.dZ() << "*mm\""
303  << " rMin=\"" << rs.rMin() << "*mm\""
304  << " rMax=\"" << rs.rMax() << "*mm\""
305  << " startPhi=\"" << convertRadToDeg(rs.startPhi()) << "*deg\""
306  << " deltaPhi=\"" << convertRadToDeg(rs.endPhi() - rs.startPhi()) << "*deg\""
307  << " lx=\"" << pLowNorm[0] << "\""
308  << " ly=\"" << pLowNorm[1] << "\""
309  << " lz=\"" << pLowNorm[2] << "\""
310  << " tx=\"" << pHighNorm[0] << "\""
311  << " ty=\"" << pHighNorm[1] << "\""
312  << " tz=\"" << pHighNorm[2] << "\"/>" << std::endl;
313  break;
314  }
317  std::vector<double> x = rs.x();
318  std::vector<double> y = rs.y();
319  std::vector<double> z = rs.z();
320  std::vector<double> zx = rs.zx();
321  std::vector<double> zy = rs.zy();
322  std::vector<double> zs = rs.zscale();
323 
324  xos << "<ExtrudedPolygon name=\"" << trimShapeName(rs.name()) << "\"";
325  for (unsigned int i = 0; i < x.size(); ++i)
326  xos << " <XYPoint x=\"" << x[i] << "*mm\" y=\"" << y[i] << "*mm\"/>\n";
327  for (unsigned int k = 0; k < z.size(); ++k)
328  xos << " <ZXYSection z=\"" << z[k] << "*mm\" x=\"" << zx[k] << "*mm\" y=\"" << zy[k] << "*mm scale=" << zs[k]
329  << "*mm\"/>\n";
330  xos << "</ExtrudedPolygon>\n";
331  break;
332  }
334  default:
335  throw cms::Exception("DDException")
336  << "DDCoreToDDXMLOutput::solid " << solid.name() << ", shape ID = " << static_cast<int>(shape)
337  << ", solid title = " << solid.title();
338  break;
339  }
340 }
std::string rotHash(const Double_t *rot)
Definition: DDNamespace.cc:26
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
static std::string trimShapeName(const std::string &solidName)
static const std::string identityHash("1.00000000.00000000.00000000.00000001.00000000.00000000.00000000.00000001.0000000")
Mapping::value_type::value_type value(Mapping a, const std::string &name)
Definition: DDSolidShapes.h:42
static const std::string & rotName(const T &rot, const cms::DDParsingContext &context)
const std::array< const cms::dd::NameValuePair< DDSolidShape >, 21 > DDSolidShapeMap
Definition: DDSolidShapes.h:99
void solid(const DDSolid &solid, std::ostream &xos)
DDSolidShape
Definition: DDSolidShapes.h:73

◆ specpar() [1/3]

void DDCoreToDDXMLOutput::specpar ( const DDSpecifics sp,
std::ostream &  xos 
)

Definition at line 834 of file DDCoreToDDXMLOutput.cc.

References mps_fire::i, alignCSCRings::s, DDSpecifics::selection(), DDSpecifics::specifics(), DDBase< N, C >::toString(), and findQualityFiles::v.

834  {
835  xos << "<SpecPar name=\"" << sp.toString() << "\" eval=\"false\">" << std::endl;
836 
837  // ========... all the selection strings out as strings by using the DDPartSelection's std::ostream function...
838  for (const auto& psit : sp.selection()) {
839  xos << "<PartSelector path=\"" << psit << "\"/>" << std::endl;
840  }
841 
842  // ========= ... and iterate over all DDValues...
843  for (const auto& vit : sp.specifics()) {
844  const DDValue& v = vit.second;
845  size_t s = v.size();
846  size_t i = 0;
847  // ============ ... all actual values with the same name
848  const std::vector<std::string>& strvec = v.strings();
849  if (v.isEvaluated()) {
850  for (; i < s; ++i) {
851  xos << "<Parameter name=\"" << v.name() << "\""
852  << " value=\"" << v[i] << "\""
853  << " eval=\"true\"/>" << std::endl;
854  }
855  } else {
856  for (; i < s; ++i) {
857  xos << "<Parameter name=\"" << v.name() << "\""
858  << " value=\"" << strvec[i] << "\""
859  << " eval=\"false\"/>" << std::endl;
860  }
861  }
862  }
863  xos << "</SpecPar>" << std::endl;
864 }
const std::vector< DDPartSelection > & selection() const
Gives a reference to the collection of part-selections.
Definition: DDSpecifics.cc:34
const DDsvalues_type & specifics() const
Reference to the user-data attached to all nodes selected by the selections-strings given through sel...
Definition: DDSpecifics.cc:36
std::string toString() const
Definition: DDBase.h:63

◆ specpar() [2/3]

void DDCoreToDDXMLOutput::specpar ( const std::pair< DDsvalues_type, std::set< const DDPartSelection *>> &  pssv,
std::ostream &  xos 
)

Definition at line 890 of file DDCoreToDDXMLOutput.cc.

References mps_fire::i, alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, and findQualityFiles::v.

891  {
892  static const std::string madeName("specparname");
893  static int numspecpars(0);
894  std::ostringstream ostr;
895  ostr << numspecpars++;
896  std::string spname = madeName + ostr.str();
897  xos << "<SpecPar name=\"" << spname << "\" eval=\"false\">" << std::endl;
898  for (const auto& psit : pssv.second) {
899  xos << "<PartSelector path=\"" << *psit << "\"/>" << std::endl;
900  }
901 
902  // ========= ... and iterate over all DDValues...
903  for (const auto& vit : pssv.first) {
904  const DDValue& v = vit.second;
905  size_t s = v.size();
906  size_t i = 0;
907  // ============ ... all actual values with the same name
908  const std::vector<std::string>& strvec = v.strings();
909  if (v.isEvaluated()) {
910  for (; i < s; ++i) {
911  xos << "<Parameter name=\"" << v.name() << "\""
912  << " value=\"" << v[i] << "\""
913  << " eval=\"true\"/>" << std::endl;
914  }
915  } else {
916  for (; i < s; ++i) {
917  xos << "<Parameter name=\"" << v.name() << "\""
918  << " value=\"" << strvec[i] << "\""
919  << " eval=\"false\"/>" << std::endl;
920  }
921  }
922  }
923 
924  xos << "</SpecPar>" << std::endl;
925 }

◆ specpar() [3/3]

void DDCoreToDDXMLOutput::specpar ( const std::string &  name,
const dd4hep::SpecPar &  specPar,
std::ostream &  xos 
)

Definition at line 866 of file DDCoreToDDXMLOutput.cc.

References Skims_PA_cff::name.

866  {
867  xos << "<SpecPar name=\"" << name << "\" eval=\"false\">" << std::endl;
868 
869  for (const auto& psit : specPar.paths) {
870  xos << "<PartSelector path=\"" << psit << "\"/>" << std::endl;
871  }
872 
873  for (const auto& vit : specPar.spars) {
874  for (const auto& sit : vit.second) {
875  xos << "<Parameter name=\"" << vit.first << "\""
876  << " value=\"" << sit << "\""
877  << " eval=\"false\"/>" << std::endl;
878  }
879  }
880  for (const auto& vit : specPar.numpars) {
881  for (const auto& sit : vit.second) {
882  xos << "<Parameter name=\"" << vit.first << "\""
883  << " value=\"" << sit << "\""
884  << " eval=\"true\"/>" << std::endl;
885  }
886  }
887  xos << "</SpecPar>" << std::endl;
888 }

◆ trimShapeName()

std::string DDCoreToDDXMLOutput::trimShapeName ( const std::string &  solidName)
static

Definition at line 93 of file DDCoreToDDXMLOutput.cc.

Referenced by OutputDD4hepToDDL::beginRun().

93  {
94  size_t trimPt = solidName.find("_shape_0x");
95  if (trimPt != std::string::npos)
96  return (solidName.substr(0, trimPt));
97  return (solidName);
98 }

Member Data Documentation

◆ ns_

std::string DDCoreToDDXMLOutput::ns_

Definition at line 78 of file DDCoreToDDXMLOutput.h.