8 #include "G4SystemOfUnits.hh" 45 edm::LogError(
"SimG4CoreGeometry") <<
" DDG4SolidConverter::convert(..) found an undefined DDSolid " << solid.
toString();
46 throw cms::Exception(
"SimG4CoreGeometry",
"DDG4SolidConverter::convert(..) found an undefined DDSolid " + solid.
toString());
48 G4VSolid *
result =
nullptr;
52 result = it->second(solid);
55 <<
"DDG4SolidConverter::convert: conversion failed for s=" << solid
56 <<
"\n solid.shape()=" << solid.
shape()
65 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: box = " << solid;
66 return new G4Box(solid.
name().
name(), (*par_)[0],(*par_)[1],(*par_)[2]);
72 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: tubs = " << solid;
73 return new G4Tubs(solid.
name().
name(), (*par_)[1],
80 #include "G4CutTubs.hh" 82 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: tubs = " << solid;
83 return new G4CutTubs(solid.
name().
name(), (*par_)[1],
88 G4ThreeVector((*par_)[5],(*par_)[6],(*par_)[7]),
89 G4ThreeVector((*par_)[8],(*par_)[9],(*par_)[10]));
95 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: trap = " << solid;
96 return new G4Trap(solid.
name().
name(), (*par_)[0],
112 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: cons = " << solid;
113 return new G4Cons(solid.
name().
name(), (*par_)[1],
123 #include "G4Polycone.hh" 125 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: pcon_rz = " << solid;
126 std::vector<double>
r;
127 std::vector<double>
z;
128 std::vector<double>::const_iterator
i = (*par_).begin()+2;
130 for(; i!=(*par_).end(); ++
i) {
131 LogDebug(
"SimG4CoreGeometry") <<
" z=" << *i/CLHEP::cm;
132 z.push_back(*i); ++
i;
133 LogDebug(
"SimG4CoreGeometry") <<
" r=" << *i/CLHEP::cm;
137 LogDebug(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0]/CLHEP::deg <<
" ep=" 138 << (*par_)[1]/CLHEP::deg;
147 return new G4Polycone(solid.
name().
name(), (*par_)[0], (*par_)[1],
155 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: pcon_rrz = " << solid;
156 std::vector<double> z_p;
157 std::vector<double> rmin_p;
158 std::vector<double> rmax_p;
159 std::vector<double>::const_iterator
i =
par_->begin()+2;
161 for (; i!=
par_->end(); ++
i) {
162 LogDebug(
"SimG4CoreGeometry") <<
"z=" << *i/CLHEP::cm;
163 z_p.push_back(*i); ++
i;
164 LogDebug(
"SimG4CoreGeometry") <<
"rmin=" << *i/CLHEP::cm;
165 rmin_p.push_back(*i); ++
i;
166 LogDebug(
"SimG4CoreGeometry") <<
"rmax=" << *i/CLHEP::cm;
167 rmax_p.push_back(*i);
170 LogDebug(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0]/CLHEP::deg <<
" ep=" 171 << (*par_)[1]/CLHEP::deg;
180 return new G4Polycone(solid.
name().
name(), (*par_)[0], (*par_)[1],
189 #include "G4Polyhedra.hh" 191 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: phed_rz = " << solid;
192 std::vector<double>
r;
193 std::vector<double>
z;
194 std::vector<double>::const_iterator
i =
par_->begin()+3;
197 for(; i!=
par_->end(); ++
i) {
198 z.push_back(*i); ++
i;
203 return new G4Polyhedra(solid.
name().
name(), (*par_)[1], (*par_)[2],
int((*par_)[0]),
211 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: phed_rrz = " << solid;
212 std::vector<double> z_p;
213 std::vector<double> rmin_p;
214 std::vector<double> rmax_p;
215 std::vector<double>::const_iterator
i =
par_->begin()+3;
217 for (; i!=
par_->end(); ++
i) {
218 LogDebug(
"SimG4CoreGeometry") <<
"z=" << *i/CLHEP::cm;
219 z_p.push_back(*i); ++
i;
220 LogDebug(
"SimG4CoreGeometry") <<
"rmin=" << *i/CLHEP::cm;
221 rmin_p.push_back(*i); ++
i;
222 LogDebug(
"SimG4CoreGeometry") <<
"rmax=" << *i/CLHEP::cm;
223 rmax_p.push_back(*i);
226 LogDebug(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0]/CLHEP::deg <<
" ep=" 227 << (*par_)[1]/CLHEP::deg;
228 return new G4Polyhedra(solid.
name().
name(), (*par_)[1], (*par_)[2],
int((*par_)[0]),
235 #include "G4ExtrudedSolid.hh" 237 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: extr_pgon = " << solid;
245 std::vector<G4TwoVector> polygon;
246 std::vector<G4ExtrudedSolid::ZSection> zsections;
247 for(
unsigned int it = 0; it < x.size(); ++it )
248 polygon.emplace_back( x[it], y[it] );
249 for(
unsigned int it = 0; it < z.size(); ++it )
250 zsections.emplace_back( z[it], G4TwoVector(zx[it], zy[it]), zs[it] );
251 return new G4ExtrudedSolid( solid.
name().
name(), polygon, zsections );
254 #include "G4Torus.hh" 256 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: torus = " << solid;
257 return new G4Torus(solid.
name().
name(), (*par_)[0],
265 #include "G4ReflectedSolid.hh" 268 const HepGeom::ReflectZ3D z_reflection;
272 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: reflected = " << solid;
273 G4ReflectedSolid * rs =
nullptr;
276 rs =
new G4ReflectedSolid(solid.
name().
name(),
285 #include "G4UnionSolid.hh" 287 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: unionsolid = " << solid.
name();
288 G4UnionSolid * us =
nullptr;
297 std::vector<double> tdbl(9);
298 bs.
rotation().
rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
299 CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
301 us =
new G4UnionSolid(solid.
name().
name(),
304 new CLHEP::HepRotation(temprep),
312 #include "G4SubtractionSolid.hh" 315 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: subtraction = " << solid;
316 G4SubtractionSolid * us =
nullptr;
326 std::vector<double> tdbl(9);
327 bs.
rotation().
rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
328 CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
330 us =
new G4SubtractionSolid(solid.
name().
name(),
333 new CLHEP::HepRotation(temprep),
340 #include "G4IntersectionSolid.hh" 342 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: intersection = " << solid;
343 G4IntersectionSolid * us =
nullptr;
350 std::vector<double> tdbl(9);
351 bs.
rotation().
rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
352 CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
354 us =
new G4IntersectionSolid(solid.
name().
name(),
357 new CLHEP::HepRotation(temprep),
363 #if defined(G4GEOM_USE_USOLIDS) 365 #include "G4MultiUnion.hh" 367 G4MultiUnion* munion =
new G4MultiUnion( G4String( solid.
name().
name()));
369 std::vector<DDSolid> solids = ms.
solids();
371 for(
auto i : solids ) {
373 G4RotationMatrix rotm = G4RotationMatrix();
374 G4ThreeVector position1 = G4ThreeVector( 0., 0., 1. );
375 G4Transform3D tr1 = G4Transform3D( rotm, position1 );
376 munion->AddNode( *gs, tr1 );
388 #endif // G4GEOM_USE_USOLIDS 393 rot =
new G4RotationMatrix;
394 rot->rotateX(90.*deg);
397 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: pseudoTrap = " << solid;
398 G4Trd *
trap =
nullptr;
399 G4Tubs *
tubs =
nullptr;
400 G4VSolid *
result =
nullptr;
406 bool intersec =
false;
413 double openingAngle = 2.*asin(x/
std::abs(r));
415 double displacement=0;
422 h = pt.
y1() < pt.
y2() ? pt.
y2() : pt.
y1();
426 startPhi = 270.*deg - openingAngle/2.;
430 startPhi = 90.*deg - openingAngle/2.;
433 else if ( r > 0 &&
std::abs(r) >= x )
437 startPhi = 90.*deg - openingAngle/2.;
442 startPhi = 270.*deg - openingAngle/2.;
447 throw cms::Exception(
"DetectorDescriptionFault",
"Check parameters of the PseudoTrap! name=" + pt.
name().
name());
449 G4ThreeVector displ(0.,0.,displacement);
450 LogDebug(
"SimG4CoreGeometry") <<
"DDSolidConverter::pseudotrap(): displacement=" << displacement
451 <<
" openingAngle=" << openingAngle/deg <<
" x=" << x <<
" h=" <<
h;
455 trap =
new G4Trd(name, pt.
x1(), pt.
x2(), pt.
y1(), pt.
y2(), pt.
halfZ());
456 tubs =
new G4Tubs(name,
463 result =
new G4SubtractionSolid(name, trap, tubs,
rot, displ);
467 G4VSolid * tubicCap =
new G4SubtractionSolid(name,
469 new G4Box(name, 1.1*x,
sqrt(r*r-x*x), 1.1*h),
472 result =
new G4UnionSolid(name, trap, tubicCap,
rot, displ);
495 LogDebug(
"SimG4CoreGeometry") <<
"before";
497 LogDebug(
"SimG4CoreGeometry") <<
"after";
498 double rIn(tt.
rIn()), rOut(tt.
rOut()), zHalf(tt.
zHalf()),
505 if (rIn <= 0 || rOut <=0 || cutAtStart <=0 || cutAtDelta <= 0) {
511 if (startPhi != 0.) {
519 double r(cutAtStart),
R(cutAtDelta);
520 G4VSolid *
result(
nullptr);
521 G4VSolid *
tubs =
new G4Tubs(name,rIn,rOut,zHalf,startPhi,
deltaPhi);
522 LogDebug(
"SimG4CoreGeometry") <<
"G4Tubs: " << rIn/CLHEP::cm <<
' ' << rOut/CLHEP::cm <<
' ' << zHalf/CLHEP::cm <<
' ' << startPhi/CLHEP::deg <<
' ' <<
deltaPhi/CLHEP::deg;
523 LogDebug(
"SimG4CoreGeometry") << solid;
525 double boxX(30.*rOut), boxY(20.*rOut);
528 double boxZ(1.1*zHalf);
533 double cos_alpha = cath/hypo;
535 double alpha = -acos(cos_alpha);
536 LogDebug(
"SimG4CoreGeometry") <<
"cath=" << cath/CLHEP::cm;
537 LogDebug(
"SimG4CoreGeometry") <<
"hypo=" << hypo/CLHEP::cm;
538 LogDebug(
"SimG4CoreGeometry") <<
"al=" << acos(cath/hypo)/CLHEP::deg;
540 <<
"r=" <<
r/CLHEP::cm <<
"\n" 541 <<
"R=" << R/CLHEP::cm;
543 LogDebug(
"SimG4CoreGeometry") <<
"alpha=" << alpha/CLHEP::deg;
546 G4RotationMatrix *
rot =
new G4RotationMatrix;
547 rot->rotateZ(-alpha);
548 LogDebug(
"SimG4CoreGeometry") << (*rot);
558 G4ThreeVector trans(xBox,0.,0.);
559 LogDebug(
"SimG4CoreGeometry") <<
"trans=" << trans;
561 G4VSolid *
box =
new G4Box(name,boxX,boxY,boxZ);
562 result =
new G4SubtractionSolid(name,tubs,box,rot,trans);
568 #include "G4Sphere.hh" 570 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: sphere = " << solid;
582 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: orb = " << solid;
587 #include "G4EllipticalTube.hh" 589 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: ellipticaltube = " << solid;
591 return new G4EllipticalTube(solid.
name().
name(),
597 #include "G4Ellipsoid.hh" 599 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: ellipsoid = " << solid;
601 return new G4Ellipsoid(solid.
name().
name(),
611 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: parallelepiped = " << solid;
613 return new G4Para(solid.
name().
name(),
double cutAtStart(void) const
truncation at begin of the tube-section
const DDRotationMatrix * rotation() const
Returns the read-only rotation-matrix.
static G4VSolid * polyhedra_rrz(const DDSolid &)
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
double xSemiAxis(void) const
static G4RotationMatrix * rot
bool cutInside(void) const
true, if truncation is on the inner side of the tube-section
static G4VSolid * orb(const DDSolid &)
A truncated tube section.
double zHalf(void) const
half of the z-Axis
double y2(void) const
half length along y on +z
static G4VSolid * ellipsoid(const DDSolid &)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
double startTheta(void) const
double deltaPhi(void) const
angular span of the tube-section
double deltaPhi(void) const
static G4VSolid * trap(const DDSolid &)
const std::vector< DDSolid > & solids(void) const
Sin< T >::type sin(const T &t)
static G4VSolid * cons(const DDSolid &)
double cutAtDelta(void) const
truncation at end of the tube-section
static G4VSolid * tubs(const DDSolid &)
double zTopCut(void) const
double radius(void) const
double rIn(void) const
inner radius
static G4VSolid * sphere(const DDSolid &)
DDTranslation translation(void) const
double ySemiAxis(void) const
double innerRadius(void) const
A DDSolid represents the shape of a part.
double y1(void) const
half length along y on -z
DDSolid solidB(void) const
static G4VSolid * cuttubs(const DDSolid &)
double outerRadius(void) const
static const char *const name(DDSolidShape s)
DDSolid unreflected(void) const
static G4VSolid * pseudotrap(const DDSolid &s)
static G4VSolid * reflected(const DDSolid &)
DDRotation rotation(void) const
static G4VSolid * para(const DDSolid &)
bool atMinusZ(void) const
true, if cut-out or rounding is on the -z side
double halfZ(void) const
half of the z-Axis
static const std::vector< double > * par_
double xSemiAxis(void) const
Cos< T >::type cos(const T &t)
const std::string fullname() const
double startPhi(void) const
Abs< T >::type abs(const T &t)
DDSolidShape shape(void) const
The type of the solid.
double deltaTheta(void) const
static G4VSolid * box(const DDSolid &)
double ySemiAxis(void) const
DDSolid solidA(void) const
std::string toString() const
static G4VSolid * ellipticaltube(const DDSolid &)
static G4VSolid * polycone_rz(const DDSolid &)
static G4VSolid * multiunion(const DDSolid &)
static G4VSolid * intersection(const DDSolid &)
G4VSolid * convert(const DDSolid &)
double startPhi(void) const
angular start of the tube-section
double zBottomCut(void) const
static G4VSolid * unionsolid(const DDSolid &)
static G4VSolid * extrudedpolygon(const DDSolid &)
static G4VSolid * trunctubs(const DDSolid &)
double zHeight(void) const
double zSemiAxis(void) const
static G4VSolid * torus(const DDSolid &)
static G4VSolid * polyhedra_rz(const DDSolid &)
static G4VSolid * polycone_rrz(const DDSolid &)
double x2(void) const
half length along x on +z
std::map< DDSolidShape, FNPTR > convDispatch_
double rOut(void) const
outer radius
const std::string & name() const
Returns the name.
double x1(void) const
half length along x on -z
static G4VSolid * subtraction(const DDSolid &)
double radius(void) const
radius of the cut-out (neg.) or rounding (pos.)