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 * ellipsoid (const DDSolid &)
 
static G4VSolid * ellipticaltube (const DDSolid &)
 
static G4VSolid * intersection (const DDSolid &)
 
static G4VSolid * orb (const DDSolid &)
 
static G4VSolid * para (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 * reflected (const DDSolid &)
 
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, ddellipsoid, ddellipticaltube, ddintersection, ddorb, ddparallelepiped, ddpolycone_rrz, ddpolycone_rz, ddpolyhedra_rrz, ddpolyhedra_rz, ddpseudotrap, ddreflected, ddsphere, ddsubtraction, ddtorus, ddtrap, ddtrunctubs, ddtubs, ddunion, ellipsoid(), ellipticaltube(), intersection(), orb(), para(), polycone_rrz(), polycone_rz(), polyhedra_rrz(), polyhedra_rz(), pseudotrap(), reflected(), sphere(), subtraction(), torus(), trap(), trunctubs(), tubs(), and unionsolid().

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

13  {
14  // could also be done 'dynamically' from outside
15  // would then need to have a 'register' method ...
37 }
static G4VSolid * polyhedra_rrz(const DDSolid &)
static G4VSolid * orb(const DDSolid &)
static G4VSolid * ellipsoid(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 * reflected(const DDSolid &)
static G4VSolid * para(const DDSolid &)
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 * 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 39 of file DDG4SolidConverter.cc.

39 {}

Member Function Documentation

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

Definition at line 62 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter(), and trunctubs().

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

Definition at line 109 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

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

Definition at line 41 of file DDG4SolidConverter.cc.

References convDispatch_, Exception, 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 " << solid.toString();
44  throw cms::Exception("SimG4CoreGeometry", "DDG4SolidConverter::convert(..) found an undefined DDSolid " + solid.toString());
45  }
46  G4VSolid * result = nullptr;
47  par_ = &(solid.parameters());
48  std::map<DDSolidShape,FNPTR>::iterator it = convDispatch_.find(solid.shape());
49  if (it != convDispatch_.end()) {
50  result = it->second(solid);
51  } else {
52  throw cms::Exception("DetectorDescriptionFault")
53  << "DDG4SolidConverter::convert: conversion failed for s=" << solid
54  << "\n solid.shape()=" << solid.shape()
55  << std::endl;
56  }
57  return result;
58 }
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:146
static const std::vector< double > * par_
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:140
std::string toString() const
Definition: DDBase.h:82
std::map< DDSolidShape, FNPTR > convDispatch_
G4VSolid * DDG4SolidConverter::cuttubs ( const DDSolid solid)
staticprivate

Definition at line 79 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

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

Definition at line 551 of file DDG4SolidConverter.cc.

References LogDebug, DDName::name(), DDBase< N, C >::name(), DDEllipsoid::xSemiAxis(), DDEllipsoid::ySemiAxis(), DDEllipsoid::zBottomCut(), DDEllipsoid::zSemiAxis(), and DDEllipsoid::zTopCut().

Referenced by DDG4SolidConverter().

