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

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

43 { }

Member Function Documentation

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

Definition at line 68 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

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

Definition at line 106 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

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

Definition at line 45 of file DDG4SolidConverter.cc.

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

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

46 {
47  if ( !s ) {
48  edm::LogError("SimG4CoreGeometry") <<" DDG4SolidConverter::convert(..) found an undefined DDSolid " << s.toString();
49  throw cms::Exception("SimG4CoreGeometry", "DDG4SolidConverter::convert(..) found an undefined DDSolid " + s.toString());
50  }
51  G4VSolid * result = 0;
52  par_ = &(s.parameters());
53  map<DDSolidShape,FNPTR>::iterator it = convDispatch_.find(s.shape());
54  if (it != convDispatch_.end()) {
55  result = it->second(s);
56  }
57  else {
58  ostringstream o;
59  o << "DDG4SolidConverter::convert: conversion failed for s=" << s << endl;
60  o << " solid.shape()=" << s.shape() << endl;
61  throw DDException(o.str());
62  }
63  return result;
64 }
const std::vector< double > & parameters() const
Don&#39;t use (only meant to be used by DDbox(), DDtub(), ...)
Definition: DDSolid.cc:153
static const std::vector< double > * par_
DDSolidShape shape() const
The type of the solid.
Definition: DDSolid.cc:147
An exception for DDD errors.
Definition: DDException.h:23
tuple result
Definition: query.py:137
std::string toString() const
Definition: DDBase.h:92
std::map< DDSolidShape, FNPTR > convDispatch_
G4VSolid * DDG4SolidConverter::ellipsoid ( const DDSolid s)
staticprivate

Definition at line 552 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

553 {
554  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: ellipsoid = " << s ;
555  DDEllipsoid sp(s);
556  return new G4Ellipsoid(s.name().name(),
557  sp.xSemiAxis(),
558  sp.ySemiAxis(),
559  sp.zSemiAxis(),
560  sp.zBottomCut(),
561  sp.zTopCut());
562 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:88
string s
Definition: asciidump.py:422
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
G4VSolid * DDG4SolidConverter::ellipticaltube ( const DDSolid s)
staticprivate

Definition at line 541 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

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

Definition at line 308 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

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

Definition at line 533 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

534 {
535  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: orb = " << s ;
536  DDOrb sp(s);
537  return new G4Orb(s.name().name(), sp.radius());
538 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:88
Definition: DDSolid.h:363
string s
Definition: asciidump.py:422
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
G4VSolid * DDG4SolidConverter::para ( const DDSolid s)
staticprivate

Definition at line 565 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

566 {
567  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: parallelepiped = " << s ;
568  DDParallelepiped sp(s);
569  return new G4Para(s.name().name(),
570  sp.xHalf(),
571  sp.yHalf(),
572  sp.zHalf(),
573  sp.alpha(),
574  sp.theta(),
575  sp.phi());
576 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:88
string s
Definition: asciidump.py:422
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
G4VSolid * DDG4SolidConverter::polycone_rrz ( const DDSolid s)
staticprivate

Definition at line 144 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

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

Definition at line 120 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

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

Definition at line 195 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

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

Definition at line 172 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

173 {
174  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: phed_rz = " << s ;
175  vector<double>* r_p = new vector<double>; // geant gets the memory!
176  vector<double>* z_p = new vector<double>;
177  vector<double>& r = *r_p;
178  vector<double>& z = *z_p;
179  vector<double>::const_iterator i = par_->begin()+3;
180  int count=0;
181 
182  for(; i!=par_->end(); ++i) {
183  z.push_back(*i); ++i;
184  r.push_back(*i);
185  count++;
186  }
187 
188  return new G4Polyhedra(s.name().name(), (*par_)[1], (*par_)[2], int((*par_)[0]),// start,delta-phi;sides
189  count, // numRZ
190  &(*r.begin()),
191  &(*z.begin()));
192 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
static const std::vector< double > * par_
const N & name() const
Definition: DDBase.h:88
double double double z
string s
Definition: asciidump.py:422
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 333 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

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

Definition at line 234 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

235 {
236  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: reflected = " << s ;
237  G4ReflectedSolid * rs = 0;
238  DDReflectionSolid rfs(s);
239  if (rfs) {
240  static /* G4Transform3D */ HepGeom::ReflectZ3D z_reflection; // = HepGeom::ReflectZ3D;
241  rs = new G4ReflectedSolid(s.name().name(),
242  DDG4SolidConverter().convert(rfs.unreflected()),
243  z_reflection);
244 
245  } // else ?
246  return rs;
247 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:88
string s
Definition: asciidump.py:422
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 520 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

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

Definition at line 280 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

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

Definition at line 222 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

223 {
224  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: torus = " << s ;
225  return new G4Torus(s.name().name(), (*par_)[0], // rmin
226  (*par_)[1], // rmax
227  (*par_)[2], // Rtor
228  (*par_)[3], // phiStart
229  (*par_)[4]);// deltaPhi
230 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:88
string s
Definition: asciidump.py:422
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
G4VSolid * DDG4SolidConverter::trap ( const DDSolid s)
staticprivate

Definition at line 88 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

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

Definition at line 436 of file DDG4SolidConverter.cc.

References abs, alpha, funct::cos(), DDTruncTubs::cutAtDelta(), DDTruncTubs::cutAtStart(), DDTruncTubs::cutInside(), Geom::deltaPhi(), DDTruncTubs::deltaPhi(), DDName::fullname(), LogDebug, m, DDSolidShapesName::name(), DDName::name(), mergeVDriftHistosByStation::name, DDBase< N, C >::name(), csvReporter::r, dttmaxenums::R, query::result, DDTruncTubs::rIn(), DDTruncTubs::rOut(), asciidump::s, DDSolid::shape(), funct::sin(), mathSSE::sqrt(), DDTruncTubs::startPhi(), and DDTruncTubs::zHalf().

Referenced by DDG4SolidConverter().

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

Definition at line 76 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

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

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

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