CMS 3D CMS Logo

DDDividedTrd.cc
Go to the documentation of this file.
12 
13 #include <cmath>
14 #include <ostream>
15 #include <string>
16 #include <utility>
17 
18 class DDCompactView;
19 
20 using namespace geant_units::operators;
21 
24  setType("DivisionTrdX");
25  DDTrap mtrd = (DDTrap)(div_.parent().solid());
26 
27  if (divisionType_ == DivWIDTH) {
28  compNDiv_ = calculateNDiv(2 * mtrd.x1(), div_.width(), div_.offset());
29  } else if (divisionType_ == DivNDIV) {
30  compWidth_ = calculateWidth(2 * mtrd.x1(), div_.nReplicas(), div_.offset());
31  }
32 }
33 
34 double DDDividedTrdX::getMaxParameter(void) const {
35  DDTrap mtrd = (DDTrap)(div_.parent().solid());
36  return 2 * mtrd.x1();
37 }
38 
40  DDTrap mtrd = (DDTrap)(div_.parent().solid());
41  double mdx = mtrd.x1();
42 
43  //----- translation
44  double posi = -mdx + div_.offset() + (copyNo + 0.5) * compWidth_;
45 
46  if (div_.axis() == DDAxes::x) {
47  return DDTranslation(posi, 0.0, 0.0);
48  } else {
49  std::string s = "ERROR - DDDividedTrdX::makeDDTranslation()";
50  s += "\n Axis is along ";
52  s += " !\n";
53  s += "DDDividedTrdX::makeDDTranslation()";
54  s += " IllegalConstruct: Only axes along x are allowed !";
55  throw cms::Exception("DDException") << s;
56  }
57 
58  return DDTranslation();
59 }
60 
61 DDRotation DDDividedTrdX::makeDDRotation(const int copyNo) const { return DDRotation(); }
62 
64  DDTrap mtrd = (DDTrap)(div_.parent().solid());
65  DDMaterial usemat = div_.parent().material();
66 
67  double pDy1 = mtrd.y1(); // Y half length1
68  double pDy2 = mtrd.y2(); // Y half length2
69  double pDz = mtrd.halfZ(); // Z half length
70  double pDx = compWidth_ / 2.;
71 
72  DDName solname(div_.parent().ddname().name() + "_DIVCHILD", div_.parent().ddname().ns());
73  DDSolid dsol(solname);
74  DDLogicalPart ddlp(solname);
75  if (!dsol.isDefined().second) {
76  dsol = DDSolidFactory::trap(solname, pDz, 0._deg, 0._deg, pDy1, pDx, pDx, 0._deg, pDy2, pDx, pDx, 0._deg);
77  ddlp = DDLogicalPart(solname, usemat, dsol);
78  }
79  return ddlp;
80 }
81 
84 
85  DDTrap mtrd = (DDTrap)(div_.parent().solid());
86 
87  double mpDx1 = mtrd.x1(); // X half length1
88  double mpDx2 = mtrd.x2(); // X half length2
89  double mpDx3 = mtrd.x3();
90  double mpDx4 = mtrd.x4();
91  double mpTheta = mtrd.theta();
92  double mpPhi = mtrd.phi();
93  double mpAlpha1 = mtrd.alpha1();
94  double mpAlpha2 = mtrd.alpha2();
95 
96  if (fabs(mpDx1 - mpDx2) > tolerance() || fabs(mpDx3 - mpDx4) > tolerance() || fabs(mpDx1 - mpDx4) > tolerance()) {
97  std::string s = "ERROR - DDDividedTrdX::checkParametersValidity()";
98  s += "\n Making a division of a TRD along axis X,";
99  s += "\n while the X half lengths are not equal,";
100  s += "\n is not (yet) supported. It will result";
101  s += "\n in non-equal division solids.";
102  throw cms::Exception("DDException") << s;
103  }
104 
105  // mec: we only have traps, not trds in DDD, so I added this check
106  // to make sure it is only a trd (I think! :-))
107  if (mpAlpha1 != 0._deg || mpAlpha2 != 0._deg || mpTheta != 0._deg || mpPhi != 0._deg) {
108  std::string s = "ERROR - DDDividedTrdX::checkParametersValidity()";
109  s += "\n Making a division of a TRD along axis X,";
110  s += "\n while the theta, phi and aplhpa2 are not zero,";
111  s += "\n is not (yet) supported. It will result";
112  s += "\n in non-equal division solids.";
113  throw cms::Exception("DDException") << s;
114  }
115 }
116 
119  setType("DivisionTrdY");
120  DDTrap mtrd = (DDTrap)(div_.parent().solid());
121 
122  if (divisionType_ == DivWIDTH) {
123  compNDiv_ = calculateNDiv(2 * mtrd.y1(), div_.width(), div_.offset());
124  } else if (divisionType_ == DivNDIV) {
125  compWidth_ = calculateWidth(2 * mtrd.y1(), div_.nReplicas(), div_.offset());
126  }
127 }
128 
129 double DDDividedTrdY::getMaxParameter(void) const {
130  DDTrap mtrd = (DDTrap)(div_.parent().solid());
131  return 2 * mtrd.y1();
132 }
133 
135  DDTrap mtrd = (DDTrap)(div_.parent().solid());
136  double mdy = mtrd.y1();
137 
138  //----- translation
139  double posi = -mdy + div_.offset() + (copyNo + 0.5) * compWidth_;
140 
141  if (div_.axis() == DDAxes::y) {
142  return DDTranslation(0.0, posi, 0.0);
143  } else {
144  std::string s = "ERROR - DDDividedTrdY::makeDDTranslation()";
145  s += "\n Axis is along ";
147  s += " !\n";
148  s += "DDDividedTrdY::makeDDTranslation()";
149  s += " IllegalConstruct: Only axes along y are allowed !";
150  throw cms::Exception("DDException") << s;
151  }
152  return DDTranslation();
153 }
154 
155 DDRotation DDDividedTrdY::makeDDRotation(const int copyNo) const { return DDRotation(); }
156 
158  //---- The division along Y of a Trd will result a Trd, only
159  //--- if Y at -Z and +Z are equal, else use the G4Trap version
160  DDTrap mtrd = (DDTrap)(div_.parent().solid());
161  DDMaterial usemat = div_.parent().material();
162 
163  double pDx1 = mtrd.x1(); // X half length1 at Y+
164  double pDx2 = mtrd.x2(); // X half length2 at Y+
165  double pDx3 = mtrd.x3(); // X half length1 at Y-
166  double pDx4 = mtrd.x4(); // X half length2 at Y-
167  double pDz = mtrd.halfZ(); // Z half length
168  double pDy = compWidth_ / 2.;
169 
170  DDName solname(div_.name());
171  DDSolid dsol(solname);
172  DDLogicalPart ddlp(solname);
173  if (!dsol.isDefined().second) {
174  dsol = DDSolidFactory::trap(solname, pDz, 0._deg, 0._deg, pDy, pDx1, pDx2, 0._deg, pDy, pDx3, pDx4, 0._deg);
175  DDLogicalPart ddlp(solname, usemat, dsol);
176  }
177  return ddlp;
178 }
179 
182 
183  DDTrap mtrd = (DDTrap)(div_.parent().solid());
184 
185  double mpDy1 = mtrd.y1(); // Y half length1
186  double mpDy2 = mtrd.y2(); // Y half length2
187  double mpTheta = mtrd.theta();
188  double mpPhi = mtrd.phi();
189  double mpAlpha1 = mtrd.alpha1();
190  double mpAlpha2 = mtrd.alpha2();
191 
192  if (fabs(mpDy1 - mpDy2) > tolerance()) {
193  std::string s = "ERROR - DDDividedTrdY::checkParametersValidity()";
194  s += "\n Making a division of a TRD along axis Y while";
195  s += "\n the Y half lengths are not equal is not (yet)";
196  s += "\n supported. It will result in non-equal";
197  s += "\n division solids.";
198  throw cms::Exception("DDException") << s;
199  }
200  // mec: we only have traps, not trds in DDD, so I added this check
201  // to make sure it is only a trd (I think! :-))
202  if (mpAlpha1 != 0._deg || mpAlpha2 != 0._deg || mpTheta != 0._deg || mpPhi != 0._deg) {
203  std::string s = "ERROR - DDDividedTrdY::checkParametersValidity()";
204  s += "\n Making a division of a TRD along axis X,";
205  s += "\n while the theta, phi and aplhpa2 are not zero,";
206  s += "\n is not (yet) supported. It will result";
207  s += "\n in non-equal division solids.";
208  throw cms::Exception("DDException") << s;
209  }
210 }
211 
214  setType("DivTrdZ");
215  DDTrap mtrd = (DDTrap)(div_.parent().solid());
216 
217  if (divisionType_ == DivWIDTH) {
218  compNDiv_ = calculateNDiv(2 * mtrd.halfZ(), div_.width(), div_.offset());
219  } else if (divisionType_ == DivNDIV) {
221  }
222 }
223 
224 double DDDividedTrdZ::getMaxParameter(void) const {
225  DDTrap mtrd = (DDTrap)(div_.parent().solid());
226  return 2 * mtrd.halfZ();
227 }
228 
230  DDTrap mtrd = (DDTrap)(div_.parent().solid());
231  double mdz = mtrd.halfZ();
232 
233  //----- translation
234  double posi = -mdz + div_.offset() + (copyNo + 0.5) * compWidth_;
235 
236  if (div_.axis() == DDAxes::z) {
237  return DDTranslation(0.0, 0.0, posi);
238  } else {
239  std::string s = "ERROR - DDDividedTrdZ::makeDDTranslation()";
240  s += "\n Axis is along ";
242  s += " !\n";
243  s += "DDDividedTrdY::makeDDTranslation()";
244  s += " IllegalConstruct: Only axes along z are allowed !";
245  throw cms::Exception("DDException") << s;
246  }
247  return DDTranslation();
248 }
249 
250 DDRotation DDDividedTrdZ::makeDDRotation(const int copyNo) const { return DDRotation(); }
251 
253  //---- The division along Z of a Trd will result a Trd
254  DDTrap mtrd = (DDTrap)(div_.parent().solid());
255  DDMaterial usemat = div_.parent().material();
256 
257  double pDx1 = mtrd.x1(); // X half length1
258  double DDx = (mtrd.x2() - mtrd.x1());
259  double pDy1 = mtrd.y1(); // Y half length1
260  double DDy = (mtrd.y2() - mtrd.y1());
261  double pDz = compWidth_ / 2.;
262  double zLength = 2 * mtrd.halfZ(); // Z half length
263 
264  DDName solname(div_.parent().ddname().name() + "_DIVCHILD" + std::to_string(copyNo), div_.parent().ddname().ns());
265  DDSolid dsol = DDSolidFactory::trap(solname,
266  pDz,
267  0._deg,
268  0._deg,
269  pDy1 + DDy * (div_.offset() + copyNo * compWidth_) / zLength,
270  pDx1 + DDx * (div_.offset() + copyNo * compWidth_) / zLength,
271  pDx1 + DDx * (div_.offset() + copyNo * compWidth_) / zLength,
272  0._deg,
273  pDy1 + DDy * (div_.offset() + (copyNo + 1) * compWidth_) / zLength,
274  pDx1 + DDx * (div_.offset() + (copyNo + 1) * compWidth_) / zLength,
275  pDx1 + DDx * (div_.offset() + (copyNo + 1) * compWidth_) / zLength,
276  0._deg);
277 
278  DDLogicalPart ddlp(solname, usemat, dsol);
279  return ddlp;
280 }
281 
284 
285  DDTrap mtrd = (DDTrap)(div_.parent().solid());
286 
287  double mpTheta = mtrd.theta();
288  double mpPhi = mtrd.phi();
289  double mpAlpha1 = mtrd.alpha1();
290  double mpAlpha2 = mtrd.alpha2();
291 
292  // mec: we only have traps, not trds in DDD, so I added this check
293  // to make sure it is only a trd (I think! :-))
294  if (mpAlpha1 != 0._deg || mpAlpha2 != 0._deg || mpTheta != 0._deg || mpPhi != 0._deg) {
295  std::string s = "ERROR - DDDividedTrdZ::checkParametersValidity()";
296  s += "\n Making a division of a TRD along axis X,";
297  s += "\n while the theta, phi and aplhpa2 are not zero,";
298  s += "\n is not (yet) supported. It will result";
299  s += "\n in non-equal division solids.";
300  throw cms::Exception("DDException") << s;
301  }
302 }
DDDividedTrdY(const DDDivision &div, DDCompactView *cpv)
DDRotation makeDDRotation(int copyNo) const override
Definition: DDDividedTrd.cc:61
int nReplicas() const
Definition: DDDivision.cc:51
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
DDRotation makeDDRotation(int copyNo) const override
double phi(void) const
Azimuthal angle of the line joining the centres of the faces at -/+pDz.
Definition: DDSolid.cc:139
double halfZ(void) const
half of the z-Axis
Definition: DDSolid.cc:135
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
std::string to_string(const V &value)
Definition: OMSAccess.h:71
double offset() const
Definition: DDDivision.cc:55
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DDTranslation makeDDTranslation(int copyNo) const override
Definition: DDDividedTrd.cc:39
DDAxes axis() const
Definition: DDDivision.cc:49
const DDLogicalPart & parent() const
Definition: DDDivision.cc:57
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
virtual void checkParametersValidity(void)
DDLogicalPart makeDDLogicalPart(int copyNo) const override
DDLogicalPart makeDDLogicalPart(int copyNo) const override
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
DDDividedTrdX(const DDDivision &div, DDCompactView *cpv)
Definition: DDDividedTrd.cc:22
static const double tolerance(void)
DDDividedTrdZ(const DDDivision &div, DDCompactView *cpv)
double x3(void) const
Half-length along x of the side at y=-pDy2 of the face at +pDz.
Definition: DDSolid.cc:151
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
void checkParametersValidity() override
DDTranslation makeDDTranslation(int copyNo) const override
int calculateNDiv(double motherDim, double width, double offset) const
Interface to a Trapezoid.
Definition: DDSolid.h:88
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
double y2(void) const
Half-length along y of the face at +pDz.
Definition: DDSolid.cc:149
virtual void setType(const std::string &type)
DDLogicalPart makeDDLogicalPart(int copyNo) const override
Definition: DDDividedTrd.cc:63
static DDSolid trap(const DDName &name, double pDz, double pTheta, double pPhi, double pDy1, double pDx1, double pDx2, double pAlp1, double pDy2, double pDx3, double pDx4, double pAlp2)
Definition: DDSolid.cc:609
double x4(void) const
Half-length along x of the side at y=+pDy2 of the face at +pDz.
Definition: DDSolid.cc:153
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
const N & name() const
Definition: DDBase.h:59
double getMaxParameter() const override
double x2(void) const
Half-length along x of the side at y=+pDy1 of the face at -pDz.
Definition: DDSolid.cc:145
const N & ddname() const
Definition: DDBase.h:61
double alpha1(void) const
Angle with respect to the y axis from the centre of the side at y=-pDy1 to the centre at y=+pDy1 of t...
Definition: DDSolid.cc:147
void checkParametersValidity() override
Definition: DDDividedTrd.cc:82
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
double width() const
Definition: DDDivision.cc:53
double alpha2(void) const
Angle with respect to the y axis from the centre of the side at y=-pDy2 to the centre at y=+pDy2 of t...
Definition: DDSolid.cc:155
void checkParametersValidity() override
double y1(void) const
Half-length along y of the face at -pDz.
Definition: DDSolid.cc:141
double calculateWidth(double motherDim, int nDiv, double offset) const
dd4hep::Trap DDTrap
double getMaxParameter() const override
Definition: DDDividedTrd.cc:34
static const std::string name(const DDAxes &s)
Definition: DDAxes.cc:24
double getMaxParameter() const override
DDRotation makeDDRotation(int copyNo) const override
DDTranslation makeDDTranslation(int copyNo) const override
double theta(void) const
Polar angle of the line joining the centres of the faces at -/+pDz.
Definition: DDSolid.cc:137
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:52
double x1(void) const
Half-length along x of the side at y=-pDy1 of the face at -pDz.
Definition: DDSolid.cc:143