CMS 3D CMS Logo

DDG4SolidConverter.cc
Go to the documentation of this file.
2 #include "G4VSolid.hh"
3 
5 
8 #include "G4SystemOfUnits.hh"
9 
10 const std::vector<double> * DDG4SolidConverter::par_ = nullptr;
11 G4RotationMatrix* DDG4SolidConverter::rot = nullptr;
12 
14  // could also be done 'dynamically' from outside
15  // would then need to have a 'register' method ...
39 }
40 
42 
43 G4VSolid * DDG4SolidConverter::convert(const DDSolid & solid) {
44  if ( !solid ) {
45  edm::LogError("SimG4CoreGeometry") <<" DDG4SolidConverter::convert(..) found an undefined DDSolid " << solid.toString();
46  throw cms::Exception("SimG4CoreGeometry", "DDG4SolidConverter::convert(..) found an undefined DDSolid " + solid.toString());
47  }
48  G4VSolid * result = nullptr;
49  par_ = &(solid.parameters());
50  std::map<DDSolidShape,FNPTR>::iterator it = convDispatch_.find(solid.shape());
51  if (it != convDispatch_.end()) {
52  result = it->second(solid);
53  } else {
54  throw cms::Exception("DetectorDescriptionFault")
55  << "DDG4SolidConverter::convert: conversion failed for s=" << solid
56  << "\n solid.shape()=" << solid.shape()
57  << std::endl;
58  }
59  return result;
60 }
61 
62 
63 #include "G4Box.hh"
64 G4VSolid * DDG4SolidConverter::box(const DDSolid & solid) {
65  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: box = " << solid;
66  return new G4Box(solid.name().name(), (*par_)[0],(*par_)[1],(*par_)[2]);
67 }
68 
69 
70 #include "G4Tubs.hh"
71 G4VSolid * DDG4SolidConverter::tubs(const DDSolid & solid) {
72  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: tubs = " << solid;
73  return new G4Tubs(solid.name().name(), (*par_)[1], // rmin
74  (*par_)[2], // rmax
75  (*par_)[0], // dzHalf
76  (*par_)[3], // phiStart
77  (*par_)[4]);// deltaPhi
78 }
79 
80 #include "G4CutTubs.hh"
81 G4VSolid * DDG4SolidConverter::cuttubs(const DDSolid & solid) {
82  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: tubs = " << solid;
83  return new G4CutTubs(solid.name().name(), (*par_)[1], // rmin
84  (*par_)[2], // rmax
85  (*par_)[0], // dzHalf
86  (*par_)[3], // phiStart
87  (*par_)[4], // deltaPhi
88  G4ThreeVector((*par_)[5],(*par_)[6],(*par_)[7]),
89  G4ThreeVector((*par_)[8],(*par_)[9],(*par_)[10]));
90 }
91 
92 
93 #include "G4Trap.hh"
94 G4VSolid * DDG4SolidConverter::trap(const DDSolid & solid) {
95  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: trap = " << solid;
96  return new G4Trap(solid.name().name(), (*par_)[0], // pDz
97  (*par_)[1], // theta
98  (*par_)[2], // phi
99  (*par_)[3], // y1
100  (*par_)[4], // x1
101  (*par_)[5], // x2
102  (*par_)[6], // alpha1
103  (*par_)[7], // y2
104  (*par_)[8], // x3
105  (*par_)[9], // x4
106  (*par_)[10]);// alpha2
107 }
108 
109 
110 #include "G4Cons.hh"
111 G4VSolid * DDG4SolidConverter::cons(const DDSolid & solid) {
112  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: cons = " << solid;
113  return new G4Cons(solid.name().name(), (*par_)[1], // rmin -z
114  (*par_)[2], // rmax -z
115  (*par_)[3], // rmin +z
116  (*par_)[4], // rmax +z
117  (*par_)[0], // zHalf
118  (*par_)[5], // phistart
119  (*par_)[6]); // deltaphi
120 }
121 
122 
123 #include "G4Polycone.hh"
124 G4VSolid * DDG4SolidConverter::polycone_rz(const DDSolid & solid) {
125  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: pcon_rz = " << solid;
126  std::vector<double> r;
127  std::vector<double> z;
128  std::vector<double>::const_iterator i = (*par_).begin()+2;
129  int count=0;
130  for(; i!=(*par_).end(); ++i) {
131  LogDebug("SimG4CoreGeometry") << " z=" << *i/CLHEP::cm;
132  z.push_back(*i); ++i;
133  LogDebug("SimG4CoreGeometry") << " r=" << *i/CLHEP::cm;
134  r.push_back(*i);
135  count++;
136  }
137  LogDebug("SimG4CoreGeometry") << "sp=" << (*par_)[0]/CLHEP::deg << " ep="
138  << (*par_)[1]/CLHEP::deg;
139  /*
140  std::cout << "### Polycone_RZ: " << "sp=" << (*par_)[0]/CLHEP::deg
141  << " ep=" << (*par_)[1]/CLHEP::deg
142  << " N= " << count << std::endl;
143  for(int i=0; i<count; ++i) {
144  std::cout << " R= " << r[i] << " Z= " << z[i] << std::endl;
145  }
146  */
147  return new G4Polycone(solid.name().name(), (*par_)[0], (*par_)[1], // start,delta-phi
148  count, // numRZ
149  &(r[0]),
150  &(z[0]));
151 }
152 
153 
154 G4VSolid * DDG4SolidConverter::polycone_rrz(const DDSolid & solid) {
155  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: pcon_rrz = " << solid;
156  std::vector<double> z_p;
157  std::vector<double> rmin_p;
158  std::vector<double> rmax_p;
159  std::vector<double>::const_iterator i = par_->begin()+2;
160  int count = 0;
161  for (; i!=par_->end(); ++i) {
162  LogDebug("SimG4CoreGeometry") << "z=" << *i/CLHEP::cm;
163  z_p.push_back(*i); ++i;
164  LogDebug("SimG4CoreGeometry") << "rmin=" << *i/CLHEP::cm;
165  rmin_p.push_back(*i); ++i;
166  LogDebug("SimG4CoreGeometry") << "rmax=" << *i/CLHEP::cm;
167  rmax_p.push_back(*i);
168  count++;
169  }
170  LogDebug("SimG4CoreGeometry") << "sp=" << (*par_)[0]/CLHEP::deg << " ep="
171  << (*par_)[1]/CLHEP::deg;
172  /*
173  std::cout << "### Polycone_RRZ: " << "sp=" << (*par_)[0]/CLHEP::deg
174  << " ep=" << (*par_)[1]/CLHEP::deg
175  << " N= " << count << std::endl;
176  for(int i=0; i<count; ++i) {
177  std::cout << " R1= " << rmin_p[i] << " R1= " << rmax_p[i] << " Z= " << z_p[i] << std::endl;
178  }
179  */
180  return new G4Polycone(solid.name().name(), (*par_)[0], (*par_)[1], // start,delta-phi
181  count, // sections
182  &(z_p[0]),
183  &(rmin_p[0]),
184  &(rmax_p[0]));
185 
186 }
187 
188 
189 #include "G4Polyhedra.hh"
190 G4VSolid * DDG4SolidConverter::polyhedra_rz(const DDSolid & solid) {
191  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: phed_rz = " << solid;
192  std::vector<double> r;
193  std::vector<double> z;
194  std::vector<double>::const_iterator i = par_->begin()+3;
195  int count=0;
196 
197  for(; i!=par_->end(); ++i) {
198  z.push_back(*i); ++i;
199  r.push_back(*i);
200  count++;
201  }
202 
203  return new G4Polyhedra(solid.name().name(), (*par_)[1], (*par_)[2], int((*par_)[0]),// start,delta-phi;sides
204  count, // numRZ
205  &(r[0]),
206  &(z[0]));
207 }
208 
209 
210 G4VSolid * DDG4SolidConverter::polyhedra_rrz(const DDSolid & solid) {
211  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: phed_rrz = " << solid;
212  std::vector<double> z_p;
213  std::vector<double> rmin_p;
214  std::vector<double> rmax_p;
215  std::vector<double>::const_iterator i = par_->begin()+3;
216  int count = 0;
217  for (; i!=par_->end(); ++i) {
218  LogDebug("SimG4CoreGeometry") << "z=" << *i/CLHEP::cm;
219  z_p.push_back(*i); ++i;
220  LogDebug("SimG4CoreGeometry") << "rmin=" << *i/CLHEP::cm;
221  rmin_p.push_back(*i); ++i;
222  LogDebug("SimG4CoreGeometry") << "rmax=" << *i/CLHEP::cm;
223  rmax_p.push_back(*i);
224  count++;
225  }
226  LogDebug("SimG4CoreGeometry") << "sp=" << (*par_)[0]/CLHEP::deg << " ep="
227  << (*par_)[1]/CLHEP::deg;
228  return new G4Polyhedra(solid.name().name(), (*par_)[1], (*par_)[2], int((*par_)[0]), // start,delta-phi,sides
229  count, // sections
230  &(z_p[0]),
231  &(rmin_p[0]),
232  &(rmax_p[0]));
233 }
234 
235 #include "G4ExtrudedSolid.hh"
236 G4VSolid * DDG4SolidConverter::extrudedpolygon(const DDSolid & solid) {
237  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: extr_pgon = " << solid;
238  std::vector<double> x = static_cast<DDExtrudedPolygon>(solid).xVec();
239  std::vector<double> y = static_cast<DDExtrudedPolygon>(solid).yVec();
240  std::vector<double> z = static_cast<DDExtrudedPolygon>(solid).zVec();
241  std::vector<double> zx = static_cast<DDExtrudedPolygon>(solid).zxVec();
242  std::vector<double> zy = static_cast<DDExtrudedPolygon>(solid).zyVec();
243  std::vector<double> zs = static_cast<DDExtrudedPolygon>(solid).zscaleVec();
244 
245  std::vector<G4TwoVector> polygon;
246  std::vector<G4ExtrudedSolid::ZSection> zsections;
247  for( unsigned int it = 0; it < x.size(); ++it )
248  polygon.emplace_back( x[it], y[it] );
249  for( unsigned int it = 0; it < z.size(); ++it )
250  zsections.emplace_back( z[it], G4TwoVector(zx[it], zy[it]), zs[it] );
251  return new G4ExtrudedSolid( solid.name().name(), polygon, zsections );
252 }
253 
254 #include "G4Torus.hh"
255 G4VSolid * DDG4SolidConverter::torus(const DDSolid & solid) {
256  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: torus = " << solid;
257  return new G4Torus(solid.name().name(), (*par_)[0], // rmin
258  (*par_)[1], // rmax
259  (*par_)[2], // Rtor
260  (*par_)[3], // phiStart
261  (*par_)[4]);// deltaPhi
262 }
263 
264 
265 #include "G4ReflectedSolid.hh"
266 
267 namespace {
268  static const HepGeom::ReflectZ3D z_reflection;
269 }
270 
271 G4VSolid * DDG4SolidConverter::reflected(const DDSolid & solid) {
272  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: reflected = " << solid;
273  G4ReflectedSolid * rs = 0;
274  DDReflectionSolid rfs(solid);
275  if (rfs) {
276  rs = new G4ReflectedSolid(solid.name().name(),
277  DDG4SolidConverter().convert(rfs.unreflected()),
278  z_reflection);
279 
280  } // else ?
281  return rs;
282 }
283 
284 
285 #include "G4UnionSolid.hh"
286 G4VSolid * DDG4SolidConverter::unionsolid(const DDSolid & solid) {
287  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: unionsolid = " << solid.name();
288  G4UnionSolid * us = 0;
289  DDBooleanSolid bs(solid);
290  if (bs) {
291  LogDebug("SimG4CoreGeometry") << "SolidA=" << bs.solidA();
292  G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
293  LogDebug("SimG4CoreGeometry") << "SolidB=" << bs.solidB();
294  G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
295  LogDebug("SimG4CoreGeometry") << " name:" << solid.name() << " t=" << bs.translation() << std::flush;
296  LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << std::flush;
297  std::vector<double> tdbl(9);
298  bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
299  CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
300  CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z());
301  us = new G4UnionSolid(solid.name().name(),
302  sa,
303  sb,
304  new CLHEP::HepRotation(temprep),
305  temphvec);
306 
307  } // else?
308  return us;
309 }
310 
311 
312 #include "G4SubtractionSolid.hh"
313 #include <sstream>
314 G4VSolid * DDG4SolidConverter::subtraction(const DDSolid & solid) {
315  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: subtraction = " << solid;
316  G4SubtractionSolid * us = 0;
317  DDBooleanSolid bs(solid);
318  if (bs) {
319  G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
320  G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
321  LogDebug("SimG4CoreGeometry") << " name:" << solid.name() << " t=" << bs.translation() << std::flush;
322  // stringstream sst;
323  // bs.rotation().rotation()->inverse().print(sst);
324  // LogDebug("SimG4CoreGeometry") << " " << sst.str() << std::flush;
325  LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << std::flush;
326  std::vector<double> tdbl(9);
327  bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
328  CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
329  CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z());
330  us = new G4SubtractionSolid(solid.name().name(),
331  sa,
332  sb,
333  new CLHEP::HepRotation(temprep),
334  temphvec);
335  }
336  return us;
337 }
338 
339 
340 #include "G4IntersectionSolid.hh"
341 G4VSolid * DDG4SolidConverter::intersection(const DDSolid & solid) {
342  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: intersection = " << solid;
343  G4IntersectionSolid * us = 0;
344  DDBooleanSolid bs(solid);
345  if (bs) {
346  G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
347  G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
348  LogDebug("SimG4CoreGeometry") << " name:" << solid.name() << " t=" << bs.translation() << std::flush;
349  LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << std::flush;
350  std::vector<double> tdbl(9);
351  bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
352  CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
353  CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z());
354  us = new G4IntersectionSolid(solid.name().name(),
355  sa,
356  sb,
357  new CLHEP::HepRotation(temprep),
358  temphvec);
359  }
360  return us;
361 }
362 
363 #if defined(G4GEOM_USE_USOLIDS)
364 
365 #include "G4MultiUnion.hh"
366 G4VSolid * DDG4SolidConverter::multiunion( const DDSolid & solid ) {
367  G4MultiUnion* munion = new G4MultiUnion( G4String( solid.name().name()));
368  DDMultiUnionSolid ms( solid );
369  std::vector<DDSolid> solids = ms.solids();
370  // FIXME: need to use G4GEOM_USE_USOLIDS
371  if( ms ) {
372  for( auto i : solids ) {
373  G4VSolid* gs = DDG4SolidConverter().convert( solids[i]);
374  G4RotationMatrix rotm = G4RotationMatrix();
375  G4ThreeVector position1 = G4ThreeVector( 0., 0., 1. );
376  G4Transform3D tr1 = G4Transform3D( rotm, position1 );
377  munion->AddNode( gs, tr1 );
378  }
379  }
380  return munion;
381 }
382 
383 #else
384 
385 G4VSolid * DDG4SolidConverter::multiunion( const DDSolid & solid ) {
386  return nullptr;
387 }
388 
389 #endif // G4GEOM_USE_USOLIDS
390 
391 #include "G4Trd.hh"
392 G4VSolid * DDG4SolidConverter::pseudotrap(const DDSolid & solid) {
393  if(nullptr == rot) {
394  rot = new G4RotationMatrix;
395  rot->rotateX(90.*deg);
396  }
397 
398  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: pseudoTrap = " << solid;
399  G4Trd * trap = 0;
400  G4Tubs * tubs = 0;
401  G4VSolid * result = 0;
402  DDPseudoTrap pt(solid); // pt...PseudoTrap
403  double r = pt.radius();
404  bool atMinusZ = pt.atMinusZ();
405  double x = 0;
406  double h = 0;
407  bool intersec = false; // union or intersection solid
408  if (pt.atMinusZ()) {
409  x = pt.x1(); // tubs radius
410  }
411  else {
412  x = pt.x2(); // tubs radius
413  }
414  double openingAngle = 2.*asin(x/std::abs(r));
415  //trap = new G4Trd(solid.name().name(),
416  double displacement=0;
417  double startPhi=0;
418  /* calculate the displacement of the tubs w.r.t. to the trap,
419  determine the opening angle of the tubs */
420  double delta = sqrt(r*r-x*x);
421  if (r < 0 && std::abs(r) >= x) {
422  intersec = true; // intersection solid
423  h = pt.y1() < pt.y2() ? pt.y2() : pt.y1(); // tubs half height
424  h += h/20.; // enlarge a bit - for subtraction solid
425  if (atMinusZ) {
426  displacement = - pt.halfZ() - delta;
427  startPhi = 270.*deg - openingAngle/2.;
428  }
429  else {
430  displacement = pt.halfZ() + delta;
431  startPhi = 90.*deg - openingAngle/2.;
432  }
433  }
434  else if ( r > 0 && std::abs(r) >= x )
435  {
436  if (atMinusZ) {
437  displacement = - pt.halfZ() + delta;
438  startPhi = 90.*deg - openingAngle/2.;
439  h = pt.y1();
440  }
441  else {
442  displacement = pt.halfZ() - delta;
443  startPhi = 270.*deg - openingAngle/2.;
444  h = pt.y2();
445  }
446  }
447  else {
448  throw cms::Exception("DetectorDescriptionFault", "Check parameters of the PseudoTrap! name=" + pt.name().name());
449  }
450  G4ThreeVector displ(0.,0.,displacement); // displacement of the tubs w.r.t. trap
451  LogDebug("SimG4CoreGeometry") << "DDSolidConverter::pseudotrap(): displacement=" << displacement
452  << " openingAngle=" << openingAngle/deg << " x=" << x << " h=" << h;
453 
454  // Now create two solids (trd & tubs), and a boolean solid out of them
455  std::string name=pt.name().name();
456  trap = new G4Trd(name, pt.x1(), pt.x2(), pt.y1(), pt.y2(), pt.halfZ());
457  tubs = new G4Tubs(name,
458  0., // rMin
459  std::abs(r), // rMax
460  h, // half height
461  startPhi, // start angle
462  openingAngle);
463  if (intersec) {
464  result = new G4SubtractionSolid(name, trap, tubs, rot, displ);
465  }
466  else {
468  G4VSolid * tubicCap = new G4SubtractionSolid(name,
469  tubs,
470  new G4Box(name, 1.1*x, sqrt(r*r-x*x), 1.1*h),
471  0,
472  G4ThreeVector());
473  result = new G4UnionSolid(name, trap, tubicCap, rot, displ);
474 
475  // approximative implementation - also fails to visualize due to G4/Iguana limitations
476  /*
477  delete tubs;
478  tubs = new G4Tubs(name,
479  sqrt(r*r-x*x), // rMin-approximation!
480  std::abs(r), // rMax
481  h, // half height
482  startPhi, // start angle
483  openingAngle);
484  result = new G4UnionSolid(name, trap, tubs, rot, displ);
485  */
486  }
487  return result;
488 }
489 
490 
491 G4VSolid * DDG4SolidConverter::trunctubs(const DDSolid & solid) {
492  // truncated tube-section: a boolean subtraction solid:
493  // from a tube-section a box is subtracted according to the
494  // given parameters
495  LogDebug("SimG4CoreGeometry") << "MantisConverter: solidshape=" << DDSolidShapesName::name(solid.shape()) << " " << solid;
496  LogDebug("SimG4CoreGeometry") << "before";
497  DDTruncTubs tt(solid);
498  LogDebug("SimG4CoreGeometry") << "after";
499  double rIn(tt.rIn()), rOut(tt.rOut()), zHalf(tt.zHalf()),
500  startPhi(tt.startPhi()), deltaPhi(tt.deltaPhi()),
501  cutAtStart(tt.cutAtStart()), cutAtDelta(tt.cutAtDelta());
502  bool cutInside(bool(tt.cutInside()));
503  std::string name=tt.name().name();
504 
505  // check the parameters
506  if (rIn <= 0 || rOut <=0 || cutAtStart <=0 || cutAtDelta <= 0) {
507  throw cms::Exception("DetectorDescriptionFault", "TruncTubs " + std::string(tt.name().fullname()) + ": 0 <= rIn,cutAtStart,rOut,cutAtDelta,rOut violated!");
508  }
509  if (rIn >= rOut) {
510  throw cms::Exception("DetectorDescriptionFault", "TruncTubs " + std::string(tt.name().fullname()) + ": rIn<rOut violated!");
511  }
512  if (startPhi != 0.) {
513  throw cms::Exception("DetectorDescriptionFault", "TruncTubs " + std::string(tt.name().fullname()) + ": startPhi != 0 not supported!");
514  }
515  // if (cutInside != false) {
516  // throw cms::Exception("DetectorDescriptionFault", "TruncTubs " + std::string(tt.name()) + " cutInside == true not supported!");
517  // }
518 
519  startPhi=0.;
520  double r(cutAtStart), R(cutAtDelta);
521  G4VSolid * result(0);
522  G4VSolid * tubs = new G4Tubs(name,rIn,rOut,zHalf,startPhi,deltaPhi);
523  LogDebug("SimG4CoreGeometry") << "G4Tubs: " << rIn/CLHEP::cm << ' ' << rOut/CLHEP::cm << ' ' << zHalf/CLHEP::cm << ' ' << startPhi/CLHEP::deg << ' ' << deltaPhi/CLHEP::deg;
524  LogDebug("SimG4CoreGeometry") << solid;
525  // length & hight of the box
526  double boxX(30.*rOut), boxY(20.*rOut); // exaggerate dimensions - does not matter, it's subtracted!
527 
528  // width of the box > width of the tubs
529  double boxZ(1.1*zHalf);
530 
531  // angle of the box w.r.t. tubs
532  double cath = r-R*cos(deltaPhi);
533  double hypo = sqrt(r*r+R*R-2.*r*R*cos(deltaPhi));
534  double cos_alpha = cath/hypo;
535 
536  double alpha = -acos(cos_alpha);
537  LogDebug("SimG4CoreGeometry") << "cath=" << cath/CLHEP::cm;
538  LogDebug("SimG4CoreGeometry") << "hypo=" << hypo/CLHEP::cm;
539  LogDebug("SimG4CoreGeometry") << "al=" << acos(cath/hypo)/CLHEP::deg;
540  LogDebug("SimG4CoreGeometry") << "deltaPhi=" << deltaPhi/CLHEP::deg << "\n"
541  << "r=" << r/CLHEP::cm << "\n"
542  << "R=" << R/CLHEP::cm;
543 
544  LogDebug("SimG4CoreGeometry") << "alpha=" << alpha/CLHEP::deg;
545 
546  // rotationmatrix of box w.r.t. tubs
547  G4RotationMatrix * rot = new G4RotationMatrix;
548  rot->rotateZ(-alpha);
549  LogDebug("SimG4CoreGeometry") << (*rot);
550 
551  // center point of the box
552  double xBox;
553  if (!cutInside) {
554  xBox = r+boxY/sin(std::abs(alpha));
555  } else {
556  xBox = -(boxY/sin(std::abs(alpha))-r);
557  }
558 
559  G4ThreeVector trans(xBox,0.,0.);
560  LogDebug("SimG4CoreGeometry") << "trans=" << trans;
561 
562  G4VSolid * box = new G4Box(name,boxX,boxY,boxZ);
563  result = new G4SubtractionSolid(name,tubs,box,rot,trans);
564 
565  return result;
566 
567 }
568 
569 #include "G4Sphere.hh"
570 G4VSolid * DDG4SolidConverter::sphere(const DDSolid & solid) {
571  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: sphere = " << solid;
572  DDSphere sp(solid);
573  return new G4Sphere(solid.name().name(), sp.innerRadius(),
574  sp.outerRadius(),
575  sp.startPhi(),
576  sp.deltaPhi(),
577  sp.startTheta(),
578  sp.deltaTheta());
579 }
580 
581 #include "G4Orb.hh"
582 G4VSolid * DDG4SolidConverter::orb(const DDSolid & solid) {
583  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: orb = " << solid;
584  DDOrb sp(solid);
585  return new G4Orb(solid.name().name(), sp.radius());
586 }
587 
588 #include "G4EllipticalTube.hh"
589 G4VSolid * DDG4SolidConverter::ellipticaltube(const DDSolid & solid) {
590  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: ellipticaltube = " << solid;
591  DDEllipticalTube sp(solid);
592  return new G4EllipticalTube(solid.name().name(),
593  sp.xSemiAxis(),
594  sp.ySemiAxis(),
595  sp.zHeight());
596 }
597 
598 #include "G4Ellipsoid.hh"
599 G4VSolid * DDG4SolidConverter::ellipsoid(const DDSolid & solid) {
600  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: ellipsoid = " << solid;
601  DDEllipsoid sp(solid);
602  return new G4Ellipsoid(solid.name().name(),
603  sp.xSemiAxis(),
604  sp.ySemiAxis(),
605  sp.zSemiAxis(),
606  sp.zBottomCut(),
607  sp.zTopCut());
608 }
609 
610 #include "G4Para.hh"
611 G4VSolid * DDG4SolidConverter::para(const DDSolid & solid) {
612  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: parallelepiped = " << solid;
613  DDParallelepiped sp(solid);
614  return new G4Para(solid.name().name(),
615  sp.xHalf(),
616  sp.yHalf(),
617  sp.zHalf(),
618  sp.alpha(),
619  sp.theta(),
620  sp.phi());
621 }
622 
#define LogDebug(id)
dbl * delta
Definition: mlp_gen.cc:36
double cutAtStart(void) const
truncation at begin of the tube-section
Definition: DDSolid.cc:220
const DDRotationMatrix * rotation() const
Returns the read-only rotation-matrix.
Definition: DDTransform.h:88
static G4VSolid * polyhedra_rrz(const DDSolid &)
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:147
double xHalf(void) const
Definition: DDSolid.cc:761
double xSemiAxis(void) const
Definition: DDSolid.cc:737
float alpha
Definition: AMPTWrapper.h:95
double phi(void) const
Definition: DDSolid.cc:776
static G4RotationMatrix * rot
bool cutInside(void) const
true, if truncation is on the inner side of the tube-section
Definition: DDSolid.cc:226
static G4VSolid * orb(const DDSolid &)
A truncated tube section.
Definition: DDSolid.h:134
double theta(void) const
Definition: DDSolid.cc:773
const N & name() const
Definition: DDBase.h:78
double zHalf(void) const
half of the z-Axis
Definition: DDSolid.cc:205
double y2(void) const
half length along y on +z
Definition: DDSolid.cc:250
static G4VSolid * ellipsoid(const DDSolid &)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
double startTheta(void) const
Definition: DDSolid.cc:692
double deltaPhi(void) const
angular span of the tube-section
Definition: DDSolid.cc:217
double deltaPhi(void) const
Definition: DDSolid.cc:689
static G4VSolid * trap(const DDSolid &)
const std::vector< DDSolid > & solids(void) const
Definition: DDSolid.cc:623
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
static G4VSolid * cons(const DDSolid &)
double cutAtDelta(void) const
truncation at end of the tube-section
Definition: DDSolid.cc:223
static G4VSolid * tubs(const DDSolid &)
double zTopCut(void) const
Definition: DDSolid.cc:749
double radius(void) const
Definition: DDSolid.cc:707
double rIn(void) const
inner radius
Definition: DDSolid.cc:208
static G4VSolid * sphere(const DDSolid &)
DDTranslation translation(void) const
Definition: DDSolid.cc:653
double ySemiAxis(void) const
Definition: DDSolid.cc:740
double innerRadius(void) const
Definition: DDSolid.cc:680
A DDSolid represents the shape of a part.
Definition: DDSolid.h:38
double y1(void) const
half length along y on -z
Definition: DDSolid.cc:247
DDSolid solidB(void) const
Definition: DDSolid.cc:665
static G4VSolid * cuttubs(const DDSolid &)
double outerRadius(void) const
Definition: DDSolid.cc:683
static const char *const name(DDSolidShape s)
Definition: DDSolidShapes.h:22
DDSolid unreflected(void) const
Definition: DDSolid.cc:288
static G4VSolid * pseudotrap(const DDSolid &s)
static G4VSolid * reflected(const DDSolid &)
DDRotation rotation(void) const
Definition: DDSolid.cc:647
static G4VSolid * para(const DDSolid &)
double yHalf(void) const
Definition: DDSolid.cc:764
bool atMinusZ(void) const
true, if cut-out or rounding is on the -z side
Definition: DDSolid.cc:256
double halfZ(void) const
half of the z-Axis
Definition: DDSolid.cc:238
T sqrt(T t)
Definition: SSEVec.h:18
static const std::vector< double > * par_
double xSemiAxis(void) const
Definition: DDSolid.cc:719
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const std::string fullname() const
Definition: DDName.h:52
double startPhi(void) const
Definition: DDSolid.cc:686
double alpha(void) const
Definition: DDSolid.cc:770
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:141
double deltaTheta(void) const
Definition: DDSolid.cc:695
static G4VSolid * box(const DDSolid &)
double ySemiAxis(void) const
Definition: DDSolid.cc:722
DDSolid solidA(void) const
Definition: DDSolid.cc:659
std::string toString() const
Definition: DDBase.h:82
static G4VSolid * ellipticaltube(const DDSolid &)
static G4VSolid * polycone_rz(const DDSolid &)
static G4VSolid * multiunion(const DDSolid &)
static G4VSolid * intersection(const DDSolid &)
G4VSolid * convert(const DDSolid &)
susybsm::MuonSegment ms
Definition: classes.h:31
double startPhi(void) const
angular start of the tube-section
Definition: DDSolid.cc:214
double zBottomCut(void) const
Definition: DDSolid.cc:746
static G4VSolid * unionsolid(const DDSolid &)
static G4VSolid * extrudedpolygon(const DDSolid &)
Definition: DDSolid.h:395
static G4VSolid * trunctubs(const DDSolid &)
double zHeight(void) const
Definition: DDSolid.cc:725
double zSemiAxis(void) const
Definition: DDSolid.cc:743
static G4VSolid * torus(const DDSolid &)
static G4VSolid * polyhedra_rz(const DDSolid &)
double zHalf(void) const
Definition: DDSolid.cc:767
Definition: sp.h:21
Definition: AbsArchive.cc:53
static G4VSolid * polycone_rrz(const DDSolid &)
double x2(void) const
half length along x on +z
Definition: DDSolid.cc:244
std::map< DDSolidShape, FNPTR > convDispatch_
double rOut(void) const
outer radius
Definition: DDSolid.cc:211
const std::string & name() const
Returns the name.
Definition: DDName.cc:90
double x1(void) const
half length along x on -z
Definition: DDSolid.cc:241
static G4VSolid * subtraction(const DDSolid &)
double radius(void) const
radius of the cut-out (neg.) or rounding (pos.)
Definition: DDSolid.cc:253