CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends
DDG4SolidConverter Class Reference

#include <DDG4SolidConverter.h>

Public Types

typedef G4VSolid *(* FNPTR) (const DDSolid &)
 

Public Member Functions

G4VSolid * convert (const DDSolid &)
 
 DDG4SolidConverter ()
 
 ~DDG4SolidConverter ()
 

Static Private Member Functions

static G4VSolid * box (const DDSolid &)
 
static G4VSolid * cons (const DDSolid &)
 
static G4VSolid * cuttubs (const DDSolid &)
 
static G4VSolid * ellipticaltube (const DDSolid &)
 
static G4VSolid * extrudedpolygon (const DDSolid &)
 
static G4VSolid * intersection (const DDSolid &)
 
static G4VSolid * polycone_rrz (const DDSolid &)
 
static G4VSolid * polycone_rz (const DDSolid &)
 
static G4VSolid * polyhedra_rrz (const DDSolid &)
 
static G4VSolid * polyhedra_rz (const DDSolid &)
 
static G4VSolid * pseudotrap (const DDSolid &s)
 
static G4VSolid * shapeless (const DDSolid &)
 
static G4VSolid * sphere (const DDSolid &)
 
static G4VSolid * subtraction (const DDSolid &)
 
static G4VSolid * torus (const DDSolid &)
 
static G4VSolid * trap (const DDSolid &)
 
static G4VSolid * trunctubs (const DDSolid &)
 
static G4VSolid * tubs (const DDSolid &)
 
static G4VSolid * unionsolid (const DDSolid &)
 

Private Attributes

std::map< DDSolidShape, FNPTRconvDispatch_
 

Static Private Attributes

static const std::vector< double > * par_ = nullptr
 
static G4RotationMatrix * rot = nullptr
 

Friends

class testPseudoTrap
 
class testTruncTubs
 

Detailed Description

Definition at line 14 of file DDG4SolidConverter.h.

Member Typedef Documentation

◆ FNPTR

typedef G4VSolid*(* DDG4SolidConverter::FNPTR) (const DDSolid &)

Definition at line 18 of file DDG4SolidConverter.h.

Constructor & Destructor Documentation

◆ DDG4SolidConverter()

DDG4SolidConverter::DDG4SolidConverter ( )

Definition at line 16 of file DDG4SolidConverter.cc.

References box(), cons(), convDispatch_, cuttubs(), ddbox, ddcons, ddcuttubs, ddellipticaltube, ddextrudedpolygon, ddintersection, ddpolycone_rrz, ddpolycone_rz, ddpolyhedra_rrz, ddpolyhedra_rz, ddpseudotrap, ddsphere, ddsubtraction, ddtorus, ddtrap, ddtrunctubs, ddtubs, ddunion, ellipticaltube(), extrudedpolygon(), intersection(), polycone_rrz(), polycone_rz(), polyhedra_rrz(), polyhedra_rz(), pseudotrap(), sphere(), subtraction(), torus(), trap(), trunctubs(), tubs(), and unionsolid().

Referenced by intersection(), subtraction(), and unionsolid().

16  {
17  // could also be done 'dynamically' from outside
18  // would then need to have a 'register' method ...
37 }
static G4VSolid * polyhedra_rrz(const DDSolid &)
static G4VSolid * trap(const DDSolid &)
static G4VSolid * cons(const DDSolid &)
static G4VSolid * tubs(const DDSolid &)
static G4VSolid * sphere(const DDSolid &)
static G4VSolid * cuttubs(const DDSolid &)
static G4VSolid * pseudotrap(const DDSolid &s)
static G4VSolid * box(const DDSolid &)
static G4VSolid * ellipticaltube(const DDSolid &)
static G4VSolid * polycone_rz(const DDSolid &)
static G4VSolid * intersection(const DDSolid &)
static G4VSolid * unionsolid(const DDSolid &)
static G4VSolid * extrudedpolygon(const DDSolid &)
std::map< DDSolidShape, FNPTR > convDispatch_
static G4VSolid * trunctubs(const DDSolid &)
static G4VSolid * torus(const DDSolid &)
static G4VSolid * polyhedra_rz(const DDSolid &)
static G4VSolid * polycone_rrz(const DDSolid &)
static G4VSolid * subtraction(const DDSolid &)

