CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDDividedTrd.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // 25.04.04 - M. Case ddd-ize G4ParameterisationTrd*
4 // ********************************************************************
5 
8 
14 
17 
18 #include "CLHEP/Units/GlobalSystemOfUnits.h"
19 
20 #include <cmath>
21 #include <cstdlib>
22 
24  : DDDividedGeometryObject(div,cpv)
25 {
27  setType( "DivisionTrdX" );
28  DDTrap mtrd = (DDTrap)( div_.parent().solid() );
29 
30  if ( divisionType_ == DivWIDTH )
31  {
32  compNDiv_ = calculateNDiv( 2 * mtrd.x1(), div_.width(), div_.offset() );
33  }
34  else if( divisionType_ == DivNDIV )
35  {
36  compWidth_ = calculateWidth( 2*mtrd.x1(), div_.nReplicas(), div_.offset() );
37  }
38 
39  DCOUT_V ('P', " DDDividedTrdX - ## divisions " << compNDiv_ << " = " << div_.nReplicas() << "\n Offset " << div_.offset() << "\n Width " << compWidth_ << " = " << div_.width());
40 }
41 
43 {}
44 
45 double
47 {
48  DDTrap mtrd = (DDTrap)(div_.parent().solid());
49  return 2 * mtrd.x1();
50 }
51 
53 DDDividedTrdX::makeDDTranslation( const int copyNo ) const
54 {
55  DDTrap mtrd = (DDTrap)(div_.parent().solid());
56  double mdx = mtrd.x1();
57 
58 
59  //----- translation
60  double posi = -mdx + div_.offset() + (copyNo+0.5)*compWidth_;
61 
62  DCOUT_V ('P', " DDDividedTrdX: " << copyNo << "\n Position: x=" << posi << " Axis= " << DDAxesNames::name(div_.axis()) << "\n");
63 
64  if( div_.axis() == x )
65  {
66  return DDTranslation(posi, 0.0, 0.0);
67  }
68  else
69  {
70  std::string s = "ERROR - DDDividedTrdX::makeDDTranslation()";
71  s += "\n Axis is along ";
72  s += DDAxesNames::name(div_.axis());
73  s += " !\n" ;
74  s += "DDDividedTrdX::makeDDTranslation()";
75  s += " IllegalConstruct: Only axes along x are allowed !";
76  throw DDException(s);
77  }
78 
79  return DDTranslation();
80 }
81 
83 DDDividedTrdX::makeDDRotation( const int copyNo ) const
84 {
85  return DDRotation();
86 }
87 
89 DDDividedTrdX::makeDDLogicalPart( const int copyNo ) const
90 {
91  DDTrap mtrd = (DDTrap)(div_.parent().solid());
92  DDMaterial usemat = div_.parent().material();
93 
94  double pDy1 = mtrd.y1(); //GetYHalfLength1();
95  double pDy2 = mtrd.y2(); //->GetYHalfLength2();
96  double pDz = mtrd.halfZ(); //->GetZHalfLength();
97  double pDx = compWidth_/2.;
98 
99  //trd.SetAllParameters ( pDx, pDx, pDy1, pDy2, pDz );
100 
101  DDName solname(div_.parent().ddname().name() + "_DIVCHILD"
102  , div_.parent().ddname().ns());
103  DDSolid dsol(solname);
104  DDLogicalPart ddlp(solname);
105  if (!dsol.isDefined().second)
106  {
107  dsol = DDSolidFactory::trap(solname
108  , pDz
109  , 0.*deg
110  , 0.*deg
111  , pDy1
112  , pDx
113  , pDx
114  , 0.*deg
115  , pDy2
116  , pDx
117  , pDx
118  , 0.*deg);
119  ddlp = DDLogicalPart(solname, usemat, dsol);
120  }
121  DCOUT_V ('P', "DDDividedTrdX::makeDDLogicalPart lp = " << ddlp);
122  return ddlp;
123 }
124 
125 void
127 {
129 
130  DDTrap mtrd = (DDTrap)(div_.parent().solid());
131 
132  double mpDx1 = mtrd.x1(); //->GetXHalfLength1();
133  double mpDx2 = mtrd.x2(); //->GetXHalfLength2();
134  double mpDx3 = mtrd.x3();
135  double mpDx4 = mtrd.x4();
136  double mpTheta = mtrd.theta();
137  double mpPhi = mtrd.phi();
138  double mpAlpha1 = mtrd.alpha1();
139  double mpAlpha2 = mtrd.alpha2();
140  // double mpDy1 = mtrd.y1();
141  // double mpDy2 = mtrd.y2();
142  // double x1Tol = mpDx1 - mpDx2;
143  // if (x1Tol < 0.0) x1Tol = x1Tol * -1.0;
144 
145  if ( fabs(mpDx1 - mpDx2) > tolerance() || fabs(mpDx3 - mpDx4) > tolerance()
146  || fabs(mpDx1 - mpDx4) > 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 X 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 DDException(s);
154  }
155  // if (fabs(mpDy1 - mpDy2) > tolerance())
156  // {
157  // std::string s = "ERROR - DDDividedTrdX::checkParametersValidity()";
158  // s+= "\n Making a division of a TRD along axis X,";
159  // s+= "\n while the Y half lengths are not equal,";
160  // s+= "\n is not (yet) supported. It will result";
161  // s+= "\n in non-equal division solids.";
162  // throw DDException(s);
163  // }
164  // mec: we only have traps, not trds in DDD, so I added this check
165  // to make sure it is only a trd (I think! :-))
166  if (mpAlpha1 != 0.*deg || mpAlpha2 != 0.*deg || mpTheta != 0.*deg || mpPhi != 0.*deg)
167  {
168  std::string s = "ERROR - DDDividedTrdX::checkParametersValidity()";
169  s+= "\n Making a division of a TRD along axis X,";
170  s+= "\n while the theta, phi and aplhpa2 are not zero,";
171  s+= "\n is not (yet) supported. It will result";
172  s+= "\n in non-equal division solids.";
173  throw DDException(s);
174  }
175 }
176 
178  : DDDividedGeometryObject( div, cpv )
179 {
181  setType( "DivisionTrdY" );
182  DDTrap mtrd = (DDTrap)(div_.parent().solid());
183 
184  if( divisionType_ == DivWIDTH )
185  {
186  compNDiv_ = calculateNDiv( 2 * mtrd.y1(), div_.width(), div_.offset() );
187  }
188  else if( divisionType_ == DivNDIV )
189  {
190  compWidth_ = calculateWidth( 2 * mtrd.y1(), div_.nReplicas(), div_.offset() );
191  }
192 
193  DCOUT_V ('P', " DDDividedTrdY no divisions " << compNDiv_ << " = " << div_.nReplicas() << "\n Offset " << div_.offset() << "\n width " << compWidth_ << " = " << div_.width() << std::endl);
194 }
195 
197 {}
198 
199 double
201 {
202  DDTrap mtrd = (DDTrap)(div_.parent().solid());
203  return 2 * mtrd.y1();
204 }
205 
207 DDDividedTrdY::makeDDTranslation( const int copyNo ) const
208 {
209  DDTrap mtrd = (DDTrap)(div_.parent().solid() );
210  double mdy = mtrd.y1();
211 
212  //----- translation
213  double posi = -mdy + div_.offset() + (copyNo+0.5)*compWidth_;
214 
215  DCOUT_V ('P', " DDDividedTrdY: " << copyNo << "\n Position: y=" << posi << " Axis= " << DDAxesNames::name(div_.axis()) << "\n");
216 
217  if( div_.axis() == y )
218  {
219  return DDTranslation(0.0, posi, 0.0);
220  }
221  else
222  {
223  std::string s = "ERROR - DDDividedTrdY::makeDDTranslation()";
224  s += "\n Axis is along ";
225  s += DDAxesNames::name(div_.axis());
226  s += " !\n" ;
227  s += "DDDividedTrdY::makeDDTranslation()";
228  s += " IllegalConstruct: Only axes along y are allowed !";
229  throw DDException(s);
230  }
231  return DDTranslation();
232 }
233 
235 DDDividedTrdY::makeDDRotation( const int copyNo ) const
236 {
237  return DDRotation();
238 }
239 
241 DDDividedTrdY::makeDDLogicalPart( const int copyNo ) const
242 {
243  //---- The division along Y of a Trd will result a Trd, only
244  //--- if Y at -Z and +Z are equal, else use the G4Trap version
245  DDTrap mtrd = (DDTrap)(div_.parent().solid());
246  DDMaterial usemat = div_.parent().material();
247 
248  double pDx1 = mtrd.x1(); //->GetXHalfLength1() at Y+;
249  double pDx2 = mtrd.x2(); //->GetXHalfLength2() at Y+;
250  double pDx3 = mtrd.x3(); //->GetXHalfLength1() at Y-;
251  double pDx4 = mtrd.x4(); //->GetXHalfLength2() at Y-;
252  double pDz = mtrd.halfZ(); //->GetZHalfLength();
253  double pDy = compWidth_/2.;
254 
255  //trd.SetAllParameters ( pDx1, pDx2, pDy, pDy, pDz );
256  DDName solname(div_.name() );
257  DDSolid dsol(solname);
258  DDLogicalPart ddlp(solname);
259  if (!dsol.isDefined().second)
260  {
261  dsol = DDSolidFactory::trap(solname
262  , pDz
263  , 0.*deg
264  , 0.*deg
265  , pDy
266  , pDx1
267  , pDx2
268  , 0*deg
269  , pDy
270  , pDx3
271  , pDx4
272  , 0.*deg);
273  DDLogicalPart ddlp(solname, usemat, dsol);
274  }
275  DCOUT_V ('P', "DDDividedTrdY::makeDDLogicalPart lp = " << ddlp);
276  return ddlp;
277 }
278 
279 void
281 {
283 
284  DDTrap mtrd = (DDTrap)(div_.parent().solid());
285 
286  double mpDy1 = mtrd.y1(); //->GetYHalfLength1();
287  double mpDy2 = mtrd.y2(); //->GetYHalfLength2();
288  double mpTheta = mtrd.theta();
289  double mpPhi = mtrd.phi();
290  double mpAlpha1 = mtrd.alpha1();
291  double mpAlpha2 = mtrd.alpha2();
292 
293  if( fabs(mpDy1 - mpDy2) > tolerance() )
294  {
295  std::string s= "ERROR - DDDividedTrdY::checkParametersValidity()";
296  s += "\n Making a division of a TRD along axis Y while";
297  s += "\n the Y half lengths are not equal is not (yet)";
298  s += "\n supported. It will result in non-equal";
299  s += "\n division solids.";
300  throw DDException(s);
301  }
302  // mec: we only have traps, not trds in DDD, so I added this check
303  // to make sure it is only a trd (I think! :-))
304  if (mpAlpha1 != 0.*deg || mpAlpha2 != 0.*deg || mpTheta != 0.*deg || mpPhi != 0.*deg)
305  {
306  std::string s = "ERROR - DDDividedTrdY::checkParametersValidity()";
307  s+= "\n Making a division of a TRD along axis X,";
308  s+= "\n while the theta, phi and aplhpa2 are not zero,";
309  s+= "\n is not (yet) supported. It will result";
310  s+= "\n in non-equal division solids.";
311  throw DDException(s);
312  }
313 }
314 
316  : DDDividedGeometryObject( div, cpv )
317 {
319  setType( "DivTrdZ" );
320  DDTrap mtrd = (DDTrap)(div_.parent().solid());
321 
322  if ( divisionType_ == DivWIDTH )
323  {
324  compNDiv_ = calculateNDiv( 2*mtrd.halfZ(), div_.width(), div_.offset() );
325  }
326  else if( divisionType_ == DivNDIV )
327  {
329  }
330  DCOUT_V ('P', " DDDividedTrdY no divisions " << compNDiv_ << " = " << div_.nReplicas() << "\n Offset " << div_.offset() << "\n width " << compWidth_ << " = " << div_.width() << std::endl);
331 }
332 
334 {}
335 
336 double
338 {
339  DDTrap mtrd = (DDTrap)(div_.parent().solid());
340  return 2 * mtrd.halfZ();
341 }
342 
344 DDDividedTrdZ::makeDDTranslation( const int copyNo ) const
345 {
346  DDTrap mtrd = (DDTrap)(div_.parent().solid() );
347  double mdz = mtrd.halfZ();
348 
349  //----- translation
350  double posi = -mdz + div_.offset() + (copyNo+0.5)*compWidth_;
351 
352  DCOUT_V ('P', " DDDividedTrdZ: " << copyNo << "\n Position: z=" << posi << " Axis= " << DDAxesNames::name(div_.axis()) << "\n");
353 
354  if( div_.axis() == z )
355  {
356  return DDTranslation(0.0, 0.0, posi);
357  }
358  else
359  {
360  std::string s = "ERROR - DDDividedTrdZ::makeDDTranslation()";
361  s += "\n Axis is along ";
362  s += DDAxesNames::name(div_.axis());
363  s += " !\n" ;
364  s += "DDDividedTrdY::makeDDTranslation()";
365  s += " IllegalConstruct: Only axes along z are allowed !";
366  throw DDException(s);
367 
368  }
369  return DDTranslation();
370 }
371 
373 DDDividedTrdZ::makeDDRotation( const int copyNo ) const
374 {
375  return DDRotation();
376 }
377 
379 DDDividedTrdZ::makeDDLogicalPart ( const int copyNo ) const
380 {
381  //---- The division along Z of a Trd will result a Trd
382  DDTrap mtrd = (DDTrap)(div_.parent().solid());
383  DDMaterial usemat = div_.parent().material();
384 
385  double pDx1 = mtrd.x1(); //->GetXHalfLength1();
386  //(mtrd->GetXHalfLength2() - mtrd->GetXHalfLength1() );
387  double DDx = (mtrd.x2() - mtrd.x1() );
388  double pDy1 = mtrd.y1(); // ->GetYHalfLength1();
389  //(mtrd->GetYHalfLength2() - mtrd->GetYHalfLength1() );
390  double DDy = (mtrd.y2() - mtrd.y1() );
391  double pDz = compWidth_/2.;
392  double zLength = 2*mtrd.halfZ(); //->GetZHalfLength();
393 
394  // trd.SetAllParameters ( pDx1+DDx*(div_.offset()+copyNo*compWidth_)/zLength,
395  // pDx1+DDx*(div_.offset()+(copyNo+1)*compWidth_)/zLength,
396  // pDy1+DDy*(div_.offset()+copyNo*compWidth_)/zLength,
397  // pDy1+DDy*(div_.offset()+(copyNo+1)*compWidth_)/zLength, pDz );
398 
399  DDName solname(div_.parent().ddname().name() + "_DIVCHILD"
400  + DDXMLElement::itostr(copyNo)
401  , div_.parent().ddname().ns());
402  DDSolid dsol =
403  DDSolidFactory::trap(solname
404  , pDz
405  , 0.*deg
406  , 0.*deg
407  , pDy1+DDy*(div_.offset()+copyNo*compWidth_)/zLength
408  , pDx1+DDx*(div_.offset()+copyNo*compWidth_)/zLength
409  , pDx1+DDx*(div_.offset()+copyNo*compWidth_)/zLength
410  , 0.*deg
411  , pDy1+DDy*(div_.offset()+(copyNo+1)*compWidth_)/zLength
412  , pDx1+DDx*(div_.offset()+(copyNo+1)*compWidth_)/zLength
413  , pDx1+DDx*(div_.offset()+(copyNo+1)*compWidth_)/zLength
414  , 0*deg
415  );
416 
417  DDLogicalPart ddlp(solname, usemat, dsol);
418  DCOUT_V ('P', "DDDividedTrdZ::makeDDLogicalPart lp = " << ddlp);
419  return ddlp;
420 }
421 
422 void
424 {
426 
427  DDTrap mtrd = (DDTrap)(div_.parent().solid());
428 
429  double mpTheta = mtrd.theta();
430  double mpPhi = mtrd.phi();
431  double mpAlpha1 = mtrd.alpha1();
432  double mpAlpha2 = mtrd.alpha2();
433 
434  // mec: we only have traps, not trds in DDD, so I added this check
435  // to make sure it is only a trd (I think! :-))
436  if (mpAlpha1 != 0.*deg || mpAlpha2 != 0.*deg || mpTheta != 0.*deg || mpPhi != 0.*deg)
437  {
438  std::string s = "ERROR - DDDividedTrdZ::checkParametersValidity()";
439  s+= "\n Making a division of a TRD along axis X,";
440  s+= "\n while the theta, phi and aplhpa2 are not zero,";
441  s+= "\n is not (yet) supported. It will result";
442  s+= "\n in non-equal division solids.";
443  throw DDException(s);
444  }
445 }
virtual ~DDDividedTrdX()
Definition: DDDividedTrd.cc:42
double halfZ() const
half of the z-Axis
Definition: DDSolid.cc:170
virtual ~DDDividedTrdZ()
double y2() const
Half-length along y of the face at +pDz.
Definition: DDSolid.cc:184
virtual double getMaxParameter() const
const DDAxes axis() const
Definition: DDDivision.cc:85
DDDividedTrdY(const DDDivision &div, DDCompactView *cpv)
const N & name() const
Definition: DDBase.h:88
const int nReplicas() const
Definition: DDDivision.cc:90
virtual DDLogicalPart makeDDLogicalPart(const int copyNo) const
double alpha1() 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:182
double x2() const
Half-length along x of the side at y=+pDy1 of the face at -pDz.
Definition: DDSolid.cc:180
static std::string itostr(int i)
WARNING: abused by other classes in this system: yet another conversion from int to std::string...
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
int calculateNDiv(double motherDim, double width, double offset) const
An exception for DDD errors.
Definition: DDException.h:23
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:101
virtual DDRotation makeDDRotation(const int copyNo) const
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:18
double alpha2() 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:190
double calculateWidth(double motherDim, int nDiv, double offset) const
virtual void checkParametersValidity()
virtual DDLogicalPart makeDDLogicalPart(const int copyNo) const
Definition: DDDividedTrd.cc:89
type of data representation of DDCompactView
Definition: DDCompactView.h:81
const DDMaterial & material() const
Returns a reference object of the material this LogicalPart is made of.
double double double z
virtual DDLogicalPart makeDDLogicalPart(const int copyNo) const
A DDSolid represents the shape of a part.
Definition: DDSolid.h:42
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:66
DDDividedTrdX(const DDDivision &div, DDCompactView *cpv)
Definition: DDDividedTrd.cc:23
static const double tolerance(void)
double phi() const
Azimuthal angle of the line joining the centres of the faces at -/+pDz.
Definition: DDSolid.cc:174
DDDividedTrdZ(const DDDivision &div, DDCompactView *cpv)
virtual ~DDDividedTrdY()
virtual DDTranslation makeDDTranslation(const int copyNo) const
double theta() const
Polar angle of the line joining the centres of the faces at -/+pDz.
Definition: DDSolid.cc:172
Interface to a Trapezoid.
Definition: DDSolid.h:115
virtual DDRotation makeDDRotation(const int copyNo) const
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:95
virtual double getMaxParameter() const
Definition: DDDividedTrd.cc:46
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:726
double y1() const
Half-length along y of the face at -pDz.
Definition: DDSolid.cc:176
#define DCOUT_V(M_v_Y, M_v_S)
Definition: DDdebug.h:54
double x4() const
Half-length along x of the side at y=+pDy2 of the face at +pDz.
Definition: DDSolid.cc:188
const double width() const
Definition: DDDivision.cc:95
virtual DDRotation makeDDRotation(const int copyNo) const
Definition: DDDividedTrd.cc:83
virtual double getMaxParameter() const
double x3() const
Half-length along x of the side at y=-pDy2 of the face at +pDz.
Definition: DDSolid.cc:186
const DDSolid & solid() const
Returns a reference object of the solid being the shape of this LogicalPart.
const double offset() const
Definition: DDDivision.cc:100
const DDLogicalPart & parent() const
Definition: DDDivision.cc:105
virtual void checkParametersValidity()
virtual DDTranslation makeDDTranslation(const int copyNo) const
Definition: DDDividedTrd.cc:53
string s
Definition: asciidump.py:422
Definition: DDAxes.h:10
static const std::string name(const DDAxes &s)
Definition: DDAxes.cc:37
virtual DDTranslation makeDDTranslation(const int copyNo) const
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
double x1() const
Half-length along x of the side at y=-pDy1 of the face at -pDz.
Definition: DDSolid.cc:178
virtual void checkParametersValidity()
const N & ddname() const
Definition: DDBase.h:90