Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:26

0001 #include "DetectorDescription/Core/interface/DDSolid.h"
0002 #include "DetectorDescription/Core/interface/DDSolidShapes.h"
0003 
0004 #include <ostream>
0005 #include <string>
0006 #include <array>
0007 
0008 #include "DetectorDescription/Core/interface/Assembly.h"
0009 #include "DetectorDescription/Core/interface/Boolean.h"
0010 #include "DetectorDescription/Core/interface/Box.h"
0011 #include "DetectorDescription/Core/interface/Cons.h"
0012 #include "DetectorDescription/Core/interface/EllipticalTube.h"
0013 #include "DetectorDescription/Core/interface/ExtrudedPolygon.h"
0014 #include "DetectorDescription/Core/interface/Polycone.h"
0015 #include "DetectorDescription/Core/interface/Polyhedra.h"
0016 #include "DetectorDescription/Core/interface/PseudoTrap.h"
0017 #include "DetectorDescription/Core/src/Shapeless.h"
0018 #include "DetectorDescription/Core/interface/Solid.h"
0019 #include "DetectorDescription/Core/interface/Sphere.h"
0020 #include "DetectorDescription/Core/interface/Torus.h"
0021 #include "DetectorDescription/Core/interface/Trap.h"
0022 #include "DetectorDescription/Core/interface/TruncTubs.h"
0023 #include "DetectorDescription/Core/interface/Tubs.h"
0024 #include "DetectorDescription/Core/interface/CutTubs.h"
0025 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0026 #include "FWCore/Utilities/interface/Exception.h"
0027 
0028 using DDI::Solid;
0029 
0030 std::ostream& operator<<(std::ostream& os, const DDSolidShape s) {
0031   return os << "DDSolidShape index:" << static_cast<int>(s) << ", name: " << DDSolidShapesName::name(s);
0032 }
0033 
0034 std::ostream& operator<<(std::ostream& os, const DDSolid& solid) {
0035   DDBase<DDName, DDI::Solid*>::def_type defined(solid.isDefined());
0036   if (defined.first) {
0037     os << *(defined.first) << " ";
0038     if (defined.second) {
0039       os << "  " << DDSolidShapesName::name(solid.shape()) << ": ";
0040       solid.rep().stream(os);
0041     } else {
0042       os << "* solid not defined * ";
0043     }
0044   } else {
0045     os << "* solid not declared * ";
0046   }
0047   return os;
0048 }
0049 
0050 DDSolid::DDSolid() : DDBase<DDName, std::unique_ptr<Solid>>() {}
0051 
0052 DDSolid::DDSolid(const DDName& name) : DDBase<DDName, std::unique_ptr<Solid>>() { create(name); }
0053 
0054 DDSolid::DDSolid(const DDName& name, std::unique_ptr<Solid> solid) : DDBase<DDName, std::unique_ptr<Solid>>() {
0055   create(name, std::move(solid));
0056 }
0057 
0058 DDSolid::DDSolid(const DDName& name, DDSolidShape shape, const std::vector<double>& pars) {
0059   std::unique_ptr<DDI::Solid> solid(nullptr);
0060   std::vector<double> dummy;
0061   switch (shape) {
0062     case DDSolidShape::ddbox:
0063       solid = std::make_unique<DDI::Box>(0, 0, 0);
0064       break;
0065     case DDSolidShape::ddtubs:
0066       solid = std::make_unique<DDI::Tubs>(0, 0, 0, 0, 0);
0067       break;
0068     case DDSolidShape::ddcons:
0069       solid = std::make_unique<DDI::Cons>(0, 0, 0, 0, 0, 0, 0);
0070       break;
0071     case DDSolidShape::ddpseudotrap:
0072       solid = std::make_unique<DDI::PseudoTrap>(0, 0, 0, 0, 0, 0, false);
0073       break;
0074     case DDSolidShape::ddshapeless:
0075       solid = std::make_unique<DDI::Shapeless>();
0076       break;
0077     case DDSolidShape::ddtrap:
0078       solid = std::make_unique<DDI::Trap>(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
0079       break;
0080     case DDSolidShape::ddpolyhedra_rz:
0081       solid = std::make_unique<DDI::Polyhedra>(0, 0, 0, dummy, dummy);
0082       break;
0083     case DDSolidShape::ddpolyhedra_rrz:
0084       solid = std::make_unique<DDI::Polyhedra>(0, 0, 0, dummy, dummy, dummy);
0085       break;
0086     case DDSolidShape::ddpolycone_rz:
0087       solid = std::make_unique<DDI::Polycone>(0, 0, dummy, dummy);
0088       break;
0089     case DDSolidShape::ddpolycone_rrz:
0090       solid = std::make_unique<DDI::Polycone>(0, 0, dummy, dummy, dummy);
0091       break;
0092     case DDSolidShape::ddtrunctubs:
0093       solid = std::make_unique<DDI::TruncTubs>(0, 0, 0, 0, 0, 0, 0, false);
0094       break;
0095     case DDSolidShape::ddtorus:
0096       solid = std::make_unique<DDI::Torus>(0, 0, 0, 0, 0);
0097       break;
0098     case DDSolidShape::ddsphere:
0099       solid = std::make_unique<DDI::Sphere>(0, 0, 0, 0, 0, 0);
0100       break;
0101     case DDSolidShape::ddellipticaltube:
0102       solid = std::make_unique<DDI::EllipticalTube>(0, 0, 0);
0103       break;
0104     case DDSolidShape::ddcuttubs:
0105       solid = std::make_unique<DDI::CutTubs>(0., 0., 0., 0., 0., 0., 0., 1., 0., 0., -1.);
0106       break;
0107     case DDSolidShape::ddextrudedpolygon:
0108       solid = std::make_unique<DDI::ExtrudedPolygon>(dummy, dummy, dummy, dummy, dummy, dummy);
0109       break;
0110     case DDSolidShape::ddassembly:
0111       solid = std::make_unique<DDI::Assembly>();
0112       break;
0113     default:
0114       throw cms::Exception("DDException")
0115           << "DDSolid::DDSolid( DDName, DDSolidShape, std::vector<double> ): wrong shape.";
0116   }
0117   solid->setParameters(pars);
0118   create(name, std::move(solid));
0119 }
0120 
0121 double DDSolid::volume() const { return rep().volume(); }
0122 
0123 DDSolidShape DDSolid::shape() const { return rep().shape(); }
0124 
0125 const std::vector<double>& DDSolid::parameters() const { return rep().parameters(); }
0126 
0127 DDTrap::DDTrap(const DDSolid& s) : DDSolid(s) {
0128   if (s.shape() != DDSolidShape::ddtrap) {
0129     std::string ex = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is no DDTrap.\n";
0130     ex = ex + "Use a different solid interface!";
0131     throw cms::Exception("DDException") << ex;
0132   }
0133 }
0134 
0135 double DDTrap::halfZ() const { return rep().parameters()[0]; }
0136 
0137 double DDTrap::theta() const { return rep().parameters()[1]; }
0138 
0139 double DDTrap::phi() const { return rep().parameters()[2]; }
0140 
0141 double DDTrap::y1() const { return rep().parameters()[3]; }
0142 
0143 double DDTrap::x1() const { return rep().parameters()[4]; }
0144 
0145 double DDTrap::x2() const { return rep().parameters()[5]; }
0146 
0147 double DDTrap::alpha1() const { return rep().parameters()[6]; }
0148 
0149 double DDTrap::y2() const { return rep().parameters()[7]; }
0150 
0151 double DDTrap::x3() const { return rep().parameters()[8]; }
0152 
0153 double DDTrap::x4() const { return rep().parameters()[9]; }
0154 
0155 double DDTrap::alpha2() const { return rep().parameters()[10]; }
0156 
0157 DDTruncTubs::DDTruncTubs(const DDSolid& s) : DDSolid(s) {
0158   if (s.shape() != DDSolidShape::ddtrunctubs) {
0159     edm::LogError("DDSolid") << "s.shape()=" << s.shape() << "  " << s.name() << std::endl;
0160     std::string ex = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is no DDTruncTubs\n";
0161     ex = ex + "Use a different solid interface!";
0162     throw cms::Exception("DDException") << ex;
0163   }
0164 }
0165 
0166 double DDTruncTubs::zHalf() const { return rep().parameters()[0]; }
0167 
0168 double DDTruncTubs::rIn() const { return rep().parameters()[1]; }
0169 
0170 double DDTruncTubs::rOut() const { return rep().parameters()[2]; }
0171 
0172 double DDTruncTubs::startPhi() const { return rep().parameters()[3]; }
0173 
0174 double DDTruncTubs::deltaPhi() const { return rep().parameters()[4]; }
0175 
0176 double DDTruncTubs::cutAtStart() const { return rep().parameters()[5]; }
0177 
0178 double DDTruncTubs::cutAtDelta() const { return rep().parameters()[6]; }
0179 
0180 bool DDTruncTubs::cutInside() const { return bool(rep().parameters()[7]); }
0181 
0182 DDPseudoTrap::DDPseudoTrap(const DDSolid& s) : DDSolid(s) {
0183   if (s.shape() != DDSolidShape::ddpseudotrap) {
0184     std::string ex = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is no DDPseudoTrap\n";
0185     ex = ex + "Use a different solid interface!";
0186     throw cms::Exception("DDException") << ex;
0187   }
0188 }
0189 
0190 double DDPseudoTrap::halfZ() const { return rep().parameters()[4]; }
0191 
0192 double DDPseudoTrap::x1() const { return rep().parameters()[0]; }
0193 
0194 double DDPseudoTrap::x2() const { return rep().parameters()[1]; }
0195 
0196 double DDPseudoTrap::y1() const { return rep().parameters()[2]; }
0197 
0198 double DDPseudoTrap::y2() const { return rep().parameters()[3]; }
0199 
0200 double DDPseudoTrap::radius() const { return rep().parameters()[5]; }
0201 
0202 bool DDPseudoTrap::atMinusZ() const { return rep().parameters()[6]; }
0203 
0204 DDBox::DDBox(const DDSolid& s) : DDSolid(s) {
0205   if (s.shape() != DDSolidShape::ddbox) {
0206     std::string ex = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDBox.\n";
0207     ex = ex + "Use a different solid interface!";
0208     throw cms::Exception("DDException") << ex;
0209   }
0210 }
0211 
0212 double DDBox::halfX() const { return rep().parameters()[0]; }
0213 
0214 double DDBox::halfY() const { return rep().parameters()[1]; }
0215 
0216 double DDBox::halfZ() const { return rep().parameters()[2]; }
0217 
0218 DDShapelessSolid::DDShapelessSolid(const DDSolid& s) : DDSolid(s) {
0219   if (s.shape() != DDSolidShape::ddshapeless) {
0220     std::string ex = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDShapelessSolid.\n";
0221     ex = ex + "Use a different solid interface!";
0222     throw cms::Exception("DDException") << ex;
0223   }
0224 }
0225 
0226 DDUnion::DDUnion(const DDSolid& s) : DDBooleanSolid(s) {
0227   if (s.shape() != DDSolidShape::ddunion) {
0228     std::string ex = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDUnion.\n";
0229     ex = ex + "Use a different solid interface!";
0230     throw cms::Exception("DDException") << ex;
0231   }
0232 }
0233 
0234 DDIntersection::DDIntersection(const DDSolid& s) : DDBooleanSolid(s) {
0235   if (s.shape() != DDSolidShape::ddunion) {
0236     std::string ex = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDIntersection.\n";
0237     ex = ex + "Use a different solid interface!";
0238     throw cms::Exception("DDException") << ex;
0239   }
0240 }
0241 
0242 DDSubtraction::DDSubtraction(const DDSolid& s) : DDBooleanSolid(s) {
0243   if (s.shape() != DDSolidShape::ddsubtraction) {
0244     std::string ex = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is no DDSubtraction.\n";
0245     ex = ex + "Use a different solid interface!";
0246     throw cms::Exception("DDException") << ex;
0247   }
0248 }
0249 
0250 DDPolySolid::DDPolySolid(const DDSolid& s) : DDSolid(s) {}
0251 
0252 std::vector<double> DDPolySolid::getVec(const size_t& which, const size_t& offset, const size_t& numVecs) const {
0253   // which:  first second or third std::vector
0254   // offset: number of non-std::vector components before std::vectors start
0255   if ((rep().parameters().size() - offset) % numVecs != 0) {
0256     edm::LogError("DDSolid") << "Could not find equal sized components of std::vectors in a PolySolid description."
0257                              << "rep().parameters().size()=" << rep().parameters().size() << "  numVecs=" << numVecs
0258                              << "  offset=" << offset << std::endl;
0259   }
0260   std::vector<double> tvec;
0261   for (size_t i = offset + which; i < rep().parameters().size(); i = i + numVecs) {
0262     tvec.emplace_back(rep().parameters()[i]);
0263   }
0264   return tvec;
0265 }
0266 
0267 DDPolycone::DDPolycone(const DDSolid& s) : DDPolySolid(s) {
0268   if (s.shape() != DDSolidShape::ddpolycone_rz && s.shape() != DDSolidShape::ddpolycone_rrz) {
0269     std::string ex = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDPolycone.\n";
0270     ex = ex + "Use a different solid interface!";
0271     throw cms::Exception("DDException") << ex;
0272   }
0273 }
0274 
0275 double DDPolycone::startPhi() const { return rep().parameters()[0]; }
0276 
0277 double DDPolycone::deltaPhi() const { return rep().parameters()[1]; }
0278 
0279 std::vector<double> DDPolycone::rVec() const {
0280   std::vector<double> tvec;
0281   if (shape() == DDSolidShape::ddpolycone_rz)
0282     tvec = getVec(1, 2, 2);
0283   return tvec;
0284 }
0285 
0286 std::vector<double> DDPolycone::zVec() const {
0287   if (shape() == DDSolidShape::ddpolycone_rz)
0288     return getVec(0, 2, 2);
0289   else  // (shape() == DDSolidShape::ddpolycone_rrz)
0290     return getVec(0, 2, 3);
0291 }
0292 
0293 std::vector<double> DDPolycone::rMinVec() const {
0294   std::vector<double> tvec;
0295   if (shape() == DDSolidShape::ddpolycone_rrz)
0296     tvec = getVec(1, 2, 3);
0297   return tvec;
0298 }
0299 
0300 std::vector<double> DDPolycone::rMaxVec() const {
0301   std::vector<double> tvec;
0302   if (shape() == DDSolidShape::ddpolycone_rrz)
0303     tvec = getVec(2, 2, 3);
0304   return tvec;
0305 }
0306 
0307 DDPolyhedra::DDPolyhedra(const DDSolid& s) : DDPolySolid(s) {
0308   if (s.shape() != DDSolidShape::ddpolyhedra_rz && s.shape() != DDSolidShape::ddpolyhedra_rrz) {
0309     std::string ex = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDPolyhedra.\n";
0310     ex = ex + "Use a different solid interface!";
0311     throw cms::Exception("DDException") << ex;
0312   }
0313 }
0314 
0315 int DDPolyhedra::sides() const { return int(rep().parameters()[0]); }
0316 
0317 double DDPolyhedra::startPhi() const { return rep().parameters()[1]; }
0318 
0319 double DDPolyhedra::deltaPhi() const { return rep().parameters()[2]; }
0320 
0321 std::vector<double> DDPolyhedra::rVec() const {
0322   std::vector<double> tvec;
0323   if (shape() == DDSolidShape::ddpolyhedra_rz)
0324     tvec = getVec(1, 3, 2);
0325   return tvec;
0326 }
0327 
0328 std::vector<double> DDPolyhedra::zVec() const {
0329   if (shape() == DDSolidShape::ddpolyhedra_rz)
0330     return getVec(0, 3, 2);
0331   else  // (shape() == ddpolycone_rrz)
0332     return getVec(0, 3, 3);
0333 }
0334 
0335 std::vector<double> DDPolyhedra::rMinVec() const {
0336   std::vector<double> tvec;
0337   if (shape() == DDSolidShape::ddpolyhedra_rrz)
0338     tvec = getVec(1, 3, 3);
0339   return tvec;
0340 }
0341 
0342 std::vector<double> DDPolyhedra::rMaxVec() const {
0343   std::vector<double> tvec;
0344   if (shape() == DDSolidShape::ddpolyhedra_rrz)
0345     tvec = getVec(2, 3, 3);
0346   return tvec;
0347 }
0348 
0349 DDExtrudedPolygon::DDExtrudedPolygon(const DDSolid& s) : DDPolySolid(s) {
0350   if (s.shape() != DDSolidShape::ddextrudedpolygon) {
0351     std::string ex = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDExtrudedPolygon.\n";
0352     ex = ex + "Use a different solid interface!";
0353     throw cms::Exception("DDException") << ex;
0354   }
0355 }
0356 
0357 auto DDExtrudedPolygon::xyPointsSize(void) const -> std::size_t {
0358   // Compute the size of the X and Y coordinate vectors
0359   // which define the vertices of the outlined polygon
0360   // defined in clock-wise order
0361 
0362   return (rep().parameters().size() - 4 * zSectionsSize()) * 0.5;
0363 }
0364 
0365 auto DDExtrudedPolygon::zSectionsSize(void) const -> std::size_t {
0366   // The first parameters element stores a size of the four equal size vectors
0367   // which form the ExtrudedPolygon shape Z sections:
0368   //
0369   //    * first: Z coordinate of the XY polygone plane,
0370   //    * second and third: x and y offset of the polygone in the XY plane,
0371   //    * fourth: the polygone scale in each XY plane
0372   //
0373   // The Z sections defined by the z position in an increasing order.
0374 
0375   return rep().parameters()[0];
0376 }
0377 
0378 std::vector<double> DDExtrudedPolygon::xVec(void) const {
0379   return std::vector<double>(rep().parameters().begin() + 1, rep().parameters().begin() + 1 + xyPointsSize());
0380 }
0381 
0382 std::vector<double> DDExtrudedPolygon::yVec(void) const {
0383   return std::vector<double>(rep().parameters().begin() + 1 + xyPointsSize(),
0384                              rep().parameters().begin() + 1 + 2 * xyPointsSize());
0385 }
0386 
0387 std::vector<double> DDExtrudedPolygon::zVec(void) const {
0388   return std::vector<double>(rep().parameters().end() - 4 * zSectionsSize(),
0389                              rep().parameters().end() - 3 * zSectionsSize());
0390 }
0391 
0392 std::vector<double> DDExtrudedPolygon::zxVec(void) const {
0393   return std::vector<double>(rep().parameters().end() - 3 * zSectionsSize(),
0394                              rep().parameters().end() - 2 * zSectionsSize());
0395 }
0396 
0397 std::vector<double> DDExtrudedPolygon::zyVec(void) const {
0398   return std::vector<double>(rep().parameters().end() - 2 * zSectionsSize(),
0399                              rep().parameters().end() - zSectionsSize());
0400 }
0401 
0402 std::vector<double> DDExtrudedPolygon::zscaleVec(void) const {
0403   return std::vector<double>(rep().parameters().end() - zSectionsSize(), rep().parameters().end());
0404 }
0405 
0406 DDCons::DDCons(const DDSolid& s) : DDSolid(s) {
0407   if (s.shape() != DDSolidShape::ddcons) {
0408     std::string ex = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDCons.\n";
0409     ex = ex + "Use a different solid interface!";
0410     throw cms::Exception("DDException") << ex;
0411   }
0412 }
0413 
0414 double DDCons::zhalf() const { return rep().parameters()[0]; }
0415 
0416 double DDCons::rInMinusZ() const { return rep().parameters()[1]; }
0417 
0418 double DDCons::rOutMinusZ() const { return rep().parameters()[2]; }
0419 
0420 double DDCons::rInPlusZ() const { return rep().parameters()[3]; }
0421 
0422 double DDCons::rOutPlusZ() const { return rep().parameters()[4]; }
0423 
0424 double DDCons::phiFrom() const { return rep().parameters()[5]; }
0425 
0426 double DDCons::deltaPhi() const { return rep().parameters()[6]; }
0427 
0428 DDTorus::DDTorus(const DDSolid& s) : DDSolid(s) {
0429   if (s.shape() != DDSolidShape::ddtorus) {
0430     std::string ex = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDTorus.\n";
0431     ex = ex + "Use a different solid interface!";
0432     throw cms::Exception("DDException") << ex;
0433   }
0434 }
0435 
0436 double DDTorus::rMin() const { return rep().parameters()[0]; }
0437 
0438 double DDTorus::rMax() const { return rep().parameters()[1]; }
0439 
0440 double DDTorus::rTorus() const { return rep().parameters()[2]; }
0441 
0442 double DDTorus::startPhi() const { return rep().parameters()[3]; }
0443 
0444 double DDTorus::deltaPhi() const { return rep().parameters()[4]; }
0445 
0446 DDTubs::DDTubs(const DDSolid& s) : DDSolid(s) {
0447   if (s.shape() != DDSolidShape::ddtubs) {
0448     std::string ex = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDTubs.\n";
0449     ex = ex + "Use a different solid interface!";
0450     throw cms::Exception("DDException") << ex;
0451   }
0452 }
0453 
0454 double DDTubs::zhalf() const { return rep().parameters()[0]; }
0455 
0456 double DDTubs::rIn() const { return rep().parameters()[1]; }
0457 
0458 double DDTubs::rOut() const { return rep().parameters()[2]; }
0459 
0460 double DDTubs::startPhi() const { return rep().parameters()[3]; }
0461 
0462 double DDTubs::deltaPhi() const { return rep().parameters()[4]; }
0463 
0464 DDBooleanSolid::DDBooleanSolid(const DDSolid& s) : DDSolid(s), boolean_(static_cast<DDI::BooleanSolid&>(s.rep())) {}
0465 
0466 DDRotation DDBooleanSolid::rotation() const { return boolean_.r(); }
0467 
0468 DDTranslation DDBooleanSolid::translation() const { return boolean_.t(); }
0469 
0470 DDSolid DDBooleanSolid::solidA() const { return boolean_.a(); }
0471 
0472 DDSolid DDBooleanSolid::solidB() const { return boolean_.b(); }
0473 
0474 DDSphere::DDSphere(const DDSolid& s) : DDSolid(s) {
0475   if (s.shape() != DDSolidShape::ddsphere) {
0476     std::string ex = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDSphere (or sphere section).\n";
0477     ex = ex + "Use a different solid interface!";
0478     throw cms::Exception("DDException") << ex;
0479   }
0480 }
0481 
0482 double DDSphere::innerRadius() const { return rep().parameters()[0]; }
0483 
0484 double DDSphere::outerRadius() const { return rep().parameters()[1]; }
0485 
0486 double DDSphere::startPhi() const { return rep().parameters()[2]; }
0487 
0488 double DDSphere::deltaPhi() const { return rep().parameters()[3]; }
0489 
0490 double DDSphere::startTheta() const { return rep().parameters()[4]; }
0491 
0492 double DDSphere::deltaTheta() const { return rep().parameters()[5]; }
0493 
0494 DDEllipticalTube::DDEllipticalTube(const DDSolid& s) : DDSolid(s) {
0495   if (s.shape() != DDSolidShape::ddellipticaltube) {
0496     std::string ex = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDEllipticalTube.\n";
0497     ex = ex + "Use a different solid interface!";
0498     throw cms::Exception("DDException") << ex;
0499   }
0500 }
0501 
0502 double DDEllipticalTube::xSemiAxis() const { return rep().parameters()[0]; }
0503 
0504 double DDEllipticalTube::ySemiAxis() const { return rep().parameters()[1]; }
0505 
0506 double DDEllipticalTube::zHeight() const { return rep().parameters()[2]; }
0507 
0508 DDCutTubs::DDCutTubs(const DDSolid& s) : DDSolid(s) {
0509   if (s.shape() != DDSolidShape::ddcuttubs) {
0510     std::string ex = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDCutTubs.\n";
0511     ex = ex + "Use a different solid interface!";
0512     throw cms::Exception("DDException") << ex;
0513   }
0514 }
0515 
0516 double DDCutTubs::zhalf() const { return rep().parameters()[0]; }
0517 
0518 double DDCutTubs::rIn() const { return rep().parameters()[1]; }
0519 
0520 double DDCutTubs::rOut() const { return rep().parameters()[2]; }
0521 
0522 double DDCutTubs::startPhi() const { return rep().parameters()[3]; }
0523 
0524 double DDCutTubs::deltaPhi() const { return rep().parameters()[4]; }
0525 
0526 std::array<double, 3> DDCutTubs::lowNorm(void) const {
0527   return std::array<double, 3>{{rep().parameters()[5], rep().parameters()[6], rep().parameters()[7]}};
0528 }
0529 
0530 std::array<double, 3> DDCutTubs::highNorm(void) const {
0531   return std::array<double, 3>{{rep().parameters()[8], rep().parameters()[9], rep().parameters()[10]}};
0532 }
0533 
0534 DDAssembly::DDAssembly(const DDSolid& s) : DDSolid(s) {
0535   if (s.shape() != DDSolidShape::ddassembly) {
0536     std::string ex = "Solid [" + s.name().ns() + ":" + s.name().name() + "] is not a DDAssembly.\n";
0537     ex = ex + "Use a different solid interface!";
0538     throw cms::Exception("DDException") << ex;
0539   }
0540 }
0541 
0542 // =================================================================================
0543 // =========================SolidFactory============================================
0544 
0545 DDSolid DDSolidFactory::assembly(const DDName& name) { return DDSolid(name, std::make_unique<DDI::Assembly>()); }
0546 
0547 DDSolid DDSolidFactory::box(const DDName& name, double xHalf, double yHalf, double zHalf) {
0548   return DDSolid(name, std::make_unique<DDI::Box>(xHalf, yHalf, zHalf));
0549 }
0550 
0551 DDSolid DDSolidFactory::polycone(const DDName& name,
0552                                  double startPhi,
0553                                  double deltaPhi,
0554                                  const std::vector<double>& z,
0555                                  const std::vector<double>& rmin,
0556                                  const std::vector<double>& rmax) {
0557   return DDSolid(name, std::make_unique<DDI::Polycone>(startPhi, deltaPhi, z, rmin, rmax));
0558 }
0559 
0560 DDSolid DDSolidFactory::polycone(
0561     const DDName& name, double startPhi, double deltaPhi, const std::vector<double>& z, const std::vector<double>& r) {
0562   return DDSolid(name, std::make_unique<DDI::Polycone>(startPhi, deltaPhi, z, r));
0563 }
0564 
0565 DDSolid DDSolidFactory::polyhedra(const DDName& name,
0566                                   int sides,
0567                                   double startPhi,
0568                                   double deltaPhi,
0569                                   const std::vector<double>& z,
0570                                   const std::vector<double>& rmin,
0571                                   const std::vector<double>& rmax) {
0572   return DDSolid(name, std::make_unique<DDI::Polyhedra>(sides, startPhi, deltaPhi, z, rmin, rmax));
0573 }
0574 
0575 DDSolid DDSolidFactory::polyhedra(const DDName& name,
0576                                   int sides,
0577                                   double startPhi,
0578                                   double deltaPhi,
0579                                   const std::vector<double>& z,
0580                                   const std::vector<double>& r) {
0581   return DDSolid(name, std::make_unique<DDI::Polyhedra>(sides, startPhi, deltaPhi, z, r));
0582 }
0583 
0584 DDSolid DDSolidFactory::extrudedpolygon(const DDName& name,
0585                                         const std::vector<double>& x,
0586                                         const std::vector<double>& y,
0587                                         const std::vector<double>& z,
0588                                         const std::vector<double>& zx,
0589                                         const std::vector<double>& zy,
0590                                         const std::vector<double>& zscale) {
0591   return DDSolid(name, std::make_unique<DDI::ExtrudedPolygon>(x, y, z, zx, zy, zscale));
0592 }
0593 
0594 DDSolid DDSolidFactory::unionSolid(
0595     const DDName& name, const DDSolid& a, const DDSolid& b, const DDTranslation& t, const DDRotation& r) {
0596   return DDSolid(name, std::make_unique<DDI::Union>(a, b, t, r));
0597 }
0598 
0599 DDSolid DDSolidFactory::subtraction(
0600     const DDName& name, const DDSolid& a, const DDSolid& b, const DDTranslation& t, const DDRotation& r) {
0601   return DDSolid(name, std::make_unique<DDI::Subtraction>(a, b, t, r));
0602 }
0603 
0604 DDSolid DDSolidFactory::intersection(
0605     const DDName& name, const DDSolid& a, const DDSolid& b, const DDTranslation& t, const DDRotation& r) {
0606   return DDSolid(name, std::make_unique<DDI::Intersection>(a, b, t, r));
0607 }
0608 
0609 DDSolid DDSolidFactory::trap(const DDName& name,
0610                              double pDz,
0611                              double pTheta,
0612                              double pPhi,
0613                              double pDy1,
0614                              double pDx1,
0615                              double pDx2,
0616                              double pAlp1,
0617                              double pDy2,
0618                              double pDx3,
0619                              double pDx4,
0620                              double pAlp2) {
0621   return DDSolid(name,
0622                  std::make_unique<DDI::Trap>(pDz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2));
0623 }
0624 
0625 DDSolid DDSolidFactory::pseudoTrap(const DDName& name,
0626                                    double pDx1,   /**< Half-length along x at the surface positioned at -dz */
0627                                    double pDx2,   /**<  Half-length along x at the surface positioned at +dz */
0628                                    double pDy1,   /**<  Half-length along y at the surface positioned at -dz */
0629                                    double pDy2,   /**<  Half-length along y at the surface positioned at +dz */
0630                                    double pDz,    /**< Half of the height of the pseudo trapezoid along z */
0631                                    double radius, /**< radius of the cut-out (negative sign) or rounding (pos. sign) */
0632                                    bool atMinusZ /**< if true, the cut-out or rounding is applied at -dz, else at +dz */
0633 ) {
0634   return DDSolid(name, std::make_unique<DDI::PseudoTrap>(pDx1, pDx2, pDy1, pDy2, pDz, radius, atMinusZ));
0635 }
0636 
0637 DDSolid DDSolidFactory::truncTubs(const DDName& name,
0638                                   double zHalf,      /**< half-length of the z-axis */
0639                                   double rIn,        /**< inner radius of the tube-section */
0640                                   double rOut,       /**< outer radius of the tube-section */
0641                                   double startPhi,   /**< starting angle of the tube-section */
0642                                   double deltaPhi,   /**< spanning angle of the tube-section */
0643                                   double cutAtStart, /**< tructation at startPhi side */
0644                                   double cutAtDelta, /**< truncation at deltaPhi side */
0645                                   bool cutInside) {
0646   return DDSolid(
0647       name, std::make_unique<DDI::TruncTubs>(zHalf, rIn, rOut, startPhi, deltaPhi, cutAtStart, cutAtDelta, cutInside));
0648 }
0649 
0650 DDSolid DDSolidFactory::cons(const DDName& name,
0651                              double zhalf,
0652                              double rInMinusZ,
0653                              double rOutMinusZ,
0654                              double rInPlusZ,
0655                              double rOutPlusZ,
0656                              double phiFrom,
0657                              double deltaPhi) {
0658   return DDSolid(name,
0659                  std::make_unique<DDI::Cons>(zhalf, rInMinusZ, rOutMinusZ, rInPlusZ, rOutPlusZ, phiFrom, deltaPhi));
0660 }
0661 
0662 DDSolid DDSolidFactory::torus(
0663     const DDName& name, double rMin, double rMax, double rTorus, double startPhi, double deltaPhi) {
0664   return DDSolid(name, std::make_unique<DDI::Torus>(rMin, rMax, rTorus, startPhi, deltaPhi));
0665 }
0666 
0667 DDSolid DDSolidFactory::tubs(
0668     const DDName& name, double zhalf, double rIn, double rOut, double phiFrom, double deltaPhi) {
0669   return DDSolid(name, std::make_unique<DDI::Tubs>(zhalf, rIn, rOut, phiFrom, deltaPhi));
0670 }
0671 
0672 DDSolid DDSolidFactory::cuttubs(const DDName& name,
0673                                 double zhalf,
0674                                 double rIn,
0675                                 double rOut,
0676                                 double phiFrom,
0677                                 double deltaPhi,
0678                                 double lx,
0679                                 double ly,
0680                                 double lz,
0681                                 double tx,
0682                                 double ty,
0683                                 double tz) {
0684   return DDSolid(name, std::make_unique<DDI::CutTubs>(zhalf, rIn, rOut, phiFrom, deltaPhi, lx, ly, lz, tx, ty, tz));
0685 }
0686 
0687 DDSolid DDSolidFactory::sphere(const DDName& name,
0688                                double innerRadius,
0689                                double outerRadius,
0690                                double startPhi,
0691                                double deltaPhi,
0692                                double startTheta,
0693                                double deltaTheta) {
0694   return DDSolid(name,
0695                  std::make_unique<DDI::Sphere>(innerRadius, outerRadius, startPhi, deltaPhi, startTheta, deltaTheta));
0696 }
0697 
0698 DDSolid DDSolidFactory::ellipticalTube(const DDName& name, double xSemiAxis, double ySemiAxis, double zHeight) {
0699   return DDSolid(name, std::make_unique<DDI::EllipticalTube>(xSemiAxis, ySemiAxis, zHeight));
0700 }
0701 
0702 DDSolid DDSolidFactory::shapeless(const DDName& name) { return DDSolid(name, std::make_unique<DDI::Shapeless>()); }