16 using namespace geant_units;
17 using namespace geant_units::operators;
22 const std::vector<double>& z,
23 const std::vector<double>& rmin,
24 const std::vector<double>& rmax)
26 p_.emplace_back(sides);
27 p_.emplace_back(startPhi);
28 p_.emplace_back(deltaPhi);
29 if ((z.size() != rmin.size()) || (z.size() != rmax.size())) {
30 throw cms::Exception(
"DDException") <<
"Polyhedra(..): std::vectors z,rmin,rmax not of same length";
32 for (
unsigned int i = 0;
i < z.size(); ++
i) {
33 p_.emplace_back(z[
i]);
34 p_.emplace_back(rmin[i]);
35 p_.emplace_back(rmax[i]);
41 int sides,
double startPhi,
double deltaPhi,
const std::vector<double>& z,
const std::vector<double>&
r)
43 p_.emplace_back(sides);
44 p_.emplace_back(startPhi);
45 p_.emplace_back(deltaPhi);
46 if (z.size() != r.size()) {
47 throw cms::Exception(
"DDException") <<
"Polyhedra(..): std::vectors z,rmin,rmax not of same length";
49 for (
unsigned int i = 0;
i < z.size(); ++
i) {
50 p_.emplace_back(z[
i]);
51 p_.emplace_back(r[i]);
82 int loop = (
p_.size() - 3) / 3 - 1;
84 double a = 0.5 * fabs(
p_[2] /
p_[0]);
86 for (
int j = 3;
j < (loop + 3); ++
j) {
87 double dz = fabs(
p_[i] -
p_[i + 3]);
97 double H1 = (
p_[i + 2] -
p_[i + 1]) *
cos(a);
98 double Bl1 =
p_[i + 1] *
sin(a);
99 double Tl1 =
p_[i + 2] *
sin(a);
101 double H2 = (
p_[i + 5] -
p_[i + 4]) *
cos(a);
102 double Bl2 =
p_[i + 4] *
sin(a);
103 double Tl2 =
p_[i + 5] *
sin(a);
105 double s = (2 * H1 * Bl1 + 2 * H1 * Tl1) * z +
106 (H1 * Bl2 - 2 * H1 * Bl1 + H1 * Tl2 - 2 * H1 * Tl1 + H2 * Bl1 + H2 * Tl1 + H2 * Tl2 - H2 * Tl1) * z +
107 (2 / 3) * (H2 * Bl2 - H2 * Bl1 - H1 * Bl2 + H1 * Bl1 - H1 * Tl2 + H1 * Tl1) * z;
115 int sides = int(
p_[0]);
117 double phiDelta =
p_[2];
128 alpha = fabs(phiDelta);
129 beta = 0.5 * (alpha / sides);
131 while (i < (
p_.size() - 2)) {
139 double volume1 = (rEnd * rEnd + rBegin * rBegin + rBegin * rEnd) * z / 3;
141 volume = volume + volume1;
155 double volume2 = (rEnd * rEnd + rBegin * rBegin + rBegin * rEnd) * z / 3;
157 volume = volume + volume2;
159 volume = fabs(sides *
cos(beta) *
sin(beta) * volume);
167 for (
unsigned k = 3;
k < p_.size(); ++
k)
constexpr NumType convertRadToDeg(NumType radians)
Sin< T >::type sin(const T &t)
Cos< T >::type cos(const T &t)
constexpr NumType convertMmToCm(NumType millimeters)
Polyhedra(int sides, double startPhi, double deltaPhi, const std::vector< double > &z, const std::vector< double > &rmin, const std::vector< double > &rmax)
double volume() const override
DDSolidShape shape() const
void stream(std::ostream &) const override