◆ ~DDG4SolidConverter()

DDG4SolidConverter::~DDG4SolidConverter ( )

Definition at line 39 of file DDG4SolidConverter.cc.

39 {}

Member Function Documentation

◆ box()

G4VSolid * DDG4SolidConverter::box ( const DDSolid solid)
staticprivate

Definition at line 62 of file DDG4SolidConverter.cc.

References DDName::name(), and DDBase< N, C >::name().

Referenced by DDG4SolidConverter(), and trunctubs().

62  {
63  edm::LogVerbatim("SimG4CoreGeometry") << "DDG4SolidConverter: box = " << solid;
64  return new G4Box(solid.name().name(), (*par_)[0], (*par_)[1], (*par_)[2]);
65 }
Log< level::Info, true > LogVerbatim
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
const N & name() const
Definition: DDBase.h:59

◆ cons()

G4VSolid * DDG4SolidConverter::cons ( const DDSolid solid)
staticprivate

Definition at line 109 of file DDG4SolidConverter.cc.

References DDName::name(), and DDBase< N, C >::name().

Referenced by DDG4SolidConverter().

109  {
110  edm::LogVerbatim("SimG4CoreGeometry") << "DDG4SolidConverter: cons = " << solid;
111  return new G4Cons(solid.name().name(),
112  (*par_)[1], // rmin -z
113  (*par_)[2], // rmax -z
114  (*par_)[3], // rmin +z
115  (*par_)[4], // rmax +z
116  (*par_)[0], // zHalf
117  (*par_)[5], // phistart
118  (*par_)[6]); // deltaphi
119 }
Log< level::Info, true > LogVerbatim
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
const N & name() const
Definition: DDBase.h:59

◆ convert()

G4VSolid * DDG4SolidConverter::convert ( const DDSolid solid)

Definition at line 41 of file DDG4SolidConverter.cc.

References convDispatch_, Exception, DDSolidShapesName::name(), par_, DDSolid::parameters(), mps_fire::result, DDSolid::shape(), and DDBase< N, C >::toString().

Referenced by DDG4Builder::convertSolid().

41  {
42  if (!solid) {
43  edm::LogError("SimG4CoreGeometry") << " DDG4SolidConverter::convert(..) found an undefined DDSolid "
44  << solid.toString();
45  throw cms::Exception("SimG4CoreGeometry",
46  "DDG4SolidConverter::convert(..) found an undefined DDSolid " + solid.toString());
47  }
48  G4VSolid *result = nullptr;
49  par_ = &(solid.parameters());
50  std::map<DDSolidShape, FNPTR>::iterator it = convDispatch_.find(solid.shape());
51  if (it != convDispatch_.end()) {
52  result = it->second(solid);
53  } else {
54  throw cms::Exception("DetectorDescriptionFault")
55  << "DDG4SolidConverter::convert: conversion failed for s=" << solid
56  << "\n solid.shape()=" << DDSolidShapesName::name(solid.shape()) << G4endl;
57  }
58  return result;
59 }
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:125
Log< level::Error, false > LogError
static const char *const name(DDSolidShape s)
Definition: DDSolidShapes.h:33
static const std::vector< double > * par_
std::string toString() const
Definition: DDBase.h:63
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:123
std::map< DDSolidShape, FNPTR > convDispatch_

◆ cuttubs()

G4VSolid * DDG4SolidConverter::cuttubs ( const DDSolid solid)
staticprivate

Definition at line 79 of file DDG4SolidConverter.cc.

References DDName::name(), DDBase< N, C >::name(), and par_.

Referenced by DDG4SolidConverter().

79  {
80  edm::LogVerbatim("SimG4CoreGeometry") << "DDG4SolidConverter: tubs = " << solid;
81  return new G4CutTubs(solid.name().name(),
82  (*par_)[1], // rmin
83  (*par_)[2], // rmax
84  (*par_)[0], // dzHalf
85  (*par_)[3], // phiStart
86  (*par_)[4], // deltaPhi
87  G4ThreeVector((*par_)[5], (*par_)[6], (*par_)[7]),
88  G4ThreeVector((*par_)[8], (*par_)[9], (*par_)[10]));
89 }
Log< level::Info, true > LogVerbatim
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
static const std::vector< double > * par_
const N & name() const
Definition: DDBase.h:59

