245 throw cms::Exception(
"TGeoMgrFromDdd::createShape * solid " + iName +
" is not declared * ");
247 throw cms::Exception(
"TGeoMgrFromDdd::createShape * solid " + defined.first->name() +
" is not defined *");
250 if (rSolid ==
nullptr) {
252 switch (iSolid.
shape()) {
257 rSolid =
new TGeoConeSeg(iName.c_str(),
268 rSolid =
new TGeoTubeSeg(iName.c_str(),
277 rSolid =
new TGeoCtub(iName.c_str(),
291 rSolid =
new TGeoTrap(iName.c_str(),
305 rSolid =
new TGeoPcon(iName.c_str(),
params[0] / deg,
params[1] / deg, (
params.size() - 2) / 3);
313 for (std::vector<double>::iterator
it =
temp.begin() + 3;
it !=
temp.end(); ++
it) {
316 rSolid->SetDimensions(&(*(
temp.begin())));
320 rSolid =
new TGeoPgon(
329 for (std::vector<double>::iterator
it =
temp.begin() + 4;
it !=
temp.end(); ++
it) {
332 rSolid->SetDimensions(&(*(
temp.begin())));
337 std::vector<double>
x = extrPgon.xVec();
339 std::vector<double>
y = extrPgon.yVec();
341 std::vector<double>
z = extrPgon.zVec();
342 std::vector<double> zx = extrPgon.zxVec();
343 std::vector<double> zy = extrPgon.zyVec();
344 std::vector<double> zscale = extrPgon.zscaleVec();
346 TGeoXtru* mySolid =
new TGeoXtru(
z.size());
347 mySolid->DefinePolygon(
x.size(), &(*
x.begin()), &(*
y.begin()));
349 mySolid->DefineSection(
i,
z[
i] / cm, zx[
i] / cm, zy[
i] / cm, zscale[
i]);
359 double r =
pt.radius();
360 bool atMinusZ =
pt.atMinusZ();
363 bool intersec =
false;
370 double halfOpeningAngle = asin(
x /
std::abs(
r)) / deg;
371 double displacement = 0;
380 h =
pt.y1() <
pt.y2() ?
pt.y2() :
pt.y1();
383 displacement = -
pt.halfZ() -
delta;
384 startPhi = 90. - halfOpeningAngle;
386 displacement =
pt.halfZ() +
delta;
387 startPhi = -90. - halfOpeningAngle;
391 displacement = -
pt.halfZ() +
delta;
392 startPhi = 270. - halfOpeningAngle;
395 displacement =
pt.halfZ() -
delta;
396 startPhi = 90. - halfOpeningAngle;
403 std::unique_ptr<TGeoShape> trap(
404 new TGeoTrd2(
name.c_str(),
pt.x1() / cm,
pt.x2() / cm,
pt.y1() / cm,
pt.y2() / cm,
pt.halfZ() / cm));
406 std::unique_ptr<TGeoShape> tubs(
new TGeoTubeSeg(
name.c_str(),
411 startPhi + halfOpeningAngle * 2.));
413 TGeoSubtraction* sub =
new TGeoSubtraction(
415 rSolid =
new TGeoCompositeShape(iName.c_str(), sub);
417 std::unique_ptr<TGeoShape> box(
new TGeoBBox(1.1 *
x / cm, 1.1 *
h / cm,
sqrt(
r *
r -
x *
x) / cm));
419 TGeoSubtraction* sub =
new TGeoSubtraction(
422 std::unique_ptr<TGeoShape> tubicCap(
new TGeoCompositeShape(iName.c_str(), sub));
424 TGeoUnion* boolS =
new TGeoUnion(
427 rSolid =
new TGeoCompositeShape(iName.c_str(), boolS);
434 rSolid =
new TGeoTorus(iName.c_str(),
438 solid.startPhi() / deg,
439 solid.deltaPhi() / deg);
445 throw cms::Exception(
"GeomConvert") <<
"conversion to DDBooleanSolid failed";
448 std::string nameA =
m_fullname ? boolSolid.solidA().name().fullname() : boolSolid.solidA().name().name();
449 std::string nameB =
m_fullname ? boolSolid.solidB().name().fullname() : boolSolid.solidB().name().name();
450 std::unique_ptr<TGeoShape> left(
createShape(nameA, boolSolid.solidA()));
451 std::unique_ptr<TGeoShape> right(
createShape(nameB, boolSolid.solidB()));
452 if (
nullptr != left.get() &&
nullptr != right.get()) {
453 TGeoSubtraction* sub =
454 new TGeoSubtraction(left.release(),
457 createPlacement(boolSolid.rotation().matrix(), boolSolid.translation()));
458 rSolid =
new TGeoCompositeShape(iName.c_str(), sub);
465 throw cms::Exception(
"GeomConvert") <<
"conversion to DDTruncTubs failed";
467 double rIn(
tt.rIn());
468 double rOut(
tt.rOut());
469 double zHalf(
tt.zHalf());
470 double startPhi(
tt.startPhi());
472 double cutAtStart(
tt.cutAtStart());
473 double cutAtDelta(
tt.cutAtDelta());
474 bool cutInside(
bool(
tt.cutInside()));
478 if (rIn <= 0 || rOut <= 0 || cutAtStart <= 0 || cutAtDelta <= 0) {
479 std::string s =
"TruncTubs " +
name +
": 0 <= rIn,cutAtStart,rOut,cutAtDelta,rOut violated!";
486 if (startPhi != 0.) {
492 double r(cutAtStart);
493 double R(cutAtDelta);
496 std::unique_ptr<TGeoShape> tubs(
497 new TGeoTubeSeg(
name.c_str(), rIn / cm, rOut / cm, zHalf / cm, startPhi,
deltaPhi / deg));
499 double boxX(rOut), boxY(rOut);
502 double boxZ(1.1 * zHalf);
507 double cos_alpha = cath / hypo;
508 double alpha = -acos(cos_alpha);
522 std::unique_ptr<TGeoShape> box(
new TGeoBBox(
name.c_str(), boxX / cm, boxZ / cm, boxY / cm));
524 TGeoTranslation trans(xBox / cm, 0., 0.);
526 TGeoSubtraction* sub =
527 new TGeoSubtraction(tubs.release(), box.release(),
nullptr,
new TGeoCombiTrans(trans,
rot));
529 rSolid =
new TGeoCompositeShape(iName.c_str(), sub);
535 throw cms::Exception(
"GeomConvert") <<
"conversion to DDBooleanSolid failed";
538 std::string nameA =
m_fullname ? boolSolid.solidA().name().fullname() : boolSolid.solidA().name().name();
539 std::string nameB =
m_fullname ? boolSolid.solidB().name().fullname() : boolSolid.solidB().name().name();
540 std::unique_ptr<TGeoShape> left(
createShape(nameA, boolSolid.solidA()));
541 std::unique_ptr<TGeoShape> right(
createShape(nameB, boolSolid.solidB()));
544 if (
nullptr != left.get() &&
nullptr != right.get()) {
545 TGeoUnion* boolS =
new TGeoUnion(left.release(),
548 createPlacement(boolSolid.rotation().matrix(), boolSolid.translation()));
549 rSolid =
new TGeoCompositeShape(iName.c_str(), boolS);
556 throw cms::Exception(
"GeomConvert") <<
"conversion to DDBooleanSolid failed";
559 std::string nameA =
m_fullname ? boolSolid.solidA().name().fullname() : boolSolid.solidA().name().name();
560 std::string nameB =
m_fullname ? boolSolid.solidB().name().fullname() : boolSolid.solidB().name().name();
561 std::unique_ptr<TGeoShape> left(
createShape(nameA, boolSolid.solidA()));
562 std::unique_ptr<TGeoShape> right(
createShape(nameB, boolSolid.solidB()));
563 if (
nullptr != left.get() &&
nullptr != right.get()) {
564 TGeoIntersection* boolS =
565 new TGeoIntersection(left.release(),
568 createPlacement(boolSolid.rotation().matrix(), boolSolid.translation()));
569 rSolid =
new TGeoCompositeShape(iName.c_str(), boolS);
576 throw cms::Exception(
"GeomConvert") <<
"conversion to DDEllipticalTube failed";
586 if (rSolid ==
nullptr) {
587 edm::LogError(
"TGeoMgrFromDdd") <<
"COULD NOT MAKE " << iName <<
" of a shape " << iSolid;
590 edm::LogVerbatim(
"TGeoMgrFromDdd") <<
"solid " << iName <<
" has been created.";
Log< level::Info, true > LogVerbatim
A truncated tube section.
Sin< T >::type sin(const T &t)
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Log< level::Error, false > LogError
TGeoCombiTrans * createPlacement(const Rotation3D &iRot, const Position &iTrans)
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
Cos< T >::type cos(const T &t)
std::map< std::string, TGeoShape * > nameToShape_
Abs< T >::type abs(const T &t)
DDSolidShape shape(void) const
The type of the solid.
TGeoShape * createShape(const std::string &iName, const DDSolid &iSolid)
const std::string fullname() const
std::pair< const N *, bool > def_type
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
def_type isDefined() const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation