CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
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 * 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 &)
 
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
 

Detailed Description

Definition at line 12 of file DDG4SolidConverter.h.

Member Typedef Documentation

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

Definition at line 17 of file DDG4SolidConverter.h.

Constructor & Destructor Documentation

DDG4SolidConverter::DDG4SolidConverter ( )

Definition at line 12 of file DDG4SolidConverter.cc.

References box(), cons(), ddbox, ddcons, 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().

13 {
14  // could also be done 'dynamically' from outside
15  // would then need to have a 'register' method ...
16  par_=0;
37 }
static G4VSolid * polyhedra_rrz(const DDSolid &)
static const std::vector< double > * par_
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 * reflected(const DDSolid &)
static G4VSolid * para(const DDSolid &)
static G4VSolid * pseudotrap(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 40 of file DDG4SolidConverter.cc.

40 { }

Member Function Documentation

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

Definition at line 65 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

66 {
67  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: box = " << s ;
68  return new G4Box(s.name().name(), (*par_)[0],(*par_)[1],(*par_)[2]);
69 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:82
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
G4VSolid * DDG4SolidConverter::cons ( const DDSolid s)
staticprivate

Definition at line 103 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

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

Definition at line 42 of file DDG4SolidConverter.cc.

References edm::hlt::Exception, DDSolid::parameters(), query::result, DDSolid::shape(), and DDBase< N, C >::toString().

Referenced by DDG4Builder::convertSolid(), intersection(), reflected(), subtraction(), and unionsolid().

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

Definition at line 540 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

541 {
542  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: ellipsoid = " << s ;
543  DDEllipsoid sp(s);
544  return new G4Ellipsoid(s.name().name(),
545  sp.xSemiAxis(),
546  sp.ySemiAxis(),
547  sp.zSemiAxis(),
548  sp.zBottomCut(),
549  sp.zTopCut());
550 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:82
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
G4VSolid * DDG4SolidConverter::ellipticaltube ( const DDSolid s)
staticprivate

Definition at line 529 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

530 {
531  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: ellipticaltube = " << s ;
532  DDEllipticalTube sp(s);
533  return new G4EllipticalTube(s.name().name(),
534  sp.xSemiAxis(),
535  sp.ySemiAxis(),
536  sp.zHeight());
537 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:82
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
G4VSolid * DDG4SolidConverter::intersection ( const DDSolid s)
staticprivate

Definition at line 300 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

301 {
302  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: intersection = " << s ;
303  G4IntersectionSolid * us = 0;
304  DDBooleanSolid bs(s);
305  if (bs) {
306  G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
307  G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
308  LogDebug("SimG4CoreGeometry") << " name:" << s.name() << " t=" << bs.translation() << flush;
309  LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << flush;
310  std::vector<double> tdbl(9);
311  bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
312  CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
313  CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z());
314  us = new G4IntersectionSolid(s.name().name(),
315  sa,
316  sb,
317  new CLHEP::HepRotation(temprep),
318  temphvec);
319  }
320  return us;
321 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:82
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
G4VSolid * DDG4SolidConverter::orb ( const DDSolid s)
staticprivate

Definition at line 521 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

522 {
523  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: orb = " << s ;
524  DDOrb sp(s);
525  return new G4Orb(s.name().name(), sp.radius());
526 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:82
Definition: DDSolid.h:338
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
G4VSolid * DDG4SolidConverter::para ( const DDSolid s)
staticprivate

Definition at line 553 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

554 {
555  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: parallelepiped = " << s ;
556  DDParallelepiped sp(s);
557  return new G4Para(s.name().name(),
558  sp.xHalf(),
559  sp.yHalf(),
560  sp.zHalf(),
561  sp.alpha(),
562  sp.theta(),
563  sp.phi());
564 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:82
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
G4VSolid * DDG4SolidConverter::polycone_rrz ( const DDSolid s)
staticprivate

Definition at line 139 of file DDG4SolidConverter.cc.

References prof2calltree::count, i, LogDebug, DDName::name(), DDBase< N, C >::name(), and alignCSCRings::s.

Referenced by DDG4SolidConverter().

140 {
141  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: pcon_rrz = " << s ;
142  vector<double> z_p;
143  vector<double> rmin_p;
144  vector<double> rmax_p;
145  vector<double>::const_iterator i = par_->begin()+2;
146  int count = 0;
147  for (; i!=par_->end(); ++i) {
148  LogDebug("SimG4CoreGeometry") << "z=" << *i ;
149  z_p.push_back(*i); ++i;
150  LogDebug("SimG4CoreGeometry") << "rmin=" << *i ;
151  rmin_p.push_back(*i); ++i;
152  LogDebug("SimG4CoreGeometry") << "rmax=" << *i ;
153  rmax_p.push_back(*i);
154  count++;
155  }
156  LogDebug("SimG4CoreGeometry") << "sp=" << (*par_)[0]/deg << " ep=" << (*par_)[1]/deg ;
157  return new G4Polycone(s.name().name(), (*par_)[0], (*par_)[1], // start,delta-phi
158  count, // sections
159  &(z_p[0]),
160  &(rmin_p[0]),
161  &(rmax_p[0]));
162 
163 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
static const std::vector< double > * par_
const N & name() const
Definition: DDBase.h:82
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
G4VSolid * DDG4SolidConverter::polycone_rz ( const DDSolid s)
staticprivate

Definition at line 117 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

118 {
119  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: pcon_rz = " << s ;
120  vector<double> r;
121  vector<double> z;
122  vector<double>::const_iterator i = (*par_).begin()+2;
123  int count=0;
124  for(; i!=(*par_).end(); ++i) {
125  LogDebug("SimG4CoreGeometry") << "z=" << *i ;
126  z.push_back(*i); ++i;
127  LogDebug("SimG4CoreGeometry") << " r=" << *i ;
128  r.push_back(*i);
129  count++;
130  }
131  LogDebug("SimG4CoreGeometry") << "sp=" << (*par_)[0]/deg << " ep=" << (*par_)[1]/deg ;
132  return new G4Polycone(s.name().name(), (*par_)[0], (*par_)[1], // start,delta-phi
133  count, // numRZ
134  &(r[0]),
135  &(z[0]));
136 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
const N & name() const
Definition: DDBase.h:82
double double double z
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
G4VSolid * DDG4SolidConverter::polyhedra_rrz ( const DDSolid s)
staticprivate

Definition at line 188 of file DDG4SolidConverter.cc.

References prof2calltree::count, i, LogDebug, DDName::name(), DDBase< N, C >::name(), and alignCSCRings::s.

Referenced by DDG4SolidConverter().

189 {
190  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: phed_rrz = " << s ;
191  vector<double> z_p;
192  vector<double> rmin_p;
193  vector<double> rmax_p;
194  vector<double>::const_iterator i = par_->begin()+3;
195  int count = 0;
196  for (; i!=par_->end(); ++i) {
197  LogDebug("SimG4CoreGeometry") << "z=" << *i ;
198  z_p.push_back(*i); ++i;
199  LogDebug("SimG4CoreGeometry") << "rmin=" << *i ;
200  rmin_p.push_back(*i); ++i;
201  LogDebug("SimG4CoreGeometry") << "rmax=" << *i ;
202  rmax_p.push_back(*i);
203  count++;
204  }
205  LogDebug("SimG4CoreGeometry") << "sp=" << (*par_)[0]/deg << " ep=" << (*par_)[1]/deg ;
206  return new G4Polyhedra(s.name().name(), (*par_)[1], (*par_)[2], int((*par_)[0]), // start,delta-phi,sides
207  count, // sections
208  &(z_p[0]),
209  &(rmin_p[0]),
210  &(rmax_p[0]));
211 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
static const std::vector< double > * par_
const N & name() const
Definition: DDBase.h:82
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
G4VSolid * DDG4SolidConverter::polyhedra_rz ( const DDSolid s)
staticprivate

Definition at line 167 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

168 {
169  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: phed_rz = " << s ;
170  vector<double> r;
171  vector<double> z;
172  vector<double>::const_iterator i = par_->begin()+3;
173  int count=0;
174 
175  for(; i!=par_->end(); ++i) {
176  z.push_back(*i); ++i;
177  r.push_back(*i);
178  count++;
179  }
180 
181  return new G4Polyhedra(s.name().name(), (*par_)[1], (*par_)[2], int((*par_)[0]),// start,delta-phi;sides
182  count, // numRZ
183  &(r[0]),
184  &(z[0]));
185 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
static const std::vector< double > * par_
const N & name() const
Definition: DDBase.h:82
double double double z
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
G4VSolid * DDG4SolidConverter::pseudotrap ( const DDSolid s)
staticprivate

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

Definition at line 325 of file DDG4SolidConverter.cc.

References abs, DDPseudoTrap::atMinusZ(), delta, edm::hlt::Exception, firstTime, h, DDPseudoTrap::halfZ(), LogDebug, DDName::name(), mergeVDriftHistosByStation::name, DDBase< N, C >::name(), alignCSCRings::r, DDPseudoTrap::radius(), query::result, makeMuonMisalignmentScenario::rot, alignCSCRings::s, mathSSE::sqrt(), x, DDPseudoTrap::x1(), DDPseudoTrap::x2(), DDPseudoTrap::y1(), and DDPseudoTrap::y2().

Referenced by DDG4SolidConverter().

326 {
327  static G4RotationMatrix * rot = 0;
328  static bool firstTime=true;
329  if (firstTime) {
330  firstTime=false;
331  rot = new G4RotationMatrix;
332  rot->rotateX(90.*deg);
333 
334  }
335  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: pseudoTrap = " << s ;
336  G4Trd * trap = 0;
337  G4Tubs * tubs = 0;
338  G4VSolid * result = 0;
339  DDPseudoTrap pt(s); // pt...PseudoTrap
340  double r = pt.radius();
341  bool atMinusZ = pt.atMinusZ();
342  double x = 0;
343  double h = 0;
344  bool intersec = false; // union or intersection solid
345  if (pt.atMinusZ()) {
346  x = pt.x1(); // tubs radius
347  }
348  else {
349  x = pt.x2(); // tubs radius
350  }
351  double openingAngle = 2.*asin(x/abs(r));
352  //trap = new G4Trd(s.name().name(),
353  double displacement=0;
354  double startPhi=0;
355  /* calculate the displacement of the tubs w.r.t. to the trap,
356  determine the opening angle of the tubs */
357  double delta = sqrt(r*r-x*x);
358  if (r < 0 && abs(r) >= x) {
359  intersec = true; // intersection solid
360  h = pt.y1() < pt.y2() ? pt.y2() : pt.y1(); // tubs half height
361  h += h/20.; // enlarge a bit - for subtraction solid
362  if (atMinusZ) {
363  displacement = - pt.halfZ() - delta;
364  startPhi = 270.*deg - openingAngle/2.;
365  }
366  else {
367  displacement = pt.halfZ() + delta;
368  startPhi = 90.*deg - openingAngle/2.;
369  }
370  }
371  else if ( r > 0 && abs(r) >= x )
372  {
373  if (atMinusZ) {
374  displacement = - pt.halfZ() + delta;
375  startPhi = 90.*deg - openingAngle/2.;
376  h = pt.y1();
377  }
378  else {
379  displacement = pt.halfZ() - delta;
380  startPhi = 270.*deg - openingAngle/2.;
381  h = pt.y2();
382  }
383  }
384  else {
385  throw cms::Exception("DetectorDescriptionFault", "Check parameters of the PseudoTrap! name=" + pt.name().name());
386  }
387  G4ThreeVector displ(0.,0.,displacement); // displacement of the tubs w.r.t. trap
388  LogDebug("SimG4CoreGeometry") << "DDSolidConverter::pseudotrap(): displacement=" << displacement
389  << " openingAngle=" << openingAngle/deg << " x=" << x << " h=" << h;
390 
391  // Now create two solids (trd & tubs), and a boolean solid out of them
392  string name=pt.name().name();
393  trap = new G4Trd(name, pt.x1(), pt.x2(), pt.y1(), pt.y2(), pt.halfZ());
394  tubs = new G4Tubs(name,
395  0., // rMin
396  abs(r), // rMax
397  h, // half height
398  startPhi, // start angle
399  openingAngle);
400  if (intersec) {
401  result = new G4SubtractionSolid(name, trap, tubs, rot, displ);
402  }
403  else {
405  G4VSolid * tubicCap = new G4SubtractionSolid(name,
406  tubs,
407  new G4Box(name, 1.1*x, sqrt(r*r-x*x), 1.1*h),
408  0,
409  G4ThreeVector());
410  result = new G4UnionSolid(name, trap, tubicCap, rot, displ);
411 
412  // approximative implementation - also fails to visualize due to G4/Iguana limitations
413  /*
414  delete tubs;
415  tubs = new G4Tubs(name,
416  sqrt(r*r-x*x), // rMin-approximation!
417  abs(r), // rMax
418  h, // half height
419  startPhi, // start angle
420  openingAngle);
421  result = new G4UnionSolid(name, trap, tubs, rot, displ);
422  */
423  }
424  return result;
425 }
#define LogDebug(id)
dbl * delta
Definition: mlp_gen.cc:36
static G4VSolid * trap(const DDSolid &)
static G4VSolid * tubs(const DDSolid &)
#define abs(x)
Definition: mlp_lapack.h:159
bool firstTime
Definition: QTestHandle.cc:18
T sqrt(T t)
Definition: SSEVec.h:46
tuple result
Definition: query.py:137
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
Definition: DDAxes.h:10
G4VSolid * DDG4SolidConverter::reflected ( const DDSolid s)
staticprivate

Definition at line 226 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

227 {
228  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: reflected = " << s ;
229  G4ReflectedSolid * rs = 0;
230  DDReflectionSolid rfs(s);
231  if (rfs) {
232  static /* G4Transform3D */ HepGeom::ReflectZ3D z_reflection; // = HepGeom::ReflectZ3D;
233  rs = new G4ReflectedSolid(s.name().name(),
234  DDG4SolidConverter().convert(rfs.unreflected()),
235  z_reflection);
236 
237  } // else ?
238  return rs;
239 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:82
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
static G4VSolid* DDG4SolidConverter::shapeless ( const DDSolid )
staticprivate
G4VSolid * DDG4SolidConverter::sphere ( const DDSolid s)
staticprivate

Definition at line 508 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

509 {
510  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: sphere = " << s ;
511  DDSphere sp(s);
512  return new G4Sphere(s.name().name(), sp.innerRadius(),
513  sp.outerRadius(),
514  sp.startPhi(),
515  sp.deltaPhi(),
516  sp.startTheta(),
517  sp.deltaTheta());
518 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:82
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
G4VSolid * DDG4SolidConverter::subtraction ( const DDSolid s)
staticprivate

Definition at line 272 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

273 {
274  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: subtraction = " << s ;
275  G4SubtractionSolid * us = 0;
276  DDBooleanSolid bs(s);
277  if (bs) {
278  G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
279  G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
280  LogDebug("SimG4CoreGeometry") << " name:" << s.name() << " t=" << bs.translation() << flush;
281  // stringstream sst;
282  // bs.rotation().rotation()->inverse().print(sst);
283  // LogDebug("SimG4CoreGeometry") << " " << sst.str() << flush;
284  LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << flush;
285  std::vector<double> tdbl(9);
286  bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
287  CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
288  CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z());
289  us = new G4SubtractionSolid(s.name().name(),
290  sa,
291  sb,
292  new CLHEP::HepRotation(temprep),
293  temphvec);
294  }
295  return us;
296 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:82
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
G4VSolid * DDG4SolidConverter::torus ( const DDSolid s)
staticprivate

Definition at line 214 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

215 {
216  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: torus = " << s ;
217  return new G4Torus(s.name().name(), (*par_)[0], // rmin
218  (*par_)[1], // rmax
219  (*par_)[2], // Rtor
220  (*par_)[3], // phiStart
221  (*par_)[4]);// deltaPhi
222 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:82
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
G4VSolid * DDG4SolidConverter::trap ( const DDSolid s)
staticprivate

Definition at line 85 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

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

Definition at line 428 of file DDG4SolidConverter.cc.

References abs, alpha, funct::cos(), DDTruncTubs::cutAtDelta(), DDTruncTubs::cutAtStart(), DDTruncTubs::cutInside(), SiPixelRawToDigiRegional_cfi::deltaPhi, DDTruncTubs::deltaPhi(), edm::hlt::Exception, DDName::fullname(), LogDebug, m, DDSolidShapesName::name(), DDName::name(), mergeVDriftHistosByStation::name, DDBase< N, C >::name(), dttmaxenums::R, alignCSCRings::r, query::result, DDTruncTubs::rIn(), makeMuonMisalignmentScenario::rot, DDTruncTubs::rOut(), alignCSCRings::s, DDSolid::shape(), funct::sin(), mathSSE::sqrt(), DDTruncTubs::startPhi(), groupFilesInBlocks::tt, and DDTruncTubs::zHalf().

Referenced by DDG4SolidConverter().

429 {
430  // truncated tube-section: a boolean subtraction solid:
431  // from a tube-section a box is subtracted according to the
432  // given parameters
433  LogDebug("SimG4CoreGeometry") << "MantisConverter: solidshape=" << DDSolidShapesName::name(s.shape()) << " " << s;
434  LogDebug("SimG4CoreGeometry") << "before";
435  DDTruncTubs tt(s);
436  LogDebug("SimG4CoreGeometry") << "after";
437  double rIn(tt.rIn()), rOut(tt.rOut()), zHalf(tt.zHalf()),
438  startPhi(tt.startPhi()), deltaPhi(tt.deltaPhi()),
439  cutAtStart(tt.cutAtStart()), cutAtDelta(tt.cutAtDelta());
440  bool cutInside(bool(tt.cutInside()));
441  string name=tt.name().name();
442 
443  // check the parameters
444  if (rIn <= 0 || rOut <=0 || cutAtStart <=0 || cutAtDelta <= 0) {
445  throw cms::Exception("DetectorDescriptionFault", "TruncTubs " + string(tt.name().fullname()) + ": 0 <= rIn,cutAtStart,rOut,cutAtDelta,rOut violated!");
446  }
447  if (rIn >= rOut) {
448  throw cms::Exception("DetectorDescriptionFault", "TruncTubs " + string(tt.name().fullname()) + ": rIn<rOut violated!");
449  }
450  if (startPhi != 0.) {
451  throw cms::Exception("DetectorDescriptionFault", "TruncTubs " + string(tt.name().fullname()) + ": startPhi != 0 not supported!");
452  }
453  // if (cutInside != false) {
454  // throw cms::Exception("DetectorDescriptionFault", "TruncTubs " + string(tt.name()) + " cutInside == true not supported!");
455  // }
456 
457  startPhi=0.;
458  double r(cutAtStart), R(cutAtDelta);
459  G4VSolid * result(0);
460  G4VSolid * tubs = new G4Tubs(name,rIn,rOut,zHalf,startPhi,deltaPhi);
461  LogDebug("SimG4CoreGeometry") << "G4Tubs: " << rIn << ' ' << rOut << ' ' << zHalf << ' ' << startPhi/deg << ' ' << deltaPhi/deg;
462  LogDebug("SimG4CoreGeometry") << s;
463  // length & hight of the box
464  double boxX(30.*rOut), boxY(20.*rOut); // exaggerate dimensions - does not matter, it's subtracted!
465 
466  // width of the box > width of the tubs
467  double boxZ(1.1*zHalf);
468 
469  // angle of the box w.r.t. tubs
470  double cath = r-R*cos(deltaPhi);
471  double hypo = sqrt(r*r+R*R-2.*r*R*cos(deltaPhi));
472  double cos_alpha = cath/hypo;
473 
474  double alpha = -acos(cos_alpha);
475  LogDebug("SimG4CoreGeometry") << "cath=" << cath/m;
476  LogDebug("SimG4CoreGeometry") << "hypo=" << hypo/m;
477  LogDebug("SimG4CoreGeometry") << "al=" << acos(cath/hypo)/deg;
478  LogDebug("SimG4CoreGeometry") << "deltaPhi=" << deltaPhi/deg << "\n"
479  << "r=" << r/m << "\n"
480  << "R=" << R/m;
481 
482  LogDebug("SimG4CoreGeometry") << "alpha=" << alpha/deg;
483 
484  // rotationmatrix of box w.r.t. tubs
485  G4RotationMatrix * rot = new G4RotationMatrix;
486  rot->rotateZ(-alpha);
487  LogDebug("SimG4CoreGeometry") << (*rot);
488 
489  // center point of the box
490  double xBox;
491  if (!cutInside) {
492  xBox = r+boxY/sin(abs(alpha));
493  } else {
494  xBox = -(boxY/sin(abs(alpha))-r);
495  }
496 
497  G4ThreeVector trans(xBox,0.,0.);
498  LogDebug("SimG4CoreGeometry") << "trans=" << trans;
499 
500  G4VSolid * box = new G4Box(name,boxX,boxY,boxZ);
501  result = new G4SubtractionSolid(name,tubs,box,rot,trans);
502 
503  return result;
504 
505 }
#define LogDebug(id)
float alpha
Definition: AMPTWrapper.h:95
A truncated tube section.
Definition: DDSolid.h:132
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
static G4VSolid * tubs(const DDSolid &)
#define abs(x)
Definition: mlp_lapack.h:159
static const char * name(DDSolidShape s)
Definition: DDSolidShapes.h:21
T sqrt(T t)
Definition: SSEVec.h:46
tuple result
Definition: query.py:137
Cos< T >::type cos(const T &t)
Definition: Cos.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 s)
staticprivate

Definition at line 73 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

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

Definition at line 243 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

244 {
245  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: unionsolid = " << s.name() ;
246  G4UnionSolid * us = 0;
247  DDBooleanSolid bs(s);
248  if (bs) {
249  LogDebug("SimG4CoreGeometry") << "SolidA=" << bs.solidA();
250  G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
251  LogDebug("SimG4CoreGeometry") << "SolidB=" << bs.solidB();
252  G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
253  LogDebug("SimG4CoreGeometry") << " name:" << s.name() << " t=" << bs.translation() << flush;
254  LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << flush;
255  std::vector<double> tdbl(9);
256  bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
257  CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
258  CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z());
259  us = new G4UnionSolid(s.name().name(),
260  sa,
261  sb,
262  new CLHEP::HepRotation(temprep),
263  temphvec);
264 
265  } // else?
266  return us;
267 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:82
const std::string & name() const
Returns the name.
Definition: DDName.cc:87

Member Data Documentation

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

Definition at line 44 of file DDG4SolidConverter.h.

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

Definition at line 43 of file DDG4SolidConverter.h.