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_ = 0
 
static G4RotationMatrix * rot = 0
 

Friends

class testPseudoTrap
 
class testTruncTubs
 

Detailed Description

Definition at line 14 of file DDG4SolidConverter.h.

Member Typedef Documentation

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

Definition at line 19 of file DDG4SolidConverter.h.

Constructor & Destructor Documentation

DDG4SolidConverter::DDG4SolidConverter ( )

Definition at line 13 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().

13  {
14  // could also be done 'dynamically' from outside
15  // would then need to have a 'register' method ...
34 }
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 &)
static G4VSolid * trunctubs(const DDSolid &)
static G4VSolid * torus(const DDSolid &)
static G4VSolid * polyhedra_rz(const DDSolid &)
static G4VSolid * polycone_rrz(const DDSolid &)
std::map< DDSolidShape, FNPTR > convDispatch_
static G4VSolid * subtraction(const DDSolid &)
DDG4SolidConverter::~DDG4SolidConverter ( )

Definition at line 36 of file DDG4SolidConverter.cc.

36 {}

Member Function Documentation

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

Definition at line 59 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter(), and trunctubs().

59  {
60  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: box = " << solid;
61  return new G4Box(solid.name().name(), (*par_)[0],(*par_)[1],(*par_)[2]);
62 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
const std::string & name() const
Returns the name.
Definition: DDName.cc:88
G4VSolid * DDG4SolidConverter::cons ( const DDSolid solid)
staticprivate

Definition at line 106 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

106  {
107  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: cons = " << solid;
108  return new G4Cons(solid.name().name(), (*par_)[1], // rmin -z
109  (*par_)[2], // rmax -z
110  (*par_)[3], // rmin +z
111  (*par_)[4], // rmax +z
112  (*par_)[0], // zHalf
113  (*par_)[5], // phistart
114  (*par_)[6]); // deltaphi
115 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
const std::string & name() const
Returns the name.
Definition: DDName.cc:88
G4VSolid * DDG4SolidConverter::convert ( const DDSolid solid)

Definition at line 38 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().

38  {
39  if ( !solid ) {
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());
42  }
43  G4VSolid * result = nullptr;
44  par_ = &(solid.parameters());
45  std::map<DDSolidShape,FNPTR>::iterator it = convDispatch_.find(solid.shape());
46  if (it != convDispatch_.end()) {
47  result = it->second(solid);
48  } else {
49  throw cms::Exception("DetectorDescriptionFault")
50  << "DDG4SolidConverter::convert: conversion failed for s=" << solid
51  << "\n solid.shape()=" << DDSolidShapesName::name(solid.shape())
52  << std::endl;
53  }
54  return result;
55 }
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:144
static const char *const name(DDSolidShape s)
Definition: DDSolidShapes.h:17
static const std::vector< double > * par_
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:138
std::string toString() const
Definition: DDBase.h:82
std::map< DDSolidShape, FNPTR > convDispatch_
G4VSolid * DDG4SolidConverter::cuttubs ( const DDSolid solid)
staticprivate

Definition at line 76 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

76  {
77  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: tubs = " << solid;
78  return new G4CutTubs(solid.name().name(), (*par_)[1], // rmin
79  (*par_)[2], // rmax
80  (*par_)[0], // dzHalf
81  (*par_)[3], // phiStart
82  (*par_)[4], // deltaPhi
83  G4ThreeVector((*par_)[5],(*par_)[6],(*par_)[7]),
84  G4ThreeVector((*par_)[8],(*par_)[9],(*par_)[10]));
85 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
const std::string & name() const
Returns the name.
Definition: DDName.cc:88
G4VSolid * DDG4SolidConverter::ellipticaltube ( const DDSolid solid)
staticprivate

Definition at line 506 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

506  {
507  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: ellipticaltube = " << solid;
508  DDEllipticalTube sp(solid);
509  return new G4EllipticalTube(solid.name().name(),
510  sp.xSemiAxis(),
511  sp.ySemiAxis(),
512  sp.zHeight());
513 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
const std::string & name() const
Returns the name.
Definition: DDName.cc:88
G4VSolid * DDG4SolidConverter::extrudedpolygon ( const DDSolid solid)
staticprivate

Definition at line 231 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

231  {
232  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: extr_pgon = " << solid;
233  std::vector<double> x = static_cast<DDExtrudedPolygon>(solid).xVec();
234  std::vector<double> y = static_cast<DDExtrudedPolygon>(solid).yVec();
235  std::vector<double> z = static_cast<DDExtrudedPolygon>(solid).zVec();
236  std::vector<double> zx = static_cast<DDExtrudedPolygon>(solid).zxVec();
237  std::vector<double> zy = static_cast<DDExtrudedPolygon>(solid).zyVec();
238  std::vector<double> zs = static_cast<DDExtrudedPolygon>(solid).zscaleVec();
239 
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 );
247 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
const std::string & name() const
Returns the name.
Definition: DDName.cc:88
G4VSolid * DDG4SolidConverter::intersection ( const DDSolid solid)
staticprivate

Definition at line 310 of file DDG4SolidConverter.cc.

References DDG4SolidConverter(), LogDebug, DDName::name(), DDBase< N, C >::name(), DDRotation::rotation(), DDBooleanSolid::rotation(), DDBooleanSolid::solidA(), DDBooleanSolid::solidB(), and DDBooleanSolid::translation().

Referenced by DDG4SolidConverter().

310  {
311  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: intersection = " << solid;
312  G4IntersectionSolid * us = nullptr;
313  DDBooleanSolid bs(solid);
314  if (bs) {
315  G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
316  G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
317  LogDebug("SimG4CoreGeometry") << " name:" << solid.name() << " t=" << bs.translation() << std::flush;
318  LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << std::flush;
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]);
322  CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z());
323  us = new G4IntersectionSolid(solid.name().name(),
324  sa,
325  sb,
326  new CLHEP::HepRotation(temprep),
327  temphvec);
328  }
329  return us;
330 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
const std::string & name() const
Returns the name.
Definition: DDName.cc:88
G4VSolid * DDG4SolidConverter::polycone_rrz ( const DDSolid solid)
staticprivate

Definition at line 149 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

149  {
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;
155  int count = 0;
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);
163  count++;
164  }
165  LogDebug("SimG4CoreGeometry") << "sp=" << (*par_)[0]/CLHEP::deg << " ep="
166  << (*par_)[1]/CLHEP::deg;
167  /*
168  std::cout << "### Polycone_RRZ: " << "sp=" << (*par_)[0]/CLHEP::deg
169  << " ep=" << (*par_)[1]/CLHEP::deg
170  << " N= " << count << std::endl;
171  for(int i=0; i<count; ++i) {
172  std::cout << " R1= " << rmin_p[i] << " R1= " << rmax_p[i] << " Z= " << z_p[i] << std::endl;
173  }
174  */
175  return new G4Polycone(solid.name().name(), (*par_)[0], (*par_)[1], // start,delta-phi
176  count, // sections
177  &(z_p[0]),
178  &(rmin_p[0]),
179  &(rmax_p[0]));
180 
181 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
static const std::vector< double > * par_
const std::string & name() const
Returns the name.
Definition: DDName.cc:88
G4VSolid * DDG4SolidConverter::polycone_rz ( const DDSolid solid)
staticprivate

