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 ;
133 return new G4Polycone(s.
name().
name(), (*par_)[0], (*par_)[1],
142 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: pcon_rrz = " <<
s ;
144 vector<double> rmin_p;
145 vector<double> rmax_p;
146 vector<double>::const_iterator
i = par_->begin()+2;
148 for (; i!=par_->end(); ++
i) {
149 LogDebug(
"SimG4CoreGeometry") <<
"z=" << *
i ;
150 z_p.push_back(*i); ++
i;
151 LogDebug(
"SimG4CoreGeometry") <<
"rmin=" << *
i ;
152 rmin_p.push_back(*i); ++
i;
153 LogDebug(
"SimG4CoreGeometry") <<
"rmax=" << *
i ;
154 rmax_p.push_back(*i);
157 LogDebug(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0]/deg <<
" ep=" << (*par_)[1]/deg ;
158 return new G4Polycone(s.
name().
name(), (*par_)[0], (*par_)[1],
167 #include "G4Polyhedra.hh"
170 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: phed_rz = " <<
s ;
173 vector<double>::const_iterator
i = par_->begin()+3;
176 for(; i!=par_->end(); ++
i) {
177 z.push_back(*i); ++
i;
182 return new G4Polyhedra(s.
name().
name(), (*par_)[1], (*par_)[2], int((*par_)[0]),
191 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: phed_rrz = " <<
s ;
193 vector<double> rmin_p;
194 vector<double> rmax_p;
195 vector<double>::const_iterator
i = par_->begin()+3;
197 for (; i!=par_->end(); ++
i) {
198 LogDebug(
"SimG4CoreGeometry") <<
"z=" << *
i ;
199 z_p.push_back(*i); ++
i;
200 LogDebug(
"SimG4CoreGeometry") <<
"rmin=" << *
i ;
201 rmin_p.push_back(*i); ++
i;
202 LogDebug(
"SimG4CoreGeometry") <<
"rmax=" << *
i ;
203 rmax_p.push_back(*i);
206 LogDebug(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0]/deg <<
" ep=" << (*par_)[1]/deg ;
207 return new G4Polyhedra(s.
name().
name(), (*par_)[1], (*par_)[2], int((*par_)[0]),
214 #include "G4Torus.hh"
217 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: torus = " <<
s ;
218 return new G4Torus(s.
name().
name(), (*par_)[0],
226 #include "G4ReflectedSolid.hh"
229 static const HepGeom::ReflectZ3D z_reflection;
234 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: reflected = " <<
s ;
235 G4ReflectedSolid * rs = 0;
238 rs =
new G4ReflectedSolid(s.
name().
name(),
247 #include "G4UnionSolid.hh"
250 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: unionsolid = " << s.
name() ;
251 G4UnionSolid * us = 0;
260 std::vector<double> tdbl(9);
261 bs.
rotation().
rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
262 CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
264 us =
new G4UnionSolid(s.
name().
name(),
267 new CLHEP::HepRotation(temprep),
275 #include "G4SubtractionSolid.hh"
279 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: subtraction = " <<
s ;
280 G4SubtractionSolid * us = 0;
290 std::vector<double> tdbl(9);
291 bs.
rotation().
rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
292 CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
294 us =
new G4SubtractionSolid(s.
name().
name(),
297 new CLHEP::HepRotation(temprep),
304 #include "G4IntersectionSolid.hh"
307 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: intersection = " <<
s ;
308 G4IntersectionSolid * us = 0;
315 std::vector<double> tdbl(9);
316 bs.
rotation().
rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
317 CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
319 us =
new G4IntersectionSolid(s.
name().
name(),
322 new CLHEP::HepRotation(temprep),
332 static G4RotationMatrix *
rot = 0;
336 rot =
new G4RotationMatrix;
337 rot->rotateX(90.*deg);
340 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: pseudoTrap = " <<
s ;
349 bool intersec =
false;
356 double openingAngle = 2.*asin(x/
abs(r));
358 double displacement=0;
363 if (r < 0 &&
abs(r) >= x) {
365 h = pt.
y1() < pt.
y2() ? pt.
y2() : pt.
y1();
369 startPhi = 270.*deg - openingAngle/2.;
373 startPhi = 90.*deg - openingAngle/2.;
376 else if ( r > 0 &&
abs(r) >= x )
380 startPhi = 90.*deg - openingAngle/2.;
385 startPhi = 270.*deg - openingAngle/2.;
390 throw cms::Exception(
"DetectorDescriptionFault",
"Check parameters of the PseudoTrap! name=" + pt.
name().
name());
392 G4ThreeVector displ(0.,0.,displacement);
393 LogDebug(
"SimG4CoreGeometry") <<
"DDSolidConverter::pseudotrap(): displacement=" << displacement
394 <<
" openingAngle=" << openingAngle/deg <<
" x=" << x <<
" h=" <<
h;
398 trap =
new G4Trd(name, pt.
x1(), pt.
x2(), pt.
y1(), pt.
y2(), pt.
halfZ());
399 tubs =
new G4Tubs(name,
406 result =
new G4SubtractionSolid(name, trap, tubs, rot, displ);
410 G4VSolid * tubicCap =
new G4SubtractionSolid(name,
412 new G4Box(name, 1.1*x,
sqrt(r*r-x*x), 1.1*h),
415 result =
new G4UnionSolid(name, trap, tubicCap, rot, displ);
439 LogDebug(
"SimG4CoreGeometry") <<
"before";
441 LogDebug(
"SimG4CoreGeometry") <<
"after";
442 double rIn(tt.
rIn()), rOut(tt.
rOut()), zHalf(tt.
zHalf()),
449 if (rIn <= 0 || rOut <=0 || cutAtStart <=0 || cutAtDelta <= 0) {
450 throw cms::Exception(
"DetectorDescriptionFault",
"TruncTubs " +
string(tt.
name().
fullname()) +
": 0 <= rIn,cutAtStart,rOut,cutAtDelta,rOut violated!");
455 if (startPhi != 0.) {
456 throw cms::Exception(
"DetectorDescriptionFault",
"TruncTubs " +
string(tt.
name().
fullname()) +
": startPhi != 0 not supported!");
463 double r(cutAtStart),
R(cutAtDelta);
465 G4VSolid * tubs =
new G4Tubs(name,rIn,rOut,zHalf,startPhi,
deltaPhi);
466 LogDebug(
"SimG4CoreGeometry") <<
"G4Tubs: " << rIn <<
' ' << rOut <<
' ' << zHalf <<
' ' << startPhi/deg <<
' ' <<
deltaPhi/deg;
469 double boxX(30.*rOut), boxY(20.*rOut);
472 double boxZ(1.1*zHalf);
477 double cos_alpha = cath/hypo;
479 double alpha = -acos(cos_alpha);
480 LogDebug(
"SimG4CoreGeometry") <<
"cath=" << cath/
m;
481 LogDebug(
"SimG4CoreGeometry") <<
"hypo=" << hypo/
m;
482 LogDebug(
"SimG4CoreGeometry") <<
"al=" << acos(cath/hypo)/deg;
484 <<
"r=" <<
r/
m <<
"\n"
487 LogDebug(
"SimG4CoreGeometry") <<
"alpha=" << alpha/deg;
490 G4RotationMatrix *
rot =
new G4RotationMatrix;
491 rot->rotateZ(-alpha);
492 LogDebug(
"SimG4CoreGeometry") << (*rot);
499 xBox = -(boxY/
sin(
abs(alpha))-
r);
502 G4ThreeVector trans(xBox,0.,0.);
503 LogDebug(
"SimG4CoreGeometry") <<
"trans=" << trans;
505 G4VSolid * box =
new G4Box(name,boxX,boxY,boxZ);
506 result =
new G4SubtractionSolid(name,tubs,box,rot,trans);
512 #include "G4Sphere.hh"
515 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: sphere = " <<
s ;
528 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: orb = " <<
s ;
533 #include "G4EllipticalTube.hh"
536 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: ellipticaltube = " <<
s ;
538 return new G4EllipticalTube(s.
name().
name(),
544 #include "G4Ellipsoid.hh"
547 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: ellipsoid = " <<
s ;
549 return new G4Ellipsoid(s.
name().
name(),
560 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
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 &)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
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.)