CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions
DDI::Trap Class Reference

#include <Trap.h>

Inheritance diagram for DDI::Trap:
DDI::Solid

Public Member Functions

void stream (std::ostream &) const
 
 Trap (double pDz, double pTheta, double pPhi, double pDy1, double pDx1, double pDx2, double pAlp1, double pDy2, double pDx3, double pDx4, double pAlp2)
 
double volume () const
 
- Public Member Functions inherited from DDI::Solid
const std::vector< double > & parameters () const
 
void setParameters (std::vector< double > const &p)
 
DDSolidShape shape () const
 
 Solid ()
 
 Solid (DDSolidShape shape)
 
virtual ~Solid ()
 

Additional Inherited Members

- Protected Attributes inherited from DDI::Solid
std::vector< double > p_
 
DDSolidShape shape_
 

Detailed Description

Definition at line 9 of file Trap.h.

Constructor & Destructor Documentation

DDI::Trap::Trap ( double  pDz,
double  pTheta,
double  pPhi,
double  pDy1,
double  pDx1,
double  pDx2,
double  pAlp1,
double  pDy2,
double  pDx3,
double  pDx4,
double  pAlp2 
)

Definition at line 9 of file Trap.cc.

References DDI::Solid::p_.

16  : Solid(ddtrap)
17 {
18  p_.push_back(pDz); // ......... 0
19  p_.push_back(pTheta); // .. 1
20  p_.push_back(pPhi); // ....... 2
21  p_.push_back(pDy1); // ........ 3
22  p_.push_back(pDx1); // ........ 4
23  p_.push_back(pDx2); // ........ 5
24  p_.push_back(pAlp1); // ....... 6
25  p_.push_back(pDy2); // ........ 7
26  p_.push_back(pDx3); // ......... 8
27  p_.push_back(pDx4); // ........ 9
28  p_.push_back(pAlp2);
29 }
Solid()
Definition: Solid.h:14
std::vector< double > p_
Definition: Solid.h:32

Member Function Documentation

void DDI::Trap::stream ( std::ostream &  os) const
virtual

Reimplemented from DDI::Solid.

Definition at line 32 of file Trap.cc.

33 {
34  os << " dz=" << p_[0]/cm
35  << " theta=" << p_[1]/deg
36  << " phi=" << p_[2]/deg
37  << " dy1=" << p_[3]/cm
38  << " dx1=" << p_[4]/cm
39  << " dx2=" << p_[5]/cm
40  << " alpha1=" << p_[6]/deg
41  << " dy2=" << p_[7]/cm
42  << " dx3=" << p_[8]/cm
43  << " dx4=" << p_[9]/cm
44  << " alpha2=" << p_[10]/deg;
45 }
std::vector< double > p_
Definition: Solid.h:32
double DDI::Trap::volume ( void  ) const
virtual

Reimplemented from DDI::Solid.

Definition at line 47 of file Trap.cc.

References funct::A, a, b, DCOUT, mathSSE::sqrt(), and detailsBasic3DVector::z.

48 {
49  double volume=0;
50 
51  /* use notation as described in documentation about geant 3 shapes */
52  /* we do not need all the parameters.*/
53 
54  double Dz=p_[0];
55  double H1=p_[3];
56  double Bl1=p_[4];
57  double Tl1=p_[5];
58  double H2=p_[7];
59  double Bl2=p_[8];
60  double Tl2=p_[9];
61 
62  double z=2*Dz;
63 
64  /* the area of a trapezoid with one side of length 2*Bl1 and other side 2*Tl1, and height 2*H1 is 0.5*(2*Bl1+2*Tl1)*2H1=2*H1(Bl1+Tl1) */
65 
66  /* the volume of a geometry defined by 2 2D parallel trapezoids is (in this case the integral over the area of a trapezoid that is defined as function x between these two trapezoids */
67 
68  /* the following formula describes this parmeterized area in x. x=0: trapezoid defined by H1,Bl1,Tl1, x=z: trapezoid defined by H2,Bl2,Tl2 */
69 
70  /* area(x)=2*(H1+x/z*(H2-H1))*(Bl1+x/z*(Bl2-Bl1)+Tl1+x/z*(Tl2-Tl1)) */
71 
72  /* primitive of area(x):
73  (2*H1*Bl1+2*H1*Tl1)*x+(H1*Bl2-2*H1*Bl1+H1*Tl2-2*H1*Tl1+H2*Bl1+H2*Tl1+H2*Tl2-H2*Tl1)*x*x/z+(2/3)*(H2*Bl2-H2*Bl1-H1*Bl2+H1*Bl1-H1*Tl2+H1*Tl1)*x*x*x/(z*z) */
74 
75 // volume=(2*H1*Bl1+2*H1*Tl1)*z+(H1*Bl2-2*H1*Bl1+H1*Tl2-2*H1*Tl1+H2*Bl1+H2*Tl1+H2*Tl2-H2*Tl1)*z*z+(2/3)*(H2*Bl2-H2*Bl1-H1*Bl2+H1*Bl1-H1*Tl2+H1*Tl1)*z*z*z;
76  volume=(2*H1*Bl1+2*H1*Tl1)*z+(H1*Bl2-2*H1*Bl1+H1*Tl2-2*H1*Tl1+H2*Bl1+H2*Tl1+H2*Tl2-H2*Tl1)*z+(2/3)*(H2*Bl2-H2*Bl1-H1*Bl2+H1*Bl1-H1*Tl2+H1*Tl1)*z;
77 
78 
79  /*
80  Alternative:
81  A ... height of bottom trapez, B ... middle line perpendicular to A
82  a ... height of top trapez, b ... middle line perpendicular to a
83  H ... heigt of the solid
84 
85  V = H/3. * ( A*B + 0.5 * ( A*b + B*a ) + a*b ) <-- this is wrong ..
86  V = H/3 * ( A*B + sqrt( A*B*a*b ) + a*b )
87  */
88  double A = 2.*p_[3];
89  double B = p_[4] + p_[5];
90  double a = 2.*p_[7];
91  double b = p_[8] + p_[9];
92 
93 
94  double volu_alt = 2.*p_[0]/3. * ( A*B + sqrt ( A*b*B*a ) + a*b );
95  DCOUT('V', "alternative-volume=" << volu_alt/m3 << std::endl);
96 
97  //DCOUT_V('C',"DC: solid=" << this->ddname() << " vol=" << volume << " vol_a=" << volu_alt << " d=" << (volume-volu_alt)/volume*100. << "%");
98  return volume;
99 }
double volume() const
Definition: Trap.cc:47
double double double z
T sqrt(T t)
Definition: SSEVec.h:46
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
std::vector< double > p_
Definition: Solid.h:32
#define DCOUT(M_v_Y, M_v_S)
Definition: DDdebug.h:53