CMS 3D CMS Logo

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 outerRadius,
16  double startPhi,
17  double deltaPhi,
18  double startTheta,
19  double deltaTheta)
21 {
22  p_.emplace_back(innerRadius);
23  p_.emplace_back(outerRadius);
24  p_.emplace_back(startPhi);
25  p_.emplace_back(deltaPhi);
26  p_.emplace_back(startTheta);
27  p_.emplace_back(deltaTheta);
28 }
29 
30 void DDI::Sphere::stream(std::ostream & os) const
31 {
32  os << " innerRadius=" << convertMmToCm( p_[0] )
33  << " outerRadius=" << convertMmToCm( p_[1] )
34  << " startPhi=" << convertRadToDeg( p_[2] )
35  << " deltaPhi=" << convertRadToDeg( p_[3] )
36  << " startTheta=" << convertRadToDeg( p_[4] )
37  << " deltaTheta=" << convertRadToDeg( p_[5] );
38 }
39 
40 double DDI::Sphere::volume() const
41 {
42  double volume(0.);
43  if ( std::fabs(p_[3]) <= 2._pi && std::fabs(p_[5]) <= piRadians ) {
44  volume = std::fabs((p_[1]*p_[1]*p_[1] - p_[0]*p_[0]*p_[0])/3. * (std::cos(p_[4]+p_[5]) - std::cos(p_[4]))*p_[3]);
45  } else if (std::fabs(p_[3]) <= 2._pi && std::fabs(p_[5]) > piRadians ) {
46  volume = std::fabs((p_[1]*p_[1]*p_[1] - p_[0]*p_[0]*p_[0])/3. * (std::cos(p_[4]+p_[5]-180._deg) - std::cos(p_[4]))*p_[3]);
47  } else if (std::fabs(p_[3]) > 2._pi && std::fabs(p_[5]) <= piRadians ) {
48  volume = std::fabs((p_[1]*p_[1]*p_[1] - p_[0]*p_[0]*p_[0])/3. * (std::cos(p_[4]+p_[5]) - std::cos(p_[4]))*(p_[3]-p_[2]));
49  }
50  return volume;
51 }
Sphere(double innerRadius, double outerRadius, double startPhi, double deltaPhi, double startZ, double deltaZ)
Definition: Sphere.cc:14
DDSolidShape
Definition: DDSolidShapes.h:6
constexpr NumType convertRadToDeg(NumType radians)
Definition: GeantUnits.h:98
constexpr long double piRadians(M_PI)
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
void stream(std::ostream &) const override
Definition: Sphere.cc:30
double volume() const override
Definition: Sphere.cc:40
std::vector< double > p_
Definition: Solid.h:32
constexpr NumType convertMmToCm(NumType millimeters)
Definition: GeantUnits.h:110