8 #include "G4SystemOfUnits.hh" 43 edm::LogError(
"SimG4CoreGeometry") <<
" DDG4SolidConverter::convert(..) found an undefined DDSolid " << solid.
toString();
44 throw cms::Exception(
"SimG4CoreGeometry",
"DDG4SolidConverter::convert(..) found an undefined DDSolid " + solid.
toString());
46 G4VSolid *
result =
nullptr;
50 result = it->second(solid);
53 <<
"DDG4SolidConverter::convert: conversion failed for s=" << solid
54 <<
"\n solid.shape()=" << solid.
shape()
63 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: box = " << solid;
64 return new G4Box(solid.
name().
name(), (*par_)[0],(*par_)[1],(*par_)[2]);
70 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: tubs = " << solid;
71 return new G4Tubs(solid.
name().
name(), (*par_)[1],
78 #include "G4CutTubs.hh" 80 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: tubs = " << solid;
81 return new G4CutTubs(solid.
name().
name(), (*par_)[1],
86 G4ThreeVector((*par_)[5],(*par_)[6],(*par_)[7]),
87 G4ThreeVector((*par_)[8],(*par_)[9],(*par_)[10]));
93 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: trap = " << solid;
94 return new G4Trap(solid.
name().
name(), (*par_)[0],
110 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: cons = " << solid;
111 return new G4Cons(solid.
name().
name(), (*par_)[1],
121 #include "G4Polycone.hh" 123 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: pcon_rz = " << solid;
124 std::vector<double>
r;
125 std::vector<double>
z;
126 std::vector<double>::const_iterator
i = (*par_).begin()+2;
128 for(; i!=(*par_).end(); ++
i) {
129 LogDebug(
"SimG4CoreGeometry") <<
" z=" << *i/CLHEP::cm;
130 z.push_back(*i); ++
i;
131 LogDebug(
"SimG4CoreGeometry") <<
" r=" << *i/CLHEP::cm;
135 LogDebug(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0]/CLHEP::deg <<
" ep=" 136 << (*par_)[1]/CLHEP::deg;
145 return new G4Polycone(solid.
name().
name(), (*par_)[0], (*par_)[1],
153 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: pcon_rrz = " << solid;
154 std::vector<double> z_p;
155 std::vector<double> rmin_p;
156 std::vector<double> rmax_p;
157 std::vector<double>::const_iterator
i =
par_->begin()+2;
159 for (; i!=
par_->end(); ++
i) {
160 LogDebug(
"SimG4CoreGeometry") <<
"z=" << *i/CLHEP::cm;
161 z_p.push_back(*i); ++
i;
162 LogDebug(
"SimG4CoreGeometry") <<
"rmin=" << *i/CLHEP::cm;
163 rmin_p.push_back(*i); ++
i;
164 LogDebug(
"SimG4CoreGeometry") <<
"rmax=" << *i/CLHEP::cm;
165 rmax_p.push_back(*i);
168 LogDebug(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0]/CLHEP::deg <<
" ep=" 169 << (*par_)[1]/CLHEP::deg;
178 return new G4Polycone(solid.
name().
name(), (*par_)[0], (*par_)[1],
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) {
196 z.push_back(*i); ++
i;
201 return new G4Polyhedra(solid.
name().
name(), (*par_)[1], (*par_)[2],
int((*par_)[0]),
209 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: phed_rrz = " << solid;
210 std::vector<double> z_p;
211 std::vector<double> rmin_p;
212 std::vector<double> rmax_p;
213 std::vector<double>::const_iterator
i =
par_->begin()+3;
215 for (; i!=
par_->end(); ++
i) {
216 LogDebug(
"SimG4CoreGeometry") <<
"z=" << *i/CLHEP::cm;
217 z_p.push_back(*i); ++
i;
218 LogDebug(
"SimG4CoreGeometry") <<
"rmin=" << *i/CLHEP::cm;
219 rmin_p.push_back(*i); ++
i;
220 LogDebug(
"SimG4CoreGeometry") <<
"rmax=" << *i/CLHEP::cm;
221 rmax_p.push_back(*i);
224 LogDebug(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0]/CLHEP::deg <<
" ep=" 225 << (*par_)[1]/CLHEP::deg;
226 return new G4Polyhedra(solid.
name().
name(), (*par_)[1], (*par_)[2],
int((*par_)[0]),
233 #include "G4Torus.hh" 235 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: torus = " << solid;
236 return new G4Torus(solid.
name().
name(), (*par_)[0],
244 #include "G4ReflectedSolid.hh" 247 static const HepGeom::ReflectZ3D z_reflection;
251 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: reflected = " << solid;
252 G4ReflectedSolid * rs = 0;
255 rs =
new G4ReflectedSolid(solid.
name().
name(),
264 #include "G4UnionSolid.hh" 266 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: unionsolid = " << solid.
name();
267 G4UnionSolid * us = 0;
276 std::vector<double> tdbl(9);
277 bs.
rotation().
rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
278 CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
280 us =
new G4UnionSolid(solid.
name().
name(),
283 new CLHEP::HepRotation(temprep),
291 #include "G4SubtractionSolid.hh" 294 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: subtraction = " << solid;
295 G4SubtractionSolid * us = 0;
305 std::vector<double> tdbl(9);
306 bs.
rotation().
rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
307 CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
309 us =
new G4SubtractionSolid(solid.
name().
name(),
312 new CLHEP::HepRotation(temprep),
319 #include "G4IntersectionSolid.hh" 321 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: intersection = " << solid;
322 G4IntersectionSolid * us = 0;
329 std::vector<double> tdbl(9);
330 bs.
rotation().
rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
331 CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
333 us =
new G4IntersectionSolid(solid.
name().
name(),
336 new CLHEP::HepRotation(temprep),
346 rot =
new G4RotationMatrix;
347 rot->rotateX(90.*deg);
350 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: pseudoTrap = " << solid;
359 bool intersec =
false;
366 double openingAngle = 2.*asin(x/
std::abs(r));
368 double displacement=0;
375 h = pt.
y1() < pt.
y2() ? pt.
y2() : pt.
y1();
379 startPhi = 270.*deg - openingAngle/2.;
383 startPhi = 90.*deg - openingAngle/2.;
386 else if ( r > 0 &&
std::abs(r) >= x )
390 startPhi = 90.*deg - openingAngle/2.;
395 startPhi = 270.*deg - openingAngle/2.;
400 throw cms::Exception(
"DetectorDescriptionFault",
"Check parameters of the PseudoTrap! name=" + pt.
name().
name());
402 G4ThreeVector displ(0.,0.,displacement);
403 LogDebug(
"SimG4CoreGeometry") <<
"DDSolidConverter::pseudotrap(): displacement=" << displacement
404 <<
" openingAngle=" << openingAngle/deg <<
" x=" << x <<
" h=" <<
h;
408 trap =
new G4Trd(name, pt.
x1(), pt.
x2(), pt.
y1(), pt.
y2(), pt.
halfZ());
409 tubs =
new G4Tubs(name,
416 result =
new G4SubtractionSolid(name, trap, tubs,
rot, displ);
420 G4VSolid * tubicCap =
new G4SubtractionSolid(name,
422 new G4Box(name, 1.1*x,
sqrt(r*r-x*x), 1.1*h),
425 result =
new G4UnionSolid(name, trap, tubicCap,
rot, displ);
448 LogDebug(
"SimG4CoreGeometry") <<
"before";
450 LogDebug(
"SimG4CoreGeometry") <<
"after";
451 double rIn(tt.
rIn()), rOut(tt.
rOut()), zHalf(tt.
zHalf()),
458 if (rIn <= 0 || rOut <=0 || cutAtStart <=0 || cutAtDelta <= 0) {
464 if (startPhi != 0.) {
472 double r(cutAtStart),
R(cutAtDelta);
474 G4VSolid *
tubs =
new G4Tubs(name,rIn,rOut,zHalf,startPhi,
deltaPhi);
475 LogDebug(
"SimG4CoreGeometry") <<
"G4Tubs: " << rIn/CLHEP::cm <<
' ' << rOut/CLHEP::cm <<
' ' << zHalf/CLHEP::cm <<
' ' << startPhi/CLHEP::deg <<
' ' <<
deltaPhi/CLHEP::deg;
476 LogDebug(
"SimG4CoreGeometry") << solid;
478 double boxX(30.*rOut), boxY(20.*rOut);
481 double boxZ(1.1*zHalf);
486 double cos_alpha = cath/hypo;
488 double alpha = -acos(cos_alpha);
489 LogDebug(
"SimG4CoreGeometry") <<
"cath=" << cath/CLHEP::cm;
490 LogDebug(
"SimG4CoreGeometry") <<
"hypo=" << hypo/CLHEP::cm;
491 LogDebug(
"SimG4CoreGeometry") <<
"al=" << acos(cath/hypo)/CLHEP::deg;
493 <<
"r=" <<
r/CLHEP::cm <<
"\n" 494 <<
"R=" << R/CLHEP::cm;
496 LogDebug(
"SimG4CoreGeometry") <<
"alpha=" << alpha/CLHEP::deg;
499 G4RotationMatrix *
rot =
new G4RotationMatrix;
500 rot->rotateZ(-alpha);
501 LogDebug(
"SimG4CoreGeometry") << (*rot);
511 G4ThreeVector trans(xBox,0.,0.);
512 LogDebug(
"SimG4CoreGeometry") <<
"trans=" << trans;
514 G4VSolid *
box =
new G4Box(name,boxX,boxY,boxZ);
515 result =
new G4SubtractionSolid(name,tubs,box,rot,trans);
521 #include "G4Sphere.hh" 523 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: sphere = " << solid;
535 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: orb = " << solid;
540 #include "G4EllipticalTube.hh" 542 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: ellipticaltube = " << solid;
544 return new G4EllipticalTube(solid.
name().
name(),
550 #include "G4Ellipsoid.hh" 552 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: ellipsoid = " << solid;
554 return new G4Ellipsoid(solid.
name().
name(),
564 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: parallelepiped = " << solid;
566 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 &)
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 * 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 * 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.)