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 | Friends
DDG4SolidConverter Class Reference

#include <DDG4SolidConverter.h>

Public Types

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

Public Member Functions

G4VSolid * convert (const DDSolid &)
 
 DDG4SolidConverter ()
 
 ~DDG4SolidConverter ()
 

Static Private Member Functions

static G4VSolid * box (const DDSolid &)
 
static G4VSolid * cons (const DDSolid &)
 
static G4VSolid * 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 &s)
 
static G4VSolid * reflected (const DDSolid &)
 
static G4VSolid * shapeless (const DDSolid &)
 
static G4VSolid * sphere (const DDSolid &)
 
static G4VSolid * subtraction (const DDSolid &)
 
static G4VSolid * torus (const DDSolid &)
 
static G4VSolid * trap (const DDSolid &)
 
static G4VSolid * trunctubs (const DDSolid &)
 
static G4VSolid * tubs (const DDSolid &)
 
static G4VSolid * unionsolid (const DDSolid &)
 

Private Attributes

std::map< DDSolidShape, FNPTRconvDispatch_
 

Static Private Attributes

static const std::vector
< double > * 
par_ = 0
 

Friends

class testPseudoTrap
 
class testTruncTubs
 

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 ...
37 }
static G4VSolid * polyhedra_rrz(const DDSolid &)
static G4VSolid * orb(const DDSolid &)
static G4VSolid * ellipsoid(const DDSolid &)
static G4VSolid * trap(const DDSolid &)
static G4VSolid * cons(const DDSolid &)
static G4VSolid * tubs(const DDSolid &)
static G4VSolid * sphere(const DDSolid &)
static G4VSolid * pseudotrap(const DDSolid &s)
static G4VSolid * reflected(const DDSolid &)
static G4VSolid * para(const DDSolid &)
static G4VSolid * box(const DDSolid &)
static G4VSolid * ellipticaltube(const DDSolid &)
static G4VSolid * polycone_rz(const DDSolid &)
static G4VSolid * 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:78
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:78
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 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 = nullptr;
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:82
std::map< DDSolidShape, FNPTR > convDispatch_
G4VSolid * DDG4SolidConverter::ellipsoid ( const DDSolid s)
staticprivate

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