◆ ellipticaltube()

G4VSolid * DDG4SolidConverter::ellipticaltube ( const DDSolid solid)
staticprivate

Definition at line 503 of file DDG4SolidConverter.cc.

References DDName::name(), DDBase< N, C >::name(), DDEllipticalTube::xSemiAxis(), DDEllipticalTube::ySemiAxis(), and DDEllipticalTube::zHeight().

Referenced by DDG4SolidConverter().

503  {
504  edm::LogVerbatim("SimG4CoreGeometry") << "DDG4SolidConverter: ellipticaltube = " << solid;
505  DDEllipticalTube sp(solid);
506  return new G4EllipticalTube(solid.name().name(), sp.xSemiAxis(), sp.ySemiAxis(), sp.zHeight());
507 }
Log< level::Info, true > LogVerbatim
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
const N & name() const
Definition: DDBase.h:59

◆ extrudedpolygon()

G4VSolid * DDG4SolidConverter::extrudedpolygon ( const DDSolid solid)
staticprivate

Definition at line 241 of file DDG4SolidConverter.cc.

References DDName::name(), DDBase< N, C >::name(), x, y, and z.

Referenced by DDG4SolidConverter().

241  {
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();
249 
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);
257 }
Log< level::Info, true > LogVerbatim
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
const N & name() const
Definition: DDBase.h:59

◆ intersection()

G4VSolid * DDG4SolidConverter::intersection ( const DDSolid solid)
staticprivate

Definition at line 313 of file DDG4SolidConverter.cc.

References cms::cuda::bs, DDG4SolidConverter(), DDName::name(), and DDBase< N, C >::name().

Referenced by DDG4SolidConverter().

313  {
314  edm::LogVerbatim("SimG4CoreGeometry") << "DDG4SolidConverter: intersection = " << solid;
315  G4IntersectionSolid *us = nullptr;
316  DDBooleanSolid bs(solid);
317  if (bs) {
318  G4VSolid *sa = DDG4SolidConverter().convert(bs.solidA());
319  G4VSolid *sb = DDG4SolidConverter().convert(bs.solidB());
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);
327  }
328  return us;
329 }
Log< level::Info, true > LogVerbatim
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
const N & name() const
Definition: DDBase.h:59

◆ polycone_rrz()

G4VSolid * DDG4SolidConverter::polycone_rrz ( const DDSolid solid)
staticprivate

Definition at line 152 of file DDG4SolidConverter.cc.

References submitPVResolutionJobs::count, ecalTB2006H4_GenSimDigiReco_cfg::G4cout, mps_fire::i, DDName::name(), DDBase< N, C >::name(), and par_.

Referenced by DDG4SolidConverter().

152  {
153  edm::LogVerbatim("SimG4CoreGeometry") << "DDG4SolidConverter: pcon_rrz = " << solid;
154  std::vector<double> z_p;
155  std::vector<double> rmin_p;
156  std::vector<double> rmax_p;
157  std::vector<double>::const_iterator i = par_->begin() + 2;
158  int count = 0;
159  for (; i != par_->end(); ++i) {
160  edm::LogVerbatim("SimG4CoreGeometry") << "z=" << *i / CLHEP::cm;
161  z_p.push_back(*i);
162  ++i;
163  edm::LogVerbatim("SimG4CoreGeometry") << "rmin=" << *i / CLHEP::cm;
164  rmin_p.push_back(*i);
165  ++i;
166  edm::LogVerbatim("SimG4CoreGeometry") << "rmax=" << *i / CLHEP::cm;
167  rmax_p.push_back(*i);
168  count++;
169  }
170  edm::LogVerbatim("SimG4CoreGeometry") << "sp=" << (*par_)[0] / CLHEP::deg << " ep=" << (*par_)[1] / CLHEP::deg;
171 #ifdef EDM_ML_DEBUG
172  G4cout << "### Polycone_RRZ: "
173  << "sp=" << (*par_)[0] / CLHEP::deg << " ep=" << (*par_)[1] / CLHEP::deg << " N= " << count << G4endl;
174  for (int i = 0; i < count; ++i) {
175  G4cout << " R1= " << rmin_p[i] << " R1= " << rmax_p[i] << " Z= " << z_p[i] << G4endl;
176  }
177 #endif
178  return new G4Polycone(solid.name().name(),
179  (*par_)[0],
180  (*par_)[1], // start,delta-phi
181  count, // sections
182  &(z_p[0]),
183  &(rmin_p[0]),
184  &(rmax_p[0]));
185 }
Log< level::Info, true > LogVerbatim
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
static const std::vector< double > * par_
const N & name() const
Definition: DDBase.h:59

