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