48 edm::LogError(
"SimG4CoreGeometry") <<
" DDG4SolidConverter::convert(..) found an undefined DDSolid " << s.
toString();
49 throw cms::Exception(
"SimG4CoreGeometry",
"DDG4SolidConverter::convert(..) found an undefined DDSolid " + s.
toString());
53 map<DDSolidShape,FNPTR>::iterator it = convDispatch_.find(s.
shape());
54 if (it != convDispatch_.end()) {
55 result = it->second(s);
59 o <<
"DDG4SolidConverter::convert: conversion failed for s=" << s << endl;
60 o <<
" solid.shape()=" << s.
shape() << endl;
70 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: box = " <<
s ;
71 return new G4Box(s.
name().
name(), (*par_)[0],(*par_)[1],(*par_)[2]);
78 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: tubs = " <<
s ;
79 return new G4Tubs(s.
name().
name(), (*par_)[1],
90 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: trap = " <<
s ;
91 return new G4Trap(s.
name().
name(), (*par_)[0],
108 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: cons = " <<
s ;
109 return new G4Cons(s.
name().
name(), (*par_)[1],
119 #include "G4Polycone.hh"
122 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: pcon_rz = " <<
s ;
123 vector<double>* r_p =
new vector<double>;
124 vector<double>* z_p =
new vector<double>;
125 vector<double>&
r = *r_p;
126 vector<double>&
z = *z_p;
127 vector<double>::const_iterator
i = (*par_).begin()+2;
129 for(; i!=(*par_).end(); ++
i) {
130 LogDebug(
"SimG4CoreGeometry") <<
"z=" << *
i ;
131 z.push_back(*i); ++
i;
132 LogDebug(
"SimG4CoreGeometry") <<
" r=" << *
i ;
136 LogDebug(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0]/deg <<
" ep=" << (*par_)[1]/deg ;
137 return new G4Polycone(s.
name().
name(), (*par_)[0], (*par_)[1],
146 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: pcon_rrz = " <<
s ;
147 vector<double>* z_p =
new vector<double>;
148 vector<double>* rmin_p =
new vector<double>;
149 vector<double>* rmax_p =
new vector<double>;
150 vector<double>::const_iterator
i = par_->begin()+2;
152 for (; i!=par_->end(); ++
i) {
153 LogDebug(
"SimG4CoreGeometry") <<
"z=" << *
i ;
154 (*z_p).push_back(*i); ++
i;
155 LogDebug(
"SimG4CoreGeometry") <<
"rmin=" << *
i ;
156 (*rmin_p).push_back(*i); ++
i;
157 LogDebug(
"SimG4CoreGeometry") <<
"rmax=" << *
i ;
158 (*rmax_p).push_back(*i);
161 LogDebug(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0]/deg <<
" ep=" << (*par_)[1]/deg ;
162 return new G4Polycone(s.
name().
name(), (*par_)[0], (*par_)[1],
171 #include "G4Polyhedra.hh"
174 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: phed_rz = " <<
s ;
175 vector<double>* r_p =
new vector<double>;
176 vector<double>* z_p =
new vector<double>;
177 vector<double>&
r = *r_p;
178 vector<double>&
z = *z_p;
179 vector<double>::const_iterator
i = par_->begin()+3;
182 for(; i!=par_->end(); ++
i) {
183 z.push_back(*i); ++
i;
188 return new G4Polyhedra(s.
name().
name(), (*par_)[1], (*par_)[2], int((*par_)[0]),
197 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: phed_rrz = " <<
s ;
198 vector<double>* z_p =
new vector<double>;
199 vector<double>* rmin_p =
new vector<double>;
200 vector<double>* rmax_p =
new vector<double>;
201 vector<double>::const_iterator
i = par_->begin()+3;
203 for (; i!=par_->end(); ++
i) {
204 LogDebug(
"SimG4CoreGeometry") <<
"z=" << *
i ;
205 (*z_p).push_back(*i); ++
i;
206 LogDebug(
"SimG4CoreGeometry") <<
"rmin=" << *
i ;
207 (*rmin_p).push_back(*i); ++
i;
208 LogDebug(
"SimG4CoreGeometry") <<
"rmax=" << *
i ;
209 (*rmax_p).push_back(*i);
212 LogDebug(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0]/deg <<
" ep=" << (*par_)[1]/deg ;
213 return new G4Polyhedra(s.
name().
name(), (*par_)[1], (*par_)[2], int((*par_)[0]),
221 #include "G4Torus.hh"
224 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: torus = " <<
s ;
225 return new G4Torus(s.
name().
name(), (*par_)[0],
233 #include "G4ReflectedSolid.hh"
236 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: reflected = " <<
s ;
237 G4ReflectedSolid * rs = 0;
240 static HepGeom::ReflectZ3D z_reflection;
241 rs =
new G4ReflectedSolid(s.
name().
name(),
250 #include "G4UnionSolid.hh"
253 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: unionsolid = " << s.
name() ;
254 G4UnionSolid * us = 0;
263 std::vector<double> tdbl(9);
264 bs.
rotation().
rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
265 CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
267 us =
new G4UnionSolid(s.
name().
name(),
270 new CLHEP::HepRotation(temprep),
278 #include "G4SubtractionSolid.hh"
282 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: subtraction = " <<
s ;
283 G4SubtractionSolid * us = 0;
293 std::vector<double> tdbl(9);
294 bs.
rotation().
rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
295 CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
297 us =
new G4SubtractionSolid(s.
name().
name(),
300 new CLHEP::HepRotation(temprep),
307 #include "G4IntersectionSolid.hh"
310 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: intersection = " <<
s ;
311 G4IntersectionSolid * us = 0;
318 std::vector<double> tdbl(9);
319 bs.
rotation().
rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
320 CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
322 us =
new G4IntersectionSolid(s.
name().
name(),
325 new CLHEP::HepRotation(temprep),
335 static G4RotationMatrix * rot = 0;
339 rot =
new G4RotationMatrix;
340 rot->rotateX(90.*deg);
343 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: pseudoTrap = " <<
s ;
352 bool intersec =
false;
359 double openingAngle = 2.*asin(x/
abs(r));
361 double displacement=0;
366 if (r < 0 &&
abs(r) >= x) {
368 h = pt.
y1() < pt.
y2() ? pt.
y2() : pt.
y1();
372 startPhi = 270.*deg - openingAngle/2.;
376 startPhi = 90.*deg - openingAngle/2.;
379 else if ( r > 0 &&
abs(r) >= x )
383 startPhi = 90.*deg - openingAngle/2.;
388 startPhi = 270.*deg - openingAngle/2.;
395 G4ThreeVector displ(0.,0.,displacement);
396 LogDebug(
"SimG4CoreGeometry") <<
"DDSolidConverter::pseudotrap(): displacement=" << displacement
397 <<
" openingAngle=" << openingAngle/deg <<
" x=" << x <<
" h=" <<
h;
401 trap =
new G4Trd(name, pt.
x1(), pt.
x2(), pt.
y1(), pt.
y2(), pt.
halfZ());
402 tubs =
new G4Tubs(name,
409 result =
new G4SubtractionSolid(name, trap, tubs, rot, displ);
413 G4VSolid * tubicCap =
new G4SubtractionSolid(name,
415 new G4Box(name, 1.1*x,
sqrt(r*r-x*x), 1.1*h),
418 result =
new G4UnionSolid(name, trap, tubicCap, rot, displ);
442 LogDebug(
"SimG4CoreGeometry") <<
"before";
444 LogDebug(
"SimG4CoreGeometry") <<
"after";
445 double rIn(tt.
rIn()), rOut(tt.
rOut()), zHalf(tt.
zHalf()),
452 if (rIn <= 0 || rOut <=0 || cutAtStart <=0 || cutAtDelta <= 0) {
453 string s =
"TruncTubs " + string(tt.
name().
fullname()) +
": 0 <= rIn,cutAtStart,rOut,cutAtDelta,rOut violated!";
457 string s =
"TruncTubs " + string(tt.
name().
fullname()) +
": rIn<rOut violated!";
460 if (startPhi != 0.) {
461 string s=
"TruncTubs " + string(tt.
name().
fullname()) +
": startPhi != 0 not supported!";
470 double r(cutAtStart),
R(cutAtDelta);
472 G4VSolid * tubs =
new G4Tubs(name,rIn,rOut,zHalf,startPhi,
deltaPhi);
473 LogDebug(
"SimG4CoreGeometry") <<
"G4Tubs: " << rIn <<
' ' << rOut <<
' ' << zHalf <<
' ' << startPhi/deg <<
' ' <<
deltaPhi/deg;
476 double boxX(30.*rOut), boxY(20.*rOut);
479 double boxZ(1.1*zHalf);
484 double cos_alpha = cath/hypo;
486 double alpha = -acos(cos_alpha);
487 LogDebug(
"SimG4CoreGeometry") <<
"cath=" << cath/
m;
488 LogDebug(
"SimG4CoreGeometry") <<
"hypo=" << hypo/
m;
489 LogDebug(
"SimG4CoreGeometry") <<
"al=" << acos(cath/hypo)/deg;
491 <<
"r=" <<
r/
m <<
"\n"
494 LogDebug(
"SimG4CoreGeometry") <<
"alpha=" << alpha/deg;
497 G4RotationMatrix * rot =
new G4RotationMatrix;
498 rot->rotateZ(-alpha);
499 LogDebug(
"SimG4CoreGeometry") << (*rot);
506 xBox = -(boxY/
sin(
abs(alpha))-
r);
509 G4ThreeVector trans(xBox,0.,0.);
510 LogDebug(
"SimG4CoreGeometry") <<
"trans=" << trans;
512 G4VSolid * box =
new G4Box(name,boxX,boxY,boxZ);
513 result =
new G4SubtractionSolid(name,tubs,box,rot,trans);
519 #include "G4Sphere.hh"
522 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: sphere = " <<
s ;
535 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: orb = " <<
s ;
540 #include "G4EllipticalTube.hh"
543 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: ellipticaltube = " <<
s ;
545 return new G4EllipticalTube(s.
name().
name(),
551 #include "G4Ellipsoid.hh"
554 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: ellipsoid = " <<
s ;
556 return new G4Ellipsoid(s.
name().
name(),
567 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: parallelepiped = " <<
s ;
const std::vector< double > & parameters() const
Don't use (only meant to be used by DDbox(), DDtub(), ...)
const DDRotationMatrix * rotation() const
Returns the read-only rotation-matrix.
static G4VSolid * polyhedra_rrz(const DDSolid &)
double deltaTheta() const
static const std::vector< double > * par_
static G4VSolid * orb(const DDSolid &)
A truncated tube section.
double x2() const
half length along x on +z
static G4VSolid * ellipsoid(const DDSolid &)
double deltaPhi() const
angular span of the tube-section
double rIn() const
inner radius
DDSolidShape shape() const
The type of the solid.
double deltaPhi(float phi1, float phi2)
double startPhi() const
angular start of the tube-section
static G4VSolid * trap(const DDSolid &)
Sin< T >::type sin(const T &t)
static G4VSolid * cons(const DDSolid &)
An exception for DDD errors.
static G4VSolid * tubs(const DDSolid &)
double zHalf() const
half of the z-Axis
static G4VSolid * sphere(const DDSolid &)
A DDSolid represents the shape of a part.
double cutAtStart() const
truncation at begin of the tube-section
double innerRadius() const
double y1() const
half length along y on -z
double radius() const
radius of the cut-out (neg.) or rounding (pos.)
DDSolid unreflected() const
static G4VSolid * reflected(const DDSolid &)
static const char * name(DDSolidShape s)
static G4VSolid * para(const DDSolid &)
double halfZ() const
half of the z-Axis
double cutAtDelta() const
truncation at end of the tube-section
Cos< T >::type cos(const T &t)
const std::string fullname() const
static G4VSolid * pseudotrap(const DDSolid &)
static G4VSolid * box(const DDSolid &)
double zBottomCut() const
double x1() const
half length along x on -z
std::string toString() const
static G4VSolid * ellipticaltube(const DDSolid &)
static G4VSolid * polycone_rz(const DDSolid &)
bool cutInside() const
true, if truncation is on the inner side of the tube-section
static G4VSolid * intersection(const DDSolid &)
G4VSolid * convert(const DDSolid &)
static G4VSolid * unionsolid(const DDSolid &)
static G4VSolid * trunctubs(const DDSolid &)
double rOut() const
outer radius
double startTheta() const
static G4VSolid * torus(const DDSolid &)
static G4VSolid * polyhedra_rz(const DDSolid &)
double y2() const
half length along y on +z
DDRotation rotation() const
double outerRadius() const
static G4VSolid * polycone_rrz(const DDSolid &)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
DDTranslation translation() const
const std::string & name() const
Returns the name.
static G4VSolid * subtraction(const DDSolid &)
bool atMinusZ() const
true, if cut-out or rounding is on the -z side