◆ polycone_rz()

G4VSolid * DDG4SolidConverter::polycone_rz ( const DDSolid solid)
staticprivate

Definition at line 122 of file DDG4SolidConverter.cc.

References submitPVResolutionJobs::count, ecalTB2006H4_GenSimDigiReco_cfg::G4cout, mps_fire::i, DDName::name(), DDBase< N, C >::name(), alignCSCRings::r, and z.

Referenced by DDG4SolidConverter().

122  {
123  edm::LogVerbatim("SimG4CoreGeometry") << "DDG4SolidConverter: pcon_rz = " << solid;
124  std::vector<double> r;
125  std::vector<double> z;
126  std::vector<double>::const_iterator i = (*par_).begin() + 2;
127  int count = 0;
128  for (; i != (*par_).end(); ++i) {
129  edm::LogVerbatim("SimG4CoreGeometry") << " z=" << *i / CLHEP::cm;
130  z.push_back(*i);
131  ++i;
132  edm::LogVerbatim("SimG4CoreGeometry") << " r=" << *i / CLHEP::cm;
133  r.push_back(*i);
134  count++;
135  }
136  edm::LogVerbatim("SimG4CoreGeometry") << "sp=" << (*par_)[0] / CLHEP::deg << " ep=" << (*par_)[1] / CLHEP::deg;
137 #ifdef EDM_ML_DEBUG
138  G4cout << "### Polycone_RZ: "
139  << "sp=" << (*par_)[0] / CLHEP::deg << " ep=" << (*par_)[1] / CLHEP::deg << " N= " << count << G4endl;
140  for (int i = 0; i < count; ++i) {
141  G4cout << " R= " << r[i] << " Z= " << z[i] << G4endl;
142  }
143 #endif
144  return new G4Polycone(solid.name().name(),
145  (*par_)[0],
146  (*par_)[1], // start,delta-phi
147  count, // numRZ
148  &(r[0]),
149  &(z[0]));
150 }
Log< level::Info, true > LogVerbatim
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
const N & name() const
Definition: DDBase.h:59

◆ polyhedra_rrz()

G4VSolid * DDG4SolidConverter::polyhedra_rrz ( const DDSolid solid)
staticprivate

Definition at line 211 of file DDG4SolidConverter.cc.

References submitPVResolutionJobs::count, mps_fire::i, createfilelist::int, DDName::name(), DDBase< N, C >::name(), and par_.

Referenced by DDG4SolidConverter().

211  {
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;
217  int count = 0;
218  for (; i != par_->end(); ++i) {
219  edm::LogVerbatim("SimG4CoreGeometry") << "z=" << *i / CLHEP::cm;
220  z_p.push_back(*i);
221  ++i;
222  edm::LogVerbatim("SimG4CoreGeometry") << "rmin=" << *i / CLHEP::cm;
223  rmin_p.push_back(*i);
224  ++i;
225  edm::LogVerbatim("SimG4CoreGeometry") << "rmax=" << *i / CLHEP::cm;
226  rmax_p.push_back(*i);
227  count++;
228  }
229  edm::LogVerbatim("SimG4CoreGeometry") << "sp=" << (*par_)[0] / CLHEP::deg << " ep=" << (*par_)[1] / CLHEP::deg;
230  return new G4Polyhedra(solid.name().name(),
231  (*par_)[1],
232  (*par_)[2],
233  int((*par_)[0]), // start,delta-phi,sides
234  count, // sections
235  &(z_p[0]),
236  &(rmin_p[0]),
237  &(rmax_p[0]));
238 }
Log< level::Info, true > LogVerbatim
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
static const std::vector< double > * par_
const N & name() const
Definition: DDBase.h:59

◆ polyhedra_rz()

G4VSolid * DDG4SolidConverter::polyhedra_rz ( const DDSolid solid)
staticprivate

