8 #include "G4SystemOfUnits.hh"
40 edm::LogError(
"SimG4CoreGeometry") <<
" DDG4SolidConverter::convert(..) found an undefined DDSolid "
43 "DDG4SolidConverter::convert(..) found an undefined DDSolid " + solid.
toString());
45 G4VSolid *
result =
nullptr;
49 result = it->second(solid);
52 <<
"DDG4SolidConverter::convert: conversion failed for s=" << solid
60 edm::LogVerbatim(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: box = " << solid;
61 return new G4Box(solid.
name().
name(), (*par_)[0], (*par_)[1], (*par_)[2]);
66 edm::LogVerbatim(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: tubs = " << solid;
67 return new G4Tubs(solid.
name().
name(),
75 #include "G4CutTubs.hh"
77 edm::LogVerbatim(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: tubs = " << solid;
78 return new G4CutTubs(solid.
name().
name(),
90 edm::LogVerbatim(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: trap = " << solid;
91 return new G4Trap(solid.
name().
name(),
107 edm::LogVerbatim(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: cons = " << solid;
108 return new G4Cons(solid.
name().
name(),
118 #include "G4Polycone.hh"
120 edm::LogVerbatim(
"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) {
133 edm::LogVerbatim(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0] / CLHEP::deg <<
" ep=" << (*par_)[1] / CLHEP::deg;
142 return new G4Polycone(solid.
name().
name(),
151 edm::LogVerbatim(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: pcon_rrz = " << solid;
152 std::vector<double> z_p;
153 std::vector<double> rmin_p;
154 std::vector<double> rmax_p;
155 std::vector<double>::const_iterator
i =
par_->begin() + 2;
157 for (;
i !=
par_->end(); ++
i) {
162 rmin_p.push_back(*
i);
165 rmax_p.push_back(*
i);
168 edm::LogVerbatim(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0] / CLHEP::deg <<
" ep=" << (*par_)[1] / CLHEP::deg;
178 return new G4Polycone(solid.
name().
name(),
187 #include "G4Polyhedra.hh"
189 edm::LogVerbatim(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: phed_rz = " << solid;
190 std::vector<double>
r;
191 std::vector<double>
z;
192 std::vector<double>::const_iterator
i =
par_->begin() + 3;
195 for (;
i !=
par_->end(); ++
i) {
202 return new G4Polyhedra(solid.
name().
name(),
212 edm::LogVerbatim(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: phed_rrz = " << solid;
213 std::vector<double> z_p;
214 std::vector<double> rmin_p;
215 std::vector<double> rmax_p;
216 std::vector<double>::const_iterator
i =
par_->begin() + 3;
218 for (;
i !=
par_->end(); ++
i) {
223 rmin_p.push_back(*
i);
226 rmax_p.push_back(*
i);
229 edm::LogVerbatim(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0] / CLHEP::deg <<
" ep=" << (*par_)[1] / CLHEP::deg;
230 return new G4Polyhedra(solid.
name().
name(),
240 #include "G4ExtrudedSolid.hh"
242 edm::LogVerbatim(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: extr_pgon = " << solid;
243 std::vector<double>
x = static_cast<DDExtrudedPolygon>(solid).xVec();
244 std::vector<double>
y = static_cast<DDExtrudedPolygon>(solid).yVec();
245 std::vector<double>
z = static_cast<DDExtrudedPolygon>(solid).zVec();
246 std::vector<double> zx = static_cast<DDExtrudedPolygon>(solid).zxVec();
247 std::vector<double> zy = static_cast<DDExtrudedPolygon>(solid).zyVec();
248 std::vector<double> zs = static_cast<DDExtrudedPolygon>(solid).zscaleVec();
250 std::vector<G4TwoVector> polygon;
251 std::vector<G4ExtrudedSolid::ZSection> zsections;
252 for (
unsigned int it = 0; it <
x.size(); ++it)
253 polygon.emplace_back(
x[it],
y[it]);
254 for (
unsigned int it = 0; it <
z.size(); ++it)
255 zsections.emplace_back(
z[it], G4TwoVector(zx[it], zy[it]), zs[it]);
256 return new G4ExtrudedSolid(solid.
name().
name(), polygon, zsections);
259 #include "G4Torus.hh"
261 edm::LogVerbatim(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: torus = " << solid;
262 return new G4Torus(solid.
name().
name(),
270 #include "G4UnionSolid.hh"
273 G4UnionSolid *us =
nullptr;
280 edm::LogVerbatim(
"SimG4CoreGeometry") <<
" name:" << solid.
name() <<
" t=" <<
bs.translation() << std::flush;
281 edm::LogVerbatim(
"SimG4CoreGeometry") <<
" " <<
bs.rotation().rotation().Inverse() << std::flush;
282 std::vector<double> tdbl(9);
283 bs.rotation().rotation().Inverse().GetComponents(tdbl.begin(), tdbl.end());
284 CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
285 CLHEP::Hep3Vector temphvec(
bs.translation().X(),
bs.translation().Y(),
bs.translation().Z());
286 us =
new G4UnionSolid(solid.
name().
name(), sa, sb,
new CLHEP::HepRotation(temprep), temphvec);
292 #include "G4SubtractionSolid.hh"
295 edm::LogVerbatim(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: subtraction = " << solid;
296 G4SubtractionSolid *us =
nullptr;
301 edm::LogVerbatim(
"SimG4CoreGeometry") <<
" name:" << solid.
name() <<
" t=" <<
bs.translation() << std::flush;
302 edm::LogVerbatim(
"SimG4CoreGeometry") <<
" " <<
bs.rotation().rotation().Inverse() << std::flush;
303 std::vector<double> tdbl(9);
304 bs.rotation().rotation().Inverse().GetComponents(tdbl.begin(), tdbl.end());
305 CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
306 CLHEP::Hep3Vector temphvec(
bs.translation().X(),
bs.translation().Y(),
bs.translation().Z());
307 us =
new G4SubtractionSolid(solid.
name().
name(), sa, sb,
new CLHEP::HepRotation(temprep), temphvec);
312 #include "G4IntersectionSolid.hh"
314 edm::LogVerbatim(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: intersection = " << solid;
315 G4IntersectionSolid *us =
nullptr;
320 edm::LogVerbatim(
"SimG4CoreGeometry") <<
" name:" << solid.
name() <<
" t=" <<
bs.translation() << std::flush;
321 edm::LogVerbatim(
"SimG4CoreGeometry") <<
" " <<
bs.rotation().rotation().Inverse() << std::flush;
322 std::vector<double> tdbl(9);
323 bs.rotation().rotation().Inverse().GetComponents(tdbl.begin(), tdbl.end());
324 CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
325 CLHEP::Hep3Vector temphvec(
bs.translation().X(),
bs.translation().Y(),
bs.translation().Z());
326 us =
new G4IntersectionSolid(solid.
name().
name(), sa, sb,
new CLHEP::HepRotation(temprep), temphvec);
333 if (
nullptr ==
rot) {
334 rot =
new G4RotationMatrix;
335 rot->rotateX(90. * deg);
338 edm::LogVerbatim(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: pseudoTrap = " << solid;
339 G4Trd *
trap =
nullptr;
340 G4Tubs *
tubs =
nullptr;
341 G4VSolid *
result =
nullptr;
343 double r =
pt.radius();
344 bool atMinusZ =
pt.atMinusZ();
347 bool intersec =
false;
353 double openingAngle = 2. * asin(
x /
std::abs(
r));
355 double displacement = 0;
362 h =
pt.y1() <
pt.y2() ?
pt.y2() :
pt.y1();
365 displacement = -
pt.halfZ() -
delta;
366 startPhi = 270. * deg - openingAngle / 2.;
368 displacement =
pt.halfZ() +
delta;
369 startPhi = 90. * deg - openingAngle / 2.;
373 displacement = -
pt.halfZ() +
delta;
374 startPhi = 90. * deg - openingAngle / 2.;
377 displacement =
pt.halfZ() -
delta;
378 startPhi = 270. * deg - openingAngle / 2.;
382 throw cms::Exception(
"DetectorDescriptionFault",
"Check parameters of the PseudoTrap! name=" +
pt.name().name());
384 G4ThreeVector displ(0., 0.,
386 edm::LogVerbatim(
"SimG4CoreGeometry") <<
"DDSolidConverter::pseudotrap(): displacement=" << displacement
387 <<
" openingAngle=" << openingAngle / deg <<
" x=" <<
x <<
" h=" <<
h;
401 G4VSolid *tubicCap =
new G4SubtractionSolid(
417 double rIn(
tt.rIn()), rOut(
tt.rOut()), zHalf(
tt.zHalf()), startPhi(
tt.startPhi()),
deltaPhi(
tt.deltaPhi()),
418 cutAtStart(
tt.cutAtStart()), cutAtDelta(
tt.cutAtDelta());
419 bool cutInside(
bool(
tt.cutInside()));
423 if (rIn <= 0 || rOut <= 0 || cutAtStart <= 0 || cutAtDelta <= 0) {
425 "DetectorDescriptionFault",
426 "TruncTubs " +
std::string(
tt.name().fullname()) +
": 0 <= rIn,cutAtStart,rOut,cutAtDelta,rOut violated!");
430 "TruncTubs " +
std::string(
tt.name().fullname()) +
": rIn<rOut violated!");
432 if (startPhi != 0.) {
434 "TruncTubs " +
std::string(
tt.name().fullname()) +
": startPhi != 0 not supported!");
438 double r(cutAtStart),
R(cutAtDelta);
439 G4VSolid *
result(
nullptr);
441 edm::LogVerbatim(
"SimG4CoreGeometry") <<
"G4Tubs: " << rIn / CLHEP::cm <<
' ' << rOut / CLHEP::cm <<
' '
442 << zHalf / CLHEP::cm <<
' ' << startPhi / CLHEP::deg <<
' '
450 double boxZ(1.1 * zHalf);
455 double cos_alpha = cath / hypo;
457 double alpha = -acos(cos_alpha);
460 edm::LogVerbatim(
"SimG4CoreGeometry") <<
"al=" << acos(cath / hypo) / CLHEP::deg;
462 <<
"r=" <<
r / CLHEP::cm <<
"\n"
463 <<
"R=" <<
R / CLHEP::cm;
468 G4RotationMatrix *
rot =
new G4RotationMatrix;
480 G4ThreeVector trans(xBox, 0., 0.);
483 G4VSolid *
box =
new G4Box(
name, boxX, boxY, boxZ);
489 #include "G4Sphere.hh"
491 edm::LogVerbatim(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: sphere = " << solid;
493 return new G4Sphere(solid.
name().
name(),
502 #include "G4EllipticalTube.hh"
504 edm::LogVerbatim(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: ellipticaltube = " << solid;