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 * extrudedpolygon (const DDSolid &)
 
static G4VSolid * intersection (const DDSolid &)
 
static G4VSolid * multiunion (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, ddextrudedpolygon, ddintersection, ddmultiunion, ddorb, ddparallelepiped, ddpolycone_rrz, ddpolycone_rz, ddpolyhedra_rrz, ddpolyhedra_rz, ddpseudotrap, ddreflected, ddsphere, ddsubtraction, ddtorus, ddtrap, ddtrunctubs, ddtubs, ddunion, ellipsoid(), ellipticaltube(), extrudedpolygon(), intersection(), multiunion(), 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 ...
39 }
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 * multiunion(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 41 of file DDG4SolidConverter.cc.

41 {}

Member Function Documentation

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

Definition at line 64 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter(), and trunctubs().

64  {
65  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: box = " << solid;
66  return new G4Box(solid.name().name(), (*par_)[0],(*par_)[1],(*par_)[2]);
67 }
#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 111 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

111  {
112  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: cons = " << solid;
113  return new G4Cons(solid.name().name(), (*par_)[1], // rmin -z
114  (*par_)[2], // rmax -z
115  (*par_)[3], // rmin +z
116  (*par_)[4], // rmax +z
117  (*par_)[0], // zHalf
118  (*par_)[5], // phistart
119  (*par_)[6]); // deltaphi
120 }
#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 43 of file DDG4SolidConverter.cc.

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

Referenced by DDG4Builder::convertSolid().

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

Definition at line 81 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

81  {
82  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: tubs = " << solid;
83  return new G4CutTubs(solid.name().name(), (*par_)[1], // rmin
84  (*par_)[2], // rmax
85  (*par_)[0], // dzHalf
86  (*par_)[3], // phiStart
87  (*par_)[4], // deltaPhi
88  G4ThreeVector((*par_)[5],(*par_)[6],(*par_)[7]),
89  G4ThreeVector((*par_)[8],(*par_)[9],(*par_)[10]));
90 }
#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 598 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().

598  {
599  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: ellipsoid = " << solid;
600  DDEllipsoid sp(solid);
601  return new G4Ellipsoid(solid.name().name(),
602  sp.xSemiAxis(),
603  sp.ySemiAxis(),
604  sp.zSemiAxis(),
605  sp.zBottomCut(),
606  sp.zTopCut());
607 }
#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::ellipticaltube ( const DDSolid solid)
staticprivate

Definition at line 588 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

588  {
589  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: ellipticaltube = " << solid;
590  DDEllipticalTube sp(solid);
591  return new G4EllipticalTube(solid.name().name(),
592  sp.xSemiAxis(),
593  sp.ySemiAxis(),
594  sp.zHeight());
595 }
#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::extrudedpolygon ( const DDSolid solid)
staticprivate

Definition at line 236 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

236  {
237  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: extr_pgon = " << solid;
238  std::vector<double> x = static_cast<DDExtrudedPolygon>(solid).xVec();
239  std::vector<double> y = static_cast<DDExtrudedPolygon>(solid).yVec();
240  std::vector<double> z = static_cast<DDExtrudedPolygon>(solid).zVec();
241  std::vector<double> zx = static_cast<DDExtrudedPolygon>(solid).zxVec();
242  std::vector<double> zy = static_cast<DDExtrudedPolygon>(solid).zyVec();
243  std::vector<double> zs = static_cast<DDExtrudedPolygon>(solid).zscaleVec();
244 
245  std::vector<G4TwoVector> polygon;
246  std::vector<G4ExtrudedSolid::ZSection> zsections;
247  for( unsigned int it = 0; it < x.size(); ++it )
248  polygon.emplace_back( x[it], y[it] );
249  for( unsigned int it = 0; it < z.size(); ++it )
250  zsections.emplace_back( z[it], G4TwoVector(zx[it], zy[it]), zs[it] );
251  return new G4ExtrudedSolid( solid.name().name(), polygon, zsections );
252 }
#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::intersection ( const DDSolid solid)
staticprivate

Definition at line 341 of file DDG4SolidConverter.cc.

References DDG4SolidConverter(), mps_fire::i, LogDebug, AnalysisDataFormats_SUSYBSMObjects::ms, multiunion(), DDName::name(), DDBase< N, C >::name(), DDRotation::rotation(), DDBooleanSolid::rotation(), DDBooleanSolid::solidA(), DDBooleanSolid::solidB(), DDMultiUnionSolid::solids(), and DDBooleanSolid::translation().

Referenced by DDG4SolidConverter().

341  {
342  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: intersection = " << solid;
343  G4IntersectionSolid * us = nullptr;
344  DDBooleanSolid bs(solid);
345  if (bs) {
346  G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
347  G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
348  LogDebug("SimG4CoreGeometry") << " name:" << solid.name() << " t=" << bs.translation() << std::flush;
349  LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << std::flush;
350  std::vector<double> tdbl(9);
351  bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
352  CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
353  CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z());
354  us = new G4IntersectionSolid(solid.name().name(),
355  sa,
356  sb,
357  new CLHEP::HepRotation(temprep),
358  temphvec);
359  }
360  return us;
361 }
#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::multiunion ( const DDSolid solid)
staticprivate