Definition at line 188 of file DDG4SolidConverter.cc.

References submitPVResolutionJobs::count, mps_fire::i, createfilelist::int, DDName::name(), DDBase< N, C >::name(), par_, alignCSCRings::r, and z.

Referenced by DDG4SolidConverter().

188  {
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;
193  int count = 0;
194 
195  for (; i != par_->end(); ++i) {
196  z.push_back(*i);
197  ++i;
198  r.push_back(*i);
199  count++;
200  }
201 
202  return new G4Polyhedra(solid.name().name(),
203  (*par_)[1],
204  (*par_)[2],
205  int((*par_)[0]), // start,delta-phi;sides
206  count, // numRZ
207  &(r[0]),
208  &(z[0]));
209 }
Log< level::Info, true > LogVerbatim
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
static const std::vector< double > * par_
const N & name() const
Definition: DDBase.h:59

◆ pseudotrap()

G4VSolid * DDG4SolidConverter::pseudotrap ( const DDSolid s)
staticprivate

Definition at line 332 of file DDG4SolidConverter.cc.

References funct::abs(), dumpMFGeometry_cfg::delta, Exception, h, Skims_PA_cff::name, DiDispStaMuonMonitor_cfi::pt, alignCSCRings::r, mps_fire::result, rot, mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, trap(), tubs(), and x.

Referenced by DDG4SolidConverter().

332  {
333  if (nullptr == rot) {
334  rot = new G4RotationMatrix;
335  rot->rotateX(90. * deg);
336  }
337 
338  edm::LogVerbatim("SimG4CoreGeometry") << "DDG4SolidConverter: pseudoTrap = " << solid;
339  G4Trd *trap = nullptr;
340  G4Tubs *tubs = nullptr;
341  G4VSolid *result = nullptr;
342  DDPseudoTrap pt(solid); // pt...PseudoTrap
343  double r = pt.radius();
344  bool atMinusZ = pt.atMinusZ();
345  double x = 0;
346  double h = 0;
347  bool intersec = false; // union or intersection solid
348  if (pt.atMinusZ()) {
349  x = pt.x1(); // tubs radius
350  } else {
351  x = pt.x2(); // tubs radius
352  }
353  double openingAngle = 2. * asin(x / std::abs(r));
354  // trap = new G4Trd(solid.name().name(),
355  double displacement = 0;
356  double startPhi = 0;
357  /* calculate the displacement of the tubs w.r.t. to the trap,
358  determine the opening angle of the tubs */
359  double delta = sqrt(r * r - x * x);
360  if (r < 0 && std::abs(r) >= x) {
361  intersec = true; // intersection solid
362  h = pt.y1() < pt.y2() ? pt.y2() : pt.y1(); // tubs half height
363  h += h / 20.; // enlarge a bit - for subtraction solid
364  if (atMinusZ) {
365  displacement = -pt.halfZ() - delta;
366  startPhi = 270. * deg - openingAngle / 2.;
367  } else {
368  displacement = pt.halfZ() + delta;
369  startPhi = 90. * deg - openingAngle / 2.;
370  }
371  } else if (r > 0 && std::abs(r) >= x) {
372  if (atMinusZ) {
373  displacement = -pt.halfZ() + delta;
374  startPhi = 90. * deg - openingAngle / 2.;
375  h = pt.y1();
376  } else {
377  displacement = pt.halfZ() - delta;
378  startPhi = 270. * deg - openingAngle / 2.;
379  h = pt.y2();
380  }
381  } else {
382  throw cms::Exception("DetectorDescriptionFault", "Check parameters of the PseudoTrap! name=" + pt.name().name());
383  }
384  G4ThreeVector displ(0., 0.,
385  displacement); // displacement of the tubs w.r.t. trap
386  edm::LogVerbatim("SimG4CoreGeometry") << "DDSolidConverter::pseudotrap(): displacement=" << displacement
387  << " openingAngle=" << openingAngle / deg << " x=" << x << " h=" << h;
388 
389  // Now create two solids (trd & tubs), and a boolean solid out of them
390  std::string name = pt.name().name();
391  trap = new G4Trd(name, pt.x1(), pt.x2(), pt.y1(), pt.y2(), pt.halfZ());
392  tubs = new G4Tubs(name,
393  0., // rMin
394  std::abs(r), // rMax
395  h, // half height
396  startPhi, // start angle
397  openingAngle);
398  if (intersec) {
399  result = new G4SubtractionSolid(name, trap, tubs, rot, displ);
400  } else {
401  G4VSolid *tubicCap = new G4SubtractionSolid(
402  name, tubs, new G4Box(name, 1.1 * x, sqrt(r * r - x * x), 1.1 * h), nullptr, G4ThreeVector());
403  result = new G4UnionSolid(name, trap, tubicCap, rot, displ);
404  }
405  return result;
406 }
Log< level::Info, true > LogVerbatim
static G4RotationMatrix * rot
static G4VSolid * trap(const DDSolid &)
static G4VSolid * tubs(const DDSolid &)
T sqrt(T t)
Definition: SSEVec.h:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

