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

14 {
15  // could also be done 'dynamically' from outside
16  // would then need to have a 'register' method ...
17  par_=0;
38 }
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 41 of file DDG4SolidConverter.cc.

41 { }

Member Function Documentation

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

Definition at line 66 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

67 {
68  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: box = " << s ;
69  return new G4Box(s.name().name(), (*par_)[0],(*par_)[1],(*par_)[2]);
70 }
#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 104 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

105 {
106  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: cons = " << s ;
107  return new G4Cons(s.name().name(), (*par_)[1], // rmin -z
108  (*par_)[2], // rmax -z
109  (*par_)[3], // rmin +z
110  (*par_)[4], // rmax +z
111  (*par_)[0], // zHalf
112  (*par_)[5], // phistart
113  (*par_)[6]); // deltaphi
114 }
#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 43 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().

44 {
45  if ( !s ) {
46  edm::LogError("SimG4CoreGeometry") <<" DDG4SolidConverter::convert(..) found an undefined DDSolid " << s.toString();
47  throw cms::Exception("SimG4CoreGeometry", "DDG4SolidConverter::convert(..) found an undefined DDSolid " + s.toString());
48  }
49  G4VSolid * result = 0;
50  par_ = &(s.parameters());
51  map<DDSolidShape,FNPTR>::iterator it = convDispatch_.find(s.shape());
52  if (it != convDispatch_.end()) {
53  result = it->second(s);
54  }
55  else {
56  throw cms::Exception("DetectorDescriptionFault")
57  << "DDG4SolidConverter::convert: conversion failed for s=" << s
58  << "\n solid.shape()=" << s.shape()
59  << std::endl;
60  }
61  return result;
62 }
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 545 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().

546 {
547  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: ellipsoid = " << s ;
548  DDEllipsoid sp(s);
549  return new G4Ellipsoid(s.name().name(),
550  sp.xSemiAxis(),
551  sp.ySemiAxis(),
552  sp.zSemiAxis(),
553  sp.zBottomCut(),
554  sp.zTopCut());
555 }
#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 534 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

535 {
536  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: ellipticaltube = " << s ;
537  DDEllipticalTube sp(s);
538  return new G4EllipticalTube(s.name().name(),
539  sp.xSemiAxis(),
540  sp.ySemiAxis(),
541  sp.zHeight());
542 }
#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 305 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().

306 {
307  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: intersection = " << s ;
308  G4IntersectionSolid * us = 0;
309  DDBooleanSolid bs(s);
310  if (bs) {
311  G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
312  G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
313  LogDebug("SimG4CoreGeometry") << " name:" << s.name() << " t=" << bs.translation() << flush;
314  LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << flush;
315  std::vector<double> tdbl(9);
316  bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
317  CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
318  CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z());
319  us = new G4IntersectionSolid(s.name().name(),
320  sa,
321  sb,
322  new CLHEP::HepRotation(temprep),
323  temphvec);
324  }
325  return us;
326 }
#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 526 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

527 {
528  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: orb = " << s ;
529  DDOrb sp(s);
530  return new G4Orb(s.name().name(), sp.radius());
531 }
#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 558 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().

559 {
560  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: parallelepiped = " << s ;
561  DDParallelepiped sp(s);
562  return new G4Para(s.name().name(),
563  sp.xHalf(),
564  sp.yHalf(),
565  sp.zHalf(),
566  sp.alpha(),
567  sp.theta(),
568  sp.phi());
569 }
#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 140 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

141 {
142  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: pcon_rrz = " << s ;
143  vector<double> z_p;
144  vector<double> rmin_p;
145  vector<double> rmax_p;
146  vector<double>::const_iterator i = par_->begin()+2;
147  int count = 0;
148  for (; i!=par_->end(); ++i) {
149  LogDebug("SimG4CoreGeometry") << "z=" << *i ;
150  z_p.push_back(*i); ++i;
151  LogDebug("SimG4CoreGeometry") << "rmin=" << *i ;
152  rmin_p.push_back(*i); ++i;
153  LogDebug("SimG4CoreGeometry") << "rmax=" << *i ;
154  rmax_p.push_back(*i);
155  count++;
156  }
157  LogDebug("SimG4CoreGeometry") << "sp=" << (*par_)[0]/deg << " ep=" << (*par_)[1]/deg ;
158  return new G4Polycone(s.name().name(), (*par_)[0], (*par_)[1], // start,delta-phi
159  count, // sections
160  &(z_p[0]),
161  &(rmin_p[0]),
162  &(rmax_p[0]));
163 
164 }
#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 118 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().

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

Definition at line 189 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