Definition at line 384 of file DDG4SolidConverter.cc.

Referenced by DDG4SolidConverter(), and intersection().

384  {
385  return nullptr;
386 }
G4VSolid * DDG4SolidConverter::orb ( const DDSolid solid)
staticprivate

Definition at line 581 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

581  {
582  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: orb = " << solid;
583  DDOrb sp(solid);
584  return new G4Orb(solid.name().name(), sp.radius());
585 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
Definition: DDSolid.h:403
const std::string & name() const
Returns the name.
Definition: DDName.cc:90
G4VSolid * DDG4SolidConverter::para ( const DDSolid solid)
staticprivate

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

610  {
611  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: parallelepiped = " << solid;
612  DDParallelepiped sp(solid);
613  return new G4Para(solid.name().name(),
614  sp.xHalf(),
615  sp.yHalf(),
616  sp.zHalf(),
617  sp.alpha(),
618  sp.theta(),
619  sp.phi());
620 }
#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::polycone_rrz ( const DDSolid solid)
staticprivate

Definition at line 154 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

154  {
155  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: pcon_rrz = " << solid;
156  std::vector<double> z_p;
157  std::vector<double> rmin_p;
158  std::vector<double> rmax_p;
159  std::vector<double>::const_iterator i = par_->begin()+2;
160  int count = 0;
161  for (; i!=par_->end(); ++i) {
162  LogDebug("SimG4CoreGeometry") << "z=" << *i/CLHEP::cm;
163  z_p.push_back(*i); ++i;
164  LogDebug("SimG4CoreGeometry") << "rmin=" << *i/CLHEP::cm;
165  rmin_p.push_back(*i); ++i;
166  LogDebug("SimG4CoreGeometry") << "rmax=" << *i/CLHEP::cm;
167  rmax_p.push_back(*i);
168  count++;
169  }
170  LogDebug("SimG4CoreGeometry") << "sp=" << (*par_)[0]/CLHEP::deg << " ep="
171  << (*par_)[1]/CLHEP::deg;
172  /*
173  std::cout << "### Polycone_RRZ: " << "sp=" << (*par_)[0]/CLHEP::deg
174  << " ep=" << (*par_)[1]/CLHEP::deg
175  << " N= " << count << std::endl;
176  for(int i=0; i<count; ++i) {
177  std::cout << " R1= " << rmin_p[i] << " R1= " << rmax_p[i] << " Z= " << z_p[i] << std::endl;
178  }
179  */
180  return new G4Polycone(solid.name().name(), (*par_)[0], (*par_)[1], // start,delta-phi
181  count, // sections
182  &(z_p[0]),
183  &(rmin_p[0]),
184  &(rmax_p[0]));
185 
186 }
#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 124 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

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

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

Referenced by DDG4SolidConverter().

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

190  {
191  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: phed_rz = " << solid;
192  std::vector<double> r;
193  std::vector<double> z;
194  std::vector<double>::const_iterator i = par_->begin()+3;
195  int count=0;
196 
197  for(; i!=par_->end(); ++i) {
198  z.push_back(*i); ++i;
199  r.push_back(*i);
200  count++;
201  }
202 
203  return new G4Polyhedra(solid.name().name(), (*par_)[1], (*par_)[2], int((*par_)[0]),// start,delta-phi;sides
204  count, // numRZ
205  &(r[0]),
206  &(z[0]));
207 }
#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 391 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().

391  {
392  if(nullptr == rot) {
393  rot = new G4RotationMatrix;
394  rot->rotateX(90.*deg);
395  }
396 
397  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: pseudoTrap = " << solid;
398  G4Trd * trap = nullptr;
399  G4Tubs * tubs = nullptr;
400  G4VSolid * result = nullptr;
401  DDPseudoTrap pt(solid); // pt...PseudoTrap
402  double r = pt.radius();
403  bool atMinusZ = pt.atMinusZ();
404  double x = 0;
405  double h = 0;
406  bool intersec = false; // union or intersection solid
407  if (pt.atMinusZ()) {
408  x = pt.x1(); // tubs radius
409  }
410  else {
411  x = pt.x2(); // tubs radius
412  }
413  double openingAngle = 2.*asin(x/std::abs(r));
414  //trap = new G4Trd(solid.name().name(),
415  double displacement=0;
416  double startPhi=0;
417  /* calculate the displacement of the tubs w.r.t. to the trap,
418  determine the opening angle of the tubs */
419  double delta = sqrt(r*r-x*x);
420  if (r < 0 && std::abs(r) >= x) {
421  intersec = true; // intersection solid
422  h = pt.y1() < pt.y2() ? pt.y2() : pt.y1(); // tubs half height
423  h += h/20.; // enlarge a bit - for subtraction solid
424  if (atMinusZ) {
425  displacement = - pt.halfZ() - delta;
426  startPhi = 270.*deg - openingAngle/2.;
427  }
428  else {
429  displacement = pt.halfZ() + delta;
430  startPhi = 90.*deg - openingAngle/2.;
431  }
432  }
433  else if ( r > 0 && std::abs(r) >= x )
434  {
435  if (atMinusZ) {
436  displacement = - pt.halfZ() + delta;
437  startPhi = 90.*deg - openingAngle/2.;
438  h = pt.y1();
439  }
440  else {
441  displacement = pt.halfZ() - delta;
442  startPhi = 270.*deg - openingAngle/2.;
443  h = pt.y2();
444  }
445  }
446  else {
447  throw cms::Exception("DetectorDescriptionFault", "Check parameters of the PseudoTrap! name=" + pt.name().name());
448  }
449  G4ThreeVector displ(0.,0.,displacement); // displacement of the tubs w.r.t. trap
450  LogDebug("SimG4CoreGeometry") << "DDSolidConverter::pseudotrap(): displacement=" << displacement
451  << " openingAngle=" << openingAngle/deg << " x=" << x << " h=" << h;
452 
453  // Now create two solids (trd & tubs), and a boolean solid out of them
454  std::string name=pt.name().name();
455  trap = new G4Trd(name, pt.x1(), pt.x2(), pt.y1(), pt.y2(), pt.halfZ());
456  tubs = new G4Tubs(name,
457  0., // rMin
458  std::abs(r), // rMax
459  h, // half height
460  startPhi, // start angle
461  openingAngle);
462  if (intersec) {
463  result = new G4SubtractionSolid(name, trap, tubs, rot, displ);
464  }
465  else {
467  G4VSolid * tubicCap = new G4SubtractionSolid(name,
468  tubs,
469  new G4Box(name, 1.1*x, sqrt(r*r-x*x), 1.1*h),
470  nullptr,
471  G4ThreeVector());
472  result = new G4UnionSolid(name, trap, tubicCap, rot, displ);
473 
474  // approximative implementation - also fails to visualize due to G4/Iguana limitations
475  /*
476  delete tubs;
477  tubs = new G4Tubs(name,
478  sqrt(r*r-x*x), // rMin-approximation!
479  std::abs(r), // rMax
480  h, // half height
481  startPhi, // start angle
482  openingAngle);
483  result = new G4UnionSolid(name, trap, tubs, rot, displ);
484  */
485  }
486  return result;
487 }
#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 271 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

271  {
272  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: reflected = " << solid;
273  G4ReflectedSolid * rs = nullptr;
274  DDReflectionSolid rfs(solid);
275  if (rfs) {
276  rs = new G4ReflectedSolid(solid.name().name(),
277  DDG4SolidConverter().convert(rfs.unreflected()),
278  z_reflection);
279 
280  } // else ?
281  return rs;
282 }
#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 569 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().

569  {
570  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: sphere = " << solid;
571  DDSphere sp(solid);
572  return new G4Sphere(solid.name().name(), sp.innerRadius(),
573  sp.outerRadius(),
574  sp.startPhi(),
575  sp.deltaPhi(),
576  sp.startTheta(),
577  sp.deltaTheta());
578 }
#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::subtraction ( const DDSolid solid)
staticprivate

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

314  {
315  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: subtraction = " << solid;
316  G4SubtractionSolid * us = nullptr;
317  DDBooleanSolid bs(solid);
318  if (bs) {
319  G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
320  G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
321  LogDebug("SimG4CoreGeometry") << " name:" << solid.name() << " t=" << bs.translation() << std::flush;
322  // stringstream sst;
323  // bs.rotation().rotation()->inverse().print(sst);
324  // LogDebug("SimG4CoreGeometry") << " " << sst.str() << std::flush;
325  LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << std::flush;
326  std::vector<double> tdbl(9);
327  bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
328  CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
329  CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z());
330  us = new G4SubtractionSolid(solid.name().name(),
331  sa,
332  sb,
333  new CLHEP::HepRotation(temprep),
334  temphvec);
335  }
336  return us;
337 }
#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 255 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

