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:147
static const std::vector< double > * par_
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:141
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 599 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().

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

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

Referenced by DDG4SolidConverter().

589  {
590  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: ellipticaltube = " << solid;
591  DDEllipticalTube sp(solid);
592  return new G4EllipticalTube(solid.name().name(),
593  sp.xSemiAxis(),
594  sp.ySemiAxis(),
595  sp.zHeight());
596 }
#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::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 = 0;
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 385 of file DDG4SolidConverter.cc.

Referenced by DDG4SolidConverter(), and intersection().

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

Definition at line 582 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

582  {
583  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: orb = " << solid;
584  DDOrb sp(solid);
585  return new G4Orb(solid.name().name(), sp.radius());
586 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
Definition: DDSolid.h:395
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 611 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().

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

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

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

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