◆ shapeless()

static G4VSolid* DDG4SolidConverter::shapeless ( const DDSolid )
staticprivate

◆ sphere()

G4VSolid * DDG4SolidConverter::sphere ( const DDSolid solid)
staticprivate

Definition at line 490 of file DDG4SolidConverter.cc.

References DDSphere::deltaPhi(), DDSphere::deltaTheta(), DDSphere::innerRadius(), DDName::name(), DDBase< N, C >::name(), DDSphere::outerRadius(), DDSphere::startPhi(), and DDSphere::startTheta().

Referenced by DDG4SolidConverter().

490  {
491  edm::LogVerbatim("SimG4CoreGeometry") << "DDG4SolidConverter: sphere = " << solid;
492  DDSphere sp(solid);
493  return new G4Sphere(solid.name().name(),
494  sp.innerRadius(),
495  sp.outerRadius(),
496  sp.startPhi(),
497  sp.deltaPhi(),
498  sp.startTheta(),
499  sp.deltaTheta());
500 }
Log< level::Info, true > LogVerbatim
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
const N & name() const
Definition: DDBase.h:59

◆ subtraction()

G4VSolid * DDG4SolidConverter::subtraction ( const DDSolid solid)
staticprivate

Definition at line 294 of file DDG4SolidConverter.cc.

References cms::cuda::bs, DDG4SolidConverter(), DDName::name(), and DDBase< N, C >::name().

Referenced by DDG4SolidConverter().

294  {
295  edm::LogVerbatim("SimG4CoreGeometry") << "DDG4SolidConverter: subtraction = " << solid;
296  G4SubtractionSolid *us = nullptr;
297  DDBooleanSolid bs(solid);
298  if (bs) {
299  G4VSolid *sa = DDG4SolidConverter().convert(bs.solidA());
300  G4VSolid *sb = DDG4SolidConverter().convert(bs.solidB());
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);
308  }
309  return us;
310 }
Log< level::Info, true > LogVerbatim
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
const N & name() const
Definition: DDBase.h:59

◆ torus()

G4VSolid * DDG4SolidConverter::torus ( const DDSolid solid)
staticprivate

Definition at line 260 of file DDG4SolidConverter.cc.

References DDName::name(), and DDBase< N, C >::name().

Referenced by DDG4SolidConverter().

260  {
261  edm::LogVerbatim("SimG4CoreGeometry") << "DDG4SolidConverter: torus = " << solid;
262  return new G4Torus(solid.name().name(),
263  (*par_)[0], // rmin
264  (*par_)[1], // rmax
265  (*par_)[2], // Rtor
266  (*par_)[3], // phiStart
267  (*par_)[4]); // deltaPhi
268 }
Log< level::Info, true > LogVerbatim
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
const N & name() const
Definition: DDBase.h:59

◆ trap()

G4VSolid * DDG4SolidConverter::trap ( const DDSolid solid)
staticprivate

Definition at line 92 of file DDG4SolidConverter.cc.

References DDName::name(), and DDBase< N, C >::name().

Referenced by DDG4SolidConverter(), and pseudotrap().

92  {
93  edm::LogVerbatim("SimG4CoreGeometry") << "DDG4SolidConverter: trap = " << solid;
94  return new G4Trap(solid.name().name(),
95  (*par_)[0], // pDz
96  (*par_)[1], // theta
97  (*par_)[2], // phi
98  (*par_)[3], // y1
99  (*par_)[4], // x1
100  (*par_)[5], // x2
101  (*par_)[6], // alpha1
102  (*par_)[7], // y2
103  (*par_)[8], // x3
104  (*par_)[9], // x4
105  (*par_)[10]); // alpha2
106 }
Log< level::Info, true > LogVerbatim
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
const N & name() const
Definition: DDBase.h:59