Definition at line 119 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

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); ++i;
128  LogDebug("SimG4CoreGeometry") << " r=" << *i/CLHEP::cm;
129  r.push_back(*i);
130  count++;
131  }
132  LogDebug("SimG4CoreGeometry") << "sp=" << (*par_)[0]/CLHEP::deg << " ep="
133  << (*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(), (*par_)[0], (*par_)[1], // start,delta-phi
143  count, // numRZ
144  &(r[0]),
145  &(z[0]));
146 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
const std::string & name() const
Returns the name.
Definition: DDName.cc:88
G4VSolid * DDG4SolidConverter::polyhedra_rrz ( const DDSolid solid)
staticprivate

Definition at line 205 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

205  {
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;
211  int count = 0;
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);
219  count++;
220  }
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]), // start,delta-phi,sides
224  count, // sections
225  &(z_p[0]),
226  &(rmin_p[0]),
227  &(rmax_p[0]));
228 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
static const std::vector< double > * par_
const std::string & name() const
Returns the name.
Definition: DDName.cc:88
G4VSolid * DDG4SolidConverter::polyhedra_rz ( const DDSolid solid)
staticprivate

Definition at line 185 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

185  {
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;
190  int count=0;
191 
192  for(; i!=par_->end(); ++i) {
193  z.push_back(*i); ++i;
194  r.push_back(*i);
195  count++;
196  }
197 
198  return new G4Polyhedra(solid.name().name(), (*par_)[1], (*par_)[2], int((*par_)[0]),// start,delta-phi;sides
199  count, // numRZ
200  &(r[0]),
201  &(z[0]));
202 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
static const std::vector< double > * par_
const std::string & name() const
Returns the name.
Definition: DDName.cc:88
G4VSolid * DDG4SolidConverter::pseudotrap ( const DDSolid s)
staticprivate

Definition at line 333 of file DDG4SolidConverter.cc.

References funct::abs(), DDPseudoTrap::atMinusZ(), delta, Exception, h, DDPseudoTrap::halfZ(), LogDebug, DDName::name(), dataset::name, DDBase< N, C >::name(), EnergyCorrector::pt, alignCSCRings::r, DDPseudoTrap::radius(), mps_fire::result, rot, mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, trap(), tubs(), x, DDPseudoTrap::x1(), DDPseudoTrap::x2(), DDPseudoTrap::y1(), and DDPseudoTrap::y2().

Referenced by DDG4SolidConverter().

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

Definition at line 494 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

494  {
495  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: sphere = " << solid;
496  DDSphere sp(solid);
497  return new G4Sphere(solid.name().name(), sp.innerRadius(),
498  sp.outerRadius(),
499  sp.startPhi(),
500  sp.deltaPhi(),
501  sp.startTheta(),
502  sp.deltaTheta());
503 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
const std::string & name() const
Returns the name.
Definition: DDName.cc:88
G4VSolid * DDG4SolidConverter::subtraction ( const DDSolid solid)
staticprivate

Definition at line 287 of file DDG4SolidConverter.cc.

References DDG4SolidConverter(), LogDebug, DDName::name(), DDBase< N, C >::name(), DDRotation::rotation(), DDBooleanSolid::rotation(), DDBooleanSolid::solidA(), DDBooleanSolid::solidB(), and DDBooleanSolid::translation().

Referenced by DDG4SolidConverter().

287  {
288  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: subtraction = " << solid;
289  G4SubtractionSolid * us = nullptr;
290  DDBooleanSolid bs(solid);
291  if (bs) {
292  G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
293  G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
294  LogDebug("SimG4CoreGeometry") << " name:" << solid.name() << " t=" << bs.translation() << std::flush;
295  LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << std::flush;
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]);
299  CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z());
300  us = new G4SubtractionSolid(solid.name().name(),
301  sa,
302  sb,
303  new CLHEP::HepRotation(temprep),
304  temphvec);
305  }
306  return us;
307 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
const std::string & name() const
Returns the name.
Definition: DDName.cc:88
G4VSolid * DDG4SolidConverter::torus ( const DDSolid solid)
staticprivate

