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 13 of file DDG4SolidConverter.cc.

13  {
14  // could also be done 'dynamically' from outside
15  // would then need to have a 'register' method ...
34 }

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().

◆ ~DDG4SolidConverter()

DDG4SolidConverter::~DDG4SolidConverter ( )

Definition at line 36 of file DDG4SolidConverter.cc.

36 {}

Member Function Documentation

◆ box()

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

Definition at line 59 of file DDG4SolidConverter.cc.

59  {
60  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: box = " << solid;
61  return new G4Box(solid.name().name(), (*par_)[0], (*par_)[1], (*par_)[2]);
62 }

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

Referenced by DDG4SolidConverter(), and trunctubs().

◆ cons()

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

Definition at line 106 of file DDG4SolidConverter.cc.

106  {
107  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: cons = " << solid;
108  return new G4Cons(solid.name().name(),
109  (*par_)[1], // rmin -z
110  (*par_)[2], // rmax -z
111  (*par_)[3], // rmin +z
112  (*par_)[4], // rmax +z
113  (*par_)[0], // zHalf
114  (*par_)[5], // phistart
115  (*par_)[6]); // deltaphi
116 }

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

Referenced by DDG4SolidConverter().

◆ convert()

G4VSolid * DDG4SolidConverter::convert ( const DDSolid solid)

Definition at line 38 of file DDG4SolidConverter.cc.

38  {
39  if (!solid) {
40  edm::LogError("SimG4CoreGeometry") << " DDG4SolidConverter::convert(..) found an undefined DDSolid "
41  << solid.toString();
42  throw cms::Exception("SimG4CoreGeometry",
43  "DDG4SolidConverter::convert(..) found an undefined DDSolid " + solid.toString());
44  }
45  G4VSolid *result = nullptr;
46  par_ = &(solid.parameters());
47  std::map<DDSolidShape, FNPTR>::iterator it = convDispatch_.find(solid.shape());
48  if (it != convDispatch_.end()) {
49  result = it->second(solid);
50  } else {
51  throw cms::Exception("DetectorDescriptionFault")
52  << "DDG4SolidConverter::convert: conversion failed for s=" << solid
53  << "\n solid.shape()=" << DDSolidShapesName::name(solid.shape()) << std::endl;
54  }
55  return result;
56 }

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

Referenced by DDG4Builder::convertSolid().

◆ cuttubs()

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

Definition at line 76 of file DDG4SolidConverter.cc.

76  {
77  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: tubs = " << solid;
78  return new G4CutTubs(solid.name().name(),
79  (*par_)[1], // rmin
80  (*par_)[2], // rmax
81  (*par_)[0], // dzHalf
82  (*par_)[3], // phiStart
83  (*par_)[4], // deltaPhi
84  G4ThreeVector((*par_)[5], (*par_)[6], (*par_)[7]),
85  G4ThreeVector((*par_)[8], (*par_)[9], (*par_)[10]));
86 }

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

Referenced by DDG4SolidConverter().

◆ ellipticaltube()

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

Definition at line 502 of file DDG4SolidConverter.cc.

502  {
503  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: ellipticaltube = " << solid;
504  DDEllipticalTube sp(solid);
505  return new G4EllipticalTube(solid.name().name(), sp.xSemiAxis(), sp.ySemiAxis(), sp.zHeight());
506 }

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

Referenced by DDG4SolidConverter().

◆ extrudedpolygon()

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

Definition at line 241 of file DDG4SolidConverter.cc.

241  {
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();
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 }

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

Referenced by DDG4SolidConverter().

◆ intersection()

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

Definition at line 313 of file DDG4SolidConverter.cc.

313  {
314  LogDebug("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  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);
327  }
328  return us;
329 }

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

Referenced by DDG4SolidConverter().

◆ polycone_rrz()

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

Definition at line 150 of file DDG4SolidConverter.cc.

150  {
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;
156  int count = 0;
157  for (; i != par_->end(); ++i) {
158  LogDebug("SimG4CoreGeometry") << "z=" << *i / CLHEP::cm;
159  z_p.push_back(*i);
160  ++i;
161  LogDebug("SimG4CoreGeometry") << "rmin=" << *i / CLHEP::cm;
162  rmin_p.push_back(*i);
163  ++i;
164  LogDebug("SimG4CoreGeometry") << "rmax=" << *i / CLHEP::cm;
165  rmax_p.push_back(*i);
166  count++;
167  }
168  LogDebug("SimG4CoreGeometry") << "sp=" << (*par_)[0] / CLHEP::deg << " ep=" << (*par_)[1] / CLHEP::deg;
169  /*
170  std::cout << "### Polycone_RRZ: " << "sp=" << (*par_)[0]/CLHEP::deg
171  << " ep=" << (*par_)[1]/CLHEP::deg
172  << " N= " << count << std::endl;
173  for(int i=0; i<count; ++i) {
174  std::cout << " R1= " << rmin_p[i] << " R1= " << rmax_p[i] << " Z= " <<
175  z_p[i] << std::endl;
176  }
177  */
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 }

