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 
23  : DDDividedGeometryObject(div,cpv)
24 {
26  setType( "DivisionTrdX" );
27  DDTrap mtrd = (DDTrap)( div_.parent().solid() );
28 
29  if ( divisionType_ == DivWIDTH )
30  {
31  compNDiv_ = calculateNDiv( 2 * mtrd.x1(), div_.width(), div_.offset() );
32  }
33  else if( divisionType_ == DivNDIV )
34  {
35  compWidth_ = calculateWidth( 2*mtrd.x1(), div_.nReplicas(), div_.offset() );
36  }
37 }
38 
39 double
41 {
42  DDTrap mtrd = (DDTrap)(div_.parent().solid());
43  return 2 * mtrd.x1();
44 }
45 
47 DDDividedTrdX::makeDDTranslation( const int copyNo ) const
48 {
49  DDTrap mtrd = (DDTrap)(div_.parent().solid());
50  double mdx = mtrd.x1();
51 
52  //----- translation
53  double posi = -mdx + div_.offset() + (copyNo+0.5)*compWidth_;
54 
55  if( div_.axis() == DDAxes::x )
56  {
57  return DDTranslation(posi, 0.0, 0.0);
58  }
59  else
60  {
61  std::string s = "ERROR - DDDividedTrdX::makeDDTranslation()";
62  s += "\n Axis is along ";
63  s += DDAxesNames::name(div_.axis());
64  s += " !\n" ;
65  s += "DDDividedTrdX::makeDDTranslation()";
66  s += " IllegalConstruct: Only axes along x are allowed !";
67  throw cms::Exception("DDException") << s;
68  }
69 
70  return DDTranslation();
71 }
72 
74 DDDividedTrdX::makeDDRotation( const int copyNo ) const
75 {
76  return DDRotation();
77 }
78 
80 DDDividedTrdX::makeDDLogicalPart( const int copyNo ) const
81 {
82  DDTrap mtrd = (DDTrap)(div_.parent().solid());
83  DDMaterial usemat = div_.parent().material();
84 
85  double pDy1 = mtrd.y1(); // Y half length1
86  double pDy2 = mtrd.y2(); // Y half length2
87  double pDz = mtrd.halfZ(); // Z half length
88  double pDx = compWidth_/2.;
89 
90  DDName solname(div_.parent().ddname().name() + "_DIVCHILD"
91  , div_.parent().ddname().ns());
92  DDSolid dsol(solname);
93  DDLogicalPart ddlp(solname);
94  if (!dsol.isDefined().second)
95  {
96  dsol = DDSolidFactory::trap(solname
97  , pDz
98  , 0._deg
99  , 0._deg
100  , pDy1
101  , pDx
102  , pDx
103  , 0._deg
104  , pDy2
105  , pDx
106  , pDx
107  , 0._deg);
108  ddlp = DDLogicalPart(solname, usemat, dsol);
109  }
110  return ddlp;
111 }
112 
113 void
115 {
117 
118  DDTrap mtrd = (DDTrap)(div_.parent().solid());
119 
120  double mpDx1 = mtrd.x1(); // X half length1
121  double mpDx2 = mtrd.x2(); // X half length2
122  double mpDx3 = mtrd.x3();
123  double mpDx4 = mtrd.x4();
124  double mpTheta = mtrd.theta();
125  double mpPhi = mtrd.phi();
126  double mpAlpha1 = mtrd.alpha1();
127  double mpAlpha2 = mtrd.alpha2();
128 
129  if ( fabs(mpDx1 - mpDx2) > tolerance() || fabs(mpDx3 - mpDx4) > tolerance()
130  || fabs(mpDx1 - mpDx4) > tolerance())
131  {
132  std::string s = "ERROR - DDDividedTrdX::checkParametersValidity()";
133  s+= "\n Making a division of a TRD along axis X,";
134  s+= "\n while the X half lengths are not equal,";
135  s+= "\n is not (yet) supported. It will result";
136  s+= "\n in non-equal division solids.";
137  throw cms::Exception("DDException") << s;
138  }
139 
140  // mec: we only have traps, not trds in DDD, so I added this check
141  // to make sure it is only a trd (I think! :-))
142  if (mpAlpha1 != 0._deg || mpAlpha2 != 0._deg || mpTheta != 0._deg || mpPhi != 0._deg)
143  {
144  std::string s = "ERROR - DDDividedTrdX::checkParametersValidity()";
145  s+= "\n Making a division of a TRD along axis X,";
146  s+= "\n while the theta, phi and aplhpa2 are not zero,";
147  s+= "\n is not (yet) supported. It will result";
148  s+= "\n in non-equal division solids.";
149  throw cms::Exception("DDException") << s;
150  }
151 }
152 
154  : DDDividedGeometryObject( div, cpv )
155 {
157  setType( "DivisionTrdY" );
158  DDTrap mtrd = (DDTrap)(div_.parent().solid());
159 
160  if( divisionType_ == DivWIDTH )
161  {
162  compNDiv_ = calculateNDiv( 2 * mtrd.y1(), div_.width(), div_.offset() );
163  }
164  else if( divisionType_ == DivNDIV )
165  {
166  compWidth_ = calculateWidth( 2 * mtrd.y1(), div_.nReplicas(), div_.offset() );
167  }
168 }
169 
170 double
172 {
173  DDTrap mtrd = (DDTrap)(div_.parent().solid());
174  return 2 * mtrd.y1();
175 }
176 
178 DDDividedTrdY::makeDDTranslation( const int copyNo ) const
179 {
180  DDTrap mtrd = (DDTrap)(div_.parent().solid() );
181  double mdy = mtrd.y1();
182 
183  //----- translation
184  double posi = -mdy + div_.offset() + (copyNo+0.5)*compWidth_;
185 
186  if( div_.axis() == DDAxes::y )
187  {
188  return DDTranslation(0.0, posi, 0.0);
189  }
190  else
191  {
192  std::string s = "ERROR - DDDividedTrdY::makeDDTranslation()";
193  s += "\n Axis is along ";
194  s += DDAxesNames::name(div_.axis());
195  s += " !\n" ;
196  s += "DDDividedTrdY::makeDDTranslation()";
197  s += " IllegalConstruct: Only axes along y are allowed !";
198  throw cms::Exception("DDException") << s;
199  }
200  return DDTranslation();
201 }
202 
204 DDDividedTrdY::makeDDRotation( const int copyNo ) const
205 {
206  return DDRotation();
207 }
208 
210 DDDividedTrdY::makeDDLogicalPart( const int copyNo ) const
211 {
212  //---- The division along Y of a Trd will result a Trd, only
213  //--- if Y at -Z and +Z are equal, else use the G4Trap version
214  DDTrap mtrd = (DDTrap)(div_.parent().solid());
215  DDMaterial usemat = div_.parent().material();
216 
217  double pDx1 = mtrd.x1(); // X half length1 at Y+
218  double pDx2 = mtrd.x2(); // X half length2 at Y+
219  double pDx3 = mtrd.x3(); // X half length1 at Y-
220  double pDx4 = mtrd.x4(); // X half length2 at Y-
221  double pDz = mtrd.halfZ(); // Z half length
222  double pDy = compWidth_/2.;
223 
224  DDName solname(div_.name() );
225  DDSolid dsol(solname);
226  DDLogicalPart ddlp(solname);
227  if (!dsol.isDefined().second)
228  {
229  dsol = DDSolidFactory::trap(solname
230  , pDz
231  , 0._deg
232  , 0._deg
233  , pDy
234  , pDx1
235  , pDx2
236  , 0._deg
237  , pDy
238  , pDx3
239  , pDx4
240  , 0._deg);
241  DDLogicalPart ddlp(solname, usemat, dsol);
242  }
243  return ddlp;
244 }
245 
246 void
248 {
250 
251  DDTrap mtrd = (DDTrap)(div_.parent().solid());
252 
253  double mpDy1 = mtrd.y1(); // Y half length1
254  double mpDy2 = mtrd.y2(); // Y half length2
255  double mpTheta = mtrd.theta();
256  double mpPhi = mtrd.phi();
257  double mpAlpha1 = mtrd.alpha1();
258  double mpAlpha2 = mtrd.alpha2();
259 
260  if( fabs(mpDy1 - mpDy2) > tolerance() )
261  {
262  std::string s= "ERROR - DDDividedTrdY::checkParametersValidity()";
263  s += "\n Making a division of a TRD along axis Y while";
264  s += "\n the Y half lengths are not equal is not (yet)";
265  s += "\n supported. It will result in non-equal";
266  s += "\n division solids.";
267  throw cms::Exception("DDException") << s;
268  }
269  // mec: we only have traps, not trds in DDD, so I added this check
270  // to make sure it is only a trd (I think! :-))
271  if (mpAlpha1 != 0._deg || mpAlpha2 != 0._deg || mpTheta != 0._deg || mpPhi != 0._deg)
272  {
273  std::string s = "ERROR - DDDividedTrdY::checkParametersValidity()";
274  s+= "\n Making a division of a TRD along axis X,";
275  s+= "\n while the theta, phi and aplhpa2 are not zero,";
276  s+= "\n is not (yet) supported. It will result";
277  s+= "\n in non-equal division solids.";
278  throw cms::Exception("DDException") << s;
279  }
280 }
281 
283  : DDDividedGeometryObject( div, cpv )
284 {
286  setType( "DivTrdZ" );
287  DDTrap mtrd = (DDTrap)(div_.parent().solid());
288 
289  if ( divisionType_ == DivWIDTH )
290  {
291  compNDiv_ = calculateNDiv( 2*mtrd.halfZ(), div_.width(), div_.offset() );
292  }
293  else if( divisionType_ == DivNDIV )
294  {
296  }
297 }
298 
299 double
301 {
302  DDTrap mtrd = (DDTrap)(div_.parent().solid());
303  return 2 * mtrd.halfZ();
304 }
305 
307 DDDividedTrdZ::makeDDTranslation( const int copyNo ) const
308 {
309  DDTrap mtrd = (DDTrap)(div_.parent().solid() );
310  double mdz = mtrd.halfZ();
311 
312  //----- translation
313  double posi = -mdz + div_.offset() + (copyNo+0.5)*compWidth_;
314 
315  if( div_.axis() == DDAxes::z )
316  {
317  return DDTranslation(0.0, 0.0, posi);
318  }
319  else
320  {
321  std::string s = "ERROR - DDDividedTrdZ::makeDDTranslation()";
322  s += "\n Axis is along ";
323  s += DDAxesNames::name(div_.axis());
324  s += " !\n" ;
325  s += "DDDividedTrdY::makeDDTranslation()";
326  s += " IllegalConstruct: Only axes along z are allowed !";
327  throw cms::Exception("DDException") << s;
328 
329  }
330  return DDTranslation();
331 }
332 
334 DDDividedTrdZ::makeDDRotation( const int copyNo ) const
335 {
336  return DDRotation();
337 }
338 
340 DDDividedTrdZ::makeDDLogicalPart ( const int copyNo ) const
341 {
342  //---- The division along Z of a Trd will result a Trd
343  DDTrap mtrd = (DDTrap)(div_.parent().solid());
344  DDMaterial usemat = div_.parent().material();
345 
346  double pDx1 = mtrd.x1(); // X half length1
347  double DDx = (mtrd.x2() - mtrd.x1() );
348  double pDy1 = mtrd.y1(); // Y half length1
349  double DDy = (mtrd.y2() - mtrd.y1() );
350  double pDz = compWidth_/2.;
351  double zLength = 2*mtrd.halfZ(); // Z half length
352 
353  DDName solname(div_.parent().ddname().name() + "_DIVCHILD"
354  + std::to_string(copyNo),
355  div_.parent().ddname().ns());
356  DDSolid dsol =
357  DDSolidFactory::trap(solname
358  , pDz
359  , 0._deg
360  , 0._deg
361  , pDy1+DDy*(div_.offset()+copyNo*compWidth_)/zLength
362  , pDx1+DDx*(div_.offset()+copyNo*compWidth_)/zLength
363  , pDx1+DDx*(div_.offset()+copyNo*compWidth_)/zLength
364  , 0._deg
365  , pDy1+DDy*(div_.offset()+(copyNo+1)*compWidth_)/zLength
366  , pDx1+DDx*(div_.offset()+(copyNo+1)*compWidth_)/zLength
367  , pDx1+DDx*(div_.offset()+(copyNo+1)*compWidth_)/zLength
368  , 0._deg
369  );
370 
371  DDLogicalPart ddlp(solname, usemat, dsol);
372  return ddlp;
373 }
374 
375 void
377 {
379 
380  DDTrap mtrd = (DDTrap)(div_.parent().solid());
381 
382  double mpTheta = mtrd.theta();
383  double mpPhi = mtrd.phi();
384  double mpAlpha1 = mtrd.alpha1();
385  double mpAlpha2 = mtrd.alpha2();
386 
387  // mec: we only have traps, not trds in DDD, so I added this check
388  // to make sure it is only a trd (I think! :-))
389  if (mpAlpha1 != 0._deg || mpAlpha2 != 0._deg || mpTheta != 0._deg || mpPhi != 0._deg)
390  {
391  std::string s = "ERROR - DDDividedTrdZ::checkParametersValidity()";
392  s+= "\n Making a division of a TRD along axis X,";
393  s+= "\n while the theta, phi and aplhpa2 are not zero,";
394  s+= "\n is not (yet) supported. It will result";
395  s+= "\n in non-equal division solids.";
396  throw cms::Exception("DDException") << s;
397  }
398 }
double halfZ(void) const
half of the z-Axis
Definition: DDSolid.cc:159
DDDividedTrdY(const DDDivision &div, DDCompactView *cpv)
double x1(void) const
Half-length along x of the side at y=-pDy1 of the face at -pDz.
Definition: DDSolid.cc:171
const N & name() const
Definition: DDBase.h:74
DDRotation makeDDRotation(int copyNo) const override
Definition: DDDividedTrd.cc:74
int nReplicas() const
Definition: DDDivision.cc:75
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:43
double offset() const
Definition: DDDivision.cc:87
double phi(void) const
Azimuthal angle of the line joining the centres of the faces at -/+pDz.
Definition: DDSolid.cc:165
double getMaxParameter() const override
DDLogicalPart makeDDLogicalPart(int copyNo) const override
int calculateNDiv(double motherDim, double width, double offset) const
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:67
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
double calculateWidth(double motherDim, int nDiv, double offset) const
DDTranslation makeDDTranslation(int copyNo) const override
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
virtual void checkParametersValidity(void)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:68
DDDividedTrdX(const DDDivision &div, DDCompactView *cpv)
Definition: DDDividedTrd.cc:22
static const double tolerance(void)
DDDividedTrdZ(const DDDivision &div, DDCompactView *cpv)
double x4(void) const
Half-length along x of the side at y=+pDy2 of the face at +pDz.
Definition: DDSolid.cc:186
void checkParametersValidity() override
Interface to a Trapezoid.
Definition: DDSolid.h:78
double y1(void) const
Half-length along y of the face at -pDz.
Definition: DDSolid.cc:168
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
virtual void setType(const std::string &type)
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:792
double getMaxParameter() const override
Definition: DDDividedTrd.cc:40
DDTranslation makeDDTranslation(int copyNo) const override
DDRotation makeDDRotation(int copyNo) const override
double getMaxParameter() const override
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:177
DDLogicalPart makeDDLogicalPart(int copyNo) const override
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:189
void checkParametersValidity() override
double x2(void) const
Half-length along x of the side at y=+pDy1 of the face at -pDz.
Definition: DDSolid.cc:174
DDAxes axis() const
Definition: DDDivision.cc:69
double width() const
Definition: DDDivision.cc:81
void checkParametersValidity() override
double y2(void) const
Half-length along y of the face at +pDz.
Definition: DDSolid.cc:180
const DDLogicalPart & parent() const
Definition: DDDivision.cc:93
static const std::string name(const DDAxes &s)
Definition: DDAxes.cc:29
double theta(void) const
Polar angle of the line joining the centres of the faces at -/+pDz.
Definition: DDSolid.cc:162
DDTranslation makeDDTranslation(int copyNo) const override
Definition: DDDividedTrd.cc:47
const std::string & name() const
Returns the name.
Definition: DDName.cc:53
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
DDRotation makeDDRotation(int copyNo) const override
double x3(void) const
Half-length along x of the side at y=-pDy2 of the face at +pDz.
Definition: DDSolid.cc:183
DDLogicalPart makeDDLogicalPart(int copyNo) const override
Definition: DDDividedTrd.cc:80
const N & ddname() const
Definition: DDBase.h:76