Definition at line 250 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

250  {
251  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: torus = " << solid;
252  return new G4Torus(solid.name().name(), (*par_)[0], // rmin
253  (*par_)[1], // rmax
254  (*par_)[2], // Rtor
255  (*par_)[3], // phiStart
256  (*par_)[4]);// deltaPhi
257 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
const std::string & name() const
Returns the name.
Definition: DDName.cc:88
G4VSolid * DDG4SolidConverter::trap ( const DDSolid solid)
staticprivate

Definition at line 89 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter(), and pseudotrap().

89  {
90  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: trap = " << solid;
91  return new G4Trap(solid.name().name(), (*par_)[0], // pDz
92  (*par_)[1], // theta
93  (*par_)[2], // phi
94  (*par_)[3], // y1
95  (*par_)[4], // x1
96  (*par_)[5], // x2
97  (*par_)[6], // alpha1
98  (*par_)[7], // y2
99  (*par_)[8], // x3
100  (*par_)[9], // x4
101  (*par_)[10]);// alpha2
102 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
const std::string & name() const
Returns the name.
Definition: DDName.cc:88
G4VSolid * DDG4SolidConverter::trunctubs ( const DDSolid solid)
staticprivate

Definition at line 418 of file DDG4SolidConverter.cc.

References funct::abs(), alpha, box(), funct::cos(), DDTruncTubs::cutAtDelta(), DDTruncTubs::cutAtStart(), DDTruncTubs::cutInside(), hiPixelPairStep_cff::deltaPhi, DDTruncTubs::deltaPhi(), Exception, DDName::fullname(), LogDebug, DDSolidShapesName::name(), DDName::name(), dataset::name, DDBase< N, C >::name(), dttmaxenums::R, alignCSCRings::r, mps_fire::result, DDTruncTubs::rIn(), rot, DDTruncTubs::rOut(), DDSolid::shape(), funct::sin(), mathSSE::sqrt(), DDTruncTubs::startPhi(), AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::tt, tubs(), and DDTruncTubs::zHalf().

Referenced by DDG4SolidConverter().

418  {
419  // truncated tube-section: a boolean subtraction solid:
420  // from a tube-section a box is subtracted according to the
421  // given parameters
422  LogDebug("SimG4CoreGeometry") << "MantisConverter: solidshape=" << DDSolidShapesName::name(solid.shape()) << " " << solid;
423  LogDebug("SimG4CoreGeometry") << "before";
424  DDTruncTubs tt(solid);
425  LogDebug("SimG4CoreGeometry") << "after";
426  double rIn(tt.rIn()), rOut(tt.rOut()), zHalf(tt.zHalf()),
427  startPhi(tt.startPhi()), deltaPhi(tt.deltaPhi()),
428  cutAtStart(tt.cutAtStart()), cutAtDelta(tt.cutAtDelta());
429  bool cutInside(bool(tt.cutInside()));
430  std::string name=tt.name().name();
431 
432  // check the parameters
433  if (rIn <= 0 || rOut <=0 || cutAtStart <=0 || cutAtDelta <= 0) {
434  throw cms::Exception("DetectorDescriptionFault", "TruncTubs " + std::string(tt.name().fullname()) + ": 0 <= rIn,cutAtStart,rOut,cutAtDelta,rOut violated!");
435  }
436  if (rIn >= rOut) {
437  throw cms::Exception("DetectorDescriptionFault", "TruncTubs " + std::string(tt.name().fullname()) + ": rIn<rOut violated!");
438  }
439  if (startPhi != 0.) {
440  throw cms::Exception("DetectorDescriptionFault", "TruncTubs " + std::string(tt.name().fullname()) + ": startPhi != 0 not supported!");
441  }
442 
443  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;
449  // length & hight of the box
450  double boxX(30.*rOut), boxY(20.*rOut); // exaggerate dimensions - does not matter, it's subtracted!
451 
452  // width of the box > width of the tubs
453  double boxZ(1.1*zHalf);
454 
455  // angle of the box w.r.t. tubs
456  double cath = r-R*cos(deltaPhi);
457  double hypo = sqrt(r*r+R*R-2.*r*R*cos(deltaPhi));
458  double cos_alpha = cath/hypo;
459 
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;
464  LogDebug("SimG4CoreGeometry") << "deltaPhi=" << deltaPhi/CLHEP::deg << "\n"
465  << "r=" << r/CLHEP::cm << "\n"
466  << "R=" << R/CLHEP::cm;
467 
468  LogDebug("SimG4CoreGeometry") << "alpha=" << alpha/CLHEP::deg;
469 
470  // rotationmatrix of box w.r.t. tubs
471  G4RotationMatrix * rot = new G4RotationMatrix;
472  rot->rotateZ(-alpha);
473  LogDebug("SimG4CoreGeometry") << (*rot);
474 
475  // center point of the box
476  double xBox;
477  if (!cutInside) {
478  xBox = r+boxY/sin(std::abs(alpha));
479  } else {
480  xBox = -(boxY/sin(std::abs(alpha))-r);
481  }
482 
483  G4ThreeVector trans(xBox,0.,0.);
484  LogDebug("SimG4CoreGeometry") << "trans=" << trans;
485 
486  G4VSolid * box = new G4Box(name,boxX,boxY,boxZ);
487  result = new G4SubtractionSolid(name,tubs,box,rot,trans);
488 
489  return result;
490 
491 }
#define LogDebug(id)
float alpha
Definition: AMPTWrapper.h:95
static G4RotationMatrix * rot
A truncated tube section.
Definition: DDSolid.h:134
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:17
T sqrt(T t)
Definition: SSEVec.h:18
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:138
static G4VSolid * box(const DDSolid &)
G4VSolid * DDG4SolidConverter::tubs ( const DDSolid solid)
staticprivate

Definition at line 66 of file DDG4SolidConverter.cc.

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

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

66  {
67  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: tubs = " << solid;
68  return new G4Tubs(solid.name().name(), (*par_)[1], // rmin
69  (*par_)[2], // rmax
70  (*par_)[0], // dzHalf
71  (*par_)[3], // phiStart
72  (*par_)[4]);// deltaPhi
73 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
const std::string & name() const
Returns the name.
Definition: DDName.cc:88
G4VSolid * DDG4SolidConverter::unionsolid ( const DDSolid solid)
staticprivate

Definition at line 260 of file DDG4SolidConverter.cc.

References DDG4SolidConverter(), LogDebug, DDName::name(), DDBase< N, C >::name(), DDRotation::rotation(), DDBooleanSolid::rotation(), DDBooleanSolid::solidA(), DDBooleanSolid::solidB(), and DDBooleanSolid::translation().

Referenced by DDG4SolidConverter().

260  {
261  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: unionsolid = " << solid.name();
262  G4UnionSolid * us = nullptr;
263  DDBooleanSolid bs(solid);
264  if (bs) {
265  LogDebug("SimG4CoreGeometry") << "SolidA=" << bs.solidA();
266  G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
267  LogDebug("SimG4CoreGeometry") << "SolidB=" << bs.solidB();
268  G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
269  LogDebug("SimG4CoreGeometry") << " name:" << solid.name() << " t=" << bs.translation() << std::flush;
270  LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << std::flush;
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]);
274  CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z());
275  us = new G4UnionSolid(solid.name().name(),
276  sa,
277  sb,
278  new CLHEP::HepRotation(temprep),
279  temphvec);
280 
281  } // else?
282  return us;
283 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
const std::string & name() const
Returns the name.
Definition: DDName.cc:88

Friends And Related Function Documentation

friend class testPseudoTrap
friend

Definition at line 50 of file DDG4SolidConverter.h.

friend class testTruncTubs
friend

Definition at line 49 of file DDG4SolidConverter.h.

Member Data Documentation

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

Definition at line 45 of file DDG4SolidConverter.h.

Referenced by convert(), and DDG4SolidConverter().

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

Definition at line 44 of file DDG4SolidConverter.h.

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

G4RotationMatrix * DDG4SolidConverter::rot = 0
staticprivate

Definition at line 47 of file DDG4SolidConverter.h.

Referenced by pseudotrap(), and trunctubs().