255  {
256  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: torus = " << solid;
257  return new G4Torus(solid.name().name(), (*par_)[0], // rmin
258  (*par_)[1], // rmax
259  (*par_)[2], // Rtor
260  (*par_)[3], // phiStart
261  (*par_)[4]);// deltaPhi
262 }
#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 94 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter(), and pseudotrap().

94  {
95  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: trap = " << solid;
96  return new G4Trap(solid.name().name(), (*par_)[0], // pDz
97  (*par_)[1], // theta
98  (*par_)[2], // phi
99  (*par_)[3], // y1
100  (*par_)[4], // x1
101  (*par_)[5], // x2
102  (*par_)[6], // alpha1
103  (*par_)[7], // y2
104  (*par_)[8], // x3
105  (*par_)[9], // x4
106  (*par_)[10]);// alpha2
107 }
#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 490 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().

490  {
491  // truncated tube-section: a boolean subtraction solid:
492  // from a tube-section a box is subtracted according to the
493  // given parameters
494  LogDebug("SimG4CoreGeometry") << "MantisConverter: solidshape=" << DDSolidShapesName::name(solid.shape()) << " " << solid;
495  LogDebug("SimG4CoreGeometry") << "before";
496  DDTruncTubs tt(solid);
497  LogDebug("SimG4CoreGeometry") << "after";
498  double rIn(tt.rIn()), rOut(tt.rOut()), zHalf(tt.zHalf()),
499  startPhi(tt.startPhi()), deltaPhi(tt.deltaPhi()),
500  cutAtStart(tt.cutAtStart()), cutAtDelta(tt.cutAtDelta());
501  bool cutInside(bool(tt.cutInside()));
502  std::string name=tt.name().name();
503 
504  // check the parameters
505  if (rIn <= 0 || rOut <=0 || cutAtStart <=0 || cutAtDelta <= 0) {
506  throw cms::Exception("DetectorDescriptionFault", "TruncTubs " + std::string(tt.name().fullname()) + ": 0 <= rIn,cutAtStart,rOut,cutAtDelta,rOut violated!");
507  }
508  if (rIn >= rOut) {
509  throw cms::Exception("DetectorDescriptionFault", "TruncTubs " + std::string(tt.name().fullname()) + ": rIn<rOut violated!");
510  }
511  if (startPhi != 0.) {
512  throw cms::Exception("DetectorDescriptionFault", "TruncTubs " + std::string(tt.name().fullname()) + ": startPhi != 0 not supported!");
513  }
514  // if (cutInside != false) {
515  // throw cms::Exception("DetectorDescriptionFault", "TruncTubs " + std::string(tt.name()) + " cutInside == true not supported!");
516  // }
517 
518  startPhi=0.;
519  double r(cutAtStart), R(cutAtDelta);
520  G4VSolid * result(nullptr);
521  G4VSolid * tubs = new G4Tubs(name,rIn,rOut,zHalf,startPhi,deltaPhi);
522  LogDebug("SimG4CoreGeometry") << "G4Tubs: " << rIn/CLHEP::cm << ' ' << rOut/CLHEP::cm << ' ' << zHalf/CLHEP::cm << ' ' << startPhi/CLHEP::deg << ' ' << deltaPhi/CLHEP::deg;
523  LogDebug("SimG4CoreGeometry") << solid;
524  // length & hight of the box
525  double boxX(30.*rOut), boxY(20.*rOut); // exaggerate dimensions - does not matter, it's subtracted!
526 
527  // width of the box > width of the tubs
528  double boxZ(1.1*zHalf);
529 
530  // angle of the box w.r.t. tubs
531  double cath = r-R*cos(deltaPhi);
532  double hypo = sqrt(r*r+R*R-2.*r*R*cos(deltaPhi));
533  double cos_alpha = cath/hypo;
534 
535  double alpha = -acos(cos_alpha);
536  LogDebug("SimG4CoreGeometry") << "cath=" << cath/CLHEP::cm;
537  LogDebug("SimG4CoreGeometry") << "hypo=" << hypo/CLHEP::cm;
538  LogDebug("SimG4CoreGeometry") << "al=" << acos(cath/hypo)/CLHEP::deg;
539  LogDebug("SimG4CoreGeometry") << "deltaPhi=" << deltaPhi/CLHEP::deg << "\n"
540  << "r=" << r/CLHEP::cm << "\n"
541  << "R=" << R/CLHEP::cm;
542 
543  LogDebug("SimG4CoreGeometry") << "alpha=" << alpha/CLHEP::deg;
544 
545  // rotationmatrix of box w.r.t. tubs
546  G4RotationMatrix * rot = new G4RotationMatrix;
547  rot->rotateZ(-alpha);
548  LogDebug("SimG4CoreGeometry") << (*rot);
549 
550  // center point of the box
551  double xBox;
552  if (!cutInside) {
553  xBox = r+boxY/sin(std::abs(alpha));
554  } else {
555  xBox = -(boxY/sin(std::abs(alpha))-r);
556  }
557 
558  G4ThreeVector trans(xBox,0.,0.);
559  LogDebug("SimG4CoreGeometry") << "trans=" << trans;
560 
561  G4VSolid * box = new G4Box(name,boxX,boxY,boxZ);
562  result = new G4SubtractionSolid(name,tubs,box,rot,trans);
563 
564  return result;
565 
566 }
#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:144
static G4VSolid * box(const DDSolid &)
G4VSolid * DDG4SolidConverter::tubs ( const DDSolid solid)
staticprivate

