CMS 3D CMS Logo

Trap.cc
Go to the documentation of this file.
3 
4 #include <cmath>
5 #include <vector>
6 
9 
10 using std::sqrt;
11 using namespace dd::operators;
12 
13 DDI::Trap::Trap( double pDz,
14  double pTheta,
15  double pPhi,
16  double pDy1, double pDx1,double pDx2,
17  double pAlp1,
18  double pDy2, double pDx3, double pDx4,
19  double pAlp2 )
21 {
22  p_.emplace_back(pDz); // ......... 0
23  p_.emplace_back(pTheta); // .. 1
24  p_.emplace_back(pPhi); // ....... 2
25  p_.emplace_back(pDy1); // ........ 3
26  p_.emplace_back(pDx1); // ........ 4
27  p_.emplace_back(pDx2); // ........ 5
28  p_.emplace_back(pAlp1); // ....... 6
29  p_.emplace_back(pDy2); // ........ 7
30  p_.emplace_back(pDx3); // ......... 8
31  p_.emplace_back(pDx4); // ........ 9
32  p_.emplace_back(pAlp2);
33 }
34 
35 
36 void DDI::Trap::stream(std::ostream & os) const
37 {
38  os << " dz=" << CONVERT_TO( p_[0], cm )
39  << " theta=" << CONVERT_TO( p_[1], deg )
40  << " phi=" << CONVERT_TO( p_[2], deg )
41  << " dy1=" << CONVERT_TO( p_[3], cm )
42  << " dx1=" << CONVERT_TO( p_[4], cm )
43  << " dx2=" << CONVERT_TO( p_[5], cm )
44  << " alpha1=" << CONVERT_TO( p_[6], deg )
45  << " dy2=" << CONVERT_TO( p_[7], cm )
46  << " dx3=" << CONVERT_TO( p_[8], cm )
47  << " dx4=" << CONVERT_TO( p_[9], cm )
48  << " alpha2=" << CONVERT_TO( p_[10], deg );
49 }
50 
51 double DDI::Trap::volume() const
52 {
53  double volume = 0;
54 
55  double dz = p_[0]*2.;
56  double dy1 = p_[3]*2.;
57  double dx1 = p_[4]*2.;
58  double dx2 = p_[5]*2.;
59  double dy2 = p_[7]*2.;
60  double dx3 = p_[8]*2.;
61  double dx4 = p_[9]*2.;
62 
63  volume = ((dx1 + dx2 + dx3 + dx4)*(dy1 + dy2) +
64  (dx4 + dx3 - dx2 - dx1)*(dy2 - dy1)/3)*dz*0.125;
65 
66  return volume;
67 }
DDSolidShape
Definition: DDSolidShapes.h:4
#define CONVERT_TO(_x, _y)
Definition: DDUnits.h:6
Trap(double pDz, double pTheta, double pPhi, double pDy1, double pDx1, double pDx2, double pAlp1, double pDy2, double pDx3, double pDx4, double pAlp2)
Definition: Trap.cc:13
void stream(std::ostream &) const override
Definition: Trap.cc:36
T sqrt(T t)
Definition: SSEVec.h:18
double volume() const override
Definition: Trap.cc:51
std::vector< double > p_
Definition: Solid.h:32