228 LogDebug(
"TGeoMgrFromDdd::createShape") <<
"with name: " << iName <<
" and solid: " << iSolid;
231 if( !defined.first )
throw cms::Exception(
"TGeoMgrFromDdd::createShape * solid " + iName +
" is not declared * " );
232 if( !defined.second )
throw cms::Exception(
"TGeoMgrFromDdd::createShape * solid " + defined.first->name() +
" is not defined *" );
235 if (rSolid ==
nullptr)
237 const std::vector<double>& params = iSolid.parameters();
238 switch(iSolid.shape())
241 rSolid =
new TGeoBBox(
248 rSolid =
new TGeoConeSeg(
256 params[6]/deg+params[5]/deg
261 rSolid=
new TGeoTubeSeg(
267 params[3]/deg + params[4]/deg);
271 rSolid=
new TGeoCtub(
277 params[3]/deg + params[4]/deg,
278 params[5],params[6],params[7],
279 params[8],params[9],params[10]);
282 rSolid =
new TGeoTrap(
297 rSolid =
new TGeoPcon(
301 (params.size()-2)/3) ;
303 std::vector<double>
temp(params.size()+1);
304 temp.reserve(params.size()+1);
305 temp[0]=params[0]/deg;
306 temp[1]=params[1]/deg;
307 temp[2]=(params.size()-2)/3;
309 for(std::vector<double>::iterator it=
temp.begin()+3;
314 rSolid->SetDimensions(&(*(
temp.begin())));
318 rSolid =
new TGeoPgon(
322 static_cast<int>(params[0]),
323 (params.size()-3)/3);
325 std::vector<double>
temp(params.size()+1);
326 temp[0]=params[1]/deg;
327 temp[1]=params[2]/deg;
329 temp[3]=(params.size()-3)/3;
330 std::copy(params.begin()+3,params.end(),temp.begin()+4);
331 for(std::vector<double>::iterator it=temp.begin()+4;
336 rSolid->SetDimensions(&(*(temp.begin())));
342 std::vector<double>
x = extrPgon.xVec();
343 std::transform(x.begin(), x.end(), x.begin(),[](
double d) {
return d/cm; });
344 std::vector<double>
y = extrPgon.yVec();
345 std::transform(y.begin(), y.end(), y.begin(),[](
double d) {
return d/cm; });
346 std::vector<double>
z = extrPgon.zVec();
347 std::vector<double> zx = extrPgon.zxVec();
348 std::vector<double> zy = extrPgon.zyVec();
349 std::vector<double> zscale = extrPgon.zscaleVec();
351 TGeoXtru* mySolid =
new TGeoXtru(z.size());
352 mySolid->DefinePolygon(x.size(), &(*x.begin()), &(*y.begin()));
353 for(
size_t i = 0;
i < params[0]; ++
i )
355 mySolid->DefineSection(
i, z[
i]/cm, zx[
i]/cm, zy[
i]/cm, zscale[
i]);
367 double r =
pt.radius();
368 bool atMinusZ =
pt.atMinusZ();
371 bool intersec =
false;
381 double halfOpeningAngle = asin( x /
std::abs( r ))/deg;
382 double displacement = 0;
391 h =
pt.y1() <
pt.y2() ?
pt.y2() :
pt.y1();
395 displacement = -
pt.halfZ() -
delta;
396 startPhi = 90. - halfOpeningAngle;
400 displacement =
pt.halfZ() +
delta;
401 startPhi = -90.- halfOpeningAngle;
404 else if( r > 0 &&
std::abs( r ) >= x )
408 displacement = -
pt.halfZ() +
delta;
409 startPhi = 270.- halfOpeningAngle;
414 displacement =
pt.halfZ() -
delta;
415 startPhi = 90. - halfOpeningAngle;
421 throw cms::Exception(
"Check parameters of the PseudoTrap! name=" +
pt.name().name());
424 std::auto_ptr<TGeoShape> trap(
new TGeoTrd2(
pt.name().name().c_str(),
431 std::auto_ptr<TGeoShape> tubs(
new TGeoTubeSeg(
pt.name().name().c_str(),
436 startPhi + halfOpeningAngle * 2. ));
439 TGeoSubtraction* sub =
new TGeoSubtraction( trap.release(),
442 createPlacement( s_rot,
446 rSolid =
new TGeoCompositeShape( iName.c_str(),
451 std::auto_ptr<TGeoShape> box(
new TGeoBBox( 1.1*x/cm, 1.1*h/cm,
sqrt(r*r-x*x)/cm ));
453 TGeoSubtraction* sub =
new TGeoSubtraction( tubs.release(),
456 createPlacement( s_rot,
461 std::auto_ptr<TGeoShape> tubicCap(
new TGeoCompositeShape( iName.c_str(), sub ));
463 TGeoUnion* boolS =
new TGeoUnion( trap.release(),
466 createPlacement( s_rot,
471 rSolid =
new TGeoCompositeShape( iName.c_str(),
480 rSolid =
new TGeoTorus( iName.c_str(),
484 solid.startPhi()/deg,
485 solid.deltaPhi()/deg);
492 throw cms::Exception(
"GeomConvert") <<
"conversion to DDBooleanSolid failed";
495 std::auto_ptr<TGeoShape> left(
createShape(boolSolid.solidA().name().fullname(),
496 boolSolid.solidA()) );
497 std::auto_ptr<TGeoShape> right(
createShape(boolSolid.solidB().name().fullname(),
498 boolSolid.solidB()));
499 if(
nullptr != left.get() &&
500 nullptr != right.get() ) {
501 TGeoSubtraction* sub =
new TGeoSubtraction(left.release(),right.release(),
504 *(boolSolid.rotation().matrix()),
505 boolSolid.translation()));
506 rSolid =
new TGeoCompositeShape(iName.c_str(),
516 throw cms::Exception(
"GeomConvert" ) <<
"conversion to DDTruncTubs failed";
518 double rIn(
tt.rIn());
519 double rOut(
tt.rOut());
520 double zHalf(
tt.zHalf());
521 double startPhi(
tt.startPhi());
523 double cutAtStart(
tt.cutAtStart());
524 double cutAtDelta(
tt.cutAtDelta());
525 bool cutInside(
bool(
tt.cutInside()));
529 if( rIn <= 0 || rOut <=0 || cutAtStart <=0 || cutAtDelta <= 0 )
531 std::string s =
"TruncTubs " +
std::string(
tt.name().fullname()) +
": 0 <= rIn,cutAtStart,rOut,cutAtDelta,rOut violated!";
546 double r( cutAtStart );
547 double R( cutAtDelta );
550 std::auto_ptr<TGeoShape> tubs(
new TGeoTubeSeg( name.c_str(), rIn/cm, rOut/cm, zHalf/cm, startPhi,
deltaPhi/deg ));
552 double boxX( rOut ), boxY( rOut );
555 double boxZ( 1.1 * zHalf );
560 double cos_alpha = cath / hypo;
561 double alpha = -acos( cos_alpha );
566 rot.RotateZ( alpha/deg );
572 xBox = r + boxX /
sin( fabs( alpha ));
576 xBox = - ( boxX /
sin( fabs( alpha )) -
r );
578 std::auto_ptr<TGeoShape> box(
new TGeoBBox( name.c_str(), boxX/cm, boxZ/cm, boxY/cm ));
580 TGeoTranslation trans( xBox/cm, 0., 0.);
582 TGeoSubtraction* sub =
new TGeoSubtraction( tubs.release(),
584 nullptr,
new TGeoCombiTrans( trans, rot ));
586 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()));
603 if(
nullptr != left.get() &&
604 nullptr != right.get() ) {
605 TGeoUnion* boolS =
new TGeoUnion(left.release(),right.release(),
608 *(boolSolid.rotation().matrix()),
609 boolSolid.translation()));
610 rSolid =
new TGeoCompositeShape(iName.c_str(),
619 throw cms::Exception(
"GeomConvert") <<
"conversion to DDBooleanSolid failed";
622 std::auto_ptr<TGeoShape> left(
createShape(boolSolid.solidA().name().fullname(),
623 boolSolid.solidA()) );
624 std::auto_ptr<TGeoShape> right(
createShape(boolSolid.solidB().name().fullname(),
625 boolSolid.solidB()));
626 if(
nullptr != left.get() &&
627 nullptr != right.get() ) {
628 TGeoIntersection* boolS =
new TGeoIntersection(left.release(),
632 *(boolSolid.rotation().matrix()),
633 boolSolid.translation()));
634 rSolid =
new TGeoCompositeShape(iName.c_str(),
643 throw cms::Exception(
"GeomConvert") <<
"conversion to DDEllipticalTube failed";
645 rSolid =
new TGeoEltu(iName.c_str(),
656 if (rSolid ==
nullptr)
658 std::cerr <<
"COULD NOT MAKE "<<iName<<
" of a shape "<<iSolid<<std::endl;
661 LogDebug(
"TGeoMgrFromDdd::createShape") <<
"solid " << iName <<
" has been created.";
A truncated tube section.
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
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.