CMS 3D CMS Logo

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