561 {
562  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: ellipsoid = " << s ;
563  DDEllipsoid sp(s);
564  return new G4Ellipsoid(s.name().name(),
565  sp.xSemiAxis(),
566  sp.ySemiAxis(),
567  sp.zSemiAxis(),
568  sp.zBottomCut(),
569  sp.zTopCut());
570 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
Definition: sp.h:21
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
G4VSolid * DDG4SolidConverter::ellipticaltube ( const DDSolid s)
staticprivate

Definition at line 549 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

550 {
551  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: ellipticaltube = " << s ;
552  DDEllipticalTube sp(s);
553  return new G4EllipticalTube(s.name().name(),
554  sp.xSemiAxis(),
555  sp.ySemiAxis(),
556  sp.zHeight());
557 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
Definition: sp.h:21
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
G4VSolid * DDG4SolidConverter::intersection ( const DDSolid s)
staticprivate

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

321 {
322  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: intersection = " << s ;
323  G4IntersectionSolid * us = 0;
324  DDBooleanSolid bs(s);
325  if (bs) {
326  G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
327  G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
328  LogDebug("SimG4CoreGeometry") << " name:" << s.name() << " t=" << bs.translation() << flush;
329  LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << flush;
330  std::vector<double> tdbl(9);
331  bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
332  CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
333  CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z());
334  us = new G4IntersectionSolid(s.name().name(),
335  sa,
336  sb,
337  new CLHEP::HepRotation(temprep),
338  temphvec);
339  }
340  return us;
341 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
G4VSolid * DDG4SolidConverter::orb ( const DDSolid s)
staticprivate

Definition at line 541 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

542 {
543  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: orb = " << s ;
544  DDOrb sp(s);
545  return new G4Orb(s.name().name(), sp.radius());
546 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
Definition: DDSolid.h:338
Definition: sp.h:21
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
G4VSolid * DDG4SolidConverter::para ( const DDSolid s)
staticprivate

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

574 {
575  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: parallelepiped = " << s ;
576  DDParallelepiped sp(s);
577  return new G4Para(s.name().name(),
578  sp.xHalf(),
579  sp.yHalf(),
580  sp.zHalf(),
581  sp.alpha(),
582  sp.theta(),
583  sp.phi());
584 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
signal_ phi
Definition: sp.h:180
Definition: sp.h:21
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
signal_ theta
Definition: sp.h:181
G4VSolid * DDG4SolidConverter::polycone_rrz ( const DDSolid s)
staticprivate

Definition at line 147 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

148 {
149  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: pcon_rrz = " << s ;
150  vector<double> z_p;
151  vector<double> rmin_p;
152  vector<double> rmax_p;
153  vector<double>::const_iterator i = par_->begin()+2;
154  int count = 0;
155  for (; i!=par_->end(); ++i) {
156  LogDebug("SimG4CoreGeometry") << "z=" << *i ;
157  z_p.push_back(*i); ++i;
158  LogDebug("SimG4CoreGeometry") << "rmin=" << *i ;
159  rmin_p.push_back(*i); ++i;
160  LogDebug("SimG4CoreGeometry") << "rmax=" << *i ;
161  rmax_p.push_back(*i);
162  count++;
163  }
164  LogDebug("SimG4CoreGeometry") << "sp=" << (*par_)[0]/deg << " ep=" << (*par_)[1]/deg ;
165  /*
166  std::cout << "### Polycone_RRZ: " << "sp=" << (*par_)[0]/deg
167  << " ep=" << (*par_)[1]/deg
168  << " N= " << count << std::endl;
169  for(int i=0; i<count; ++i) {
170  std::cout << " R1= " << rmin_p[i] << " R1= " << rmax_p[i] << " Z= " << z_p[i] << std::endl;
171  }
172  */
173  return new G4Polycone(s.name().name(), (*par_)[0], (*par_)[1], // start,delta-phi
174  count, // sections
175  &(z_p[0]),
176  &(rmin_p[0]),
177  &(rmax_p[0]));
178 
179 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
static const std::vector< double > * par_
const N & name() const
Definition: DDBase.h:78
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 KineDebug3::count(), i, LogDebug, DDName::name(), DDBase< N, C >::name(), alignCSCRings::r, and alignCSCRings::s.

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  /*
133  std::cout << "### Polycone_RZ: " << "sp=" << (*par_)[0]/deg
134  << " ep=" << (*par_)[1]/deg
135  << " N= " << count << std::endl;
136  for(int i=0; i<count; ++i) {
137  std::cout << " R= " << r[i] << " Z= " << z[i] << std::endl;
138  }
139  */
140  return new G4Polycone(s.name().name(), (*par_)[0], (*par_)[1], // start,delta-phi
141  count, // numRZ
142  &(r[0]),
143  &(z[0]));
144 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
const N & name() const
Definition: DDBase.h:78
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
G4VSolid * DDG4SolidConverter::polyhedra_rrz ( const DDSolid s)
staticprivate

Definition at line 204 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

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

Definition at line 183 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

184 {
185  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: phed_rz = " << s ;
186  vector<double> r;
187  vector<double> z;
188  vector<double>::const_iterator i = par_->begin()+3;
189  int count=0;
190 
191  for(; i!=par_->end(); ++i) {
192  z.push_back(*i); ++i;
193  r.push_back(*i);
194  count++;
195  }
196 
197  return new G4Polyhedra(s.name().name(), (*par_)[1], (*par_)[2], int((*par_)[0]),// start,delta-phi;sides
198  count, // numRZ
199  &(r[0]),
200  &(z[0]));
201 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
static const std::vector< double > * par_
const N & name() const
Definition: DDBase.h:78
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 345 of file DDG4SolidConverter.cc.

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

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

Definition at line 247 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

248 {
249  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: reflected = " << s ;
250  G4ReflectedSolid * rs = 0;
251  DDReflectionSolid rfs(s);
252  if (rfs) {
253  rs = new G4ReflectedSolid(s.name().name(),
254  DDG4SolidConverter().convert(rfs.unreflected()),
255  z_reflection);
256 
257  } // else ?
258  return rs;
259 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
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 528 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().

529 {
530  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: sphere = " << s ;
531  DDSphere sp(s);
532  return new G4Sphere(s.name().name(), sp.innerRadius(),
533  sp.outerRadius(),
534  sp.startPhi(),
535  sp.deltaPhi(),
536  sp.startTheta(),
537  sp.deltaTheta());
538 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
Definition: sp.h:21
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
G4VSolid * DDG4SolidConverter::subtraction ( const DDSolid s)
staticprivate

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

293 {
294  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: subtraction = " << s ;
295  G4SubtractionSolid * us = 0;
296  DDBooleanSolid bs(s);
297  if (bs) {
298  G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
299  G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
300  LogDebug("SimG4CoreGeometry") << " name:" << s.name() << " t=" << bs.translation() << flush;
301  // stringstream sst;
302  // bs.rotation().rotation()->inverse().print(sst);
303  // LogDebug("SimG4CoreGeometry") << " " << sst.str() << flush;
304  LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << flush;
305  std::vector<double> tdbl(9);
306  bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
307  CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
308  CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z());
309  us = new G4SubtractionSolid(s.name().name(),
310  sa,
311  sb,
312  new CLHEP::HepRotation(temprep),
313  temphvec);
314  }
315  return us;
316 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
G4VSolid * DDG4SolidConverter::torus ( const DDSolid s)
staticprivate

Definition at line 230 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

231 {
232  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: torus = " << s ;
233  return new G4Torus(s.name().name(), (*par_)[0], // rmin
234  (*par_)[1], // rmax
235  (*par_)[2], // Rtor
236  (*par_)[3], // phiStart
237  (*par_)[4]);// deltaPhi
238 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
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:78
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
G4VSolid * DDG4SolidConverter::trunctubs ( const DDSolid s)
staticprivate

Definition at line 448 of file DDG4SolidConverter.cc.

References funct::abs(), alpha, funct::cos(), DDTruncTubs::cutAtDelta(), DDTruncTubs::cutAtStart(), DDTruncTubs::cutInside(), SiPixelRawToDigiRegional_cfi::deltaPhi, DDTruncTubs::deltaPhi(), Exception, DDName::fullname(), LogDebug, visualization-live-secondInstance_cfg::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().

449 {
450  // truncated tube-section: a boolean subtraction solid:
451  // from a tube-section a box is subtracted according to the
452  // given parameters
453  LogDebug("SimG4CoreGeometry") << "MantisConverter: solidshape=" << DDSolidShapesName::name(s.shape()) << " " << s;
454  LogDebug("SimG4CoreGeometry") << "before";
455  DDTruncTubs tt(s);
456  LogDebug("SimG4CoreGeometry") << "after";
457  double rIn(tt.rIn()), rOut(tt.rOut()), zHalf(tt.zHalf()),
458  startPhi(tt.startPhi()), deltaPhi(tt.deltaPhi()),
459  cutAtStart(tt.cutAtStart()), cutAtDelta(tt.cutAtDelta());
460  bool cutInside(bool(tt.cutInside()));
461  string name=tt.name().name();
462 
463  // check the parameters
464  if (rIn <= 0 || rOut <=0 || cutAtStart <=0 || cutAtDelta <= 0) {
465  throw cms::Exception("DetectorDescriptionFault", "TruncTubs " + string(tt.name().fullname()) + ": 0 <= rIn,cutAtStart,rOut,cutAtDelta,rOut violated!");
466  }
467  if (rIn >= rOut) {
468  throw cms::Exception("DetectorDescriptionFault", "TruncTubs " + string(tt.name().fullname()) + ": rIn<rOut violated!");
469  }
470  if (startPhi != 0.) {
471  throw cms::Exception("DetectorDescriptionFault", "TruncTubs " + string(tt.name().fullname()) + ": startPhi != 0 not supported!");
472  }
473  // if (cutInside != false) {
474  // throw cms::Exception("DetectorDescriptionFault", "TruncTubs " + string(tt.name()) + " cutInside == true not supported!");
475  // }
476 
477  startPhi=0.;
478  double r(cutAtStart), R(cutAtDelta);
479  G4VSolid * result(0);
480  G4VSolid * tubs = new G4Tubs(name,rIn,rOut,zHalf,startPhi,deltaPhi);
481  LogDebug("SimG4CoreGeometry") << "G4Tubs: " << rIn << ' ' << rOut << ' ' << zHalf << ' ' << startPhi/deg << ' ' << deltaPhi/deg;
482  LogDebug("SimG4CoreGeometry") << s;
483  // length & hight of the box
484  double boxX(30.*rOut), boxY(20.*rOut); // exaggerate dimensions - does not matter, it's subtracted!
485 
486  // width of the box > width of the tubs
487  double boxZ(1.1*zHalf);
488 
489  // angle of the box w.r.t. tubs
490  double cath = r-R*cos(deltaPhi);
491  double hypo = sqrt(r*r+R*R-2.*r*R*cos(deltaPhi));
492  double cos_alpha = cath/hypo;
493 
494  double alpha = -acos(cos_alpha);
495  LogDebug("SimG4CoreGeometry") << "cath=" << cath/m;
496  LogDebug("SimG4CoreGeometry") << "hypo=" << hypo/m;
497  LogDebug("SimG4CoreGeometry") << "al=" << acos(cath/hypo)/deg;
498  LogDebug("SimG4CoreGeometry") << "deltaPhi=" << deltaPhi/deg << "\n"
499  << "r=" << r/m << "\n"
500  << "R=" << R/m;
501 
502  LogDebug("SimG4CoreGeometry") << "alpha=" << alpha/deg;
503 
504  // rotationmatrix of box w.r.t. tubs
505  G4RotationMatrix * rot = new G4RotationMatrix;
506  rot->rotateZ(-alpha);
507  LogDebug("SimG4CoreGeometry") << (*rot);
508 
509  // center point of the box
510  double xBox;
511  if (!cutInside) {
512  xBox = r+boxY/sin(abs(alpha));
513  } else {
514  xBox = -(boxY/sin(abs(alpha))-r);
515  }
516 
517  G4ThreeVector trans(xBox,0.,0.);
518  LogDebug("SimG4CoreGeometry") << "trans=" << trans;
519 
520  G4VSolid * box = new G4Box(name,boxX,boxY,boxZ);
521  result = new G4SubtractionSolid(name,tubs,box,rot,trans);
522 
523  return result;
524 
525 }
#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:18
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 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:78
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
G4VSolid * DDG4SolidConverter::unionsolid ( const DDSolid s)
staticprivate

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

264 {
265  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: unionsolid = " << s.name() ;
266  G4UnionSolid * us = 0;
267  DDBooleanSolid bs(s);
268  if (bs) {
269  LogDebug("SimG4CoreGeometry") << "SolidA=" << bs.solidA();
270  G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
271  LogDebug("SimG4CoreGeometry") << "SolidB=" << bs.solidB();
272  G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
273  LogDebug("SimG4CoreGeometry") << " name:" << s.name() << " t=" << bs.translation() << flush;
274  LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << flush;
275  std::vector<double> tdbl(9);
276  bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
277  CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
278  CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z());
279  us = new G4UnionSolid(s.name().name(),
280  sa,
281  sb,
282  new CLHEP::HepRotation(temprep),
283  temphvec);
284 
285  } // else?
286  return us;
287 }
#define LogDebug(id)
const N & name() const
Definition: DDBase.h:78
const std::string & name() const
Returns the name.
Definition: DDName.cc:87

Friends And Related Function Documentation

friend class testPseudoTrap
friend

Definition at line 48 of file DDG4SolidConverter.h.

friend class testTruncTubs
friend

Definition at line 47 of file DDG4SolidConverter.h.

Member Data Documentation

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

Definition at line 45 of file DDG4SolidConverter.h.

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

Definition at line 44 of file DDG4SolidConverter.h.