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

562 {
563  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: ellipsoid = " << s ;
564  DDEllipsoid sp(s);
565  return new G4Ellipsoid(s.name().name(),
566  sp.xSemiAxis(),
567  sp.ySemiAxis(),
568  sp.zSemiAxis(),
569  sp.zBottomCut(),
570  sp.zTopCut());
571 }
#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 550 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

551 {
552  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: ellipticaltube = " << s ;
553  DDEllipticalTube sp(s);
554  return new G4EllipticalTube(s.name().name(),
555  sp.xSemiAxis(),
556  sp.ySemiAxis(),
557  sp.zHeight());
558 }
#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 321 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().

322 {
323  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: intersection = " << s ;
324  G4IntersectionSolid * us = 0;
325  DDBooleanSolid bs(s);
326  if (bs) {
327  G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
328  G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
329  LogDebug("SimG4CoreGeometry") << " name:" << s.name() << " t=" << bs.translation() << flush;
330  LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << flush;
331  std::vector<double> tdbl(9);
332  bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
333  CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
334  CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z());
335  us = new G4IntersectionSolid(s.name().name(),
336  sa,
337  sb,
338  new CLHEP::HepRotation(temprep),
339  temphvec);
340  }
341  return us;
342 }
#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 542 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

543 {
544  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: orb = " << s ;
545  DDOrb sp(s);
546  return new G4Orb(s.name().name(), sp.radius());
547 }
#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 574 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().

575 {
576  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: parallelepiped = " << s ;
577  DDParallelepiped sp(s);
578  return new G4Para(s.name().name(),
579  sp.xHalf(),
580  sp.yHalf(),
581  sp.zHalf(),
582  sp.alpha(),
583  sp.theta(),
584  sp.phi());
585 }
#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 148 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

149 {
150  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: pcon_rrz = " << s ;
151  vector<double> z_p;
152  vector<double> rmin_p;
153  vector<double> rmax_p;
154  vector<double>::const_iterator i = par_->begin()+2;
155  int count = 0;
156  for (; i!=par_->end(); ++i) {
157  LogDebug("SimG4CoreGeometry") << "z=" << *i ;
158  z_p.push_back(*i); ++i;
159  LogDebug("SimG4CoreGeometry") << "rmin=" << *i ;
160  rmin_p.push_back(*i); ++i;
161  LogDebug("SimG4CoreGeometry") << "rmax=" << *i ;
162  rmax_p.push_back(*i);
163  count++;
164  }
165  LogDebug("SimG4CoreGeometry") << "sp=" << (*par_)[0]/deg << " ep=" << (*par_)[1]/deg ;
166  /*
167  std::cout << "### Polycone_RRZ: " << "sp=" << (*par_)[0]/deg
168  << " ep=" << (*par_)[1]/deg
169  << " N= " << count << std::endl;
170  for(int i=0; i<count; ++i) {
171  std::cout << " R1= " << rmin_p[i] << " R1= " << rmax_p[i] << " Z= " << z_p[i] << std::endl;
172  }
173  */
174  return new G4Polycone(s.name().name(), (*par_)[0], (*par_)[1], // start,delta-phi
175  count, // sections
176  &(z_p[0]),
177  &(rmin_p[0]),
178  &(rmax_p[0]));
179 
180 }
#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  /*
134  std::cout << "### Polycone_RZ: " << "sp=" << (*par_)[0]/deg
135  << " ep=" << (*par_)[1]/deg
136  << " N= " << count << std::endl;
137  for(int i=0; i<count; ++i) {
138  std::cout << " R= " << r[i] << " Z= " << z[i] << std::endl;
139  }
140  */
141  return new G4Polycone(s.name().name(), (*par_)[0], (*par_)[1], // start,delta-phi
142  count, // numRZ
143  &(r[0]),
144  &(z[0]));
145 }
#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 205 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

206 {
207  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: phed_rrz = " << s ;
208  vector<double> z_p;
209  vector<double> rmin_p;
210  vector<double> rmax_p;
211  vector<double>::const_iterator i = par_->begin()+3;
212  int count = 0;
213  for (; i!=par_->end(); ++i) {
214  LogDebug("SimG4CoreGeometry") << "z=" << *i ;
215  z_p.push_back(*i); ++i;
216  LogDebug("SimG4CoreGeometry") << "rmin=" << *i ;
217  rmin_p.push_back(*i); ++i;
218  LogDebug("SimG4CoreGeometry") << "rmax=" << *i ;
219  rmax_p.push_back(*i);
220  count++;
221  }
222  LogDebug("SimG4CoreGeometry") << "sp=" << (*par_)[0]/deg << " ep=" << (*par_)[1]/deg ;
223  return new G4Polyhedra(s.name().name(), (*par_)[1], (*par_)[2], int((*par_)[0]), // start,delta-phi,sides
224  count, // sections
225  &(z_p[0]),
226  &(rmin_p[0]),
227  &(rmax_p[0]));
228 }
#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 184 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().

185 {
186  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: phed_rz = " << s ;
187  vector<double> r;
188  vector<double> z;
189  vector<double>::const_iterator i = par_->begin()+3;
190  int count=0;
191 
192  for(; i!=par_->end(); ++i) {
193  z.push_back(*i); ++i;
194  r.push_back(*i);
195  count++;
196  }
197 
198  return new G4Polyhedra(s.name().name(), (*par_)[1], (*par_)[2], int((*par_)[0]),// start,delta-phi;sides
199  count, // numRZ
200  &(r[0]),
201  &(z[0]));
202 }
#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 346 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(), 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().

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

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

Referenced by DDG4SolidConverter().

249 {
250  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: reflected = " << s ;
251  G4ReflectedSolid * rs = 0;
252  DDReflectionSolid rfs(s);
253  if (rfs) {
254  rs = new G4ReflectedSolid(s.name().name(),
255  DDG4SolidConverter().convert(rfs.unreflected()),
256  z_reflection);
257 
258  } // else ?
259  return rs;
260 }
#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 529 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().

530 {
531  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: sphere = " << s ;
532  DDSphere sp(s);
533  return new G4Sphere(s.name().name(), sp.innerRadius(),
534  sp.outerRadius(),
535  sp.startPhi(),
536  sp.deltaPhi(),
537  sp.startTheta(),
538  sp.deltaTheta());
539 }
#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 293 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().

294 {
295  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: subtraction = " << s ;
296  G4SubtractionSolid * us = 0;
297  DDBooleanSolid bs(s);
298  if (bs) {
299  G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
300  G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
301  LogDebug("SimG4CoreGeometry") << " name:" << s.name() << " t=" << bs.translation() << flush;
302  // stringstream sst;
303  // bs.rotation().rotation()->inverse().print(sst);
304  // LogDebug("SimG4CoreGeometry") << " " << sst.str() << flush;
305  LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << flush;
306  std::vector<double> tdbl(9);
307  bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
308  CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
309  CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z());
310  us = new G4SubtractionSolid(s.name().name(),
311  sa,
312  sb,
313  new CLHEP::HepRotation(temprep),
314  temphvec);
315  }
316  return us;
317 }
#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 231 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

232 {
233  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: torus = " << s ;
234  return new G4Torus(s.name().name(), (*par_)[0], // rmin
235  (*par_)[1], // rmax
236  (*par_)[2], // Rtor
237  (*par_)[3], // phiStart
238  (*par_)[4]);// deltaPhi
239 }
#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 449 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, 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(), edmStreamStallGrapher::trans, groupFilesInBlocks::tt, and DDTruncTubs::zHalf().

Referenced by DDG4SolidConverter().

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

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