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 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: box = " << solid;
61 return new G4Box(solid.
name().
name(), (*par_)[0], (*par_)[1], (*par_)[2]);
66 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: tubs = " << solid;
67 return new G4Tubs(solid.
name().
name(),
75 #include "G4CutTubs.hh"
77 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: tubs = " << solid;
78 return new G4CutTubs(solid.
name().
name(),
90 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: trap = " << solid;
91 return new G4Trap(solid.
name().
name(),
107 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: cons = " << solid;
108 return new G4Cons(solid.
name().
name(),
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;
129 LogDebug(
"SimG4CoreGeometry") <<
" r=" << *
i / CLHEP::cm;
133 LogDebug(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0] / CLHEP::deg <<
" ep=" << (*par_)[1] / CLHEP::deg;
142 return new G4Polycone(solid.
name().
name(),
151 LogDebug(
"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) {
158 LogDebug(
"SimG4CoreGeometry") <<
"z=" << *
i / CLHEP::cm;
161 LogDebug(
"SimG4CoreGeometry") <<
"rmin=" << *
i / CLHEP::cm;
162 rmin_p.push_back(*
i);
164 LogDebug(
"SimG4CoreGeometry") <<
"rmax=" << *
i / CLHEP::cm;
165 rmax_p.push_back(*
i);
168 LogDebug(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0] / CLHEP::deg <<
" ep=" << (*par_)[1] / CLHEP::deg;
178 return new G4Polycone(solid.
name().
name(),
187 #include "G4Polyhedra.hh"
189 LogDebug(
"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 LogDebug(
"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) {
219 LogDebug(
"SimG4CoreGeometry") <<
"z=" << *
i / CLHEP::cm;
222 LogDebug(
"SimG4CoreGeometry") <<
"rmin=" << *
i / CLHEP::cm;
223 rmin_p.push_back(*
i);
225 LogDebug(
"SimG4CoreGeometry") <<
"rmax=" << *
i / CLHEP::cm;
226 rmax_p.push_back(*
i);
229 LogDebug(
"SimG4CoreGeometry") <<
"sp=" << (*par_)[0] / CLHEP::deg <<
" ep=" << (*par_)[1] / CLHEP::deg;
230 return new G4Polyhedra(solid.
name().
name(),
240 #include "G4ExtrudedSolid.hh"
242 LogDebug(
"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 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: torus = " << solid;
262 return new G4Torus(solid.
name().
name(),
270 #include "G4UnionSolid.hh"
272 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: unionsolid = " << solid.
name();
273 G4UnionSolid *us =
nullptr;
276 LogDebug(
"SimG4CoreGeometry") <<
"SolidA=" <<
bs.solidA();
278 LogDebug(
"SimG4CoreGeometry") <<
"SolidB=" <<
bs.solidB();
280 LogDebug(
"SimG4CoreGeometry") <<
" name:" << solid.
name() <<
" t=" <<
bs.translation() << std::flush;
281 LogDebug(
"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 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: subtraction = " << solid;
296 G4SubtractionSolid *us =
nullptr;
301 LogDebug(
"SimG4CoreGeometry") <<
" name:" << solid.
name() <<
" t=" <<
bs.translation() << std::flush;
302 LogDebug(
"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 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: intersection = " << solid;
315 G4IntersectionSolid *us =
nullptr;
320 LogDebug(
"SimG4CoreGeometry") <<
" name:" << solid.
name() <<
" t=" <<
bs.translation() << std::flush;
321 LogDebug(
"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 LogDebug(
"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 LogDebug(
"SimG4CoreGeometry") <<
"DDSolidConverter::pseudotrap(): displacement=" << displacement
387 <<
" openingAngle=" << openingAngle / deg <<
" x=" <<
x <<
" h=" <<
h;
401 G4VSolid *tubicCap =
new G4SubtractionSolid(
414 LogDebug(
"SimG4CoreGeometry") <<
"before";
416 LogDebug(
"SimG4CoreGeometry") <<
"after";
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 LogDebug(
"SimG4CoreGeometry") <<
"G4Tubs: " << rIn / CLHEP::cm <<
' ' << rOut / CLHEP::cm <<
' ' << zHalf / CLHEP::cm
442 <<
' ' << startPhi / CLHEP::deg <<
' ' <<
deltaPhi / CLHEP::deg;
443 LogDebug(
"SimG4CoreGeometry") << solid;
449 double boxZ(1.1 * zHalf);
454 double cos_alpha = cath / hypo;
456 double alpha = -acos(cos_alpha);
457 LogDebug(
"SimG4CoreGeometry") <<
"cath=" << cath / CLHEP::cm;
458 LogDebug(
"SimG4CoreGeometry") <<
"hypo=" << hypo / CLHEP::cm;
459 LogDebug(
"SimG4CoreGeometry") <<
"al=" << acos(cath / hypo) / CLHEP::deg;
460 LogDebug(
"SimG4CoreGeometry") <<
"deltaPhi=" <<
deltaPhi / CLHEP::deg <<
"\n"
461 <<
"r=" <<
r / CLHEP::cm <<
"\n"
462 <<
"R=" <<
R / CLHEP::cm;
464 LogDebug(
"SimG4CoreGeometry") <<
"alpha=" <<
alpha / CLHEP::deg;
467 G4RotationMatrix *
rot =
new G4RotationMatrix;
469 LogDebug(
"SimG4CoreGeometry") << (*rot);
479 G4ThreeVector trans(xBox, 0., 0.);
480 LogDebug(
"SimG4CoreGeometry") <<
"trans=" << trans;
482 G4VSolid *
box =
new G4Box(
name, boxX, boxY, boxZ);
488 #include "G4Sphere.hh"
490 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: sphere = " << solid;
492 return new G4Sphere(solid.
name().
name(),
501 #include "G4EllipticalTube.hh"
503 LogDebug(
"SimG4CoreGeometry") <<
"DDG4SolidConverter: ellipticaltube = " << solid;