References KineDebug3::count(), mps_fire::i, LogDebug, DDName::name(), DDBase< N, C >::name(), and par_.

Referenced by DDG4SolidConverter().

◆ polycone_rz()

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

Definition at line 119 of file DDG4SolidConverter.cc.

119  {
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;
124  int count = 0;
125  for (; i != (*par_).end(); ++i) {
126  LogDebug("SimG4CoreGeometry") << " z=" << *i / CLHEP::cm;
127  z.push_back(*i);
128  ++i;
129  LogDebug("SimG4CoreGeometry") << " r=" << *i / CLHEP::cm;
130  r.push_back(*i);
131  count++;
132  }
133  LogDebug("SimG4CoreGeometry") << "sp=" << (*par_)[0] / CLHEP::deg << " ep=" << (*par_)[1] / CLHEP::deg;
134  /*
135  std::cout << "### Polycone_RZ: " << "sp=" << (*par_)[0]/CLHEP::deg
136  << " ep=" << (*par_)[1]/CLHEP::deg
137  << " N= " << count << std::endl;
138  for(int i=0; i<count; ++i) {
139  std::cout << " R= " << r[i] << " Z= " << z[i] << std::endl;
140  }
141  */
142  return new G4Polycone(solid.name().name(),
143  (*par_)[0],
144  (*par_)[1], // start,delta-phi
145  count, // numRZ
146  &(r[0]),
147  &(z[0]));
148 }

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

Referenced by DDG4SolidConverter().

◆ polyhedra_rrz()

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

Definition at line 211 of file DDG4SolidConverter.cc.