190 {
191  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: phed_rrz = " << s ;
192  vector<double> z_p;
193  vector<double> rmin_p;
194  vector<double> rmax_p;
195  vector<double>::const_iterator i = par_->begin()+3;
196  int count = 0;
197  for (; i!=par_->end(); ++i) {
198  LogDebug("SimG4CoreGeometry") << "z=" << *i ;
199  z_p.push_back(*i); ++i;
200  LogDebug("SimG4CoreGeometry") << "rmin=" << *i ;
201  rmin_p.push_back(*i); ++i;
202  LogDebug("SimG4CoreGeometry") << "rmax=" << *i ;
203  rmax_p.push_back(*i);
204  count++;
205  }
206  LogDebug("SimG4CoreGeometry") << "sp=" << (*par_)[0]/deg << " ep=" << (*par_)[1]/deg ;
207  return new G4Polyhedra(s.name().name(), (*par_)[1], (*par_)[2], int((*par_)[0]), // start,delta-phi,sides
208  count, // sections
209  &(z_p[0]),
210  &(rmin_p[0]),
211  &(rmax_p[0]));
212 }
#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 168 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().

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

References funct::abs(), DDPseudoTrap::atMinusZ(), delta, edm::hlt::Exception, firstTime, h, DDPseudoTrap::halfZ(), LogDebug, DDName::name(), mergeVDriftHistosByStation::name, DDBase< N, C >::name(), RecoTauCleanerPlugins::pt, 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().

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

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

Referenced by DDG4SolidConverter().

233 {
234  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: reflected = " << s ;
235  G4ReflectedSolid * rs = 0;
236  DDReflectionSolid rfs(s);
237  if (rfs) {
238  rs = new G4ReflectedSolid(s.name().name(),
239  DDG4SolidConverter().convert(rfs.unreflected()),
240  z_reflection);
241 
242  } // else ?
243  return rs;
244 }
#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 513 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().

514 {
515  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: sphere = " << s ;
516  DDSphere sp(s);
517  return new G4Sphere(s.name().name(), sp.innerRadius(),
518  sp.outerRadius(),
519  sp.startPhi(),
520  sp.deltaPhi(),
521  sp.startTheta(),
522  sp.deltaTheta());
523 }
#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 277 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().

278 {
279  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: subtraction = " << s ;
280  G4SubtractionSolid * us = 0;
281  DDBooleanSolid bs(s);
282  if (bs) {
283  G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
284  G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
285  LogDebug("SimG4CoreGeometry") << " name:" << s.name() << " t=" << bs.translation() << flush;
286  // stringstream sst;
287  // bs.rotation().rotation()->inverse().print(sst);
288  // LogDebug("SimG4CoreGeometry") << " " << sst.str() << flush;
289  LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << flush;
290  std::vector<double> tdbl(9);
291  bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
292  CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
293  CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z());
294  us = new G4SubtractionSolid(s.name().name(),
295  sa,
296  sb,
297  new CLHEP::HepRotation(temprep),
298  temphvec);
299  }
300  return us;
301 }
#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 215 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

216 {
217  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: torus = " << s ;
218  return new G4Torus(s.name().name(), (*par_)[0], // rmin
219  (*par_)[1], // rmax
220  (*par_)[2], // Rtor
221  (*par_)[3], // phiStart
222  (*par_)[4]);// deltaPhi
223 }
#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 86 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

87 {
88  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: trap = " << s ;
89  return new G4Trap(s.name().name(), (*par_)[0], // pDz
90  (*par_)[1], // theta
91  (*par_)[2], // phi
92  (*par_)[3], // y1
93  (*par_)[4], // x1
94  (*par_)[5], // x2
95  (*par_)[6], // alpha1
96  (*par_)[7], // y2
97  (*par_)[8], // x3
98  (*par_)[9], // x4
99  (*par_)[10]);// alpha2
100 }
#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 433 of file DDG4SolidConverter.cc.

References funct::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().

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

Definition at line 74 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

75 {
76  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: tubs = " << s ;
77  return new G4Tubs(s.name().name(), (*par_)[1], // rmin
78  (*par_)[2], // rmax
79  (*par_)[0], // dzHalf
80  (*par_)[3], // phiStart
81  (*par_)[4]);// deltaPhi
82 }
#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 248 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().

249 {
250  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: unionsolid = " << s.name() ;
251  G4UnionSolid * us = 0;
252  DDBooleanSolid bs(s);
253  if (bs) {
254  LogDebug("SimG4CoreGeometry") << "SolidA=" << bs.solidA();
255  G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
256  LogDebug("SimG4CoreGeometry") << "SolidB=" << bs.solidB();
257  G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
258  LogDebug("SimG4CoreGeometry") << " name:" << s.name() << " t=" << bs.translation() << flush;
259  LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << flush;
260  std::vector<double> tdbl(9);
261  bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
262  CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
263  CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z());
264  us = new G4UnionSolid(s.name().name(),
265  sa,
266  sb,
267  new CLHEP::HepRotation(temprep),
268  temphvec);
269 
270  } // else?
271  return us;
272 }
#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.