5 #include "CLHEP/Units/GlobalSystemOfUnits.h" 6 #include "CLHEP/Units/SystemOfUnits.h" 19 const std::vector<double> &
z,
20 const std::vector<double> & rmin,
21 const std::vector<double> & rmax)
24 p_.emplace_back(sides);
25 p_.emplace_back(startPhi);
26 p_.emplace_back(deltaPhi);
27 if((z.size()!=rmin.size()) || (z.size()!=rmax.size()) )
29 throw cms::Exception(
"DDException") <<
"Polyhedra(..): std::vectors z,rmin,rmax not of same length";
33 for(
unsigned int i=0;
i<z.size(); ++
i)
35 p_.emplace_back(z[
i]);
36 p_.emplace_back(rmin[i]);
37 p_.emplace_back(rmax[i]);
43 const std::vector<double> & z,
46 p_.emplace_back(sides);
47 p_.emplace_back(startPhi);
48 p_.emplace_back(deltaPhi);
49 if(z.size()!=r.size())
51 throw cms::Exception(
"DDException") <<
"Polyhedra(..): std::vectors z,rmin,rmax not of same length";
55 for(
unsigned int i=0;
i<z.size(); ++
i)
57 p_.emplace_back(z[
i]);
58 p_.emplace_back(r[i]);
73 int loop = (
p_.size()-3)/3 -1;
75 double a = 0.5*fabs(
p_[2]/rad /
p_[0]);
77 for (
int j=3; j<(loop+3); ++j)
79 double dz= fabs(
p_[i]-
p_[i+3]);
89 double H1=(
p_[i+2]-
p_[i+1])*
cos(a);
90 double Bl1=
p_[i+1]*
sin(a);
91 double Tl1=
p_[i+2]*
sin(a);
94 double Bl2=
p_[i+4]*
sin(a);
95 double Tl2=
p_[i+5]*
sin(a);
97 double s = (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;
105 int sides=
int(
p_[0]);
107 double phiDelta=
p_[2]/rad;
118 alpha=fabs(phiDelta);
119 beta=0.5*(alpha/sides);
121 while(i<(
p_.size()-2))
130 double volume1=(rEnd*rEnd+rBegin*rBegin+rBegin*rEnd)*z/3;
132 volume=volume+volume1;
146 double volume2=(rEnd*rEnd+rBegin*rBegin+rBegin*rEnd)*z/3;
148 volume=volume+volume2;
150 volume=fabs(sides*
cos(beta)*
sin(beta)*volume);
157 os <<
" sides=" <<
p_[0]
158 <<
" startPhi[deg]=" <<
p_[1]/deg
159 <<
" dPhi[deg]=" <<
p_[2]/deg
161 for (
unsigned k=3;
k<
p_.size(); ++
k)
162 os <<
p_[
k]/cm <<
" ";
void stream(std::ostream &) const override
double volume() const override
Sin< T >::type sin(const T &t)
Cos< T >::type cos(const T &t)
Polyhedra(int sides, double startPhi, double deltaPhi, const std::vector< double > &z, const std::vector< double > &rmin, const std::vector< double > &rmax)
DDSolidShape shape() const