237 edm::LogVerbatim(
"TGeoMgrFromDdd") <<
"with name: " << iName <<
" and solid: " << iSolid;
241 throw cms::Exception(
"TGeoMgrFromDdd::createShape * solid " + iName +
" is not declared * ");
243 throw cms::Exception(
"TGeoMgrFromDdd::createShape * solid " + defined.first->name() +
" is not defined *");
246 if (rSolid ==
nullptr) {
247 const std::vector<double>&
params = iSolid.parameters();
248 switch (iSolid.shape()) {
253 rSolid =
new TGeoConeSeg(iName.c_str(),
264 rSolid =
new TGeoTubeSeg(iName.c_str(),
273 rSolid =
new TGeoCtub(iName.c_str(),
287 rSolid =
new TGeoTrap(iName.c_str(),
301 rSolid =
new TGeoPcon(iName.c_str(),
params[0] / deg,
params[1] / deg, (
params.size() - 2) / 3);
309 for (std::vector<double>::iterator it =
temp.begin() + 3; it !=
temp.end(); ++it) {
312 rSolid->SetDimensions(&(*(
temp.begin())));
316 rSolid =
new TGeoPgon(
325 for (std::vector<double>::iterator it =
temp.begin() + 4; it !=
temp.end(); ++it) {
328 rSolid->SetDimensions(&(*(
temp.begin())));
333 std::vector<double>
x = extrPgon.xVec();
335 std::vector<double>
y = extrPgon.yVec();
337 std::vector<double>
z = extrPgon.zVec();
338 std::vector<double> zx = extrPgon.zxVec();
339 std::vector<double> zy = extrPgon.zyVec();
340 std::vector<double> zscale = extrPgon.zscaleVec();
342 TGeoXtru* mySolid =
new TGeoXtru(
z.size());
343 mySolid->DefinePolygon(
x.size(), &(*
x.begin()), &(*
y.begin()));
345 mySolid->DefineSection(
i,
z[
i] / cm, zx[
i] / cm, zy[
i] / cm, zscale[
i]);
355 double r =
pt.radius();
356 bool atMinusZ =
pt.atMinusZ();
359 bool intersec =
false;
366 double halfOpeningAngle = asin(
x /
std::abs(
r)) / deg;
367 double displacement = 0;
376 h =
pt.y1() <
pt.y2() ?
pt.y2() :
pt.y1();
379 displacement = -
pt.halfZ() -
delta;
380 startPhi = 90. - halfOpeningAngle;
382 displacement =
pt.halfZ() +
delta;
383 startPhi = -90. - halfOpeningAngle;
387 displacement = -
pt.halfZ() +
delta;
388 startPhi = 270. - halfOpeningAngle;
391 displacement =
pt.halfZ() -
delta;
392 startPhi = 90. - halfOpeningAngle;
399 std::unique_ptr<TGeoShape> trap(
400 new TGeoTrd2(
name.c_str(),
pt.x1() / cm,
pt.x2() / cm,
pt.y1() / cm,
pt.y2() / cm,
pt.halfZ() / cm));
402 std::unique_ptr<TGeoShape> tubs(
new TGeoTubeSeg(
name.c_str(),
407 startPhi + halfOpeningAngle * 2.));
409 TGeoSubtraction* sub =
new TGeoSubtraction(
411 rSolid =
new TGeoCompositeShape(iName.c_str(), sub);
413 std::unique_ptr<TGeoShape> box(
new TGeoBBox(1.1 *
x / cm, 1.1 *
h / cm,
sqrt(
r *
r -
x *
x) / cm));
415 TGeoSubtraction* sub =
new TGeoSubtraction(
418 std::unique_ptr<TGeoShape> tubicCap(
new TGeoCompositeShape(iName.c_str(), sub));
420 TGeoUnion* boolS =
new TGeoUnion(
423 rSolid =
new TGeoCompositeShape(iName.c_str(), boolS);
430 rSolid =
new TGeoTorus(iName.c_str(),
434 solid.startPhi() / deg,
435 solid.deltaPhi() / deg);
441 throw cms::Exception(
"GeomConvert") <<
"conversion to DDBooleanSolid failed";
444 std::string nameA =
m_fullname ? boolSolid.solidA().name().fullname() : boolSolid.solidA().name().name();
445 std::string nameB =
m_fullname ? boolSolid.solidB().name().fullname() : boolSolid.solidB().name().name();
446 std::unique_ptr<TGeoShape> left(
createShape(nameA, boolSolid.solidA()));
447 std::unique_ptr<TGeoShape> right(
createShape(nameB, boolSolid.solidB()));
448 if (
nullptr != left.get() &&
nullptr != right.get()) {
449 TGeoSubtraction* sub =
450 new TGeoSubtraction(left.release(),
453 createPlacement(boolSolid.rotation().matrix(), boolSolid.translation()));
454 rSolid =
new TGeoCompositeShape(iName.c_str(), sub);
461 throw cms::Exception(
"GeomConvert") <<
"conversion to DDTruncTubs failed";
463 double rIn(
tt.rIn());
464 double rOut(
tt.rOut());
465 double zHalf(
tt.zHalf());
466 double startPhi(
tt.startPhi());
468 double cutAtStart(
tt.cutAtStart());
469 double cutAtDelta(
tt.cutAtDelta());
470 bool cutInside(
bool(
tt.cutInside()));
474 if (rIn <= 0 || rOut <= 0 || cutAtStart <= 0 || cutAtDelta <= 0) {
475 std::string s =
"TruncTubs " +
name +
": 0 <= rIn,cutAtStart,rOut,cutAtDelta,rOut violated!";
482 if (startPhi != 0.) {
488 double r(cutAtStart);
489 double R(cutAtDelta);
492 std::unique_ptr<TGeoShape> tubs(
493 new TGeoTubeSeg(
name.c_str(), rIn / cm, rOut / cm, zHalf / cm, startPhi,
deltaPhi / deg));
495 double boxX(rOut), boxY(rOut);
498 double boxZ(1.1 * zHalf);
503 double cos_alpha = cath / hypo;
504 double alpha = -acos(cos_alpha);
518 std::unique_ptr<TGeoShape> box(
new TGeoBBox(
name.c_str(), boxX / cm, boxZ / cm, boxY / cm));
520 TGeoTranslation trans(xBox / cm, 0., 0.);
522 TGeoSubtraction* sub =
523 new TGeoSubtraction(tubs.release(), box.release(),
nullptr,
new TGeoCombiTrans(trans,
rot));
525 rSolid =
new TGeoCompositeShape(iName.c_str(), sub);
531 throw cms::Exception(
"GeomConvert") <<
"conversion to DDBooleanSolid failed";
534 std::string nameA =
m_fullname ? boolSolid.solidA().name().fullname() : boolSolid.solidA().name().name();
535 std::string nameB =
m_fullname ? boolSolid.solidB().name().fullname() : boolSolid.solidB().name().name();
536 std::unique_ptr<TGeoShape> left(
createShape(nameA, boolSolid.solidA()));
537 std::unique_ptr<TGeoShape> right(
createShape(nameB, boolSolid.solidB()));
540 if (
nullptr != left.get() &&
nullptr != right.get()) {
541 TGeoUnion* boolS =
new TGeoUnion(left.release(),
544 createPlacement(boolSolid.rotation().matrix(), boolSolid.translation()));
545 rSolid =
new TGeoCompositeShape(iName.c_str(), boolS);
552 throw cms::Exception(
"GeomConvert") <<
"conversion to DDBooleanSolid failed";
555 std::string nameA =
m_fullname ? boolSolid.solidA().name().fullname() : boolSolid.solidA().name().name();
556 std::string nameB =
m_fullname ? boolSolid.solidB().name().fullname() : boolSolid.solidB().name().name();
557 std::unique_ptr<TGeoShape> left(
createShape(nameA, boolSolid.solidA()));
558 std::unique_ptr<TGeoShape> right(
createShape(nameB, boolSolid.solidB()));
559 if (
nullptr != left.get() &&
nullptr != right.get()) {
560 TGeoIntersection* boolS =
561 new TGeoIntersection(left.release(),
564 createPlacement(boolSolid.rotation().matrix(), boolSolid.translation()));
565 rSolid =
new TGeoCompositeShape(iName.c_str(), boolS);
572 throw cms::Exception(
"GeomConvert") <<
"conversion to DDEllipticalTube failed";
582 if (rSolid ==
nullptr) {
583 edm::LogError(
"TGeoMgrFromDdd") <<
"COULD NOT MAKE " << iName <<
" of a shape " << iSolid;
586 edm::LogVerbatim(
"TGeoMgrFromDdd") <<
"solid " << iName <<
" has been created.";