◆ trunctubs()

G4VSolid * DDG4SolidConverter::trunctubs ( const DDSolid solid)
staticprivate

Definition at line 408 of file DDG4SolidConverter.cc.

References funct::abs(), alpha, box(), funct::cos(), SiPixelRawToDigiRegional_cfi::deltaPhi, Exception, Skims_PA_cff::name, DDSolidShapesName::name(), dttmaxenums::R, alignCSCRings::r, mps_fire::result, rot, DDSolid::shape(), funct::sin(), mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::tt, and tubs().

Referenced by DDG4SolidConverter().

408  {
409  // truncated tube-section: a boolean subtraction solid:
410  // from a tube-section a box is subtracted according
411  // to the given parameters
412  edm::LogVerbatim("SimG4CoreGeometry") << "MantisConverter: solidshape=" << DDSolidShapesName::name(solid.shape())
413  << " " << solid;
414  edm::LogVerbatim("SimG4CoreGeometry") << "before";
415  DDTruncTubs tt(solid);
416  edm::LogVerbatim("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()));
420  std::string name = tt.name().name();
421 
422  // check the parameters
423  if (rIn <= 0 || rOut <= 0 || cutAtStart <= 0 || cutAtDelta <= 0) {
424  throw cms::Exception(
425  "DetectorDescriptionFault",
426  "TruncTubs " + std::string(tt.name().fullname()) + ": 0 <= rIn,cutAtStart,rOut,cutAtDelta,rOut violated!");
427  }
428  if (rIn >= rOut) {
429  throw cms::Exception("DetectorDescriptionFault",
430  "TruncTubs " + std::string(tt.name().fullname()) + ": rIn<rOut violated!");
431  }
432  if (startPhi != 0.) {
433  throw cms::Exception("DetectorDescriptionFault",
434  "TruncTubs " + std::string(tt.name().fullname()) + ": startPhi != 0 not supported!");
435  }
436 
437  startPhi = 0.;
438  double r(cutAtStart), R(cutAtDelta);
439  G4VSolid *result(nullptr);
440  G4VSolid *tubs = new G4Tubs(name, rIn, rOut, zHalf, startPhi, deltaPhi);
441  edm::LogVerbatim("SimG4CoreGeometry") << "G4Tubs: " << rIn / CLHEP::cm << ' ' << rOut / CLHEP::cm << ' '
442  << zHalf / CLHEP::cm << ' ' << startPhi / CLHEP::deg << ' '
443  << deltaPhi / CLHEP::deg;
444  edm::LogVerbatim("SimG4CoreGeometry") << solid;
445  // length & hight of the box
446  double boxX(rOut * std::sqrt(2) * 1.1),
447  boxY(rOut * std::sqrt(2) * 1.1); // exaggerate dimensions - does not matter, it's subtracted!
448 
449  // width of the box > width of the tubs
450  double boxZ(1.1 * zHalf);
451 
452  // angle of the box w.r.t. tubs
453  double cath = r - R * cos(deltaPhi);
454  double hypo = sqrt(r * r + R * R - 2. * r * R * cos(deltaPhi));
455  double cos_alpha = cath / hypo;
456 
457  double alpha = -acos(cos_alpha);
458  edm::LogVerbatim("SimG4CoreGeometry") << "cath=" << cath / CLHEP::cm;
459  edm::LogVerbatim("SimG4CoreGeometry") << "hypo=" << hypo / CLHEP::cm;
460  edm::LogVerbatim("SimG4CoreGeometry") << "al=" << acos(cath / hypo) / CLHEP::deg;
461  edm::LogVerbatim("SimG4CoreGeometry") << "deltaPhi=" << deltaPhi / CLHEP::deg << "\n"
462  << "r=" << r / CLHEP::cm << "\n"
463  << "R=" << R / CLHEP::cm;
464 
465  edm::LogVerbatim("SimG4CoreGeometry") << "alpha=" << alpha / CLHEP::deg;
466 
467  // rotationmatrix of box w.r.t. tubs
468  G4RotationMatrix *rot = new G4RotationMatrix;
469  rot->rotateZ(-alpha);
470  edm::LogVerbatim("SimG4CoreGeometry") << (*rot);
471 
472  // center point of the box
473  double xBox;
474  if (!cutInside) {
475  xBox = r + boxY / sin(std::abs(alpha));
476  } else {
477  xBox = -(boxY / sin(std::abs(alpha)) - r);
478  }
479 
480  G4ThreeVector trans(xBox, 0., 0.);
481  edm::LogVerbatim("SimG4CoreGeometry") << "trans=" << trans;
482 
483  G4VSolid *box = new G4Box(name, boxX, boxY, boxZ);
484  result = new G4SubtractionSolid(name, tubs, box, rot, trans);
485 
486  return result;
487 }
Log< level::Info, true > LogVerbatim
float alpha
Definition: AMPTWrapper.h:105
static G4RotationMatrix * rot
A truncated tube section.
Definition: DDSolid.h:139
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
static G4VSolid * tubs(const DDSolid &)
static const char *const name(DDSolidShape s)
Definition: DDSolidShapes.h:33
Definition: TTTypes.h:54
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static G4VSolid * box(const DDSolid &)
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:123

◆ tubs()

G4VSolid * DDG4SolidConverter::tubs ( const DDSolid solid)
staticprivate

Definition at line 68 of file DDG4SolidConverter.cc.

References DDName::name(), and DDBase< N, C >::name().

Referenced by DDG4SolidConverter(), pseudotrap(), and trunctubs().

68  {
69  edm::LogVerbatim("SimG4CoreGeometry") << "DDG4SolidConverter: tubs = " << solid;
70  return new G4Tubs(solid.name().name(),
71  (*par_)[1], // rmin
72  (*par_)[2], // rmax
73  (*par_)[0], // dzHalf
74  (*par_)[3], // phiStart
75  (*par_)[4]); // deltaPhi
76 }
Log< level::Info, true > LogVerbatim
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
const N & name() const
Definition: DDBase.h:59

◆ unionsolid()

G4VSolid * DDG4SolidConverter::unionsolid ( const DDSolid solid)
staticprivate

Definition at line 271 of file DDG4SolidConverter.cc.

References cms::cuda::bs, DDG4SolidConverter(), DDName::name(), and DDBase< N, C >::name().

Referenced by DDG4SolidConverter().

271  {
272  edm::LogVerbatim("SimG4CoreGeometry") << "DDG4SolidConverter: unionsolid = " << solid.name();
273  G4UnionSolid *us = nullptr;
274  DDBooleanSolid bs(solid);
275  if (bs) {
276  edm::LogVerbatim("SimG4CoreGeometry") << "SolidA=" << bs.solidA();
277  G4VSolid *sa = DDG4SolidConverter().convert(bs.solidA());
278  edm::LogVerbatim("SimG4CoreGeometry") << "SolidB=" << bs.solidB();
279  G4VSolid *sb = DDG4SolidConverter().convert(bs.solidB());
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);
287 
288  } // else?
289  return us;
290 }
Log< level::Info, true > LogVerbatim
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
const N & name() const
Definition: DDBase.h:59

Friends And Related Function Documentation

◆ testPseudoTrap

friend class testPseudoTrap
friend

Definition at line 49 of file DDG4SolidConverter.h.

◆ testTruncTubs

friend class testTruncTubs
friend

Definition at line 48 of file DDG4SolidConverter.h.

Member Data Documentation

◆ convDispatch_

std::map<DDSolidShape, FNPTR> DDG4SolidConverter::convDispatch_
private

Definition at line 44 of file DDG4SolidConverter.h.

Referenced by convert(), and DDG4SolidConverter().

◆ par_

const std::vector< double > * DDG4SolidConverter::par_ = nullptr
staticprivate

Definition at line 43 of file DDG4SolidConverter.h.

Referenced by convert(), cuttubs(), polycone_rrz(), polyhedra_rrz(), and polyhedra_rz().

◆ rot

G4RotationMatrix * DDG4SolidConverter::rot = nullptr
staticprivate

Definition at line 46 of file DDG4SolidConverter.h.

Referenced by pseudotrap(), and trunctubs().