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  const HepGeom::ReflectZ3D z_reflection;
269 }
270 
271 G4VSolid * DDG4SolidConverter::reflected(const DDSolid & solid) {
272  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: reflected = " << solid;
273  G4ReflectedSolid * rs = nullptr;
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 = nullptr;
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 = nullptr;
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 = nullptr;
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  if( ms ) {
371  for( auto i : solids ) {
372  G4VSolid* gs = DDG4SolidConverter().convert( solids[i]);
373  G4RotationMatrix rotm = G4RotationMatrix();
374  G4ThreeVector position1 = G4ThreeVector( 0., 0., 1. );
375  G4Transform3D tr1 = G4Transform3D( rotm, position1 );
376  munion->AddNode( *gs, tr1 );
377  }
378  }
379  return munion;
380 }
381 
382 #else
383 
384 G4VSolid * DDG4SolidConverter::multiunion( const DDSolid & solid ) {
385  return nullptr;
386 }
387 
388 #endif // G4GEOM_USE_USOLIDS
389 
390 #include "G4Trd.hh"
391 G4VSolid * DDG4SolidConverter::pseudotrap(const DDSolid & solid) {
392  if(nullptr == rot) {
393  rot = new G4RotationMatrix;
394  rot->rotateX(90.*deg);
395  }
396 
397  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: pseudoTrap = " << solid;
398  G4Trd * trap = nullptr;
399  G4Tubs * tubs = nullptr;
400  G4VSolid * result = nullptr;
401  DDPseudoTrap pt(solid); // pt...PseudoTrap
402  double r = pt.radius();
403  bool atMinusZ = pt.atMinusZ();
404  double x = 0;
405  double h = 0;
406  bool intersec = false; // union or intersection solid
407  if (pt.atMinusZ()) {
408  x = pt.x1(); // tubs radius
409  }
410  else {
411  x = pt.x2(); // tubs radius
412  }
413  double openingAngle = 2.*asin(x/std::abs(r));
414  //trap = new G4Trd(solid.name().name(),
415  double displacement=0;
416  double startPhi=0;
417  /* calculate the displacement of the tubs w.r.t. to the trap,
418  determine the opening angle of the tubs */
419  double delta = sqrt(r*r-x*x);
420  if (r < 0 && std::abs(r) >= x) {
421  intersec = true; // intersection solid
422  h = pt.y1() < pt.y2() ? pt.y2() : pt.y1(); // tubs half height
423  h += h/20.; // enlarge a bit - for subtraction solid
424  if (atMinusZ) {
425  displacement = - pt.halfZ() - delta;
426  startPhi = 270.*deg - openingAngle/2.;
427  }
428  else {
429  displacement = pt.halfZ() + delta;
430  startPhi = 90.*deg - openingAngle/2.;
431  }
432  }
433  else if ( r > 0 && std::abs(r) >= x )
434  {
435  if (atMinusZ) {
436  displacement = - pt.halfZ() + delta;
437  startPhi = 90.*deg - openingAngle/2.;
438  h = pt.y1();
439  }
440  else {
441  displacement = pt.halfZ() - delta;
442  startPhi = 270.*deg - openingAngle/2.;
443  h = pt.y2();
444  }
445  }
446  else {
447  throw cms::Exception("DetectorDescriptionFault", "Check parameters of the PseudoTrap! name=" + pt.name().name());
448  }
449  G4ThreeVector displ(0.,0.,displacement); // displacement of the tubs w.r.t. trap
450  LogDebug("SimG4CoreGeometry") << "DDSolidConverter::pseudotrap(): displacement=" << displacement
451  << " openingAngle=" << openingAngle/deg << " x=" << x << " h=" << h;
452 
453  // Now create two solids (trd & tubs), and a boolean solid out of them
454  std::string name=pt.name().name();
455  trap = new G4Trd(name, pt.x1(), pt.x2(), pt.y1(), pt.y2(), pt.halfZ());
456  tubs = new G4Tubs(name,
457  0., // rMin
458  std::abs(r), // rMax
459  h, // half height
460  startPhi, // start angle
461  openingAngle);
462  if (intersec) {
463  result = new G4SubtractionSolid(name, trap, tubs, rot, displ);
464  }
465  else {
467  G4VSolid * tubicCap = new G4SubtractionSolid(name,
468  tubs,
469  new G4Box(name, 1.1*x, sqrt(r*r-x*x), 1.1*h),
470  nullptr,
471  G4ThreeVector());
472  result = new G4UnionSolid(name, trap, tubicCap, rot, displ);
473 
474  // approximative implementation - also fails to visualize due to G4/Iguana limitations
475  /*
476  delete tubs;
477  tubs = new G4Tubs(name,
478  sqrt(r*r-x*x), // rMin-approximation!
479  std::abs(r), // rMax
480  h, // half height
481  startPhi, // start angle
482  openingAngle);
483  result = new G4UnionSolid(name, trap, tubs, rot, displ);
484  */
485  }
486  return result;
487 }
488 
489 
490 G4VSolid * DDG4SolidConverter::trunctubs(const DDSolid & solid) {
491  // truncated tube-section: a boolean subtraction solid:
492  // from a tube-section a box is subtracted according to the
493  // given parameters
494  LogDebug("SimG4CoreGeometry") << "MantisConverter: solidshape=" << DDSolidShapesName::name(solid.shape()) << " " << solid;
495  LogDebug("SimG4CoreGeometry") << "before";
496  DDTruncTubs tt(solid);
497  LogDebug("SimG4CoreGeometry") << "after";
498  double rIn(tt.rIn()), rOut(tt.rOut()), zHalf(tt.zHalf()),
499  startPhi(tt.startPhi()), deltaPhi(tt.deltaPhi()),
500  cutAtStart(tt.cutAtStart()), cutAtDelta(tt.cutAtDelta());
501  bool cutInside(bool(tt.cutInside()));
502  std::string name=tt.name().name();
503 
504  // check the parameters
505  if (rIn <= 0 || rOut <=0 || cutAtStart <=0 || cutAtDelta <= 0) {
506  throw cms::Exception("DetectorDescriptionFault", "TruncTubs " + std::string(tt.name().fullname()) + ": 0 <= rIn,cutAtStart,rOut,cutAtDelta,rOut violated!");
507  }
508  if (rIn >= rOut) {
509  throw cms::Exception("DetectorDescriptionFault", "TruncTubs " + std::string(tt.name().fullname()) + ": rIn<rOut violated!");
510  }
511  if (startPhi != 0.) {
512  throw cms::Exception("DetectorDescriptionFault", "TruncTubs " + std::string(tt.name().fullname()) + ": startPhi != 0 not supported!");
513  }
514  // if (cutInside != false) {
515  // throw cms::Exception("DetectorDescriptionFault", "TruncTubs " + std::string(tt.name()) + " cutInside == true not supported!");
516  // }
517 
518  startPhi=0.;
519  double r(cutAtStart), R(cutAtDelta);
520  G4VSolid * result(nullptr);
521  G4VSolid * tubs = new G4Tubs(name,rIn,rOut,zHalf,startPhi,deltaPhi);
522  LogDebug("SimG4CoreGeometry") << "G4Tubs: " << rIn/CLHEP::cm << ' ' << rOut/CLHEP::cm << ' ' << zHalf/CLHEP::cm << ' ' << startPhi/CLHEP::deg << ' ' << deltaPhi/CLHEP::deg;
523  LogDebug("SimG4CoreGeometry") << solid;
524  // length & hight of the box
525  double boxX(30.*rOut), boxY(20.*rOut); // exaggerate dimensions - does not matter, it's subtracted!
526 
527  // width of the box > width of the tubs
528  double boxZ(1.1*zHalf);
529 
530  // angle of the box w.r.t. tubs
531  double cath = r-R*cos(deltaPhi);
532  double hypo = sqrt(r*r+R*R-2.*r*R*cos(deltaPhi));
533  double cos_alpha = cath/hypo;
534 
535  double alpha = -acos(cos_alpha);
536  LogDebug("SimG4CoreGeometry") << "cath=" << cath/CLHEP::cm;
537  LogDebug("SimG4CoreGeometry") << "hypo=" << hypo/CLHEP::cm;
538  LogDebug("SimG4CoreGeometry") << "al=" << acos(cath/hypo)/CLHEP::deg;
539  LogDebug("SimG4CoreGeometry") << "deltaPhi=" << deltaPhi/CLHEP::deg << "\n"
540  << "r=" << r/CLHEP::cm << "\n"
541  << "R=" << R/CLHEP::cm;
542 
543  LogDebug("SimG4CoreGeometry") << "alpha=" << alpha/CLHEP::deg;
544 
545  // rotationmatrix of box w.r.t. tubs
546  G4RotationMatrix * rot = new G4RotationMatrix;
547  rot->rotateZ(-alpha);
548  LogDebug("SimG4CoreGeometry") << (*rot);
549 
550  // center point of the box
551  double xBox;
552  if (!cutInside) {
553  xBox = r+boxY/sin(std::abs(alpha));
554  } else {
555  xBox = -(boxY/sin(std::abs(alpha))-r);
556  }
557 
558  G4ThreeVector trans(xBox,0.,0.);
559  LogDebug("SimG4CoreGeometry") << "trans=" << trans;
560 
561  G4VSolid * box = new G4Box(name,boxX,boxY,boxZ);
562  result = new G4SubtractionSolid(name,tubs,box,rot,trans);
563 
564  return result;
565 
566 }
567 
568 #include "G4Sphere.hh"
569 G4VSolid * DDG4SolidConverter::sphere(const DDSolid & solid) {
570  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: sphere = " << solid;
571  DDSphere sp(solid);
572  return new G4Sphere(solid.name().name(), sp.innerRadius(),
573  sp.outerRadius(),
574  sp.startPhi(),
575  sp.deltaPhi(),
576  sp.startTheta(),
577  sp.deltaTheta());
578 }
579 
580 #include "G4Orb.hh"
581 G4VSolid * DDG4SolidConverter::orb(const DDSolid & solid) {
582  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: orb = " << solid;
583  DDOrb sp(solid);
584  return new G4Orb(solid.name().name(), sp.radius());
585 }
586 
587 #include "G4EllipticalTube.hh"
588 G4VSolid * DDG4SolidConverter::ellipticaltube(const DDSolid & solid) {
589  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: ellipticaltube = " << solid;
590  DDEllipticalTube sp(solid);
591  return new G4EllipticalTube(solid.name().name(),
592  sp.xSemiAxis(),
593  sp.ySemiAxis(),
594  sp.zHeight());
595 }
596 
597 #include "G4Ellipsoid.hh"
598 G4VSolid * DDG4SolidConverter::ellipsoid(const DDSolid & solid) {
599  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: ellipsoid = " << solid;
600  DDEllipsoid sp(solid);
601  return new G4Ellipsoid(solid.name().name(),
602  sp.xSemiAxis(),
603  sp.ySemiAxis(),
604  sp.zSemiAxis(),
605  sp.zBottomCut(),
606  sp.zTopCut());
607 }
608 
609 #include "G4Para.hh"
610 G4VSolid * DDG4SolidConverter::para(const DDSolid & solid) {
611  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: parallelepiped = " << solid;
612  DDParallelepiped sp(solid);
613  return new G4Para(solid.name().name(),
614  sp.xHalf(),
615  sp.yHalf(),
616  sp.zHalf(),
617  sp.alpha(),
618  sp.theta(),
619  sp.phi());
620 }
621 
#define LogDebug(id)
dbl * delta
Definition: mlp_gen.cc:36
double cutAtStart(void) const
truncation at begin of the tube-section
Definition: DDSolid.cc:223
const DDRotationMatrix * rotation() const
Returns the read-only rotation-matrix.
Definition: DDTransform.h:91
static G4VSolid * polyhedra_rrz(const DDSolid &)
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:150
double xHalf(void) const
Definition: DDSolid.cc:764
double xSemiAxis(void) const
Definition: DDSolid.cc:740
float alpha
Definition: AMPTWrapper.h:95
double phi(void) const
Definition: DDSolid.cc:779
static G4RotationMatrix * rot
bool cutInside(void) const
true, if truncation is on the inner side of the tube-section
Definition: DDSolid.cc:229
static G4VSolid * orb(const DDSolid &)
A truncated tube section.
Definition: DDSolid.h:134
double theta(void) const
Definition: DDSolid.cc:776
const N & name() const
Definition: DDBase.h:78
double zHalf(void) const
half of the z-Axis
Definition: DDSolid.cc:208
double y2(void) const
half length along y on +z
Definition: DDSolid.cc:253
static G4VSolid * ellipsoid(const DDSolid &)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
double startTheta(void) const
Definition: DDSolid.cc:695
double deltaPhi(void) const
angular span of the tube-section
Definition: DDSolid.cc:220
double deltaPhi(void) const
Definition: DDSolid.cc:692
static G4VSolid * trap(const DDSolid &)
const std::vector< DDSolid > & solids(void) const
Definition: DDSolid.cc:626
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:226
static G4VSolid * tubs(const DDSolid &)
double zTopCut(void) const
Definition: DDSolid.cc:752
double radius(void) const
Definition: DDSolid.cc:710
double rIn(void) const
inner radius
Definition: DDSolid.cc:211
static G4VSolid * sphere(const DDSolid &)
DDTranslation translation(void) const
Definition: DDSolid.cc:656
double ySemiAxis(void) const
Definition: DDSolid.cc:743
double innerRadius(void) const
Definition: DDSolid.cc:683
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:250
DDSolid solidB(void) const
Definition: DDSolid.cc:668
static G4VSolid * cuttubs(const DDSolid &)
double outerRadius(void) const
Definition: DDSolid.cc:686
static const char *const name(DDSolidShape s)
Definition: DDSolidShapes.h:22
DDSolid unreflected(void) const
Definition: DDSolid.cc:291
static G4VSolid * pseudotrap(const DDSolid &s)
static G4VSolid * reflected(const DDSolid &)
DDRotation rotation(void) const
Definition: DDSolid.cc:650
static G4VSolid * para(const DDSolid &)
double yHalf(void) const
Definition: DDSolid.cc:767
bool atMinusZ(void) const
true, if cut-out or rounding is on the -z side
Definition: DDSolid.cc:259
double halfZ(void) const
half of the z-Axis
Definition: DDSolid.cc:241
T sqrt(T t)
Definition: SSEVec.h:18
static const std::vector< double > * par_
double xSemiAxis(void) const
Definition: DDSolid.cc:722
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:689
double alpha(void) const
Definition: DDSolid.cc:773
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:144
double deltaTheta(void) const
Definition: DDSolid.cc:698
static G4VSolid * box(const DDSolid &)
double ySemiAxis(void) const
Definition: DDSolid.cc:725
DDSolid solidA(void) const
Definition: DDSolid.cc:662
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:217
double zBottomCut(void) const
Definition: DDSolid.cc:749
static G4VSolid * unionsolid(const DDSolid &)
static G4VSolid * extrudedpolygon(const DDSolid &)
Definition: DDSolid.h:403
static G4VSolid * trunctubs(const DDSolid &)
double zHeight(void) const
Definition: DDSolid.cc:728
double zSemiAxis(void) const
Definition: DDSolid.cc:746
static G4VSolid * torus(const DDSolid &)
static G4VSolid * polyhedra_rz(const DDSolid &)
double zHalf(void) const
Definition: DDSolid.cc:770
Definition: AbsArchive.cc:53
static G4VSolid * polycone_rrz(const DDSolid &)
double x2(void) const
half length along x on +z
Definition: DDSolid.cc:247
std::map< DDSolidShape, FNPTR > convDispatch_
double rOut(void) const
outer radius
Definition: DDSolid.cc:214
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:244
static G4VSolid * subtraction(const DDSolid &)
double radius(void) const
radius of the cut-out (neg.) or rounding (pos.)
Definition: DDSolid.cc:256