CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Sphere.cc
Go to the documentation of this file.
3 
4 #include <cmath>
5 #include <ostream>
6 #include <vector>
7 
10 
11 using namespace geant_units;
12 using namespace geant_units::operators;
13 
15  double innerRadius, double outerRadius, double startPhi, double deltaPhi, double startTheta, double deltaTheta)
17  p_.emplace_back(innerRadius);
18  p_.emplace_back(outerRadius);
19  p_.emplace_back(startPhi);
20  p_.emplace_back(deltaPhi);
21  p_.emplace_back(startTheta);
22  p_.emplace_back(deltaTheta);
23 }
24 
25 void DDI::Sphere::stream(std::ostream& os) const {
26  os << " innerRadius=" << convertMmToCm(p_[0]) << " outerRadius=" << convertMmToCm(p_[1])
27  << " startPhi=" << convertRadToDeg(p_[2]) << " deltaPhi=" << convertRadToDeg(p_[3])
28  << " startTheta=" << convertRadToDeg(p_[4]) << " deltaTheta=" << convertRadToDeg(p_[5]);
29 }
30 
31 double DDI::Sphere::volume() const {
32  double volume(0.);
33  if (std::fabs(p_[3]) <= 2._pi && std::fabs(p_[5]) <= piRadians) {
34  volume = std::fabs((p_[1] * p_[1] * p_[1] - p_[0] * p_[0] * p_[0]) / 3. *
35  (std::cos(p_[4] + p_[5]) - std::cos(p_[4])) * p_[3]);
36  } else if (std::fabs(p_[3]) <= 2._pi && std::fabs(p_[5]) > piRadians) {
37  volume = std::fabs((p_[1] * p_[1] * p_[1] - p_[0] * p_[0] * p_[0]) / 3. *
38  (std::cos(p_[4] + p_[5] - 180._deg) - std::cos(p_[4])) * p_[3]);
39  } else if (std::fabs(p_[3]) > 2._pi && std::fabs(p_[5]) <= piRadians) {
40  volume = std::fabs((p_[1] * p_[1] * p_[1] - p_[0] * p_[0] * p_[0]) / 3. *
41  (std::cos(p_[4] + p_[5]) - std::cos(p_[4])) * (p_[3] - p_[2]));
42  }
43  return volume;
44 }
Sphere(double innerRadius, double outerRadius, double startPhi, double deltaPhi, double startZ, double deltaZ)
Definition: Sphere.cc:14
void stream(std::ostream &) const override
Definition: Sphere.cc:25
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
double volume() const override
Definition: Sphere.cc:31
constexpr double piRadians(M_PI)
DDSolidShape
Definition: DDSolidShapes.h:6
std::vector< double > p_
Definition: Solid.h:30
constexpr NumType convertMmToCm(NumType millimeters)
Definition: GeantUnits.h:63