8 #include "G4SystemOfUnits.hh"
45 edm::LogError(
"SimG4CoreGeometry") <<
" DDG4SolidConverter::convert(..) found an undefined DDSolid " << s.
toString();
46 throw cms::Exception(
"SimG4CoreGeometry",
"DDG4SolidConverter::convert(..) found an undefined DDSolid " + s.
toString());
48 G4VSolid *
result =
nullptr;
50 map<DDSolidShape,FNPTR>::iterator it = convDispatch_.find(s.
shape());
51 if (it != convDispatch_.end()) {
52 result = it->second(s);
56 <<
"DDG4SolidConverter::convert: conversion failed for s=" << s
57 <<
"\n solid.shape()=" << s.
shape()
67 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: box = " <<
s ;
68 return new G4Box(s.
name().
name(), (*par_)[0],(*par_)[1],(*par_)[2]);
75 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: tubs = " <<
s ;
76 return new G4Tubs(s.
name().
name(), (*par_)[1],
87 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: trap = " <<
s ;
88 return new G4Trap(s.
name().
name(), (*par_)[0],
105 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: cons = " <<
s ;
106 return new G4Cons(s.
name().
name(), (*par_)[1],
116 #include "G4Polycone.hh"
119 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: pcon_rz = " <<
s ;
122 vector<double>::const_iterator
i = (*par_).begin()+2;
124 for(; i!=(*par_).end(); ++
i) {
125 LogDebug(
"SimG4CoreGeometry") <<
"z=" << *
i ;
126 z.push_back(*i); ++
i;
127 LogDebug(
"SimG4CoreGeometry") <<
" r=" << *
i ;
131 LogDebug(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0]/deg <<
" ep=" << (*par_)[1]/deg ;
140 return new G4Polycone(s.
name().
name(), (*par_)[0], (*par_)[1],
149 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: pcon_rrz = " <<
s ;
151 vector<double> rmin_p;
152 vector<double> rmax_p;
153 vector<double>::const_iterator
i = par_->begin()+2;
155 for (; i!=par_->end(); ++
i) {
156 LogDebug(
"SimG4CoreGeometry") <<
"z=" << *
i ;
157 z_p.push_back(*i); ++
i;
158 LogDebug(
"SimG4CoreGeometry") <<
"rmin=" << *
i ;
159 rmin_p.push_back(*i); ++
i;
160 LogDebug(
"SimG4CoreGeometry") <<
"rmax=" << *
i ;
161 rmax_p.push_back(*i);
164 LogDebug(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0]/deg <<
" ep=" << (*par_)[1]/deg ;
173 return new G4Polycone(s.
name().
name(), (*par_)[0], (*par_)[1],
182 #include "G4Polyhedra.hh"
185 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: phed_rz = " <<
s ;
188 vector<double>::const_iterator
i = par_->begin()+3;
191 for(; i!=par_->end(); ++
i) {
192 z.push_back(*i); ++
i;
197 return new G4Polyhedra(s.
name().
name(), (*par_)[1], (*par_)[2], int((*par_)[0]),
206 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: phed_rrz = " <<
s ;
208 vector<double> rmin_p;
209 vector<double> rmax_p;
210 vector<double>::const_iterator
i = par_->begin()+3;
212 for (; i!=par_->end(); ++
i) {
213 LogDebug(
"SimG4CoreGeometry") <<
"z=" << *
i ;
214 z_p.push_back(*i); ++
i;
215 LogDebug(
"SimG4CoreGeometry") <<
"rmin=" << *
i ;
216 rmin_p.push_back(*i); ++
i;
217 LogDebug(
"SimG4CoreGeometry") <<
"rmax=" << *
i ;
218 rmax_p.push_back(*i);
221 LogDebug(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0]/deg <<
" ep=" << (*par_)[1]/deg ;
222 return new G4Polyhedra(s.
name().
name(), (*par_)[1], (*par_)[2], int((*par_)[0]),
229 #include "G4Torus.hh"
232 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: torus = " <<
s ;
233 return new G4Torus(s.
name().
name(), (*par_)[0],
241 #include "G4ReflectedSolid.hh"
244 static const HepGeom::ReflectZ3D z_reflection;
249 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: reflected = " <<
s ;
250 G4ReflectedSolid * rs = 0;
253 rs =
new G4ReflectedSolid(s.
name().
name(),
262 #include "G4UnionSolid.hh"
265 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: unionsolid = " << s.
name() ;
266 G4UnionSolid * us = 0;
275 std::vector<double> tdbl(9);
276 bs.
rotation().
rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
277 CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
279 us =
new G4UnionSolid(s.
name().
name(),
282 new CLHEP::HepRotation(temprep),
290 #include "G4SubtractionSolid.hh"
294 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: subtraction = " <<
s ;
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(s.
name().
name(),
312 new CLHEP::HepRotation(temprep),
319 #include "G4IntersectionSolid.hh"
322 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: intersection = " <<
s ;
323 G4IntersectionSolid * us = 0;
330 std::vector<double> tdbl(9);
331 bs.
rotation().
rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
332 CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
334 us =
new G4IntersectionSolid(s.
name().
name(),
337 new CLHEP::HepRotation(temprep),
347 static G4RotationMatrix *
rot = 0;
351 rot =
new G4RotationMatrix;
352 rot->rotateX(90.*deg);
355 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: pseudoTrap = " <<
s ;
364 bool intersec =
false;
371 double openingAngle = 2.*asin(x/
abs(r));
373 double displacement=0;
378 if (r < 0 &&
abs(r) >= x) {
380 h = pt.
y1() < pt.
y2() ? pt.
y2() : pt.
y1();
384 startPhi = 270.*deg - openingAngle/2.;
388 startPhi = 90.*deg - openingAngle/2.;
391 else if ( r > 0 &&
abs(r) >= x )
395 startPhi = 90.*deg - openingAngle/2.;
400 startPhi = 270.*deg - openingAngle/2.;
405 throw cms::Exception(
"DetectorDescriptionFault",
"Check parameters of the PseudoTrap! name=" + pt.
name().
name());
407 G4ThreeVector displ(0.,0.,displacement);
408 LogDebug(
"SimG4CoreGeometry") <<
"DDSolidConverter::pseudotrap(): displacement=" << displacement
409 <<
" openingAngle=" << openingAngle/deg <<
" x=" << x <<
" h=" <<
h;
413 trap =
new G4Trd(name, pt.
x1(), pt.
x2(), pt.
y1(), pt.
y2(), pt.
halfZ());
414 tubs =
new G4Tubs(name,
421 result =
new G4SubtractionSolid(name, trap, tubs, rot, displ);
425 G4VSolid * tubicCap =
new G4SubtractionSolid(name,
427 new G4Box(name, 1.1*x,
sqrt(r*r-x*x), 1.1*h),
430 result =
new G4UnionSolid(name, trap, tubicCap, rot, displ);
454 LogDebug(
"SimG4CoreGeometry") <<
"before";
456 LogDebug(
"SimG4CoreGeometry") <<
"after";
457 double rIn(tt.
rIn()), rOut(tt.
rOut()), zHalf(tt.
zHalf()),
464 if (rIn <= 0 || rOut <=0 || cutAtStart <=0 || cutAtDelta <= 0) {
465 throw cms::Exception(
"DetectorDescriptionFault",
"TruncTubs " +
string(tt.
name().
fullname()) +
": 0 <= rIn,cutAtStart,rOut,cutAtDelta,rOut violated!");
470 if (startPhi != 0.) {
471 throw cms::Exception(
"DetectorDescriptionFault",
"TruncTubs " +
string(tt.
name().
fullname()) +
": startPhi != 0 not supported!");
478 double r(cutAtStart),
R(cutAtDelta);
480 G4VSolid * tubs =
new G4Tubs(name,rIn,rOut,zHalf,startPhi,
deltaPhi);
481 LogDebug(
"SimG4CoreGeometry") <<
"G4Tubs: " << rIn <<
' ' << rOut <<
' ' << zHalf <<
' ' << startPhi/deg <<
' ' <<
deltaPhi/deg;
484 double boxX(30.*rOut), boxY(20.*rOut);
487 double boxZ(1.1*zHalf);
492 double cos_alpha = cath/hypo;
494 double alpha = -acos(cos_alpha);
495 LogDebug(
"SimG4CoreGeometry") <<
"cath=" << cath/
m;
496 LogDebug(
"SimG4CoreGeometry") <<
"hypo=" << hypo/
m;
497 LogDebug(
"SimG4CoreGeometry") <<
"al=" << acos(cath/hypo)/deg;
499 <<
"r=" <<
r/
m <<
"\n"
502 LogDebug(
"SimG4CoreGeometry") <<
"alpha=" << alpha/deg;
505 G4RotationMatrix *
rot =
new G4RotationMatrix;
506 rot->rotateZ(-alpha);
507 LogDebug(
"SimG4CoreGeometry") << (*rot);
514 xBox = -(boxY/
sin(
abs(alpha))-
r);
517 G4ThreeVector trans(xBox,0.,0.);
518 LogDebug(
"SimG4CoreGeometry") <<
"trans=" << trans;
520 G4VSolid * box =
new G4Box(name,boxX,boxY,boxZ);
521 result =
new G4SubtractionSolid(name,tubs,box,rot,trans);
527 #include "G4Sphere.hh"
530 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: sphere = " <<
s ;
543 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: orb = " <<
s ;
548 #include "G4EllipticalTube.hh"
551 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: ellipticaltube = " <<
s ;
553 return new G4EllipticalTube(s.
name().
name(),
559 #include "G4Ellipsoid.hh"
562 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: ellipsoid = " <<
s ;
564 return new G4Ellipsoid(s.
name().
name(),
575 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: parallelepiped = " <<
s ;
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.
static const std::vector< double > * par_
double xSemiAxis(void) const
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
T x() const
Cartesian x coordinate.
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
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
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.)