CMS 3D CMS Logo

DDDividedTrd.cc
Go to the documentation of this file.
2 #include "CLHEP/Units/GlobalSystemOfUnits.h"
3 #include "CLHEP/Units/SystemOfUnits.h"
13 
14 #include <cmath>
15 #include <ostream>
16 #include <string>
17 #include <utility>
18 
19 class DDCompactView;
20 
22  : DDDividedGeometryObject(div,cpv)
23 {
25  setType( "DivisionTrdX" );
26  DDTrap mtrd = (DDTrap)( div_.parent().solid() );
27 
28  if ( divisionType_ == DivWIDTH )
29  {
30  compNDiv_ = calculateNDiv( 2 * mtrd.x1(), div_.width(), div_.offset() );
31  }
32  else if( divisionType_ == DivNDIV )
33  {
34  compWidth_ = calculateWidth( 2*mtrd.x1(), div_.nReplicas(), div_.offset() );
35  }
36 }
37 
38 double
40 {
41  DDTrap mtrd = (DDTrap)(div_.parent().solid());
42  return 2 * mtrd.x1();
43 }
44 
46 DDDividedTrdX::makeDDTranslation( const int copyNo ) const
47 {
48  DDTrap mtrd = (DDTrap)(div_.parent().solid());
49  double mdx = mtrd.x1();
50 
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(); //GetYHalfLength1();
86  double pDy2 = mtrd.y2(); //->GetYHalfLength2();
87  double pDz = mtrd.halfZ(); //->GetZHalfLength();
88  double pDx = compWidth_/2.;
89 
90  //trd.SetAllParameters ( pDx, pDx, pDy1, pDy2, pDz );
91 
92  DDName solname(div_.parent().ddname().name() + "_DIVCHILD"
93  , div_.parent().ddname().ns());
94  DDSolid dsol(solname);
95  DDLogicalPart ddlp(solname);
96  if (!dsol.isDefined().second)
97  {
98  dsol = DDSolidFactory::trap(solname
99  , pDz
100  , 0.*deg
101  , 0.*deg
102  , pDy1
103  , pDx
104  , pDx
105  , 0.*deg
106  , pDy2
107  , pDx
108  , pDx
109  , 0.*deg);
110  ddlp = DDLogicalPart(solname, usemat, dsol);
111  }
112  return ddlp;
113 }
114 
115 void
117 {
119 
120  DDTrap mtrd = (DDTrap)(div_.parent().solid());
121 
122  double mpDx1 = mtrd.x1(); //->GetXHalfLength1();
123  double mpDx2 = mtrd.x2(); //->GetXHalfLength2();
124  double mpDx3 = mtrd.x3();
125  double mpDx4 = mtrd.x4();
126  double mpTheta = mtrd.theta();
127  double mpPhi = mtrd.phi();
128  double mpAlpha1 = mtrd.alpha1();
129  double mpAlpha2 = mtrd.alpha2();
130  // double mpDy1 = mtrd.y1();
131  // double mpDy2 = mtrd.y2();
132  // double x1Tol = mpDx1 - mpDx2;
133  // if (x1Tol < 0.0) x1Tol = x1Tol * -1.0;
134 
135  if ( fabs(mpDx1 - mpDx2) > tolerance() || fabs(mpDx3 - mpDx4) > tolerance()
136  || fabs(mpDx1 - mpDx4) > tolerance())
137  {
138  std::string s = "ERROR - DDDividedTrdX::checkParametersValidity()";
139  s+= "\n Making a division of a TRD along axis X,";
140  s+= "\n while the X half lengths are not equal,";
141  s+= "\n is not (yet) supported. It will result";
142  s+= "\n in non-equal division solids.";
143  throw cms::Exception("DDException") << s;
144  }
145  // if (fabs(mpDy1 - mpDy2) > tolerance())
146  // {
147  // std::string s = "ERROR - DDDividedTrdX::checkParametersValidity()";
148  // s+= "\n Making a division of a TRD along axis X,";
149  // s+= "\n while the Y half lengths are not equal,";
150  // s+= "\n is not (yet) supported. It will result";
151  // s+= "\n in non-equal division solids.";
152  // throw cms::Exception("DDException") << s;
153  // }
154  // mec: we only have traps, not trds in DDD, so I added this check
155  // to make sure it is only a trd (I think! :-))
156  if (mpAlpha1 != 0.*deg || mpAlpha2 != 0.*deg || mpTheta != 0.*deg || mpPhi != 0.*deg)
157  {
158  std::string s = "ERROR - DDDividedTrdX::checkParametersValidity()";
159  s+= "\n Making a division of a TRD along axis X,";
160  s+= "\n while the theta, phi and aplhpa2 are not zero,";
161  s+= "\n is not (yet) supported. It will result";
162  s+= "\n in non-equal division solids.";
163  throw cms::Exception("DDException") << s;
164  }
165 }
166 
168  : DDDividedGeometryObject( div, cpv )
169 {
171  setType( "DivisionTrdY" );
172  DDTrap mtrd = (DDTrap)(div_.parent().solid());
173 
174  if( divisionType_ == DivWIDTH )
175  {
176  compNDiv_ = calculateNDiv( 2 * mtrd.y1(), div_.width(), div_.offset() );
177  }
178  else if( divisionType_ == DivNDIV )
179  {
180  compWidth_ = calculateWidth( 2 * mtrd.y1(), div_.nReplicas(), div_.offset() );
181  }
182 }
183 
184 double
186 {
187  DDTrap mtrd = (DDTrap)(div_.parent().solid());
188  return 2 * mtrd.y1();
189 }
190 
192 DDDividedTrdY::makeDDTranslation( const int copyNo ) const
193 {
194  DDTrap mtrd = (DDTrap)(div_.parent().solid() );
195  double mdy = mtrd.y1();
196 
197  //----- translation
198  double posi = -mdy + div_.offset() + (copyNo+0.5)*compWidth_;
199 
200  if( div_.axis() == DDAxes::y )
201  {
202  return DDTranslation(0.0, posi, 0.0);
203  }
204  else
205  {
206  std::string s = "ERROR - DDDividedTrdY::makeDDTranslation()";
207  s += "\n Axis is along ";
208  s += DDAxesNames::name(div_.axis());
209  s += " !\n" ;
210  s += "DDDividedTrdY::makeDDTranslation()";
211  s += " IllegalConstruct: Only axes along y are allowed !";
212  throw cms::Exception("DDException") << s;
213  }
214  return DDTranslation();
215 }
216 
218 DDDividedTrdY::makeDDRotation( const int copyNo ) const
219 {
220  return DDRotation();
221 }
222 
224 DDDividedTrdY::makeDDLogicalPart( const int copyNo ) const
225 {
226  //---- The division along Y of a Trd will result a Trd, only
227  //--- if Y at -Z and +Z are equal, else use the G4Trap version
228  DDTrap mtrd = (DDTrap)(div_.parent().solid());
229  DDMaterial usemat = div_.parent().material();
230 
231  double pDx1 = mtrd.x1(); //->GetXHalfLength1() at Y+;
232  double pDx2 = mtrd.x2(); //->GetXHalfLength2() at Y+;
233  double pDx3 = mtrd.x3(); //->GetXHalfLength1() at Y-;
234  double pDx4 = mtrd.x4(); //->GetXHalfLength2() at Y-;
235  double pDz = mtrd.halfZ(); //->GetZHalfLength();
236  double pDy = compWidth_/2.;
237 
238  //trd.SetAllParameters ( pDx1, pDx2, pDy, pDy, pDz );
239  DDName solname(div_.name() );
240  DDSolid dsol(solname);
241  DDLogicalPart ddlp(solname);
242  if (!dsol.isDefined().second)
243  {
244  dsol = DDSolidFactory::trap(solname
245  , pDz
246  , 0.*deg
247  , 0.*deg
248  , pDy
249  , pDx1
250  , pDx2
251  , 0*deg
252  , pDy
253  , pDx3
254  , pDx4
255  , 0.*deg);
256  DDLogicalPart ddlp(solname, usemat, dsol);
257  }
258  return ddlp;
259 }
260 
261 void
263 {
265 
266  DDTrap mtrd = (DDTrap)(div_.parent().solid());
267 
268  double mpDy1 = mtrd.y1(); //->GetYHalfLength1();
269  double mpDy2 = mtrd.y2(); //->GetYHalfLength2();
270  double mpTheta = mtrd.theta();
271  double mpPhi = mtrd.phi();
272  double mpAlpha1 = mtrd.alpha1();
273  double mpAlpha2 = mtrd.alpha2();
274 
275  if( fabs(mpDy1 - mpDy2) > tolerance() )
276  {
277  std::string s= "ERROR - DDDividedTrdY::checkParametersValidity()";
278  s += "\n Making a division of a TRD along axis Y while";
279  s += "\n the Y half lengths are not equal is not (yet)";
280  s += "\n supported. It will result in non-equal";
281  s += "\n division solids.";
282  throw cms::Exception("DDException") << s;
283  }
284  // mec: we only have traps, not trds in DDD, so I added this check
285  // to make sure it is only a trd (I think! :-))
286  if (mpAlpha1 != 0.*deg || mpAlpha2 != 0.*deg || mpTheta != 0.*deg || mpPhi != 0.*deg)
287  {
288  std::string s = "ERROR - DDDividedTrdY::checkParametersValidity()";
289  s+= "\n Making a division of a TRD along axis X,";
290  s+= "\n while the theta, phi and aplhpa2 are not zero,";
291  s+= "\n is not (yet) supported. It will result";
292  s+= "\n in non-equal division solids.";
293  throw cms::Exception("DDException") << s;
294  }
295 }
296 
298  : DDDividedGeometryObject( div, cpv )
299 {
301  setType( "DivTrdZ" );
302  DDTrap mtrd = (DDTrap)(div_.parent().solid());
303 
304  if ( divisionType_ == DivWIDTH )
305  {
306  compNDiv_ = calculateNDiv( 2*mtrd.halfZ(), div_.width(), div_.offset() );
307  }
308  else if( divisionType_ == DivNDIV )
309  {
311  }
312 }
313 
314 double
316 {
317  DDTrap mtrd = (DDTrap)(div_.parent().solid());
318  return 2 * mtrd.halfZ();
319 }
320 
322 DDDividedTrdZ::makeDDTranslation( const int copyNo ) const
323 {
324  DDTrap mtrd = (DDTrap)(div_.parent().solid() );
325  double mdz = mtrd.halfZ();
326 
327  //----- translation
328  double posi = -mdz + div_.offset() + (copyNo+0.5)*compWidth_;
329 
330  if( div_.axis() == DDAxes::z )
331  {
332  return DDTranslation(0.0, 0.0, posi);
333  }
334  else
335  {
336  std::string s = "ERROR - DDDividedTrdZ::makeDDTranslation()";
337  s += "\n Axis is along ";
338  s += DDAxesNames::name(div_.axis());
339  s += " !\n" ;
340  s += "DDDividedTrdY::makeDDTranslation()";
341  s += " IllegalConstruct: Only axes along z are allowed !";
342  throw cms::Exception("DDException") << s;
343 
344  }
345  return DDTranslation();
346 }
347 
349 DDDividedTrdZ::makeDDRotation( const int copyNo ) const
350 {
351  return DDRotation();
352 }
353 
355 DDDividedTrdZ::makeDDLogicalPart ( const int copyNo ) const
356 {
357  //---- The division along Z of a Trd will result a Trd
358  DDTrap mtrd = (DDTrap)(div_.parent().solid());
359  DDMaterial usemat = div_.parent().material();
360 
361  double pDx1 = mtrd.x1(); //->GetXHalfLength1();
362  //(mtrd->GetXHalfLength2() - mtrd->GetXHalfLength1() );
363  double DDx = (mtrd.x2() - mtrd.x1() );
364  double pDy1 = mtrd.y1(); // ->GetYHalfLength1();
365  //(mtrd->GetYHalfLength2() - mtrd->GetYHalfLength1() );
366  double DDy = (mtrd.y2() - mtrd.y1() );
367  double pDz = compWidth_/2.;
368  double zLength = 2*mtrd.halfZ(); //->GetZHalfLength();
369 
370  // trd.SetAllParameters ( pDx1+DDx*(div_.offset()+copyNo*compWidth_)/zLength,
371  // pDx1+DDx*(div_.offset()+(copyNo+1)*compWidth_)/zLength,
372  // pDy1+DDy*(div_.offset()+copyNo*compWidth_)/zLength,
373  // pDy1+DDy*(div_.offset()+(copyNo+1)*compWidth_)/zLength, pDz );
374 
375  DDName solname(div_.parent().ddname().name() + "_DIVCHILD"
376  + std::to_string(copyNo),
377  div_.parent().ddname().ns());
378  DDSolid dsol =
379  DDSolidFactory::trap(solname
380  , pDz
381  , 0.*deg
382  , 0.*deg
383  , pDy1+DDy*(div_.offset()+copyNo*compWidth_)/zLength
384  , pDx1+DDx*(div_.offset()+copyNo*compWidth_)/zLength
385  , pDx1+DDx*(div_.offset()+copyNo*compWidth_)/zLength
386  , 0.*deg
387  , pDy1+DDy*(div_.offset()+(copyNo+1)*compWidth_)/zLength
388  , pDx1+DDx*(div_.offset()+(copyNo+1)*compWidth_)/zLength
389  , pDx1+DDx*(div_.offset()+(copyNo+1)*compWidth_)/zLength
390  , 0*deg
391  );
392 
393  DDLogicalPart ddlp(solname, usemat, dsol);
394  return ddlp;
395 }
396 
397 void
399 {
401 
402  DDTrap mtrd = (DDTrap)(div_.parent().solid());
403 
404  double mpTheta = mtrd.theta();
405  double mpPhi = mtrd.phi();
406  double mpAlpha1 = mtrd.alpha1();
407  double mpAlpha2 = mtrd.alpha2();
408 
409  // mec: we only have traps, not trds in DDD, so I added this check
410  // to make sure it is only a trd (I think! :-))
411  if (mpAlpha1 != 0.*deg || mpAlpha2 != 0.*deg || mpTheta != 0.*deg || mpPhi != 0.*deg)
412  {
413  std::string s = "ERROR - DDDividedTrdZ::checkParametersValidity()";
414  s+= "\n Making a division of a TRD along axis X,";
415  s+= "\n while the theta, phi and aplhpa2 are not zero,";
416  s+= "\n is not (yet) supported. It will result";
417  s+= "\n in non-equal division solids.";
418  throw cms::Exception("DDException") << s;
419  }
420 }
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:78
DDRotation makeDDRotation(int copyNo) const override
Definition: DDDividedTrd.cc:74
int nReplicas() const
Definition: DDDivision.cc:71
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:41
double offset() const
Definition: DDDivision.cc:81
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:102
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:83
A DDSolid represents the shape of a part.
Definition: DDSolid.h:38
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:67
DDDividedTrdX(const DDDivision &div, DDCompactView *cpv)
Definition: DDDividedTrd.cc:21
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:79
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:92
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:794
double getMaxParameter() const override
Definition: DDDividedTrd.cc:39
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:66
double width() const
Definition: DDDivision.cc:76
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:86
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:46
const std::string & name() const
Returns the name.
Definition: DDName.cc:88
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:80