8 #include "G4SystemOfUnits.hh" 40 edm::LogError(
"SimG4CoreGeometry") <<
" DDG4SolidConverter::convert(..) found an undefined DDSolid " 43 "DDG4SolidConverter::convert(..) found an undefined DDSolid " + solid.
toString());
45 G4VSolid *
result =
nullptr;
49 result = it->second(solid);
52 <<
"DDG4SolidConverter::convert: conversion failed for s=" << solid
60 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: box = " << solid;
61 return new G4Box(solid.
name().
name(), (*par_)[0], (*par_)[1], (*par_)[2]);
66 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: tubs = " << solid;
67 return new G4Tubs(solid.
name().
name(),
75 #include "G4CutTubs.hh" 77 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: tubs = " << solid;
78 return new G4CutTubs(solid.
name().
name(),
84 G4ThreeVector((*par_)[5], (*par_)[6], (*par_)[7]),
85 G4ThreeVector((*par_)[8], (*par_)[9], (*par_)[10]));
90 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: trap = " << solid;
91 return new G4Trap(solid.
name().
name(),
107 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: cons = " << solid;
108 return new G4Cons(solid.
name().
name(),
118 #include "G4Polycone.hh" 120 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: pcon_rz = " << solid;
121 std::vector<double>
r;
122 std::vector<double>
z;
123 std::vector<double>::const_iterator
i = (*par_).begin() + 2;
125 for (; i != (*par_).end(); ++
i) {
126 LogDebug(
"SimG4CoreGeometry") <<
" z=" << *i / CLHEP::cm;
129 LogDebug(
"SimG4CoreGeometry") <<
" r=" << *i / CLHEP::cm;
133 LogDebug(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0] / CLHEP::deg <<
" ep=" << (*par_)[1] / CLHEP::deg;
142 return new G4Polycone(solid.
name().
name(),
151 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: pcon_rrz = " << solid;
152 std::vector<double> z_p;
153 std::vector<double> rmin_p;
154 std::vector<double> rmax_p;
155 std::vector<double>::const_iterator
i =
par_->begin() + 2;
157 for (; i !=
par_->end(); ++
i) {
158 LogDebug(
"SimG4CoreGeometry") <<
"z=" << *i / CLHEP::cm;
161 LogDebug(
"SimG4CoreGeometry") <<
"rmin=" << *i / CLHEP::cm;
162 rmin_p.push_back(*i);
164 LogDebug(
"SimG4CoreGeometry") <<
"rmax=" << *i / CLHEP::cm;
165 rmax_p.push_back(*i);
168 LogDebug(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0] / CLHEP::deg <<
" ep=" << (*par_)[1] / CLHEP::deg;
178 return new G4Polycone(solid.
name().
name(),
187 #include "G4Polyhedra.hh" 189 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: phed_rz = " << solid;
190 std::vector<double>
r;
191 std::vector<double>
z;
192 std::vector<double>::const_iterator
i =
par_->begin() + 3;
195 for (; i !=
par_->end(); ++
i) {
202 return new G4Polyhedra(solid.
name().
name(),
212 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: phed_rrz = " << solid;
213 std::vector<double> z_p;
214 std::vector<double> rmin_p;
215 std::vector<double> rmax_p;
216 std::vector<double>::const_iterator
i =
par_->begin() + 3;
218 for (; i !=
par_->end(); ++
i) {
219 LogDebug(
"SimG4CoreGeometry") <<
"z=" << *i / CLHEP::cm;
222 LogDebug(
"SimG4CoreGeometry") <<
"rmin=" << *i / CLHEP::cm;
223 rmin_p.push_back(*i);
225 LogDebug(
"SimG4CoreGeometry") <<
"rmax=" << *i / CLHEP::cm;
226 rmax_p.push_back(*i);
229 LogDebug(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0] / CLHEP::deg <<
" ep=" << (*par_)[1] / CLHEP::deg;
230 return new G4Polyhedra(solid.
name().
name(),
240 #include "G4ExtrudedSolid.hh" 242 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: extr_pgon = " << solid;
250 std::vector<G4TwoVector> polygon;
251 std::vector<G4ExtrudedSolid::ZSection> zsections;
252 for (
unsigned int it = 0; it < x.size(); ++it)
253 polygon.emplace_back(x[it], y[it]);
254 for (
unsigned int it = 0; it < z.size(); ++it)
255 zsections.emplace_back(z[it], G4TwoVector(zx[it], zy[it]), zs[it]);
256 return new G4ExtrudedSolid(solid.
name().
name(), polygon, zsections);
259 #include "G4Torus.hh" 261 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: torus = " << solid;
262 return new G4Torus(solid.
name().
name(),
270 #include "G4UnionSolid.hh" 272 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: unionsolid = " << solid.
name();
273 G4UnionSolid *us =
nullptr;
282 std::vector<double> tdbl(9);
284 CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
286 us =
new G4UnionSolid(solid.
name().
name(), sa, sb,
new CLHEP::HepRotation(temprep), temphvec);
292 #include "G4SubtractionSolid.hh" 295 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: subtraction = " << solid;
296 G4SubtractionSolid *us =
nullptr;
303 std::vector<double> tdbl(9);
305 CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
307 us =
new G4SubtractionSolid(solid.
name().
name(), sa, sb,
new CLHEP::HepRotation(temprep), temphvec);
312 #include "G4IntersectionSolid.hh" 314 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: intersection = " << solid;
315 G4IntersectionSolid *us =
nullptr;
322 std::vector<double> tdbl(9);
324 CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
326 us =
new G4IntersectionSolid(solid.
name().
name(), sa, sb,
new CLHEP::HepRotation(temprep), temphvec);
333 if (
nullptr ==
rot) {
334 rot =
new G4RotationMatrix;
335 rot->rotateX(90. * deg);
338 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: pseudoTrap = " << solid;
339 G4Trd *
trap =
nullptr;
340 G4Tubs *
tubs =
nullptr;
341 G4VSolid *
result =
nullptr;
347 bool intersec =
false;
353 double openingAngle = 2. * asin(x /
std::abs(r));
355 double displacement = 0;
362 h = pt.
y1() < pt.
y2() ? pt.
y2() : pt.
y1();
366 startPhi = 270. * deg - openingAngle / 2.;
369 startPhi = 90. * deg - openingAngle / 2.;
371 }
else if (r > 0 &&
std::abs(r) >= x) {
374 startPhi = 90. * deg - openingAngle / 2.;
378 startPhi = 270. * deg - openingAngle / 2.;
382 throw cms::Exception(
"DetectorDescriptionFault",
"Check parameters of the PseudoTrap! name=" + pt.
name().
name());
384 G4ThreeVector displ(0., 0.,
386 LogDebug(
"SimG4CoreGeometry") <<
"DDSolidConverter::pseudotrap(): displacement=" << displacement
387 <<
" openingAngle=" << openingAngle / deg <<
" x=" << x <<
" h=" <<
h;
391 trap =
new G4Trd(name, pt.
x1(), pt.
x2(), pt.
y1(), pt.
y2(), pt.
halfZ());
392 tubs =
new G4Tubs(name,
399 result =
new G4SubtractionSolid(name, trap, tubs,
rot, displ);
401 G4VSolid *tubicCap =
new G4SubtractionSolid(
402 name, tubs,
new G4Box(name, 1.1 * x,
sqrt(r * r - x * x), 1.1 * h),
nullptr, G4ThreeVector());
403 result =
new G4UnionSolid(name, trap, tubicCap,
rot, displ);
414 LogDebug(
"SimG4CoreGeometry") <<
"before";
416 LogDebug(
"SimG4CoreGeometry") <<
"after";
423 if (rIn <= 0 || rOut <= 0 || cutAtStart <= 0 || cutAtDelta <= 0) {
425 "DetectorDescriptionFault",
432 if (startPhi != 0.) {
438 double r(cutAtStart),
R(cutAtDelta);
439 G4VSolid *
result(
nullptr);
440 G4VSolid *
tubs =
new G4Tubs(name, rIn, rOut, zHalf, startPhi,
deltaPhi);
441 LogDebug(
"SimG4CoreGeometry") <<
"G4Tubs: " << rIn / CLHEP::cm <<
' ' << rOut / CLHEP::cm <<
' ' << zHalf / CLHEP::cm
442 <<
' ' << startPhi / CLHEP::deg <<
' ' <<
deltaPhi / CLHEP::deg;
443 LogDebug(
"SimG4CoreGeometry") << solid;
445 double boxX(30. * rOut),
449 double boxZ(1.1 * zHalf);
454 double cos_alpha = cath / hypo;
456 double alpha = -acos(cos_alpha);
457 LogDebug(
"SimG4CoreGeometry") <<
"cath=" << cath / CLHEP::cm;
458 LogDebug(
"SimG4CoreGeometry") <<
"hypo=" << hypo / CLHEP::cm;
459 LogDebug(
"SimG4CoreGeometry") <<
"al=" << acos(cath / hypo) / CLHEP::deg;
460 LogDebug(
"SimG4CoreGeometry") <<
"deltaPhi=" <<
deltaPhi / CLHEP::deg <<
"\n" 461 <<
"r=" <<
r / CLHEP::cm <<
"\n" 462 <<
"R=" << R / CLHEP::cm;
464 LogDebug(
"SimG4CoreGeometry") <<
"alpha=" << alpha / CLHEP::deg;
467 G4RotationMatrix *
rot =
new G4RotationMatrix;
468 rot->rotateZ(-alpha);
469 LogDebug(
"SimG4CoreGeometry") << (*rot);
479 G4ThreeVector trans(xBox, 0., 0.);
480 LogDebug(
"SimG4CoreGeometry") <<
"trans=" << trans;
482 G4VSolid *
box =
new G4Box(name, boxX, boxY, boxZ);
483 result =
new G4SubtractionSolid(name, tubs, box, rot, trans);
488 #include "G4Sphere.hh" 490 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: sphere = " << solid;
492 return new G4Sphere(solid.
name().
name(),
501 #include "G4EllipticalTube.hh" 503 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: ellipticaltube = " << solid;
double cutAtStart(void) const
truncation at begin of the tube-section
static G4VSolid * polyhedra_rrz(const DDSolid &)
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
static G4RotationMatrix * rot
bool cutInside(void) const
true, if truncation is on the inner side of the tube-section
A truncated tube section.
double zHalf(void) const
half of the z-Axis
double y2(void) const
half length along y on +z
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 &)
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 rIn(void) const
inner radius
static G4VSolid * sphere(const DDSolid &)
DDTranslation translation(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)
static G4VSolid * pseudotrap(const DDSolid &s)
DDRotation rotation(void) const
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 * intersection(const DDSolid &)
G4VSolid * convert(const DDSolid &)
double startPhi(void) const
angular start of the tube-section
static G4VSolid * unionsolid(const DDSolid &)
static G4VSolid * extrudedpolygon(const DDSolid &)
std::map< DDSolidShape, FNPTR > convDispatch_
static G4VSolid * trunctubs(const DDSolid &)
double zHeight(void) const
const DDRotationMatrix & rotation() const
Returns the read-only rotation-matrix.
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
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.)