DD4hep  1.28.0
Detector Description Toolkit for High Energy Physics
Shapes.cpp
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 
14 #define _USE_MATH_DEFINES
15 
16 // Framework include files
17 #include <DD4hep/Detector.h>
18 #include <DD4hep/MatrixHelpers.h>
19 #include <DD4hep/DD4hepUnits.h>
20 #include <DD4hep/ShapeTags.h>
21 #include <DD4hep/Printout.h>
23 
24 // C/C++ include files
25 #include <stdexcept>
26 #include <iomanip>
27 #include <sstream>
28 
29 // ROOT includes
30 #include <TClass.h>
31 #include <TGeoMatrix.h>
32 #include <TGeoBoolNode.h>
33 #include <TGeoScaledShape.h>
34 #include <TGeoCompositeShape.h>
35 
36 using namespace dd4hep;
37 namespace units = dd4hep;
38 
39 template <typename T> void Solid_type<T>::_setDimensions(double* param) const {
40  auto p = this->access(); // Ensure we have a valid handle!
41  p->SetDimensions(param);
42  p->ComputeBBox();
43 }
44 
46 template <typename T>
47 void Solid_type<T>::_assign(T* n, const std::string& nam, const std::string& tit, bool cbbox) {
48  this->assign(n, nam, tit);
49  if (cbbox)
50  n->ComputeBBox();
51 }
52 
54 template <typename T> const char* Solid_type<T>::name() const {
55  if ( this->ptr() ) {
56  return this->ptr()->GetName();
57  }
58  return this->access()->GetName(); // Trigger an exception if object is invalid
59 }
60 
62 template <typename T> const char* Solid_type<T>::title() const {
63  if ( this->ptr() ) {
64  return this->ptr()->GetTitle();
65  }
66  return this->access()->GetTitle(); // Trigger an exception if object is invalid
67 }
68 
70 template <typename T> Solid_type<T>& Solid_type<T>::setName(const char* value) {
71  this->access()->SetName(value);
72  return *this;
73 }
74 
76 template <typename T> Solid_type<T>& Solid_type<T>::setName(const std::string& value) {
77  this->access()->SetName(value.c_str());
78  return *this;
79 }
80 
82 template <typename T> const char* Solid_type<T>::type() const {
83  if ( this->ptr() ) {
84  return this->ptr()->IsA()->GetName();
85  }
86  return this->access()->GetName(); // Trigger an exception on invalid handle
87 }
88 
90 template <typename T> std::vector<double> Solid_type<T>::dimensions() {
91  return get_shape_dimensions(this->access());
92 }
93 
95 template <typename T> Solid_type<T>& Solid_type<T>::setDimensions(const std::vector<double>& params) {
96  set_shape_dimensions(this->access(), params);
97  return *this;
98 }
99 
101 template <typename T> TGeoVolume*
102 Solid_type<T>::divide(const Volume& voldiv, const std::string& divname,
103  int iaxis, int ndiv, double start, double step) const {
104  T* p = this->ptr();
105  if ( p ) {
106  auto* pdiv = p->Divide(voldiv.ptr(), divname.c_str(), iaxis, ndiv, start, step);
107  if ( pdiv ) {
108  VolumeMulti mv(pdiv);
109  return mv.ptr();
110  }
111  except("dd4hep","Volume: Failed to divide volume %s -> %s [Invalid result]",
112  voldiv.name(), divname.c_str());
113  }
114  except("dd4hep","Volume: Attempt to divide an invalid logical volume to %s.", divname.c_str());
115  return 0;
116 }
117 
119 ShapelessSolid::ShapelessSolid(const std::string& nam) {
120  _assign(new TGeoShapeAssembly(), nam, SHAPELESS_TAG, true);
121 }
122 
123 void Scale::make(const std::string& nam, Solid base, double x_scale, double y_scale, double z_scale) {
124  auto scale = std::make_unique<TGeoScale>(x_scale, y_scale, z_scale);
125  _assign(new TGeoScaledShape(nam.c_str(), base.access(), scale.release()), "", SCALE_TAG, true);
126 }
127 
129 double Scale::scale_x() const {
130  return this->access()->GetScale()->GetScale()[0];
131 }
132 
134 double Scale::scale_y() const {
135  return this->access()->GetScale()->GetScale()[1];
136 }
137 
139 double Scale::scale_z() const {
140  return this->access()->GetScale()->GetScale()[2];
141 }
142 
143 void Box::make(const std::string& nam, double x_val, double y_val, double z_val) {
144  _assign(new TGeoBBox(nam.c_str(), x_val, y_val, z_val), "", BOX_TAG, true);
145 }
146 
148 Box& Box::setDimensions(double x_val, double y_val, double z_val) {
149  double params[] = { x_val, y_val, z_val};
150  _setDimensions(params);
151  return *this;
152 }
153 
155 double Box::x() const {
156  return this->ptr()->GetDX();
157 }
158 
160 double Box::y() const {
161  return this->ptr()->GetDY();
162 }
163 
165 double Box::z() const {
166  return this->ptr()->GetDZ();
167 }
168 
170 void HalfSpace::make(const std::string& nam, const double* const point, const double* const normal) {
171  _assign(new TGeoHalfSpace(nam.c_str(),(Double_t*)point, (Double_t*)normal), "", HALFSPACE_TAG,true);
172 }
173 
175 Polycone::Polycone(double startPhi, double deltaPhi) {
176  _assign(new TGeoPcon(startPhi/units::deg, deltaPhi/units::deg, 0), "", POLYCONE_TAG, false);
177 }
178 
180 Polycone::Polycone(double startPhi, double deltaPhi,
181  const std::vector<double>& rmin, const std::vector<double>& rmax, const std::vector<double>& z) {
182  std::vector<double> params;
183  if (rmin.size() < 2) {
184  throw std::runtime_error("dd4hep: PolyCone Not enough Z planes. minimum is 2!");
185  }
186  if((z.size()!=rmin.size()) || (z.size()!=rmax.size()) ) {
187  throw std::runtime_error("dd4hep: Polycone: vectors z,rmin,rmax not of same length");
188  }
189  params.emplace_back(startPhi/units::deg);
190  params.emplace_back(deltaPhi/units::deg);
191  params.emplace_back(rmin.size());
192  for (std::size_t i = 0; i < rmin.size(); ++i) {
193  params.emplace_back(z[i] );
194  params.emplace_back(rmin[i] );
195  params.emplace_back(rmax[i] );
196  }
197  _assign(new TGeoPcon(&params[0]), "", POLYCONE_TAG, true);
198 }
199 
201 Polycone::Polycone(double startPhi, double deltaPhi, const std::vector<double>& r, const std::vector<double>& z) {
202  std::vector<double> params;
203  if (r.size() < 2) {
204  throw std::runtime_error("dd4hep: PolyCone Not enough Z planes. minimum is 2!");
205  }
206  if((z.size()!=r.size()) ) {
207  throw std::runtime_error("dd4hep: Polycone: vectors z,r not of same length");
208  }
209  params.emplace_back(startPhi/units::deg);
210  params.emplace_back(deltaPhi/units::deg);
211  params.emplace_back(r.size());
212  for (std::size_t i = 0; i < r.size(); ++i) {
213  params.emplace_back(z[i] );
214  params.emplace_back(0.0 );
215  params.emplace_back(r[i] );
216  }
217  _assign(new TGeoPcon(&params[0]), "", POLYCONE_TAG, true);
218 }
219 
221 Polycone::Polycone(const std::string& nam, double startPhi, double deltaPhi) {
222  _assign(new TGeoPcon(nam.c_str(), startPhi/units::deg, deltaPhi/units::deg, 0), "", POLYCONE_TAG, false);
223 }
224 
226 Polycone::Polycone(const std::string& nam, double startPhi, double deltaPhi,
227  const std::vector<double>& rmin, const std::vector<double>& rmax, const std::vector<double>& z) {
228  std::vector<double> params;
229  if (rmin.size() < 2) {
230  throw std::runtime_error("dd4hep: PolyCone Not enough Z planes. minimum is 2!");
231  }
232  if((z.size()!=rmin.size()) || (z.size()!=rmax.size()) ) {
233  throw std::runtime_error("dd4hep: Polycone: vectors z,rmin,rmax not of same length");
234  }
235  params.emplace_back(startPhi/units::deg);
236  params.emplace_back(deltaPhi/units::deg);
237  params.emplace_back(rmin.size());
238  for (std::size_t i = 0; i < rmin.size(); ++i) {
239  params.emplace_back(z[i] );
240  params.emplace_back(rmin[i] );
241  params.emplace_back(rmax[i] );
242  }
243  _assign(new TGeoPcon(&params[0]), nam, POLYCONE_TAG, true);
244 }
245 
247 Polycone::Polycone(const std::string& nam, double startPhi, double deltaPhi, const std::vector<double>& r, const std::vector<double>& z) {
248  std::vector<double> params;
249  if (r.size() < 2) {
250  throw std::runtime_error("dd4hep: PolyCone Not enough Z planes. minimum is 2!");
251  }
252  if((z.size()!=r.size()) ) {
253  throw std::runtime_error("dd4hep: Polycone: vectors z,r not of same length");
254  }
255  params.emplace_back(startPhi/units::deg);
256  params.emplace_back(deltaPhi/units::deg);
257  params.emplace_back(r.size());
258  for (std::size_t i = 0; i < r.size(); ++i) {
259  params.emplace_back(z[i] );
260  params.emplace_back(0.0 );
261  params.emplace_back(r[i] );
262  }
263  _assign(new TGeoPcon(&params[0]), nam, POLYCONE_TAG, true);
264 }
265 
267 void Polycone::addZPlanes(const std::vector<double>& rmin, const std::vector<double>& rmax, const std::vector<double>& z) {
268  TGeoPcon* sh = *this;
269  std::vector<double> params;
270  std::size_t num = sh->GetNz();
271  if (num + rmin.size() < 2) {
272  except("PolyCone","++ addZPlanes: Not enough Z planes. minimum is 2!");
273  }
274  params.emplace_back(sh->GetPhi1());
275  params.emplace_back(sh->GetDphi());
276  params.emplace_back(num + rmin.size());
277  for (std::size_t i = 0; i < num; ++i) {
278  params.emplace_back(sh->GetZ(i));
279  params.emplace_back(sh->GetRmin(i));
280  params.emplace_back(sh->GetRmax(i));
281  }
282  for (std::size_t i = 0; i < rmin.size(); ++i) {
283  params.emplace_back(z[i] );
284  params.emplace_back(rmin[i] );
285  params.emplace_back(rmax[i] );
286  }
287  _setDimensions(&params[0]);
288 }
289 
291 void ConeSegment::make(const std::string& nam,
292  double dz,
293  double rmin1, double rmax1,
294  double rmin2, double rmax2,
295  double startPhi, double endPhi)
296 {
297  _assign(new TGeoConeSeg(nam.c_str(), dz, rmin1, rmax1, rmin2, rmax2,
298  startPhi/units::deg, endPhi/units::deg), "", CONESEGMENT_TAG, true);
299 }
300 
303  double rmin1, double rmax1,
304  double rmin2, double rmax2,
305  double startPhi, double endPhi) {
306  double params[] = { dz, rmin1, rmax1, rmin2, rmax2, startPhi/units::deg, endPhi/units::deg };
307  _setDimensions(params);
308  return *this;
309 }
310 
312 void Cone::make(const std::string& nam, double z, double rmin1, double rmax1, double rmin2, double rmax2) {
313  _assign(new TGeoCone(nam.c_str(), z, rmin1, rmax1, rmin2, rmax2 ), "", CONE_TAG, true);
314 }
315 
317 Cone& Cone::setDimensions(double z, double rmin1, double rmax1, double rmin2, double rmax2) {
318  double params[] = { z, rmin1, rmax1, rmin2, rmax2 };
319  _setDimensions(params);
320  return *this;
321 }
322 
324 void Tube::make(const std::string& nam, double rmin, double rmax, double z, double start_phi, double end_phi) {
325  // Check if it is a full tube
326  if(fabs(end_phi-start_phi-2*M_PI)<10e-6){
327  _assign(new TGeoTubeSeg(nam.c_str(), rmin, rmax, z, start_phi/units::deg, start_phi/units::deg+360.),nam,TUBE_TAG,true);
328  }else{
329  _assign(new TGeoTubeSeg(nam.c_str(), rmin, rmax, z, start_phi/units::deg, end_phi/units::deg),nam,TUBE_TAG,true);
330  }
331 }
332 
334 Tube& Tube::setDimensions(double rmin, double rmax, double z, double start_phi, double end_phi) {
335  double params[] = {rmin,rmax,z,start_phi/units::deg,end_phi/units::deg};
336  _setDimensions(params);
337  return *this;
338 }
339 
341 CutTube::CutTube(double rmin, double rmax, double dz, double start_phi, double end_phi,
342  double lx, double ly, double lz, double tx, double ty, double tz) {
343  make("", rmin,rmax,dz,start_phi/units::deg,end_phi/units::deg,lx,ly,lz,tx,ty,tz);
344 }
345 
347 CutTube::CutTube(const std::string& nam,
348  double rmin, double rmax, double dz, double start_phi, double end_phi,
349  double lx, double ly, double lz, double tx, double ty, double tz) {
350  make(nam, rmin,rmax,dz,start_phi/units::deg,end_phi/units::deg,lx,ly,lz,tx,ty,tz);
351 }
352 
354 void CutTube::make(const std::string& nam, double rmin, double rmax, double dz, double start_phi, double end_phi,
355  double lx, double ly, double lz, double tx, double ty, double tz) {
356  _assign(new TGeoCtub(nam.c_str(), rmin,rmax,dz,start_phi,end_phi,lx,ly,lz,tx,ty,tz),"",CUTTUBE_TAG,true);
357 }
358 
360 TruncatedTube::TruncatedTube(double dz, double rmin, double rmax, double start_phi, double delta_phi,
361  double cut_atStart, double cut_atDelta, bool cut_inside)
362 { make("", dz, rmin, rmax, start_phi/units::deg, delta_phi/units::deg, cut_atStart, cut_atDelta, cut_inside); }
363 
365 TruncatedTube::TruncatedTube(const std::string& nam,
366  double dz, double rmin, double rmax, double start_phi, double delta_phi,
367  double cut_atStart, double cut_atDelta, bool cut_inside)
368 { make(nam, dz, rmin, rmax, start_phi/units::deg, delta_phi/units::deg, cut_atStart, cut_atDelta, cut_inside); }
369 
371 void TruncatedTube::make(const std::string& nam,
372  double dz, double rmin, double rmax, double start_phi, double delta_phi,
373  double cut_atStart, double cut_atDelta, bool cut_inside) {
374  // check the parameters
375  if( rmin <= 0 || rmax <= 0 || cut_atStart <= 0 || cut_atDelta <= 0 )
376  except(TRUNCATEDTUBE_TAG,"++ 0 <= rIn,cut_atStart,rOut,cut_atDelta,rOut violated!");
377  else if( rmin >= rmax )
378  except(TRUNCATEDTUBE_TAG,"++ rIn<rOut violated!");
379  else if( start_phi != 0. )
380  except(TRUNCATEDTUBE_TAG,"++ start_phi != 0 not supported!");
381 
382  double r = cut_atStart;
383  double R = cut_atDelta;
384  // angle of the box w.r.t. tubs
385  double cath = r - R * std::cos( delta_phi*units::deg );
386  double hypo = std::sqrt( r*r + R*R - 2.*r*R * std::cos( delta_phi*units::deg ));
387  double cos_alpha = cath / hypo;
388  double alpha = std::acos( cos_alpha );
389  double sin_alpha = std::sin( std::fabs(alpha) );
390 
391  // exaggerate dimensions - does not matter, it's subtracted!
392  // If we don't, the **edge** of the box would cut into the tube segment
393  // for larger delta-phi values
394  double boxX = 1.1*rmax + rmax/sin_alpha; // Need to adjust for move!
395  double boxY = rmax;
396  // width of the box > width of the tubs
397  double boxZ = 1.1 * dz;
398  double xBox; // center point of the box
399  if( cut_inside )
400  xBox = r - boxY / sin_alpha;
401  else
402  xBox = r + boxY / sin_alpha;
403 
404  // rotationmatrix of box w.r.t. tubs
405  TGeoRotation rot;
406  rot.RotateZ( -alpha/dd4hep::deg );
407  TGeoTranslation trans(xBox, 0., 0.);
408  TGeoBBox* box = new TGeoBBox((nam+"Box").c_str(), boxX, boxY, boxZ);
409  TGeoTubeSeg* tubs = new TGeoTubeSeg((nam+"Tubs").c_str(), rmin, rmax, dz, start_phi, delta_phi);
410  TGeoCombiTrans* combi = new TGeoCombiTrans(trans, rot);
411  TGeoSubtraction* sub = new TGeoSubtraction(tubs, box, nullptr, combi);
412  _assign(new TGeoCompositeShape(nam.c_str(), sub),"",TRUNCATEDTUBE_TAG,true);
413  std::stringstream params;
414  params << dz << " " << std::endl
415  << rmin << " " << std::endl
416  << rmax << " " << std::endl
417  << start_phi*units::deg << " " << std::endl
418  << delta_phi*units::deg << " " << std::endl
419  << cut_atStart << " " << std::endl
420  << cut_atDelta << " " << std::endl
421  << char(cut_inside ? '1' : '0') << std::endl;
422  combi->SetTitle(params.str().c_str());
423  //cout << "Params: " << params.str() << std::endl;
424 #if 0
425  params << TRUNCATEDTUBE_TAG << ":" << std::endl
426  << "\t dz: " << dz << " " << std::endl
427  << "\t rmin: " << rmin << " " << std::endl
428  << "\t rmax: " << rmax << " " << std::endl
429  << "\t startPhi: " << start_phi << " " << std::endl
430  << "\t deltaPhi: " << delta_phi << " " << std::endl
431  << "\t r/cutAtStart:" << cut_atStart << " " << std::endl
432  << "\t R/cutAtDelta:" << cut_atDelta << " " << std::endl
433  << "\t cutInside: " << char(cut_inside ? '1' : '0') << std::endl
434  << "\t\t alpha: " << alpha << std::endl
435  << "\t\t sin_alpha: " << sin_alpha << std::endl
436  << "\t\t boxY: " << boxY << std::endl
437  << "\t\t xBox: " << xBox << std::endl;
438 #endif
439 #if 0
440  cout << "Trans:"; trans.Print(); cout << std::endl;
441  cout << "Rot: "; rot.Print(); cout << std::endl;
442  cout << " Dz: " << dz
443  << " rmin: " << rmin
444  << " rmax: " << rmax
445  << " r/cutAtStart: " << r
446  << " R/cutAtDelta: " << R
447  << " cutInside: " << (cut_inside ? "YES" : "NO ")
448  << std::endl;
449  cout << " cath: " << cath
450  << " hypo: " << hypo
451  << " cos_alpha: " << cos_alpha
452  << " alpha: " << alpha
453  << " alpha(deg):" << alpha/dd4hep::deg
454  << std::endl;
455  cout << " Deg: " << dd4hep::deg
456  << " cm: " << dd4hep::cm
457  << " xBox: " << xBox
458  << std::endl;
459  cout << "Box:" << "x:" << box->GetDX() << " y:" << box->GetDY() << " z:" << box->GetDZ() << std::endl;
460  cout << "Tubs:" << " rmin:" << rmin << " rmax" << rmax << "dZ" << dZ
461  << " startPhi:" << start_phi << " deltaPhi:" << delta_phi << std::endl;
462 #endif
463 }
464 
466 double TruncatedTube::dZ() const {
467  return dd4hep::dimensions<TruncatedTube>(*this)[0];
468 }
469 
471 double TruncatedTube::rMin() const {
472  return dd4hep::dimensions<TruncatedTube>(*this)[1];
473 }
474 
476 double TruncatedTube::rMax() const {
477  return dd4hep::dimensions<TruncatedTube>(*this)[2];
478 }
479 
481 double TruncatedTube::startPhi() const {
482  return dd4hep::dimensions<TruncatedTube>(*this)[3];
483 }
484 
486 double TruncatedTube::deltaPhi() const {
487  return dd4hep::dimensions<TruncatedTube>(*this)[4];
488 }
489 
492  return dd4hep::dimensions<TruncatedTube>(*this)[5];
493 }
494 
497  return dd4hep::dimensions<TruncatedTube>(*this)[6];
498 }
499 
503 }
504 
506 void EllipticalTube::make(const std::string& nam, double a, double b, double dz) {
507  _assign(new TGeoEltu(nam.c_str(), a, b, dz), "", ELLIPTICALTUBE_TAG, true);
508 }
509 
511 void TwistedTube::make(const std::string& nam, double twist_angle, double rmin, double rmax,
512  double zneg, double zpos, int nsegments, double totphi) {
513  _assign(new TwistedTubeObject(nam.c_str(), twist_angle/units::deg, rmin, rmax, zneg, zpos, nsegments, totphi/units::deg),
514  "", TWISTEDTUBE_TAG, true);
515 }
516 
518 void Trd1::make(const std::string& nam, double x1, double x2, double y, double z) {
519  _assign(new TGeoTrd1(nam.c_str(), x1, x2, y, z ), "", TRD1_TAG, true);
520 }
521 
523 Trd1& Trd1::setDimensions(double x1, double x2, double y, double z) {
524  double params[] = { x1, x2, y, z };
525  _setDimensions(params);
526  return *this;
527 }
528 
530 void Trd2::make(const std::string& nam, double x1, double x2, double y1, double y2, double z) {
531  _assign(new TGeoTrd2(nam.c_str(), x1, x2, y1, y2, z ), "", TRD2_TAG, true);
532 }
533 
535 Trd2& Trd2::setDimensions(double x1, double x2, double y1, double y2, double z) {
536  double params[] = { x1, x2, y1, y2, z };
537  _setDimensions(params);
538  return *this;
539 }
540 
542 void Paraboloid::make(const std::string& nam, double r_low, double r_high, double delta_z) {
543  _assign(new TGeoParaboloid(nam.c_str(), r_low, r_high, delta_z ), "", PARABOLOID_TAG, true);
544 }
545 
547 Paraboloid& Paraboloid::setDimensions(double r_low, double r_high, double delta_z) {
548  double params[] = { r_low, r_high, delta_z };
549  _setDimensions(params);
550  return *this;
551 }
552 
554 void Hyperboloid::make(const std::string& nam, double rin, double stin, double rout, double stout, double dz) {
555  _assign(new TGeoHype(nam.c_str(), rin, stin/units::deg, rout, stout/units::deg, dz), "", HYPERBOLOID_TAG, true);
556 }
557 
559 Hyperboloid& Hyperboloid::setDimensions(double rin, double stin, double rout, double stout, double dz) {
560  double params[] = { rin, stin/units::deg, rout, stout/units::deg, dz};
561  _setDimensions(params);
562  return *this;
563 }
564 
566 void Sphere::make(const std::string& nam, double rmin, double rmax, double startTheta, double endTheta, double startPhi, double endPhi) {
567  _assign(new TGeoSphere(nam.c_str(), rmin, rmax,
568  startTheta/units::deg, endTheta/units::deg,
569  startPhi/units::deg, endPhi/units::deg), "", SPHERE_TAG, true);
570 }
571 
573 Sphere& Sphere::setDimensions(double rmin, double rmax, double startTheta, double endTheta, double startPhi, double endPhi) {
574  double params[] = { rmin, rmax, startTheta/units::deg, endTheta/units::deg, startPhi/units::deg, endPhi/units::deg };
575  _setDimensions(params);
576  return *this;
577 }
578 
580 void Torus::make(const std::string& nam, double r, double rmin, double rmax, double startPhi, double deltaPhi) {
581  _assign(new TGeoTorus(nam.c_str(), r, rmin, rmax, startPhi/units::deg, deltaPhi/units::deg), "", TORUS_TAG, true);
582 }
583 
585 Torus& Torus::setDimensions(double r, double rmin, double rmax, double startPhi, double deltaPhi) {
586  double params[] = { r, rmin, rmax, startPhi/units::deg, deltaPhi/units::deg };
587  _setDimensions(params);
588  return *this;
589 }
590 
592 Trap::Trap(double z, double theta, double phi,
593  double h1, double bl1, double tl1, double alpha1,
594  double h2, double bl2, double tl2, double alpha2) {
595  _assign(new TGeoTrap(z, theta/units::deg, phi/units::deg,
596  h1, bl1, tl1, alpha1/units::deg,
597  h2, bl2, tl2, alpha2/units::deg), "", TRAP_TAG, true);
598 }
599 
601 Trap::Trap(const std::string& nam,
602  double z, double theta, double phi,
603  double h1, double bl1, double tl1, double alpha1,
604  double h2, double bl2, double tl2, double alpha2) {
605  _assign(new TGeoTrap(nam.c_str(), z, theta/units::deg, phi/units::deg,
606  h1, bl1, tl1, alpha1/units::deg,
607  h2, bl2, tl2, alpha2/units::deg), "", TRAP_TAG, true);
608 }
609 
611 void Trap::make(const std::string& nam, double pZ, double pY, double pX, double pLTX) {
612  double fDz = 0.5*pZ;
613  double fTheta = 0;
614  double fPhi = 0;
615  double fDy1 = 0.5*pY;
616  double fDx1 = 0.5*pX;
617  double fDx2 = 0.5*pLTX;
618  double fAlpha1 = atan(0.5*(pLTX - pX)/pY);
619  double fDy2 = fDy1;
620  double fDx3 = fDx1;
621  double fDx4 = fDx2;
622  double fAlpha2 = fAlpha1;
623 
624  _assign(new TGeoTrap(nam.c_str(),
625  fDz, fTheta /* = 0 */, fPhi /* = 0 */,
626  fDy1, fDx1, fDx2, fAlpha1/units::deg,
627  fDy2, fDx3, fDx4, fAlpha2/units::deg), "", TRAP_TAG, true);
628 }
629 
631 Trap& Trap::setDimensions(double z, double theta, double phi,
632  double h1, double bl1, double tl1, double alpha1,
633  double h2, double bl2, double tl2, double alpha2) {
634  double params[] = { z, theta/units::deg, phi/units::deg,
635  h1, bl1, tl1, alpha1/units::deg,
636  h2, bl2, tl2, alpha2/units::deg };
637  _setDimensions(params);
638  return *this;
639 }
640 
642 void PseudoTrap::make(const std::string& nam, double x1, double x2, double y1, double y2, double z, double r, bool atMinusZ) {
643  double x = atMinusZ ? x1 : x2;
644  double h = 0;
645  bool intersec = false; // union or intersection solid
646  double displacement = 0;
647  double startPhi = 0;
648  double halfZ = z;
649  double halfOpeningAngle = std::asin( x / std::abs( r ))/units::deg;
650 
652  double delta = std::sqrt( r * r - x * x );
653 
654 #if 0
655  // Implementation from : (Crappy)
656  // https://cmssdt.cern.ch/lxr/source/SimG4Core/Geometry/src/DDG4SolidConverter.cc#0362
657  if( r < 0 && std::abs(r) >= x ) {
658  intersec = true; // intersection solid
659  h = y1 < y2 ? y2 : y1; // tubs half height
660  h += h/20.; // enlarge a bit - for subtraction solid
661  if( atMinusZ ) {
662  displacement = -halfZ - delta;
663  startPhi = 270.0 - halfOpeningAngle;
664  }
665  else {
666  displacement = halfZ + delta;
667  startPhi = 90.0 - halfOpeningAngle;
668  }
669  }
670  else if( r > 0 && std::abs(r) >= x ) {
671  if( atMinusZ ) {
672  displacement = -halfZ + delta;
673  startPhi = 90.0 - halfOpeningAngle;
674  h = y1;
675  }
676  else
677  {
678  displacement = halfZ - delta;
679  startPhi = 270.0 - halfOpeningAngle;
680  h = y2;
681  }
682  }
683  else {
684  except(PSEUDOTRAP_TAG,"Check parameters of the PseudoTrap!");
685  }
686 #endif
687 
688  // Implementation from :
689  // https://cmssdt.cern.ch/lxr/source/Fireworks/Geometry/src/TGeoMgrFromDdd.cc#0538
690  if( r < 0 && std::abs(r) >= x ) {
691  intersec = true; // intersection solid
692  h = y1 < y2 ? y2 : y1; // tubs half height
693  h += h/20.; // enlarge a bit - for subtraction solid
694  if( atMinusZ ) {
695  displacement = - halfZ - delta;
696  startPhi = 90.0 - halfOpeningAngle;
697  }
698  else {
699  displacement = halfZ + delta;
700  startPhi = -90.0 - halfOpeningAngle;
701  }
702  }
703  else if( r > 0 && std::abs(r) >= x ) {
704  if( atMinusZ ) {
705  displacement = - halfZ + delta;
706  startPhi = 270.0 - halfOpeningAngle;
707  h = y1;
708  }
709  else
710  {
711  displacement = halfZ - delta;
712  startPhi = 90.0 - halfOpeningAngle;
713  h = y2;
714  }
715  }
716  else {
717  except(PSEUDOTRAP_TAG,"Check parameters of the PseudoTrap!");
718  }
719  printout(DEBUG,"PseudoTrap","++ Trd2(%s): x1=%.3g x2=%.3g y1=%.3g y2=%.3g halfZ=%.3g",
720  (nam+"Trd2").c_str(), x1, x2, y1, y2, halfZ);
721  printout(DEBUG,"PseudoTrap","++ Tubs(%s): r=%.3g h=%.3g startPhi=%.3g endPhi=%.3g",
722  (nam+"Tubs").c_str(), std::abs(r),h,startPhi,startPhi + halfOpeningAngle*2.);
723 
724  Solid trap(new TGeoTrd2((nam+"Trd2").c_str(), x1, x2, y1, y2, halfZ));
725  Solid tubs(new TGeoTubeSeg((nam+"Tubs").c_str(), 0.,std::abs(r),h,startPhi,startPhi + halfOpeningAngle*2.));
726  std::stringstream params;
727  params << x1 << " " << x2 << " " << y1 << " " << y2 << " " << z << " "
728  << r << " " << char(atMinusZ ? '1' : '0') << " ";
729  TGeoCompositeShape* solid = 0;
730  if( intersec ) {
731  printout(DEBUG,"PseudoTrap","++ Intersection displacement=%.3g", displacement);
732  solid = SubtractionSolid(nam, trap, tubs, Transform3D(RotationX(M_PI/2.), Position(0.,0.,displacement))).ptr();
733  }
734  else {
735  printout(DEBUG,"PseudoTrap","++ Union displacement=%.3g sqrt(r*r-x*x)=%.3g", displacement, std::sqrt(r*r-x*x));
736  SubtractionSolid sub((nam+"Subs").c_str(), tubs, Box(1.1*x, 1.1*h, std::sqrt(r*r-x*x)), Transform3D(RotationX(M_PI/2.)));
737  solid = UnionSolid(nam, trap, sub, Transform3D(RotationX(M_PI/2.), Position(0,0,displacement))).ptr();
738  }
739  solid->GetBoolNode()->GetRightMatrix()->SetTitle(params.str().c_str());
740  _assign(solid,"",PSEUDOTRAP_TAG, true);
741 }
742 
744 void PolyhedraRegular::make(const std::string& nam, int nsides, double rmin, double rmax,
745  double zpos, double zneg, double start, double delta) {
746  if (rmin < 0e0 || rmin > rmax)
747  throw std::runtime_error("dd4hep: PolyhedraRegular: Illegal argument rmin:<" + _toString(rmin) + "> is invalid!");
748  else if (rmax < 0e0)
749  throw std::runtime_error("dd4hep: PolyhedraRegular: Illegal argument rmax:<" + _toString(rmax) + "> is invalid!");
750  double params[] = { start/units::deg, delta/units::deg, double(nsides), 2e0, zpos, rmin, rmax, zneg, rmin, rmax };
751  _assign(new TGeoPgon(params), nam, POLYHEDRA_TAG, false);
752  //_setDimensions(&params[0]);
753 }
754 
756 void Polyhedra::make(const std::string& nam, int nsides, double start, double delta,
757  const std::vector<double>& z, const std::vector<double>& rmin, const std::vector<double>& rmax) {
758  std::vector<double> temp;
759  if ( rmin.size() != z.size() || rmax.size() != z.size() ) {
760  except("Polyhedra",
761  "Number of values to define zplanes are incorrect: z:%ld rmin:%ld rmax:%ld",
762  z.size(), rmin.size(), rmax.size());
763  }
764  // No need to transform coordinates to cm. We are in the dd4hep world: all is already in cm.
765  temp.reserve(4+z.size()*2);
766  temp.emplace_back(start/units::deg);
767  temp.emplace_back(delta/units::deg);
768  temp.emplace_back(double(nsides));
769  temp.emplace_back(double(z.size()));
770  for(std::size_t i=0; i<z.size(); ++i) {
771  temp.emplace_back(z[i]);
772  temp.emplace_back(rmin[i]);
773  temp.emplace_back(rmax[i]);
774  }
775  _assign(new TGeoPgon(&temp[0]), nam, POLYHEDRA_TAG, false);
776 }
777 
779 void ExtrudedPolygon::make(const std::string& nam,
780  const std::vector<double>& pt_x,
781  const std::vector<double>& pt_y,
782  const std::vector<double>& sec_z,
783  const std::vector<double>& sec_x,
784  const std::vector<double>& sec_y,
785  const std::vector<double>& sec_scale)
786 {
787  TGeoXtru* solid = new TGeoXtru(sec_z.size());
788  _assign(solid, nam, EXTRUDEDPOLYGON_TAG, false);
789  // No need to transform coordinates to cm. We are in the dd4hep world: all is already in cm.
790  solid->DefinePolygon(pt_x.size(), &(*pt_x.begin()), &(*pt_y.begin()));
791  for( std::size_t i = 0; i < sec_z.size(); ++i )
792  solid->DefineSection(i, sec_z[i], sec_x[i], sec_y[i], sec_scale[i]);
793 }
794 
796 void EightPointSolid::make(const std::string& nam, double dz, const double* vtx) {
797  _assign(new TGeoArb8(nam.c_str(), dz, (double*)vtx), "", EIGHTPOINTSOLID_TAG, true);
798 }
799 
801 void TessellatedSolid::make(const std::string& nam, int num_facets) {
802  _assign(new TGeoTessellated(nam.c_str(), num_facets), nam, TESSELLATEDSOLID_TAG, false);
803 }
804 
806 void TessellatedSolid::make(const std::string& nam, const std::vector<Vertex>& vertices) {
807  _assign(new TGeoTessellated(nam.c_str(), vertices), nam, TESSELLATEDSOLID_TAG, false);
808 }
809 
811 bool TessellatedSolid::addFacet(const Vertex& pt0, const Vertex& pt1, const Vertex& pt2) const {
812  return access()->AddFacet(pt0, pt1, pt2);
813 }
814 
816 bool TessellatedSolid::addFacet(const Vertex& pt0, const Vertex& pt1, const Vertex& pt2, const Vertex& pt3) const {
817  return access()->AddFacet(pt0, pt1, pt2, pt3);
818 }
819 
821 bool TessellatedSolid::addFacet(const int pt0, const int pt1, const int pt2) const {
822  return access()->AddFacet(pt0, pt1, pt2);
823 }
824 
826 bool TessellatedSolid::addFacet(const int pt0, const int pt1, const int pt2, const int pt3) const {
827  return access()->AddFacet(pt0, pt1, pt2, pt3);
828 }
829 
832  return access()->GetNvertices();
833 }
834 
837  return ptr()->GetFacet(index);
838 }
839 
842  return access()->GetNvertices();
843 }
844 
847  return ptr()->GetVertex(index);
848 }
849 
852  return access()->GetBoolNode()->GetRightShape();
853 }
854 
857  return access()->GetBoolNode()->GetLeftShape();
858 }
859 
861 const TGeoMatrix* BooleanSolid::rightMatrix() const {
862  return access()->GetBoolNode()->GetRightMatrix();
863 }
864 
866 const TGeoMatrix* BooleanSolid::leftMatrix() const {
867  return access()->GetBoolNode()->GetLeftMatrix();
868 }
869 
871 SubtractionSolid::SubtractionSolid(const Solid& shape1, const Solid& shape2) {
872  TGeoSubtraction* sub = new TGeoSubtraction(shape1, shape2, detail::matrix::_identity(), detail::matrix::_identity());
873  _assign(new TGeoCompositeShape("", sub), "", SUBTRACTION_TAG, true);
874 }
875 
877 SubtractionSolid::SubtractionSolid(const Solid& shape1, const Solid& shape2, const Transform3D& trans) {
878  TGeoSubtraction* sub = new TGeoSubtraction(shape1, shape2, detail::matrix::_identity(), detail::matrix::_transform(trans));
879  _assign(new TGeoCompositeShape("", sub), "", SUBTRACTION_TAG, true);
880 }
881 
883 SubtractionSolid::SubtractionSolid(const Solid& shape1, const Solid& shape2, const Position& pos) {
884  TGeoSubtraction* sub = new TGeoSubtraction(shape1, shape2, detail::matrix::_identity(), detail::matrix::_translation(pos));
885  _assign(new TGeoCompositeShape("", sub), "", SUBTRACTION_TAG, true);
886 }
887 
889 SubtractionSolid::SubtractionSolid(const Solid& shape1, const Solid& shape2, const RotationZYX& rot) {
890  TGeoSubtraction* sub = new TGeoSubtraction(shape1, shape2, detail::matrix::_identity(), detail::matrix::_rotationZYX(rot));
891  _assign(new TGeoCompositeShape("", sub), "", SUBTRACTION_TAG, true);
892 }
893 
895 SubtractionSolid::SubtractionSolid(const Solid& shape1, const Solid& shape2, const Rotation3D& rot) {
896  TGeoSubtraction* sub = new TGeoSubtraction(shape1, shape2, detail::matrix::_identity(), detail::matrix::_rotation3D(rot));
897  _assign(new TGeoCompositeShape("", sub), "", SUBTRACTION_TAG, true);
898 }
899 
901 SubtractionSolid::SubtractionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2) {
902  TGeoSubtraction* sub = new TGeoSubtraction(shape1, shape2, detail::matrix::_identity(), detail::matrix::_identity());
903  _assign(new TGeoCompositeShape(nam.c_str(), sub), "", SUBTRACTION_TAG, true);
904 }
905 
907 SubtractionSolid::SubtractionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const Transform3D& trans) {
908  TGeoSubtraction* sub = new TGeoSubtraction(shape1, shape2, detail::matrix::_identity(), detail::matrix::_transform(trans));
909  _assign(new TGeoCompositeShape(nam.c_str(), sub), "", SUBTRACTION_TAG, true);
910 }
911 
913 SubtractionSolid::SubtractionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const Position& pos) {
914  TGeoSubtraction* sub = new TGeoSubtraction(shape1, shape2, detail::matrix::_identity(), detail::matrix::_translation(pos));
915  _assign(new TGeoCompositeShape(nam.c_str(), sub), "", SUBTRACTION_TAG, true);
916 }
917 
919 SubtractionSolid::SubtractionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const RotationZYX& rot) {
920  TGeoSubtraction* sub = new TGeoSubtraction(shape1, shape2, detail::matrix::_identity(), detail::matrix::_rotationZYX(rot));
921  _assign(new TGeoCompositeShape(nam.c_str(), sub), "", SUBTRACTION_TAG, true);
922 }
923 
925 SubtractionSolid::SubtractionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const Rotation3D& rot) {
926  TGeoSubtraction* sub = new TGeoSubtraction(shape1, shape2, detail::matrix::_identity(), detail::matrix::_rotation3D(rot));
927  _assign(new TGeoCompositeShape(nam.c_str(), sub), "", SUBTRACTION_TAG, true);
928 }
929 
931 UnionSolid::UnionSolid(const Solid& shape1, const Solid& shape2) {
932  TGeoUnion* uni = new TGeoUnion(shape1, shape2, detail::matrix::_identity(), detail::matrix::_identity());
933  _assign(new TGeoCompositeShape("", uni), "", UNION_TAG, true);
934 }
935 
937 UnionSolid::UnionSolid(const Solid& shape1, const Solid& shape2, const Transform3D& trans) {
938  TGeoUnion* uni = new TGeoUnion(shape1, shape2, detail::matrix::_identity(), detail::matrix::_transform(trans));
939  _assign(new TGeoCompositeShape("", uni), "", UNION_TAG, true);
940 }
941 
943 UnionSolid::UnionSolid(const Solid& shape1, const Solid& shape2, const Position& pos) {
944  TGeoUnion* uni = new TGeoUnion(shape1, shape2, detail::matrix::_identity(), detail::matrix::_translation(pos));
945  _assign(new TGeoCompositeShape("", uni), "", UNION_TAG, true);
946 }
947 
949 UnionSolid::UnionSolid(const Solid& shape1, const Solid& shape2, const RotationZYX& rot) {
950  TGeoUnion *uni = new TGeoUnion(shape1, shape2, detail::matrix::_identity(), detail::matrix::_rotationZYX(rot));
951  _assign(new TGeoCompositeShape("", uni), "", UNION_TAG, true);
952 }
953 
955 UnionSolid::UnionSolid(const Solid& shape1, const Solid& shape2, const Rotation3D& rot) {
956  TGeoUnion *uni = new TGeoUnion(shape1, shape2, detail::matrix::_identity(), detail::matrix::_rotation3D(rot));
957  _assign(new TGeoCompositeShape("", uni), "", UNION_TAG, true);
958 }
959 
961 UnionSolid::UnionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2) {
962  TGeoUnion* uni = new TGeoUnion(shape1, shape2, detail::matrix::_identity(), detail::matrix::_identity());
963  _assign(new TGeoCompositeShape(nam.c_str(), uni), "", UNION_TAG, true);
964 }
965 
967 UnionSolid::UnionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const Transform3D& trans) {
968  TGeoUnion* uni = new TGeoUnion(shape1, shape2, detail::matrix::_identity(), detail::matrix::_transform(trans));
969  _assign(new TGeoCompositeShape(nam.c_str(), uni), "", UNION_TAG, true);
970 }
971 
973 UnionSolid::UnionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const Position& pos) {
974  TGeoUnion* uni = new TGeoUnion(shape1, shape2, detail::matrix::_identity(), detail::matrix::_translation(pos));
975  _assign(new TGeoCompositeShape(nam.c_str(), uni), "", UNION_TAG, true);
976 }
977 
979 UnionSolid::UnionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const RotationZYX& rot) {
980  TGeoUnion *uni = new TGeoUnion(shape1, shape2, detail::matrix::_identity(), detail::matrix::_rotationZYX(rot));
981  _assign(new TGeoCompositeShape(nam.c_str(), uni), "", UNION_TAG, true);
982 }
983 
985 UnionSolid::UnionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const Rotation3D& rot) {
986  TGeoUnion *uni = new TGeoUnion(shape1, shape2, detail::matrix::_identity(), detail::matrix::_rotation3D(rot));
987  _assign(new TGeoCompositeShape(nam.c_str(), uni), "", UNION_TAG, true);
988 }
989 
991 IntersectionSolid::IntersectionSolid(const Solid& shape1, const Solid& shape2) {
992  TGeoIntersection* inter = new TGeoIntersection(shape1, shape2, detail::matrix::_identity(), detail::matrix::_identity());
993  _assign(new TGeoCompositeShape("", inter), "", INTERSECTION_TAG, true);
994 }
995 
997 IntersectionSolid::IntersectionSolid(const Solid& shape1, const Solid& shape2, const Transform3D& trans) {
998  TGeoIntersection* inter = new TGeoIntersection(shape1, shape2, detail::matrix::_identity(), detail::matrix::_transform(trans));
999  _assign(new TGeoCompositeShape("", inter), "", INTERSECTION_TAG, true);
1000 }
1001 
1003 IntersectionSolid::IntersectionSolid(const Solid& shape1, const Solid& shape2, const Position& pos) {
1004  TGeoIntersection* inter = new TGeoIntersection(shape1, shape2, detail::matrix::_identity(), detail::matrix::_translation(pos));
1005  _assign(new TGeoCompositeShape("", inter), "", INTERSECTION_TAG, true);
1006 }
1007 
1009 IntersectionSolid::IntersectionSolid(const Solid& shape1, const Solid& shape2, const RotationZYX& rot) {
1010  TGeoIntersection* inter = new TGeoIntersection(shape1, shape2, detail::matrix::_identity(), detail::matrix::_rotationZYX(rot));
1011  _assign(new TGeoCompositeShape("", inter), "", INTERSECTION_TAG, true);
1012 }
1013 
1015 IntersectionSolid::IntersectionSolid(const Solid& shape1, const Solid& shape2, const Rotation3D& rot) {
1016  TGeoIntersection* inter = new TGeoIntersection(shape1, shape2, detail::matrix::_identity(), detail::matrix::_rotation3D(rot));
1017  _assign(new TGeoCompositeShape("", inter), "", INTERSECTION_TAG, true);
1018 }
1019 
1021 IntersectionSolid::IntersectionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2) {
1022  TGeoIntersection* inter = new TGeoIntersection(shape1, shape2, detail::matrix::_identity(), detail::matrix::_identity());
1023  _assign(new TGeoCompositeShape(nam.c_str(), inter), "", INTERSECTION_TAG, true);
1024 }
1025 
1027 IntersectionSolid::IntersectionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const Transform3D& trans) {
1028  TGeoIntersection* inter = new TGeoIntersection(shape1, shape2, detail::matrix::_identity(), detail::matrix::_transform(trans));
1029  _assign(new TGeoCompositeShape(nam.c_str(), inter), "", INTERSECTION_TAG, true);
1030 }
1031 
1033 IntersectionSolid::IntersectionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const Position& pos) {
1034  TGeoIntersection* inter = new TGeoIntersection(shape1, shape2, detail::matrix::_identity(), detail::matrix::_translation(pos));
1035  _assign(new TGeoCompositeShape(nam.c_str(), inter), "", INTERSECTION_TAG, true);
1036 }
1037 
1039 IntersectionSolid::IntersectionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const RotationZYX& rot) {
1040  TGeoIntersection* inter = new TGeoIntersection(shape1, shape2, detail::matrix::_identity(), detail::matrix::_rotationZYX(rot));
1041  _assign(new TGeoCompositeShape(nam.c_str(), inter), "", INTERSECTION_TAG, true);
1042 }
1043 
1045 IntersectionSolid::IntersectionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const Rotation3D& rot) {
1046  TGeoIntersection* inter = new TGeoIntersection(shape1, shape2, detail::matrix::_identity(), detail::matrix::_rotation3D(rot));
1047  _assign(new TGeoCompositeShape(nam.c_str(), inter), "", INTERSECTION_TAG, true);
1048 }
1049 
1050 
1051 #define INSTANTIATE(X) template class dd4hep::Solid_type<X>
1053 INSTANTIATE(TGeoShape);
1054 INSTANTIATE(TGeoBBox);
1055 INSTANTIATE(TGeoHalfSpace);
1056 INSTANTIATE(TGeoCone);
1058 INSTANTIATE(TGeoParaboloid);
1059 INSTANTIATE(TGeoPcon);
1060 INSTANTIATE(TGeoPgon);
1061 INSTANTIATE(TGeoSphere);
1062 INSTANTIATE(TGeoTorus);
1063 INSTANTIATE(TGeoTube);
1064 INSTANTIATE(TGeoTubeSeg);
1065 INSTANTIATE(TGeoEltu);
1066 INSTANTIATE(TGeoXtru);
1067 INSTANTIATE(TGeoGtra);
1068 INSTANTIATE(TGeoHype);
1069 INSTANTIATE(TGeoTrap);
1070 INSTANTIATE(TGeoTrd1);
1071 INSTANTIATE(TGeoTrd2);
1072 INSTANTIATE(TGeoCtub);
1073 INSTANTIATE(TGeoScaledShape);
1074 INSTANTIATE(TGeoCompositeShape);
1075 INSTANTIATE(TGeoTessellated);
dd4hep::Solid_type::_assign
void _assign(T *n, const std::string &nam, const std::string &tit, bool cbbox)
Assign pointrs and register solid to geometry.
Definition: Shapes.cpp:47
dd4hep::detail::matrix::_translation
TGeoTranslation * _translation(const Position &pos)
Convert a Position object to a TGeoTranslation.
Definition: MatrixHelpers.cpp:55
dd4hep::ConeSegment::endPhi
double endPhi() const
Accessor: end-phi value.
Definition: Shapes.h:603
dd4hep::Torus::setDimensions
Torus & setDimensions(double r, double rmin, double rmax, double startPhi, double deltaPhi)
Set the Torus dimensions.
Definition: Shapes.cpp:585
dd4hep::TruncatedTube::rMax
double rMax() const
Accessor: r-max value.
Definition: Shapes.cpp:476
dd4hep::UnionSolid::UnionSolid
UnionSolid()=default
Default constructor.
dd4hep::TruncatedTube::cutInside
bool cutInside() const
Accessor: cut-inside value.
Definition: Shapes.cpp:501
dd4hep::VolumeMulti
Implementation class extending the ROOT mulit-volumes (TGeoVolumeMulti)
Definition: Volumes.h:728
dd4hep::HalfSpace::normal
Direction normal() const
Accessor: normal vector spanning plane at positioning point.
Definition: Shapes.h:387
dd4hep::Paraboloid::make
void make(const std::string &nam, double r_low, double r_high, double delta_z)
Constructor function to create a new anonymous object with attribute initialization.
Definition: Shapes.cpp:542
dd4hep::TruncatedTube::startPhi
double startPhi() const
Accessor: start-phi value.
Definition: Shapes.cpp:481
INSTANTIATE
#define INSTANTIATE(X)
Definition: Shapes.cpp:1051
dd4hep::Trd2::make
void make(const std::string &nam, double x1, double x2, double y1, double y2, double z)
Internal helper method to support object construction.
Definition: Shapes.cpp:530
dd4hep::TruncatedTube::deltaPhi
double deltaPhi() const
Accessor: delta-phi value.
Definition: Shapes.cpp:486
dd4hep::Solid_type::title
const char * title() const
Access to shape title (GetTitle accessor of the TGeoShape)
Definition: Shapes.cpp:62
dd4hep::PseudoTrap::make
void make(const std::string &nam, double x1, double x2, double y1, double y2, double z, double radius, bool minusZ)
Internal helper method to support object construction.
Definition: Shapes.cpp:642
dd4hep::Trap::setDimensions
Trap & setDimensions(double z, double theta, double phi, double h1, double bl1, double tl1, double alpha1, double h2, double bl2, double tl2, double alpha2)
Set the trap dimensions.
Definition: Shapes.cpp:631
dd4hep::Trap::make
void make(const std::string &name, double pz, double py, double px, double pLTX)
Internal helper method to support object construction.
Definition: Shapes.cpp:611
dd4hep::TessellatedSolid::num_vertex
int num_vertex() const
Access the number of vertices in the shape.
Definition: Shapes.cpp:841
TRD2_TAG
#define TRD2_TAG
Definition: ShapeTags.h:25
dd4hep::TruncatedTube::TruncatedTube
TruncatedTube()=default
Default constructor.
dd4hep::BooleanSolid::leftShape
Solid leftShape() const
Access left solid of the boolean.
Definition: Shapes.cpp:856
dd4hep::detail::matrix::_rotationZYX
TGeoRotation * _rotationZYX(const RotationZYX &rot)
Convert a RotationZYX object to a newly created TGeoRotation.
Definition: MatrixHelpers.cpp:59
MatrixHelpers.h
dd4hep::Torus
Class describing a Torus shape.
Definition: Shapes.h:1226
Detector.h
M_PI
#define M_PI
Definition: Handle.h:33
POLYCONE_TAG
#define POLYCONE_TAG
Definition: ShapeTags.h:19
TESSELLATEDSOLID_TAG
#define TESSELLATEDSOLID_TAG
Definition: ShapeTags.h:37
HALFSPACE_TAG
#define HALFSPACE_TAG
Definition: ShapeTags.h:18
ShapeTags.h
dd4hep::Box::x
double x() const
Access half "length" of the box.
Definition: Shapes.cpp:155
SPHERE_TAG
#define SPHERE_TAG
Definition: ShapeTags.h:30
delta
const Delta * delta
Definition: AlignmentsCalculator.cpp:67
dd4hep::Sphere::startTheta
double startTheta() const
Accessor: start-theta value.
Definition: Shapes.h:1359
dd4hep::detail::matrix::_identity
TGeoIdentity * _identity()
Access the TGeo identity transformation.
Definition: MatrixHelpers.cpp:27
dd4hep::Hyperboloid
Class describing a Hyperboloid shape.
Definition: Shapes.h:1434
dd4hep::TruncatedTube::dZ
double dZ() const
Accessor: z-half value.
Definition: Shapes.cpp:466
dd4hep::detail::matrix::_transform
TGeoHMatrix * _transform(const Transform3D &trans)
Convert a Transform3D object to a newly created TGeoHMatrix.
Definition: MatrixHelpers.cpp:140
dd4hep::_toString
std::string _toString(bool value)
String conversions: boolean value to string.
Definition: Handle.cpp:332
dd4hep::detail::matrix::_rotation3D
TGeoRotation * _rotation3D(const Rotation3D &rot)
Convert a Rotation3D object to a newly createdTGeoRotation.
Definition: MatrixHelpers.cpp:63
dd4hep::Rotation3D
ROOT::Math::Rotation3D Rotation3D
Definition: Objects.h:113
dd4hep::Polycone::z
double z(int which) const
Accessor: z value.
Definition: Shapes.h:516
dd4hep::Trap
Class describing a trap shape.
Definition: Shapes.h:974
dd4hep::Solid_type
Base class for Solid (shape) objects.
Definition: Shapes.h:135
dd4hep::ConeSegment::setDimensions
ConeSegment & setDimensions(double dz, double rmin1, double rmax1, double rmin2, double rmax2, double startPhi=0.0, double endPhi=2.0 *M_PI)
Set the cone segment dimensions.
Definition: Shapes.cpp:302
SCALE_TAG
#define SCALE_TAG
Definition: ShapeTags.h:33
TRD1_TAG
#define TRD1_TAG
Definition: ShapeTags.h:24
dd4hep::Handle::name
const char * name() const
Access the object name (or "" if not supported by the object)
dd4hep::SubtractionSolid::SubtractionSolid
SubtractionSolid()=default
Default constructor.
TUBE_TAG
#define TUBE_TAG
Definition: ShapeTags.h:21
dd4hep::Solid_type::divide
TGeoVolume * divide(const Volume &voldiv, const std::string &divname, int iaxis, int ndiv, double start, double step) const
Divide volume into subsections (See the ROOT manuloa for details)
Definition: Shapes.cpp:102
UNION_TAG
#define UNION_TAG
Definition: ShapeTags.h:41
dd4hep::TessellatedSolid::Facet
TGeoFacet Facet
Definition: Shapes.h:1781
dd4hep::HalfSpace::make
void make(const std::string &name, const double *const point, const double *const normal)
Internal helper method to support object construction.
Definition: Shapes.cpp:170
dd4hep::Box::z
double z() const
Access half "depth" of the box.
Definition: Shapes.cpp:165
TRAP_TAG
#define TRAP_TAG
Definition: ShapeTags.h:32
dd4hep::Box::y
double y() const
Access half "width" of the box.
Definition: Shapes.cpp:160
epsilon
const double epsilon
Definition: test_cellid_position_converter.cpp:42
dd4hep::Scale::make
void make(const std::string &name, Solid base_solid, double x_scale, double y_scale, double z_scale)
Internal helper method to support object construction.
Definition: Shapes.cpp:123
dd4hep::Torus::deltaPhi
double deltaPhi() const
Accessor: delta-phi value.
Definition: Shapes.h:1268
dd4hep::ConeSegment
Class describing a cone segment shape.
Definition: Shapes.h:542
dd4hep::TruncatedTube::cutAtStart
double cutAtStart() const
Accessor: cut at start value.
Definition: Shapes.cpp:491
dd4hep::Trd2
Class describing a Trd2 shape.
Definition: Shapes.h:1163
dd4hep::TwistedTubeObject
Concrete object implementation for the Header handle.
Definition: ShapesInterna.h:29
dd4hep::Trd1::make
void make(const std::string &nam, double x1, double x2, double y, double z)
Internal helper method to support object construction.
Definition: Shapes.cpp:518
dd4hep::IntersectionSolid::IntersectionSolid
IntersectionSolid()=default
Default constructor.
dd4hep::TessellatedSolid::addFacet
bool addFacet(const Vertex &pt0, const Vertex &pt1, const Vertex &pt2) const
Add new facet to the shape.
Definition: Shapes.cpp:811
dd4hep::Paraboloid::setDimensions
Paraboloid & setDimensions(double r_low, double r_high, double delta_z)
Set the Paraboloid dimensions.
Definition: Shapes.cpp:547
dd4hep::Sphere::endPhi
double endPhi() const
Accessor: end-phi value.
Definition: Shapes.h:1357
dd4hep::CutTube::make
void make(const std::string &name, double rmin, double rmax, double dz, double startPhi, double endPhi, double lx, double ly, double lz, double tx, double ty, double tz)
Internal helper method to support object construction.
Definition: Shapes.cpp:354
dd4hep::Volume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:378
dd4hep::TessellatedSolid::make
void make(const std::string &nam, int num_facets)
Internal helper method to support object construction.
Definition: Shapes.cpp:801
dd4hep::Solid_type::name
const char * name() const
Access to shape name.
Definition: Shapes.cpp:54
dd4hep::Torus::startPhi
double startPhi() const
Accessor: start-phi value.
Definition: Shapes.h:1266
dd4hep::Sphere::endTheta
double endTheta() const
Accessor: end-theta value.
Definition: Shapes.h:1361
dd4hep::Cone::setDimensions
Cone & setDimensions(double z, double rmin1, double rmax1, double rmin2, double rmax2)
Set the box dimensions.
Definition: Shapes.cpp:317
dd4hep::Trap::theta
double theta() const
Accessor: theta value.
Definition: Shapes.h:1026
dd4hep::EllipticalTube::b
double b() const
Accessor: b value (semi axis along y)
Definition: Shapes.h:885
dd4hep::Polyhedra::z
double z(int which) const
Accessor: z value.
Definition: Shapes.h:1635
TWISTEDTUBE_TAG
#define TWISTEDTUBE_TAG
Definition: ShapeTags.h:29
dd4hep::Hyperboloid::make
void make(const std::string &nam, double rin, double stin, double rout, double stout, double dz)
Constructor function to create a new anonymous object with attribute initialization.
Definition: Shapes.cpp:554
ShapesInterna.h
dd4hep::Trd1::setDimensions
Trd1 & setDimensions(double x1, double x2, double y, double z)
Set the Trd1 dimensions.
Definition: Shapes.cpp:523
CONE_TAG
#define CONE_TAG
Definition: ShapeTags.h:20
dd4hep::Solid_type::_setDimensions
void _setDimensions(double *param) const
Definition: Shapes.cpp:39
PARABOLOID_TAG
#define PARABOLOID_TAG
Definition: ShapeTags.h:26
dd4hep::Sphere::make
void make(const std::string &nam, double rmin, double rmax, double startTheta, double endTheta, double startPhi, double endPhi)
Constructor function to be used when creating a new object with attribute initialization.
Definition: Shapes.cpp:566
dd4hep::Trap::alpha2
double alpha2() const
Angle between centers of x edges and y axis at low z.
Definition: Shapes.h:1030
dd4hep::Torus::make
void make(const std::string &nam, double r, double rmin, double rmax, double startPhi, double deltaPhi)
Internal helper method to support object construction.
Definition: Shapes.cpp:580
TRUNCATEDTUBE_TAG
#define TRUNCATEDTUBE_TAG
Definition: ShapeTags.h:39
dd4hep::TwistedTube::make
void make(const std::string &nam, double twist_angle, double rmin, double rmax, double zneg, double zpos, int nsegments, double totphi)
Internal helper method to support TwistedTube object construction.
Definition: Shapes.cpp:511
dd4hep::TruncatedTube::rMin
double rMin() const
Accessor: r-min value.
Definition: Shapes.cpp:471
SHAPELESS_TAG
#define SHAPELESS_TAG
Definition: ShapeTags.h:16
dd4hep::Torus::r
double r() const
Accessor: r value (torus axial radius)
Definition: Shapes.h:1271
dd4hep::set_shape_dimensions
void set_shape_dimensions(TGeoShape *shape, const std::vector< double > &params)
Set the shape dimensions (As for the TGeo shape, but angles in rad rather than degrees)
Definition: ShapeUtilities.cpp:1139
dd4hep::ConeSegment::startPhi
double startPhi() const
Accessor: start-phi value.
Definition: Shapes.h:601
dd4hep::Cone
Class describing a cone shape.
Definition: Shapes.h:402
dd4hep::Polycone::Polycone
Polycone()=default
Default constructor.
dd4hep::Polycone::addZPlanes
void addZPlanes(const std::vector< double > &rmin, const std::vector< double > &rmax, const std::vector< double > &z)
Add Z-planes to the Polycone.
Definition: Shapes.cpp:267
SUBTRACTION_TAG
#define SUBTRACTION_TAG
Definition: ShapeTags.h:42
dd4hep::TessellatedSolid::vertex
const Vertex & vertex(int index) const
Access a single vertex from the shape.
Definition: Shapes.cpp:846
dd4hep::Scale::scale_y
double scale_y() const
Access y-scale factor.
Definition: Shapes.cpp:134
dd4hep::get_shape_dimensions
std::vector< double > get_shape_dimensions(TGeoShape *shape)
Access Shape dimension parameters (As in TGeo, but angles in radians rather than degrees)
Definition: ShapeUtilities.cpp:607
dd4hep::Trd1
Class describing a Trd1 shape.
Definition: Shapes.h:1103
CUTTUBE_TAG
#define CUTTUBE_TAG
Definition: ShapeTags.h:22
EIGHTPOINTSOLID_TAG
#define EIGHTPOINTSOLID_TAG
Definition: ShapeTags.h:36
dd4hep::Cone::make
void make(const std::string &name, double z, double rmin1, double rmax1, double rmin2, double rmax2)
Internal helper method to support object construction.
Definition: Shapes.cpp:312
dd4hep::TessellatedSolid::facet
const Facet & facet(int index) const
Access a facet from the built shape.
Definition: Shapes.cpp:836
PSEUDOTRAP_TAG
#define PSEUDOTRAP_TAG
Definition: ShapeTags.h:40
dd4hep::PolyhedraRegular::make
void make(const std::string &nam, int nsides, double rmin, double rmax, double zpos, double zneg, double start, double delta)
Helper function to create the polyhedron.
Definition: Shapes.cpp:744
dd4hep::UnionSolid
Class describing boolean union solid.
Definition: Shapes.h:1926
dd4hep::EightPointSolid::make
void make(const std::string &nam, double dz, const double *vtx)
Internal helper method to support object construction.
Definition: Shapes.cpp:796
EXTRUDEDPOLYGON_TAG
#define EXTRUDEDPOLYGON_TAG
Definition: ShapeTags.h:35
dd4hep::Trd2::setDimensions
Trd2 & setDimensions(double x1, double x2, double y1, double y2, double z)
Set the Trd2 dimensions.
Definition: Shapes.cpp:535
dd4hep::ExtrudedPolygon::make
void make(const std::string &nam, const std::vector< double > &pt_x, const std::vector< double > &pt_y, const std::vector< double > &sec_z, const std::vector< double > &sec_x, const std::vector< double > &sec_y, const std::vector< double > &zscale)
Helper function to create the polygon.
Definition: Shapes.cpp:779
dd4hep::Transform3D
ROOT::Math::Transform3D Transform3D
Definition: Objects.h:117
dd4hep::CutTube::CutTube
CutTube()=default
Default constructor.
dd4hep::Position
ROOT::Math::XYZVector Position
Definition: Objects.h:81
dd4hep::Box::make
void make(const std::string &name, double x_val, double y_val, double z_val)
Internal helper method to support object construction.
Definition: Shapes.cpp:143
CONESEGMENT_TAG
#define CONESEGMENT_TAG
Definition: ShapeTags.h:23
dd4hep::Box
Class describing a box shape.
Definition: Shapes.h:294
dd4hep::Sphere::startPhi
double startPhi() const
Accessor: start-phi value.
Definition: Shapes.h:1355
dd4hep::Trap::phi
double phi() const
Accessor: phi value.
Definition: Shapes.h:1024
dd4hep::Handle::access
T * access() const
Checked object access. Throws invalid handle runtime exception if invalid handle.
dd4hep::Scale::scale_x
double scale_x() const
Access x-scale factor.
Definition: Shapes.cpp:129
dd4hep::Handle::ptr
T * ptr() const
Access to the held object.
Definition: Handle.h:153
dd4hep::ConeSegment::make
void make(const std::string &name, double dz, double rmin1, double rmax1, double rmin2, double rmax2, double startPhi, double endPhi)
Constructor to be used when creating a new cone segment object.
Definition: Shapes.cpp:291
dd4hep::Polycone::startPhi
double startPhi() const
Accessor: start-phi value.
Definition: Shapes.h:511
dd4hep::Box::setDimensions
Box & setDimensions(double x_val, double y_val, double z_val)
Set the box dimensions.
Definition: Shapes.cpp:148
TORUS_TAG
#define TORUS_TAG
Definition: ShapeTags.h:31
dd4hep::TruncatedTube::cutAtDelta
double cutAtDelta() const
Accessor: cut at delta value.
Definition: Shapes.cpp:496
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::Sphere
Class describing a sphere shape.
Definition: Shapes.h:1288
dd4hep::Solid_type::setDimensions
Solid_type & setDimensions(const std::vector< double > &params)
Set the shape dimensions. As for the TGeo shape, but angles in rad rather than degrees.
Definition: Shapes.cpp:95
dd4hep::Solid_type::type
const char * type() const
Access to shape type (The TClass name of the ROOT implementation)
Definition: Shapes.cpp:82
dd4hep::TessellatedSolid::Vertex
Object::Vertex_t Vertex
Definition: Shapes.h:1780
dd4hep::EllipticalTube::a
double a() const
Accessor: a value (semi axis along x)
Definition: Shapes.h:883
BOX_TAG
#define BOX_TAG
Definition: ShapeTags.h:17
dd4hep::Tube::setDimensions
Tube & setDimensions(double rmin, double rmax, double dz, double startPhi=0.0, double endPhi=2 *M_PI)
Set the tube dimensions.
Definition: Shapes.cpp:334
TGeoConeSeg
Class of the ROOT toolkit. See http://root.cern.ch/root/htmldoc/ClassIndex.html.
Definition: ROOTClasses.h:17
dd4hep::Polycone::deltaPhi
double deltaPhi() const
Accessor: delta-phi value.
Definition: Shapes.h:513
dd4hep::RotationX
ROOT::Math::RotationX RotationX
Definition: Objects.h:111
INTERSECTION_TAG
#define INTERSECTION_TAG
Definition: ShapeTags.h:43
dd4hep::BooleanSolid::rightMatrix
const TGeoMatrix * rightMatrix() const
Access right positioning matrix of the boolean.
Definition: Shapes.cpp:861
HYPERBOLOID_TAG
#define HYPERBOLOID_TAG
Definition: ShapeTags.h:27
dd4hep::EllipticalTube::make
void make(const std::string &nam, double a, double b, double dz)
Internal helper method to support object construction.
Definition: Shapes.cpp:506
dd4hep::dimensions< TruncatedTube >
std::vector< double > dimensions< TruncatedTube >(const Handle< TGeoShape > &shape)
Definition: ShapeUtilities.cpp:518
dd4hep::ShapelessSolid::ShapelessSolid
ShapelessSolid()=default
Default constructor.
dd4hep::BooleanSolid::rightShape
Solid rightShape() const
Access right solid of the boolean.
Definition: Shapes.cpp:851
dd4hep::RotationZYX
ROOT::Math::RotationZYX RotationZYX
Definition: Objects.h:105
dd4hep::Hyperboloid::setDimensions
Hyperboloid & setDimensions(double rin, double stin, double rout, double stout, double dz)
Set the Hyperboloid dimensions.
Definition: Shapes.cpp:559
dd4hep::Tube::make
void make(const std::string &nam, double rmin, double rmax, double z, double startPhi, double endPhi)
Internal helper method to support object construction.
Definition: Shapes.cpp:324
dd4hep::Polyhedra::make
void make(const std::string &nam, int nsides, double start, double delta, const std::vector< double > &z, const std::vector< double > &rmin, const std::vector< double > &rmax)
Helper function to create the polyhedron.
Definition: Shapes.cpp:756
dd4hep::Solid_type::setName
Solid_type< T > & setName(const char *value)
Set new shape name.
Definition: Shapes.cpp:70
DD4hepUnits.h
dd4hep::Tube
Class describing a tube shape of a section of a tube.
Definition: Shapes.h:628
dd4hep::TessellatedSolid::num_facet
int num_facet() const
Access the number of facets in the shape.
Definition: Shapes.cpp:831
dd4hep::Solid_type::dimensions
std::vector< double > dimensions()
Access the dimensions of the shape: inverse of the setDimensions member function.
Definition: Shapes.cpp:90
Printout.h
POLYHEDRA_TAG
#define POLYHEDRA_TAG
Definition: ShapeTags.h:34
dd4hep::Scale::scale_z
double scale_z() const
Access z-scale factor.
Definition: Shapes.cpp:139
dd4hep::Sphere::setDimensions
Sphere & setDimensions(double rmin, double rmax, double startTheta, double endTheta, double startPhi, double endPhi)
Set the Sphere dimensions.
Definition: Shapes.cpp:573
dd4hep::Trap::Trap
Trap()=default
Default constructor.
dd4hep::SubtractionSolid
Class describing boolean subtraction solid.
Definition: Shapes.h:1878
dd4hep::TruncatedTube::make
void make(const std::string &name, double dz, double rmin, double rmax, double startPhi, double deltaPhi, double cutAtStart, double cutAtDelta, bool cutInside)
Internal helper method to support object construction.
Definition: Shapes.cpp:371
dd4hep::Paraboloid
Class describing a Paraboloid shape.
Definition: Shapes.h:1378
ELLIPTICALTUBE_TAG
#define ELLIPTICALTUBE_TAG
Definition: ShapeTags.h:28
dd4hep::BooleanSolid::leftMatrix
const TGeoMatrix * leftMatrix() const
Access left positioning matrix of the boolean.
Definition: Shapes.cpp:866
dd4hep::Trap::alpha1
double alpha1() const
Angle between centers of x edges and y axis at low z.
Definition: Shapes.h:1028