Definition at line 71 of file DDG4SolidConverter.cc.

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

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

71  {
72  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: tubs = " << solid;
73  return new G4Tubs(solid.name().name(), (*par_)[1], // rmin
74  (*par_)[2], // rmax
75  (*par_)[0], // dzHalf
76  (*par_)[3], // phiStart
77  (*par_)[4]);// deltaPhi
78 }
#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 286 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().

286  {
287  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: unionsolid = " << solid.name();
288  G4UnionSolid * us = nullptr;
289  DDBooleanSolid bs(solid);
290  if (bs) {
291  LogDebug("SimG4CoreGeometry") << "SolidA=" << bs.solidA();
292  G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
293  LogDebug("SimG4CoreGeometry") << "SolidB=" << bs.solidB();
294  G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
295  LogDebug("SimG4CoreGeometry") << " name:" << solid.name() << " t=" << bs.translation() << std::flush;
296  LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << std::flush;
297  std::vector<double> tdbl(9);
298  bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
299  CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
300  CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z());
301  us = new G4UnionSolid(solid.name().name(),
302  sa,
303  sb,
304  new CLHEP::HepRotation(temprep),
305  temphvec);
306 
307  } // else?
308  return us;
309 }
#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 55 of file DDG4SolidConverter.h.

friend class testTruncTubs
friend

Definition at line 54 of file DDG4SolidConverter.h.

Member Data Documentation

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

Definition at line 50 of file DDG4SolidConverter.h.

Referenced by convert(), and DDG4SolidConverter().

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

Definition at line 49 of file DDG4SolidConverter.h.

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

G4RotationMatrix * DDG4SolidConverter::rot = 0
staticprivate

Definition at line 52 of file DDG4SolidConverter.h.

Referenced by pseudotrap(), and trunctubs().