226 LogDebug(
"TGeoMgrFromDdd::createShape") <<
"with name: " << iName <<
" and solid: " << iSolid;
229 if( !defined.first )
throw cms::Exception(
"TGeoMgrFromDdd::createShape * solid " + iName +
" is not declared * " );
230 if( !defined.second )
throw cms::Exception(
"TGeoMgrFromDdd::createShape * solid " + defined.first->name() +
" is not defined *" );
235 const std::vector<double>& params = iSolid.parameters();
236 switch(iSolid.shape())
239 rSolid =
new TGeoBBox(
246 rSolid =
new TGeoConeSeg(
254 params[6]/deg+params[5]/deg
259 rSolid=
new TGeoTubeSeg(
265 params[3]/deg + params[4]/deg);
269 rSolid=
new TGeoCtub(
275 params[3]/deg + params[4]/deg,
276 params[5],params[6],params[7],
277 params[8],params[9],params[10]);
280 rSolid =
new TGeoTrap(
295 rSolid =
new TGeoPcon(
299 (params.size()-2)/3) ;
301 std::vector<double>
temp(params.size()+1);
302 temp.reserve(params.size()+1);
303 temp[0]=params[0]/deg;
304 temp[1]=params[1]/deg;
305 temp[2]=(params.size()-2)/3;
307 for(std::vector<double>::iterator it=
temp.begin()+3;
312 rSolid->SetDimensions(&(*(
temp.begin())));
316 rSolid =
new TGeoPgon(
320 static_cast<int>(params[0]),
321 (params.size()-3)/3);
323 std::vector<double>
temp(params.size()+1);
324 temp[0]=params[1]/deg;
325 temp[1]=params[2]/deg;
327 temp[3]=(params.size()-3)/3;
328 std::copy(params.begin()+3,params.end(),temp.begin()+4);
329 for(std::vector<double>::iterator it=temp.begin()+4;
334 rSolid->SetDimensions(&(*(temp.begin())));
340 std::vector<double>
x = extrPgon.xVec();
341 std::transform(x.begin(), x.end(), x.begin(),[](
double d) {
return d/cm; });
342 std::vector<double>
y = extrPgon.yVec();
343 std::transform(y.begin(), y.end(), y.begin(),[](
double d) {
return d/cm; });
344 std::vector<double>
z = extrPgon.zVec();
345 std::vector<double> zx = extrPgon.zxVec();
346 std::vector<double> zy = extrPgon.zyVec();
347 std::vector<double> zscale = extrPgon.zscaleVec();
349 TGeoXtru* mySolid =
new TGeoXtru(z.size());
350 mySolid->DefinePolygon(x.size(), &(*x.begin()), &(*y.begin()));
351 for(
size_t i = 0;
i < params[0]; ++
i )
353 mySolid->DefineSection(
i, z[
i]/cm, zx[
i]/cm, zy[
i]/cm, zscale[
i]);
365 double r =
pt.radius();
366 bool atMinusZ =
pt.atMinusZ();
369 bool intersec =
false;
379 double halfOpeningAngle = asin( x /
std::abs( r ))/deg;
380 double displacement = 0;
389 h =
pt.y1() <
pt.y2() ?
pt.y2() :
pt.y1();
393 displacement = -
pt.halfZ() -
delta;
394 startPhi = 90. - halfOpeningAngle;
398 displacement =
pt.halfZ() +
delta;
399 startPhi = -90.- halfOpeningAngle;
402 else if( r > 0 &&
std::abs( r ) >= x )
406 displacement = -
pt.halfZ() +
delta;
407 startPhi = 270.- halfOpeningAngle;
412 displacement =
pt.halfZ() -
delta;
413 startPhi = 90. - halfOpeningAngle;
419 throw cms::Exception(
"Check parameters of the PseudoTrap! name=" +
pt.name().name());
422 std::auto_ptr<TGeoShape> trap(
new TGeoTrd2(
pt.name().name().c_str(),
429 std::auto_ptr<TGeoShape> tubs(
new TGeoTubeSeg(
pt.name().name().c_str(),
434 startPhi + halfOpeningAngle * 2. ));
437 TGeoSubtraction* sub =
new TGeoSubtraction( trap.release(),
440 createPlacement( s_rot,
444 rSolid =
new TGeoCompositeShape( iName.c_str(),
449 std::auto_ptr<TGeoShape> box(
new TGeoBBox( 1.1*x/cm, 1.1*h/cm,
sqrt(r*r-x*x)/cm ));
451 TGeoSubtraction* sub =
new TGeoSubtraction( tubs.release(),
454 createPlacement( s_rot,
459 std::auto_ptr<TGeoShape> tubicCap(
new TGeoCompositeShape( iName.c_str(), sub ));
461 TGeoUnion* boolS =
new TGeoUnion( trap.release(),
464 createPlacement( s_rot,
469 rSolid =
new TGeoCompositeShape( iName.c_str(),
478 rSolid =
new TGeoTorus( iName.c_str(),
482 solid.startPhi()/deg,
483 solid.deltaPhi()/deg);
490 throw cms::Exception(
"GeomConvert") <<
"conversion to DDBooleanSolid failed";
493 std::auto_ptr<TGeoShape> left(
createShape(boolSolid.solidA().name().fullname(),
494 boolSolid.solidA()) );
495 std::auto_ptr<TGeoShape> right(
createShape(boolSolid.solidB().name().fullname(),
496 boolSolid.solidB()));
497 if( 0 != left.get() &&
499 TGeoSubtraction* sub =
new TGeoSubtraction(left.release(),right.release(),
502 *(boolSolid.rotation().matrix()),
503 boolSolid.translation()));
504 rSolid =
new TGeoCompositeShape(iName.c_str(),
514 throw cms::Exception(
"GeomConvert" ) <<
"conversion to DDTruncTubs failed";
516 double rIn(
tt.rIn());
517 double rOut(
tt.rOut());
518 double zHalf(
tt.zHalf());
519 double startPhi(
tt.startPhi());
521 double cutAtStart(
tt.cutAtStart());
522 double cutAtDelta(
tt.cutAtDelta());
523 bool cutInside(
bool(
tt.cutInside()));
527 if( rIn <= 0 || rOut <=0 || cutAtStart <=0 || cutAtDelta <= 0 )
529 std::string s =
"TruncTubs " +
std::string(
tt.name().fullname()) +
": 0 <= rIn,cutAtStart,rOut,cutAtDelta,rOut violated!";
544 double r( cutAtStart );
545 double R( cutAtDelta );
548 std::auto_ptr<TGeoShape> tubs(
new TGeoTubeSeg( name.c_str(), rIn/cm, rOut/cm, zHalf/cm, startPhi,
deltaPhi/deg ));
550 double boxX( rOut ), boxY( rOut );
553 double boxZ( 1.1 * zHalf );
558 double cos_alpha = cath / hypo;
559 double alpha = -acos( cos_alpha );
564 rot.RotateZ( alpha/deg );
570 xBox = r + boxX /
sin( fabs( alpha ));
574 xBox = - ( boxX /
sin( fabs( alpha )) -
r );
576 std::auto_ptr<TGeoShape> box(
new TGeoBBox( name.c_str(), boxX/cm, boxZ/cm, boxY/cm ));
578 TGeoTranslation trans( xBox/cm, 0., 0.);
580 TGeoSubtraction* sub =
new TGeoSubtraction( tubs.release(),
582 0,
new TGeoCombiTrans( trans, rot ));
584 rSolid =
new TGeoCompositeShape( iName.c_str(),
592 throw cms::Exception(
"GeomConvert") <<
"conversion to DDBooleanSolid failed";
595 std::auto_ptr<TGeoShape> left(
createShape(boolSolid.solidA().name().fullname(),
596 boolSolid.solidA()) );
597 std::auto_ptr<TGeoShape> right(
createShape(boolSolid.solidB().name().fullname(),
598 boolSolid.solidB()));
601 if( 0 != left.get() &&
603 TGeoUnion* boolS =
new TGeoUnion(left.release(),right.release(),
606 *(boolSolid.rotation().matrix()),
607 boolSolid.translation()));
608 rSolid =
new TGeoCompositeShape(iName.c_str(),
617 throw cms::Exception(
"GeomConvert") <<
"conversion to DDBooleanSolid failed";
620 std::auto_ptr<TGeoShape> left(
createShape(boolSolid.solidA().name().fullname(),
621 boolSolid.solidA()) );
622 std::auto_ptr<TGeoShape> right(
createShape(boolSolid.solidB().name().fullname(),
623 boolSolid.solidB()));
624 if( 0 != left.get() &&
626 TGeoIntersection* boolS =
new TGeoIntersection(left.release(),
630 *(boolSolid.rotation().matrix()),
631 boolSolid.translation()));
632 rSolid =
new TGeoCompositeShape(iName.c_str(),
641 throw cms::Exception(
"GeomConvert") <<
"conversion to DDEllipticalTube failed";
643 rSolid =
new TGeoEltu(iName.c_str(),
656 std::cerr <<
"COULD NOT MAKE "<<iName<<
" of a shape "<<iSolid<<std::endl;
659 LogDebug(
"TGeoMgrFromDdd::createShape") <<
"solid " << iName <<
" has been created.";
A truncated tube section.
Sin< T >::type sin(const T &t)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Cos< T >::type cos(const T &t)
std::map< std::string, TGeoShape * > nameToShape_
Abs< T >::type abs(const T &t)
TGeoShape * createShape(const std::string &iName, const DDSolid &iSolid)
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.