241 LogDebug(
"TGeoMgrFromDdd::createShape") <<
"with name: " << iName <<
" and solid: " << iSolid;
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) {
251 const std::vector<double>&
params = iSolid.parameters();
252 switch (iSolid.shape()) {
254 rSolid =
new TGeoBBox(iName.c_str(), params[0] / cm, params[1] / cm, params[2] / cm);
257 rSolid =
new TGeoConeSeg(iName.c_str(),
264 params[6] / deg + params[5] / deg);
268 rSolid =
new TGeoTubeSeg(iName.c_str(),
273 params[3] / deg + params[4] / deg);
277 rSolid =
new TGeoCtub(iName.c_str(),
282 params[3] / deg + params[4] / deg,
291 rSolid =
new TGeoTrap(iName.c_str(),
305 rSolid =
new TGeoPcon(iName.c_str(), params[0] / deg, params[1] / deg, (params.size() - 2) / 3);
307 std::vector<double>
temp(params.size() + 1);
308 temp.reserve(params.size() + 1);
309 temp[0] = params[0] / deg;
310 temp[1] = params[1] / deg;
311 temp[2] = (params.size() - 2) / 3;
312 std::copy(params.begin() + 2, params.end(),
temp.begin() + 3);
313 for (std::vector<double>::iterator it =
temp.begin() + 3; it !=
temp.end(); ++it) {
316 rSolid->SetDimensions(&(*(
temp.begin())));
320 rSolid =
new TGeoPgon(
321 iName.c_str(), params[1] / deg, params[2] / deg,
static_cast<int>(params[0]), (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; it != temp.end(); ++it) {
332 rSolid->SetDimensions(&(*(temp.begin())));
337 std::vector<double>
x = extrPgon.xVec();
338 std::transform(x.begin(), x.end(), x.begin(), [](
double d) {
return d / cm; });
339 std::vector<double>
y = extrPgon.yVec();
340 std::transform(y.begin(), y.end(), y.begin(), [](
double d) {
return d / cm; });
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()));
348 for (
size_t i = 0;
i < params[0]; ++
i) {
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;
389 }
else if (r > 0 &&
std::abs(r) >= x) {
391 displacement = -
pt.halfZ() +
delta;
392 startPhi = 270. - halfOpeningAngle;
395 displacement =
pt.halfZ() -
delta;
396 startPhi = 90. - halfOpeningAngle;
400 throw cms::Exception(
"Check parameters of the PseudoTrap! name=" + name);
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!";
483 std::string s =
"TruncTubs " + name +
": rIn<rOut violated!";
486 if (startPhi != 0.) {
487 std::string s =
"TruncTubs " + name +
": startPhi != 0 not supported!";
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);
513 rot.RotateZ(alpha / deg);
518 xBox = r + boxX /
sin(fabs(alpha));
520 xBox = -(boxX /
sin(fabs(alpha)) -
r);
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";
578 rSolid =
new TGeoEltu(iName.c_str(), params[0] / cm, params[1] / cm, params[2] / cm);
586 if (rSolid ==
nullptr) {
587 std::cerr <<
"COULD NOT MAKE " << iName <<
" of a shape " << iSolid << std::endl;
590 LogDebug(
"TGeoMgrFromDdd::createShape") <<
"solid " << iName <<
" has been created.";
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
A truncated tube section.
Sin< T >::type sin(const T &t)
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
TGeoCombiTrans * createPlacement(const Rotation3D &iRot, const Position &iTrans)
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)
std::pair< const N *, bool > def_type
alpha
zGenParticlesMatch = cms.InputTag(""),