8 #include "G4SystemOfUnits.hh"
46 edm::LogError(
"SimG4CoreGeometry") <<
" DDG4SolidConverter::convert(..) found an undefined DDSolid " << s.
toString();
47 throw cms::Exception(
"SimG4CoreGeometry",
"DDG4SolidConverter::convert(..) found an undefined DDSolid " + s.
toString());
51 map<DDSolidShape,FNPTR>::iterator it = convDispatch_.find(s.
shape());
52 if (it != convDispatch_.end()) {
53 result = it->second(s);
57 <<
"DDG4SolidConverter::convert: conversion failed for s=" << s
58 <<
"\n solid.shape()=" << s.
shape()
68 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: box = " <<
s ;
69 return new G4Box(s.
name().
name(), (*par_)[0],(*par_)[1],(*par_)[2]);
76 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: tubs = " <<
s ;
77 return new G4Tubs(s.
name().
name(), (*par_)[1],
88 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: trap = " <<
s ;
89 return new G4Trap(s.
name().
name(), (*par_)[0],
106 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: cons = " <<
s ;
107 return new G4Cons(s.
name().
name(), (*par_)[1],
117 #include "G4Polycone.hh"
120 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: pcon_rz = " <<
s ;
123 vector<double>::const_iterator
i = (*par_).begin()+2;
125 for(; i!=(*par_).end(); ++
i) {
126 LogDebug(
"SimG4CoreGeometry") <<
"z=" << *
i ;
127 z.push_back(*i); ++
i;
128 LogDebug(
"SimG4CoreGeometry") <<
" r=" << *
i ;
132 LogDebug(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0]/deg <<
" ep=" << (*par_)[1]/deg ;
141 return new G4Polycone(s.
name().
name(), (*par_)[0], (*par_)[1],
150 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: pcon_rrz = " <<
s ;
152 vector<double> rmin_p;
153 vector<double> rmax_p;
154 vector<double>::const_iterator
i = par_->begin()+2;
156 for (; i!=par_->end(); ++
i) {
157 LogDebug(
"SimG4CoreGeometry") <<
"z=" << *
i ;
158 z_p.push_back(*i); ++
i;
159 LogDebug(
"SimG4CoreGeometry") <<
"rmin=" << *
i ;
160 rmin_p.push_back(*i); ++
i;
161 LogDebug(
"SimG4CoreGeometry") <<
"rmax=" << *
i ;
162 rmax_p.push_back(*i);
165 LogDebug(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0]/deg <<
" ep=" << (*par_)[1]/deg ;
174 return new G4Polycone(s.
name().
name(), (*par_)[0], (*par_)[1],
183 #include "G4Polyhedra.hh"
186 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: phed_rz = " <<
s ;
189 vector<double>::const_iterator
i = par_->begin()+3;
192 for(; i!=par_->end(); ++
i) {
193 z.push_back(*i); ++
i;
198 return new G4Polyhedra(s.
name().
name(), (*par_)[1], (*par_)[2], int((*par_)[0]),
207 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: phed_rrz = " <<
s ;
209 vector<double> rmin_p;
210 vector<double> rmax_p;
211 vector<double>::const_iterator
i = par_->begin()+3;
213 for (; i!=par_->end(); ++
i) {
214 LogDebug(
"SimG4CoreGeometry") <<
"z=" << *
i ;
215 z_p.push_back(*i); ++
i;
216 LogDebug(
"SimG4CoreGeometry") <<
"rmin=" << *
i ;
217 rmin_p.push_back(*i); ++
i;
218 LogDebug(
"SimG4CoreGeometry") <<
"rmax=" << *
i ;
219 rmax_p.push_back(*i);
222 LogDebug(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0]/deg <<
" ep=" << (*par_)[1]/deg ;
223 return new G4Polyhedra(s.
name().
name(), (*par_)[1], (*par_)[2], int((*par_)[0]),
230 #include "G4Torus.hh"
233 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: torus = " <<
s ;
234 return new G4Torus(s.
name().
name(), (*par_)[0],
242 #include "G4ReflectedSolid.hh"
245 static const HepGeom::ReflectZ3D z_reflection;
250 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: reflected = " <<
s ;
251 G4ReflectedSolid * rs = 0;
254 rs =
new G4ReflectedSolid(s.
name().
name(),
263 #include "G4UnionSolid.hh"
266 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: unionsolid = " << s.
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(s.
name().
name(),
283 new CLHEP::HepRotation(temprep),
291 #include "G4SubtractionSolid.hh"
295 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: subtraction = " <<
s ;
296 G4SubtractionSolid * us = 0;
306 std::vector<double> tdbl(9);
307 bs.
rotation().
rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
308 CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
310 us =
new G4SubtractionSolid(s.
name().
name(),
313 new CLHEP::HepRotation(temprep),
320 #include "G4IntersectionSolid.hh"
323 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: intersection = " <<
s ;
324 G4IntersectionSolid * us = 0;
331 std::vector<double> tdbl(9);
332 bs.
rotation().
rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
333 CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
335 us =
new G4IntersectionSolid(s.
name().
name(),
338 new CLHEP::HepRotation(temprep),
348 static G4RotationMatrix *
rot = 0;
352 rot =
new G4RotationMatrix;
353 rot->rotateX(90.*deg);
356 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: pseudoTrap = " <<
s ;
365 bool intersec =
false;
372 double openingAngle = 2.*asin(x/
abs(r));
374 double displacement=0;
379 if (r < 0 &&
abs(r) >= x) {
381 h = pt.
y1() < pt.
y2() ? pt.
y2() : pt.
y1();
385 startPhi = 270.*deg - openingAngle/2.;
389 startPhi = 90.*deg - openingAngle/2.;
392 else if ( r > 0 &&
abs(r) >= x )
396 startPhi = 90.*deg - openingAngle/2.;
401 startPhi = 270.*deg - openingAngle/2.;
406 throw cms::Exception(
"DetectorDescriptionFault",
"Check parameters of the PseudoTrap! name=" + pt.
name().
name());
408 G4ThreeVector displ(0.,0.,displacement);
409 LogDebug(
"SimG4CoreGeometry") <<
"DDSolidConverter::pseudotrap(): displacement=" << displacement
410 <<
" openingAngle=" << openingAngle/deg <<
" x=" << x <<
" h=" <<
h;
414 trap =
new G4Trd(name, pt.
x1(), pt.
x2(), pt.
y1(), pt.
y2(), pt.
halfZ());
415 tubs =
new G4Tubs(name,
422 result =
new G4SubtractionSolid(name, trap, tubs, rot, displ);
426 G4VSolid * tubicCap =
new G4SubtractionSolid(name,
428 new G4Box(name, 1.1*x,
sqrt(r*r-x*x), 1.1*h),
431 result =
new G4UnionSolid(name, trap, tubicCap, rot, displ);
455 LogDebug(
"SimG4CoreGeometry") <<
"before";
457 LogDebug(
"SimG4CoreGeometry") <<
"after";
458 double rIn(tt.
rIn()), rOut(tt.
rOut()), zHalf(tt.
zHalf()),
465 if (rIn <= 0 || rOut <=0 || cutAtStart <=0 || cutAtDelta <= 0) {
466 throw cms::Exception(
"DetectorDescriptionFault",
"TruncTubs " +
string(tt.
name().
fullname()) +
": 0 <= rIn,cutAtStart,rOut,cutAtDelta,rOut violated!");
471 if (startPhi != 0.) {
472 throw cms::Exception(
"DetectorDescriptionFault",
"TruncTubs " +
string(tt.
name().
fullname()) +
": startPhi != 0 not supported!");
479 double r(cutAtStart),
R(cutAtDelta);
481 G4VSolid * tubs =
new G4Tubs(name,rIn,rOut,zHalf,startPhi,
deltaPhi);
482 LogDebug(
"SimG4CoreGeometry") <<
"G4Tubs: " << rIn <<
' ' << rOut <<
' ' << zHalf <<
' ' << startPhi/deg <<
' ' <<
deltaPhi/deg;
485 double boxX(30.*rOut), boxY(20.*rOut);
488 double boxZ(1.1*zHalf);
493 double cos_alpha = cath/hypo;
495 double alpha = -acos(cos_alpha);
496 LogDebug(
"SimG4CoreGeometry") <<
"cath=" << cath/
m;
497 LogDebug(
"SimG4CoreGeometry") <<
"hypo=" << hypo/
m;
498 LogDebug(
"SimG4CoreGeometry") <<
"al=" << acos(cath/hypo)/deg;
500 <<
"r=" <<
r/
m <<
"\n"
503 LogDebug(
"SimG4CoreGeometry") <<
"alpha=" << alpha/deg;
506 G4RotationMatrix *
rot =
new G4RotationMatrix;
507 rot->rotateZ(-alpha);
508 LogDebug(
"SimG4CoreGeometry") << (*rot);
515 xBox = -(boxY/
sin(
abs(alpha))-
r);
518 G4ThreeVector
trans(xBox,0.,0.);
521 G4VSolid * box =
new G4Box(name,boxX,boxY,boxZ);
522 result =
new G4SubtractionSolid(name,tubs,box,rot,trans);
528 #include "G4Sphere.hh"
531 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: sphere = " <<
s ;
544 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: orb = " <<
s ;
549 #include "G4EllipticalTube.hh"
552 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: ellipticaltube = " <<
s ;
554 return new G4EllipticalTube(s.
name().
name(),
560 #include "G4Ellipsoid.hh"
563 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: ellipsoid = " <<
s ;
565 return new G4Ellipsoid(s.
name().
name(),
576 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 &)
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
double outerRadius(void) const
static const char *const name(DDSolidShape s)
DDSolid unreflected(void) const
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
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
static G4VSolid * pseudotrap(const DDSolid &)
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.)