211  {
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;
217  int count = 0;
218  for (; i != par_->end(); ++i) {
219  LogDebug("SimG4CoreGeometry") << "z=" << *i / CLHEP::cm;
220  z_p.push_back(*i);
221  ++i;
222  LogDebug("SimG4CoreGeometry") << "rmin=" << *i / CLHEP::cm;
223  rmin_p.push_back(*i);
224  ++i;
225  LogDebug("SimG4CoreGeometry") << "rmax=" << *i / CLHEP::cm;
226  rmax_p.push_back(*i);
227  count++;
228  }
229  LogDebug("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 }

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

Referenced by DDG4SolidConverter().

◆ polyhedra_rz()

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

Definition at line 188 of file DDG4SolidConverter.cc.

188  {
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;
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 }

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

Referenced by DDG4SolidConverter().

◆ pseudotrap()

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

Definition at line 332 of file DDG4SolidConverter.cc.

332  {
333  if (nullptr == rot) {
334  rot = new G4RotationMatrix;
335  rot->rotateX(90. * deg);
336  }
337 
338  LogDebug("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  LogDebug("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 }

References funct::abs(), dumpMFGeometry_cfg::delta, Exception, h, LogDebug, 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().

◆ shapeless()

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

◆ sphere()

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

Definition at line 489 of file DDG4SolidConverter.cc.

489  {
490  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: sphere = " << solid;
491  DDSphere sp(solid);
492  return new G4Sphere(solid.name().name(),
493  sp.innerRadius(),
494  sp.outerRadius(),
495  sp.startPhi(),
496  sp.deltaPhi(),
497  sp.startTheta(),
498  sp.deltaTheta());
499 }

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

Referenced by DDG4SolidConverter().

◆ subtraction()

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

Definition at line 294 of file DDG4SolidConverter.cc.

294  {
295  LogDebug("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  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);
308  }
309  return us;
310 }

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

Referenced by DDG4SolidConverter().

◆ torus()

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

Definition at line 260 of file DDG4SolidConverter.cc.

260  {
261  LogDebug("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 }

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

Referenced by DDG4SolidConverter().

◆ trap()

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

Definition at line 89 of file DDG4SolidConverter.cc.

89  {
90  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: trap = " << solid;
91  return new G4Trap(solid.name().name(),
92  (*par_)[0], // pDz
93  (*par_)[1], // theta
94  (*par_)[2], // phi
95  (*par_)[3], // y1
96  (*par_)[4], // x1
97  (*par_)[5], // x2
98  (*par_)[6], // alpha1
99  (*par_)[7], // y2
100  (*par_)[8], // x3
101  (*par_)[9], // x4
102  (*par_)[10]); // alpha2
103 }

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

Referenced by DDG4SolidConverter(), and pseudotrap().

◆ trunctubs()

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

Definition at line 408 of file DDG4SolidConverter.cc.

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  LogDebug("SimG4CoreGeometry") << "MantisConverter: solidshape=" << DDSolidShapesName::name(solid.shape()) << " "
413  << solid;
414  LogDebug("SimG4CoreGeometry") << "before";
415  DDTruncTubs tt(solid);
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()));
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  LogDebug("SimG4CoreGeometry") << "G4Tubs: " << rIn / CLHEP::cm << ' ' << rOut / CLHEP::cm << ' ' << zHalf / CLHEP::cm
442  << ' ' << startPhi / CLHEP::deg << ' ' << deltaPhi / CLHEP::deg;
443  LogDebug("SimG4CoreGeometry") << solid;
444  // length & hight of the box
445  double boxX(rOut * std::sqrt(2) * 1.1),
446  boxY(rOut * std::sqrt(2) * 1.1); // exaggerate dimensions - does not matter, it's subtracted!
447 
448  // width of the box > width of the tubs
449  double boxZ(1.1 * zHalf);
450 
451  // angle of the box w.r.t. tubs
452  double cath = r - R * cos(deltaPhi);
453  double hypo = sqrt(r * r + R * R - 2. * r * R * cos(deltaPhi));
454  double cos_alpha = cath / hypo;
455 
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;
463 
464  LogDebug("SimG4CoreGeometry") << "alpha=" << alpha / CLHEP::deg;
465 
466  // rotationmatrix of box w.r.t. tubs
467  G4RotationMatrix *rot = new G4RotationMatrix;
468  rot->rotateZ(-alpha);
469  LogDebug("SimG4CoreGeometry") << (*rot);
470 
471  // center point of the box
472  double xBox;
473  if (!cutInside) {
474  xBox = r + boxY / sin(std::abs(alpha));
475  } else {
476  xBox = -(boxY / sin(std::abs(alpha)) - r);
477  }
478 
479  G4ThreeVector trans(xBox, 0., 0.);
480  LogDebug("SimG4CoreGeometry") << "trans=" << trans;
481 
482  G4VSolid *box = new G4Box(name, boxX, boxY, boxZ);
483  result = new G4SubtractionSolid(name, tubs, box, rot, trans);
484 
485  return result;
486 }

References funct::abs(), zMuMuMuonUserData::alpha, box(), funct::cos(), SiPixelRawToDigiRegional_cfi::deltaPhi, Exception, LogDebug, 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().

◆ tubs()

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

Definition at line 65 of file DDG4SolidConverter.cc.

65  {
66  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: tubs = " << solid;
67  return new G4Tubs(solid.name().name(),
68  (*par_)[1], // rmin
69  (*par_)[2], // rmax
70  (*par_)[0], // dzHalf
71  (*par_)[3], // phiStart
72  (*par_)[4]); // deltaPhi
73 }

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

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

◆ unionsolid()

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

Definition at line 271 of file DDG4SolidConverter.cc.

271  {
272  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: unionsolid = " << solid.name();
273  G4UnionSolid *us = nullptr;
274  DDBooleanSolid bs(solid);
275  if (bs) {
276  LogDebug("SimG4CoreGeometry") << "SolidA=" << bs.solidA();
277  G4VSolid *sa = DDG4SolidConverter().convert(bs.solidA());
278  LogDebug("SimG4CoreGeometry") << "SolidB=" << bs.solidB();
279  G4VSolid *sb = DDG4SolidConverter().convert(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);
287 
288  } // else?
289  return us;
290 }

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

Referenced by DDG4SolidConverter().

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().

DDG4SolidConverter::polycone_rrz
static G4VSolid * polycone_rrz(const DDSolid &)
Definition: DDG4SolidConverter.cc:150
DDAxes::y
mps_fire.i
i
Definition: mps_fire.py:355
DDEllipticalTube
Definition: DDSolid.h:352
DDSolidShape::ddtrap
DDSolidShape::ddtorus
groupFilesInBlocks.tt
int tt
Definition: groupFilesInBlocks.py:144
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
DDG4SolidConverter::cons
static G4VSolid * cons(const DDSolid &)
Definition: DDG4SolidConverter.cc:106
zMuMuMuonUserData.alpha
alpha
zGenParticlesMatch = cms.InputTag(""),
Definition: zMuMuMuonUserData.py:9
DDSolidShape::ddpseudotrap
h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition: L1TUtmAlgorithmRcd.h:4
DDSolidShape::ddpolyhedra_rrz
DDG4SolidConverter::rot
static G4RotationMatrix * rot
Definition: DDG4SolidConverter.h:46
DDG4SolidConverter::trap
static G4VSolid * trap(const DDSolid &)
Definition: DDG4SolidConverter.cc:89
DDG4SolidConverter::convDispatch_
std::map< DDSolidShape, FNPTR > convDispatch_
Definition: DDG4SolidConverter.h:44
DDAxes::x
DDG4SolidConverter::ellipticaltube
static G4VSolid * ellipticaltube(const DDSolid &)
Definition: DDG4SolidConverter.cc:502
DDPseudoTrap
Definition: DDSolid.h:106
DDG4SolidConverter::pseudotrap
static G4VSolid * pseudotrap(const DDSolid &s)
Definition: DDG4SolidConverter.cc:332
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DDBooleanSolid
Definition: DDSolid.h:173
DDSolid::shape
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:119
cms::cuda::bs
bs
Definition: HistoContainer.h:127
DDG4SolidConverter::par_
static const std::vector< double > * par_
Definition: DDG4SolidConverter.h:43
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
DDTruncTubs
A truncated tube section.
Definition: DDSolid.h:128
DDSolidShape::ddtubs
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
DDBase::toString
std::string toString() const
Definition: DDBase.h:63
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
DDSolidShape::ddtrunctubs
DDSolidShape::ddpolyhedra_rz
DDBase::name
const N & name() const
Definition: DDBase.h:59
DDAxes::z
h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDSolidShapesName::name
static const char *const name(DDSolidShape s)
Definition: DDSolidShapes.h:32
DDSolidShape::ddellipticaltube
DDG4SolidConverter::subtraction
static G4VSolid * subtraction(const DDSolid &)
Definition: DDG4SolidConverter.cc:294
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::LogError
Definition: MessageLogger.h:183
DDSolidShape::ddsphere
KineDebug3::count
void count()
Definition: KinematicConstrainedVertexUpdatorT.h:21
dumpMFGeometry_cfg.delta
delta
Definition: dumpMFGeometry_cfg.py:25
DDSolidShape::ddcons
DDG4SolidConverter::polycone_rz
static G4VSolid * polycone_rz(const DDSolid &)
Definition: DDG4SolidConverter.cc:119
createfilelist.int
int
Definition: createfilelist.py:10
DDG4SolidConverter::box
static G4VSolid * box(const DDSolid &)
Definition: DDG4SolidConverter.cc:59
DDName::name
const std::string & name() const
Returns the name.
Definition: DDName.cc:40
DDSphere
Definition: DDSolid.h:331
DDG4SolidConverter::DDG4SolidConverter
DDG4SolidConverter()
Definition: DDG4SolidConverter.cc:13
DDG4SolidConverter::tubs
static G4VSolid * tubs(const DDSolid &)
Definition: DDG4SolidConverter.cc:65
alignCSCRings.r
r
Definition: alignCSCRings.py:93
DDSolidShape::ddbox
Exception
Definition: hltDiff.cc:246
DDG4SolidConverter::sphere
static G4VSolid * sphere(const DDSolid &)
Definition: DDG4SolidConverter.cc:489
DDG4SolidConverter::unionsolid
static G4VSolid * unionsolid(const DDSolid &)
Definition: DDG4SolidConverter.cc:271
DDG4SolidConverter::intersection
static G4VSolid * intersection(const DDSolid &)
Definition: DDG4SolidConverter.cc:313
DDG4SolidConverter::extrudedpolygon
static G4VSolid * extrudedpolygon(const DDSolid &)
Definition: DDG4SolidConverter.cc:241
DDSolid::parameters
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:121
DDSolidShape::ddextrudedpolygon
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
DDG4SolidConverter::trunctubs
static G4VSolid * trunctubs(const DDSolid &)
Definition: DDG4SolidConverter.cc:408
DDG4SolidConverter::cuttubs
static G4VSolid * cuttubs(const DDSolid &)
Definition: DDG4SolidConverter.cc:76
DDSolidShape::ddcuttubs
DDSolidShape::ddpolycone_rrz
mps_fire.result
result
Definition: mps_fire.py:303
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
DDSolidShape::ddsubtraction
DDSolidShape::ddintersection
dttmaxenums::R
Definition: DTTMax.h:29
DDSolidShape::ddunion
DDSolidShape::ddpolycone_rz
DDG4SolidConverter::torus
static G4VSolid * torus(const DDSolid &)
Definition: DDG4SolidConverter.cc:260
DDG4SolidConverter::polyhedra_rz
static G4VSolid * polyhedra_rz(const DDSolid &)
Definition: DDG4SolidConverter.cc:188
DDG4SolidConverter::polyhedra_rrz
static G4VSolid * polyhedra_rrz(const DDSolid &)
Definition: DDG4SolidConverter.cc:211