8 #include "G4SystemOfUnits.hh" 40 edm::LogError(
"SimG4CoreGeometry") <<
" DDG4SolidConverter::convert(..) found an undefined DDSolid " << solid.
toString();
41 throw cms::Exception(
"SimG4CoreGeometry",
"DDG4SolidConverter::convert(..) found an undefined DDSolid " + solid.
toString());
43 G4VSolid *
result =
nullptr;
47 result = it->second(solid);
50 <<
"DDG4SolidConverter::convert: conversion failed for s=" << solid
60 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: box = " << solid;
61 return new G4Box(solid.
name().
name(), (*par_)[0],(*par_)[1],(*par_)[2]);
67 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: tubs = " << solid;
68 return new G4Tubs(solid.
name().
name(), (*par_)[1],
75 #include "G4CutTubs.hh" 77 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: tubs = " << solid;
78 return new G4CutTubs(solid.
name().
name(), (*par_)[1],
83 G4ThreeVector((*par_)[5],(*par_)[6],(*par_)[7]),
84 G4ThreeVector((*par_)[8],(*par_)[9],(*par_)[10]));
90 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: trap = " << solid;
91 return new G4Trap(solid.
name().
name(), (*par_)[0],
107 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: cons = " << solid;
108 return new G4Cons(solid.
name().
name(), (*par_)[1],
118 #include "G4Polycone.hh" 120 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: pcon_rz = " << solid;
121 std::vector<double>
r;
122 std::vector<double>
z;
123 std::vector<double>::const_iterator
i = (*par_).begin()+2;
125 for(; i!=(*par_).end(); ++
i) {
126 LogDebug(
"SimG4CoreGeometry") <<
" z=" << *i/CLHEP::cm;
127 z.push_back(*i); ++
i;
128 LogDebug(
"SimG4CoreGeometry") <<
" r=" << *i/CLHEP::cm;
132 LogDebug(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0]/CLHEP::deg <<
" ep=" 133 << (*par_)[1]/CLHEP::deg;
142 return new G4Polycone(solid.
name().
name(), (*par_)[0], (*par_)[1],
150 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: pcon_rrz = " << solid;
151 std::vector<double> z_p;
152 std::vector<double> rmin_p;
153 std::vector<double> rmax_p;
154 std::vector<double>::const_iterator
i =
par_->begin()+2;
156 for (; i!=
par_->end(); ++
i) {
157 LogDebug(
"SimG4CoreGeometry") <<
"z=" << *i/CLHEP::cm;
158 z_p.push_back(*i); ++
i;
159 LogDebug(
"SimG4CoreGeometry") <<
"rmin=" << *i/CLHEP::cm;
160 rmin_p.push_back(*i); ++
i;
161 LogDebug(
"SimG4CoreGeometry") <<
"rmax=" << *i/CLHEP::cm;
162 rmax_p.push_back(*i);
165 LogDebug(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0]/CLHEP::deg <<
" ep=" 166 << (*par_)[1]/CLHEP::deg;
175 return new G4Polycone(solid.
name().
name(), (*par_)[0], (*par_)[1],
184 #include "G4Polyhedra.hh" 186 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: phed_rz = " << solid;
187 std::vector<double>
r;
188 std::vector<double>
z;
189 std::vector<double>::const_iterator
i =
par_->begin()+3;
192 for(; i!=
par_->end(); ++
i) {
193 z.push_back(*i); ++
i;
198 return new G4Polyhedra(solid.
name().
name(), (*par_)[1], (*par_)[2],
int((*par_)[0]),
206 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: phed_rrz = " << solid;
207 std::vector<double> z_p;
208 std::vector<double> rmin_p;
209 std::vector<double> rmax_p;
210 std::vector<double>::const_iterator
i =
par_->begin()+3;
212 for (; i!=
par_->end(); ++
i) {
213 LogDebug(
"SimG4CoreGeometry") <<
"z=" << *i/CLHEP::cm;
214 z_p.push_back(*i); ++
i;
215 LogDebug(
"SimG4CoreGeometry") <<
"rmin=" << *i/CLHEP::cm;
216 rmin_p.push_back(*i); ++
i;
217 LogDebug(
"SimG4CoreGeometry") <<
"rmax=" << *i/CLHEP::cm;
218 rmax_p.push_back(*i);
221 LogDebug(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0]/CLHEP::deg <<
" ep=" 222 << (*par_)[1]/CLHEP::deg;
223 return new G4Polyhedra(solid.
name().
name(), (*par_)[1], (*par_)[2],
int((*par_)[0]),
230 #include "G4ExtrudedSolid.hh" 232 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: extr_pgon = " << solid;
240 std::vector<G4TwoVector> polygon;
241 std::vector<G4ExtrudedSolid::ZSection> zsections;
242 for(
unsigned int it = 0; it < x.size(); ++it )
243 polygon.emplace_back( x[it], y[it] );
244 for(
unsigned int it = 0; it < z.size(); ++it )
245 zsections.emplace_back( z[it], G4TwoVector(zx[it], zy[it]), zs[it] );
246 return new G4ExtrudedSolid( solid.
name().
name(), polygon, zsections );
249 #include "G4Torus.hh" 251 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: torus = " << solid;
252 return new G4Torus(solid.
name().
name(), (*par_)[0],
259 #include "G4UnionSolid.hh" 261 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: unionsolid = " << solid.
name();
262 G4UnionSolid * us =
nullptr;
271 std::vector<double> tdbl(9);
272 bs.
rotation().
rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
273 CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
275 us =
new G4UnionSolid(solid.
name().
name(),
278 new CLHEP::HepRotation(temprep),
285 #include "G4SubtractionSolid.hh" 288 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: subtraction = " << solid;
289 G4SubtractionSolid * us =
nullptr;
296 std::vector<double> tdbl(9);
297 bs.
rotation().
rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
298 CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
300 us =
new G4SubtractionSolid(solid.
name().
name(),
303 new CLHEP::HepRotation(temprep),
309 #include "G4IntersectionSolid.hh" 311 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: intersection = " << solid;
312 G4IntersectionSolid * us =
nullptr;
319 std::vector<double> tdbl(9);
320 bs.
rotation().
rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
321 CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
323 us =
new G4IntersectionSolid(solid.
name().
name(),
326 new CLHEP::HepRotation(temprep),
335 rot =
new G4RotationMatrix;
336 rot->rotateX(90.*deg);
339 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: pseudoTrap = " << solid;
340 G4Trd *
trap =
nullptr;
341 G4Tubs *
tubs =
nullptr;
342 G4VSolid *
result =
nullptr;
348 bool intersec =
false;
355 double openingAngle = 2.*asin(x/
std::abs(r));
357 double displacement=0;
364 h = pt.
y1() < pt.
y2() ? pt.
y2() : pt.
y1();
368 startPhi = 270.*deg - openingAngle/2.;
372 startPhi = 90.*deg - openingAngle/2.;
375 else if ( r > 0 &&
std::abs(r) >= x )
379 startPhi = 90.*deg - openingAngle/2.;
384 startPhi = 270.*deg - openingAngle/2.;
389 throw cms::Exception(
"DetectorDescriptionFault",
"Check parameters of the PseudoTrap! name=" + pt.
name().
name());
391 G4ThreeVector displ(0.,0.,displacement);
392 LogDebug(
"SimG4CoreGeometry") <<
"DDSolidConverter::pseudotrap(): displacement=" << displacement
393 <<
" openingAngle=" << openingAngle/deg <<
" x=" << x <<
" h=" <<
h;
397 trap =
new G4Trd(name, pt.
x1(), pt.
x2(), pt.
y1(), pt.
y2(), pt.
halfZ());
398 tubs =
new G4Tubs(name,
405 result =
new G4SubtractionSolid(name, trap, tubs,
rot, displ);
408 G4VSolid * tubicCap =
new G4SubtractionSolid(name,
410 new G4Box(name, 1.1*x,
sqrt(r*r-x*x), 1.1*h),
413 result =
new G4UnionSolid(name, trap, tubicCap,
rot, displ);
423 LogDebug(
"SimG4CoreGeometry") <<
"before";
425 LogDebug(
"SimG4CoreGeometry") <<
"after";
426 double rIn(tt.
rIn()), rOut(tt.
rOut()), zHalf(tt.
zHalf()),
433 if (rIn <= 0 || rOut <=0 || cutAtStart <=0 || cutAtDelta <= 0) {
439 if (startPhi != 0.) {
444 double r(cutAtStart),
R(cutAtDelta);
445 G4VSolid *
result(
nullptr);
446 G4VSolid *
tubs =
new G4Tubs(name,rIn,rOut,zHalf,startPhi,
deltaPhi);
447 LogDebug(
"SimG4CoreGeometry") <<
"G4Tubs: " << rIn/CLHEP::cm <<
' ' << rOut/CLHEP::cm <<
' ' << zHalf/CLHEP::cm <<
' ' << startPhi/CLHEP::deg <<
' ' <<
deltaPhi/CLHEP::deg;
448 LogDebug(
"SimG4CoreGeometry") << solid;
450 double boxX(30.*rOut), boxY(20.*rOut);
453 double boxZ(1.1*zHalf);
458 double cos_alpha = cath/hypo;
460 double alpha = -acos(cos_alpha);
461 LogDebug(
"SimG4CoreGeometry") <<
"cath=" << cath/CLHEP::cm;
462 LogDebug(
"SimG4CoreGeometry") <<
"hypo=" << hypo/CLHEP::cm;
463 LogDebug(
"SimG4CoreGeometry") <<
"al=" << acos(cath/hypo)/CLHEP::deg;
465 <<
"r=" <<
r/CLHEP::cm <<
"\n" 466 <<
"R=" << R/CLHEP::cm;
468 LogDebug(
"SimG4CoreGeometry") <<
"alpha=" << alpha/CLHEP::deg;
471 G4RotationMatrix *
rot =
new G4RotationMatrix;
472 rot->rotateZ(-alpha);
473 LogDebug(
"SimG4CoreGeometry") << (*rot);
483 G4ThreeVector trans(xBox,0.,0.);
484 LogDebug(
"SimG4CoreGeometry") <<
"trans=" << trans;
486 G4VSolid *
box =
new G4Box(name,boxX,boxY,boxZ);
487 result =
new G4SubtractionSolid(name,tubs,box,rot,trans);
493 #include "G4Sphere.hh" 495 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: sphere = " << solid;
505 #include "G4EllipticalTube.hh" 507 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: ellipticaltube = " << solid;
509 return new G4EllipticalTube(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.
static G4RotationMatrix * rot
bool cutInside(void) const
true, if truncation is on the inner side of the tube-section
A truncated tube section.
double zHalf(void) const
half of the z-Axis
double y2(void) const
half length along y on +z
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 rIn(void) const
inner radius
static G4VSolid * sphere(const DDSolid &)
DDTranslation translation(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)
static G4VSolid * pseudotrap(const DDSolid &s)
DDRotation rotation(void) const
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
static G4VSolid * unionsolid(const DDSolid &)
static G4VSolid * extrudedpolygon(const DDSolid &)
static G4VSolid * trunctubs(const DDSolid &)
double zHeight(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.)