225 LogDebug(
"TGeoMgrFromDdd::createShape") <<
"with name: " << iName <<
" and solid: " << iSolid;
228 if( !defined.first )
throw cms::Exception(
"TGeoMgrFromDdd::createShape * solid " + iName +
" is not declared * " );
229 if( !defined.second )
throw cms::Exception(
"TGeoMgrFromDdd::createShape * solid " + defined.first->name() +
" is not defined *" );
234 const std::vector<double>& params = iSolid.parameters();
235 switch(iSolid.shape())
238 rSolid =
new TGeoBBox(
245 rSolid =
new TGeoConeSeg(
253 params[6]/deg+params[5]/deg
258 rSolid=
new TGeoTubeSeg(
264 params[3]/deg + params[4]/deg);
268 rSolid=
new TGeoCtub(
274 params[3]/deg + params[4]/deg,
275 params[5],params[6],params[7],
276 params[8],params[9],params[10]);
279 rSolid =
new TGeoTrap(
294 rSolid =
new TGeoPcon(
298 (params.size()-2)/3) ;
300 std::vector<double>
temp(params.size()+1);
301 temp.reserve(params.size()+1);
302 temp[0]=params[0]/deg;
303 temp[1]=params[1]/deg;
304 temp[2]=(params.size()-2)/3;
306 for(std::vector<double>::iterator it=
temp.begin()+3;
311 rSolid->SetDimensions(&(*(
temp.begin())));
315 rSolid =
new TGeoPgon(
319 static_cast<int>(params[0]),
320 (params.size()-3)/3);
322 std::vector<double>
temp(params.size()+1);
323 temp[0]=params[1]/deg;
324 temp[1]=params[2]/deg;
326 temp[3]=(params.size()-3)/3;
327 std::copy(params.begin()+3,params.end(),temp.begin()+4);
328 for(std::vector<double>::iterator it=temp.begin()+4;
333 rSolid->SetDimensions(&(*(temp.begin())));
342 double r =
pt.radius();
343 bool atMinusZ =
pt.atMinusZ();
346 bool intersec =
false;
356 double halfOpeningAngle = asin( x /
std::abs( r ))/deg;
357 double displacement = 0;
366 h =
pt.y1() <
pt.y2() ?
pt.y2() :
pt.y1();
370 displacement = -
pt.halfZ() -
delta;
371 startPhi = 90. - halfOpeningAngle;
375 displacement =
pt.halfZ() +
delta;
376 startPhi = -90.- halfOpeningAngle;
379 else if( r > 0 &&
std::abs( r ) >= x )
383 displacement = -
pt.halfZ() +
delta;
384 startPhi = 270.- halfOpeningAngle;
389 displacement =
pt.halfZ() -
delta;
390 startPhi = 90. - halfOpeningAngle;
396 throw cms::Exception(
"Check parameters of the PseudoTrap! name=" +
pt.name().name());
399 std::auto_ptr<TGeoShape> trap(
new TGeoTrd2(
pt.name().name().c_str(),
406 std::auto_ptr<TGeoShape> tubs(
new TGeoTubeSeg(
pt.name().name().c_str(),
411 startPhi + halfOpeningAngle * 2. ));
414 TGeoSubtraction* sub =
new TGeoSubtraction( trap.release(),
417 createPlacement( s_rot,
421 rSolid =
new TGeoCompositeShape( iName.c_str(),
426 std::auto_ptr<TGeoShape> box(
new TGeoBBox( 1.1*x/cm, 1.1*h/cm,
sqrt(r*r-x*x)/cm ));
428 TGeoSubtraction* sub =
new TGeoSubtraction( tubs.release(),
431 createPlacement( s_rot,
436 std::auto_ptr<TGeoShape> tubicCap(
new TGeoCompositeShape( iName.c_str(), sub ));
438 TGeoUnion* boolS =
new TGeoUnion( trap.release(),
441 createPlacement( s_rot,
446 rSolid =
new TGeoCompositeShape( iName.c_str(),
455 rSolid =
new TGeoTorus( iName.c_str(),
459 solid.startPhi()/deg,
460 solid.deltaPhi()/deg);
467 throw cms::Exception(
"GeomConvert") <<
"conversion to DDBooleanSolid failed";
470 std::auto_ptr<TGeoShape> left(
createShape(boolSolid.solidA().name().fullname(),
471 boolSolid.solidA()) );
472 std::auto_ptr<TGeoShape> right(
createShape(boolSolid.solidB().name().fullname(),
473 boolSolid.solidB()));
474 if( 0 != left.get() &&
476 TGeoSubtraction* sub =
new TGeoSubtraction(left.release(),right.release(),
479 *(boolSolid.rotation().matrix()),
480 boolSolid.translation()));
481 rSolid =
new TGeoCompositeShape(iName.c_str(),
491 throw cms::Exception(
"GeomConvert" ) <<
"conversion to DDTruncTubs failed";
493 double rIn(
tt.rIn());
494 double rOut(
tt.rOut());
495 double zHalf(
tt.zHalf());
496 double startPhi(
tt.startPhi());
498 double cutAtStart(
tt.cutAtStart());
499 double cutAtDelta(
tt.cutAtDelta());
500 bool cutInside(
bool(
tt.cutInside()));
504 if( rIn <= 0 || rOut <=0 || cutAtStart <=0 || cutAtDelta <= 0 )
506 std::string s =
"TruncTubs " +
std::string(
tt.name().fullname()) +
": 0 <= rIn,cutAtStart,rOut,cutAtDelta,rOut violated!";
521 double r( cutAtStart );
522 double R( cutAtDelta );
525 std::auto_ptr<TGeoShape> tubs(
new TGeoTubeSeg( name.c_str(), rIn/cm, rOut/cm, zHalf/cm, startPhi,
deltaPhi/deg ));
527 double boxX( rOut ), boxY( rOut );
530 double boxZ( 1.1 * zHalf );
535 double cos_alpha = cath / hypo;
536 double alpha = -acos( cos_alpha );
541 rot.RotateZ( alpha/deg );
547 xBox = r + boxX /
sin( fabs( alpha ));
551 xBox = - ( boxX /
sin( fabs( alpha )) -
r );
553 std::auto_ptr<TGeoShape> box(
new TGeoBBox( name.c_str(), boxX/cm, boxZ/cm, boxY/cm ));
555 TGeoTranslation trans( xBox/cm, 0., 0.);
557 TGeoSubtraction* sub =
new TGeoSubtraction( tubs.release(),
559 0,
new TGeoCombiTrans( trans, rot ));
561 rSolid =
new TGeoCompositeShape( iName.c_str(),
569 throw cms::Exception(
"GeomConvert") <<
"conversion to DDBooleanSolid failed";
572 std::auto_ptr<TGeoShape> left(
createShape(boolSolid.solidA().name().fullname(),
573 boolSolid.solidA()) );
574 std::auto_ptr<TGeoShape> right(
createShape(boolSolid.solidB().name().fullname(),
575 boolSolid.solidB()));
578 if( 0 != left.get() &&
580 TGeoUnion* boolS =
new TGeoUnion(left.release(),right.release(),
583 *(boolSolid.rotation().matrix()),
584 boolSolid.translation()));
585 rSolid =
new TGeoCompositeShape(iName.c_str(),
594 throw cms::Exception(
"GeomConvert") <<
"conversion to DDBooleanSolid failed";
597 std::auto_ptr<TGeoShape> left(
createShape(boolSolid.solidA().name().fullname(),
598 boolSolid.solidA()) );
599 std::auto_ptr<TGeoShape> right(
createShape(boolSolid.solidB().name().fullname(),
600 boolSolid.solidB()));
601 if( 0 != left.get() &&
603 TGeoIntersection* boolS =
new TGeoIntersection(left.release(),
607 *(boolSolid.rotation().matrix()),
608 boolSolid.translation()));
609 rSolid =
new TGeoCompositeShape(iName.c_str(),
618 throw cms::Exception(
"GeomConvert") <<
"conversion to DDEllipticalTube failed";
620 rSolid =
new TGeoEltu(iName.c_str(),
633 std::cerr <<
"COULD NOT MAKE "<<iName<<
" of a shape "<<iSolid<<std::endl;
636 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.