551  {
552  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: ellipsoid = " << solid;
553  DDEllipsoid sp(solid);
554  return new G4Ellipsoid(solid.name().name(),
555  sp.xSemiAxis(),
556  sp.ySemiAxis(),
557  sp.zSemiAxis(),
558  sp.zBottomCut(),
559  sp.zTopCut());
560 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
Definition: sp.h:21
const std::string & name() const
Returns the name.
Definition: DDName.cc:90
G4VSolid * DDG4SolidConverter::ellipticaltube ( const DDSolid solid)
staticprivate

Definition at line 541 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

541  {
542  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: ellipticaltube = " << solid;
543  DDEllipticalTube sp(solid);
544  return new G4EllipticalTube(solid.name().name(),
545  sp.xSemiAxis(),
546  sp.ySemiAxis(),
547  sp.zHeight());
548 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
Definition: sp.h:21
const std::string & name() const
Returns the name.
Definition: DDName.cc:90
G4VSolid * DDG4SolidConverter::intersection ( const DDSolid solid)
staticprivate

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

320  {
321  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: intersection = " << solid;
322  G4IntersectionSolid * us = 0;
323  DDBooleanSolid bs(solid);
324  if (bs) {
325  G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
326  G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
327  LogDebug("SimG4CoreGeometry") << " name:" << solid.name() << " t=" << bs.translation() << std::flush;
328  LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << std::flush;
329  std::vector<double> tdbl(9);
330  bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
331  CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
332  CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z());
333  us = new G4IntersectionSolid(solid.name().name(),
334  sa,
335  sb,
336  new CLHEP::HepRotation(temprep),
337  temphvec);
338  }
339  return us;
340 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
const std::string & name() const
Returns the name.
Definition: DDName.cc:90
G4VSolid * DDG4SolidConverter::orb ( const DDSolid solid)
staticprivate

Definition at line 534 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

534  {
535  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: orb = " << solid;
536  DDOrb sp(solid);
537  return new G4Orb(solid.name().name(), sp.radius());
538 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
Definition: DDSolid.h:371
Definition: sp.h:21
const std::string & name() const
Returns the name.
Definition: DDName.cc:90
G4VSolid * DDG4SolidConverter::para ( const DDSolid solid)
staticprivate

Definition at line 563 of file DDG4SolidConverter.cc.

References DDParallelepiped::alpha(), LogDebug, DDName::name(), DDBase< N, C >::name(), DDParallelepiped::phi(), DDParallelepiped::theta(), DDParallelepiped::xHalf(), DDParallelepiped::yHalf(), and DDParallelepiped::zHalf().

Referenced by DDG4SolidConverter().

563  {
564  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: parallelepiped = " << solid;
565  DDParallelepiped sp(solid);
566  return new G4Para(solid.name().name(),
567  sp.xHalf(),
568  sp.yHalf(),
569  sp.zHalf(),
570  sp.alpha(),
571  sp.theta(),
572  sp.phi());
573 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
signal_ phi
Definition: sp.h:180
Definition: sp.h:21
const std::string & name() const
Returns the name.
Definition: DDName.cc:90
signal_ theta
Definition: sp.h:181
G4VSolid * DDG4SolidConverter::polycone_rrz ( const DDSolid solid)
staticprivate

Definition at line 152 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

152  {
153  LogDebug("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  LogDebug("SimG4CoreGeometry") << "z=" << *i/CLHEP::cm;
161  z_p.push_back(*i); ++i;
162  LogDebug("SimG4CoreGeometry") << "rmin=" << *i/CLHEP::cm;
163  rmin_p.push_back(*i); ++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="
169  << (*par_)[1]/CLHEP::deg;
170  /*
171  std::cout << "### Polycone_RRZ: " << "sp=" << (*par_)[0]/CLHEP::deg
172  << " ep=" << (*par_)[1]/CLHEP::deg
173  << " N= " << count << std::endl;
174  for(int i=0; i<count; ++i) {
175  std::cout << " R1= " << rmin_p[i] << " R1= " << rmax_p[i] << " Z= " << z_p[i] << std::endl;
176  }
177  */
178  return new G4Polycone(solid.name().name(), (*par_)[0], (*par_)[1], // start,delta-phi
179  count, // sections
180  &(z_p[0]),
181  &(rmin_p[0]),
182  &(rmax_p[0]));
183 
184 }
#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:90
G4VSolid * DDG4SolidConverter::polycone_rz ( const DDSolid solid)
staticprivate

Definition at line 122 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

122  {
123  LogDebug("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  LogDebug("SimG4CoreGeometry") << " z=" << *i/CLHEP::cm;
130  z.push_back(*i); ++i;
131  LogDebug("SimG4CoreGeometry") << " r=" << *i/CLHEP::cm;
132  r.push_back(*i);
133  count++;
134  }
135  LogDebug("SimG4CoreGeometry") << "sp=" << (*par_)[0]/CLHEP::deg << " ep="
136  << (*par_)[1]/CLHEP::deg;
137  /*
138  std::cout << "### Polycone_RZ: " << "sp=" << (*par_)[0]/CLHEP::deg
139  << " ep=" << (*par_)[1]/CLHEP::deg
140  << " N= " << count << std::endl;
141  for(int i=0; i<count; ++i) {
142  std::cout << " R= " << r[i] << " Z= " << z[i] << std::endl;
143  }
144  */
145  return new G4Polycone(solid.name().name(), (*par_)[0], (*par_)[1], // start,delta-phi
146  count, // numRZ
147  &(r[0]),
148  &(z[0]));
149 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
const std::string & name() const
Returns the name.
Definition: DDName.cc:90
G4VSolid * DDG4SolidConverter::polyhedra_rrz ( const DDSolid solid)
staticprivate

Definition at line 208 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

208  {
209  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: phed_rrz = " << solid;
210  std::vector<double> z_p;
211  std::vector<double> rmin_p;
212  std::vector<double> rmax_p;
213  std::vector<double>::const_iterator i = par_->begin()+3;
214  int count = 0;
215  for (; i!=par_->end(); ++i) {
216  LogDebug("SimG4CoreGeometry") << "z=" << *i/CLHEP::cm;
217  z_p.push_back(*i); ++i;
218  LogDebug("SimG4CoreGeometry") << "rmin=" << *i/CLHEP::cm;
219  rmin_p.push_back(*i); ++i;
220  LogDebug("SimG4CoreGeometry") << "rmax=" << *i/CLHEP::cm;
221  rmax_p.push_back(*i);
222  count++;
223  }
224  LogDebug("SimG4CoreGeometry") << "sp=" << (*par_)[0]/CLHEP::deg << " ep="
225  << (*par_)[1]/CLHEP::deg;
226  return new G4Polyhedra(solid.name().name(), (*par_)[1], (*par_)[2], int((*par_)[0]), // start,delta-phi,sides
227  count, // sections
228  &(z_p[0]),
229  &(rmin_p[0]),
230  &(rmax_p[0]));
231 }
#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:90
G4VSolid * DDG4SolidConverter::polyhedra_rz ( const DDSolid solid)
staticprivate

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

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); ++i;
197  r.push_back(*i);
198  count++;
199  }
200 
201  return new G4Polyhedra(solid.name().name(), (*par_)[1], (*par_)[2], int((*par_)[0]),// start,delta-phi;sides
202  count, // numRZ
203  &(r[0]),
204  &(z[0]));
205 }
#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:90
G4VSolid * DDG4SolidConverter::pseudotrap ( const DDSolid s)
staticprivate

correct implementation, but fails to visualize due to G4/Iguana limitations

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

344  {
345  if(nullptr == rot) {
346  rot = new G4RotationMatrix;
347  rot->rotateX(90.*deg);
348  }
349 
350  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: pseudoTrap = " << solid;
351  G4Trd * trap = 0;
352  G4Tubs * tubs = 0;
353  G4VSolid * result = 0;
354  DDPseudoTrap pt(solid); // pt...PseudoTrap
355  double r = pt.radius();
356  bool atMinusZ = pt.atMinusZ();
357  double x = 0;
358  double h = 0;
359  bool intersec = false; // union or intersection solid
360  if (pt.atMinusZ()) {
361  x = pt.x1(); // tubs radius
362  }
363  else {
364  x = pt.x2(); // tubs radius
365  }
366  double openingAngle = 2.*asin(x/std::abs(r));
367  //trap = new G4Trd(solid.name().name(),
368  double displacement=0;
369  double startPhi=0;
370  /* calculate the displacement of the tubs w.r.t. to the trap,
371  determine the opening angle of the tubs */
372  double delta = sqrt(r*r-x*x);
373  if (r < 0 && std::abs(r) >= x) {
374  intersec = true; // intersection solid
375  h = pt.y1() < pt.y2() ? pt.y2() : pt.y1(); // tubs half height
376  h += h/20.; // enlarge a bit - for subtraction solid
377  if (atMinusZ) {
378  displacement = - pt.halfZ() - delta;
379  startPhi = 270.*deg - openingAngle/2.;
380  }
381  else {
382  displacement = pt.halfZ() + delta;
383  startPhi = 90.*deg - openingAngle/2.;
384  }
385  }
386  else if ( r > 0 && std::abs(r) >= x )
387  {
388  if (atMinusZ) {
389  displacement = - pt.halfZ() + delta;
390  startPhi = 90.*deg - openingAngle/2.;
391  h = pt.y1();
392  }
393  else {
394  displacement = pt.halfZ() - delta;
395  startPhi = 270.*deg - openingAngle/2.;
396  h = pt.y2();
397  }
398  }
399  else {
400  throw cms::Exception("DetectorDescriptionFault", "Check parameters of the PseudoTrap! name=" + pt.name().name());
401  }
402  G4ThreeVector displ(0.,0.,displacement); // displacement of the tubs w.r.t. trap
403  LogDebug("SimG4CoreGeometry") << "DDSolidConverter::pseudotrap(): displacement=" << displacement
404  << " openingAngle=" << openingAngle/deg << " x=" << x << " h=" << h;
405 
406  // Now create two solids (trd & tubs), and a boolean solid out of them
407  std::string name=pt.name().name();
408  trap = new G4Trd(name, pt.x1(), pt.x2(), pt.y1(), pt.y2(), pt.halfZ());
409  tubs = new G4Tubs(name,
410  0., // rMin
411  std::abs(r), // rMax
412  h, // half height
413  startPhi, // start angle
414  openingAngle);
415  if (intersec) {
416  result = new G4SubtractionSolid(name, trap, tubs, rot, displ);
417  }
418  else {
420  G4VSolid * tubicCap = new G4SubtractionSolid(name,
421  tubs,
422  new G4Box(name, 1.1*x, sqrt(r*r-x*x), 1.1*h),
423  0,
424  G4ThreeVector());
425  result = new G4UnionSolid(name, trap, tubicCap, rot, displ);
426 
427  // approximative implementation - also fails to visualize due to G4/Iguana limitations
428  /*
429  delete tubs;
430  tubs = new G4Tubs(name,
431  sqrt(r*r-x*x), // rMin-approximation!
432  std::abs(r), // rMax
433  h, // half height
434  startPhi, // start angle
435  openingAngle);
436  result = new G4UnionSolid(name, trap, tubs, rot, displ);
437  */
438  }
439  return result;
440 }
#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
G4VSolid * DDG4SolidConverter::reflected ( const DDSolid solid)
staticprivate

Definition at line 250 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

250  {
251  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: reflected = " << solid;
252  G4ReflectedSolid * rs = 0;
253  DDReflectionSolid rfs(solid);
254  if (rfs) {
255  rs = new G4ReflectedSolid(solid.name().name(),
256  DDG4SolidConverter().convert(rfs.unreflected()),
257  z_reflection);
258 
259  } // else ?
260  return rs;
261 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
const std::string & name() const
Returns the name.
Definition: DDName.cc:90
static G4VSolid* DDG4SolidConverter::shapeless ( const DDSolid )
staticprivate
G4VSolid * DDG4SolidConverter::sphere ( const DDSolid solid)
staticprivate

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

522  {
523  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: sphere = " << solid;
524  DDSphere sp(solid);
525  return new G4Sphere(solid.name().name(), sp.innerRadius(),
526  sp.outerRadius(),
527  sp.startPhi(),
528  sp.deltaPhi(),
529  sp.startTheta(),
530  sp.deltaTheta());
531 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
Definition: sp.h:21
const std::string & name() const
Returns the name.
Definition: DDName.cc:90
G4VSolid * DDG4SolidConverter::subtraction ( const DDSolid solid)
staticprivate

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

293  {
294  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: subtraction = " << solid;
295  G4SubtractionSolid * us = 0;
296  DDBooleanSolid bs(solid);
297  if (bs) {
298  G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
299  G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
300  LogDebug("SimG4CoreGeometry") << " name:" << solid.name() << " t=" << bs.translation() << std::flush;
301  // stringstream sst;
302  // bs.rotation().rotation()->inverse().print(sst);
303  // LogDebug("SimG4CoreGeometry") << " " << sst.str() << std::flush;
304  LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << std::flush;
305  std::vector<double> tdbl(9);
306  bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
307  CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
308  CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z());
309  us = new G4SubtractionSolid(solid.name().name(),
310  sa,
311  sb,
312  new CLHEP::HepRotation(temprep),
313  temphvec);
314  }
315  return us;
316 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
const std::string & name() const
Returns the name.
Definition: DDName.cc:90
G4VSolid * DDG4SolidConverter::torus ( const DDSolid solid)
staticprivate

Definition at line 234 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

234  {
235  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: torus = " << solid;
236  return new G4Torus(solid.name().name(), (*par_)[0], // rmin
237  (*par_)[1], // rmax
238  (*par_)[2], // Rtor
239  (*par_)[3], // phiStart
240  (*par_)[4]);// deltaPhi
241 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
const std::string & name() const
Returns the name.
Definition: DDName.cc:90
G4VSolid * DDG4SolidConverter::trap ( const DDSolid solid)
staticprivate

Definition at line 92 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter(), and pseudotrap().

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

Definition at line 443 of file DDG4SolidConverter.cc.

References funct::abs(), alpha, box(), funct::cos(), DDTruncTubs::cutAtDelta(), DDTruncTubs::cutAtStart(), DDTruncTubs::cutInside(), MuonCkfTrajectoryBuilder_cfi::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().

443  {
444  // truncated tube-section: a boolean subtraction solid:
445  // from a tube-section a box is subtracted according to the
446  // given parameters
447  LogDebug("SimG4CoreGeometry") << "MantisConverter: solidshape=" << DDSolidShapesName::name(solid.shape()) << " " << solid;
448  LogDebug("SimG4CoreGeometry") << "before";
449  DDTruncTubs tt(solid);
450  LogDebug("SimG4CoreGeometry") << "after";
451  double rIn(tt.rIn()), rOut(tt.rOut()), zHalf(tt.zHalf()),
452  startPhi(tt.startPhi()), deltaPhi(tt.deltaPhi()),
453  cutAtStart(tt.cutAtStart()), cutAtDelta(tt.cutAtDelta());
454  bool cutInside(bool(tt.cutInside()));
455  std::string name=tt.name().name();
456 
457  // check the parameters
458  if (rIn <= 0 || rOut <=0 || cutAtStart <=0 || cutAtDelta <= 0) {
459  throw cms::Exception("DetectorDescriptionFault", "TruncTubs " + std::string(tt.name().fullname()) + ": 0 <= rIn,cutAtStart,rOut,cutAtDelta,rOut violated!");
460  }
461  if (rIn >= rOut) {
462  throw cms::Exception("DetectorDescriptionFault", "TruncTubs " + std::string(tt.name().fullname()) + ": rIn<rOut violated!");
463  }
464  if (startPhi != 0.) {
465  throw cms::Exception("DetectorDescriptionFault", "TruncTubs " + std::string(tt.name().fullname()) + ": startPhi != 0 not supported!");
466  }
467  // if (cutInside != false) {
468  // throw cms::Exception("DetectorDescriptionFault", "TruncTubs " + std::string(tt.name()) + " cutInside == true not supported!");
469  // }
470 
471  startPhi=0.;
472  double r(cutAtStart), R(cutAtDelta);
473  G4VSolid * result(0);
474  G4VSolid * tubs = new G4Tubs(name,rIn,rOut,zHalf,startPhi,deltaPhi);
475  LogDebug("SimG4CoreGeometry") << "G4Tubs: " << rIn/CLHEP::cm << ' ' << rOut/CLHEP::cm << ' ' << zHalf/CLHEP::cm << ' ' << startPhi/CLHEP::deg << ' ' << deltaPhi/CLHEP::deg;
476  LogDebug("SimG4CoreGeometry") << solid;
477  // length & hight of the box
478  double boxX(30.*rOut), boxY(20.*rOut); // exaggerate dimensions - does not matter, it's subtracted!
479 
480  // width of the box > width of the tubs
481  double boxZ(1.1*zHalf);
482 
483  // angle of the box w.r.t. tubs
484  double cath = r-R*cos(deltaPhi);
485  double hypo = sqrt(r*r+R*R-2.*r*R*cos(deltaPhi));
486  double cos_alpha = cath/hypo;
487 
488  double alpha = -acos(cos_alpha);
489  LogDebug("SimG4CoreGeometry") << "cath=" << cath/CLHEP::cm;
490  LogDebug("SimG4CoreGeometry") << "hypo=" << hypo/CLHEP::cm;
491  LogDebug("SimG4CoreGeometry") << "al=" << acos(cath/hypo)/CLHEP::deg;
492  LogDebug("SimG4CoreGeometry") << "deltaPhi=" << deltaPhi/CLHEP::deg << "\n"
493  << "r=" << r/CLHEP::cm << "\n"
494  << "R=" << R/CLHEP::cm;
495 
496  LogDebug("SimG4CoreGeometry") << "alpha=" << alpha/CLHEP::deg;
497 
498  // rotationmatrix of box w.r.t. tubs
499  G4RotationMatrix * rot = new G4RotationMatrix;
500  rot->rotateZ(-alpha);
501  LogDebug("SimG4CoreGeometry") << (*rot);
502 
503  // center point of the box
504  double xBox;
505  if (!cutInside) {
506  xBox = r+boxY/sin(std::abs(alpha));
507  } else {
508  xBox = -(boxY/sin(std::abs(alpha))-r);
509  }
510 
511  G4ThreeVector trans(xBox,0.,0.);
512  LogDebug("SimG4CoreGeometry") << "trans=" << trans;
513 
514  G4VSolid * box = new G4Box(name,boxX,boxY,boxZ);
515  result = new G4SubtractionSolid(name,tubs,box,rot,trans);
516 
517  return result;
518 
519 }
#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:22
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:140
static G4VSolid * box(const DDSolid &)
G4VSolid * DDG4SolidConverter::tubs ( const DDSolid solid)
staticprivate

Definition at line 69 of file DDG4SolidConverter.cc.

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

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

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

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

265  {
266  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: unionsolid = " << solid.name();
267  G4UnionSolid * us = 0;
268  DDBooleanSolid bs(solid);
269  if (bs) {
270  LogDebug("SimG4CoreGeometry") << "SolidA=" << bs.solidA();
271  G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
272  LogDebug("SimG4CoreGeometry") << "SolidB=" << bs.solidB();
273  G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
274  LogDebug("SimG4CoreGeometry") << " name:" << solid.name() << " t=" << bs.translation() << std::flush;
275  LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << std::flush;
276  std::vector<double> tdbl(9);
277  bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
278  CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
279  CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z());
280  us = new G4UnionSolid(solid.name().name(),
281  sa,
282  sb,
283  new CLHEP::HepRotation(temprep),
284  temphvec);
285 
286  } // else?
287  return us;
288 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
const std::string & name() const
Returns the name.
Definition: DDName.cc:90

Friends And Related Function Documentation

friend class testPseudoTrap
friend

Definition at line 53 of file DDG4SolidConverter.h.

friend class testTruncTubs
friend

Definition at line 52 of file DDG4SolidConverter.h.

Member Data Documentation

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

Definition at line 48 of file DDG4SolidConverter.h.

Referenced by convert(), and DDG4SolidConverter().

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

Definition at line 47 of file DDG4SolidConverter.h.

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

G4RotationMatrix * DDG4SolidConverter::rot = 0
staticprivate

Definition at line 50 of file DDG4SolidConverter.h.

Referenced by pseudotrap(), and trunctubs().