CMS 3D CMS Logo

DDShapes.cc
Go to the documentation of this file.
6 
7 #include "DD4hep/Shapes.h"
8 #include <TGeoBBox.h>
9 
10 using namespace cms;
11 using namespace cms::dd;
12 using namespace angle_units::operators;
13 
14 template <class T>
16  return (static_cast<int>(val + 0.5) != 0);
17 }
18 
20  if (fview.isABox())
21  return (DDSolidShape::ddbox);
22 
23  if (fview.isAConeSeg())
24  return (DDSolidShape::ddcons);
25 
26  if (fview.isATrapezoid())
27  return (DDSolidShape::ddtrap);
28 
29  if (fview.isATubeSeg())
30  return (DDSolidShape::ddtubs);
31 
32  if (fview.isATruncTube())
34 
35  if (fview.isAPseudoTrap()) // Rarely used -- put it last
37 
39 }
40 
41 // ** DDBox
43  if (valid) {
44  const TGeoBBox *box = fv.getShapePtr<TGeoBBox>();
45  dx_ = box->GetDX();
46  dy_ = box->GetDY();
47  dz_ = box->GetDZ();
48  }
49 }
50 
51 // ** end DDBox
52 
53 // ** DDCons
54 
56  if (valid) {
57  const TGeoConeSeg *coneSeg = fv.getShapePtr<TGeoConeSeg>();
58  dz_ = coneSeg->GetDZ();
59  phi1_ = convertDegToRad(coneSeg->GetPhi1());
60  phi2_ = convertDegToRad(coneSeg->GetPhi2()) - phi1_;
61 
62  // Limit to range -pi to pi
64  rmin1_ = coneSeg->GetRmin1();
65  rmin2_ = coneSeg->GetRmin2();
66  rmax1_ = coneSeg->GetRmax1();
67  rmax2_ = coneSeg->GetRmax2();
68  }
69 }
70 
71 // ** end of DDCons
72 
73 // ** DDPseudoTrap
74 // No longer used -- this code does not work right
75 /*
76 DDPseudoTrap::DDPseudoTrap(const DDFilteredView &fv) : valid{fv.isAPseudoTrap()} {
77  if (valid) {
78  auto trap = fv.solid();
79  std::vector<double> params = trap.dimensions();
80  minusX_ = params[0];
81  plusX_ = params[1];
82  minusY_ = params[2];
83  plusY_ = params[3];
84  dz_ = params[4];
85  rmax_ = params[5];
86  minusZSide_ = convFpToBool(params[6]);
87  }
88 }
89 */
90 // ** end of DDPseudoTrap
91 
92 // *** DDTrap
93 
95  if (valid) {
96  const TGeoTrap *trap = fv.getShapePtr<TGeoTrap>();
97  halfZ_ = trap->GetDz();
98  theta_ = convertDegToRad(trap->GetTheta());
99  phi_ = convertDegToRad(trap->GetPhi());
100  x1_ = trap->GetBl1(); // Along x, low y, low z
101  x2_ = trap->GetTl1(); // Along x, high y, low z
102  y1_ = trap->GetH1(); // Along y, low z
103  y2_ = trap->GetH2(); // Along y, high z
104  x3_ = trap->GetBl2(); // Along x, low y, high z
105  x4_ = trap->GetTl2(); // Along x, high y, high z
106  alpha1_ = convertDegToRad(trap->GetAlpha1());
107  alpha2_ = convertDegToRad(trap->GetAlpha2());
108  }
109 }
110 
111 // *** end of DDTrap
112 
113 // ** DDTubs
114 
116  if (valid) {
117  const TGeoTubeSeg *tube = fv.getShapePtr<TGeoTubeSeg>();
118  zHalf_ = tube->GetDz();
119  rIn_ = tube->GetRmin();
120  rOut_ = tube->GetRmax();
121  startPhi_ = convertDegToRad(tube->GetPhi1());
122  deltaPhi_ = convertDegToRad(tube->GetPhi2()) - startPhi_;
123 
124  // Limit to range -pi to pi
126  }
127 }
128 
129 // *** end of DDTubs
130 
131 // ** DDTruncTubs
132 
134  if (valid) {
135  auto tube = fv.solid();
136  std::vector<double> params = tube.dimensions();
137  if (params.size() < 8) {
138  edm::LogError("DDShapes DDTruncTubs") << "Truncated tube parameters list too small: " << params.size();
139  return;
140  }
141  LogTrace("DDShapes DDTruncTubs") << "DDTruncTubs zHalf = " << params[0];
142  LogTrace("DDShapes DDTruncTubs") << "DDTruncTubs rIn = " << params[1];
143  LogTrace("DDShapes DDTruncTubs") << "DDTruncTubs rOut = " << params[2];
144  LogTrace("DDShapes DDTruncTubs") << "DDTruncTubs startPhi = " << params[3];
145  LogTrace("DDShapes DDTruncTubs") << "DDTruncTubs deltaPhi = " << params[4];
146  LogTrace("DDShapes DDTruncTubs") << "DDTruncTubs cutAtStart = " << params[5];
147  LogTrace("DDShapes DDTruncTubs") << "DDTruncTubs cutAtDelta = " << params[6];
148  LogTrace("DDShapes DDTruncTubs") << "DDTruncTubs cutInside = " << params[7];
149 
150  zHalf_ = params[0]; // This order determined by reading DD4hep source code
151  rIn_ = params[1];
152  rOut_ = params[2];
153  startPhi_ = params[3];
154  deltaPhi_ = params[4];
155  cutAtStart_ = params[5];
156  cutAtDelta_ = params[6];
157  cutInside_ = (params[7] != 0);
158 
159  /* Previous versions of DD4hep output parameters that required more complex conversion
160  * to produce the values CMS needs. Now the desired values are returned directly by the
161  * "dimensions" function. If the more complex conversion is ever needed again, the git history
162  * of this file from before 2019-11-25 has code for converting from the internal DD4hep parameters
163  * for a TruncatedTube to the eight parameters used by CMS.
164  * There is also example code for checking the parameters of the TGeoCompositeShape.
165  */
166  }
167 }
168 
169 // *** end of DDTruncTubs
Phi.h
cms::dd::DDTubs::DDTubs
DDTubs(void)=delete
MessageLogger.h
cms::DDFilteredView::isATruncTube
auto isATruncTube(Ts &&... ts) const -> decltype(isA< dd4hep::TruncatedTube >(std::forward< Ts >(ts)...))
Definition: DDFilteredView.h:173
cms::DDFilteredView::isAConeSeg
auto isAConeSeg(Ts &&... ts) const -> decltype(isA< dd4hep::ConeSegment >(std::forward< Ts >(ts)...))
Definition: DDFilteredView.h:158
cms::DDSolidShape::ddtubs
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
cms::dd::DDTruncTubs::DDTruncTubs
DDTruncTubs(void)=delete
DDShapes.h
angle_units::operators::convertDegToRad
constexpr long double convertDegToRad(NumType degrees)
Definition: angle_units.h:27
cms::DDFilteredView::isATubeSeg
auto isATubeSeg(Ts &&... ts) const -> decltype(isA< dd4hep::Tube >(std::forward< Ts >(ts)...))
Definition: DDFilteredView.h:178
cms::DDFilteredView
Definition: DDFilteredView.h:65
cms::DDSolidShape::ddcons
validateGeometry_cfg.valid
valid
Definition: validateGeometry_cfg.py:21
cms::DDSolidShape::ddtrunctubs
cms::dd::DDTrap::DDTrap
DDTrap(void)=delete
cms::DDSolidShape::ddpseudotrap
DDSolidShapes.h
cms::dd::DDCons::DDCons
DDCons(void)=delete
DDAlgoArguments.h
cms::dd::getCurrentShape
DDSolidShape getCurrentShape(const cms::DDFilteredView &fview)
Definition: DDShapes.cc:19
cms::DDSolidShape
DDSolidShape
Definition: DDSolidShapes.h:62
edm::LogError
Definition: MessageLogger.h:183
angle_units::operators
Definition: angle_units.h:11
cms::DDSolidShape::ddtrap
cms::DDSolidShape::ddbox
Geom::NormalizeWrapper
Definition: Phi.h:29
cms::DDFilteredView::isABox
auto isABox(Ts &&... ts) const -> decltype(isA< dd4hep::Box >(std::forward< Ts >(ts)...))
Definition: DDFilteredView.h:153
heppy_batch.val
val
Definition: heppy_batch.py:351
T
long double T
Definition: Basic3DVectorLD.h:48
cms::DDSolidShape::dd_not_init
cms::dd::DDBox::DDBox
DDBox(void)=delete
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
cms::DDFilteredView::isATrapezoid
auto isATrapezoid(Ts &&... ts) const -> decltype(isA< dd4hep::Trap >(std::forward< Ts >(ts)...))
Definition: DDFilteredView.h:168
convFpToBool
bool convFpToBool(T val)
Definition: DDShapes.cc:15
cms::DDFilteredView::isAPseudoTrap
auto isAPseudoTrap(Ts &&... ts) const -> decltype(isA< dd4hep::PseudoTrap >(std::forward< Ts >(ts)...))
Definition: DDFilteredView.h:163
cms::dd
Definition: DDShapes.h:10
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21